aboutsummaryrefslogtreecommitdiff
path: root/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc.template
blob: 4d36797ac708148d7325c702668f0d4956276883 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/*
 * Copyright (c) 2019-2021, Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 *
 */

{{utilities.donotedit_warning}}

#ifndef __TFM_SPM_DB_IPC_INC__
#define __TFM_SPM_DB_IPC_INC__

#include "psa_manifest/sid.h"

{# Produce a build error if heap_size is presented in the manifest, because of the dynamic memory allocation is not supported now. #}
{% for partition in partitions %}
    {% if partition.manifest.heap_size %}
#error "Please do not add 'heap_size' for partition '{{partition.manifest.name}}', the dynamic memory allocation is not supported now!"
    {% endif %}
{% endfor %}
/**************************************************************************/
/** IRQ count per partition */
/**************************************************************************/
{% for partition in partitions %}
    {% if partition.attr.conditional %}
#ifdef {{partition.attr.conditional}}
    {% endif %}
    {% if partition.manifest.irqs %}
#define TFM_PARTITION_{{partition.manifest.name}}_IRQ_COUNT {{partition.manifest.irqs | length() }}
    {% else %}
#define TFM_PARTITION_{{partition.manifest.name}}_IRQ_COUNT 0
    {% endif %}
    {% if partition.attr.conditional %}
#endif /* {{partition.attr.conditional}} */
    {% endif %}

{% endfor %}
/**************************************************************************/
/** Declarations of partition init functions */
/**************************************************************************/
extern void tfm_nspm_thread_entry(void);

{% for partition in partitions %}
    {% if partition.attr.conditional %}
#ifdef {{partition.attr.conditional}}
    {% endif %}
extern void {{partition.manifest.entry_point}}(void);
    {% if partition.attr.conditional %}
#endif /* {{partition.attr.conditional}} */
    {% endif %}

{% endfor %}
/**************************************************************************/
/** Memory region declarations */
/**************************************************************************/
REGION_DECLARE(Image$$, ARM_LIB_STACK, $$ZI$$Base);
REGION_DECLARE(Image$$, ARM_LIB_STACK, $$ZI$$Limit);

{% for partition in partitions %}
    {% if partition.attr.conditional %}
#ifdef {{partition.attr.conditional}}
    {% endif %}
#if TFM_LVL == 3
REGION_DECLARE(Image$$, PT_{{partition.manifest.name}}_PRIVATE, _DATA_START$$Base);
REGION_DECLARE(Image$$, PT_{{partition.manifest.name}}_PRIVATE, _DATA_END$$Base);
#endif
extern uint8_t {{partition.manifest.name.lower()}}_stack[];
    {% if partition.attr.conditional %}
#endif /* {{partition.attr.conditional}} */
    {% endif %}

{% endfor %}
/**************************************************************************/
/** Dependencies array for Secure Partition */
/**************************************************************************/
{% for partition in partitions %}
    {% if partition.manifest.dependencies %}
        {% if partition.attr.conditional %}
#ifdef {{partition.attr.conditional}}
        {% endif %}
static uint32_t dependencies_{{partition.manifest.name}}[] =
{
        {% for dependence in partition.manifest.dependencies %}
            {% for service in partition.manifest.services %}
                {% if dependence == service.name %}
#error "Please DO NOT include SP's own RoT Service '{{dependence}}', which will cause a deadlock!"
                {% endif %}
            {% endfor %}
    {{dependence}}_SID,
        {% endfor %}
};
        {% if partition.attr.conditional %}
#endif /* {{partition.attr.conditional}} */
        {% endif %}

    {% endif %}
{% endfor %}
/**************************************************************************/
/** The static data of the partition list */
/**************************************************************************/
const struct partition_static_t static_data_list[] =
{
    {
        .psa_ff_ver           = 0x0100,
        .pid                  = TFM_SP_NON_SECURE_ID,
#if TFM_MULTI_CORE_TOPOLOGY
        .flags                = SPM_PART_FLAG_PSA_ROT | SPM_PART_FLAG_IPC,
#else
        .flags                = SPM_PART_FLAG_APP_ROT | SPM_PART_FLAG_IPC,
#endif
        .priority             = TFM_PRIORITY_LOW,
        .entry                = tfm_nspm_thread_entry,
        .stack_base_addr      = 0,
        .stack_size           = 0
    },

{% for partition in partitions %}
    {% if partition.attr.conditional %}
#ifdef {{partition.attr.conditional}}
    {% endif %}
    {{'{'}}
    {% if partition.manifest.psa_framework_version == 1.0 %}
        .psa_ff_ver            = 0x0100,
    {% else %}
        .psa_ff_ver            = 0,
    {% endif %}
        .pid                   = {{partition.manifest.name}},
    {% if partition.attr.tfm_partition_ipc %}
        .flags                 = SPM_PART_FLAG_IPC
    {% else %}
        .flags                 = 0
    {% endif %}
    {% if partition.manifest.type == "APPLICATION-ROT" %}
                               | SPM_PART_FLAG_APP_ROT
    {% elif partition.manifest.type == "PSA-ROT" %}
                               | SPM_PART_FLAG_PSA_ROT | SPM_PART_FLAG_APP_ROT
    {% else %}
#error "Unsupported type '{{partition.manifest.type}}' for partition '{{partition.manifest.name}}'!"
    {% endif %}
                              ,
        .priority             = TFM_PRIORITY({{partition.manifest.priority}}),
        .entry                = {{partition.manifest.entry_point}},
        .stack_base_addr      = 0,
        .stack_size           = 0,
        .ndeps                = {{partition.manifest.dependencies | length()}},
    {% if partition.manifest.dependencies %}
        .deps                 = dependencies_{{partition.manifest.name}},
    {% else %}
        .deps                 = NULL,
    {% endif %}
    {{'},'}}
    {% if partition.attr.conditional %}
#endif /* {{partition.attr.conditional}} */
    {% endif %}

{% endfor %}
};

/**************************************************************************/
/** The platform data of the partition list */
/**************************************************************************/
{% for partition in partitions %}
    {% if partition.manifest.mmio_regions %}
        {% if partition.attr.conditional %}
#ifdef {{partition.attr.conditional}}
        {% endif %}
const struct tfm_spm_partition_platform_data_t *
    platform_data_list_{{partition.manifest.name}}[] =
{
        {% for region in partition.manifest.mmio_regions %}
            {% if region.conditional %}
#ifdef {{region.conditional}}
            {% endif %}
    {{region.name}},
            {% if region.conditional %}
#endif /* {{region.conditional}} */
            {% endif %}
        {% endfor %}
    NULL
};
        {% if partition.attr.conditional %}
#endif /* {{partition.attr.conditional}} */
        {% endif %}

    {% endif %}
{% endfor %}
const struct tfm_spm_partition_platform_data_t **platform_data_list_list[] =
{
    NULL,

{% for partition in partitions %}
    {% if partition.attr.conditional %}
#ifdef {{partition.attr.conditional}}
    {% endif %}
    {% if partition.manifest.mmio_regions %}
    platform_data_list_{{partition.manifest.name}},
    {% else %}{# if partition.manifest.mmio_regions #}
    NULL,
    {% endif %}{# if partition.manifest.mmio_regions #}
    {% if partition.attr.conditional %}
#endif /* {{partition.attr.conditional}} */
    {% endif %}

{% endfor %}
};

/**************************************************************************/
/** The memory data of the partition list */
/**************************************************************************/
const struct tfm_spm_partition_memory_data_t memory_data_list[] =
{
    {
#if TFM_LVL == 3
        .data_start           = PART_REGION_ADDR(ARM_LIB_STACK, $$ZI$$Base),
        .data_limit           = PART_REGION_ADDR(ARM_LIB_STACK, $$ZI$$Limit),
#endif
        .stack_bottom         = PART_REGION_ADDR(ARM_LIB_STACK, $$ZI$$Base),
        .stack_top            = PART_REGION_ADDR(ARM_LIB_STACK, $$ZI$$Limit),
    },
{% for partition in partitions %}
    {% if partition.attr.conditional %}
#ifdef {{partition.attr.conditional}}
    {% endif %}
    {{'{'}}
#if TFM_LVL == 3
        .data_start           = PART_REGION_ADDR(PT_{{partition.manifest.name}}_PRIVATE, _DATA_START$$Base),
        .data_limit           = PART_REGION_ADDR(PT_{{partition.manifest.name}}_PRIVATE, _DATA_END$$Base),
#endif
        .stack_bottom         = (uint32_t){{partition.manifest.name.lower()}}_stack,
        .stack_top            = (uint32_t)({{partition.manifest.name.lower()}}_stack + {{partition.manifest.stack_size}}),
    {{'},'}}
    {% if partition.attr.conditional %}
#endif /* {{partition.attr.conditional}} */
    {% endif %}

{% endfor %}
};

/**************************************************************************/
/** The partition list for the DB */
/**************************************************************************/
static struct partition_t partition_list [] =
{
    {{'{0}'}}, /* placeholder for Non-secure internal partition */

{% for partition in partitions %}
    /* -----------------------------------------------------------------------*/
    /* - Partition DB record for {{partition.manifest.name}} */
    /* -----------------------------------------------------------------------*/
    {% if partition.attr.conditional %}
#ifdef {{partition.attr.conditional}}
    {% endif %}
    {{'{0}'}},
    {% if partition.attr.conditional %}
#endif /* {{partition.attr.conditional}} */
    {% endif %}

{% endfor %}
};

struct spm_partition_db_t g_spm_partition_db = {
    .is_init = 0,
    .partition_count = sizeof(partition_list) / sizeof(partition_list[0]),
    .partitions = partition_list,
};

#endif /* __TFM_SPM_DB_IPC_INC__ */