SPM: Shorten 'TFM_GET_CONTAINER_PTR'
Use 'TO_CONTAINER' instead, which is shorter and straight.
Change-Id: I7f669aeed386b34b12ffeb2b9554310dcaa24d55
Signed-off-by: Ken Liu <Ken.Liu@arm.com>
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.c b/secure_fw/spm/cmsis_psa/spm_ipc.c
index 432a5c9..b3fd61c 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.c
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.c
@@ -250,7 +250,7 @@
* partition mask until no remaining message. Search may be optimized.
*/
BI_LIST_FOR_EACH(node, head) {
- tmp_msg = TFM_GET_CONTAINER_PTR(node, struct tfm_msg_body_t, msg_node);
+ tmp_msg = TO_CONTAINER(node, struct tfm_msg_body_t, msg_node);
if (tmp_msg->service->service_db->signal == signal && msg) {
return msg;
} else if (tmp_msg->service->service_db->signal == signal) {
@@ -385,7 +385,7 @@
struct tfm_core_thread_t *pth = tfm_core_thrd_get_curr();
struct partition_t *partition;
- partition = TFM_GET_CONTAINER_PTR(pth, struct partition_t, sp_thread);
+ partition = TO_CONTAINER(pth, struct partition_t, sp_thread);
return partition;
}
@@ -882,9 +882,9 @@
if (pth_next != NULL && pth_curr != pth_next) {
#if TFM_LVL != 1
- p_next_partition = TFM_GET_CONTAINER_PTR(pth_next,
- struct partition_t,
- sp_thread);
+ p_next_partition = TO_CONTAINER(pth_next,
+ struct partition_t,
+ sp_thread);
p_part_static = p_next_partition->p_static;
if (p_part_static->flags & SPM_PART_FLAG_PSA_ROT) {
is_privileged = TFM_PARTITION_PRIVILEGED_MODE;
diff --git a/secure_fw/spm/cmsis_psa/tfm_pools.c b/secure_fw/spm/cmsis_psa/tfm_pools.c
index f298340..5bd07f1 100644
--- a/secure_fw/spm/cmsis_psa/tfm_pools.c
+++ b/secure_fw/spm/cmsis_psa/tfm_pools.c
@@ -68,7 +68,7 @@
}
node = BI_LIST_NEXT_NODE(&pool->chunks_list);
- pchunk = TFM_GET_CONTAINER_PTR(node, struct tfm_pool_chunk_t, list);
+ pchunk = TO_CONTAINER(node, struct tfm_pool_chunk_t, list);
/* Remove node from list node, it will be added when pool free */
BI_LIST_REMOVE_NODE(node);
@@ -80,7 +80,7 @@
{
struct tfm_pool_chunk_t *pchunk;
- pchunk = TFM_GET_CONTAINER_PTR(ptr, struct tfm_pool_chunk_t, data);
+ pchunk = TO_CONTAINER(ptr, struct tfm_pool_chunk_t, data);
BI_LIST_INSERT_BEFORE(&pool->chunks_list, &pchunk->list);
}
@@ -99,7 +99,7 @@
}
pool_chunk_address =
- (uint32_t)TFM_GET_CONTAINER_PTR(data, struct tfm_pool_chunk_t, data);
+ (uint32_t)TO_CONTAINER(data, struct tfm_pool_chunk_t, data);
/* Make sure that the chunk containing the message is aligned on */
/* chunk boundary in the pool. */
diff --git a/secure_fw/spm/ffm/psa_client_service_apis.c b/secure_fw/spm/ffm/psa_client_service_apis.c
index 33b200d..2f57c0c 100644
--- a/secure_fw/spm/ffm/psa_client_service_apis.c
+++ b/secure_fw/spm/ffm/psa_client_service_apis.c
@@ -210,9 +210,9 @@
return PSA_ERROR_DOES_NOT_EXIST;
}
- (TFM_GET_CONTAINER_PTR(tmp_msg,
- struct tfm_conn_handle_t,
- internal_msg))->status = TFM_HANDLE_STATUS_ACTIVE;
+ (TO_CONTAINER(tmp_msg,
+ struct tfm_conn_handle_t,
+ internal_msg))->status = TFM_HANDLE_STATUS_ACTIVE;
spm_memcpy(msg, &tmp_msg->msg, sizeof(psa_msg_t));
diff --git a/secure_fw/spm/include/utilities.h b/secure_fw/spm/include/utilities.h
index 76c9128..847e406 100644
--- a/secure_fw/spm/include/utilities.h
+++ b/secure_fw/spm/include/utilities.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -30,7 +30,7 @@
#endif
/* Get container structure start address from member */
-#define TFM_GET_CONTAINER_PTR(ptr, type, member) \
+#define TO_CONTAINER(ptr, type, member) \
(type *)((unsigned long)(ptr) - offsetof(type, member))
#define ERROR_MSG(msg)