Skip to main content

enter_privileged_psp

Function enter_privileged_psp 

Source
pub unsafe fn enter_privileged_psp(
    psp: *const u32,
    entry: extern "C" fn() -> !,
) -> !
Expand description

Switch to using the Process Stack, but remain in Privileged Mode

Sets CONTROL.SPSEL (setting the Process Stack to be the active stack) but leaves CONTROL.nPRIV alone, updates the program stack pointer to the address in psp, then jumps to the address in entry.

ยงSafety

  • psp and entry must point to valid stack memory and executable code, respectively.
  • psp must be 8 bytes aligned and point to stack top as stack grows towards lower addresses.
  • The size of the stack provided here must be large enough for your program - stack overflows are obviously UB. If your processor supports it, you may wish to set the PSPLIM register to guard against this.