Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 1 | /* |
Zelalem Aweke | 688fbf7 | 2021-07-09 11:37:10 -0500 | [diff] [blame] | 2 | * Copyright (c) 2013-2021, Arm Limited and Contributors. All rights reserved. |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
Sandrine Bailleux | c10bd2c | 2013-11-12 16:41:16 +0000 | [diff] [blame] | 7 | #include <arch.h> |
Zelalem Aweke | 688fbf7 | 2021-07-09 11:37:10 -0500 | [diff] [blame] | 8 | #include <common/bl_common.h> |
Sandrine Bailleux | acde8b0 | 2015-05-19 11:54:45 +0100 | [diff] [blame] | 9 | #include <el3_common_macros.S> |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 10 | |
Jeenu Viswambharan | 2a30a75 | 2014-03-11 11:06:45 +0000 | [diff] [blame] | 11 | .globl bl1_entrypoint |
Zelalem Aweke | 688fbf7 | 2021-07-09 11:37:10 -0500 | [diff] [blame] | 12 | .globl bl1_run_bl2_in_root |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 13 | |
| 14 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 15 | /* ----------------------------------------------------- |
Jeenu Viswambharan | 2a30a75 | 2014-03-11 11:06:45 +0000 | [diff] [blame] | 16 | * bl1_entrypoint() is the entry point into the trusted |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 17 | * firmware code when a cpu is released from warm or |
| 18 | * cold reset. |
| 19 | * ----------------------------------------------------- |
| 20 | */ |
| 21 | |
Andrew Thoelke | 38bde41 | 2014-03-18 13:46:55 +0000 | [diff] [blame] | 22 | func bl1_entrypoint |
Sandrine Bailleux | 449dbd5 | 2015-06-02 17:19:43 +0100 | [diff] [blame] | 23 | /* --------------------------------------------------------------------- |
| 24 | * If the reset address is programmable then bl1_entrypoint() is |
| 25 | * executed only on the cold boot path. Therefore, we can skip the warm |
| 26 | * boot mailbox mechanism. |
| 27 | * --------------------------------------------------------------------- |
| 28 | */ |
Sandrine Bailleux | acde8b0 | 2015-05-19 11:54:45 +0100 | [diff] [blame] | 29 | el3_entrypoint_common \ |
David Cunado | fee8653 | 2017-04-13 22:38:29 +0100 | [diff] [blame] | 30 | _init_sctlr=1 \ |
Sandrine Bailleux | 449dbd5 | 2015-06-02 17:19:43 +0100 | [diff] [blame] | 31 | _warm_boot_mailbox=!PROGRAMMABLE_RESET_ADDRESS \ |
Sandrine Bailleux | b21b02f | 2015-10-30 15:05:17 +0000 | [diff] [blame] | 32 | _secondary_cold_boot=!COLD_BOOT_SINGLE_CPU \ |
Sandrine Bailleux | acde8b0 | 2015-05-19 11:54:45 +0100 | [diff] [blame] | 33 | _init_memory=1 \ |
| 34 | _init_c_runtime=1 \ |
Manish Pandey | c825768 | 2019-11-26 11:34:17 +0000 | [diff] [blame] | 35 | _exception_vectors=bl1_exceptions \ |
| 36 | _pie_fixup_size=0 |
Vikram Kanigiri | 9637745 | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 37 | |
Antonio Nino Diaz | e3887a9 | 2019-01-30 20:29:50 +0000 | [diff] [blame] | 38 | /* -------------------------------------------------------------------- |
| 39 | * Perform BL1 setup |
| 40 | * -------------------------------------------------------------------- |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 41 | */ |
Antonio Nino Diaz | e3887a9 | 2019-01-30 20:29:50 +0000 | [diff] [blame] | 42 | bl bl1_setup |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 43 | |
Alexei Fedorov | f41355c | 2019-09-13 14:11:59 +0100 | [diff] [blame] | 44 | #if ENABLE_PAUTH |
Antonio Nino Diaz | e3887a9 | 2019-01-30 20:29:50 +0000 | [diff] [blame] | 45 | /* -------------------------------------------------------------------- |
Alexei Fedorov | f41355c | 2019-09-13 14:11:59 +0100 | [diff] [blame] | 46 | * Program APIAKey_EL1 and enable pointer authentication. |
Antonio Nino Diaz | e3887a9 | 2019-01-30 20:29:50 +0000 | [diff] [blame] | 47 | * -------------------------------------------------------------------- |
| 48 | */ |
Alexei Fedorov | f41355c | 2019-09-13 14:11:59 +0100 | [diff] [blame] | 49 | bl pauth_init_enable_el3 |
Antonio Nino Diaz | e3887a9 | 2019-01-30 20:29:50 +0000 | [diff] [blame] | 50 | #endif /* ENABLE_PAUTH */ |
| 51 | |
| 52 | /* -------------------------------------------------------------------- |
Vikram Kanigiri | 9637745 | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 53 | * Initialize platform and jump to our c-entry point |
Yatharth Kochar | a65be2f | 2015-10-09 18:06:13 +0100 | [diff] [blame] | 54 | * for this type of reset. |
Antonio Nino Diaz | e3887a9 | 2019-01-30 20:29:50 +0000 | [diff] [blame] | 55 | * -------------------------------------------------------------------- |
Vikram Kanigiri | 9637745 | 2014-04-24 11:02:16 +0100 | [diff] [blame] | 56 | */ |
| 57 | bl bl1_main |
Yatharth Kochar | a65be2f | 2015-10-09 18:06:13 +0100 | [diff] [blame] | 58 | |
Alexei Fedorov | f41355c | 2019-09-13 14:11:59 +0100 | [diff] [blame] | 59 | #if ENABLE_PAUTH |
Antonio Nino Diaz | e3887a9 | 2019-01-30 20:29:50 +0000 | [diff] [blame] | 60 | /* -------------------------------------------------------------------- |
Alexei Fedorov | f41355c | 2019-09-13 14:11:59 +0100 | [diff] [blame] | 61 | * Disable pointer authentication before jumping to next boot image. |
Antonio Nino Diaz | e3887a9 | 2019-01-30 20:29:50 +0000 | [diff] [blame] | 62 | * -------------------------------------------------------------------- |
| 63 | */ |
Alexei Fedorov | f41355c | 2019-09-13 14:11:59 +0100 | [diff] [blame] | 64 | bl pauth_disable_el3 |
Antonio Nino Diaz | e3887a9 | 2019-01-30 20:29:50 +0000 | [diff] [blame] | 65 | #endif /* ENABLE_PAUTH */ |
| 66 | |
Yatharth Kochar | a65be2f | 2015-10-09 18:06:13 +0100 | [diff] [blame] | 67 | /* -------------------------------------------------- |
| 68 | * Do the transition to next boot image. |
| 69 | * -------------------------------------------------- |
| 70 | */ |
Zelalem Aweke | 688fbf7 | 2021-07-09 11:37:10 -0500 | [diff] [blame] | 71 | #if ENABLE_RME |
| 72 | b bl1_run_bl2_in_root |
| 73 | #else |
Yatharth Kochar | a65be2f | 2015-10-09 18:06:13 +0100 | [diff] [blame] | 74 | b el3_exit |
Zelalem Aweke | 688fbf7 | 2021-07-09 11:37:10 -0500 | [diff] [blame] | 75 | #endif |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 76 | endfunc bl1_entrypoint |
Zelalem Aweke | 688fbf7 | 2021-07-09 11:37:10 -0500 | [diff] [blame] | 77 | |
| 78 | /* ----------------------------------------------------- |
| 79 | * void bl1_run_bl2_in_root(); |
| 80 | * This function runs BL2 in root/EL3 when RME is enabled. |
| 81 | * ----------------------------------------------------- |
| 82 | */ |
| 83 | |
| 84 | func bl1_run_bl2_in_root |
| 85 | /* read bl2_ep_info */ |
| 86 | adrp x20, bl2_ep_info |
| 87 | add x20, x20, :lo12:bl2_ep_info |
| 88 | ldr x20, [x20] |
| 89 | |
| 90 | /* --------------------------------------------- |
| 91 | * MMU needs to be disabled because BL2 executes |
| 92 | * in EL3. It will initialize the address space |
| 93 | * according to its own requirements. |
| 94 | * --------------------------------------------- |
| 95 | */ |
| 96 | bl disable_mmu_icache_el3 |
| 97 | tlbi alle3 |
| 98 | |
| 99 | ldp x0, x1, [x20, #ENTRY_POINT_INFO_PC_OFFSET] |
| 100 | msr elr_el3, x0 |
| 101 | msr spsr_el3, x1 |
| 102 | |
| 103 | ldp x6, x7, [x20, #(ENTRY_POINT_INFO_ARGS_OFFSET + 0x30)] |
| 104 | ldp x4, x5, [x20, #(ENTRY_POINT_INFO_ARGS_OFFSET + 0x20)] |
| 105 | ldp x2, x3, [x20, #(ENTRY_POINT_INFO_ARGS_OFFSET + 0x10)] |
| 106 | ldp x0, x1, [x20, #(ENTRY_POINT_INFO_ARGS_OFFSET + 0x0)] |
| 107 | exception_return |
| 108 | endfunc bl1_run_bl2_in_root |