Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 1 | /* |
| 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> |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 8 | #include <arm_spm_def.h> |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 9 | #include <bl_common.h> |
| 10 | #include <ccn.h> |
| 11 | #include <debug.h> |
| 12 | #include <plat_arm.h> |
Sughosh Ganu | 70661cf | 2018-05-16 17:26:40 +0530 | [diff] [blame] | 13 | #include <platform_def.h> |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 14 | #include <platform.h> |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 15 | #include <secure_partition.h> |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 16 | #include "../../../../bl1/bl1_private.h" |
| 17 | |
| 18 | #if USE_COHERENT_MEM |
| 19 | /* |
| 20 | * The next 2 constants identify the extents of the coherent memory region. |
| 21 | * These addresses are used by the MMU setup code and therefore they must be |
| 22 | * page-aligned. It is the responsibility of the linker script to ensure that |
| 23 | * __COHERENT_RAM_START__ and __COHERENT_RAM_END__ linker symbols |
| 24 | * refer to page-aligned addresses. |
| 25 | */ |
| 26 | #define BL1_COHERENT_RAM_BASE (unsigned long)(&__COHERENT_RAM_START__) |
| 27 | #define BL1_COHERENT_RAM_LIMIT (unsigned long)(&__COHERENT_RAM_END__) |
| 28 | #define BL2_COHERENT_RAM_BASE (unsigned long)(&__COHERENT_RAM_START__) |
| 29 | #define BL2_COHERENT_RAM_LIMIT (unsigned long)(&__COHERENT_RAM_END__) |
| 30 | |
| 31 | #define BL31_COHERENT_RAM_BASE (uintptr_t)(&__COHERENT_RAM_START__) |
| 32 | #define BL31_COHERENT_RAM_LIMIT (uintptr_t)(&__COHERENT_RAM_END__) |
| 33 | #endif |
| 34 | |
| 35 | #define SGI_MAP_FLASH0_RO MAP_REGION_FLAT(V2M_FLASH0_BASE,\ |
| 36 | V2M_FLASH0_SIZE, \ |
| 37 | MT_DEVICE | MT_RO | MT_SECURE) |
| 38 | /* |
| 39 | * Table of regions for different BL stages to map using the MMU. |
| 40 | * This doesn't include Trusted RAM as the 'mem_layout' argument passed to |
| 41 | * arm_configure_mmu_elx() will give the available subset of that. |
| 42 | * |
| 43 | * Replace or extend the below regions as required |
| 44 | */ |
| 45 | #if IMAGE_BL1 |
| 46 | const mmap_region_t plat_arm_mmap[] = { |
| 47 | ARM_MAP_SHARED_RAM, |
| 48 | SGI_MAP_FLASH0_RO, |
| 49 | CSS_SGI_MAP_DEVICE, |
| 50 | SOC_CSS_MAP_DEVICE, |
| 51 | {0} |
| 52 | }; |
| 53 | #endif |
| 54 | #if IMAGE_BL2 |
| 55 | const mmap_region_t plat_arm_mmap[] = { |
| 56 | ARM_MAP_SHARED_RAM, |
| 57 | SGI_MAP_FLASH0_RO, |
| 58 | CSS_SGI_MAP_DEVICE, |
| 59 | SOC_CSS_MAP_DEVICE, |
| 60 | ARM_MAP_NS_DRAM1, |
| 61 | #if ARM_BL31_IN_DRAM |
| 62 | ARM_MAP_BL31_SEC_DRAM, |
| 63 | #endif |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 64 | #if ENABLE_SPM |
| 65 | ARM_SP_IMAGE_MMAP, |
| 66 | #endif |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 67 | {0} |
| 68 | }; |
| 69 | #endif |
| 70 | #if IMAGE_BL31 |
| 71 | const mmap_region_t plat_arm_mmap[] = { |
| 72 | ARM_MAP_SHARED_RAM, |
| 73 | V2M_MAP_IOFPGA, |
| 74 | CSS_SGI_MAP_DEVICE, |
| 75 | SOC_CSS_MAP_DEVICE, |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 76 | #if ENABLE_SPM |
| 77 | ARM_SPM_BUF_EL3_MMAP, |
| 78 | #endif |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 79 | {0} |
| 80 | }; |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 81 | |
| 82 | #if ENABLE_SPM && defined(IMAGE_BL31) |
| 83 | const mmap_region_t plat_arm_secure_partition_mmap[] = { |
| 84 | PLAT_ARM_SECURE_MAP_DEVICE, |
| 85 | ARM_SP_IMAGE_MMAP, |
| 86 | ARM_SP_IMAGE_NS_BUF_MMAP, |
Sughosh Ganu | 70661cf | 2018-05-16 17:26:40 +0530 | [diff] [blame] | 87 | ARM_SP_CPER_BUF_MMAP, |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 88 | ARM_SP_IMAGE_RW_MMAP, |
| 89 | ARM_SPM_BUF_EL0_MMAP, |
| 90 | {0} |
| 91 | }; |
| 92 | #endif /* ENABLE_SPM && defined(IMAGE_BL31) */ |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 93 | #endif |
| 94 | |
| 95 | ARM_CASSERT_MMAP |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 96 | |
| 97 | #if ENABLE_SPM && defined(IMAGE_BL31) |
| 98 | /* |
| 99 | * Boot information passed to a secure partition during initialisation. Linear |
| 100 | * indices in MP information will be filled at runtime. |
| 101 | */ |
| 102 | static secure_partition_mp_info_t sp_mp_info[] = { |
| 103 | [0] = {0x81000000, 0}, |
| 104 | [1] = {0x81000100, 0}, |
| 105 | [2] = {0x81000200, 0}, |
| 106 | [3] = {0x81000300, 0}, |
| 107 | [4] = {0x81010000, 0}, |
| 108 | [5] = {0x81010100, 0}, |
| 109 | [6] = {0x81010200, 0}, |
| 110 | [7] = {0x81010300, 0}, |
| 111 | }; |
| 112 | |
| 113 | const secure_partition_boot_info_t plat_arm_secure_partition_boot_info = { |
| 114 | .h.type = PARAM_SP_IMAGE_BOOT_INFO, |
| 115 | .h.version = VERSION_1, |
| 116 | .h.size = sizeof(secure_partition_boot_info_t), |
| 117 | .h.attr = 0, |
| 118 | .sp_mem_base = ARM_SP_IMAGE_BASE, |
| 119 | .sp_mem_limit = ARM_SP_IMAGE_LIMIT, |
| 120 | .sp_image_base = ARM_SP_IMAGE_BASE, |
| 121 | .sp_stack_base = PLAT_SP_IMAGE_STACK_BASE, |
| 122 | .sp_heap_base = ARM_SP_IMAGE_HEAP_BASE, |
| 123 | .sp_ns_comm_buf_base = ARM_SP_IMAGE_NS_BUF_BASE, |
| 124 | .sp_shared_buf_base = PLAT_SPM_BUF_BASE, |
| 125 | .sp_image_size = ARM_SP_IMAGE_SIZE, |
| 126 | .sp_pcpu_stack_size = PLAT_SP_IMAGE_STACK_PCPU_SIZE, |
| 127 | .sp_heap_size = ARM_SP_IMAGE_HEAP_SIZE, |
| 128 | .sp_ns_comm_buf_size = ARM_SP_IMAGE_NS_BUF_SIZE, |
| 129 | .sp_shared_buf_size = PLAT_SPM_BUF_SIZE, |
| 130 | .num_sp_mem_regions = ARM_SP_IMAGE_NUM_MEM_REGIONS, |
| 131 | .num_cpus = PLATFORM_CORE_COUNT, |
| 132 | .mp_info = &sp_mp_info[0], |
| 133 | }; |
| 134 | |
| 135 | const struct mmap_region *plat_get_secure_partition_mmap(void *cookie) |
| 136 | { |
| 137 | return plat_arm_secure_partition_mmap; |
| 138 | } |
| 139 | |
| 140 | const struct secure_partition_boot_info *plat_get_secure_partition_boot_info( |
| 141 | void *cookie) |
| 142 | { |
| 143 | return &plat_arm_secure_partition_boot_info; |
| 144 | } |
| 145 | #endif /* ENABLE_SPM && defined(IMAGE_BL31) */ |