start.S (9cef20b10929d7ad047b071c3dcb924401bf78e8) start.S (e945f6dc2814f5f0d30b5b7e23821b3fd4faff5b)
1/*
2 * (C) Copyright 2007 Michal Simek
3 * (C) Copyright 2004 Atmark Techno, Inc.
4 *
5 * Michal SIMEK <monstr@monstr.eu>
6 * Yasushi SHOJI <yashi@atmark-techno.com>
7 *
8 * SPDX-License-Identifier: GPL-2.0+

--- 136 unchanged lines hidden (view full) ---

145 beqi r6, 3f
1462:
147 swi r0, r5, 0 /* write zero to loc */
148 addi r5, r5, 4 /* increment to next loc */
149 cmp r6, r5, r4 /* check if we have reach the end */
150 bnei r6, 2b
1513: /* jumping to board_init */
152#ifndef CONFIG_SPL_BUILD
1/*
2 * (C) Copyright 2007 Michal Simek
3 * (C) Copyright 2004 Atmark Techno, Inc.
4 *
5 * Michal SIMEK <monstr@monstr.eu>
6 * Yasushi SHOJI <yashi@atmark-techno.com>
7 *
8 * SPDX-License-Identifier: GPL-2.0+

--- 136 unchanged lines hidden (view full) ---

145 beqi r6, 3f
1462:
147 swi r0, r5, 0 /* write zero to loc */
148 addi r5, r5, 4 /* increment to next loc */
149 cmp r6, r5, r4 /* check if we have reach the end */
150 bnei r6, 2b
1513: /* jumping to board_init */
152#ifndef CONFIG_SPL_BUILD
153 or r5, r0, r0 /* flags - empty */
153 brai board_init_f
154#else
155 addi r31, r0, CONFIG_SYS_SPL_MALLOC_END
156 brai board_init_r
157#endif
1581: bri 1b
159
160#ifndef CONFIG_SPL_BUILD

--- 24 unchanged lines hidden (view full) ---

185out16: bslli r3, r6, 8
186 bsrli r6, r6, 8
187 andi r3, r3, 0xffff
188 or r3, r3, r6
189 sh r3, r0, r5
190 rtsd r15, 8
191 or r0, r0, r0
192 .end out16
154 brai board_init_f
155#else
156 addi r31, r0, CONFIG_SYS_SPL_MALLOC_END
157 brai board_init_r
158#endif
1591: bri 1b
160
161#ifndef CONFIG_SPL_BUILD

--- 24 unchanged lines hidden (view full) ---

186out16: bslli r3, r6, 8
187 bsrli r6, r6, 8
188 andi r3, r3, 0xffff
189 or r3, r3, r6
190 sh r3, r0, r5
191 rtsd r15, 8
192 or r0, r0, r0
193 .end out16
194
195/*
196 * Relocate u-boot
197 */
198 .text
199 .global relocate_code
200 .ent relocate_code
201 .align 2
202relocate_code:
203 /*
204 * r5 - start_addr_sp
205 * r6 - new_gd
206 * r7 - reloc_addr
207 */
208 addi r1, r5, 0 /* Start to use new SP */
209 addi r31, r6, 0 /* Start to use new GD */
210
211 add r23, r0, r7 /* Move reloc addr to r23 */
212 /* Relocate text and data - r12 temp value */
213 addi r21, r0, _start
214 addi r22, r0, __end - 4 /* Include BSS too */
2151: lwi r12, r21, 0 /* Load u-boot data */
216 swi r12, r23, 0 /* Write zero to loc */
217 addi r21, r21, 4 /* Increment to next loc - origin code */
218 cmp r12, r21, r22 /* Check if we have reach the end */
219 bneid r12, 1b
220 addi r23, r23, 4 /* Increment to next loc - relocate code */
221
222 /* R23 points to the base address. */
223 add r23, r0, r7 /* Move reloc addr to r23 */
224 addi r24, r0, CONFIG_SYS_TEXT_BASE /* Get reloc offset */
225 rsub r23, r24, r23 /* keep - this is already here gd->reloc_off */
226
227 addik r6, r0, 0x2 /* BIG/LITTLE endian offset */
228 lwi r7, r0, 0x28
229 swi r6, r0, 0x28 /* used first unused MB vector */
230 lbui r10, r0, 0x28 /* used first unused MB vector */
231 swi r7, r0, 0x28
232
233#ifdef CONFIG_SYS_USR_EXCEP
234 addik r6, r0, _exception_handler
235 addk r6, r6, r23 /* add offset */
236 sw r6, r1, r0
237 lhu r7, r1, r10
238 rsubi r8, r10, 0xa
239 sh r7, r0, r8
240 rsubi r8, r10, 0xe
241 sh r6, r0, r8
193#endif
242#endif
243 addik r6, r0, _hw_exception_handler
244 addk r6, r6, r23 /* add offset */
245 sw r6, r1, r0
246 lhu r7, r1, r10
247 rsubi r8, r10, 0x22
248 sh r7, r0, r8
249 rsubi r8, r10, 0x26
250 sh r6, r0, r8
251
252 addik r6, r0, _interrupt_handler
253 addk r6, r6, r23 /* add offset */
254 sw r6, r1, r0
255 lhu r7, r1, r10
256 rsubi r8, r10, 0x12
257 sh r7, r0, r8
258 rsubi r8, r10, 0x16
259 sh r6, r0, r8
260
261 /* Check if GOT exist */
262 addik r21, r23, _got_start
263 addik r22, r23, _got_end
264 cmpu r12, r21, r22
265 beqi r12, 2f /* No GOT table - jump over */
266
267 /* Skip last 3 entries plus 1 because of loop boundary below */
268 addik r22, r22, -0x10
269
270 /* Relocate the GOT. */
2713: lw r12, r21, r0 /* Load entry */
272 addk r12, r12, r23 /* Add reloc offset */
273 sw r12, r21, r0 /* Save entry back */
274
275 cmpu r12, r21, r22 /* Check if this cross boundary */
276 bneid r12, 3b
277 addik r21. r21, 4
278
279 /* Update pointer to GOT */
280 mfs r20, rpc
281 addik r20, r20, _GLOBAL_OFFSET_TABLE_ + 8
282 addk r20, r20, r23
283
284 /* Flush caches to ensure consistency */
285 addik r5, r0, 0
286 addik r6, r0, XILINX_DCACHE_BYTE_SIZE
287 bralid r15, flush_cache
288 nop
289
2902: addi r5, r31, 0 /* gd is initialized in board_r.c */
291 addi r6, r0, CONFIG_SYS_TEXT_BASE
292 addi r12, r23, board_init_r
293 bra r12 /* Jump to relocated code */
294
295 .end relocate_code
296#endif