Operating mode is a term used to describe the state of a microcontroller and the resources and instructions that are available to it. ARM microcontrollers have several operating modes that are used to control the access to certain resources and to protect the system from unauthorized access.

Before the introduction of Security Extentions, the ARM architecture have 7 processor modes. Out of these seven modes, six modes are the privileged modes and one non-privileged user mode.

  • Privilege is the ability to perform certain tasks that cannot be done from User (Unprivileged) mode.
  • In Unprivileged mode, there are limitations on operations that affect overall system configuration, for example, MMU configuration and cache operations. The normal code runs in this User (Unprivileged) mode.
image 4
Credit: https://developer.arm.com
  1. User mode User mode is a normal operating mode in ARM microcontrollers that is used for most applications. In user mode, the microcontroller has access to a limited set of resources and instructions and is not able to access certain privileged resources or execute certain privileged instructions. User mode is typically the default operating mode for most applications, and it is used to execute the main program code. User mode has a lower priority than other operating modes, such as supervisor mode or interrupt mode, and will be interrupted if a higher-priority interrupt or exception occurs.

The specific resources and instructions that are available in user mode will depend on the specific microcontroller model and the configuration of the system. In general, user mode provides access to the general-purpose registers (R0-R15), the main program memory, and a subset of the microcontroller’s instructions. It may also provide access to certain memory-mapped I/O registers, depending on the system configuration. User mode is typically used to execute the main program code and to perform tasks that do not require access to privileged resources or instructions. It is important to carefully design the system to ensure that user mode code does not attempt to access protected resources or execute privileged instructions, as this can result in an exception or fault.

  1. System mode (SYS)– System mode is an operating mode in ARM microcontrollers that is used for accessing system resources such as memory-mapped I/O registers. In system mode, the microcontroller has access to a broader set of resources and instructions than in user mode, but it is still not able to access certain privileged resources or execute certain privileged instructions. System mode is typically used for operating system tasks and for accessing system resources that are not available in user mode. It has a higher priority than user mode, but a lower priority than supervisor mode or interrupt mode.

The specific resources and instructions that are available in system mode will depend on the specific microcontroller model and the configuration of the system. In general, system mode provides access to the general-purpose registers (R0-R15), the main program memory, and a broader set of the microcontroller’s instructions than user mode. It also provides access to certain memory-mapped I/O registers that are not available in user mode. System mode is typically used to access system resources such as memory-mapped I/O registers, to perform operating system tasks, and to handle exceptions and faults. It is important to carefully design the system to ensure that system mode code does not attempt to access protected resources or execute privileged instructions, as this can result in an exception or fault.

  1. Fast Interrupt Mode(FIQ)- FIQ mode (Fast Interrupt Request mode) is a special operating mode in ARM microcontrollers that is used for handling high-priority interrupts. In FIQ mode, the microcontroller has access to a limited set of resources and instructions and is not able to access certain privileged resources or execute certain privileged instructions.

FIQ mode has a higher priority than other operating modes, including user mode, system mode, and supervisor mode. When an interrupt occurs in FIQ mode, the microcontroller will immediately stop executing the current task and begin executing the interrupt service routine (ISR) associated with the interrupt. The specific resources and instructions that are available in FIQ mode will depend on the specific microcontroller model and the configuration of the system. In general, FIQ mode provides access to a subset of the general-purpose registers (R0-R7), the program memory, and a limited set of instructions. It may also provide access to certain memory-mapped I/O registers, depending on the system configuration.

FIQ mode is typically used for handling high-priority interrupts that require a fast response time, such as interrupts associated with real-time systems or critical system events. It is important to carefully design the system to ensure that FIQ mode code executes as quickly as possible and does not perform any unauthorized or unsafe operations.

  1. Interrupt Mode (IRQ)- Interrupt mode is a special operating mode in ARM microcontrollers that is entered when the microcontroller is servicing an interrupt. When an interrupt occurs, the microcontroller saves its current state and then jumps to the start of the interrupt service routine (ISR) to begin executing the ISR code.

While the microcontroller is in interrupt mode, it is executing the ISR code and is not executing the main program. The microcontroller remains in interrupt mode until the ISR is finished, at which point it restores its previous state and resumes execution of the main program. There are several important features of interrupt mode in ARM microcontrollers:

  1. Interrupt mode has a higher priority than other operating modes. When an interrupt occurs, the microcontroller will immediately stop executing the main program and begin executing the ISR, even if the main program is in the middle of executing a critical section of code.
  2. The microcontroller may have multiple interrupts with different priorities. In this case, the microcontroller will service the highest-priority interrupt first and then return to the main program. If another interrupt occurs while the microcontroller is in interrupt mode, it will be serviced after the current interrupt is finished.
  3. The microcontroller may be configured to allow nested interrupts. This means that an interrupt can be serviced while the microcontroller is already in interrupt mode, resulting in multiple nested interrupts. In this case, the microcontroller will keep track of the interrupt state and return to the correct interrupt when all nested interrupts are finished.
  4. The microcontroller may have special registers that are used to manage interrupts. For example, the interrupt priority mask register (PRIMASK) is used to globally enable or disable interrupts, and the interrupt control and state register (ICSR) is used to enable specific interrupts and to determine the cause of an interrupt.
  1. Supervisor mode (SVC)- Supervisor mode is a special operating mode in ARM microcontrollers that is used for executing privileged instructions and accessing protected resources. Supervisor mode has a higher priority than user mode and can be entered from user mode or from other operating modes such as system mode or interrupt mode. In supervisor mode, the microcontroller has access to a wider range of resources and instructions than it does in user mode. This includes access to certain privileged resources and instructions that are not available in user mode.

The specific resources and instructions that are available in supervisor mode will depend on the specific microcontroller model and the configuration of the system. In general, supervisor mode provides access to the same resources and instructions as user mode, as well as additional resources such as memory-mapped I/O registers and certain privileged instructions. Supervisor mode is typically used for tasks such as handling exceptions and interrupts, and performing system-level operations such as resetting the microcontroller or changing the operating mode. It may also be used for operating system tasks, such as managing system resources or scheduling tasks.

  1. Abort mode (ABT) – Abort mode is a special operating mode in ARM microcontrollers that is entered when the microcontroller detects an error, such as an attempted access to a protected resource. In abort mode, the microcontroller has access to a limited set of resources and instructions, and is not able to access certain privileged resources or execute certain privileged instructions.

Abort mode has a higher priority than other operating modes, including user mode, system mode, and supervisor mode. When the microcontroller enters abort mode, it will immediately stop executing the current task and begin executing the abort handler code. The specific resources and instructions that are available in abort mode will depend on the specific microcontroller model and the configuration of the system. In general, abort mode provides access to a subset of the general-purpose registers (R0-R7), the program memory, and a limited set of instructions. It may also provide access to certain memory-mapped I/O registers, depending on the system configuration.

Abort mode is typically used for handling errors and exceptions that occur during the execution of a program. It may be used to report the error to the system, log the error, or take corrective action to prevent further errors from occurring.

  1. Undefined mode (UND)- Undefined mode is a special operating mode in ARM microcontrollers that is entered when the microcontroller executes an undefined instruction. In undefined mode, the microcontroller has access to a limited set of resources and instructions, and is not able to access certain privileged resources or execute certain privileged instructions.

Undefined mode has a higher priority than other operating modes, including user mode, system mode, and supervisor mode. When the microcontroller enters undefined mode, it will immediately stop executing the current task and begin executing the undefined instruction handler code.

The specific resources and instructions that are available in undefined mode will depend on the specific microcontroller model and the configuration of the system. In general, undefined mode provides access to a subset of the general-purpose registers (R0-R7), the program memory, and a limited set of instructions. It may also provide access to certain memory-mapped I/O registers, depending on the system configuration.

Undefined mode is typically used for handling errors that occur when the microcontroller executes an undefined instruction. It may be used to report the error to the system, log the error, or take corrective action to prevent further errors from occurring.

  1. Monitor Mode (MON):
tz jpg

The introduction of the TrustZone Security Extensions created two security states for the processor that are independent of Privilege and processor mode, with a new Monitor mode to act as a gateway between the Secure and Non-secure states and modes existing independently for each security state. Click here to read more about TrustZone.

  1. Hypervisor mode (HYP): The ARMv7-A architecture Virtualization Extensions add a hypervisor mode, in addition to the existing privileged modes. Virtualization enables more than one Operating System to co-exist and operate on the same system. The ARM Virtualization Extensions therefore makes it possible to operate multiple Operating Systems on the same platform.

So, the below image describes all the 9 operation modes

image 5
Credit: http://developer.arm.com

The Operating System (e.g. Linux) runs in Non-secure state. The Application specific firmware will be able to enter into the Secure state. In some cases, software running in the Secure state is even more privileged than that running in Non-secure.

The current processor mode and execution state is contained in the Current Program Status Register (CPSR). Changing processor state and modes can be either explicit by privileged software, or as a result of taking exceptions link to relevant section.

Please click here to read more on this topic. This will take you to ARM webpage.