Mate Toth-Pal | 3ad2e3e | 2019-07-11 21:43:37 +0200 | [diff] [blame] | 1 | /* |
TTornblom | 83d9637 | 2019-11-19 12:53:16 +0100 | [diff] [blame] | 2 | * Copyright (c) 2019-2020, Arm Limited. All rights reserved. |
Mate Toth-Pal | 3ad2e3e | 2019-07-11 21:43:37 +0200 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | {{utilities.donotedit_warning}} |
| 9 | |
Shawn Shan | 071d86d | 2020-05-25 17:32:58 +0800 | [diff] [blame] | 10 | #ifndef __TFM_SPM_DB_IPC_INC__ |
| 11 | #define __TFM_SPM_DB_IPC_INC__ |
Mate Toth-Pal | 3ad2e3e | 2019-07-11 21:43:37 +0200 | [diff] [blame] | 12 | |
| 13 | #include "spm_api.h" |
Edison Ai | e728fbf | 2019-11-13 09:37:12 +0800 | [diff] [blame] | 14 | #include "psa_manifest/sid.h" |
Mate Toth-Pal | 3ad2e3e | 2019-07-11 21:43:37 +0200 | [diff] [blame] | 15 | |
Edison Ai | 1545bb9 | 2019-11-14 14:15:27 +0800 | [diff] [blame] | 16 | {# Produce a build error if heap_size is presented in the manifest, because of the dynamic memory allocation is not supported now. #} |
| 17 | {% for manifest in manifests %} |
| 18 | {% if manifest.manifest.heap_size %} |
| 19 | #error "Please do not add 'heap_size' for partition '{{manifest.manifest.name}}', the dynamic memory allocation is not supported now!" |
| 20 | {% endif %} |
| 21 | {% endfor %} |
Mate Toth-Pal | 3ad2e3e | 2019-07-11 21:43:37 +0200 | [diff] [blame] | 22 | /**************************************************************************/ |
| 23 | /** IRQ count per partition */ |
| 24 | /**************************************************************************/ |
| 25 | {% for manifest in manifests %} |
| 26 | {% if manifest.attr.conditional %} |
| 27 | #ifdef {{manifest.attr.conditional}} |
| 28 | {% endif %} |
| 29 | {% if manifest.manifest.irqs %} |
| 30 | #define TFM_PARTITION_{{manifest.manifest.name}}_IRQ_COUNT {{manifest.manifest.irqs | length() }} |
| 31 | {% else %} |
| 32 | #define TFM_PARTITION_{{manifest.manifest.name}}_IRQ_COUNT 0 |
| 33 | {% endif %} |
| 34 | {% if manifest.attr.conditional %} |
| 35 | #endif /* {{manifest.attr.conditional}} */ |
| 36 | {% endif %} |
| 37 | |
| 38 | {% endfor %} |
| 39 | /**************************************************************************/ |
| 40 | /** Declarations of partition init functions */ |
| 41 | /**************************************************************************/ |
Edison Ai | 9c48d20 | 2019-10-12 16:57:21 +0800 | [diff] [blame] | 42 | extern void tfm_nspm_thread_entry(void); |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 43 | |
Mate Toth-Pal | 3ad2e3e | 2019-07-11 21:43:37 +0200 | [diff] [blame] | 44 | {% for manifest in manifests %} |
| 45 | {% if manifest.attr.conditional %} |
| 46 | #ifdef {{manifest.attr.conditional}} |
| 47 | {% endif %} |
Edison Ai | 9c48d20 | 2019-10-12 16:57:21 +0800 | [diff] [blame] | 48 | extern void {{manifest.manifest.entry_point}}(void); |
Mate Toth-Pal | 3ad2e3e | 2019-07-11 21:43:37 +0200 | [diff] [blame] | 49 | {% if manifest.attr.conditional %} |
| 50 | #endif /* {{manifest.attr.conditional}} */ |
| 51 | {% endif %} |
| 52 | |
| 53 | {% endfor %} |
| 54 | /**************************************************************************/ |
| 55 | /** Memory region declarations */ |
| 56 | /**************************************************************************/ |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 57 | REGION_DECLARE(Image$$, ARM_LIB_STACK, $$ZI$$Base); |
| 58 | REGION_DECLARE(Image$$, ARM_LIB_STACK, $$ZI$$Limit); |
| 59 | |
Mate Toth-Pal | 3ad2e3e | 2019-07-11 21:43:37 +0200 | [diff] [blame] | 60 | {% for manifest in manifests %} |
| 61 | {% if manifest.attr.conditional %} |
| 62 | #ifdef {{manifest.attr.conditional}} |
| 63 | {% endif %} |
Edison Ai | b2134e6 | 2019-10-11 18:24:47 +0800 | [diff] [blame] | 64 | REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, $$Base); |
| 65 | REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, $$Limit); |
| 66 | REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, $$RO$$Base); |
| 67 | REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, $$RO$$Limit); |
| 68 | REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, _DATA$$RW$$Base); |
| 69 | REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, _DATA$$RW$$Limit); |
| 70 | REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, _DATA$$ZI$$Base); |
| 71 | REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, _DATA$$ZI$$Limit); |
| 72 | REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, _STACK$$ZI$$Base); |
| 73 | REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, _STACK$$ZI$$Limit); |
Mate Toth-Pal | 3ad2e3e | 2019-07-11 21:43:37 +0200 | [diff] [blame] | 74 | {% if manifest.attr.conditional %} |
| 75 | #endif /* {{manifest.attr.conditional}} */ |
| 76 | {% endif %} |
| 77 | |
| 78 | {% endfor %} |
Mate Toth-Pal | 3ad2e3e | 2019-07-11 21:43:37 +0200 | [diff] [blame] | 79 | /**************************************************************************/ |
Edison Ai | e728fbf | 2019-11-13 09:37:12 +0800 | [diff] [blame] | 80 | /** Dependencies array for Secure Partition */ |
| 81 | /**************************************************************************/ |
| 82 | {% for manifest in manifests %} |
| 83 | {% if manifest.manifest.dependencies %} |
| 84 | {% if manifest.attr.conditional %} |
| 85 | #ifdef {{manifest.attr.conditional}} |
| 86 | {% endif %} |
| 87 | static int32_t dependencies_{{manifest.manifest.name}}[] = |
| 88 | { |
| 89 | {% for dependence in manifest.manifest.dependencies %} |
Edison Ai | b262cc4 | 2019-12-20 14:47:52 +0800 | [diff] [blame] | 90 | {% for service in manifest.manifest.services %} |
| 91 | {% if dependence == service.name %} |
| 92 | #error "Please DO NOT include SP's own RoT Service '{{dependence}}', which will cause a deadlock!" |
| 93 | {% endif %} |
| 94 | {% endfor %} |
Edison Ai | e728fbf | 2019-11-13 09:37:12 +0800 | [diff] [blame] | 95 | {{dependence}}_SID, |
| 96 | {% endfor %} |
| 97 | }; |
| 98 | {% if manifest.attr.conditional %} |
| 99 | #endif /* {{manifest.attr.conditional}} */ |
| 100 | {% endif %} |
| 101 | |
| 102 | {% endif %} |
| 103 | {% endfor %} |
| 104 | /**************************************************************************/ |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 105 | /** The static data of the partition list */ |
| 106 | /**************************************************************************/ |
| 107 | const struct spm_partition_static_data_t static_data_list[] = |
| 108 | { |
| 109 | { |
Edison Ai | f050170 | 2019-10-11 14:36:42 +0800 | [diff] [blame] | 110 | .psa_framework_version = 0x0100, |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 111 | .partition_id = TFM_SP_NON_SECURE_ID, |
David Hu | 90128b7 | 2019-09-23 16:35:41 +0800 | [diff] [blame] | 112 | #if TFM_MULTI_CORE_TOPOLOGY |
| 113 | .partition_flags = SPM_PART_FLAG_PSA_ROT | SPM_PART_FLAG_IPC, |
| 114 | #else |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 115 | .partition_flags = SPM_PART_FLAG_APP_ROT | SPM_PART_FLAG_IPC, |
David Hu | 90128b7 | 2019-09-23 16:35:41 +0800 | [diff] [blame] | 116 | #endif |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 117 | .partition_priority = TFM_PRIORITY_LOW, |
| 118 | .partition_init = tfm_nspm_thread_entry, |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 119 | }, |
| 120 | |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 121 | {% for manifest in manifests %} |
| 122 | {% if manifest.attr.conditional %} |
| 123 | #ifdef {{manifest.attr.conditional}} |
| 124 | {% endif %} |
| 125 | {{'{'}} |
Edison Ai | f050170 | 2019-10-11 14:36:42 +0800 | [diff] [blame] | 126 | {% if manifest.manifest.psa_framework_version == 1.0 %} |
| 127 | .psa_framework_version = 0x0100, |
| 128 | {% else %} |
| 129 | .psa_framework_version = 0, |
| 130 | {% endif %} |
Edison Ai | b2134e6 | 2019-10-11 18:24:47 +0800 | [diff] [blame] | 131 | .partition_id = {{manifest.manifest.name}}, |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 132 | {% if manifest.attr.tfm_partition_ipc %} |
| 133 | .partition_flags = SPM_PART_FLAG_IPC |
| 134 | {% else %} |
| 135 | .partition_flags = 0 |
| 136 | {% endif %} |
| 137 | {% if manifest.manifest.type == "APPLICATION-ROT" %} |
| 138 | | SPM_PART_FLAG_APP_ROT |
| 139 | {% elif manifest.manifest.type == "PSA-ROT" %} |
| 140 | | SPM_PART_FLAG_PSA_ROT | SPM_PART_FLAG_APP_ROT |
| 141 | {% else %} |
| 142 | #error "Unsupported type '{{manifest.manifest.type}}' for partition '{{manifest.manifest.name}}'!" |
| 143 | {% endif %} |
| 144 | , |
| 145 | .partition_priority = TFM_PRIORITY({{manifest.manifest.priority}}), |
| 146 | .partition_init = {{manifest.manifest.entry_point}}, |
Edison Ai | e728fbf | 2019-11-13 09:37:12 +0800 | [diff] [blame] | 147 | .dependencies_num = {{manifest.manifest.dependencies | length()}}, |
| 148 | {% if manifest.manifest.dependencies %} |
| 149 | .p_dependencies = dependencies_{{manifest.manifest.name}}, |
| 150 | {% else %} |
| 151 | .p_dependencies = NULL, |
| 152 | {% endif %} |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 153 | {{'},'}} |
| 154 | {% if manifest.attr.conditional %} |
| 155 | #endif /* {{manifest.attr.conditional}} */ |
| 156 | {% endif %} |
| 157 | |
| 158 | {% endfor %} |
| 159 | }; |
| 160 | |
| 161 | /**************************************************************************/ |
| 162 | /** The platform data of the partition list */ |
| 163 | /**************************************************************************/ |
Mate Toth-Pal | 8ac98a7 | 2019-11-21 17:30:10 +0100 | [diff] [blame] | 164 | {% for manifest in manifests %} |
| 165 | {% if manifest.manifest.mmio_regions %} |
| 166 | {% if manifest.attr.conditional %} |
| 167 | #ifdef {{manifest.attr.conditional}} |
| 168 | {% endif %} |
| 169 | const struct tfm_spm_partition_platform_data_t * |
| 170 | platform_data_list_{{manifest.manifest.name}}[] = |
| 171 | { |
| 172 | {% for region in manifest.manifest.mmio_regions %} |
| 173 | {% if region.conditional %} |
| 174 | #ifdef {{region.conditional}} |
| 175 | {% endif %} |
| 176 | {{region.name}}, |
| 177 | {% if region.conditional %} |
| 178 | #endif /* {{region.conditional}} */ |
| 179 | {% endif %} |
| 180 | {% endfor %} |
| 181 | NULL |
| 182 | }; |
| 183 | {% if manifest.attr.conditional %} |
| 184 | #endif /* {{manifest.attr.conditional}} */ |
| 185 | {% endif %} |
| 186 | |
| 187 | {% endif %} |
| 188 | {% endfor %} |
| 189 | const struct tfm_spm_partition_platform_data_t **platform_data_list_list[] = |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 190 | { |
| 191 | NULL, |
| 192 | |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 193 | {% for manifest in manifests %} |
| 194 | {% if manifest.attr.conditional %} |
| 195 | #ifdef {{manifest.attr.conditional}} |
| 196 | {% endif %} |
| 197 | {% if manifest.manifest.mmio_regions %} |
Mate Toth-Pal | 8ac98a7 | 2019-11-21 17:30:10 +0100 | [diff] [blame] | 198 | platform_data_list_{{manifest.manifest.name}}, |
| 199 | {% else %}{# if manifest.manifest.mmio_regions #} |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 200 | NULL, |
Mate Toth-Pal | 8ac98a7 | 2019-11-21 17:30:10 +0100 | [diff] [blame] | 201 | {% endif %}{# if manifest.manifest.mmio_regions #} |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 202 | {% if manifest.attr.conditional %} |
| 203 | #endif /* {{manifest.attr.conditional}} */ |
| 204 | {% endif %} |
| 205 | |
| 206 | {% endfor %} |
| 207 | }; |
| 208 | |
| 209 | /**************************************************************************/ |
| 210 | /** The memory data of the partition list */ |
| 211 | /**************************************************************************/ |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 212 | const struct tfm_spm_partition_memory_data_t memory_data_list[] = |
| 213 | { |
| 214 | { |
| 215 | .stack_bottom = PART_REGION_ADDR(ARM_LIB_STACK, $$ZI$$Base), |
| 216 | .stack_top = PART_REGION_ADDR(ARM_LIB_STACK, $$ZI$$Limit), |
| 217 | .rw_start = PART_REGION_ADDR(ARM_LIB_STACK, $$ZI$$Base), |
| 218 | }, |
| 219 | {% for manifest in manifests %} |
| 220 | {% if manifest.attr.conditional %} |
| 221 | #ifdef {{manifest.attr.conditional}} |
| 222 | {% endif %} |
| 223 | {{'{'}} |
Edison Ai | b2134e6 | 2019-10-11 18:24:47 +0800 | [diff] [blame] | 224 | .code_start = PART_REGION_ADDR({{manifest.manifest.name}}_LINKER, $$Base), |
| 225 | .code_limit = PART_REGION_ADDR({{manifest.manifest.name}}_LINKER, $$Limit), |
| 226 | .ro_start = PART_REGION_ADDR({{manifest.manifest.name}}_LINKER, $$RO$$Base), |
| 227 | .ro_limit = PART_REGION_ADDR({{manifest.manifest.name}}_LINKER, $$RO$$Limit), |
| 228 | .rw_start = PART_REGION_ADDR({{manifest.manifest.name}}_LINKER, _DATA$$RW$$Base), |
| 229 | .rw_limit = PART_REGION_ADDR({{manifest.manifest.name}}_LINKER, _DATA$$RW$$Limit), |
| 230 | .zi_start = PART_REGION_ADDR({{manifest.manifest.name}}_LINKER, _DATA$$ZI$$Base), |
| 231 | .zi_limit = PART_REGION_ADDR({{manifest.manifest.name}}_LINKER, _DATA$$ZI$$Limit), |
| 232 | .stack_bottom = PART_REGION_ADDR({{manifest.manifest.name}}_LINKER, _STACK$$ZI$$Base), |
| 233 | .stack_top = PART_REGION_ADDR({{manifest.manifest.name}}_LINKER, _STACK$$ZI$$Limit), |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 234 | {{'},'}} |
| 235 | {% if manifest.attr.conditional %} |
| 236 | #endif /* {{manifest.attr.conditional}} */ |
| 237 | {% endif %} |
| 238 | |
| 239 | {% endfor %} |
| 240 | }; |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 241 | |
| 242 | /**************************************************************************/ |
Mate Toth-Pal | 3ad2e3e | 2019-07-11 21:43:37 +0200 | [diff] [blame] | 243 | /** The partition list for the DB */ |
| 244 | /**************************************************************************/ |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 245 | static struct spm_partition_desc_t partition_list [] = |
Mate Toth-Pal | 3ad2e3e | 2019-07-11 21:43:37 +0200 | [diff] [blame] | 246 | { |
TTornblom | 83d9637 | 2019-11-19 12:53:16 +0100 | [diff] [blame] | 247 | {{'{{0}}'}}, /* placeholder for Non-secure internal partition */ |
Mate Toth-Pal | 3ad2e3e | 2019-07-11 21:43:37 +0200 | [diff] [blame] | 248 | |
| 249 | {% for manifest in manifests %} |
| 250 | /* -----------------------------------------------------------------------*/ |
| 251 | /* - Partition DB record for {{manifest.manifest.name}} */ |
| 252 | /* -----------------------------------------------------------------------*/ |
| 253 | {% if manifest.attr.conditional %} |
| 254 | #ifdef {{manifest.attr.conditional}} |
| 255 | {% endif %} |
| 256 | {{'{'}} |
Mate Toth-Pal | 3ad2e3e | 2019-07-11 21:43:37 +0200 | [diff] [blame] | 257 | /* Runtime data */ |
TTornblom | 83d9637 | 2019-11-19 12:53:16 +0100 | [diff] [blame] | 258 | .runtime_data = {0}, |
Summer Qin | 423dbef | 2019-08-22 15:59:35 +0800 | [diff] [blame] | 259 | .static_data = NULL, |
Mate Toth-Pal | 8ac98a7 | 2019-11-21 17:30:10 +0100 | [diff] [blame] | 260 | .platform_data_list = NULL, |
Mate Toth-Pal | 3ad2e3e | 2019-07-11 21:43:37 +0200 | [diff] [blame] | 261 | {{'},'}} |
| 262 | {% if manifest.attr.conditional %} |
| 263 | #endif /* {{manifest.attr.conditional}} */ |
| 264 | {% endif %} |
| 265 | |
| 266 | {% endfor %} |
| 267 | }; |
| 268 | |
| 269 | struct spm_partition_db_t g_spm_partition_db = { |
| 270 | .is_init = 0, |
| 271 | .partition_count = sizeof(partition_list) / sizeof(partition_list[0]), |
Mate Toth-Pal | 3ad2e3e | 2019-07-11 21:43:37 +0200 | [diff] [blame] | 272 | .partitions = partition_list, |
| 273 | }; |
| 274 | |
Shawn Shan | 071d86d | 2020-05-25 17:32:58 +0800 | [diff] [blame] | 275 | #endif /* __TFM_SPM_DB_IPC_INC__ */ |