xref: /rk3399_ARM-atf/bl1/aarch32/bl1_entrypoint.S (revision dfdb73f77317b1349e383c5836454db67f8643d3)
1f3b4914bSYatharth Kochar/*
2*d158d425SBoyan Karatotev * Copyright (c) 2016-2025, Arm Limited and Contributors. All rights reserved.
3f3b4914bSYatharth Kochar *
482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause
5f3b4914bSYatharth Kochar */
6f3b4914bSYatharth Kochar
7f3b4914bSYatharth Kochar#include <arch.h>
8f3b4914bSYatharth Kochar#include <asm_macros.S>
909d40e0eSAntonio Nino Diaz#include <common/bl_common.h>
10f3b4914bSYatharth Kochar#include <context.h>
11f3b4914bSYatharth Kochar#include <el3_common_macros.S>
12085e80ecSAntonio Nino Diaz#include <smccc_helpers.h>
13085e80ecSAntonio Nino Diaz#include <smccc_macros.S>
14f3b4914bSYatharth Kochar
15f3b4914bSYatharth Kochar	.globl	bl1_vector_table
16f3b4914bSYatharth Kochar	.globl	bl1_entrypoint
17f3b4914bSYatharth Kochar
18f3b4914bSYatharth Kochar	/* -----------------------------------------------------
19f3b4914bSYatharth Kochar	 * Setup the vector table to support SVC & MON mode.
20f3b4914bSYatharth Kochar	 * -----------------------------------------------------
21f3b4914bSYatharth Kochar	 */
22f3b4914bSYatharth Kocharvector_base bl1_vector_table
23f3b4914bSYatharth Kochar	b	bl1_entrypoint
24f3b4914bSYatharth Kochar	b	report_exception	/* Undef */
25f3b4914bSYatharth Kochar	b	bl1_aarch32_smc_handler	/* SMC call */
266dc5979aSYann Gautier	b	report_prefetch_abort	/* Prefetch abort */
276dc5979aSYann Gautier	b	report_data_abort	/* Data abort */
28f3b4914bSYatharth Kochar	b	report_exception	/* Reserved */
29f3b4914bSYatharth Kochar	b	report_exception	/* IRQ */
30f3b4914bSYatharth Kochar	b	report_exception	/* FIQ */
31f3b4914bSYatharth Kochar
32f3b4914bSYatharth Kochar	/* -----------------------------------------------------
33f3b4914bSYatharth Kochar	 * bl1_entrypoint() is the entry point into the trusted
34f3b4914bSYatharth Kochar	 * firmware code when a cpu is released from warm or
35f3b4914bSYatharth Kochar	 * cold reset.
36f3b4914bSYatharth Kochar	 * -----------------------------------------------------
37f3b4914bSYatharth Kochar	 */
38f3b4914bSYatharth Kochar
39f3b4914bSYatharth Kocharfunc bl1_entrypoint
40f3b4914bSYatharth Kochar/* ---------------------------------------------------------------------
41f3b4914bSYatharth Kochar* If the reset address is programmable then bl1_entrypoint() is
42f3b4914bSYatharth Kochar* executed only on the cold boot path. Therefore, we can skip the warm
43f3b4914bSYatharth Kochar* boot mailbox mechanism.
44f3b4914bSYatharth Kochar* ---------------------------------------------------------------------
45f3b4914bSYatharth Kochar*/
46f3b4914bSYatharth Kochar	el3_entrypoint_common					\
4718f2efd6SDavid Cunado		_init_sctlr=1					\
48f3b4914bSYatharth Kochar		_warm_boot_mailbox=!PROGRAMMABLE_RESET_ADDRESS	\
49f3b4914bSYatharth Kochar		_secondary_cold_boot=!COLD_BOOT_SINGLE_CPU	\
50f3b4914bSYatharth Kochar		_init_memory=1					\
51f3b4914bSYatharth Kochar		_init_c_runtime=1				\
524324a14bSYann Gautier		_exception_vectors=bl1_vector_table		\
534324a14bSYann Gautier		_pie_fixup_size=0
54f3b4914bSYatharth Kochar
55f3b4914bSYatharth Kochar	/* -----------------------------------------------------
56f3b4914bSYatharth Kochar	 * Jump to main function.
57f3b4914bSYatharth Kochar	 * -----------------------------------------------------
58f3b4914bSYatharth Kochar	 */
59f3b4914bSYatharth Kochar	bl	bl1_main
60f3b4914bSYatharth Kochar
61f3b4914bSYatharth Kochar	/* -----------------------------------------------------
62f3b4914bSYatharth Kochar	 * Jump to next image.
63f3b4914bSYatharth Kochar	 * -----------------------------------------------------
64f3b4914bSYatharth Kochar	 */
65f3b4914bSYatharth Kochar
66f3b4914bSYatharth Kochar	/*
67a4409008Sdp-arm	 * Get the smc_context for next BL image,
68a4409008Sdp-arm	 * program the gp/system registers and save it in `r4`.
69a4409008Sdp-arm	 */
70a4409008Sdp-arm	bl	smc_get_next_ctx
71a4409008Sdp-arm	mov	r4, r0
72a4409008Sdp-arm
73a4409008Sdp-arm	/* Only turn-off MMU if going to secure world */
74a4409008Sdp-arm	ldr	r5, [r4, #SMC_CTX_SCR]
75a4409008Sdp-arm	tst	r5, #SCR_NS_BIT
76a4409008Sdp-arm	bne	skip_mmu_off
77a4409008Sdp-arm
78a4409008Sdp-arm	/*
79a4409008Sdp-arm	 * MMU needs to be disabled because both BL1 and BL2/BL2U execute
80f3b4914bSYatharth Kochar	 * in PL1, and therefore share the same address space.
81a4409008Sdp-arm	 * BL2/BL2U will initialize the address space according to its
82f3b4914bSYatharth Kochar	 * own requirement.
83f3b4914bSYatharth Kochar	 */
84f3b4914bSYatharth Kochar	bl	disable_mmu_icache_secure
85f3b4914bSYatharth Kochar	stcopr	r0, TLBIALL
86f3b4914bSYatharth Kochar	dsb	sy
87f3b4914bSYatharth Kochar	isb
88f3b4914bSYatharth Kochar
89a4409008Sdp-armskip_mmu_off:
90a4409008Sdp-arm	/* Restore smc_context from `r4` and exit secure monitor mode. */
91a4409008Sdp-arm	mov	r0, r4
92b6285d64SSoby Mathew	monitor_exit
93f3b4914bSYatharth Kocharendfunc bl1_entrypoint
94