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