2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
10 #include <bl31/bl31.h>
11 #include <common/bl_common.h>
12 #include <common/debug.h>
13 #include <drivers/arm/pl011.h>
14 #include <drivers/console.h>
15 #include <lib/xlat_tables/xlat_tables.h>
16 #include <plat/common/platform.h>
18 #include "versal_private.h"
20 static entry_point_info_t bl32_image_ep_info
;
21 static entry_point_info_t bl33_image_ep_info
;
22 static console_pl011_t versal_runtime_console
;
25 * Return a pointer to the 'entry_point_info' structure of the next image for
26 * the security state specified. BL33 corresponds to the non-secure image type
27 * while BL32 corresponds to the secure image type. A NULL pointer is returned
28 * if the image does not exist.
30 entry_point_info_t
*bl31_plat_get_next_image_ep_info(uint32_t type
)
32 assert(sec_state_is_valid(type
));
34 if (type
== NON_SECURE
)
35 return &bl33_image_ep_info
;
37 return &bl32_image_ep_info
;
41 * Perform any BL31 specific platform actions. Here is an opportunity to copy
42 * parameters passed by the calling EL (S-EL1 in BL2 & S-EL3 in BL1) before they
43 * are lost (potentially). This needs to be done before the MMU is initialized
44 * so that the memory layout can be used while creating page tables.
46 void bl31_early_platform_setup2(u_register_t arg0
, u_register_t arg1
,
47 u_register_t arg2
, u_register_t arg3
)
50 /* Initialize the console to provide early debug support */
51 int rc
= console_pl011_register(VERSAL_UART_BASE
,
54 &versal_runtime_console
);
58 console_set_scope(&versal_runtime_console
.console
, CONSOLE_FLAG_BOOT
|
59 CONSOLE_FLAG_RUNTIME
);
61 /* Initialize the platform config for future decision making */
62 versal_config_setup();
63 /* There are no parameters from BL2 if BL31 is a reset vector */
68 * Do initial security configuration to allow DRAM/device access. On
69 * Base VERSAL only DRAM security is programmable (via TrustZone), but
70 * other platforms might have more programmable security devices
74 /* Populate common information for BL32 and BL33 */
75 SET_PARAM_HEAD(&bl32_image_ep_info
, PARAM_EP
, VERSION_1
, 0);
76 SET_SECURITY_STATE(bl32_image_ep_info
.h
.attr
, SECURE
);
77 SET_PARAM_HEAD(&bl33_image_ep_info
, PARAM_EP
, VERSION_1
, 0);
78 SET_SECURITY_STATE(bl33_image_ep_info
.h
.attr
, NON_SECURE
);
80 /* use build time defaults in JTAG boot mode */
81 bl32_image_ep_info
.pc
= BL32_BASE
;
82 bl32_image_ep_info
.spsr
= 0;
83 bl33_image_ep_info
.pc
= plat_get_ns_image_entrypoint();
84 bl33_image_ep_info
.spsr
= SPSR_64(MODE_EL2
, MODE_SP_ELX
,
85 DISABLE_ALL_EXCEPTIONS
);
87 NOTICE("BL31: Secure code at 0x%lx\n", bl32_image_ep_info
.pc
);
88 NOTICE("BL31: Non secure code at 0x%lx\n", bl33_image_ep_info
.pc
);
91 void bl31_platform_setup(void)
93 /* Initialize the gic cpu and distributor interfaces */
94 plat_versal_gic_driver_init();
95 plat_versal_gic_init();
98 void bl31_plat_runtime_setup(void)
103 * Perform the very early platform specific architectural setup here.
105 void bl31_plat_arch_setup(void)
107 const mmap_region_t bl_regions
[] = {
108 MAP_REGION_FLAT(BL31_BASE
, BL31_END
- BL31_BASE
,
109 MT_MEMORY
| MT_RW
| MT_SECURE
),
110 MAP_REGION_FLAT(BL_CODE_BASE
, BL_CODE_END
- BL_CODE_BASE
,
111 MT_CODE
| MT_SECURE
),
112 MAP_REGION_FLAT(BL_RO_DATA_BASE
, BL_RO_DATA_END
- BL_RO_DATA_BASE
,
113 MT_RO_DATA
| MT_SECURE
),
114 MAP_REGION_FLAT(BL_COHERENT_RAM_BASE
,
115 BL_COHERENT_RAM_END
- BL_COHERENT_RAM_BASE
,
116 MT_DEVICE
| MT_RW
| MT_SECURE
),
120 setup_page_tables(bl_regions
, plat_versal_get_mmap());