aboutsummaryrefslogtreecommitdiff
path: root/secure_fw/partitions/partition_static_info.template
blob: e3a3a2b1f3d55204a3cbdc4251853c439793437f (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
/*
 * Copyright (c) 2021, Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 *
 */

{{utilities.donotedit_warning}}

#include <stdint.h>
#include <stddef.h>
#include "region.h"
#include "load/partition_static_load.h"
#include "load/partition_defs.h"
#include "load/service_defs.h"
#include "tfm_peripherals_def.h"
#include "psa_manifest/pid.h"
#include "psa_manifest/sid.h"
#include "psa_manifest/{{file_name}}.h"

{% set counter = namespace(dep_counter=0, service_counter=0) %}
{% if manifest.dependencies %}
    {% for dep in manifest.dependencies %}
        {% set counter.dep_counter = counter.dep_counter + 1 %}
    {% endfor %}
{% endif %}
{% if manifest.services %}
    {% for service in manifest.services %}
        {% set counter.service_counter = counter.service_counter + 1 %}
    {% endfor %}
{% endif %}
#define {{"%-55s"|format(manifest.name|upper + "_NDEPS")}} ({{"%d"|format(counter.dep_counter)}})
#define {{"%-55s"|format(manifest.name|upper + "_NSERVS")}} ({{"%d"|format(counter.service_counter)}})

/* Memory region declaration */
#if TFM_LVL == 3
REGION_DECLARE(Image$$, PT_{{manifest.name}}_PRIVATE, _DATA_START$$Base);
REGION_DECLARE(Image$$, PT_{{manifest.name}}_PRIVATE, _DATA_END$$Base);
#endif
extern uint8_t {{manifest.name|lower}}_stack[];

/* Entrypoint function declaration */
extern void {{manifest.entry_point}}(void);

{% if manifest.mmio_regions %}
/* Platform data declaration */
const struct platform_data_t *platform_data_list_{{manifest.name|lower}}[] =
{
    {% for region in manifest.mmio_regions %}
        {% if region.conditional %}
#ifdef {{region.conditional}}
        {% endif %}
    {{region.name}},
        {% if region.conditional %}
#endif
        {% endif %}
    {% endfor %}
    NULL
};
{% endif %}

/* partition static info type definition */
struct partition_{{manifest.name|lower}}_static_info_t {
    /* common length data */
    struct partition_static_info_t  cmn_info;
    /* per-partition variable length data */
    uintptr_t                       stack_pos;
    uintptr_t                       heap_pos;
{% if manifest.dependencies %}
    uint32_t                        deps[{{(manifest.name|upper + "_NDEPS")}}];
{% endif %}
{% if manifest.services %}
    struct service_static_info_t    services[{{(manifest.name|upper + "_NSERVS")}}];
{% endif %}
} __attribute__((aligned(4)));

/* Partition static, deps, service static data. Put to a dedicated section. */
const struct partition_{{manifest.name|lower}}_static_info_t {{manifest.name|lower}}_static
    __attribute__((used, section(".partition_info"))) = {
    .cmn_info = {
{% if manifest.psa_framework_version == 1.0 %}
        .psa_ff_ver                 = 0x0100 | PARTITION_INFO_MAGIC,
{% elif manifest.psa_framework_version == 1.1 %}
        .psa_ff_ver                 = 0x0101 | PARTITION_INFO_MAGIC,
{% else %}
#error "Unsupported ff version '{{manifest.psa_framework_version}}' for partition '{{manifest.name}}'!"
{% endif %}
        .pid                        = {{manifest.name}},
        .flags                      = 0
{% if manifest.psa_framework_version == 1.0 and attr.tfm_partition_ipc is sameas true %}
                                    | SPM_PART_FLAG_IPC
{% elif manifest.psa_framework_version == 1.1 and manifest.model == "IPC" %}
                                    | SPM_PART_FLAG_IPC
{% endif %}
{% if manifest.type == "PSA-ROT" %}
                                    | SPM_PART_FLAG_PSA_ROT
{% elif manifest.type != "APPLICATION-ROT" %}
#error "Unsupported type '{{manifest.type}}' for partition '{{manifest.name}}'!"
{% endif %}
                                    | PARTITION_PRI_{{manifest.priority}},
        .entry                      = ENTRY_TO_POSITION({{manifest.entry_point}}),
        .stack_size                 = {{manifest.stack_size}},
        .heap_size                  = 0,
        .ndeps                      = {{(manifest.name|upper + "_NDEPS")}},
        .nservices                  = {{(manifest.name|upper + "_NSERVS")}},
{% if manifest.mmio_regions %}
        .plat_cookie                = PTR_TO_POSITION(platform_data_list_{{manifest.name|lower}}),
{% else %}
        .plat_cookie                = 0,
{% endif %}
#if TFM_LVL == 3
        .mems                       = {
            .start                    = PART_REGION_ADDR(PT_{{manifest.name}}_PRIVATE, _DATA_START$$Base),
            .limit                    = PART_REGION_ADDR(PT_{{manifest.name}}_PRIVATE, _DATA_END$$Base),
        },
#endif
    },
    .stack_pos                      = PTR_TO_POSITION({{manifest.name|lower}}_stack),
    .heap_pos                       = 0,
{% if manifest.dependencies %}
    .deps = {
    {% for dep in manifest.dependencies %}
        {{dep}}_SID,
    {% endfor %}
    },
{% endif %}
{% if manifest.services %}
    .services = {
    {% for service in manifest.services %}
        {
            .name_strid             = STRING_PTR_TO_STRID("{{service.name}}"),
            .signal                 = {{service.name}}_SIGNAL,
            .sid                    = {{service.sid}},
            .flags                  = 0
        {% if service.non_secure_clients is sameas true %}
                                    | SERVICE_FLAG_NS_ACCESSIBLE
        {% endif %}
        {% if manifest.psa_framework_version > 1.0 and service.connection_based is sameas false %}
                                    | SERVICE_FLAG_STATELESS
        {% endif %}
        {% if service.version_policy %}
                                    | TFM_VERSION_POLICY_{{service.version_policy}},
        {% else %}
                                    | TFM_VERSION_POLICY_STRICT,
        {% endif %}
        {% if service.version %}
            .version                = {{service.version}},
        {% else %}
            .version                = 1,
        {% endif %}
        },
    {% endfor %}
    },
{% endif %}
};