Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
wdenk | 507bbe3 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 2 | /* |
Michal Simek | cfc6711 | 2007-03-11 13:48:24 +0100 | [diff] [blame] | 3 | * (C) Copyright 2007 Michal Simek |
wdenk | 507bbe3 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 4 | * (C) Copyright 2004 Atmark Techno, Inc. |
| 5 | * |
Michal Simek | cfc6711 | 2007-03-11 13:48:24 +0100 | [diff] [blame] | 6 | * Michal SIMEK <monstr@monstr.eu> |
wdenk | 507bbe3 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 7 | * Yasushi SHOJI <yashi@atmark-techno.com> |
wdenk | 507bbe3 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
Wolfgang Denk | 25ddd1f | 2010-10-26 14:34:52 +0200 | [diff] [blame] | 10 | #include <asm-offsets.h> |
wdenk | 507bbe3 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 11 | #include <config.h> |
| 12 | |
| 13 | .text |
| 14 | .global _start |
| 15 | _start: |
Michal Simek | cfc6711 | 2007-03-11 13:48:24 +0100 | [diff] [blame] | 16 | mts rmsr, r0 /* disable cache */ |
Michal Simek | 9d24274 | 2014-01-21 07:30:37 +0100 | [diff] [blame] | 17 | |
Michal Simek | 16a1847 | 2022-06-24 14:14:59 +0200 | [diff] [blame] | 18 | mts rslr, r0 |
| 19 | addi r8, r0, _start |
| 20 | mts rshr, r8 |
Ovidiu Panait | f5d8b1a | 2020-09-24 11:54:37 +0300 | [diff] [blame] | 21 | |
Michal Simek | 9d24274 | 2014-01-21 07:30:37 +0100 | [diff] [blame] | 22 | #if defined(CONFIG_SPL_BUILD) |
| 23 | addi r1, r0, CONFIG_SPL_STACK_ADDR |
Michal Simek | 405e651 | 2015-01-30 15:46:43 +0100 | [diff] [blame] | 24 | #else |
Michal Simek | aa0799e | 2022-06-24 14:14:59 +0200 | [diff] [blame] | 25 | add r1, r0, r8 |
Michal Simek | 405e651 | 2015-01-30 15:46:43 +0100 | [diff] [blame] | 26 | #endif |
Ovidiu Panait | f5d8b1a | 2020-09-24 11:54:37 +0300 | [diff] [blame] | 27 | |
Michal Simek | 1798049 | 2007-03-26 01:39:07 +0200 | [diff] [blame] | 28 | addi r1, r1, -4 /* Decrement SP to top of memory */ |
Michal Simek | b98cba0 | 2010-08-12 11:47:11 +0200 | [diff] [blame] | 29 | |
Ovidiu Panait | f5d8b1a | 2020-09-24 11:54:37 +0300 | [diff] [blame] | 30 | /* Call board_init_f_alloc_reserve with the current stack pointer as |
| 31 | * parameter. */ |
| 32 | add r5, r0, r1 |
Michal Simek | 7cf236c | 2022-06-24 14:14:59 +0200 | [diff] [blame] | 33 | brlid r15, board_init_f_alloc_reserve |
Ovidiu Panait | f5d8b1a | 2020-09-24 11:54:37 +0300 | [diff] [blame] | 34 | nop |
| 35 | |
| 36 | /* board_init_f_alloc_reserve returns a pointer to the allocated area |
| 37 | * in r3. Set the new stack pointer below this area. */ |
| 38 | add r1, r0, r3 |
| 39 | mts rshr, r1 |
| 40 | addi r1, r1, -4 |
| 41 | |
| 42 | /* Call board_init_f_init_reserve with the address returned by |
| 43 | * board_init_f_alloc_reserve as parameter. */ |
| 44 | add r5, r0, r3 |
Michal Simek | 7cf236c | 2022-06-24 14:14:59 +0200 | [diff] [blame] | 45 | brlid r15, board_init_f_init_reserve |
Ovidiu Panait | f5d8b1a | 2020-09-24 11:54:37 +0300 | [diff] [blame] | 46 | nop |
| 47 | |
| 48 | #if !defined(CONFIG_SPL_BUILD) |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 49 | /* Setup vectors with pre-relocation symbols */ |
| 50 | or r5, r0, r0 |
Michal Simek | 7cf236c | 2022-06-24 14:14:59 +0200 | [diff] [blame] | 51 | brlid r15, __setup_exceptions |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 52 | nop |
Ovidiu Panait | f5d8b1a | 2020-09-24 11:54:37 +0300 | [diff] [blame] | 53 | #endif |
Michal Simek | cfc6711 | 2007-03-11 13:48:24 +0100 | [diff] [blame] | 54 | |
Michal Simek | 5811830 | 2012-09-25 10:13:35 +0200 | [diff] [blame] | 55 | /* Flush cache before enable cache */ |
| 56 | addik r5, r0, 0 |
| 57 | addik r6, r0, XILINX_DCACHE_BYTE_SIZE |
Michal Simek | 7cf236c | 2022-06-24 14:14:59 +0200 | [diff] [blame] | 58 | brlid r15, flush_cache |
Michal Simek | 5811830 | 2012-09-25 10:13:35 +0200 | [diff] [blame] | 59 | nop |
| 60 | |
Michal Simek | cfc6711 | 2007-03-11 13:48:24 +0100 | [diff] [blame] | 61 | /* enable instruction and data cache */ |
| 62 | mfs r12, rmsr |
Michal Simek | 822d43a | 2014-11-04 13:27:52 +0100 | [diff] [blame] | 63 | ori r12, r12, 0x1a0 |
Michal Simek | cfc6711 | 2007-03-11 13:48:24 +0100 | [diff] [blame] | 64 | mts rmsr, r12 |
| 65 | |
Michal Simek | 1798049 | 2007-03-26 01:39:07 +0200 | [diff] [blame] | 66 | clear_bss: |
| 67 | /* clear BSS segments */ |
| 68 | addi r5, r0, __bss_start |
| 69 | addi r4, r0, __bss_end |
| 70 | cmp r6, r5, r4 |
| 71 | beqi r6, 3f |
| 72 | 2: |
| 73 | swi r0, r5, 0 /* write zero to loc */ |
| 74 | addi r5, r5, 4 /* increment to next loc */ |
| 75 | cmp r6, r5, r4 /* check if we have reach the end */ |
| 76 | bnei r6, 2b |
| 77 | 3: /* jumping to board_init */ |
Michal Simek | 48470b7 | 2015-12-10 12:55:39 +0100 | [diff] [blame] | 78 | #ifdef CONFIG_DEBUG_UART |
Michal Simek | 7cf236c | 2022-06-24 14:14:59 +0200 | [diff] [blame] | 79 | brlid r15, debug_uart_init |
Michal Simek | 48470b7 | 2015-12-10 12:55:39 +0100 | [diff] [blame] | 80 | nop |
| 81 | #endif |
Michal Simek | 9d24274 | 2014-01-21 07:30:37 +0100 | [diff] [blame] | 82 | #ifndef CONFIG_SPL_BUILD |
Michal Simek | e945f6d | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 83 | or r5, r0, r0 /* flags - empty */ |
Michal Simek | 7cf236c | 2022-06-24 14:14:59 +0200 | [diff] [blame] | 84 | bri board_init_f |
Michal Simek | 9d24274 | 2014-01-21 07:30:37 +0100 | [diff] [blame] | 85 | #else |
Michal Simek | 7cf236c | 2022-06-24 14:14:59 +0200 | [diff] [blame] | 86 | bri board_init_r |
Michal Simek | 9d24274 | 2014-01-21 07:30:37 +0100 | [diff] [blame] | 87 | #endif |
wdenk | 507bbe3 | 2004-04-18 21:13:41 +0000 | [diff] [blame] | 88 | 1: bri 1b |
Michal Simek | 0643631 | 2007-04-21 21:02:40 +0200 | [diff] [blame] | 89 | |
Michal Simek | 9d24274 | 2014-01-21 07:30:37 +0100 | [diff] [blame] | 90 | #ifndef CONFIG_SPL_BUILD |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 91 | .text |
| 92 | .ent __setup_exceptions |
| 93 | .align 2 |
| 94 | /* |
| 95 | * Set up reset, interrupt, user exception and hardware exception vectors. |
| 96 | * |
| 97 | * Parameters: |
| 98 | * r5 - relocation offset (zero when setting up vectors before |
| 99 | * relocation, and gd->reloc_off when setting up vectors after |
| 100 | * relocation) |
| 101 | * - the relocation offset is added to the _exception_handler, |
| 102 | * _interrupt_handler and _hw_exception_handler symbols to reflect the |
| 103 | * post-relocation memory addresses |
| 104 | * |
| 105 | * Reserve registers: |
| 106 | * r10: Stores little/big endian offset for vectors |
| 107 | * r2: Stores imm opcode |
| 108 | * r3: Stores brai opcode |
Ovidiu Panait | f149ee4 | 2021-11-30 18:33:56 +0200 | [diff] [blame] | 109 | * r4: Stores the vector base address |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 110 | */ |
| 111 | __setup_exceptions: |
Ovidiu Panait | f149ee4 | 2021-11-30 18:33:56 +0200 | [diff] [blame] | 112 | addik r1, r1, -32 |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 113 | swi r2, r1, 4 |
| 114 | swi r3, r1, 8 |
Ovidiu Panait | f149ee4 | 2021-11-30 18:33:56 +0200 | [diff] [blame] | 115 | swi r4, r1, 12 |
| 116 | swi r6, r1, 16 |
| 117 | swi r7, r1, 20 |
| 118 | swi r8, r1, 24 |
| 119 | swi r10, r1, 28 |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 120 | |
| 121 | /* Find-out if u-boot is running on BIG/LITTLE endian platform |
| 122 | * There are some steps which is necessary to keep in mind: |
| 123 | * 1. Setup offset value to r6 |
| 124 | * 2. Store word offset value to address 0x0 |
| 125 | * 3. Load just byte from address 0x0 |
| 126 | * 4a) LITTLE endian - r10 contains 0x2 because it is the smallest |
| 127 | * value that's why is on address 0x0 |
| 128 | * 4b) BIG endian - r10 contains 0x0 because 0x2 offset is on addr 0x3 |
| 129 | */ |
| 130 | addik r6, r0, 0x2 /* BIG/LITTLE endian offset */ |
Ovidiu Panait | 48039c3 | 2021-11-30 18:33:52 +0200 | [diff] [blame] | 131 | sw r6, r1, r0 |
| 132 | lbu r10, r1, r0 |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 133 | |
| 134 | /* add opcode instruction for 32bit jump - 2 instruction imm & brai */ |
| 135 | addi r2, r0, 0xb0000000 /* hex b000 opcode imm */ |
| 136 | addi r3, r0, 0xb8080000 /* hew b808 opcode brai */ |
| 137 | |
Ovidiu Panait | f149ee4 | 2021-11-30 18:33:56 +0200 | [diff] [blame] | 138 | /* Store the vector base address in r4 */ |
| 139 | addi r4, r0, CONFIG_XILINX_MICROBLAZE0_VECTOR_BASE_ADDR |
| 140 | |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 141 | /* reset address */ |
Ovidiu Panait | f149ee4 | 2021-11-30 18:33:56 +0200 | [diff] [blame] | 142 | swi r2, r4, 0x0 /* reset address - imm opcode */ |
| 143 | swi r3, r4, 0x4 /* reset address - brai opcode */ |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 144 | |
Michal Simek | 65a4da9 | 2022-06-24 14:14:59 +0200 | [diff] [blame] | 145 | addik r6, r0, _start |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 146 | sw r6, r1, r0 |
| 147 | lhu r7, r1, r10 |
| 148 | rsubi r8, r10, 0x2 |
Ovidiu Panait | f149ee4 | 2021-11-30 18:33:56 +0200 | [diff] [blame] | 149 | sh r7, r4, r8 |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 150 | rsubi r8, r10, 0x6 |
Ovidiu Panait | f149ee4 | 2021-11-30 18:33:56 +0200 | [diff] [blame] | 151 | sh r6, r4, r8 |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 152 | |
Ovidiu Panait | 83b175b | 2021-11-30 18:33:54 +0200 | [diff] [blame] | 153 | #if CONFIG_IS_ENABLED(XILINX_MICROBLAZE0_USR_EXCEP) |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 154 | /* user_vector_exception */ |
Ovidiu Panait | f149ee4 | 2021-11-30 18:33:56 +0200 | [diff] [blame] | 155 | swi r2, r4, 0x8 /* user vector exception - imm opcode */ |
| 156 | swi r3, r4, 0xC /* user vector exception - brai opcode */ |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 157 | |
| 158 | addik r6, r5, _exception_handler |
| 159 | sw r6, r1, r0 |
| 160 | /* |
| 161 | * BIG ENDIAN memory map for user exception |
| 162 | * 0x8: 0xB000XXXX |
| 163 | * 0xC: 0xB808XXXX |
| 164 | * |
| 165 | * then it is necessary to count address for storing the most significant |
| 166 | * 16bits from _exception_handler address and copy it to |
| 167 | * 0xa address. Big endian use offset in r10=0 that's why is it just |
| 168 | * 0xa address. The same is done for the least significant 16 bits |
| 169 | * for 0xe address. |
| 170 | * |
| 171 | * LITTLE ENDIAN memory map for user exception |
| 172 | * 0x8: 0xXXXX00B0 |
| 173 | * 0xC: 0xXXXX08B8 |
| 174 | * |
| 175 | * Offset is for little endian setup to 0x2. rsubi instruction decrease |
| 176 | * address value to ensure that points to proper place which is |
| 177 | * 0x8 for the most significant 16 bits and |
| 178 | * 0xC for the least significant 16 bits |
| 179 | */ |
| 180 | lhu r7, r1, r10 |
| 181 | rsubi r8, r10, 0xa |
Ovidiu Panait | f149ee4 | 2021-11-30 18:33:56 +0200 | [diff] [blame] | 182 | sh r7, r4, r8 |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 183 | rsubi r8, r10, 0xe |
Ovidiu Panait | f149ee4 | 2021-11-30 18:33:56 +0200 | [diff] [blame] | 184 | sh r6, r4, r8 |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 185 | #endif |
| 186 | |
| 187 | /* interrupt_handler */ |
Ovidiu Panait | f149ee4 | 2021-11-30 18:33:56 +0200 | [diff] [blame] | 188 | swi r2, r4, 0x10 /* interrupt - imm opcode */ |
| 189 | swi r3, r4, 0x14 /* interrupt - brai opcode */ |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 190 | |
| 191 | addik r6, r5, _interrupt_handler |
| 192 | sw r6, r1, r0 |
| 193 | lhu r7, r1, r10 |
| 194 | rsubi r8, r10, 0x12 |
Ovidiu Panait | f149ee4 | 2021-11-30 18:33:56 +0200 | [diff] [blame] | 195 | sh r7, r4, r8 |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 196 | rsubi r8, r10, 0x16 |
Ovidiu Panait | f149ee4 | 2021-11-30 18:33:56 +0200 | [diff] [blame] | 197 | sh r6, r4, r8 |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 198 | |
| 199 | /* hardware exception */ |
Ovidiu Panait | f149ee4 | 2021-11-30 18:33:56 +0200 | [diff] [blame] | 200 | swi r2, r4, 0x20 /* hardware exception - imm opcode */ |
| 201 | swi r3, r4, 0x24 /* hardware exception - brai opcode */ |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 202 | |
| 203 | addik r6, r5, _hw_exception_handler |
| 204 | sw r6, r1, r0 |
| 205 | lhu r7, r1, r10 |
| 206 | rsubi r8, r10, 0x22 |
Ovidiu Panait | f149ee4 | 2021-11-30 18:33:56 +0200 | [diff] [blame] | 207 | sh r7, r4, r8 |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 208 | rsubi r8, r10, 0x26 |
Ovidiu Panait | f149ee4 | 2021-11-30 18:33:56 +0200 | [diff] [blame] | 209 | sh r6, r4, r8 |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 210 | |
Ovidiu Panait | f149ee4 | 2021-11-30 18:33:56 +0200 | [diff] [blame] | 211 | lwi r10, r1, 28 |
| 212 | lwi r8, r1, 24 |
| 213 | lwi r7, r1, 20 |
| 214 | lwi r6, r1, 16 |
| 215 | lwi r4, r1, 12 |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 216 | lwi r3, r1, 8 |
| 217 | lwi r2, r1, 4 |
Ovidiu Panait | f149ee4 | 2021-11-30 18:33:56 +0200 | [diff] [blame] | 218 | addik r1, r1, 32 |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 219 | |
| 220 | rtsd r15, 8 |
| 221 | or r0, r0, r0 |
| 222 | .end __setup_exceptions |
| 223 | |
Michal Simek | 0643631 | 2007-04-21 21:02:40 +0200 | [diff] [blame] | 224 | /* |
| 225 | * Read 16bit little endian |
| 226 | */ |
| 227 | .text |
| 228 | .global in16 |
| 229 | .ent in16 |
| 230 | .align 2 |
| 231 | in16: lhu r3, r0, r5 |
| 232 | bslli r4, r3, 8 |
| 233 | bsrli r3, r3, 8 |
| 234 | andi r4, r4, 0xffff |
| 235 | or r3, r3, r4 |
| 236 | rtsd r15, 8 |
| 237 | sext16 r3, r3 |
| 238 | .end in16 |
| 239 | |
| 240 | /* |
| 241 | * Write 16bit little endian |
| 242 | * first parameter(r5) - address, second(r6) - short value |
| 243 | */ |
| 244 | .text |
| 245 | .global out16 |
| 246 | .ent out16 |
| 247 | .align 2 |
| 248 | out16: bslli r3, r6, 8 |
| 249 | bsrli r6, r6, 8 |
| 250 | andi r3, r3, 0xffff |
| 251 | or r3, r3, r6 |
| 252 | sh r3, r0, r5 |
| 253 | rtsd r15, 8 |
| 254 | or r0, r0, r0 |
| 255 | .end out16 |
Michal Simek | e945f6d | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 256 | |
| 257 | /* |
| 258 | * Relocate u-boot |
| 259 | */ |
| 260 | .text |
| 261 | .global relocate_code |
| 262 | .ent relocate_code |
| 263 | .align 2 |
| 264 | relocate_code: |
| 265 | /* |
| 266 | * r5 - start_addr_sp |
| 267 | * r6 - new_gd |
| 268 | * r7 - reloc_addr |
| 269 | */ |
| 270 | addi r1, r5, 0 /* Start to use new SP */ |
| 271 | addi r31, r6, 0 /* Start to use new GD */ |
| 272 | |
| 273 | add r23, r0, r7 /* Move reloc addr to r23 */ |
| 274 | /* Relocate text and data - r12 temp value */ |
| 275 | addi r21, r0, _start |
Michal Simek | 1918c41 | 2022-06-24 14:15:00 +0200 | [diff] [blame^] | 276 | addi r22, r0, _end /* Include BSS too */ |
| 277 | addi r22, r22, -4 |
Michal Simek | 7c4dd54 | 2015-01-27 15:10:37 +0100 | [diff] [blame] | 278 | |
| 279 | rsub r6, r21, r22 |
| 280 | or r5, r0, r0 |
| 281 | 1: lw r12, r21, r5 /* Load u-boot data */ |
| 282 | sw r12, r23, r5 /* Write zero to loc */ |
| 283 | cmp r12, r5, r6 /* Check if we have reach the end */ |
Michal Simek | e945f6d | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 284 | bneid r12, 1b |
Michal Simek | 7c4dd54 | 2015-01-27 15:10:37 +0100 | [diff] [blame] | 285 | addi r5, r5, 4 /* Increment to next loc - relocate code */ |
Michal Simek | e945f6d | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 286 | |
Michal Simek | 3ad95ed | 2019-10-21 12:20:16 +0200 | [diff] [blame] | 287 | /* R23 points to the base address. */ |
Michal Simek | e945f6d | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 288 | add r23, r0, r7 /* Move reloc addr to r23 */ |
Michal Simek | 65a4da9 | 2022-06-24 14:14:59 +0200 | [diff] [blame] | 289 | addi r24, r0, _start /* Get reloc offset */ |
Michal Simek | e945f6d | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 290 | rsub r23, r24, r23 /* keep - this is already here gd->reloc_off */ |
| 291 | |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 292 | /* Setup vectors with post-relocation symbols */ |
| 293 | add r5, r0, r23 /* load gd->reloc_off to r5 */ |
Michal Simek | 7cf236c | 2022-06-24 14:14:59 +0200 | [diff] [blame] | 294 | brlid r15, __setup_exceptions |
Ovidiu Panait | 627085e | 2020-09-24 11:54:36 +0300 | [diff] [blame] | 295 | nop |
Michal Simek | e945f6d | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 296 | |
| 297 | /* Check if GOT exist */ |
| 298 | addik r21, r23, _got_start |
| 299 | addik r22, r23, _got_end |
| 300 | cmpu r12, r21, r22 |
| 301 | beqi r12, 2f /* No GOT table - jump over */ |
| 302 | |
| 303 | /* Skip last 3 entries plus 1 because of loop boundary below */ |
| 304 | addik r22, r22, -0x10 |
| 305 | |
| 306 | /* Relocate the GOT. */ |
| 307 | 3: lw r12, r21, r0 /* Load entry */ |
| 308 | addk r12, r12, r23 /* Add reloc offset */ |
| 309 | sw r12, r21, r0 /* Save entry back */ |
| 310 | |
| 311 | cmpu r12, r21, r22 /* Check if this cross boundary */ |
| 312 | bneid r12, 3b |
| 313 | addik r21. r21, 4 |
| 314 | |
| 315 | /* Update pointer to GOT */ |
| 316 | mfs r20, rpc |
| 317 | addik r20, r20, _GLOBAL_OFFSET_TABLE_ + 8 |
| 318 | addk r20, r20, r23 |
| 319 | |
| 320 | /* Flush caches to ensure consistency */ |
| 321 | addik r5, r0, 0 |
| 322 | addik r6, r0, XILINX_DCACHE_BYTE_SIZE |
Michal Simek | 7cf236c | 2022-06-24 14:14:59 +0200 | [diff] [blame] | 323 | brlid r15, flush_cache |
Michal Simek | e945f6d | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 324 | nop |
| 325 | |
| 326 | 2: addi r5, r31, 0 /* gd is initialized in board_r.c */ |
Michal Simek | 65a4da9 | 2022-06-24 14:14:59 +0200 | [diff] [blame] | 327 | addi r6, r0, _start |
Michal Simek | e945f6d | 2014-05-08 16:08:44 +0200 | [diff] [blame] | 328 | addi r12, r23, board_init_r |
| 329 | bra r12 /* Jump to relocated code */ |
| 330 | |
| 331 | .end relocate_code |
Michal Simek | 9d24274 | 2014-01-21 07:30:37 +0100 | [diff] [blame] | 332 | #endif |