Skip to content

Commit

Permalink
Enable co-processors for second core
Browse files Browse the repository at this point in the history
  • Loading branch information
jannic committed Feb 8, 2025
1 parent c046fe2 commit ec185d7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions rp235x-hal/src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ mod inner {
}
t
}

/// Enable co-processors.
///
/// For core0, this is done by the `#[entry]` macro. Fore core1, this function is called
/// from `multicore::Core::spawn`.
///
/// # Safety
///
/// Must only be called immediately after starting up a core.
pub unsafe fn enable_coprocessors() {
unsafe {
(*cortex_m::peripheral::SCB::PTR)
.cpacr
.modify(|value| value | 3 | 3 << 8 | (3 << 20) | (3 << 22))
}
}
}

#[cfg(all(target_arch = "riscv32", target_os = "none"))]
Expand Down
4 changes: 4 additions & 0 deletions rp235x-hal/src/multicore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ fn install_stack_guard(_stack_limit: *mut usize) {
#[inline(always)]
fn core1_setup(stack_limit: *mut usize) {
install_stack_guard(stack_limit);
#[cfg(all(target_arch = "arm", target_os = "none"))]
unsafe {
crate::arch::enable_coprocessors()
};
// TODO: irq priorities
}

Expand Down

0 comments on commit ec185d7

Please sign in to comment.