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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [lwIP_Demo_Rowley_ARM7/] [crt0.s] - Blame information for rev 867

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

Line No. Rev Author Line
1 583 jeremybenn
/*****************************************************************************
2
 * Copyright (c) 2001, 2002 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
  .section .init, "ax"
11
  .code 32
12
  .align 0
13
 
14
  .weak _start
15
  .global __start
16
  .global __gccmain
17
  .extern main
18
  .extern exit
19
 
20
/*****************************************************************************
21
 * Function    : _start                                                      *
22
 * Description : Main entry point and startup code for C system.             *
23
 *****************************************************************************/
24
_start:
25
__start:
26
  mrs r0, cpsr
27
  bic r0, r0, #0x1F
28
 
29
  /* Setup stacks */
30
  orr r1, r0, #0x1B /* Undefined mode */
31
  msr cpsr_cxsf, r1
32
  ldr sp, =__stack_und_end__
33
 
34
  orr r1, r0, #0x17 /* Abort mode */
35
  msr cpsr_cxsf, r1
36
  ldr sp, =__stack_abt_end__
37
 
38
  orr r1, r0, #0x12 /* IRQ mode */
39
  msr cpsr_cxsf, r1
40
  ldr sp, =__stack_irq_end__
41
 
42
  orr r1, r0, #0x11 /* FIQ mode */
43
  msr cpsr_cxsf, r1
44
  ldr sp, =__stack_fiq_end__
45
 
46
  orr r1, r0, #0x13 /* Supervisor mode */
47
  msr cpsr_cxsf, r1
48
  ldr sp, =__stack_svc_end__
49
#ifdef SUPERVISOR_START
50
  /* Start application in supervisor mode */
51
  ldr r1, =__stack_end__ /* Setup user/system mode stack */
52
  mov r2, sp
53
  stmfd r2!, {r1}
54
  ldmfd r2, {sp}^
55
#else
56
  /* Start application in system mode */
57
  orr r1, r0, #0x1F /* System mode */
58
  msr cpsr_cxsf, r1
59
  ldr sp, =__stack_end__
60
#endif
61
 
62
  /* Copy from initialised data section to data section (if necessary). */
63
  ldr r0, =__data_load_start__
64
  ldr r1, =__data_start__
65
  cmp r0, r1
66
  beq copy_data_end
67
 
68
  ldr r2, =__data_end__
69
  subs r2, r2, r1
70
  beq copy_data_end
71
 
72
copy_data_loop:
73
  ldrb r3, [r0], #+1
74
  strb r3, [r1], #+1
75
  subs r2, r2, #1
76
  bne copy_data_loop
77
copy_data_end:
78
 
79
  /* Copy from initialised text section to text section (if necessary). */
80
  ldr r0, =__text_load_start__
81
  ldr r1, =__text_start__
82
  cmp r0, r1
83
  beq copy_text_end
84
 
85
  ldr r2, =__text_end__
86
  subs r2, r2, r1
87
  beq copy_text_end
88
 
89
copy_text_loop:
90
  ldrb r3, [r0], #+1
91
  strb r3, [r1], #+1
92
  subs r2, r2, #1
93
  bne copy_text_loop
94
copy_text_end:
95
 
96
  /* Copy from initialised fast_text section to fast_text section (if necessary). */
97
  ldr r0, =__fast_load_start__
98
  ldr r1, =__fast_start__
99
  cmp r0, r1
100
  beq copy_fast_end
101
 
102
  ldr r2, =__fast_end__
103
  subs r2, r2, r1
104
  beq copy_fast_end
105
 
106
copy_fast_loop:
107
  ldrb r3, [r0], #+1
108
  strb r3, [r1], #+1
109
  subs r2, r2, #1
110
  bne copy_fast_loop
111
copy_fast_end:
112
 
113
  /* Zero the bss. */
114
  ldr r0, =__bss_start__
115
  ldr r1, =__bss_end__
116
  mov r2, #0
117
zero_bss_loop:
118
  cmp r0, r1
119
  beq zero_bss_end
120
  strb r2, [r0], #+1
121
  b zero_bss_loop
122
zero_bss_end:
123
 
124
#ifdef CHECK
125
  /* Check data */
126
  ldr r0, =__data_load_start__
127
  ldr r1, =__data_start__
128
  cmp r0, r1
129
  beq check_data_end
130
  ldr r2, =__data_end__
131
  subs r2, r2, r1
132
  beq check_data_end
133
 
134
check_data_loop:
135
  ldrb r3, [r0], #+1
136
  ldrb r4, [r1], #+1
137
  cmp r3, r4
138
  bne data_error_loop
139
  subs r2, r2, #1
140
  bne check_data_loop
141
check_data_end:
142
 
143
  /* Check text */
144
  ldr r0, =__text_load_start__
145
  ldr r1, =__text_start__
146
  cmp r0, r1
147
  beq check_text_end
148
  ldr r2, =__text_end__
149
  subs r2, r2, r1
150
  beq check_text_end
151
 
152
check_text_loop:
153
  ldrb r3, [r0], #+1
154
  ldrb r4, [r1], #+1
155
  cmp r3, r4
156
  bne text_error_loop
157
  subs r2, r2, #1
158
  bne check_text_loop
159
check_text_end:
160
 
161
  /* Check fast */
162
  ldr r0, =__fast_load_start__
163
  ldr r1, =__fast_start__
164
  cmp r0, r1
165
  beq check_fast_end
166
  ldr r2, =__fast_end__
167
  subs r2, r2, r1
168
  beq check_fast_end
169
 
170
check_fast_loop:
171
  ldrb r3, [r0], #+1
172
  ldrb r4, [r1], #+1
173
  cmp r3, r4
174
  bne fast_error_loop
175
  subs r2, r2, #1
176
  bne check_fast_loop
177
check_fast_end:
178
 
179
  /* Check bss */
180
  ldr r0, =__bss_start__
181
  ldr r1, =__bss_end__
182
  mov r2, #0
183
check_bss_loop:
184
  cmp r0, r1
185
  beq check_bss_end
186
  ldrb r2, [r0], #+1
187
  cmp r2, #0
188
  bne bss_error_loop
189
  b check_bss_loop
190
check_bss_end:
191
#endif
192
 
193
  /* Initialise the heap */
194
  ldr r0, = __heap_start__
195
  ldr r1, = __heap_end__
196
  sub r1, r1, r0     /* r1 = r1-r0 */
197
  mov r2, #0
198
  str r2, [r0], #+4 /* *r0++ = 0 */
199
  str r1, [r0]      /* *r0 = __heap_end__ - __heap_start__ */
200
 
201
  /* Call constructors */
202
  ldr r0, =__ctors_start__
203
  ldr r1, =__ctors_end__
204
ctor_loop:
205
  cmp r0, r1
206
  beq ctor_end
207
  ldr r2, [r0], #+4
208
  stmfd sp!, {r0-r1}
209
  mov lr, pc
210
  mov pc, r2
211
  ldmfd sp!, {r0-r1}
212
  b ctor_loop
213
ctor_end:
214
 
215
  /* Setup initial call frame */
216
  mov lr, #4
217
  mov r12, sp
218
  stmfd sp!, {r11-r12, lr-pc}
219
  sub r11, r12, #0x00000004
220
 
221
start:
222
  /* Jump to main entry point */
223
  mov r0, #0
224
  mov r1, #0
225
  ldr r2, =main
226
  mov lr, pc
227
#ifdef __ARM_ARCH_3__
228
  mov pc, r2
229
#else
230
  bx r2
231
#endif
232
 
233
  /* Call destructors */
234
  ldr r0, =__dtors_start__
235
  ldr r1, =__dtors_end__
236
dtor_loop:
237
  cmp r0, r1
238
  beq dtor_end
239
  ldr r2, [r0], #+4
240
  stmfd sp!, {r0-r1}
241
  mov lr, pc
242
  mov pc, r2
243
  ldmfd sp!, {r0-r1}
244
  b dtor_loop
245
dtor_end:
246
 
247
  /* Return from main, loop forever. */
248
exit_loop:
249
  b exit_loop
250
 
251
#ifdef CHECK
252
data_error_loop:
253
  b data_error_loop
254
 
255
text_error_loop:
256
  b text_error_loop
257
 
258
fast_error_loop:
259
  b fast_error_loop
260
 
261
bss_error_loop:
262
  b bss_error_loop
263
#endif
264
 
265
 

powered by: WebSVN 2.1.0

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