blob: ad005dddae5d2f25ec1b7266bfcf7fb23a5d7c62 [file] [log] [blame]
Mingyang Sunf6a78572021-04-02 16:51:05 +08001/*
2 * Copyright (c) 2021, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8{{utilities.donotedit_warning}}
9
10#include <stdint.h>
11#include <stddef.h>
12#include "region.h"
13#include "load/partition_static_load.h"
14#include "load/partition_defs.h"
15#include "load/service_defs.h"
Ken Liu86686282021-04-27 11:11:15 +080016#include "load/asset_defs.h"
Mingyang Sunf6a78572021-04-02 16:51:05 +080017#include "tfm_peripherals_def.h"
18#include "psa_manifest/pid.h"
19#include "psa_manifest/sid.h"
Ken Liu861b0782021-05-22 13:15:08 +080020#include "psa_manifest/{{manifest_out_basename}}.h"
Mingyang Sunf6a78572021-04-02 16:51:05 +080021
Ken Liu86686282021-04-27 11:11:15 +080022{% set counter = namespace(dep_counter=0, service_counter=0, asset_counter=0) %}
Mingyang Sunf6a78572021-04-02 16:51:05 +080023{% if manifest.dependencies %}
24 {% for dep in manifest.dependencies %}
25 {% set counter.dep_counter = counter.dep_counter + 1 %}
26 {% endfor %}
27{% endif %}
28{% if manifest.services %}
29 {% for service in manifest.services %}
30 {% set counter.service_counter = counter.service_counter + 1 %}
31 {% endfor %}
32{% endif %}
Ken Liu86686282021-04-27 11:11:15 +080033{% if manifest.mmio_regions %}
34 {% for asset in manifest.mmio_regions %}
35 {% set counter.asset_counter = counter.asset_counter + 1 %}
36 {% endfor %}
37{% endif %}
Mingyang Sunf6a78572021-04-02 16:51:05 +080038#define {{"%-55s"|format(manifest.name|upper + "_NDEPS")}} ({{"%d"|format(counter.dep_counter)}})
39#define {{"%-55s"|format(manifest.name|upper + "_NSERVS")}} ({{"%d"|format(counter.service_counter)}})
Ken Liu86686282021-04-27 11:11:15 +080040#if TFM_LVL == 3
41#define {{"%-55s"|format(manifest.name|upper + "_NASSETS")}} ({{"%d"|format(counter.asset_counter)}} + 1)
42#else
43#define {{"%-55s"|format(manifest.name|upper + "_NASSETS")}} ({{"%d"|format(counter.asset_counter)}})
44#endif
Mingyang Sunf6a78572021-04-02 16:51:05 +080045
46/* Memory region declaration */
47#if TFM_LVL == 3
48REGION_DECLARE(Image$$, PT_{{manifest.name}}_PRIVATE, _DATA_START$$Base);
49REGION_DECLARE(Image$$, PT_{{manifest.name}}_PRIVATE, _DATA_END$$Base);
50#endif
51extern uint8_t {{manifest.name|lower}}_stack[];
52
53/* Entrypoint function declaration */
54extern void {{manifest.entry_point}}(void);
55
Mingyang Sunf6a78572021-04-02 16:51:05 +080056/* partition static info type definition */
Ken Liu4520ce32021-05-11 22:49:10 +080057struct partition_{{manifest.name|lower}}_load_info_t {
Mingyang Sunf6a78572021-04-02 16:51:05 +080058 /* common length data */
Ken Liu4520ce32021-05-11 22:49:10 +080059 struct partition_load_info_t cmn_info;
Mingyang Sunf6a78572021-04-02 16:51:05 +080060 /* per-partition variable length data */
61 uintptr_t stack_pos;
62 uintptr_t heap_pos;
63{% if manifest.dependencies %}
64 uint32_t deps[{{(manifest.name|upper + "_NDEPS")}}];
65{% endif %}
66{% if manifest.services %}
Ken Liu4520ce32021-05-11 22:49:10 +080067 struct service_load_info_t services[{{(manifest.name|upper + "_NSERVS")}}];
Mingyang Sunf6a78572021-04-02 16:51:05 +080068{% endif %}
Ken Liu86686282021-04-27 11:11:15 +080069#if TFM_LVL == 3
70 struct asset_desc_t assets[{{(manifest.name|upper + "_NASSETS")}}];
71#else
72{% if manifest.mmio_regions %}
73 struct asset_desc_t assets[{{(manifest.name|upper + "_NASSETS")}}];
74{% endif %}
75#endif
Mingyang Sunf6a78572021-04-02 16:51:05 +080076} __attribute__((aligned(4)));
77
78/* Partition static, deps, service static data. Put to a dedicated section. */
Ken Liu4520ce32021-05-11 22:49:10 +080079const struct partition_{{manifest.name|lower}}_load_info_t {{manifest.name|lower}}_static
Mingyang Sunf6a78572021-04-02 16:51:05 +080080 __attribute__((used, section(".partition_info"))) = {
81 .cmn_info = {
82{% if manifest.psa_framework_version == 1.0 %}
83 .psa_ff_ver = 0x0100 | PARTITION_INFO_MAGIC,
84{% elif manifest.psa_framework_version == 1.1 %}
85 .psa_ff_ver = 0x0101 | PARTITION_INFO_MAGIC,
86{% else %}
87#error "Unsupported ff version '{{manifest.psa_framework_version}}' for partition '{{manifest.name}}'!"
88{% endif %}
89 .pid = {{manifest.name}},
90 .flags = 0
91{% if manifest.psa_framework_version == 1.0 and attr.tfm_partition_ipc is sameas true %}
92 | SPM_PART_FLAG_IPC
93{% elif manifest.psa_framework_version == 1.1 and manifest.model == "IPC" %}
94 | SPM_PART_FLAG_IPC
95{% endif %}
96{% if manifest.type == "PSA-ROT" %}
97 | SPM_PART_FLAG_PSA_ROT
98{% elif manifest.type != "APPLICATION-ROT" %}
99#error "Unsupported type '{{manifest.type}}' for partition '{{manifest.name}}'!"
100{% endif %}
101 | PARTITION_PRI_{{manifest.priority}},
102 .entry = ENTRY_TO_POSITION({{manifest.entry_point}}),
103 .stack_size = {{manifest.stack_size}},
104 .heap_size = 0,
105 .ndeps = {{(manifest.name|upper + "_NDEPS")}},
106 .nservices = {{(manifest.name|upper + "_NSERVS")}},
Ken Liu86686282021-04-27 11:11:15 +0800107 .nassets = {{(manifest.name|upper + "_NASSETS")}},
Mingyang Sunf6a78572021-04-02 16:51:05 +0800108 },
109 .stack_pos = PTR_TO_POSITION({{manifest.name|lower}}_stack),
110 .heap_pos = 0,
111{% if manifest.dependencies %}
112 .deps = {
113 {% for dep in manifest.dependencies %}
114 {{dep}}_SID,
115 {% endfor %}
116 },
117{% endif %}
118{% if manifest.services %}
119 .services = {
120 {% for service in manifest.services %}
121 {
122 .name_strid = STRING_PTR_TO_STRID("{{service.name}}"),
123 .signal = {{service.name}}_SIGNAL,
124 .sid = {{service.sid}},
125 .flags = 0
126 {% if service.non_secure_clients is sameas true %}
127 | SERVICE_FLAG_NS_ACCESSIBLE
128 {% endif %}
129 {% if manifest.psa_framework_version > 1.0 and service.connection_based is sameas false %}
130 | SERVICE_FLAG_STATELESS
131 {% endif %}
132 {% if service.version_policy %}
133 | TFM_VERSION_POLICY_{{service.version_policy}},
134 {% else %}
135 | TFM_VERSION_POLICY_STRICT,
136 {% endif %}
137 {% if service.version %}
138 .version = {{service.version}},
139 {% else %}
140 .version = 1,
141 {% endif %}
142 },
143 {% endfor %}
144 },
145{% endif %}
Ken Liu86686282021-04-27 11:11:15 +0800146#if TFM_LVL == 3
147 .assets = {
148 {
149 .mem.addr_x = PART_REGION_ADDR(PT_{{manifest.name}}_PRIVATE, _DATA_START$$Base),
150 .mem.addr_y = PART_REGION_ADDR(PT_{{manifest.name}}_PRIVATE, _DATA_END$$Base),
151 .attr = ASSET_MEM_RD_BIT | ASSET_MEM_WR_BIT,
152 },
153{% for region in manifest.mmio_regions %}
154 {% if region.conditional %}
155#ifdef {{region.conditional}}
156 {% endif %}
157 {
158 .dev.addr_ref = PTR_TO_POSITION({{region.name}}),
159 .attr = ASSET_DEV_REF_BIT,
160 },
161 {% if region.conditional %}
162#endif
163 {% endif %}
164{% endfor %}
165 }
166#else
167{% if manifest.mmio_regions %}
168 .assets = {
169 {% for region in manifest.mmio_regions %}
170 {% if region.conditional %}
171#ifdef {{region.conditional}}
172 {% endif %}
173 {
174 .dev.addr_ref = PTR_TO_POSITION({{region.name}}),
175 .attr = ASSET_DEV_REF_BIT,
176 },
177 {% if region.conditional %}
178#endif
179 {% endif %}
180 {% endfor %}
181 }
182{% endif %}
183#endif
Mingyang Sunf6a78572021-04-02 16:51:05 +0800184};