Roberto Vargas | e0e9946 | 2017-10-30 14:43:43 +0000 | [diff] [blame] | 1 | /* |
Anthony Steinhauser | 0f7e601 | 2020-01-07 15:44:06 -0800 | [diff] [blame] | 2 | * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved. |
Roberto Vargas | e0e9946 | 2017-10-30 14:43:43 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Masahiro Yamada | 65d699d | 2020-01-17 13:45:02 +0900 | [diff] [blame] | 7 | #include <platform_def.h> |
| 8 | |
Roberto Vargas | e0e9946 | 2017-10-30 14:43:43 +0000 | [diff] [blame] | 9 | #include <arch.h> |
| 10 | #include <asm_macros.S> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 11 | #include <common/bl_common.h> |
Roberto Vargas | e0e9946 | 2017-10-30 14:43:43 +0000 | [diff] [blame] | 12 | #include <el3_common_macros.S> |
| 13 | |
| 14 | .globl bl2_entrypoint |
Roberto Vargas | e0e9946 | 2017-10-30 14:43:43 +0000 | [diff] [blame] | 15 | .globl bl2_el3_run_image |
| 16 | .globl bl2_run_next_image |
| 17 | |
Masahiro Yamada | 65d699d | 2020-01-17 13:45:02 +0900 | [diff] [blame] | 18 | #if BL2_IN_XIP_MEM |
| 19 | #define FIXUP_SIZE 0 |
| 20 | #else |
| 21 | #define FIXUP_SIZE ((BL2_LIMIT) - (BL2_BASE)) |
| 22 | #endif |
| 23 | |
Roberto Vargas | e0e9946 | 2017-10-30 14:43:43 +0000 | [diff] [blame] | 24 | func bl2_entrypoint |
| 25 | /* Save arguments x0-x3 from previous Boot loader */ |
| 26 | mov x20, x0 |
| 27 | mov x21, x1 |
| 28 | mov x22, x2 |
| 29 | mov x23, x3 |
| 30 | |
| 31 | el3_entrypoint_common \ |
| 32 | _init_sctlr=1 \ |
| 33 | _warm_boot_mailbox=!PROGRAMMABLE_RESET_ADDRESS \ |
| 34 | _secondary_cold_boot=!COLD_BOOT_SINGLE_CPU \ |
| 35 | _init_memory=1 \ |
| 36 | _init_c_runtime=1 \ |
Manish Pandey | c825768 | 2019-11-26 11:34:17 +0000 | [diff] [blame] | 37 | _exception_vectors=bl2_el3_exceptions \ |
Masahiro Yamada | 65d699d | 2020-01-17 13:45:02 +0900 | [diff] [blame] | 38 | _pie_fixup_size=FIXUP_SIZE |
Roberto Vargas | e0e9946 | 2017-10-30 14:43:43 +0000 | [diff] [blame] | 39 | |
Antonio Nino Diaz | 4f29fb7 | 2019-01-31 17:40:44 +0000 | [diff] [blame] | 40 | /* --------------------------------------------- |
Roberto Vargas | e0e9946 | 2017-10-30 14:43:43 +0000 | [diff] [blame] | 41 | * Restore parameters of boot rom |
Antonio Nino Diaz | 4f29fb7 | 2019-01-31 17:40:44 +0000 | [diff] [blame] | 42 | * --------------------------------------------- |
Roberto Vargas | e0e9946 | 2017-10-30 14:43:43 +0000 | [diff] [blame] | 43 | */ |
| 44 | mov x0, x20 |
| 45 | mov x1, x21 |
| 46 | mov x2, x22 |
| 47 | mov x3, x23 |
| 48 | |
Antonio Nino Diaz | 4f29fb7 | 2019-01-31 17:40:44 +0000 | [diff] [blame] | 49 | /* --------------------------------------------- |
| 50 | * Perform BL2 setup |
| 51 | * --------------------------------------------- |
| 52 | */ |
| 53 | bl bl2_el3_setup |
| 54 | |
Antonio Nino Diaz | 4f29fb7 | 2019-01-31 17:40:44 +0000 | [diff] [blame] | 55 | #if ENABLE_PAUTH |
Alexei Fedorov | 90f2e88 | 2019-05-24 12:17:09 +0100 | [diff] [blame] | 56 | /* --------------------------------------------- |
Alexei Fedorov | f41355c | 2019-09-13 14:11:59 +0100 | [diff] [blame] | 57 | * Program APIAKey_EL1 and enable pointer authentication. |
Alexei Fedorov | 90f2e88 | 2019-05-24 12:17:09 +0100 | [diff] [blame] | 58 | * --------------------------------------------- |
| 59 | */ |
Alexei Fedorov | f41355c | 2019-09-13 14:11:59 +0100 | [diff] [blame] | 60 | bl pauth_init_enable_el3 |
Antonio Nino Diaz | 4f29fb7 | 2019-01-31 17:40:44 +0000 | [diff] [blame] | 61 | #endif /* ENABLE_PAUTH */ |
Roberto Vargas | e0e9946 | 2017-10-30 14:43:43 +0000 | [diff] [blame] | 62 | |
| 63 | /* --------------------------------------------- |
| 64 | * Jump to main function. |
| 65 | * --------------------------------------------- |
| 66 | */ |
| 67 | bl bl2_main |
| 68 | |
| 69 | /* --------------------------------------------- |
| 70 | * Should never reach this point. |
| 71 | * --------------------------------------------- |
| 72 | */ |
| 73 | no_ret plat_panic_handler |
| 74 | endfunc bl2_entrypoint |
| 75 | |
| 76 | func bl2_run_next_image |
| 77 | mov x20,x0 |
Antonio Nino Diaz | 4f29fb7 | 2019-01-31 17:40:44 +0000 | [diff] [blame] | 78 | /* --------------------------------------------- |
| 79 | * MMU needs to be disabled because both BL2 and BL31 execute |
| 80 | * in EL3, and therefore share the same address space. |
| 81 | * BL31 will initialize the address space according to its |
| 82 | * own requirement. |
| 83 | * --------------------------------------------- |
| 84 | */ |
Roberto Vargas | e0e9946 | 2017-10-30 14:43:43 +0000 | [diff] [blame] | 85 | bl disable_mmu_icache_el3 |
| 86 | tlbi alle3 |
| 87 | bl bl2_el3_plat_prepare_exit |
| 88 | |
Alexei Fedorov | f41355c | 2019-09-13 14:11:59 +0100 | [diff] [blame] | 89 | #if ENABLE_PAUTH |
Antonio Nino Diaz | 4f29fb7 | 2019-01-31 17:40:44 +0000 | [diff] [blame] | 90 | /* --------------------------------------------- |
Alexei Fedorov | f41355c | 2019-09-13 14:11:59 +0100 | [diff] [blame] | 91 | * Disable pointer authentication before jumping |
| 92 | * to next boot image. |
Antonio Nino Diaz | 4f29fb7 | 2019-01-31 17:40:44 +0000 | [diff] [blame] | 93 | * --------------------------------------------- |
| 94 | */ |
Alexei Fedorov | f41355c | 2019-09-13 14:11:59 +0100 | [diff] [blame] | 95 | bl pauth_disable_el3 |
Antonio Nino Diaz | 4f29fb7 | 2019-01-31 17:40:44 +0000 | [diff] [blame] | 96 | #endif /* ENABLE_PAUTH */ |
| 97 | |
Roberto Vargas | e0e9946 | 2017-10-30 14:43:43 +0000 | [diff] [blame] | 98 | ldp x0, x1, [x20, #ENTRY_POINT_INFO_PC_OFFSET] |
| 99 | msr elr_el3, x0 |
| 100 | msr spsr_el3, x1 |
| 101 | |
| 102 | ldp x6, x7, [x20, #(ENTRY_POINT_INFO_ARGS_OFFSET + 0x30)] |
| 103 | ldp x4, x5, [x20, #(ENTRY_POINT_INFO_ARGS_OFFSET + 0x20)] |
| 104 | ldp x2, x3, [x20, #(ENTRY_POINT_INFO_ARGS_OFFSET + 0x10)] |
| 105 | ldp x0, x1, [x20, #(ENTRY_POINT_INFO_ARGS_OFFSET + 0x0)] |
Anthony Steinhauser | 0f7e601 | 2020-01-07 15:44:06 -0800 | [diff] [blame] | 106 | exception_return |
Roberto Vargas | e0e9946 | 2017-10-30 14:43:43 +0000 | [diff] [blame] | 107 | endfunc bl2_run_next_image |