Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Peng Fan | eae4de2 | 2018-01-10 13:20:37 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2017 NXP |
Peng Fan | eae4de2 | 2018-01-10 13:20:37 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <config.h> |
| 7 | |
| 8 | .align 8 |
| 9 | .global rom_pointer |
| 10 | rom_pointer: |
| 11 | .space 256 |
| 12 | |
| 13 | /* |
| 14 | * Routine: save_boot_params (called after reset from start.S) |
| 15 | */ |
| 16 | |
| 17 | .global save_boot_params |
| 18 | save_boot_params: |
| 19 | /* The firmware provided ATAG/FDT address can be found in r2/x0 */ |
| 20 | adr x0, rom_pointer |
| 21 | stp x1, x2, [x0], #16 |
| 22 | stp x3, x4, [x0], #16 |
| 23 | stp x5, x6, [x0], #16 |
| 24 | stp x7, x8, [x0], #16 |
| 25 | stp x9, x10, [x0], #16 |
| 26 | stp x11, x12, [x0], #16 |
| 27 | stp x13, x14, [x0], #16 |
| 28 | stp x15, x16, [x0], #16 |
| 29 | stp x17, x18, [x0], #16 |
| 30 | stp x19, x20, [x0], #16 |
| 31 | stp x21, x22, [x0], #16 |
| 32 | stp x23, x24, [x0], #16 |
| 33 | stp x25, x26, [x0], #16 |
| 34 | stp x27, x28, [x0], #16 |
| 35 | stp x29, x30, [x0], #16 |
| 36 | mov x30, sp |
| 37 | str x30, [x0], #8 |
| 38 | |
| 39 | /* Returns */ |
| 40 | b save_boot_params_ret |
| 41 | |
| 42 | .global restore_boot_params |
| 43 | restore_boot_params: |
| 44 | adr x0, rom_pointer |
| 45 | ldp x1, x2, [x0], #16 |
| 46 | ldp x3, x4, [x0], #16 |
| 47 | ldp x5, x6, [x0], #16 |
| 48 | ldp x7, x8, [x0], #16 |
| 49 | ldp x9, x10, [x0], #16 |
| 50 | ldp x11, x12, [x0], #16 |
| 51 | ldp x13, x14, [x0], #16 |
| 52 | ldp x15, x16, [x0], #16 |
| 53 | ldp x17, x18, [x0], #16 |
| 54 | ldp x19, x20, [x0], #16 |
| 55 | ldp x21, x22, [x0], #16 |
| 56 | ldp x23, x24, [x0], #16 |
| 57 | ldp x25, x26, [x0], #16 |
| 58 | ldp x27, x28, [x0], #16 |
| 59 | ldp x29, x30, [x0], #16 |
| 60 | ldr x0, [x0] |
| 61 | mov sp, x0 |
| 62 | ret |
Peng Fan | 85447c1 | 2020-07-10 11:22:20 +0800 | [diff] [blame] | 63 | |
| 64 | .global armv8_el2_to_aarch32 |
| 65 | armv8_el2_to_aarch32: |
| 66 | cmp x0, #0 |
| 67 | bne 0f |
| 68 | mov x3, x2 |
| 69 | mov x2, x1 |
| 70 | mov x1, x4 |
| 71 | ldr x0, =0xc20000fd |
| 72 | 0: |
| 73 | smc #0 |
| 74 | ret |