blob: 94d713d99d0192e22dfe1f5d4e095d5d04d7c354 [file] [log] [blame]
Nariman Poushin0ece80f2018-02-26 06:52:04 +00001/*
2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arm_def.h>
8#include <bl_common.h>
9#include <ccn.h>
10#include <debug.h>
11#include <plat_arm.h>
12#include <platform.h>
13#include "../../../../bl1/bl1_private.h"
14
15#if USE_COHERENT_MEM
16/*
17 * The next 2 constants identify the extents of the coherent memory region.
18 * These addresses are used by the MMU setup code and therefore they must be
19 * page-aligned. It is the responsibility of the linker script to ensure that
20 * __COHERENT_RAM_START__ and __COHERENT_RAM_END__ linker symbols
21 * refer to page-aligned addresses.
22 */
23#define BL1_COHERENT_RAM_BASE (unsigned long)(&__COHERENT_RAM_START__)
24#define BL1_COHERENT_RAM_LIMIT (unsigned long)(&__COHERENT_RAM_END__)
25#define BL2_COHERENT_RAM_BASE (unsigned long)(&__COHERENT_RAM_START__)
26#define BL2_COHERENT_RAM_LIMIT (unsigned long)(&__COHERENT_RAM_END__)
27
28#define BL31_COHERENT_RAM_BASE (uintptr_t)(&__COHERENT_RAM_START__)
29#define BL31_COHERENT_RAM_LIMIT (uintptr_t)(&__COHERENT_RAM_END__)
30#endif
31
32#define SGI_MAP_FLASH0_RO MAP_REGION_FLAT(V2M_FLASH0_BASE,\
33 V2M_FLASH0_SIZE, \
34 MT_DEVICE | MT_RO | MT_SECURE)
35/*
36 * Table of regions for different BL stages to map using the MMU.
37 * This doesn't include Trusted RAM as the 'mem_layout' argument passed to
38 * arm_configure_mmu_elx() will give the available subset of that.
39 *
40 * Replace or extend the below regions as required
41 */
42#if IMAGE_BL1
43const mmap_region_t plat_arm_mmap[] = {
44 ARM_MAP_SHARED_RAM,
45 SGI_MAP_FLASH0_RO,
46 CSS_SGI_MAP_DEVICE,
47 SOC_CSS_MAP_DEVICE,
48 {0}
49};
50#endif
51#if IMAGE_BL2
52const mmap_region_t plat_arm_mmap[] = {
53 ARM_MAP_SHARED_RAM,
54 SGI_MAP_FLASH0_RO,
55 CSS_SGI_MAP_DEVICE,
56 SOC_CSS_MAP_DEVICE,
57 ARM_MAP_NS_DRAM1,
58#if ARM_BL31_IN_DRAM
59 ARM_MAP_BL31_SEC_DRAM,
60#endif
61 {0}
62};
63#endif
64#if IMAGE_BL31
65const mmap_region_t plat_arm_mmap[] = {
66 ARM_MAP_SHARED_RAM,
67 V2M_MAP_IOFPGA,
68 CSS_SGI_MAP_DEVICE,
69 SOC_CSS_MAP_DEVICE,
70 {0}
71};
72#endif
73
74ARM_CASSERT_MMAP
75
76/*
77 * Set up the page tables for the generic and platform-specific memory regions.
78 * The extents of the generic memory regions are specified by the function
79 * arguments and consist of:
80 * - Trusted SRAM seen by the BL image;
81 * - Code section;
82 * - Read-only data section;
83 * - Coherent memory region, if applicable.
84 */
85
86#if IMAGE_BL1
87void bl1_plat_arch_setup(void)
88{
89 arm_setup_page_tables(ARM_BL_RAM_BASE,
90 ARM_BL_RAM_SIZE,
91 BL_CODE_BASE,
92 BL1_CODE_END,
93 BL1_RO_DATA_BASE,
94 BL1_RO_DATA_END
95#if USE_COHERENT_MEM
96 , BL1_COHERENT_RAM_BASE,
97 BL1_COHERENT_RAM_LIMIT
98#endif /* USE_COHERENT_MEM */
99 );
100
101 enable_mmu_el3(0);
102}
103#endif /* IMAGE_BL1 */
104
105#if IMAGE_BL2
106void bl2_plat_arch_setup(void)
107{
108 arm_setup_page_tables(BL2_BASE,
109 BL2_LIMIT-BL2_BASE,
110 BL_CODE_BASE,
111 BL_CODE_END,
112 BL_RO_DATA_BASE,
113 BL_RO_DATA_END
114#if USE_COHERENT_MEM
115 , BL2_COHERENT_RAM_BASE,
116 BL2_COHERENT_RAM_LIMIT
117#endif /* USE_COHERENT_MEM */
118 );
119 enable_mmu_el1(0);
120}
121#endif /* IMAGE_BL2 */