1 /*****************************************************************************
\r
2 * Copyright (c) 2009 Rowley Associates Limited. *
\r
4 * This file may be distributed under the terms of the License Agreement *
\r
5 * provided with this software. *
\r
7 * THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING THE *
\r
8 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *
\r
9 *****************************************************************************/
\r
11 /*****************************************************************************
\r
12 * Preprocessor Definitions
\r
13 * ------------------------
\r
16 * Defines the application entry point function, if undefined this setting
\r
17 * defaults to "main".
\r
21 * If defined, thread mode will be configured to use the process stack if
\r
22 * the size of the process stack is greater than zero bytes in length.
\r
26 * If defined, the contents of the stack will be initialized to a the
\r
32 * - argc, argv are setup by the debug_getargs.
\r
33 * - the exit symbol is defined and executes on return from main.
\r
34 * - the exit symbol calls destructors, atexit functions and then debug_exit.
\r
36 * If not defined then
\r
37 * - argc and argv are zero.
\r
38 * - no exit symbol, code loops on return from main.
\r
39 *****************************************************************************/
\r
41 #ifndef APP_ENTRY_POINT
\r
42 #define APP_ENTRY_POINT main
\r
46 #define ARGSSPACE 128
\r
51 .extern APP_ENTRY_POINT
\r
56 .section .init, "ax"
\r
63 ldr r1, =__stack_end__
\r
66 #ifdef INITIALIZE_STACK
\r
68 ldr r0, =__stack_start__
\r
75 #ifdef USE_PROCESS_STACK
\r
76 /* Set up process stack if size > 0 */
\r
77 ldr r1, =__stack_process_end__
\r
78 ldr r0, =__stack_process_start__
\r
84 #ifdef INITIALIZE_STACK
\r
90 /* Copy initialised memory sections into RAM (if necessary). */
\r
91 ldr r0, =__data_load_start__
\r
92 ldr r1, =__data_start__
\r
93 ldr r2, =__data_end__
\r
95 ldr r0, =__text_load_start__
\r
96 ldr r1, =__text_start__
\r
97 ldr r2, =__text_end__
\r
99 ldr r0, =__fast_load_start__
\r
100 ldr r1, =__fast_start__
\r
101 ldr r2, =__fast_end__
\r
103 ldr r0, =__ctors_load_start__
\r
104 ldr r1, =__ctors_start__
\r
105 ldr r2, =__ctors_end__
\r
107 ldr r0, =__dtors_load_start__
\r
108 ldr r1, =__dtors_start__
\r
109 ldr r2, =__dtors_end__
\r
111 ldr r0, =__rodata_load_start__
\r
112 ldr r1, =__rodata_start__
\r
113 ldr r2, =__rodata_end__
\r
116 /* Zero the bss. */
\r
117 ldr r0, =__bss_start__
\r
118 ldr r1, =__bss_end__
\r
122 /* Initialise the heap */
\r
123 ldr r0, = __heap_start__
\r
124 ldr r1, = __heap_end__
\r
131 /* Call constructors */
\r
132 ldr r0, =__ctors_start__
\r
133 ldr r1, =__ctors_end__
\r
145 /* Setup initial call frame */
\r
151 /* Jump to application entry point */
\r
152 #ifdef FULL_LIBRARY
\r
155 ldr r2, =debug_getargs
\r
162 ldr r2, =APP_ENTRY_POINT
\r
165 #ifdef FULL_LIBRARY
\r
168 mov r5, r0 // save the exit parameter/return result
\r
170 /* Call destructors */
\r
171 ldr r0, =__dtors_start__
\r
172 ldr r1, =__dtors_end__
\r
184 /* Call atexit functions */
\r
185 ldr r2, =_execute_at_exit_fns
\r
188 /* Call debug_exit with return result/exit parameter */
\r
190 ldr r2, =debug_exit
\r
194 /* Returned from application entry point, loop forever. */
\r
222 #ifdef FULL_LIBRARY
\r