In baremetal boot code implementation https://developer.arm.com/documentation/dai0527/a , it is explained that depending on the SOC implementation, if the ARMv8 comes out on reset as EL3, AArch64 configuration, then it is possible to drop down to EL0, AArch32 in startup code.
This looks fine for boot code. But can this be reverted back in the bootable image (bootloader).
The boot code after initializing the core in AARCH32 state and initializing the incoming boot loader stream , will be jumping into the entry point of application.
What restriction does it add in the bootable application execution state? Does this has to be AARCH32 only?
Or can be changed to AARCH64 state by reverting the changes from AARCH32 EL0 to AARCH64/AARCH32 (EL1/EL2 etc) in startup code?
Your bootable application could go back to EL1/EL2 at the end of its execution.
Going from 32b EL0 to EL1 is typically done with an AArch32 SVC instruction.
64b EL1 can call EL2 with an AArch64 HVC instruction.
64b EL1/EL2 can call EL3 with an AArch64 SMC instruction.
(See AArch64 Exceptions.)
Your EL3 bootloader will need to install the proper exception handlers in EL3/EL2/EL1 before running the bootable application.
View all questions in Cortex-A / A-Profile forum