blob: 529510ce435637419aba9be57d9772ab6ca6f112 [file] [log] [blame]
Jens Wiklander52c798e2015-12-07 14:37:10 +01001/*
2 * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
3 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Jens Wiklander52c798e2015-12-07 14:37:10 +01005 */
6
Jens Wiklander52c798e2015-12-07 14:37:10 +01007#include <assert.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008
Jens Wiklander52c798e2015-12-07 14:37:10 +01009#include <platform_def.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +000010
11#include <arch.h>
12#include <arch_helpers.h>
13#include <common/bl_common.h>
14
Jens Wiklander52c798e2015-12-07 14:37:10 +010015#include "qemu_private.h"
16
Chen Baozif7d9aa82023-02-20 10:50:15 +000017#define MAP_BL1_TOTAL MAP_REGION_FLAT( \
18 bl1_tzram_layout.total_base, \
19 bl1_tzram_layout.total_size, \
20 MT_MEMORY | MT_RW | EL3_PAS)
21
22#define MAP_BL1_RO MAP_REGION_FLAT( \
23 BL_CODE_BASE, \
24 BL1_CODE_END - BL_CODE_BASE, \
25 MT_CODE | EL3_PAS), \
26 MAP_REGION_FLAT( \
27 BL1_RO_DATA_BASE, \
28 BL1_RO_DATA_END \
29 - BL_RO_DATA_BASE, \
30 MT_RO_DATA | EL3_PAS)
31
Chen Baozi097a43a2023-03-12 20:58:04 +080032#if USE_COHERENT_MEM
Chen Baozif7d9aa82023-02-20 10:50:15 +000033#define MAP_BL_COHERENT_RAM MAP_REGION_FLAT( \
34 BL_COHERENT_RAM_BASE, \
35 BL_COHERENT_RAM_END \
36 - BL_COHERENT_RAM_BASE, \
37 MT_DEVICE | MT_RW | EL3_PAS)
Chen Baozi097a43a2023-03-12 20:58:04 +080038#endif
Chen Baozif7d9aa82023-02-20 10:50:15 +000039
Jens Wiklander52c798e2015-12-07 14:37:10 +010040/* Data structure which holds the extents of the trusted SRAM for BL1*/
41static meminfo_t bl1_tzram_layout;
42
43
44meminfo_t *bl1_plat_sec_mem_layout(void)
45{
46 return &bl1_tzram_layout;
47}
48
49/*******************************************************************************
50 * Perform any BL1 specific platform actions.
51 ******************************************************************************/
52void bl1_early_platform_setup(void)
53{
Jens Wiklander52c798e2015-12-07 14:37:10 +010054 /* Initialize the console to provide early debug support */
Michalis Pappascca6cb72018-03-04 15:43:38 +080055 qemu_console_init();
Jens Wiklander52c798e2015-12-07 14:37:10 +010056
57 /* Allow BL1 to see the whole Trusted RAM */
58 bl1_tzram_layout.total_base = BL_RAM_BASE;
59 bl1_tzram_layout.total_size = BL_RAM_SIZE;
Jens Wiklander52c798e2015-12-07 14:37:10 +010060}
61
62/******************************************************************************
63 * Perform the very early platform specific architecture setup. This only
64 * does basic initialization. Later architectural setup (bl1_arch_setup())
65 * does not do anything platform specific.
66 *****************************************************************************/
Julius Werner8e0ef0f2019-07-09 14:02:43 -070067#ifdef __aarch64__
Etienne Carriere911de8c2018-02-02 13:23:22 +010068#define QEMU_CONFIGURE_BL1_MMU(...) qemu_configure_mmu_el3(__VA_ARGS__)
Julius Werner8e0ef0f2019-07-09 14:02:43 -070069#else
70#define QEMU_CONFIGURE_BL1_MMU(...) qemu_configure_mmu_svc_mon(__VA_ARGS__)
Etienne Carriere911de8c2018-02-02 13:23:22 +010071#endif
72
Jens Wiklander52c798e2015-12-07 14:37:10 +010073void bl1_plat_arch_setup(void)
74{
Chen Baozif7d9aa82023-02-20 10:50:15 +000075 const mmap_region_t bl_regions[] = {
76 MAP_BL1_TOTAL,
77 MAP_BL1_RO,
Chen Baozi097a43a2023-03-12 20:58:04 +080078#if USE_COHERENT_MEM
Chen Baozif7d9aa82023-02-20 10:50:15 +000079 MAP_BL_COHERENT_RAM,
Chen Baozi097a43a2023-03-12 20:58:04 +080080#endif
Chen Baozif7d9aa82023-02-20 10:50:15 +000081 {0}
82 };
83
84 setup_page_tables(bl_regions, plat_qemu_get_mmap());
85#ifdef __aarch64__
86 enable_mmu_el3(0);
87#else
88 enable_mmu_svc_mon(0);
89#endif
Jens Wiklander52c798e2015-12-07 14:37:10 +010090}
91
92void bl1_platform_setup(void)
93{
94 plat_qemu_io_setup();
95}