Programmer’s Model
ARM DDI 0337G
Copyright © 2005-2008 ARM Limited. All rights reserved.
2-3
Unrestricted Access
Non-Confidential
2.2
Privileged access and user access
Code can execute as privileged or unprivileged. Unprivileged execution limits or
excludes access to some resources. Privileged execution has access to all resources.
Handler mode is always privileged. Thread mode can be privileged or unprivileged.
Thread mode is privileged out of reset, but you can change it to user or unprivileged by
setting the CONTROL[0] bit using the MSR instruction. User access prevents:
•
use of some instructions such as CPS to set FAULTMASK and PRIMASK
•
access to most registers in
System Control Space
(SCS).
When Thread mode has been changed from privileged to user, it cannot change itself
back to privileged. Only a Handler can change the privilege of Thread mode. Handler
mode is always privileged.
2.2.1
Main stack and process stack
Out of reset, all code uses the main stack. An exception handler such as SVC can change
the stack used by Thread mode from main stack to process stack by changing the
EXC_RETURN value it uses on exit. All exceptions continue to use the main stack. The
stack pointer, r13, is a banked register that switches between SP_main and SP_process.
Only one stack, the process stack or the main stack, is visible, using r13, at any time.
It is also possible to switch from main stack to process stack while in Thread mode by
writing to CONTROL[1] using the MSR instruction, in addition to being selectable
using the EXC_RETURN value from an exit from Handler mode.