Skip to main content

warm_boot_entry

Function warm_boot_entry 

Source
pub unsafe extern "C" fn warm_boot_entry(
    context: *const SuspendContext,
) -> !
Expand description

An assembly entry point for warm boot (e.g. resume from suspend).

It will enable the MMU, disable trapping of floating point instructions, set up the exception vector, set the stack pointer to context.stack_ptr, and then jump to context.entry(context.arg).

The function expects to be passed a pointer to a SuspendContext instance that will be valid after resuming from suspend. It should therefore be a static, allocated on the heap, or on the stack of the resuming core, to avoid being deallocated before resuming.

This is a low-level function that should be used as the entry point when manually calling the CPU_SUSPEND PSCI call. It deliberately doesn’t store any data itself so that the caller has maximum flexibility over things such as where the SuspendContext is stored. If you need to restore any state (such as the registers), or you want to emulate returning from a function after suspending the core, you need to implement this functionality yourself in the entry function of the SuspendContext.

§Safety

The caller must ensure that the SuspendContext instance passed to the function will be valid and safe to read when the core resumes, at least until the first call to any Rust function. The best way to do this is to put it on the stack of the core which is resuming, as the stack won’t otherwise be used until after the SuspendContext has been read.

context.stack_ptr must be a valid stack pointer to use for the resuming core. Depending on how you want to handle resuming this could either be the bottom of the stack (if you want to treat resuming like CPU_ON) or the top (if context.entry will restore register state and return from the point where the suspend happened).