1
2
3
4
5
6
7
8
9
10
11#include <asm-offsets.h>
12#include <config.h>
13
14 .text
15 .global _start
16_start:
17
18
19
20
21
22
23
24 mts rmsr, r0
25
26 addi r8, r0, __end
27 mts rslr, r8
28
29
30 addi r1, r0, CONFIG_SPL_STACK_ADDR
31 mts rshr, r1
32 addi r1, r1, -4
33#else
34
35 addi r1, r0, CONFIG_SYS_INIT_SP_OFFSET - CONFIG_SYS_MALLOC_F_LEN
36#else
37 addi r1, r0, CONFIG_SYS_INIT_SP_OFFSET
38#endif
39 mts rshr, r1
40 addi r1, r1, -4
41
42
43
44
45
46
47
48
49
50
51 addik r6, r0, 0x2
52 lwi r7, r0, 0x28
53 swi r6, r0, 0x28
54 lbui r10, r0, 0x28
55 swi r7, r0, 0x28
56
57
58 addi r2, r0, 0xb0000000
59 addi r3, r0, 0xb8080000
60
61#ifdef CONFIG_SYS_RESET_ADDRESS
62
63 swi r2, r0, 0x0
64 swi r3, r0, 0x4
65
66 addik r6, r0, CONFIG_SYS_RESET_ADDRESS
67 sw r6, r1, r0
68 lhu r7, r1, r10
69 rsubi r8, r10, 0x2
70 sh r7, r0, r8
71 rsubi r8, r10, 0x6
72 sh r6, r0, r8
73#endif
74
75#ifdef CONFIG_SYS_USR_EXCEP
76
77 swi r2, r0, 0x8
78 swi r3, r0, 0xC
79
80 addik r6, r0, _exception_handler
81 sw r6, r1, r0
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102 lhu r7, r1, r10
103 rsubi r8, r10, 0xa
104 sh r7, r0, r8
105 rsubi r8, r10, 0xe
106 sh r6, r0, r8
107#endif
108
109
110 swi r2, r0, 0x10
111 swi r3, r0, 0x14
112
113 addik r6, r0, _interrupt_handler
114 sw r6, r1, r0
115 lhu r7, r1, r10
116 rsubi r8, r10, 0x12
117 sh r7, r0, r8
118 rsubi r8, r10, 0x16
119 sh r6, r0, r8
120
121
122 swi r2, r0, 0x20
123 swi r3, r0, 0x24
124
125 addik r6, r0, _hw_exception_handler
126 sw r6, r1, r0
127 lhu r7, r1, r10
128 rsubi r8, r10, 0x22
129 sh r7, r0, r8
130 rsubi r8, r10, 0x26
131 sh r6, r0, r8
132#endif
133
134
135 addik r5, r0, 0
136 addik r6, r0, XILINX_DCACHE_BYTE_SIZE
137 bralid r15, flush_cache
138 nop
139
140
141 mfs r12, rmsr
142 ori r12, r12, 0x1a0
143 mts rmsr, r12
144
145
146clear_bss:
147
148 addi r5, r0, __bss_start
149 addi r4, r0, __bss_end
150 cmp r6, r5, r4
151 beqi r6, 3f
1522:
153 swi r0, r5, 0
154 addi r5, r5, 4
155 cmp r6, r5, r4
156 bnei r6, 2b
1573:
158#ifdef CONFIG_DEBUG_UART
159 bralid r15, debug_uart_init
160 nop
161#endif
162#ifndef CONFIG_SPL_BUILD
163 or r5, r0, r0
164 addi r31, r0, _gd
165
166 addi r6, r0, CONFIG_SYS_INIT_SP_OFFSET
167 swi r6, r31, GD_MALLOC_BASE
168#endif
169 brai board_init_f
170#else
171 addi r31, r0, _gd
172
173 addi r6, r0, CONFIG_SPL_STACK_ADDR
174 swi r6, r31, GD_MALLOC_BASE
175#endif
176 brai board_init_r
177#endif
1781: bri 1b
179
180 .section .bss
181.align 4
182_gd:
183 .space GENERATED_GBL_DATA_SIZE
184
185#ifndef CONFIG_SPL_BUILD
186
187
188
189 .text
190 .global in16
191 .ent in16
192 .align 2
193in16: lhu r3, r0, r5
194 bslli r4, r3, 8
195 bsrli r3, r3, 8
196 andi r4, r4, 0xffff
197 or r3, r3, r4
198 rtsd r15, 8
199 sext16 r3, r3
200 .end in16
201
202
203
204
205
206 .text
207 .global out16
208 .ent out16
209 .align 2
210out16: bslli r3, r6, 8
211 bsrli r6, r6, 8
212 andi r3, r3, 0xffff
213 or r3, r3, r6
214 sh r3, r0, r5
215 rtsd r15, 8
216 or r0, r0, r0
217 .end out16
218
219
220
221
222 .text
223 .global relocate_code
224 .ent relocate_code
225 .align 2
226relocate_code:
227
228
229
230
231
232 addi r1, r5, 0
233 addi r31, r6, 0
234
235 add r23, r0, r7
236
237 addi r21, r0, _start
238 addi r22, r0, __end - 4
239
240 rsub r6, r21, r22
241 or r5, r0, r0
2421: lw r12, r21, r5
243 sw r12, r23, r5
244 cmp r12, r5, r6
245 bneid r12, 1b
246 addi r5, r5, 4
247
248
249 add r23, r0, r7
250 addi r24, r0, CONFIG_SYS_TEXT_BASE
251 rsub r23, r24, r23
252
253 addik r6, r0, 0x2
254 lwi r7, r0, 0x28
255 swi r6, r0, 0x28
256 lbui r10, r0, 0x28
257 swi r7, r0, 0x28
258
259#ifdef CONFIG_SYS_USR_EXCEP
260 addik r6, r0, _exception_handler
261 addk r6, r6, r23
262 sw r6, r1, r0
263 lhu r7, r1, r10
264 rsubi r8, r10, 0xa
265 sh r7, r0, r8
266 rsubi r8, r10, 0xe
267 sh r6, r0, r8
268#endif
269 addik r6, r0, _hw_exception_handler
270 addk r6, r6, r23
271 sw r6, r1, r0
272 lhu r7, r1, r10
273 rsubi r8, r10, 0x22
274 sh r7, r0, r8
275 rsubi r8, r10, 0x26
276 sh r6, r0, r8
277
278 addik r6, r0, _interrupt_handler
279 addk r6, r6, r23
280 sw r6, r1, r0
281 lhu r7, r1, r10
282 rsubi r8, r10, 0x12
283 sh r7, r0, r8
284 rsubi r8, r10, 0x16
285 sh r6, r0, r8
286
287
288 addik r21, r23, _got_start
289 addik r22, r23, _got_end
290 cmpu r12, r21, r22
291 beqi r12, 2f
292
293
294 addik r22, r22, -0x10
295
296
2973: lw r12, r21, r0
298 addk r12, r12, r23
299 sw r12, r21, r0
300
301 cmpu r12, r21, r22
302 bneid r12, 3b
303 addik r21. r21, 4
304
305
306 mfs r20, rpc
307 addik r20, r20, _GLOBAL_OFFSET_TABLE_ + 8
308 addk r20, r20, r23
309
310
311 addik r5, r0, 0
312 addik r6, r0, XILINX_DCACHE_BYTE_SIZE
313 bralid r15, flush_cache
314 nop
315
3162: addi r5, r31, 0
317 addi r6, r0, CONFIG_SYS_TEXT_BASE
318 addi r12, r23, board_init_r
319 bra r12
320
321 .end relocate_code
322#endif
323