Build: Update to IAR support
Cleaned up #ifdef in secure_fw/services/tfm_spm_db.inc.template
Moved "signals" member to front of spm_partition_runtime_data_t.
The suggestion to move the aggregate types to the front turned
out to be hard to make work for both PSA and non-PSA configs.
Moved REGION_DECLARE macros to new include file,
platform/include/region.h.
Cleaned up type cast in core_test_api.c
Change-Id: I5dce1e7c019d4d7e4c14dc79be5ee2b855ad4f9e
Signed-off-by: Thomas Tornblom <thomas.tornblom@iar.com>
diff --git a/secure_fw/core/ipc/include/tfm_pools.h b/secure_fw/core/ipc/include/tfm_pools.h
index 64be3c4..422484b 100644
--- a/secure_fw/core/ipc/include/tfm_pools.h
+++ b/secure_fw/core/ipc/include/tfm_pools.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -28,11 +28,20 @@
uint8_t data[0]; /* Data indicator */
};
+/*
+ * tfm_pool_chunk_t minus the zero length "data" member,
+ * required for standards compliant C
+ */
+struct tfm_pool_chunk_s_t {
+ struct tfm_list_node_t list; /* Chunk list */
+ void *pool; /* Point to the parent pool */
+};
+
struct tfm_pool_instance_t {
size_t chunksz; /* Chunks size of pool member */
size_t chunk_count; /* A number of chunks in the pool */
struct tfm_list_node_t chunks_list; /* Chunk list head in pool */
- struct tfm_pool_chunk_t chunks[0]; /* Data indicator */
+ struct tfm_pool_chunk_s_t chunks[0]; /* Data indicator */
};
/*
diff --git a/secure_fw/core/ipc/tfm_multi_core_mem_check.c b/secure_fw/core/ipc/tfm_multi_core_mem_check.c
index 0d20f07..b126c7d 100644
--- a/secure_fw/core/ipc/tfm_multi_core_mem_check.c
+++ b/secure_fw/core/ipc/tfm_multi_core_mem_check.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -15,6 +15,7 @@
#include "tfm_multi_core.h"
#include "tfm_secure_api.h"
#include "tfm_utils.h"
+#include "region.h"
#ifndef TFM_LVL
#error TFM_LVL is not defined!
diff --git a/secure_fw/core/ipc/tfm_psa_client_call.c b/secure_fw/core/ipc/tfm_psa_client_call.c
index 3d8f46f..e4c349f 100644
--- a/secure_fw/core/ipc/tfm_psa_client_call.c
+++ b/secure_fw/core/ipc/tfm_psa_client_call.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -204,8 +204,10 @@
*/
for (i = 0; i + 1 < in_num; i++) {
for (j = i+1; j < in_num; j++) {
- if (!(invecs[j].base + invecs[j].len <= invecs[i].base ||
- invecs[j].base >= invecs[i].base + invecs[i].len)) {
+ if (!((char *) invecs[j].base + invecs[j].len <=
+ (char *) invecs[i].base ||
+ (char *) invecs[j].base >=
+ (char *) invecs[i].base + invecs[i].len)) {
tfm_core_panic();
}
}
diff --git a/secure_fw/core/ipc/tfm_svcalls.c b/secure_fw/core/ipc/tfm_svcalls.c
index ec14f0b..72ba1a1 100644
--- a/secure_fw/core/ipc/tfm_svcalls.c
+++ b/secure_fw/core/ipc/tfm_svcalls.c
@@ -29,6 +29,7 @@
#include "tfm_rpc.h"
#include "tfm_internal.h"
#include "tfm_core_trustzone.h"
+#include "region.h"
#ifdef PLATFORM_SVC_HANDLERS
extern int32_t platform_svc_handlers(tfm_svc_number_t svc_num,
@@ -130,7 +131,7 @@
TFM_CORE_ASSERT(args != NULL);
handle = args[0];
- return tfm_psa_close(handle, ns_caller);
+ tfm_psa_close(handle, ns_caller);
}
uint32_t tfm_svcall_get_lifecycle_state(void)
@@ -415,7 +416,7 @@
tfm_core_util_memcpy(buffer, msg->invec[invec_idx].base, bytes);
/* There maybe some remaining data */
- msg->invec[invec_idx].base += bytes;
+ msg->invec[invec_idx].base = (char *) msg->invec[invec_idx].base + bytes;
msg->msg.in_size[invec_idx] -= bytes;
return bytes;
@@ -486,7 +487,8 @@
}
/* There maybe some remaining data */
- msg->invec[invec_idx].base += num_bytes;
+ msg->invec[invec_idx].base = (char *) msg->invec[invec_idx].base +
+ num_bytes;
msg->msg.in_size[invec_idx] -= num_bytes;
return num_bytes;
@@ -570,7 +572,7 @@
tfm_core_panic();
}
- tfm_core_util_memcpy(msg->outvec[outvec_idx].base +
+ tfm_core_util_memcpy((char *) msg->outvec[outvec_idx].base +
msg->outvec[outvec_idx].len, buffer, num_bytes);
/* Update the write number */
@@ -771,7 +773,7 @@
TFM_CORE_ASSERT(args != NULL);
partition_id = (int32_t)args[0];
- return notify_with_signal(partition_id, PSA_DOORBELL);
+ notify_with_signal(partition_id, PSA_DOORBELL);
}
/**
diff --git a/secure_fw/core/tfm_core.c b/secure_fw/core/tfm_core.c
index 3387464..e834b39 100644
--- a/secure_fw/core/tfm_core.c
+++ b/secure_fw/core/tfm_core.c
@@ -20,6 +20,7 @@
#include "tfm_version.h"
#include "spm_db.h"
#include "log/tfm_log.h"
+#include "region.h"
#ifdef TFM_PSA_API
#include "psa/client.h"
#include "psa/service.h"
diff --git a/secure_fw/core/tfm_func_api.c b/secure_fw/core/tfm_func_api.c
index ca603eb..92c8b95 100644
--- a/secure_fw/core/tfm_func_api.c
+++ b/secure_fw/core/tfm_func_api.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -22,6 +22,7 @@
#include "psa/service.h"
#include "tfm_core_mem_check.h"
#include "tfm_secure_api.h"
+#include "region.h"
#define EXC_RETURN_SECURE_FUNCTION 0xFFFFFFFD
#define EXC_RETURN_SECURE_HANDLER 0xFFFFFFF1
@@ -30,13 +31,8 @@
#error TFM_LVL is not defined!
#endif
-/* Macros to pick linker symbols and allow references to sections */
-#define REGION(a, b, c) a##b##c
-#define REGION_NAME(a, b, c) REGION(a, b, c)
-#define REGION_DECLARE(a, b, c) extern uint32_t REGION_NAME(a, b, c)
-
-REGION_DECLARE(Image$$, TFM_SECURE_STACK, $$ZI$$Base);
-REGION_DECLARE(Image$$, TFM_SECURE_STACK, $$ZI$$Limit);
+REGION_DECLARE_T(Image$$, TFM_SECURE_STACK, $$ZI$$Base, uint32_t);
+REGION_DECLARE_T(Image$$, TFM_SECURE_STACK, $$ZI$$Limit, struct iovec_args_t)[];
/* This is the "Big Lock" on the secure side, to guarantee single entry
* to SPE
diff --git a/secure_fw/core/tfm_secure_api.c b/secure_fw/core/tfm_secure_api.c
index c0bdc75..53b3499 100644
--- a/secure_fw/core/tfm_secure_api.c
+++ b/secure_fw/core/tfm_secure_api.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -44,7 +44,7 @@
/* Calculate the result */
range_in_region = ((uintptr_t)p >= region_start) &&
- ((uintptr_t)(p + s - 1) <= region_limit);
+ ((uintptr_t)((char *) p + s - 1) <= region_limit);
if (range_in_region) {
return TFM_SUCCESS;
} else {
diff --git a/secure_fw/spm/spm_api.c b/secure_fw/spm/spm_api.c
index 044e336..f71db78 100644
--- a/secure_fw/spm/spm_api.c
+++ b/secure_fw/spm/spm_api.c
@@ -20,6 +20,7 @@
#include "tfm_peripherals_def.h"
#include "spm_partition_defs.h"
#include "psa/lifecycle.h"
+#include "region.h"
#define NON_SECURE_INTERNAL_PARTITION_DB_IDX 0
#define TFM_CORE_INTERNAL_PARTITION_DB_IDX 1
diff --git a/secure_fw/spm/spm_api.h b/secure_fw/spm/spm_api.h
index 33118b1..b28cac7 100644
--- a/secure_fw/spm/spm_api.h
+++ b/secure_fw/spm/spm_api.h
@@ -88,8 +88,8 @@
*/
struct spm_partition_runtime_data_t {
#ifdef TFM_PSA_API
- struct tfm_event_t signal_evnt; /* Event signal */
uint32_t signals; /* Service signals had been triggered*/
+ struct tfm_event_t signal_evnt; /* Event signal */
struct tfm_list_node_t service_list;/* Service list */
struct tfm_core_thread_t sp_thrd; /* Thread object */
uint32_t assigned_signals; /* All assigned signals */
diff --git a/secure_fw/spm/spm_db.h b/secure_fw/spm/spm_db.h
index 6cd0e4e..2cbbe44 100644
--- a/secure_fw/spm/spm_db.h
+++ b/secure_fw/spm/spm_db.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -68,10 +68,6 @@
struct spm_partition_desc_t *partitions;
};
-/* Macros to pick linker symbols and allow to form the partition data base */
-#define REGION(a, b, c) a##b##c
-#define REGION_NAME(a, b, c) REGION(a, b, c)
-#define REGION_DECLARE(a, b, c) extern uint32_t REGION_NAME(a, b, c)
#ifdef TFM_PSA_API
#define PART_REGION_ADDR(partition, region) \
(uint32_t)®ION_NAME(Image$$, partition, region)
diff --git a/secure_fw/spm/tfm_spm_db.inc b/secure_fw/spm/tfm_spm_db.inc
index 3da5c47..d22d46b 100644
--- a/secure_fw/spm/tfm_spm_db.inc
+++ b/secure_fw/spm/tfm_spm_db.inc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -1261,10 +1261,10 @@
/**************************************************************************/
static struct spm_partition_desc_t partition_list [] =
{
- {{}}, /* placeholder for Non-secure internal partition */
+ {{0}}, /* placeholder for Non-secure internal partition */
#ifndef TFM_PSA_API
- {{}}, /* placeholder for TF-M Core internal partition */
-#endif /* !ifndefined(TFM_PSA_API) */
+ {{0}}, /* placeholder for TF-M Core internal partition */
+#endif
/* -----------------------------------------------------------------------*/
/* - Partition DB record for TFM_SP_STORAGE */
@@ -1272,7 +1272,7 @@
#ifdef TFM_PARTITION_SECURE_STORAGE
{
/* Runtime data */
- .runtime_data = {},
+ .runtime_data = {0},
.static_data = NULL,
.platform_data_list = NULL,
},
@@ -1284,7 +1284,7 @@
#ifdef TFM_PARTITION_INTERNAL_TRUSTED_STORAGE
{
/* Runtime data */
- .runtime_data = {},
+ .runtime_data = {0},
.static_data = NULL,
.platform_data_list = NULL,
},
@@ -1296,7 +1296,7 @@
#ifdef TFM_PARTITION_AUDIT_LOG
{
/* Runtime data */
- .runtime_data = {},
+ .runtime_data = {0},
.static_data = NULL,
.platform_data_list = NULL,
},
@@ -1308,7 +1308,7 @@
#ifdef TFM_PARTITION_CRYPTO
{
/* Runtime data */
- .runtime_data = {},
+ .runtime_data = {0},
.static_data = NULL,
.platform_data_list = NULL,
},
@@ -1320,7 +1320,7 @@
#ifdef TFM_PARTITION_PLATFORM
{
/* Runtime data */
- .runtime_data = {},
+ .runtime_data = {0},
.static_data = NULL,
.platform_data_list = NULL,
},
@@ -1332,7 +1332,7 @@
#ifdef TFM_PARTITION_INITIAL_ATTESTATION
{
/* Runtime data */
- .runtime_data = {},
+ .runtime_data = {0},
.static_data = NULL,
.platform_data_list = NULL,
},
@@ -1344,7 +1344,7 @@
#ifdef TFM_PARTITION_TEST_CORE
{
/* Runtime data */
- .runtime_data = {},
+ .runtime_data = {0},
.static_data = NULL,
.platform_data_list = NULL,
},
@@ -1356,7 +1356,7 @@
#ifdef TFM_PARTITION_TEST_CORE
{
/* Runtime data */
- .runtime_data = {},
+ .runtime_data = {0},
.static_data = NULL,
.platform_data_list = NULL,
},
@@ -1368,7 +1368,7 @@
#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
{
/* Runtime data */
- .runtime_data = {},
+ .runtime_data = {0},
.static_data = NULL,
.platform_data_list = NULL,
},
@@ -1380,7 +1380,7 @@
#ifdef TFM_PARTITION_TEST_CORE_IPC
{
/* Runtime data */
- .runtime_data = {},
+ .runtime_data = {0},
.static_data = NULL,
.platform_data_list = NULL,
},
@@ -1392,7 +1392,7 @@
#ifdef TFM_PARTITION_TEST_CORE_IPC
{
/* Runtime data */
- .runtime_data = {},
+ .runtime_data = {0},
.static_data = NULL,
.platform_data_list = NULL,
},
@@ -1404,7 +1404,7 @@
#ifdef TFM_ENABLE_IRQ_TEST
{
/* Runtime data */
- .runtime_data = {},
+ .runtime_data = {0},
.static_data = NULL,
.platform_data_list = NULL,
},
@@ -1416,7 +1416,7 @@
#ifdef TFM_PARTITION_TEST_SST
{
/* Runtime data */
- .runtime_data = {},
+ .runtime_data = {0},
.static_data = NULL,
.platform_data_list = NULL,
},
@@ -1428,7 +1428,7 @@
#ifdef TFM_PARTITION_TEST_SECURE_SERVICES
{
/* Runtime data */
- .runtime_data = {},
+ .runtime_data = {0},
.static_data = NULL,
.platform_data_list = NULL,
},
@@ -1440,7 +1440,7 @@
#ifdef TFM_MULTI_CORE_TEST
{
/* Runtime data */
- .runtime_data = {},
+ .runtime_data = {0},
.static_data = NULL,
.platform_data_list = NULL,
},
diff --git a/secure_fw/spm/tfm_spm_db.inc.template b/secure_fw/spm/tfm_spm_db.inc.template
index 83de242..5a0f453 100644
--- a/secure_fw/spm/tfm_spm_db.inc.template
+++ b/secure_fw/spm/tfm_spm_db.inc.template
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -321,10 +321,10 @@
/**************************************************************************/
static struct spm_partition_desc_t partition_list [] =
{
- {{'{{}}'}}, /* placeholder for Non-secure internal partition */
+ {{'{{0}}'}}, /* placeholder for Non-secure internal partition */
#ifndef TFM_PSA_API
- {{'{{}}'}}, /* placeholder for TF-M Core internal partition */
-#endif /* !ifndefined(TFM_PSA_API) */
+ {{'{{0}}'}}, /* placeholder for TF-M Core internal partition */
+#endif
{% for manifest in manifests %}
/* -----------------------------------------------------------------------*/
@@ -335,7 +335,7 @@
{% endif %}
{{'{'}}
/* Runtime data */
- .runtime_data = {},
+ .runtime_data = {0},
.static_data = NULL,
.platform_data_list = NULL,
{{'},'}}