OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [CORTEX_LM3Sxxxx_Rowley/] [thumb_crt0.s] - Blame information for rev 623

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 581 jeremybenn
/*****************************************************************************
2
 * Copyright (c) 2009 Rowley Associates Limited.                             *
3
 *                                                                           *
4
 * This file may be distributed under the terms of the License Agreement     *
5
 * provided with this software.                                              *
6
 *                                                                           *
7
 * THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING THE   *
8
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *
9
 *****************************************************************************/
10
 
11
/*****************************************************************************
12
 *                           Preprocessor Definitions
13
 *                           ------------------------
14
 * APP_ENTRY_POINT
15
 *
16
 *   Defines the application entry point function, if undefined this setting
17
 *   defaults to "main".
18
 *
19
 * USE_PROCESS_STACK
20
 *
21
 *   If defined, thread mode will be configured to use the process stack if
22
 *   the size of the process stack is greater than zero bytes in length.
23
 *
24
 * INITIALIZE_STACK
25
 *
26
 *   If defined, the contents of the stack will be initialized to a the
27
 *   value 0xCC.
28
 *
29
 * FULL_LIBRARY
30
 *
31
 *  If defined then
32
 *    - argc, argv are setup by the debug_getargs.
33
 *    - the exit symbol is defined and executes on return from main.
34
 *    - the exit symbol calls destructors, atexit functions and then debug_exit.
35
 *
36
 *  If not defined then
37
 *    - argc and argv are zero.
38
 *    - no exit symbol, code loops on return from main.
39
 *****************************************************************************/
40
 
41
#ifndef APP_ENTRY_POINT
42
#define APP_ENTRY_POINT main
43
#endif
44
 
45
#ifndef ARGSSPACE
46
#define ARGSSPACE 128
47
#endif
48
 
49
  .global _start
50
  .syntax unified
51
  .extern APP_ENTRY_POINT
52
#ifdef FULL_LIBRARY
53
  .global exit
54
#endif
55
 
56
  .section .init, "ax"
57
  .code 16
58
  .align 2
59
  .thumb_func
60
 
61
_start:
62
#ifdef __RAM_BUILD
63
  ldr r1, =__stack_end__
64
  mov sp, r1
65
#endif
66
#ifdef INITIALIZE_STACK
67
  mov r2, #0xCC
68
  ldr r0, =__stack_start__
69
#ifndef __RAM_BUILD
70
  mov r1, sp
71
#endif
72
  bl memory_set
73
#endif
74
 
75
#ifdef USE_PROCESS_STACK
76
  /* Set up process stack if size > 0 */
77
  ldr r1, =__stack_process_end__
78
  ldr r0, =__stack_process_start__
79
  subs r2, r1, r0
80
  beq 1f
81
  msr psp, r1
82
  mov r2, #2
83
  msr control, r2
84
#ifdef INITIALIZE_STACK
85
  mov r2, #0xCC
86
  bl memory_set
87
#endif
88
1:
89
#endif
90
  /* Copy initialised memory sections into RAM (if necessary). */
91
  ldr r0, =__data_load_start__
92
  ldr r1, =__data_start__
93
  ldr r2, =__data_end__
94
  bl memory_copy
95
  ldr r0, =__text_load_start__
96
  ldr r1, =__text_start__
97
  ldr r2, =__text_end__
98
  bl memory_copy
99
  ldr r0, =__fast_load_start__
100
  ldr r1, =__fast_start__
101
  ldr r2, =__fast_end__
102
  bl memory_copy
103
  ldr r0, =__ctors_load_start__
104
  ldr r1, =__ctors_start__
105
  ldr r2, =__ctors_end__
106
  bl memory_copy
107
  ldr r0, =__dtors_load_start__
108
  ldr r1, =__dtors_start__
109
  ldr r2, =__dtors_end__
110
  bl memory_copy
111
  ldr r0, =__rodata_load_start__
112
  ldr r1, =__rodata_start__
113
  ldr r2, =__rodata_end__
114
  bl memory_copy
115
 
116
  /* Zero the bss. */
117
  ldr r0, =__bss_start__
118
  ldr r1, =__bss_end__
119
  mov r2, #0
120
  bl memory_set
121
 
122
  /* Initialise the heap */
123
  ldr r0, = __heap_start__
124
  ldr r1, = __heap_end__
125
  sub r1, r1, r0
126
  mov r2, #0
127
  str r2, [r0]
128
  add r0, r0, #4
129
  str r1, [r0]
130
 
131
  /* Call constructors */
132
  ldr r0, =__ctors_start__
133
  ldr r1, =__ctors_end__
134
ctor_loop:
135
  cmp r0, r1
136
  beq ctor_end
137
  ldr r2, [r0]
138
  add r0, #4
139
  push {r0-r1}
140
  blx r2
141
  pop {r0-r1}
142
  b ctor_loop
143
ctor_end:
144
 
145
  /* Setup initial call frame */
146
  mov r0, #0
147
  mov lr, r0
148
  mov r12, sp
149
 
150
start:
151
  /* Jump to application entry point */
152
#ifdef FULL_LIBRARY
153
  mov r0, #ARGSSPACE
154
  ldr r1, =args
155
  ldr r2, =debug_getargs
156
  blx r2
157
  ldr r1, =args
158
#else
159
  mov r0, #0
160
  mov r1, #0
161
#endif
162
  ldr r2, =APP_ENTRY_POINT
163
  blx r2
164
 
165
#ifdef FULL_LIBRARY
166
  .thumb_func
167
exit:
168
  mov r5, r0 // save the exit parameter/return result
169
 
170
  /* Call destructors */
171
  ldr r0, =__dtors_start__
172
  ldr r1, =__dtors_end__
173
dtor_loop:
174
  cmp r0, r1
175
  beq dtor_end
176
  ldr r2, [r0]
177
  add r0, #4
178
  push {r0-r1}
179
  blx r2
180
  pop {r0-r1}
181
  b dtor_loop
182
dtor_end:
183
 
184
  /* Call atexit functions */
185
  ldr r2, =_execute_at_exit_fns
186
  blx r2
187
 
188
  /* Call debug_exit with return result/exit parameter */
189
  mov r0, r5
190
  ldr r2, =debug_exit
191
  blx r2
192
#endif
193
 
194
  /* Returned from application entry point, loop forever. */
195
exit_loop:
196
  b exit_loop
197
 
198
memory_copy:
199
  cmp r0, r1
200
  beq 2f
201
  subs r2, r2, r1
202
  beq 2f
203
1:
204
  ldrb r3, [r0]
205
  add r0, r0, #1
206
  strb r3, [r1]
207
  add r1, r1, #1
208
  subs r2, r2, #1
209
  bne 1b
210
2:
211
  bx lr
212
 
213
memory_set:
214
  cmp r0, r1
215
  beq 1f
216
  strb r2, [r0]
217
  add r0, r0, #1
218
  b memory_set
219
1:
220
  bx lr
221
 
222
#ifdef FULL_LIBRARY
223
  .bss
224
args:
225
  .space ARGSSPACE
226
#endif
227
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.