aboutsummaryrefslogtreecommitdiff
path: root/platform/ext/common/iar/tfm_common_s.icf.template
blob: 059948ee60e0eb151c8137d05c620b85f7134070 (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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
/*
 * Copyright (c) 2017-2020 Arm Limited. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * This file is derivative of ../armclang/tfm_common_s.sct.template
 */

{{utilities.donotedit_warning}}

#include "region_defs.h"

define memory mem with size = 4G;

define block ER_TFM_CODE          with fixed order, alignment = 8 {readonly section .intvec, readonly};

define block TFM_UNPRIV_CODE with alignment = 32 {
       ro object platform_retarget_dev.o,
       ro object device_definition.o,
       section SFN,
       ro section .rodata object tfm_*_secure_api.o,
       ro object *6M_tl*.a,
       ro object *7M_tl*.a,
       ro object *libtfmsprt.a
       };

    /**** PSA RoT RO part (CODE + RODATA) start here */
    /*
     * This empty, zero long execution region is here to mark the start address
     * of PSA RoT code.
     */
define block TFM_PSA_CODE_START with alignment = 32, size = 0 { };

{% for manifest in manifests %}
    {% if manifest.manifest.type == 'PSA-ROT' %}
    {% if manifest.attr.conditional %}
#ifdef {{manifest.attr.conditional}}
    {% endif %}
define block {{manifest.manifest.name}}_LINKER with alignment = 32 {
    {% if manifest.attr.linker_pattern.library_list %}
        {% for pattern in manifest.attr.linker_pattern.library_list %}
        ro object {{pattern}},
        {% endfor %}
    {% endif %}
    {% if manifest.attr.linker_pattern.object_list %}
        {% for pattern in manifest.attr.linker_pattern.object_list %}
        ro object {{pattern}},
        {% endfor %}
    {% endif %}
    };
    {% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
    {% endif %}

    {% endif %}
{% endfor %}
    /*
     * This empty, zero long execution region is here to mark the end address
     * of PSA RoT code.
     */
define block TFM_PSA_CODE_END with alignment = 32, size = 0 { };

    /**** APPLICATION RoT RO part (CODE + RODATA) start here */
    /*
     * This empty, zero long execution region is here to mark the start address
     * of APP RoT code.
     */
define block TFM_APP_CODE_START with alignment = 32, size = 0 { };

{% for manifest in manifests %}
    {% if manifest.manifest.type == 'APPLICATION-ROT' %}
    {% if manifest.attr.conditional %}
#ifdef {{manifest.attr.conditional}}
    {% endif %}
define block {{manifest.manifest.name}}_LINKER with alignment = 32 {
    {% if manifest.attr.linker_pattern.library_list %}
        {% for pattern in manifest.attr.linker_pattern.library_list %}
        ro object {{pattern}},
        {% endfor %}
    {% endif %}
    {% if manifest.attr.linker_pattern.object_list %}
        {% for pattern in manifest.attr.linker_pattern.object_list %}
        ro object {{pattern}},
        {% endfor %}
    {% endif %}
    };
    {% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
    {% endif %}

    {% endif %}
{% endfor %}
    /*
     * This empty, zero long execution region is here to mark the end address
     * of APP RoT code.
     */
define block TFM_APP_CODE_END with alignment = 32, size = 0 { };

    /**** Base address of secure data area */
define block TFM_SECURE_DATA_START with size = 0 { };

#if !TFM_MULTI_CORE_TOPOLOGY
    /* Shared area between BL2 and runtime to exchange data */
define block TFM_SHARED_DATA with alignment = 32, size = BOOT_TFM_SHARED_DATA_SIZE { };
define block ARM_LIB_STACK_MSP with alignment = 32, size = S_MSP_STACK_SIZE { };
define overlay STACK_DATA {block TFM_SHARED_DATA};
define overlay STACK_DATA {block ARM_LIB_STACK_MSP};

define block ARM_LIB_STACK with alignment = 32, size = S_PSP_STACK_SIZE { };
#endif

#if !defined(TFM_PSA_API)
define block TFM_SECURE_STACK   with size = 0x2000, alignment = 128 {};
#endif /* !defined(TFM_PSA_API) */

define block TFM_UNPRIV_DATA with alignment = 32 {
       rw object platform_retarget_dev.o,
       rw object device_definition.o,
       };

define block TFM_APP_RW_STACK_START with alignment = 32, size = 0 { };

{% for manifest in manifests %}
    {% if manifest.manifest.type == 'APPLICATION-ROT' %}
    {% if manifest.attr.conditional %}
#ifdef {{manifest.attr.conditional}}
    {% endif %}
define block {{manifest.manifest.name}}_LINKER_DATA with alignment = 32 {
    {% if manifest.attr.linker_pattern.library_list %}
        {% for pattern in manifest.attr.linker_pattern.library_list %}
        rw object {{pattern}},
        {% endfor %}
    {% endif %}
    {% if manifest.attr.linker_pattern.object_list %}
        {% for pattern in manifest.attr.linker_pattern.object_list %}
        rw object {{pattern}},
        {% endfor %}
    {% endif %}
    };

    {% if manifest.attr.tfm_partition_ipc %}
#if defined (TFM_PSA_API)
define block {{manifest.manifest.name}}_LINKER_STACK with alignment = 128, size = {{manifest.manifest.stack_size}} { };
#endif
    {% else %}
#if defined (TFM_PSA_API)
define block {{manifest.manifest.name}}_LINKER_STACK with alignment =  128, size = 0 { };
#endif
    {% endif %}
    {% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
    {% endif %}

    {% endif %}
{% endfor %}

    /*
     * This empty, zero long execution region is here to mark the end address
     * of APP RoT RW and Stack.
     */
define block TFM_APP_RW_STACK_END with alignment = 32, size = 0 { };

#if TFM_MULTI_CORE_TOPOLOGY && defined(S_DATA_PRIV_START)
    /**** Privileged data area base address specified by multi-core platform */
define block TFM_SECURE_PRIV_DATA_BOUNDARY with size = 0 { };
#endif

#if TFM_MULTI_CORE_TOPOLOGY
    /*
     * Move BL2 shared area and MSP stack to the beginning of privileged data
     * area in multi-core topology.
     */
    /* Shared area between BL2 and runtime to exchange data */
define block TFM_SHARED_DATA with alignment = 32, size = BOOT_TFM_SHARED_DATA_SIZE { };

    /* MSP */
define block ARM_LIB_STACK_MSP with alignment = 32, size = S_MSP_STACK_SIZE { };

define overlay STACK_DATA {block TFM_SHARED_DATA};
define overlay STACK_DATA {block ARM_LIB_STACK_MSP};

    /* PSP is privileged in multi-core topology */
define block ARM_LIB_STACK with alignment = 32, size = S_PSP_STACK_SIZE { };
#endif

define block HEAP         with alignment = 8, size = S_HEAP_SIZE { };
define block ARM_LIB_HEAP with alignment = 8, size = S_HEAP_SIZE { };
define overlay HEAP_OVL {block HEAP};
define overlay HEAP_OVL {block ARM_LIB_HEAP};

define block ER_TFM_DATA          with alignment = 8 {readwrite};

    /**** PSA RoT DATA start here */
    /*
     * This empty, zero long execution region is here to mark the start address
     * of PSA RoT RW and Stack.
     */
define block TFM_PSA_RW_STACK_START with alignment = 32, size = 0 { };

{% for manifest in manifests %}
    {% if manifest.manifest.type == 'PSA-ROT' %}
    {% if manifest.attr.conditional %}
#ifdef {{manifest.attr.conditional}}
    {% endif %}
define block {{manifest.manifest.name}}_LINKER_DATA with alignment = 32 {
    {% if manifest.attr.linker_pattern.library_list %}
        {% for pattern in manifest.attr.linker_pattern.library_list %}
        rw object {{pattern}},
        {% endfor %}
    {% endif %}
    {% if manifest.attr.linker_pattern.object_list %}
        {% for pattern in manifest.attr.linker_pattern.object_list %}
        rw object {{pattern}},
        {% endfor %}
    {% endif %}
    };

    {% if manifest.attr.tfm_partition_ipc %}
#if defined (TFM_PSA_API)
define block {{manifest.manifest.name}}_LINKER_STACK with alignment = 128, size = {{manifest.manifest.stack_size}} { };
#endif
    {% else %}
#if defined (TFM_PSA_API)
define block {{manifest.manifest.name}}_LINKER_STACK with alignment = 128, size = 0 { };
#endif
    {% endif %}
    {% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
    {% endif %}

    {% endif %}
{% endfor %}

    /*
     * This empty, zero long execution region is here to mark the end address
     * of PSA RoT RW and Stack.
     */
define block TFM_PSA_RW_STACK_END with alignment = 32, size = 0x0 { };

    /* This empty, zero long execution region is here to mark the limit address
     * of the last execution region that is allocated in SRAM.
     */
define block SRAM_WATERMARK with size = 0 { };

define block LR_CODE with fixed order {
       block ER_TFM_CODE,
       block TFM_UNPRIV_CODE,
       block TFM_PSA_CODE_START,

{% for manifest in manifests %}
    {% if manifest.manifest.type == 'PSA-ROT' %}
    {% if manifest.attr.conditional %}
#ifdef {{manifest.attr.conditional}}
    {% endif %}
       block {{manifest.manifest.name}}_LINKER,
    {% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
    {% endif %}
    {% endif %}
{% endfor %}

       block TFM_PSA_CODE_END,

/**** APPLICATION RoT RO part (CODE + RODATA) start here */
    /*
     * This empty, zero long execution region is here to mark the start address
     * of APP RoT code.
     */
       block TFM_APP_CODE_START,
{% for manifest in manifests %}
    {% if manifest.manifest.type == 'APPLICATION-ROT' %}
    {% if manifest.attr.conditional %}
#ifdef {{manifest.attr.conditional}}
    {% endif %}
       block {{manifest.manifest.name}}_LINKER,
    {% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
    {% endif %}

    {% endif %}
{% endfor %}
    /*
     * This empty, zero long execution region is here to mark the end address
     * of APP RoT code.
     */
       block TFM_APP_CODE_END,
       };

do not initialize  { section .noinit };
initialize by copy with packing = none { readwrite };
if (isdefinedsymbol(__USE_DLIB_PERTHREAD))
{
  // Required in a multi-threaded application
  initialize by copy { section __DLIB_PERTHREAD };
}

place at address S_CODE_START         { block LR_CODE };

define block DATA with fixed order {
    /**** Base address of secure data area */
   block  TFM_SECURE_DATA_START,

    /*
     * MPU on Armv6-M/v7-M core in multi-core topology may require more strict
     * alignment that MPU region base address must align with the MPU region
     * size.
     * As a result, in multi-core topology, to save memory resource and MPU
     * regions, unprivileged data sections and privileged data sections are
     * separated and gathered in unprivileged/privileged data area respectively.
     * Keep BL2 shared data and MSP stack at the beginning of the secure data
     * area in single Armv8-M topology, while move the two areas to the
     * beginning of privileged data region in multi-core topology.
     */
#ifndef TFM_MULTI_CORE_TOPOLOGY
    /* Shared area between BL2 and runtime to exchange data */
    overlay STACK_DATA,
    /* PSP is unprivileged in single-core topology */
    block ARM_LIB_STACK,
#endif

#if !defined(TFM_PSA_API)
    block TFM_SECURE_STACK,
#endif /* !defined(TFM_PSA_API) */

    block TFM_UNPRIV_DATA,

    /**** APP RoT DATA start here */
    /*
     * This empty, zero long execution region is here to mark the start address
     * of APP RoT RW and Stack.
     */
    block TFM_APP_RW_STACK_START,

{% for manifest in manifests %}
    {% if manifest.manifest.type == 'APPLICATION-ROT' %}
    {% if manifest.attr.conditional %}
#ifdef {{manifest.attr.conditional}}
    {% endif %}
    block {{manifest.manifest.name}}_LINKER_DATA,

#if defined (TFM_PSA_API)
    block {{manifest.manifest.name}}_LINKER_STACK,
#endif
    {% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
    {% endif %}

    {% endif %}
{% endfor %}
    /*
     * This empty, zero long execution region is here to mark the end address
     * of APP RoT RW and Stack.
     */
    block TFM_APP_RW_STACK_END,

#ifdef TFM_MULTI_CORE_TOPOLOGY
#ifdef S_DATA_PRIV_START
    /**** Privileged data area base address specified by multi-core platform */
};
define block PRIV_DATA with fixed order {
    block TFM_SECURE_PRIV_DATA_BOUNDARY,
#endif

    /*
     * Move BL2 shared area and MSP stack to the beginning of privileged data
     * area in multi-core topology.
     */
    /* Shared area between BL2 and runtime to exchange data */
    overlay STACK_DATA,
    /* PSP is privileged in multi-core topology */
    block ARM_LIB_STACK,
#endif

    overlay HEAP_OVL,

    block ER_TFM_DATA,

    /**** PSA RoT DATA start here */
    /*
     * This empty, zero long execution region is here to mark the start address
     * of PSA RoT RW and Stack.
     */
    block TFM_PSA_RW_STACK_START,

{% for manifest in manifests %}
    {% if manifest.manifest.type == 'PSA-ROT' %}
    {% if manifest.attr.conditional %}
#ifdef {{manifest.attr.conditional}}
    {% endif %}
    block {{manifest.manifest.name}}_LINKER_DATA,

#if defined (TFM_PSA_API)
    block {{manifest.manifest.name}}_LINKER_STACK,
#endif
    {% if manifest.attr.conditional %}
#endif /* {{manifest.attr.conditional}} */
    {% endif %}

    {% endif %}
{% endfor %}
    /*
     * This empty, zero long execution region is here to mark the end address
     * of PSA RoT RW and Stack.
     */
    block TFM_PSA_RW_STACK_END,

#if 0
#if defined (S_RAM_CODE_START)
    /* Executable code allocated in RAM */
    TFM_RAM_CODE S_RAM_CODE_START {
        * (.ramfunc)
    }
#endif
#endif

    /* This empty, zero long execution region is here to mark the limit address
     * of the last execution region that is allocated in SRAM.
     */
    block SRAM_WATERMARK,

    /* Make sure that the sections allocated in the SRAM does not exceed the
     * size of the SRAM available.
     */
};

place at address S_DATA_START          { block DATA };
#if defined(TFM_MULTI_CORE_TOPOLOGY) && defined(S_DATA_PRIV_START)
place at address S_DATA_PRIV_START     { block PRIV_DATA };
#endif

#ifndef TFM_MULTI_CORE_TOPOLOGY
    /*
     * Place the CMSE Veneers (containing the SG instruction) in a separate
     * 32 bytes aligned region so that the SAU can be programmed to
     * just set this region as Non-Secure Callable.
     */
define block LR_VENEER with alignment = 0x20, size = CMSE_VENEER_REGION_SIZE {section Veneer$$CMSE};
place at address CMSE_VENEER_REGION_START {block LR_VENEER};
#endif

    /* Reserved place for NS application.
     * No code will be placed here, just address of this region is used in the
     * secure code to configure certain HW components. This generates an empty
     * execution region description warning during linking.
     */
define block LR_NS_PARTITION with size = NS_PARTITION_SIZE { };
place at address NS_PARTITION_START { block LR_NS_PARTITION };

#ifdef BL2
    /* Reserved place for new image in case of firmware upgrade.
     * No code will be placed here, just address of this region is used in the
     * secure code to configure certain HW components. This generates an empty
     * execution region description warning during linking.
     */
define block LR_SECONDARY_PARTITION with size = SECONDARY_PARTITION_SIZE { };
place at address SECONDARY_PARTITION_START { block LR_SECONDARY_PARTITION };
#endif /* BL2 */