SPM: Change data type of irq line to uint32_t
This patch changes the data type of irq line from IRQn_Type to
uint32_t to remove the platform dependency.
Also updated the get_irq_line_for_signal function to align between
the two models.
Change-Id: Ifc381b913d60797b06facd8ccb5d26ba01327372
Signed-off-by: Kevin Peng <kevin.peng@arm.com>
diff --git a/secure_fw/spm/cmsis_func/spm_func.c b/secure_fw/spm/cmsis_func/spm_func.c
index 5af3429..35702b2 100644
--- a/secure_fw/spm/cmsis_func/spm_func.c
+++ b/secure_fw/spm/cmsis_func/spm_func.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -574,7 +574,7 @@
uint32_t handler_partition_id = svc_ctx->r0;
sfn_t unpriv_handler = (sfn_t)svc_ctx->r1;
uint32_t irq_signal = svc_ctx->r2;
- IRQn_Type irq_line = (IRQn_Type) svc_ctx->r3;
+ uint32_t irq_line = svc_ctx->r3;
enum tfm_status_e res;
uint32_t psp = __get_PSP();
uint32_t handler_partition_psp;
@@ -1082,7 +1082,7 @@
* \retval >=0 The IRQ line number associated with a signal in the partition
* \retval <0 error
*/
-static IRQn_Type get_irq_line_for_signal(int32_t partition_id,
+static int32_t get_irq_line_for_signal(int32_t partition_id,
psa_signal_t signal)
{
size_t i;
@@ -1093,7 +1093,7 @@
return tfm_core_irq_signals[i].irq_line;
}
}
- return (IRQn_Type) -1;
+ return -1;
}
void tfm_spm_enable_irq_handler(uint32_t *svc_args)
@@ -1105,7 +1105,7 @@
tfm_spm_partition_get_running_partition_idx();
uint32_t running_partition_id =
tfm_spm_partition_get_partition_id(running_partition_idx);
- IRQn_Type irq_line;
+ int32_t irq_line;
/* Only a single signal is allowed */
if (!tfm_is_one_bit_set(irq_signal)) {
@@ -1132,7 +1132,7 @@
tfm_spm_partition_get_running_partition_idx();
uint32_t running_partition_id =
tfm_spm_partition_get_partition_id(running_partition_idx);
- IRQn_Type irq_line;
+ int32_t irq_line;
/* Only a single signal is allowed */
if (!tfm_is_one_bit_set(irq_signal)) {
@@ -1190,7 +1190,7 @@
uint32_t running_partition_idx;
uint32_t running_partition_id;
const struct spm_partition_runtime_data_t *curr_part_data;
- IRQn_Type irq_line;
+ int32_t irq_line;
running_partition_idx = tfm_spm_partition_get_running_partition_idx();
running_partition_id =
diff --git a/secure_fw/spm/cmsis_func/tfm_secure_irq_handlers.inc.template b/secure_fw/spm/cmsis_func/tfm_secure_irq_handlers.inc.template
index b41e7a5..e031669 100644
--- a/secure_fw/spm/cmsis_func/tfm_secure_irq_handlers.inc.template
+++ b/secure_fw/spm/cmsis_func/tfm_secure_irq_handlers.inc.template
@@ -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
*
@@ -43,7 +43,7 @@
{% endif %}
{% endif %}
{% endfor %}
- {0, 0, (IRQn_Type) 0, 0} /* add dummy element to avoid non-standard empty array */
+ {0, 0, 0, 0} /* add dummy element to avoid non-standard empty array */
};
const size_t tfm_core_irq_signals_count = (sizeof(tfm_core_irq_signals) /
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.c b/secure_fw/spm/cmsis_psa/spm_ipc.c
index cfc0489..188c75f 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.c
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.c
@@ -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
*
@@ -45,7 +45,7 @@
TFM_CONN_HANDLE_MAX_NUM);
void tfm_irq_handler(uint32_t partition_id, psa_signal_t signal,
- IRQn_Type irq_line);
+ uint32_t irq_line);
#include "tfm_secure_irq_handlers_ipc.inc"
@@ -868,34 +868,31 @@
* \retval "Does not return" Partition ID is invalid
*/
void tfm_irq_handler(uint32_t partition_id, psa_signal_t signal,
- IRQn_Type irq_line)
+ uint32_t irq_line)
{
tfm_spm_hal_disable_irq(irq_line);
notify_with_signal(partition_id, signal);
}
-int32_t get_irq_line_for_signal(int32_t partition_id,
- psa_signal_t signal,
- IRQn_Type *irq_line)
+int32_t get_irq_line_for_signal(int32_t partition_id, psa_signal_t signal)
{
size_t i;
for (i = 0; i < tfm_core_irq_signals_count; ++i) {
if (tfm_core_irq_signals[i].partition_id == partition_id &&
tfm_core_irq_signals[i].signal_value == signal) {
- *irq_line = tfm_core_irq_signals[i].irq_line;
- return IPC_SUCCESS;
+ return tfm_core_irq_signals[i].irq_line;
}
}
- return IPC_ERROR_GENERIC;
+
+ return -1;
}
void tfm_spm_enable_irq(uint32_t *args)
{
struct tfm_state_context_t *svc_ctx = (struct tfm_state_context_t *)args;
psa_signal_t irq_signal = svc_ctx->r0;
- IRQn_Type irq_line = (IRQn_Type) 0;
- int32_t ret;
+ int32_t irq_line = 0;
struct partition_t *partition = NULL;
/* It is a fatal error if passed signal indicates more than one signals. */
@@ -908,10 +905,9 @@
tfm_core_panic();
}
- ret = get_irq_line_for_signal(partition->p_static->pid,
- irq_signal, &irq_line);
+ irq_line = get_irq_line_for_signal(partition->p_static->pid, irq_signal);
/* It is a fatal error if passed signal is not an interrupt signal. */
- if (ret != IPC_SUCCESS) {
+ if (irq_line < 0) {
tfm_core_panic();
}
@@ -922,8 +918,7 @@
{
struct tfm_state_context_t *svc_ctx = (struct tfm_state_context_t *)args;
psa_signal_t irq_signal = svc_ctx->r0;
- IRQn_Type irq_line = (IRQn_Type) 0;
- int32_t ret;
+ int32_t irq_line = 0;
struct partition_t *partition = NULL;
/* It is a fatal error if passed signal indicates more than one signals. */
@@ -936,10 +931,9 @@
tfm_core_panic();
}
- ret = get_irq_line_for_signal(partition->p_static->pid,
- irq_signal, &irq_line);
+ irq_line = get_irq_line_for_signal(partition->p_static->pid, irq_signal);
/* It is a fatal error if passed signal is not an interrupt signal. */
- if (ret != IPC_SUCCESS) {
+ if (irq_line < 0) {
tfm_core_panic();
}
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.h b/secure_fw/spm/cmsis_psa/spm_ipc.h
index 1af5945..3328a30 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.h
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -507,15 +507,11 @@
* \param[in] partition_id The ID of the partition in which we look for
* the signal.
* \param[in] signal The signal we do the query for.
- * \param[out] irq_line The irq line associated with signal
*
- * \retval IPC_SUCCESS Execution successful, irq_line contains a valid
- * value.
- * \retval IPC_ERROR_GENERIC There was an error finding the IRQ line for the
+ * \retval None-negative value The irq line associated with signal
+ * \retval Negative value There was an error finding the IRQ line for the
* signal. irq_line is unchanged.
*/
-int32_t get_irq_line_for_signal(int32_t partition_id,
- psa_signal_t signal,
- IRQn_Type *irq_line);
+int32_t get_irq_line_for_signal(int32_t partition_id, psa_signal_t signal);
#endif /* __SPM_IPC_H__ */
diff --git a/secure_fw/spm/cmsis_psa/tfm_secure_irq_handlers_ipc.inc.template b/secure_fw/spm/cmsis_psa/tfm_secure_irq_handlers_ipc.inc.template
index b38c9c1..64e2eba 100644
--- a/secure_fw/spm/cmsis_psa/tfm_secure_irq_handlers_ipc.inc.template
+++ b/secure_fw/spm/cmsis_psa/tfm_secure_irq_handlers_ipc.inc.template
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -45,7 +45,7 @@
{% endif %}
{% endif %}
{% endfor %}
- {0, 0, (IRQn_Type) 0, 0} /* add dummy element to avoid non-standard empty array */
+ {0, 0, 0, 0} /* add dummy element to avoid non-standard empty array */
};
const size_t tfm_core_irq_signals_count = (sizeof(tfm_core_irq_signals) /
diff --git a/secure_fw/spm/common/psa_client_service_apis.c b/secure_fw/spm/common/psa_client_service_apis.c
index 671a44c..285c85a 100644
--- a/secure_fw/spm/common/psa_client_service_apis.c
+++ b/secure_fw/spm/common/psa_client_service_apis.c
@@ -584,8 +584,7 @@
void tfm_spm_psa_eoi(uint32_t *args)
{
psa_signal_t irq_signal;
- IRQn_Type irq_line = (IRQn_Type) 0;
- int32_t ret;
+ int32_t irq_line = 0;
struct partition_t *partition = NULL;
TFM_CORE_ASSERT(args != NULL);
@@ -601,10 +600,9 @@
tfm_core_panic();
}
- ret = get_irq_line_for_signal(partition->p_static->pid,
- irq_signal, &irq_line);
+ irq_line = get_irq_line_for_signal(partition->p_static->pid, irq_signal);
/* It is a fatal error if passed signal is not an interrupt signal. */
- if (ret != IPC_SUCCESS) {
+ if (irq_line < 0) {
tfm_core_panic();
}
diff --git a/secure_fw/spm/include/tfm_irq_list.h b/secure_fw/spm/include/tfm_irq_list.h
index c8b842f..bb34616 100644
--- a/secure_fw/spm/include/tfm_irq_list.h
+++ b/secure_fw/spm/include/tfm_irq_list.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -16,7 +16,7 @@
struct tfm_core_irq_signal_data_t {
int32_t partition_id;
psa_signal_t signal_value;
- IRQn_Type irq_line;
+ uint32_t irq_line;
uint32_t irq_priority;
};