2.5.7. Hardware initialization

In general, it is beneficial to separate all system initialization code from the main application. However, some components of system initialization, for example, enabling of caches and interrupts, must occur after executing C library initialization code.

You can make use of the $Sub and $Super function wrapper symbols to (effectively) insert a routine that is executed immediately before entering the main application. This mechanism enables you to extend functions without altering the source code.

Example 2.12 shows how $Sub and $Super can be used in this way. The linker replaces the function call to main() with a call to $Sub$$main(). From there you can call a routine that enables caches and another to enable interrupts.

The code branches to the real main() by calling $Super$$main().

Note

For more information on $Sub and $Super, see RealView Compilation Tools v3.0 Linker and Utilities Guide.

Example 2.12. Use of $Sub and $Super

extern void $Super$$main(void);

void $Sub$$main(void)
{
    cache_enable();    // enables caches
    int_enable(); 		     // enables interrupts 
    $Super$$main();    // calls original main()
}
Copyright © 2002-2006 ARM Limited. All rights reserved.ARM DUI 0203G
Non-Confidential