Skip to main content

enter_unprivileged_psp

Function enter_unprivileged_psp 

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

Switch to unprivileged mode using the Process Stack

Sets CONTROL.SPSEL (setting the Process Stack to be the active stack) and CONTROL.nPRIV (setting unprivileged mode), 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.