blob: 6391f537cd2cafb4462efce603c111caa508f8e9 [file] [log] [blame]
Yatharth Kochar18dfb302016-11-22 11:06:03 +00001/*
John Tsichritzisd5a59602019-03-04 16:42:54 +00002 * Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved.
Yatharth Kochar18dfb302016-11-22 11:06:03 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00009#include <common/bl_common.h>
Yatharth Kochar18dfb302016-11-22 11:06:03 +000010
11 .globl bl2u_vector_table
12 .globl bl2u_entrypoint
13
14
15vector_base bl2u_vector_table
16 b bl2u_entrypoint
17 b report_exception /* Undef */
18 b report_exception /* SVC call */
19 b report_exception /* Prefetch abort */
20 b report_exception /* Data abort */
21 b report_exception /* Reserved */
22 b report_exception /* IRQ */
23 b report_exception /* FIQ */
24
25
26func bl2u_entrypoint
27 /*---------------------------------------------
28 * Save from r1 the extents of the trusted ram
29 * available to BL2U for future use.
30 * r0 is not currently used.
31 * ---------------------------------------------
32 */
33 mov r11, r1
Douglas Raillard983b4752017-07-26 19:23:16 +010034 mov r10, r2
Yatharth Kochar18dfb302016-11-22 11:06:03 +000035
36 /* ---------------------------------------------
37 * Set the exception vector to something sane.
38 * ---------------------------------------------
39 */
40 ldr r0, =bl2u_vector_table
41 stcopr r0, VBAR
42 isb
43
John Tsichritzisd5a59602019-03-04 16:42:54 +000044 /* --------------------------------------------------------
45 * Enable the instruction cache - disable speculative loads
46 * --------------------------------------------------------
Yatharth Kochar18dfb302016-11-22 11:06:03 +000047 */
48 ldcopr r0, SCTLR
49 orr r0, r0, #SCTLR_I_BIT
John Tsichritzisd5a59602019-03-04 16:42:54 +000050 bic r0, r0, #SCTLR_DSSBS_BIT
Yatharth Kochar18dfb302016-11-22 11:06:03 +000051 stcopr r0, SCTLR
52 isb
53
54 /* ---------------------------------------------
55 * Since BL2U executes after BL1, it is assumed
56 * here that BL1 has already has done the
57 * necessary register initializations.
58 * ---------------------------------------------
59 */
60
61 /* ---------------------------------------------
62 * Invalidate the RW memory used by the BL2U
63 * image. This includes the data and NOBITS
64 * sections. This is done to safeguard against
65 * possible corruption of this memory by dirty
66 * cache lines in a system cache as a result of
67 * use by an earlier boot loader stage.
68 * ---------------------------------------------
69 */
70 ldr r0, =__RW_START__
71 ldr r1, =__RW_END__
72 sub r1, r1, r0
73 bl inv_dcache_range
74
75 /* ---------------------------------------------
76 * Zero out NOBITS sections. There are 2 of them:
77 * - the .bss section;
78 * - the coherent memory section.
79 * ---------------------------------------------
80 */
81 ldr r0, =__BSS_START__
82 ldr r1, =__BSS_SIZE__
83 bl zeromem
84
85 /* --------------------------------------------
86 * Allocate a stack whose memory will be marked
87 * as Normal-IS-WBWA when the MMU is enabled.
88 * There is no risk of reading stale stack
89 * memory after enabling the MMU as only the
90 * primary cpu is running at the moment.
91 * --------------------------------------------
92 */
93 bl plat_set_my_stack
94
95 /* ---------------------------------------------
96 * Initialize the stack protector canary before
97 * any C code is called.
98 * ---------------------------------------------
99 */
100#if STACK_PROTECTOR_ENABLED
101 bl update_stack_protector_canary
102#endif
103
104 /* ---------------------------------------------
105 * Perform early platform setup & platform
106 * specific early arch. setup e.g. mmu setup
107 * ---------------------------------------------
108 */
109 mov r0, r11
Douglas Raillard983b4752017-07-26 19:23:16 +0100110 mov r1, r10
Yatharth Kochar18dfb302016-11-22 11:06:03 +0000111 bl bl2u_early_platform_setup
112 bl bl2u_plat_arch_setup
113
114 /* ---------------------------------------------
115 * Jump to main function.
116 * ---------------------------------------------
117 */
118 bl bl2u_main
119
120 /* ---------------------------------------------
121 * Should never reach this point.
122 * ---------------------------------------------
123 */
124 no_ret plat_panic_handler
125
126endfunc bl2u_entrypoint