aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios/os/common/startup/e200/compilers/GCC/crt0.S
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios/os/common/startup/e200/compilers/GCC/crt0.S')
-rw-r--r--lib/chibios/os/common/startup/e200/compilers/GCC/crt0.S253
1 files changed, 253 insertions, 0 deletions
diff --git a/lib/chibios/os/common/startup/e200/compilers/GCC/crt0.S b/lib/chibios/os/common/startup/e200/compilers/GCC/crt0.S
new file mode 100644
index 000000000..89e4dcc21
--- /dev/null
+++ b/lib/chibios/os/common/startup/e200/compilers/GCC/crt0.S
@@ -0,0 +1,253 @@
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/**
18 * @file GCC/crt0.S
19 * @brief Generic PowerPC startup file for GCC.
20 *
21 * @addtogroup PPC_GCC_CORE
22 * @{
23 */
24
25/*===========================================================================*/
26/* Module constants. */
27/*===========================================================================*/
28
29#if !defined(FALSE) || defined(__DOXYGEN__)
30#define FALSE 0
31#endif
32
33#if !defined(TRUE) || defined(__DOXYGEN__)
34#define TRUE 1
35#endif
36
37#if defined(__HIGHTEC__)
38#define se_bge bge
39#endif
40
41/*===========================================================================*/
42/* Module pre-compile time settings. */
43/*===========================================================================*/
44
45/**
46 * @brief Stack segments initialization switch.
47 */
48#if !defined(CRT0_STACKS_FILL_PATTERN) || defined(__DOXYGEN__)
49#define CRT0_STACKS_FILL_PATTERN 0x55555555
50#endif
51
52/**
53 * @brief Stack segments initialization switch.
54 */
55#if !defined(CRT0_INIT_STACKS) || defined(__DOXYGEN__)
56#define CRT0_INIT_STACKS TRUE
57#endif
58
59/**
60 * @brief DATA segment initialization switch.
61 */
62#if !defined(CRT0_INIT_DATA) || defined(__DOXYGEN__)
63#define CRT0_INIT_DATA TRUE
64#endif
65
66/**
67 * @brief BSS segment initialization switch.
68 */
69#if !defined(CRT0_INIT_BSS) || defined(__DOXYGEN__)
70#define CRT0_INIT_BSS TRUE
71#endif
72
73/**
74 * @brief Constructors invocation switch.
75 */
76#if !defined(CRT0_CALL_CONSTRUCTORS) || defined(__DOXYGEN__)
77#define CRT0_CALL_CONSTRUCTORS TRUE
78#endif
79
80/**
81 * @brief Destructors invocation switch.
82 */
83#if !defined(CRT0_CALL_DESTRUCTORS) || defined(__DOXYGEN__)
84#define CRT0_CALL_DESTRUCTORS TRUE
85#endif
86
87/*===========================================================================*/
88/* Code section. */
89/*===========================================================================*/
90
91#if !defined(__DOXYGEN__)
92
93 .section .crt0, "ax"
94 .align 2
95 .globl _boot_address
96 .type _boot_address, @function
97_boot_address:
98 /* Stack setup.*/
99 e_lis r1, __process_stack_end__@h
100 e_or2i r1, __process_stack_end__@l
101 se_li r0, 0
102 e_stwu r0, -8(r1)
103
104 /* Small sections registers initialization.*/
105 e_lis r2, __sdata2_start__@h
106 e_or2i r2, __sdata2_start__@l
107 e_lis r13, __sdata_start__@h
108 e_or2i r13, __sdata_start__@l
109
110 /* Early initialization.*/
111 e_bl __early_init
112
113#if CRT0_INIT_STACKS == TRUE
114 /* Stacks fill pattern.*/
115 e_lis r7, CRT0_STACKS_FILL_PATTERN@h
116 e_or2i r7, CRT0_STACKS_FILL_PATTERN@l
117
118 /* IRQ Stack initialization. Note, the architecture does not use this
119 stack, the size is usually zero. An OS can have special SW handling
120 and require this. A 4 bytes alignment is assmend and required.*/
121 e_lis r4, __irq_stack_base__@h
122 e_or2i r4, __irq_stack_base__@l
123 e_lis r5, __irq_stack_end__@h
124 e_or2i r5, __irq_stack_end__@l
125.irqsloop:
126 se_cmpl r4, r5
127 se_bge .irqsend
128 se_stw r7, 0(r4)
129 se_addi r4, 4
130 se_b .irqsloop
131.irqsend:
132
133 /* Process Stack initialization. Note, does not overwrite the already
134 written EABI frame. A 4 bytes alignment is assmend and required.*/
135 e_lis r4, __process_stack_base__@h
136 e_or2i r4, __process_stack_base__@l
137 e_lis r5, (__process_stack_end__ - 8)@h
138 e_or2i r5, (__process_stack_end__ - 8)@l
139.prcsloop:
140 se_cmpl r4, r5
141 se_bge .prcsend
142 se_stw r7, 0(r4)
143 se_addi r4, 4
144 se_b .prcsloop
145.prcsend:
146#endif
147
148#if CRT0_INIT_BSS == TRUE
149 /* BSS clearing.*/
150 e_lis r4, __bss_start__@h
151 e_or2i r4, __bss_start__@l
152 e_lis r5, __bss_end__@h
153 e_or2i r5, __bss_end__@l
154 se_li r7, 0
155.bssloop:
156 se_cmpl r4, r5
157 se_bge .bssend
158 se_stw r7, 0(r4)
159 se_addi r4, 4
160 se_b .bssloop
161.bssend:
162#endif
163
164#if CRT0_INIT_DATA == TRUE
165 /* DATA initialization.*/
166 e_lis r4, __romdata_start__@h
167 e_or2i r4, __romdata_start__@l
168 e_lis r5, __data_start__@h
169 e_or2i r5, __data_start__@l
170 e_lis r6, __data_end__@h
171 e_or2i r6, __data_end__@l
172.dataloop:
173 se_cmpl r5, r6
174 se_bge .dataend
175 se_lwz r7, 0(r4)
176 se_addi r4, 4
177 se_stw r7, 0(r5)
178 se_addi r5, 4
179 se_b .dataloop
180.dataend:
181#endif
182
183 /* Late initialization.*/
184 e_bl __late_init
185
186#if CRT0_CALL_CONSTRUCTORS == TRUE
187 /* Constructors invocation.*/
188 e_lis r4, __init_array_start@h
189 e_or2i r4, __init_array_start@l
190 e_lis r5, __init_array_end@h
191 e_or2i r5, __init_array_end@l
192.iniloop:
193 se_cmpl r4, r5
194 se_bge .iniend
195 se_lwz r6, 0(r4)
196 mtctr r6
197 se_addi r4, 4
198 se_bctrl
199 se_b .iniloop
200.iniend:
201#endif
202
203 /* Main program invocation.*/
204 e_bl main
205
206#if CRT0_CALL_DESTRUCTORS == TRUE
207 /* Destructors invocation.*/
208 e_lis r4, __fini_array_start@h
209 e_or2i r4, __fini_array_start@l
210 e_lis r5, __fini_array_end@h
211 e_or2i r5, __fini_array_end@l
212.finiloop:
213 se_cmpl r4, r5
214 se_bge .finiend
215 se_lwz r6, 0(r4)
216 mtctr r6
217 se_addi r4, 4
218 se_bctrl
219 se_b .finiloop
220.finiend:
221#endif
222
223 /* Branching to the defined exit handler.*/
224 e_b __default_exit
225
226 /* Default main exit code, infinite loop.*/
227 .weak __default_exit
228 .type __default_exit, @function
229__default_exit:
230 e_b __default_exit
231
232 /* Default early initialization code, none.*/
233 .weak __early_init
234 .type __early_init, @function
235__early_init:
236 se_blr
237
238 /* Default late initialization code, none.*/
239 .weak __late_init
240 .type __late_init, @function
241__late_init:
242 se_blr
243
244 /* Default implementation for __eabi() function.*/
245 .weak __eabi
246 .type __eabi, @function
247__eabi:
248 /* R2 and R13 initialization is done in the startup code.*/
249 se_blr
250
251#endif /* !defined(__DOXYGEN__) */
252
253/** @} */