1/*
2 * Copyright (c) 2017-2021, 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
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=1                                   \
31		_warm_boot_mailbox=!PROGRAMMABLE_RESET_ADDRESS  \
32		_secondary_cold_boot=!COLD_BOOT_SINGLE_CPU      \
33		_init_memory=1                                  \
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	bl	bl2_el3_setup
52
53#if ENABLE_PAUTH
54	/* ---------------------------------------------
55	 * Program APIAKey_EL1 and enable pointer authentication.
56	 * ---------------------------------------------
57	 */
58	bl	pauth_init_enable_el3
59#endif /* ENABLE_PAUTH */
60
61	/* ---------------------------------------------
62	 * Jump to main function.
63	 * ---------------------------------------------
64	 */
65	bl	bl2_main
66
67	/* ---------------------------------------------
68	 * Should never reach this point.
69	 * ---------------------------------------------
70	 */
71	no_ret	plat_panic_handler
72endfunc bl2_entrypoint
73