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