Patrick Rudolph | cb42bc8 | 2024-10-23 15:20:08 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | /* |
| 3 | * sbsa-ref starts U-Boot in XIP memory. Need to relocate U-Boot |
| 4 | * to DRAM which is already up. Instead of using SPL this simple loader |
| 5 | * is being used. |
| 6 | */ |
| 7 | relocate_check: |
| 8 | /* x0 contains the pointer to FDT provided by ATF */ |
| 9 | adr x1, _start /* x1 <- Runtime value of _start */ |
| 10 | ldr x2, _TEXT_BASE /* x2 <- Linked value of _start */ |
| 11 | subs x9, x1, x2 /* x9 <- Run-vs-link offset */ |
| 12 | beq reset |
| 13 | |
| 14 | adrp x1, __image_copy_start /* x2 <- address bits [31:12] */ |
| 15 | add x1, x1, :lo12:__image_copy_start/* x2 <- address bits [11:00] */ |
| 16 | adrp x3, __image_copy_end /* x3 <- address bits [31:12] */ |
| 17 | add x3, x3, :lo12:__image_copy_end /* x3 <- address bits [11:00] */ |
| 18 | add x3, x3, #0x100000 /* 1 MiB for the DTB found at _end */ |
| 19 | |
| 20 | copy_loop: |
| 21 | ldp x10, x11, [x1], #16 /* copy from source address [x1] */ |
| 22 | stp x10, x11, [x2], #16 /* copy to target address [x2] */ |
| 23 | cmp x1, x3 /* until source end address [x3] */ |
| 24 | b.lo copy_loop |
| 25 | |
| 26 | isb |
| 27 | ldr x2, _TEXT_BASE /* x2 <- Linked value of _start */ |
| 28 | br x2 /* Jump to linked address */ |
| 29 | /* Never reaches this point */ |
| 30 | 1: |
| 31 | wfi |
| 32 | b 1b |
| 33 | |
| 34 | relocate_done: |