blob: 86390df74e4715bc0ff0d7e9d92f167944832dc0 [file] [log] [blame]
Mate Toth-Pal3ad2e3e2019-07-11 21:43:37 +02001/*
TTornblom83d96372019-11-19 12:53:16 +01002 * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
Mate Toth-Pal3ad2e3e2019-07-11 21:43:37 +02003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8{{utilities.donotedit_warning}}
9
Shawn Shan071d86d2020-05-25 17:32:58 +080010#ifndef __TFM_SPM_DB_IPC_INC__
11#define __TFM_SPM_DB_IPC_INC__
Mate Toth-Pal3ad2e3e2019-07-11 21:43:37 +020012
13#include "spm_api.h"
Edison Aie728fbf2019-11-13 09:37:12 +080014#include "psa_manifest/sid.h"
Mate Toth-Pal3ad2e3e2019-07-11 21:43:37 +020015
Edison Ai1545bb92019-11-14 14:15:27 +080016{# 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-Pal3ad2e3e2019-07-11 21:43:37 +020022/**************************************************************************/
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 Ai9c48d202019-10-12 16:57:21 +080042extern void tfm_nspm_thread_entry(void);
Summer Qin423dbef2019-08-22 15:59:35 +080043
Mate Toth-Pal3ad2e3e2019-07-11 21:43:37 +020044{% for manifest in manifests %}
45 {% if manifest.attr.conditional %}
46#ifdef {{manifest.attr.conditional}}
47 {% endif %}
Edison Ai9c48d202019-10-12 16:57:21 +080048extern void {{manifest.manifest.entry_point}}(void);
Mate Toth-Pal3ad2e3e2019-07-11 21:43:37 +020049 {% if manifest.attr.conditional %}
50#endif /* {{manifest.attr.conditional}} */
51 {% endif %}
52
53{% endfor %}
54/**************************************************************************/
55/** Memory region declarations */
56/**************************************************************************/
Summer Qin423dbef2019-08-22 15:59:35 +080057REGION_DECLARE(Image$$, ARM_LIB_STACK, $$ZI$$Base);
58REGION_DECLARE(Image$$, ARM_LIB_STACK, $$ZI$$Limit);
59
Mate Toth-Pal3ad2e3e2019-07-11 21:43:37 +020060{% for manifest in manifests %}
61 {% if manifest.attr.conditional %}
62#ifdef {{manifest.attr.conditional}}
63 {% endif %}
Edison Aib2134e62019-10-11 18:24:47 +080064REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, $$Base);
65REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, $$Limit);
66REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, $$RO$$Base);
67REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, $$RO$$Limit);
68REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, _DATA$$RW$$Base);
69REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, _DATA$$RW$$Limit);
70REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, _DATA$$ZI$$Base);
71REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, _DATA$$ZI$$Limit);
72REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, _STACK$$ZI$$Base);
73REGION_DECLARE(Image$$, {{manifest.manifest.name}}_LINKER, _STACK$$ZI$$Limit);
Mate Toth-Pal3ad2e3e2019-07-11 21:43:37 +020074 {% if manifest.attr.conditional %}
75#endif /* {{manifest.attr.conditional}} */
76 {% endif %}
77
78{% endfor %}
Mate Toth-Pal3ad2e3e2019-07-11 21:43:37 +020079/**************************************************************************/
Edison Aie728fbf2019-11-13 09:37:12 +080080/** 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 %}
87static int32_t dependencies_{{manifest.manifest.name}}[] =
88{
89 {% for dependence in manifest.manifest.dependencies %}
Edison Aib262cc42019-12-20 14:47:52 +080090 {% 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 Aie728fbf2019-11-13 09:37:12 +080095 {{dependence}}_SID,
96 {% endfor %}
97};
98 {% if manifest.attr.conditional %}
99#endif /* {{manifest.attr.conditional}} */
100 {% endif %}
101
102 {% endif %}
103{% endfor %}
104/**************************************************************************/
Summer Qin423dbef2019-08-22 15:59:35 +0800105/** The static data of the partition list */
106/**************************************************************************/
107const struct spm_partition_static_data_t static_data_list[] =
108{
109 {
Edison Aif0501702019-10-11 14:36:42 +0800110 .psa_framework_version = 0x0100,
Summer Qin423dbef2019-08-22 15:59:35 +0800111 .partition_id = TFM_SP_NON_SECURE_ID,
David Hu90128b72019-09-23 16:35:41 +0800112#if TFM_MULTI_CORE_TOPOLOGY
113 .partition_flags = SPM_PART_FLAG_PSA_ROT | SPM_PART_FLAG_IPC,
114#else
Summer Qin423dbef2019-08-22 15:59:35 +0800115 .partition_flags = SPM_PART_FLAG_APP_ROT | SPM_PART_FLAG_IPC,
David Hu90128b72019-09-23 16:35:41 +0800116#endif
Summer Qin423dbef2019-08-22 15:59:35 +0800117 .partition_priority = TFM_PRIORITY_LOW,
118 .partition_init = tfm_nspm_thread_entry,
Summer Qin423dbef2019-08-22 15:59:35 +0800119 },
120
Summer Qin423dbef2019-08-22 15:59:35 +0800121{% for manifest in manifests %}
122 {% if manifest.attr.conditional %}
123#ifdef {{manifest.attr.conditional}}
124 {% endif %}
125 {{'{'}}
Edison Aif0501702019-10-11 14:36:42 +0800126 {% if manifest.manifest.psa_framework_version == 1.0 %}
127 .psa_framework_version = 0x0100,
128 {% else %}
129 .psa_framework_version = 0,
130 {% endif %}
Edison Aib2134e62019-10-11 18:24:47 +0800131 .partition_id = {{manifest.manifest.name}},
Summer Qin423dbef2019-08-22 15:59:35 +0800132 {% 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 Aie728fbf2019-11-13 09:37:12 +0800147 .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 Qin423dbef2019-08-22 15:59:35 +0800153 {{'},'}}
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-Pal8ac98a72019-11-21 17:30:10 +0100164{% for manifest in manifests %}
165 {% if manifest.manifest.mmio_regions %}
166 {% if manifest.attr.conditional %}
167#ifdef {{manifest.attr.conditional}}
168 {% endif %}
169const 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 %}
189const struct tfm_spm_partition_platform_data_t **platform_data_list_list[] =
Summer Qin423dbef2019-08-22 15:59:35 +0800190{
191 NULL,
192
Summer Qin423dbef2019-08-22 15:59:35 +0800193{% for manifest in manifests %}
194 {% if manifest.attr.conditional %}
195#ifdef {{manifest.attr.conditional}}
196 {% endif %}
197 {% if manifest.manifest.mmio_regions %}
Mate Toth-Pal8ac98a72019-11-21 17:30:10 +0100198 platform_data_list_{{manifest.manifest.name}},
199 {% else %}{# if manifest.manifest.mmio_regions #}
Summer Qin423dbef2019-08-22 15:59:35 +0800200 NULL,
Mate Toth-Pal8ac98a72019-11-21 17:30:10 +0100201 {% endif %}{# if manifest.manifest.mmio_regions #}
Summer Qin423dbef2019-08-22 15:59:35 +0800202 {% 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 Qin423dbef2019-08-22 15:59:35 +0800212const 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 Aib2134e62019-10-11 18:24:47 +0800224 .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 Qin423dbef2019-08-22 15:59:35 +0800234 {{'},'}}
235 {% if manifest.attr.conditional %}
236#endif /* {{manifest.attr.conditional}} */
237 {% endif %}
238
239{% endfor %}
240};
Summer Qin423dbef2019-08-22 15:59:35 +0800241
242/**************************************************************************/
Mate Toth-Pal3ad2e3e2019-07-11 21:43:37 +0200243/** The partition list for the DB */
244/**************************************************************************/
Summer Qin423dbef2019-08-22 15:59:35 +0800245static struct spm_partition_desc_t partition_list [] =
Mate Toth-Pal3ad2e3e2019-07-11 21:43:37 +0200246{
TTornblom83d96372019-11-19 12:53:16 +0100247 {{'{{0}}'}}, /* placeholder for Non-secure internal partition */
Mate Toth-Pal3ad2e3e2019-07-11 21:43:37 +0200248
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-Pal3ad2e3e2019-07-11 21:43:37 +0200257 /* Runtime data */
TTornblom83d96372019-11-19 12:53:16 +0100258 .runtime_data = {0},
Summer Qin423dbef2019-08-22 15:59:35 +0800259 .static_data = NULL,
Mate Toth-Pal8ac98a72019-11-21 17:30:10 +0100260 .platform_data_list = NULL,
Mate Toth-Pal3ad2e3e2019-07-11 21:43:37 +0200261 {{'},'}}
262 {% if manifest.attr.conditional %}
263#endif /* {{manifest.attr.conditional}} */
264 {% endif %}
265
266{% endfor %}
267};
268
269struct spm_partition_db_t g_spm_partition_db = {
270 .is_init = 0,
271 .partition_count = sizeof(partition_list) / sizeof(partition_list[0]),
Mate Toth-Pal3ad2e3e2019-07-11 21:43:37 +0200272 .partitions = partition_list,
273};
274
Shawn Shan071d86d2020-05-25 17:32:58 +0800275#endif /* __TFM_SPM_DB_IPC_INC__ */