diff options
Diffstat (limited to 'lib/chibios/os/common/startup/e200/compilers/CW/crt0.s')
-rw-r--r-- | lib/chibios/os/common/startup/e200/compilers/CW/crt0.s | 258 |
1 files changed, 258 insertions, 0 deletions
diff --git a/lib/chibios/os/common/startup/e200/compilers/CW/crt0.s b/lib/chibios/os/common/startup/e200/compilers/CW/crt0.s new file mode 100644 index 000000000..03074f975 --- /dev/null +++ b/lib/chibios/os/common/startup/e200/compilers/CW/crt0.s | |||
@@ -0,0 +1,258 @@ | |||
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 CW/crt0.s | ||
19 | * @brief Generic PowerPC startup file for CodeWarrior. | ||
20 | * | ||
21 | * @addtogroup PPC_CW_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 | /*===========================================================================*/ | ||
38 | /* Module pre-compile time settings. */ | ||
39 | /*===========================================================================*/ | ||
40 | |||
41 | /** | ||
42 | * @brief Stack segments initialization switch. | ||
43 | */ | ||
44 | #if !defined(CRT0_STACKS_FILL_PATTERN) || defined(__DOXYGEN__) | ||
45 | #define CRT0_STACKS_FILL_PATTERN 0x55555555 | ||
46 | #endif | ||
47 | |||
48 | /** | ||
49 | * @brief Stack segments initialization switch. | ||
50 | */ | ||
51 | #if !defined(CRT0_INIT_STACKS) || defined(__DOXYGEN__) | ||
52 | #define CRT0_INIT_STACKS TRUE | ||
53 | #endif | ||
54 | |||
55 | /** | ||
56 | * @brief DATA segment initialization switch. | ||
57 | */ | ||
58 | #if !defined(CRT0_INIT_DATA) || defined(__DOXYGEN__) | ||
59 | #define CRT0_INIT_DATA TRUE | ||
60 | #endif | ||
61 | |||
62 | /** | ||
63 | * @brief BSS segment initialization switch. | ||
64 | */ | ||
65 | #if !defined(CRT0_INIT_BSS) || defined(__DOXYGEN__) | ||
66 | #define CRT0_INIT_BSS TRUE | ||
67 | #endif | ||
68 | |||
69 | /** | ||
70 | * @brief Constructors invocation switch. | ||
71 | */ | ||
72 | #if !defined(CRT0_CALL_CONSTRUCTORS) || defined(__DOXYGEN__) | ||
73 | #define CRT0_CALL_CONSTRUCTORS FALSE | ||
74 | #endif | ||
75 | |||
76 | /** | ||
77 | * @brief Destructors invocation switch. | ||
78 | */ | ||
79 | #if !defined(CRT0_CALL_DESTRUCTORS) || defined(__DOXYGEN__) | ||
80 | #define CRT0_CALL_DESTRUCTORS FALSE | ||
81 | #endif | ||
82 | |||
83 | /*===========================================================================*/ | ||
84 | /* Code section. */ | ||
85 | /*===========================================================================*/ | ||
86 | |||
87 | #if !defined(__DOXYGEN__) | ||
88 | .extern __sdata2_start__ | ||
89 | .extern __sdata_start__ | ||
90 | .extern __bss_start__ | ||
91 | .extern __bss_end__ | ||
92 | .extern __irq_stack_base__ | ||
93 | .extern __irq_stack_end__ | ||
94 | .extern __process_stack_end__ | ||
95 | .extern __process_stack_base__ | ||
96 | .extern __romdata_start__ | ||
97 | .extern __data_start__ | ||
98 | .extern __data_end__ | ||
99 | .extern __init_array_start | ||
100 | .extern __init_array_end | ||
101 | .extern __fini_array_start | ||
102 | .extern __fini_array_end | ||
103 | |||
104 | .extern main | ||
105 | |||
106 | .section .crt0, text_vle | ||
107 | .align 16 | ||
108 | .globl _boot_address | ||
109 | .type _boot_address, @function | ||
110 | _boot_address: | ||
111 | /* Stack setup.*/ | ||
112 | e_lis r1, __process_stack_end__@h | ||
113 | e_or2i r1, __process_stack_end__@l | ||
114 | se_li r0, 0 | ||
115 | e_stwu r0, -8(r1) | ||
116 | |||
117 | /* Small sections registers initialization.*/ | ||
118 | e_lis r2, __sdata2_start__@h | ||
119 | e_or2i r2, __sdata2_start__@l | ||
120 | e_lis r13, __sdata_start__@h | ||
121 | e_or2i r13, __sdata_start__@l | ||
122 | |||
123 | /* Early initialization.*/ | ||
124 | e_bl __early_init | ||
125 | |||
126 | #if CRT0_INIT_STACKS == TRUE | ||
127 | /* Stacks fill pattern.*/ | ||
128 | e_lis r7, CRT0_STACKS_FILL_PATTERN@h | ||
129 | e_or2i r7, CRT0_STACKS_FILL_PATTERN@l | ||
130 | |||
131 | /* IRQ Stack initialization. Note, the architecture does not use this | ||
132 | stack, the size is usually zero. An OS can have special SW handling | ||
133 | and require this. A 4 bytes alignment is assumed and required.*/ | ||
134 | e_lis r4, __irq_stack_base__@h | ||
135 | e_or2i r4, __irq_stack_base__@l | ||
136 | e_lis r5, __irq_stack_end__@h | ||
137 | e_or2i r5, __irq_stack_end__@l | ||
138 | .irqsloop: | ||
139 | se_cmpl r4, r5 | ||
140 | se_bge .irqsend | ||
141 | se_stw r7, 0(r4) | ||
142 | se_addi r4, 4 | ||
143 | se_b .irqsloop | ||
144 | .irqsend: | ||
145 | |||
146 | /* Process Stack initialization. Note, does not overwrite the already | ||
147 | written EABI frame. A 4 bytes alignment is assumed and required.*/ | ||
148 | e_lis r4, __process_stack_base__@h | ||
149 | e_or2i r4, __process_stack_base__@l | ||
150 | e_lis r5, (__process_stack_end__ - 8)@h | ||
151 | e_or2i r5, (__process_stack_end__ - 8)@l | ||
152 | .prcsloop: | ||
153 | se_cmpl r4, r5 | ||
154 | se_bge .prcsend | ||
155 | se_stw r7, 0(r4) | ||
156 | se_addi r4, 4 | ||
157 | se_b .prcsloop | ||
158 | .prcsend: | ||
159 | #endif | ||
160 | |||
161 | #if CRT0_INIT_BSS == TRUE | ||
162 | /* BSS clearing.*/ | ||
163 | e_lis r4, __bss_start__@h | ||
164 | e_or2i r4, __bss_start__@l | ||
165 | e_lis r5, __bss_end__@h | ||
166 | e_or2i r5, __bss_end__@l | ||
167 | se_li r7, 0 | ||
168 | .bssloop: | ||
169 | se_cmpl r4, r5 | ||
170 | se_bge .bssend | ||
171 | se_stw r7, 0(r4) | ||
172 | se_addi r4, 4 | ||
173 | se_b .bssloop | ||
174 | .bssend: | ||
175 | #endif | ||
176 | |||
177 | #if CRT0_INIT_DATA == TRUE | ||
178 | /* DATA initialization.*/ | ||
179 | e_lis r4, __romdata_start__@h | ||
180 | e_or2i r4, __romdata_start__@l | ||
181 | e_lis r5, __data_start__@h | ||
182 | e_or2i r5, __data_start__@l | ||
183 | e_lis r6, __data_end__@h | ||
184 | e_or2i r6, __data_end__@l | ||
185 | .dataloop: | ||
186 | se_cmpl r5, r6 | ||
187 | se_bge .dataend | ||
188 | se_lwz r7, 0(r4) | ||
189 | se_addi r4, 4 | ||
190 | se_stw r7, 0(r5) | ||
191 | se_addi r5, 4 | ||
192 | se_b .dataloop | ||
193 | .dataend: | ||
194 | #endif | ||
195 | |||
196 | /* Late initialization.*/ | ||
197 | e_bl __late_init | ||
198 | |||
199 | #if CRT0_CALL_CONSTRUCTORS == TRUE | ||
200 | /* Constructors invocation.*/ | ||
201 | e_lis r4, __init_array_start@h | ||
202 | e_or2i r4, __init_array_start@l | ||
203 | e_lis r5, __init_array_end@h | ||
204 | e_or2i r5, __init_array_end@l | ||
205 | .iniloop: | ||
206 | se_cmpl r4, r5 | ||
207 | se_bge .iniend | ||
208 | se_lwz r6, 0(r4) | ||
209 | se_mtctr r6 | ||
210 | se_addi r4, 4 | ||
211 | se_bctrl | ||
212 | se_b .iniloop | ||
213 | .iniend: | ||
214 | #endif | ||
215 | |||
216 | /* Main program invocation.*/ | ||
217 | e_bl main | ||
218 | |||
219 | #if CRT0_CALL_DESTRUCTORS == TRUE | ||
220 | /* Destructors invocation.*/ | ||
221 | e_lis r4, __fini_array_start@h | ||
222 | e_or2i r4, __fini_array_start@l | ||
223 | e_lis r5, __fini_array_end@h | ||
224 | e_or2i r5, __fini_array_end@l | ||
225 | .finiloop: | ||
226 | se_cmpl r4, r5 | ||
227 | se_bge .finiend | ||
228 | se_lwz r6, 0(r4) | ||
229 | se_mtctr r6 | ||
230 | se_addi r4, 4 | ||
231 | se_bctrl | ||
232 | se_b .finiloop | ||
233 | .finiend: | ||
234 | #endif | ||
235 | |||
236 | /* Branching to the defined exit handler.*/ | ||
237 | e_b __default_exit | ||
238 | |||
239 | #endif /* !defined(__DOXYGEN__) */ | ||
240 | |||
241 | .section .text_vle | ||
242 | .align 4 | ||
243 | |||
244 | /* Default main exit code, infinite loop.*/ | ||
245 | .weak __default_exit | ||
246 | __default_exit: | ||
247 | e_b __default_exit | ||
248 | |||
249 | /* Default early initialization code, none.*/ | ||
250 | .weak __early_init | ||
251 | se_blr | ||
252 | |||
253 | /* Default late initialization code, none.*/ | ||
254 | .weak __late_init | ||
255 | __late_init: | ||
256 | se_blr | ||
257 | |||
258 | /** @} */ | ||