Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 1 | /* |
Olivier Deprez | 21cf360 | 2020-07-30 17:18:33 +0200 | [diff] [blame] | 2 | * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved. |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 7 | #include <assert.h> |
| 8 | |
| 9 | #include <platform_def.h> |
| 10 | |
| 11 | #include <common/bl_common.h> |
| 12 | #include <common/debug.h> |
| 13 | #include <drivers/arm/ccn.h> |
Antonio Nino Diaz | bd7b740 | 2019-01-25 14:30:04 +0000 | [diff] [blame] | 14 | #include <plat/arm/common/plat_arm.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 15 | #include <plat/common/platform.h> |
Aditya Angadi | 20b4841 | 2019-04-16 11:29:14 +0530 | [diff] [blame] | 16 | #include <drivers/arm/sbsa.h> |
| 17 | #include <sgi_base_platform_def.h> |
Olivier Deprez | 21cf360 | 2020-07-30 17:18:33 +0200 | [diff] [blame] | 18 | |
| 19 | #if SPM_MM |
Paul Beesley | 45f4028 | 2019-10-15 10:57:42 +0000 | [diff] [blame] | 20 | #include <services/spm_mm_partition.h> |
Olivier Deprez | 21cf360 | 2020-07-30 17:18:33 +0200 | [diff] [blame] | 21 | #endif |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 22 | |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 23 | #define SGI_MAP_FLASH0_RO MAP_REGION_FLAT(V2M_FLASH0_BASE,\ |
| 24 | V2M_FLASH0_SIZE, \ |
| 25 | MT_DEVICE | MT_RO | MT_SECURE) |
| 26 | /* |
| 27 | * Table of regions for different BL stages to map using the MMU. |
| 28 | * This doesn't include Trusted RAM as the 'mem_layout' argument passed to |
| 29 | * arm_configure_mmu_elx() will give the available subset of that. |
| 30 | * |
| 31 | * Replace or extend the below regions as required |
| 32 | */ |
| 33 | #if IMAGE_BL1 |
| 34 | const mmap_region_t plat_arm_mmap[] = { |
| 35 | ARM_MAP_SHARED_RAM, |
| 36 | SGI_MAP_FLASH0_RO, |
| 37 | CSS_SGI_MAP_DEVICE, |
| 38 | SOC_CSS_MAP_DEVICE, |
| 39 | {0} |
| 40 | }; |
| 41 | #endif |
| 42 | #if IMAGE_BL2 |
| 43 | const 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 | ARM_MAP_NS_DRAM1, |
| 49 | #if ARM_BL31_IN_DRAM |
| 50 | ARM_MAP_BL31_SEC_DRAM, |
| 51 | #endif |
Paul Beesley | fe975b4 | 2019-09-16 11:29:03 +0000 | [diff] [blame] | 52 | #if SPM_MM |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 53 | ARM_SP_IMAGE_MMAP, |
| 54 | #endif |
Antonio Nino Diaz | 9b75986 | 2018-09-25 11:38:18 +0100 | [diff] [blame] | 55 | #if TRUSTED_BOARD_BOOT && !BL2_AT_EL3 |
John Tsichritzis | 0c6ee74 | 2018-08-22 12:36:37 +0100 | [diff] [blame] | 56 | ARM_MAP_BL1_RW, |
| 57 | #endif |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 58 | {0} |
| 59 | }; |
| 60 | #endif |
| 61 | #if IMAGE_BL31 |
| 62 | const mmap_region_t plat_arm_mmap[] = { |
| 63 | ARM_MAP_SHARED_RAM, |
| 64 | V2M_MAP_IOFPGA, |
| 65 | CSS_SGI_MAP_DEVICE, |
| 66 | SOC_CSS_MAP_DEVICE, |
Paul Beesley | fe975b4 | 2019-09-16 11:29:03 +0000 | [diff] [blame] | 67 | #if SPM_MM |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 68 | ARM_SPM_BUF_EL3_MMAP, |
| 69 | #endif |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 70 | {0} |
| 71 | }; |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 72 | |
Paul Beesley | fe975b4 | 2019-09-16 11:29:03 +0000 | [diff] [blame] | 73 | #if SPM_MM && defined(IMAGE_BL31) |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 74 | const mmap_region_t plat_arm_secure_partition_mmap[] = { |
| 75 | PLAT_ARM_SECURE_MAP_DEVICE, |
| 76 | ARM_SP_IMAGE_MMAP, |
| 77 | ARM_SP_IMAGE_NS_BUF_MMAP, |
Sughosh Ganu | 70661cf | 2018-05-16 17:26:40 +0530 | [diff] [blame] | 78 | ARM_SP_CPER_BUF_MMAP, |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 79 | ARM_SP_IMAGE_RW_MMAP, |
| 80 | ARM_SPM_BUF_EL0_MMAP, |
| 81 | {0} |
| 82 | }; |
Paul Beesley | fe975b4 | 2019-09-16 11:29:03 +0000 | [diff] [blame] | 83 | #endif /* SPM_MM && defined(IMAGE_BL31) */ |
Nariman Poushin | 0ece80f | 2018-02-26 06:52:04 +0000 | [diff] [blame] | 84 | #endif |
| 85 | |
| 86 | ARM_CASSERT_MMAP |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 87 | |
Paul Beesley | fe975b4 | 2019-09-16 11:29:03 +0000 | [diff] [blame] | 88 | #if SPM_MM && defined(IMAGE_BL31) |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 89 | /* |
| 90 | * Boot information passed to a secure partition during initialisation. Linear |
| 91 | * indices in MP information will be filled at runtime. |
| 92 | */ |
Paul Beesley | 45f4028 | 2019-10-15 10:57:42 +0000 | [diff] [blame] | 93 | static spm_mm_mp_info_t sp_mp_info[] = { |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 94 | [0] = {0x81000000, 0}, |
| 95 | [1] = {0x81000100, 0}, |
| 96 | [2] = {0x81000200, 0}, |
| 97 | [3] = {0x81000300, 0}, |
| 98 | [4] = {0x81010000, 0}, |
| 99 | [5] = {0x81010100, 0}, |
| 100 | [6] = {0x81010200, 0}, |
| 101 | [7] = {0x81010300, 0}, |
| 102 | }; |
| 103 | |
Paul Beesley | 45f4028 | 2019-10-15 10:57:42 +0000 | [diff] [blame] | 104 | const spm_mm_boot_info_t plat_arm_secure_partition_boot_info = { |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 105 | .h.type = PARAM_SP_IMAGE_BOOT_INFO, |
| 106 | .h.version = VERSION_1, |
Paul Beesley | 45f4028 | 2019-10-15 10:57:42 +0000 | [diff] [blame] | 107 | .h.size = sizeof(spm_mm_boot_info_t), |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 108 | .h.attr = 0, |
| 109 | .sp_mem_base = ARM_SP_IMAGE_BASE, |
| 110 | .sp_mem_limit = ARM_SP_IMAGE_LIMIT, |
| 111 | .sp_image_base = ARM_SP_IMAGE_BASE, |
| 112 | .sp_stack_base = PLAT_SP_IMAGE_STACK_BASE, |
| 113 | .sp_heap_base = ARM_SP_IMAGE_HEAP_BASE, |
Ard Biesheuvel | 8b034fc | 2018-12-29 19:43:21 +0100 | [diff] [blame] | 114 | .sp_ns_comm_buf_base = PLAT_SP_IMAGE_NS_BUF_BASE, |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 115 | .sp_shared_buf_base = PLAT_SPM_BUF_BASE, |
| 116 | .sp_image_size = ARM_SP_IMAGE_SIZE, |
| 117 | .sp_pcpu_stack_size = PLAT_SP_IMAGE_STACK_PCPU_SIZE, |
| 118 | .sp_heap_size = ARM_SP_IMAGE_HEAP_SIZE, |
Ard Biesheuvel | 8b034fc | 2018-12-29 19:43:21 +0100 | [diff] [blame] | 119 | .sp_ns_comm_buf_size = PLAT_SP_IMAGE_NS_BUF_SIZE, |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 120 | .sp_shared_buf_size = PLAT_SPM_BUF_SIZE, |
| 121 | .num_sp_mem_regions = ARM_SP_IMAGE_NUM_MEM_REGIONS, |
| 122 | .num_cpus = PLATFORM_CORE_COUNT, |
| 123 | .mp_info = &sp_mp_info[0], |
| 124 | }; |
| 125 | |
| 126 | const struct mmap_region *plat_get_secure_partition_mmap(void *cookie) |
| 127 | { |
| 128 | return plat_arm_secure_partition_mmap; |
| 129 | } |
| 130 | |
Paul Beesley | 45f4028 | 2019-10-15 10:57:42 +0000 | [diff] [blame] | 131 | const struct spm_mm_boot_info *plat_get_secure_partition_boot_info( |
Sughosh Ganu | e1579e0 | 2018-05-16 17:19:56 +0530 | [diff] [blame] | 132 | void *cookie) |
| 133 | { |
| 134 | return &plat_arm_secure_partition_boot_info; |
| 135 | } |
Paul Beesley | fe975b4 | 2019-09-16 11:29:03 +0000 | [diff] [blame] | 136 | #endif /* SPM_MM && defined(IMAGE_BL31) */ |
John Tsichritzis | 0c6ee74 | 2018-08-22 12:36:37 +0100 | [diff] [blame] | 137 | |
Antonio Nino Diaz | 9b75986 | 2018-09-25 11:38:18 +0100 | [diff] [blame] | 138 | #if TRUSTED_BOARD_BOOT |
John Tsichritzis | 0c6ee74 | 2018-08-22 12:36:37 +0100 | [diff] [blame] | 139 | int plat_get_mbedtls_heap(void **heap_addr, size_t *heap_size) |
| 140 | { |
| 141 | assert(heap_addr != NULL); |
| 142 | assert(heap_size != NULL); |
| 143 | |
| 144 | return arm_get_mbedtls_heap(heap_addr, heap_size); |
| 145 | } |
| 146 | #endif |
Aditya Angadi | 20b4841 | 2019-04-16 11:29:14 +0530 | [diff] [blame] | 147 | |
| 148 | void plat_arm_secure_wdt_start(void) |
| 149 | { |
| 150 | sbsa_wdog_start(SBSA_SECURE_WDOG_BASE, SBSA_SECURE_WDOG_TIMEOUT); |
| 151 | } |
| 152 | |
| 153 | void plat_arm_secure_wdt_stop(void) |
| 154 | { |
| 155 | sbsa_wdog_stop(SBSA_SECURE_WDOG_BASE); |
| 156 | } |