The processor supports two separate stacks:
- Process stack
You can configure Thread mode to use either SP_process or SP_main for its Stack Pointer (SP).
This is only available if the OS extension option is implemented. Contact your implementation team for information.
- Main stack
Handler mode uses the main stack. SP_main is the SP register for the main stack. Thread mode uses SP_main out of reset.
Only one Stack Pointer register, SP_process or SP_main, is visible at any time, using R13.
When a thread is pre-empted, its context is automatically saved onto the stack that was active at the time the exception was recognized.
If an exception pre-empts Thread mode, the context of the pre-empted thread can be stacked using SP_process or SP_main depending on the value of the CONTROL bit.
If an exception pre-empts another exception handler running in Handler mode, the pre-empted context can only be stacked using SP_main because this is the only stack pointer that can be active in Handler mode.
On exception return, the EXC_RETURN value determines which stack is used for the unstacking of context. The EXC_RETURN value loaded into R14 during exception entry points to the same stack that was used to stack the context. If your exception handler code moves the stack, you must ensure that the EXC_RETURN value used for exception return is correctly updated.
All exception handlers must use SP_main for their local variables.
When the OS extension option is implemented:
you can configure Thread mode to use the process stack
exception handlers always use SP_main.
MRS instructions have visibility
of both stack pointers.