When the Raspberry Pi is turned on, the ARM SoC starts at the upper-most Exception Level 3 (EL3 – Secure Mode). However, during initialisation the Raspberry Pi drops the ARM to Exception Level 2 (EL2 – Hypervisor).
Recall that the Exception Levels on the ARM are:
- EL3 (Secure)
- EL2 (Hypervisor)
- EL1 (Supervisor)
- EL0 (User)
With a typical Operating System, only the lower two levels (EL1 and EL0) are of real interest: EL1 is the Supervisor level – a privileged level that the kernel operates under – while EL0 is the User level (the “unprivileged” level for hosting user programs).
It is understood that the Raspberry Pi drops the ARM from EL3 to EL2 as Linux in particular is not suited for launching from such a high Exception Level. But whilst this is fine for Linux, for IMP OS this is currently a bit of a pain:
Specifically, there are various registers that need to be configured to ensure that memory management can happen successfully. This requires registers at the EL2 level to be configured, but these can only be set via EL3.
As a result,
armstubs is used. The repository
armstubs is taken from the Raspberry Pi Foundation’s repository. It allows a small
armstubs.bin file to be placed on the boot-up filesystem. Upon seeing this, the Raspberry Pi will run it as part of its final stages. It effectively allows for the Raspberry Pi to avoid dropping from EL3 to EL2 before running 3rd party code. This is what is required to ensure IMP OS can initialise itself successfully.