2.5.8. Execution mode considerations

You must consider in what mode the main application is to run. Your choice affects how you implement system initialization.

Much of the functionality that you are likely to implement at startup, both in the reset handler and $Sub$$main, can only be done while executing in privileged modes, for example, on-chip memory manipulation, and enabling interrupts.

If you want to run your application in a privileged mode (for example, Supervisor), this is not an issue. Ensure that you change to the appropriate mode before exiting your reset handler.

If you want to run your application in User mode, however, you can only change to User mode after completing the necessary tasks in a privileged mode. The most likely place to do this is in $Sub$$main().

Note

__user_initial_stackheap() must set up the application mode stack. Because of this, you must exit your reset handler in system mode, which uses the User mode registers. __user_initial_stackheap() then executes in system mode, and so the application stack and heap are still set up when User mode is entered.

Copyright © 2002-2006 ARM Limited. All rights reserved.ARM DUI 0203G
Non-Confidential