@@ -38,7 +38,11 @@ struct spm_partition_db_t {
38
38
data.partition_priority = TFM_PRIORITY(priority); \
39
39
} while (0)
40
40
41
- #if (TFM_LVL == 1 ) && !defined(TFM_PSA_API )
41
+ /* Changed from #if (TFM_LVL == 1) && !defined(TFM_PSA_API) to #if (TFM_LVL == 1) to avoid linker error.
42
+ TF-M build autogenerates region details (code, ro, rw, zi and stack ) using linker scripts. We do not
43
+ hve that in mbed-os build yet.
44
+ */
45
+ #if (TFM_LVL == 1 )
42
46
#define PARTITION_INIT_MEMORY_DATA (data , partition )
43
47
#else
44
48
#define PARTITION_INIT_MEMORY_DATA (data , partition ) \
@@ -75,56 +79,60 @@ struct spm_partition_db_t {
75
79
} while (0 )
76
80
#endif
77
81
78
- #define PARTITION_DECLARE (partition , flag , type , id , priority ) \
79
- do { \
80
- REGION_DECLARE(Image$$, partition, $$Base); \
81
- REGION_DECLARE(Image$$, partition, $$Limit); \
82
- REGION_DECLARE(Image$$, partition, $$RO$$Base); \
83
- REGION_DECLARE(Image$$, partition, $$RO$$Limit); \
84
- REGION_DECLARE(Image$$, partition, _DATA$$RW$$Base); \
85
- REGION_DECLARE(Image$$, partition, _DATA$$RW$$Limit); \
86
- REGION_DECLARE(Image$$, partition, _DATA$$ZI$$Base); \
87
- REGION_DECLARE(Image$$, partition, _DATA$$ZI$$Limit); \
88
- REGION_DECLARE(Image$$, partition, _STACK$$ZI$$Base); \
89
- REGION_DECLARE(Image$$, partition, _STACK$$ZI$$Limit); \
90
- int32_t flags = flag; \
91
- if (tfm_memcmp(type, TFM_PARTITION_TYPE_APP, \
92
- strlen(TFM_PARTITION_TYPE_APP)) == 0) { \
93
- flags |= SPM_PART_FLAG_APP_ROT; \
94
- } else if (tfm_memcmp(type, TFM_PARTITION_TYPE_PSA, \
95
- strlen(TFM_PARTITION_TYPE_PSA)) == 0) { \
96
- flags |= SPM_PART_FLAG_PSA_ROT | SPM_PART_FLAG_APP_ROT; \
97
- } else { \
98
- return SPM_ERR_INVALID_CONFIG; \
99
- } \
100
- struct spm_partition_desc_t *part_ptr; \
101
- if (g_spm_partition_db.partition_count >= SPM_MAX_PARTITIONS) { \
102
- return SPM_ERR_INVALID_CONFIG; \
103
- } \
104
- part_ptr = &(g_spm_partition_db.partitions[ \
105
- g_spm_partition_db.partition_count]); \
106
- PARTITION_INIT_STATIC_DATA(part_ptr->static_data, partition, flags, \
107
- id, priority); \
108
- PARTITION_INIT_RUNTIME_DATA(part_ptr->runtime_data, partition); \
109
- PARTITION_INIT_MEMORY_DATA(part_ptr->memory_data, partition); \
110
- ++g_spm_partition_db.partition_count; \
82
+ #define PARTITION_DECLARE (partition , flag , type , id , priority , part_stack_size ) \
83
+ do { \
84
+ REGION_DECLARE(Image$$, partition, $$Base); \
85
+ REGION_DECLARE(Image$$, partition, $$Limit); \
86
+ REGION_DECLARE(Image$$, partition, $$RO$$Base); \
87
+ REGION_DECLARE(Image$$, partition, $$RO$$Limit); \
88
+ REGION_DECLARE(Image$$, partition, _DATA$$RW$$Base); \
89
+ REGION_DECLARE(Image$$, partition, _DATA$$RW$$Limit); \
90
+ REGION_DECLARE(Image$$, partition, _DATA$$ZI$$Base); \
91
+ REGION_DECLARE(Image$$, partition, _DATA$$ZI$$Limit); \
92
+ REGION_DECLARE(Image$$, partition, _STACK$$ZI$$Base); \
93
+ REGION_DECLARE(Image$$, partition, _STACK$$ZI$$Limit); \
94
+ int32_t flags = flag; \
95
+ if (tfm_memcmp(type, TFM_PARTITION_TYPE_APP, \
96
+ strlen(TFM_PARTITION_TYPE_APP)) == 0) { \
97
+ flags |= SPM_PART_FLAG_APP_ROT; \
98
+ } else if (tfm_memcmp(type, TFM_PARTITION_TYPE_PSA, \
99
+ strlen(TFM_PARTITION_TYPE_PSA)) == 0) { \
100
+ flags |= SPM_PART_FLAG_PSA_ROT | SPM_PART_FLAG_APP_ROT; \
101
+ } else { \
102
+ return SPM_ERR_INVALID_CONFIG; \
103
+ } \
104
+ struct spm_partition_desc_t *part_ptr; \
105
+ if (g_spm_partition_db.partition_count >= SPM_MAX_PARTITIONS) { \
106
+ return SPM_ERR_INVALID_CONFIG; \
107
+ } \
108
+ __attribute__((section(".data.partitions_stacks"))) \
109
+ static uint8_t partition##_stack[part_stack_size] __attribute__((aligned(8))); \
110
+ part_ptr = &(g_spm_partition_db.partitions[ \
111
+ g_spm_partition_db.partition_count]); \
112
+ part_ptr->memory_data.stack_bottom = (uint32_t)partition##_stack; \
113
+ part_ptr->memory_data.stack_top = part_ptr->memory_data.stack_bottom + part_stack_size; \
114
+ PARTITION_INIT_STATIC_DATA(part_ptr->static_data, partition, flags, \
115
+ id, priority); \
116
+ PARTITION_INIT_RUNTIME_DATA(part_ptr->runtime_data, partition); \
117
+ PARTITION_INIT_MEMORY_DATA(part_ptr->memory_data, partition); \
118
+ ++g_spm_partition_db.partition_count; \
111
119
} while (0)
112
120
113
- #define PARTITION_ADD_INIT_FUNC (partition , init_func ) \
114
- do { \
115
- extern int32_t init_func(void); \
116
- uint32_t partition_idx = get_partition_idx(partition##_ID); \
117
- struct spm_partition_desc_t *part_ptr = \
118
- &(g_spm_partition_db.partitions[partition_idx]); \
119
- part_ptr->static_data.partition_init = init_func; \
121
+ #define PARTITION_ADD_INIT_FUNC (partition , init_func ) \
122
+ do { \
123
+ extern int32_t init_func(void); \
124
+ uint32_t partition_idx = get_partition_idx(partition##_ID); \
125
+ struct spm_partition_desc_t *part_ptr = \
126
+ &(g_spm_partition_db.partitions[partition_idx]); \
127
+ part_ptr->static_data.partition_init = init_func; \
120
128
} while (0)
121
129
122
- #define PARTITION_ADD_PERIPHERAL (partition , peripheral ) \
123
- do { \
124
- uint32_t partition_idx = get_partition_idx(partition##_ID); \
125
- struct spm_partition_desc_t *part_ptr = \
126
- &(g_spm_partition_db.partitions[partition_idx]); \
127
- part_ptr->platform_data = peripheral; \
130
+ #define PARTITION_ADD_PERIPHERAL (partition , peripheral ) \
131
+ do { \
132
+ uint32_t partition_idx = get_partition_idx(partition##_ID); \
133
+ struct spm_partition_desc_t *part_ptr = \
134
+ &(g_spm_partition_db.partitions[partition_idx]); \
135
+ part_ptr->platform_data = peripheral; \
128
136
} while (0)
129
137
130
138
#endif /* __SPM_DB_SETUP_H__ */
0 commit comments