Yatharth Kochar | 5d36121 | 2016-06-28 17:07:09 +0100 | [diff] [blame] | 1 | /* |
Yann Gautier | c142587 | 2019-02-15 16:42:20 +0100 | [diff] [blame] | 2 | * Copyright (c) 2016-2022, ARM Limited and Contributors. All rights reserved. |
Yatharth Kochar | 5d36121 | 2016-06-28 17:07:09 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Yatharth Kochar | 5d36121 | 2016-06-28 17:07:09 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <arch.h> |
| 8 | #include <asm_macros.S> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 9 | #include <common/bl_common.h> |
Yatharth Kochar | 5d36121 | 2016-06-28 17:07:09 +0100 | [diff] [blame] | 10 | #include <context.h> |
| 11 | #include <el3_common_macros.S> |
Antonio Nino Diaz | 3c817f4 | 2018-03-21 10:49:27 +0000 | [diff] [blame] | 12 | #include <smccc_helpers.h> |
| 13 | #include <smccc_macros.S> |
Yatharth Kochar | 5d36121 | 2016-06-28 17:07:09 +0100 | [diff] [blame] | 14 | |
| 15 | .globl bl1_vector_table |
| 16 | .globl bl1_entrypoint |
| 17 | |
| 18 | /* ----------------------------------------------------- |
| 19 | * Setup the vector table to support SVC & MON mode. |
| 20 | * ----------------------------------------------------- |
| 21 | */ |
| 22 | vector_base bl1_vector_table |
| 23 | b bl1_entrypoint |
| 24 | b report_exception /* Undef */ |
| 25 | b bl1_aarch32_smc_handler /* SMC call */ |
Yann Gautier | c142587 | 2019-02-15 16:42:20 +0100 | [diff] [blame] | 26 | b report_prefetch_abort /* Prefetch abort */ |
| 27 | b report_data_abort /* Data abort */ |
Yatharth Kochar | 5d36121 | 2016-06-28 17:07:09 +0100 | [diff] [blame] | 28 | b report_exception /* Reserved */ |
| 29 | b report_exception /* IRQ */ |
| 30 | b report_exception /* FIQ */ |
| 31 | |
| 32 | /* ----------------------------------------------------- |
| 33 | * bl1_entrypoint() is the entry point into the trusted |
| 34 | * firmware code when a cpu is released from warm or |
| 35 | * cold reset. |
| 36 | * ----------------------------------------------------- |
| 37 | */ |
| 38 | |
| 39 | func bl1_entrypoint |
| 40 | /* --------------------------------------------------------------------- |
| 41 | * If the reset address is programmable then bl1_entrypoint() is |
| 42 | * executed only on the cold boot path. Therefore, we can skip the warm |
| 43 | * boot mailbox mechanism. |
| 44 | * --------------------------------------------------------------------- |
| 45 | */ |
| 46 | el3_entrypoint_common \ |
David Cunado | fee8653 | 2017-04-13 22:38:29 +0100 | [diff] [blame] | 47 | _init_sctlr=1 \ |
Yatharth Kochar | 5d36121 | 2016-06-28 17:07:09 +0100 | [diff] [blame] | 48 | _warm_boot_mailbox=!PROGRAMMABLE_RESET_ADDRESS \ |
| 49 | _secondary_cold_boot=!COLD_BOOT_SINGLE_CPU \ |
| 50 | _init_memory=1 \ |
| 51 | _init_c_runtime=1 \ |
Yann Gautier | 514e59c | 2020-10-05 11:02:54 +0200 | [diff] [blame] | 52 | _exception_vectors=bl1_vector_table \ |
| 53 | _pie_fixup_size=0 |
Yatharth Kochar | 5d36121 | 2016-06-28 17:07:09 +0100 | [diff] [blame] | 54 | |
| 55 | /* ----------------------------------------------------- |
Antonio Nino Diaz | e3887a9 | 2019-01-30 20:29:50 +0000 | [diff] [blame] | 56 | * Perform BL1 setup |
Yatharth Kochar | 5d36121 | 2016-06-28 17:07:09 +0100 | [diff] [blame] | 57 | * ----------------------------------------------------- |
| 58 | */ |
Antonio Nino Diaz | e3887a9 | 2019-01-30 20:29:50 +0000 | [diff] [blame] | 59 | bl bl1_setup |
Yatharth Kochar | 5d36121 | 2016-06-28 17:07:09 +0100 | [diff] [blame] | 60 | |
| 61 | /* ----------------------------------------------------- |
| 62 | * Jump to main function. |
| 63 | * ----------------------------------------------------- |
| 64 | */ |
| 65 | bl bl1_main |
| 66 | |
| 67 | /* ----------------------------------------------------- |
| 68 | * Jump to next image. |
| 69 | * ----------------------------------------------------- |
| 70 | */ |
| 71 | |
| 72 | /* |
dp-arm | cdd03cb | 2017-02-15 11:07:55 +0000 | [diff] [blame] | 73 | * Get the smc_context for next BL image, |
| 74 | * program the gp/system registers and save it in `r4`. |
| 75 | */ |
| 76 | bl smc_get_next_ctx |
| 77 | mov r4, r0 |
| 78 | |
| 79 | /* Only turn-off MMU if going to secure world */ |
| 80 | ldr r5, [r4, #SMC_CTX_SCR] |
| 81 | tst r5, #SCR_NS_BIT |
| 82 | bne skip_mmu_off |
| 83 | |
| 84 | /* |
| 85 | * MMU needs to be disabled because both BL1 and BL2/BL2U execute |
Yatharth Kochar | 5d36121 | 2016-06-28 17:07:09 +0100 | [diff] [blame] | 86 | * in PL1, and therefore share the same address space. |
dp-arm | cdd03cb | 2017-02-15 11:07:55 +0000 | [diff] [blame] | 87 | * BL2/BL2U will initialize the address space according to its |
Yatharth Kochar | 5d36121 | 2016-06-28 17:07:09 +0100 | [diff] [blame] | 88 | * own requirement. |
| 89 | */ |
| 90 | bl disable_mmu_icache_secure |
| 91 | stcopr r0, TLBIALL |
| 92 | dsb sy |
| 93 | isb |
| 94 | |
dp-arm | cdd03cb | 2017-02-15 11:07:55 +0000 | [diff] [blame] | 95 | skip_mmu_off: |
| 96 | /* Restore smc_context from `r4` and exit secure monitor mode. */ |
| 97 | mov r0, r4 |
Soby Mathew | f3e3a43 | 2017-03-30 14:42:54 +0100 | [diff] [blame] | 98 | monitor_exit |
Yatharth Kochar | 5d36121 | 2016-06-28 17:07:09 +0100 | [diff] [blame] | 99 | endfunc bl1_entrypoint |