xref: /rk3399_ARM-atf/bl2/aarch64/bl2_el3_entrypoint.S (revision 04cf04c72d403e0c057505882fac9002d39d4102)
1/*
2 * Copyright (c) 2017-2025, Arm Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <platform_def.h>
8
9#include <arch.h>
10#include <asm_macros.S>
11#include <common/bl_common.h>
12#include <el3_common_macros.S>
13
14	.globl	bl2_entrypoint
15
16#if BL2_IN_XIP_MEM || ENABLE_RME
17#define FIXUP_SIZE	0
18#else
19#define FIXUP_SIZE	((BL2_LIMIT) - (BL2_BASE))
20#endif
21
22func bl2_entrypoint
23	/* Save arguments x0-x3 from previous Boot loader */
24	mov	x20, x0
25	mov	x21, x1
26	mov	x22, x2
27	mov	x23, x3
28
29	el3_entrypoint_common							\
30		_init_sctlr=RESET_TO_BL2					\
31		_warm_boot_mailbox=!PROGRAMMABLE_RESET_ADDRESS && RESET_TO_BL2	\
32		_secondary_cold_boot=!COLD_BOOT_SINGLE_CPU && RESET_TO_BL2	\
33		_init_memory=RESET_TO_BL2					\
34		_init_c_runtime=1						\
35		_exception_vectors=bl2_el3_exceptions				\
36		_pie_fixup_size=FIXUP_SIZE
37
38	/* ---------------------------------------------
39	 * Restore parameters of boot rom
40	 * ---------------------------------------------
41	 */
42	mov	x0, x20
43	mov	x1, x21
44	mov	x2, x22
45	mov	x3, x23
46
47	/* ---------------------------------------------
48	 * Perform BL2 setup
49	 * ---------------------------------------------
50	 */
51#if RESET_TO_BL2
52	bl	bl2_el3_setup
53#else
54	bl	bl2_setup
55#endif
56
57#if ENABLE_PAUTH
58	/* ---------------------------------------------
59	 * Program APIAKey_EL1 and enable pointer authentication.
60	 * ---------------------------------------------
61	 */
62	bl	pauth_init_enable_el3
63#endif /* ENABLE_PAUTH */
64
65	/* ---------------------------------------------
66	 * Jump to main function.
67	 * ---------------------------------------------
68	 */
69	bl	bl2_main
70
71	/* ---------------------------------------------
72	 * Should never reach this point.
73	 * ---------------------------------------------
74	 */
75	no_ret	plat_panic_handler
76endfunc bl2_entrypoint
77