SPM: Sort out tfm_secure_api.c file
- Rename 'tfm_utils.h' to 'utilities.h'.
- Rename 'tfm_spm_services_api.h'to 'tfm_spm_services.h'.
- Move 'tfm_secure_api.c' from spm/runtime to spm/model_func and
sort out the content
Change-Id: Ie8831e2b1430eab6a2edc9b6c0487ef14f2fafc6
Signed-off-by: Summer Qin <summer.qin@arm.com>
diff --git a/secure_fw/include/tfm/tfm_spm_services.h b/secure_fw/include/tfm/tfm_spm_services.h
new file mode 100644
index 0000000..43e7e81
--- /dev/null
+++ b/secure_fw/include/tfm/tfm_spm_services.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __TFM_SPM_SERVICES_H__
+#define __TFM_SPM_SERVICES_H__
+
+#include "psa/service.h"
+#include "tfm_boot_status.h"
+
+enum tfm_spm_request_type_t {
+ TFM_SPM_REQUEST_RESET_VOTE,
+};
+
+/**
+ * \brief Request a vote from SPM on a system reset
+ *
+ * \return Returns 0 if request is accepted, any other value means reject
+ */
+int32_t tfm_spm_request_reset_vote(void);
+int32_t tfm_core_get_boot_data(uint8_t major_type,
+ struct tfm_boot_data *boot_data,
+ uint32_t len);
+
+void tfm_enable_irq(psa_signal_t irq_signal);
+void tfm_disable_irq(psa_signal_t irq_signal);
+
+#endif /* __TFM_SPM_SERVICES_H__ */
diff --git a/secure_fw/include/tfm/tfm_spm_services_api.h b/secure_fw/include/tfm/tfm_spm_services_api.h
deleted file mode 100644
index be08ed2..0000000
--- a/secure_fw/include/tfm/tfm_spm_services_api.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#ifndef __TFM_SPM_SERVICES_API_H__
-#define __TFM_SPM_SERVICES_API_H__
-
-enum tfm_spm_request_type_t {
- TFM_SPM_REQUEST_RESET_VOTE,
-};
-
-/**
- * \brief Request a vote from SPM on a system reset
- *
- * \return Returns 0 if request is accepted, any other value means reject
- */
-int32_t tfm_spm_request_reset_vote(void);
-
-#endif /* __TFM_SPM_SERVICES_API_H__ */
diff --git a/secure_fw/partitions/initial_attestation/tfm_attestation.c b/secure_fw/partitions/initial_attestation/tfm_attestation.c
index 0ac143a..a49714b 100644
--- a/secure_fw/partitions/initial_attestation/tfm_attestation.c
+++ b/secure_fw/partitions/initial_attestation/tfm_attestation.c
@@ -7,6 +7,7 @@
#include "tfm_api.h"
#include "tfm_secure_api.h"
+#include "tfm/tfm_spm_services.h"
#include "attestation.h"
#include "psa/initial_attestation.h"
#include "tfm_boot_status.h"
diff --git a/secure_fw/partitions/platform/platform_sp.c b/secure_fw/partitions/platform/platform_sp.c
index 331bdb7..616032d 100644
--- a/secure_fw/partitions/platform/platform_sp.c
+++ b/secure_fw/partitions/platform/platform_sp.c
@@ -9,7 +9,7 @@
#include "tfm_platform_system.h"
#include "tfm_plat_nv_counters.h"
-#include "tfm/tfm_spm_services_api.h"
+#include "tfm/tfm_spm_services.h"
#include "tfm_secure_api.h"
#include "psa_manifest/pid.h"
diff --git a/secure_fw/spm/include/spm_api.h b/secure_fw/spm/include/spm_api.h
index 1825a33..968f628 100644
--- a/secure_fw/spm/include/spm_api.h
+++ b/secure_fw/spm/include/spm_api.h
@@ -165,6 +165,11 @@
struct tfm_msg_queue_t msg_queue; /* Message queue */
struct tfm_list_node_t list; /* For list operation */
};
+
+enum tfm_memory_access_e {
+ TFM_MEMORY_ACCESS_RO = 1,
+ TFM_MEMORY_ACCESS_RW = 2,
+};
#endif /* ifdef(TFM_PSA_API) */
/*********************** common definitions ***********************/
diff --git a/secure_fw/spm/include/tfm_secure_api.h b/secure_fw/spm/include/tfm_secure_api.h
index 6b177d4..8ed7a79 100644
--- a/secure_fw/spm/include/tfm_secure_api.h
+++ b/secure_fw/spm/include/tfm_secure_api.h
@@ -14,11 +14,12 @@
#include "tfm_arch.h"
#include "tfm/tfm_core_svc.h"
#include "tfm_api.h"
-#include "tfm_utils.h"
+#include "utilities.h"
#include "tfm_boot_status.h"
#include "psa/service.h"
#ifndef TFM_MULTI_CORE_TOPOLOGY
+#ifndef TFM_PSA_API
/*!
* \def __tfm_secure_gateway_attributes__
*
@@ -35,7 +36,9 @@
#define __tfm_secure_gateway_attributes__ \
__attribute__((cmse_nonsecure_entry, section("SFN")))
#endif /* __GNUC__ && !__ARMCC_VERSION */
+#endif /* !TFM_PSA_API */
+#ifdef TFM_PSA_API
/*!
* \def __tfm_psa_secure_gateway_attributes__
*
@@ -52,6 +55,7 @@
#define __tfm_psa_secure_gateway_attributes__ \
__attribute__((cmse_nonsecure_entry, naked, section("SFN")))
#endif /* __GNUC__ && !__ARMCC_VERSION */
+#endif /* TFM_PSA_API */
#endif /* TFM_MULTI_CORE_TOPOLOGY */
/* Hide specific errors if not debugging */
@@ -65,6 +69,7 @@
#error TFM_LVL is not defined!
#endif
+#ifndef TFM_PSA_API
extern void tfm_secure_api_error_handler(void);
typedef int32_t(*sfn_t)(int32_t, int32_t, int32_t, int32_t);
@@ -77,53 +82,12 @@
bool ns_caller;
};
-enum tfm_memory_access_e {
- TFM_MEMORY_ACCESS_RO = 1,
- TFM_MEMORY_ACCESS_RW = 2,
-};
-
extern int32_t tfm_core_get_caller_client_id(int32_t *caller_client_id);
-extern int32_t tfm_core_get_boot_data(uint8_t major_type,
- struct tfm_boot_data *boot_data,
- uint32_t len);
-
int32_t tfm_core_sfn_request(const struct tfm_sfn_req_s *desc_ptr);
int32_t tfm_spm_sfn_request_thread_mode(struct tfm_sfn_req_s *desc_ptr);
-/**
- * \brief Check whether a memory range is inside a memory region.
- *
- * \param[in] p The start address of the range to check
- * \param[in] s The size of the range to check
- * \param[in] region_start The start address of the region, which should
- * contain the range
- * \param[in] region_limit The end address of the region, which should contain
- * the range
- *
- * \return TFM_SUCCESS if the region contains the range,
- * TFM_ERROR_GENERIC otherwise.
- */
-enum tfm_status_e check_address_range(const void *p, size_t s,
- uintptr_t region_start,
- uintptr_t region_limit);
-
-void tfm_enable_irq(psa_signal_t irq_signal);
-void tfm_disable_irq(psa_signal_t irq_signal);
-
-#ifdef TFM_PSA_API
-/* The following macros are only valid if secure services can be called
- * using veneer functions. This is not the case if IPC messaging is enabled
- */
-#define TFM_CORE_IOVEC_SFN_REQUEST(id, fn, a, b, c, d) \
- do { \
- ERROR_MSG("Invalid TF-M configuration detected"); \
- tfm_secure_api_error_handler(); \
- /* This point never reached */ \
- return (int32_t)TFM_ERROR_GENERIC; \
- } while (0)
-#else
#define TFM_CORE_IOVEC_SFN_REQUEST(id, is_ns, fn, a, b, c, d) \
return tfm_core_partition_request(id, is_ns, fn, \
(int32_t)a, (int32_t)b, (int32_t)c, (int32_t)d)
diff --git a/secure_fw/spm/include/tfm_utils.h b/secure_fw/spm/include/utilities.h
similarity index 100%
rename from secure_fw/spm/include/tfm_utils.h
rename to secure_fw/spm/include/utilities.h
diff --git a/secure_fw/spm/init/tfm_boot_data.c b/secure_fw/spm/init/tfm_boot_data.c
index 0dc3124..20739a6 100644
--- a/secure_fw/spm/init/tfm_boot_data.c
+++ b/secure_fw/spm/init/tfm_boot_data.c
@@ -16,7 +16,7 @@
#include "spm_partition_defs.h"
#ifdef TFM_PSA_API
#include "tfm_internal_defines.h"
-#include "tfm_utils.h"
+#include "utilities.h"
#include "psa/service.h"
#include "tfm_thread.h"
#include "tfm_wait.h"
diff --git a/secure_fw/spm/model_func/CMakeLists.inc b/secure_fw/spm/model_func/CMakeLists.inc
index e700a9f..2160e86 100644
--- a/secure_fw/spm/model_func/CMakeLists.inc
+++ b/secure_fw/spm/model_func/CMakeLists.inc
@@ -37,12 +37,12 @@
"${SFW_SPM_INIT_DIR}/tfm_boot_data.c"
"${SFW_SPM_INIT_DIR}/tfm_core.c"
"${SFW_FUNC_SPM_DIR}/tfm_core_svcalls_func.c"
- "${SFW_FUNC_SPM_DIR}/../runtime/tfm_secure_api.c"
+ "${SFW_FUNC_SPM_DIR}/tfm_secure_api.c"
"${SFW_FUNC_SPM_DIR}/../runtime/tfm_spm_services.c"
"${SFW_FUNC_SPM_DIR}/../runtime/spm_api.c"
"${SFW_FUNC_SPM_DIR}/spm_func.c"
"${SFW_FUNC_SPM_DIR}/tfm_nspm_func.c"
- "${SFW_FUNC_SPM_DIR}/../runtime/tfm_utils.c"
+ "${SFW_FUNC_SPM_DIR}/../runtime/utilities.c"
"${SFW_FUNC_SPM_DIR}/../runtime/tfm_core_mem_check.c"
"${SFW_FUNC_SPM_DIR}/../runtime/tfm_core_utils.c"
"${SFW_FUNC_SPM_DIR}/tfm_veneers.c"
diff --git a/secure_fw/spm/model_func/spm_func.c b/secure_fw/spm/model_func/spm_func.c
index 890e0b2..3d4491e 100644
--- a/secure_fw/spm/model_func/spm_func.c
+++ b/secure_fw/spm/model_func/spm_func.c
@@ -21,7 +21,7 @@
#include "spm_db.h"
#include "region_defs.h"
#include "region.h"
-#include "tfm/tfm_spm_services_api.h"
+#include "tfm/tfm_spm_services.h"
#include "tfm_spm_db_func.inc"
#define EXC_RETURN_SECURE_FUNCTION 0xFFFFFFFD
@@ -38,7 +38,7 @@
* This is the "Big Lock" on the secure side, to guarantee single entry
* to SPE
*/
-extern int32_t tfm_secure_lock;
+static int32_t tfm_secure_lock;
static int32_t tfm_secure_api_initializing = 1;
static uint32_t *prepare_partition_iovec_ctx(
diff --git a/secure_fw/spm/model_func/tfm_secure_api.c b/secure_fw/spm/model_func/tfm_secure_api.c
new file mode 100644
index 0000000..d4fe179
--- /dev/null
+++ b/secure_fw/spm/model_func/tfm_secure_api.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include <stdbool.h>
+#include "spm_api.h"
+#include "tfm_secure_api.h"
+
+void tfm_secure_api_error_handler(void)
+{
+ ERROR_MSG("Security violation when calling secure API");
+ tfm_core_panic();
+}
+
+int32_t tfm_core_partition_request(uint32_t id, bool is_ns, void *fn,
+ int32_t arg1, int32_t arg2, int32_t arg3, int32_t arg4)
+{
+ int32_t args[4] = {arg1, arg2, arg3, arg4};
+ struct tfm_sfn_req_s desc, *desc_ptr = &desc;
+
+ desc.sp_id = id;
+ desc.sfn = (sfn_t) fn;
+ desc.args = args;
+ desc.ns_caller = is_ns;
+
+ if (__get_active_exc_num() != EXC_NUM_THREAD_MODE) {
+ /* The veneer of a secure service had been called from Handler mode.
+ * This violates TF-M's programming model, and is considered an
+ * unrecoverable error.
+ */
+ tfm_core_panic();
+ } else {
+ if (desc.ns_caller) {
+ return tfm_core_sfn_request(desc_ptr);
+ } else {
+ return tfm_spm_sfn_request_thread_mode(desc_ptr);
+ }
+ }
+ return TFM_ERROR_GENERIC;
+}
diff --git a/secure_fw/spm/model_ipc/CMakeLists.inc b/secure_fw/spm/model_ipc/CMakeLists.inc
index a763ab4..0836022 100644
--- a/secure_fw/spm/model_ipc/CMakeLists.inc
+++ b/secure_fw/spm/model_ipc/CMakeLists.inc
@@ -40,11 +40,10 @@
"${SFW_IPC_SPM_DIR}/spm_psa_client_call.c"
"${SFW_IPC_SPM_DIR}/tfm_core_svcalls_ipc.c"
"${SFW_IPC_SPM_DIR}/tfm_message_queue.c"
- "${SFW_IPC_SPM_DIR}/../runtime/tfm_utils.c"
+ "${SFW_IPC_SPM_DIR}/../runtime/utilities.c"
"${SFW_IPC_SPM_DIR}/../runtime/tfm_core_utils.c"
"${SFW_IPC_SPM_DIR}/../runtime/spm_api.c"
"${SFW_IPC_SPM_DIR}/../runtime/tfm_spm_services.c"
- "${SFW_IPC_SPM_DIR}/../runtime/tfm_secure_api.c"
"${SFW_IPC_SPM_DIR}/tfm_pools.c"
"${SFW_IPC_SPM_DIR}/tfm_thread.c"
"${SFW_IPC_SPM_DIR}/tfm_wait.c"
diff --git a/secure_fw/spm/model_ipc/spm_ipc.c b/secure_fw/spm/model_ipc/spm_ipc.c
index deb7d30..0f25828 100644
--- a/secure_fw/spm/model_ipc/spm_ipc.c
+++ b/secure_fw/spm/model_ipc/spm_ipc.c
@@ -12,7 +12,7 @@
#include "psa/lifecycle.h"
#include "tfm_thread.h"
#include "tfm_wait.h"
-#include "tfm_utils.h"
+#include "utilities.h"
#include "tfm_internal_defines.h"
#include "tfm_message_queue.h"
#include "tfm_spm_hal.h"
@@ -33,7 +33,7 @@
#include "tfm_pools.h"
#include "region.h"
#include "region_defs.h"
-#include "tfm/tfm_spm_services_api.h"
+#include "tfm/tfm_spm_services.h"
#include "secure_fw/partitions/tfm_service_list.inc"
#include "tfm_spm_db_ipc.inc"
diff --git a/secure_fw/spm/model_ipc/spm_psa_client_call.c b/secure_fw/spm/model_ipc/spm_psa_client_call.c
index 3c1de45..9fca10c 100644
--- a/secure_fw/spm/model_ipc/spm_psa_client_call.c
+++ b/secure_fw/spm/model_ipc/spm_psa_client_call.c
@@ -12,7 +12,7 @@
#include "tfm_memory_utils.h"
#include "tfm_message_queue.h"
#include "spm_psa_client_call.h"
-#include "tfm_utils.h"
+#include "utilities.h"
#include "tfm_wait.h"
#include "tfm_nspm.h"
diff --git a/secure_fw/spm/model_ipc/tfm_core_svcalls_ipc.c b/secure_fw/spm/model_ipc/tfm_core_svcalls_ipc.c
index 2db4233..7f8bbd9 100644
--- a/secure_fw/spm/model_ipc/tfm_core_svcalls_ipc.c
+++ b/secure_fw/spm/model_ipc/tfm_core_svcalls_ipc.c
@@ -14,7 +14,7 @@
#include "tfm_core_trustzone.h"
#include "tfm_internal.h"
#include "tfm_svcalls.h"
-#include "tfm_utils.h"
+#include "utilities.h"
#include "tfm/tfm_core_svc.h"
/* The section names come from the scatter file */
diff --git a/secure_fw/spm/model_ipc/tfm_multi_core.c b/secure_fw/spm/model_ipc/tfm_multi_core.c
index 855755b..f8ef7d6 100644
--- a/secure_fw/spm/model_ipc/tfm_multi_core.c
+++ b/secure_fw/spm/model_ipc/tfm_multi_core.c
@@ -9,7 +9,7 @@
#include "tfm_internal.h"
#include "tfm_nspm.h"
#include "tfm_spe_mailbox.h"
-#include "tfm_utils.h"
+#include "utilities.h"
#include "log/tfm_assert.h"
#include "log/tfm_log.h"
#include "log/tfm_assert.h"
diff --git a/secure_fw/spm/model_ipc/tfm_multi_core_mem_check.c b/secure_fw/spm/model_ipc/tfm_multi_core_mem_check.c
index 0eae524..9cf8bf8 100644
--- a/secure_fw/spm/model_ipc/tfm_multi_core_mem_check.c
+++ b/secure_fw/spm/model_ipc/tfm_multi_core_mem_check.c
@@ -12,7 +12,7 @@
#include "tfm_internal.h"
#include "tfm_multi_core.h"
#include "tfm_secure_api.h"
-#include "tfm_utils.h"
+#include "utilities.h"
#include "region.h"
#ifndef TFM_LVL
@@ -28,6 +28,42 @@
#define MEM_CHECK_NONSECURE (MEM_CHECK_AU_NONSECURE | \
MEM_CHECK_MPU_NONSECURE)
+/**
+ * \brief Check whether a memory range is inside a memory region.
+ *
+ * \param[in] p The start address of the range to check
+ * \param[in] s The size of the range to check
+ * \param[in] region_start The start address of the region, which should
+ * contain the range
+ * \param[in] region_limit The end address of the region, which should contain
+ * the range
+ *
+ * \return TFM_SUCCESS if the region contains the range,
+ * TFM_ERROR_GENERIC otherwise.
+ */
+static enum tfm_status_e check_address_range(const void *p, size_t s,
+ uintptr_t region_start,
+ uintptr_t region_limit)
+{
+ int32_t range_in_region;
+
+ /* Check for overflow in the range parameters */
+ if ((uintptr_t)p > UINTPTR_MAX - s) {
+ return TFM_ERROR_GENERIC;
+ }
+
+ /* We trust the region parameters, and don't check for overflow */
+
+ /* Calculate the result */
+ range_in_region = ((uintptr_t)p >= region_start) &&
+ ((uintptr_t)((char *) p + s - 1) <= region_limit);
+ if (range_in_region) {
+ return TFM_SUCCESS;
+ } else {
+ return TFM_ERROR_GENERIC;
+ }
+}
+
void tfm_get_mem_region_security_attr(const void *p, size_t s,
struct security_attr_info_t *p_attr)
{
diff --git a/secure_fw/spm/model_ipc/tfm_nspm_ipc.c b/secure_fw/spm/model_ipc/tfm_nspm_ipc.c
index 8413d46..2237906 100644
--- a/secure_fw/spm/model_ipc/tfm_nspm_ipc.c
+++ b/secure_fw/spm/model_ipc/tfm_nspm_ipc.c
@@ -9,7 +9,7 @@
#include "tfm_spm_hal.h"
#include "psa/error.h"
#include "tfm_nspm.h"
-#include "tfm_utils.h"
+#include "utilities.h"
#include "tfm_internal.h"
#include "log/tfm_assert.h"
#include "log/tfm_log.h"
diff --git a/secure_fw/spm/model_ipc/tfm_pools.c b/secure_fw/spm/model_ipc/tfm_pools.c
index 6ab56af..2fa3d40 100644
--- a/secure_fw/spm/model_ipc/tfm_pools.c
+++ b/secure_fw/spm/model_ipc/tfm_pools.c
@@ -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
*
@@ -13,7 +13,7 @@
#include "psa/service.h"
#include "tfm_internal_defines.h"
#include "cmsis_compiler.h"
-#include "tfm_utils.h"
+#include "utilities.h"
#include "tfm_list.h"
#include "tfm_pools.h"
#include "tfm_memory_utils.h"
diff --git a/secure_fw/spm/model_ipc/tfm_rpc.c b/secure_fw/spm/model_ipc/tfm_rpc.c
index f2778aa..351c971 100644
--- a/secure_fw/spm/model_ipc/tfm_rpc.c
+++ b/secure_fw/spm/model_ipc/tfm_rpc.c
@@ -8,7 +8,7 @@
#include "spm_api.h"
#include "spm_psa_client_call.h"
#include "tfm_rpc.h"
-#include "tfm_utils.h"
+#include "utilities.h"
static void default_handle_req(void)
{
diff --git a/secure_fw/spm/model_ipc/tfm_spe_mailbox.c b/secure_fw/spm/model_ipc/tfm_spe_mailbox.c
index baa02c7..c0affe1 100644
--- a/secure_fw/spm/model_ipc/tfm_spe_mailbox.c
+++ b/secure_fw/spm/model_ipc/tfm_spe_mailbox.c
@@ -9,7 +9,7 @@
#include "psa/error.h"
#include "tfm_core_utils.h"
-#include "tfm_utils.h"
+#include "utilities.h"
#include "tfm_spe_mailbox.h"
#include "tfm_rpc.h"
diff --git a/secure_fw/spm/model_ipc/tfm_thread.c b/secure_fw/spm/model_ipc/tfm_thread.c
index 74af5a9..e3554e3 100644
--- a/secure_fw/spm/model_ipc/tfm_thread.c
+++ b/secure_fw/spm/model_ipc/tfm_thread.c
@@ -7,7 +7,7 @@
#include <inttypes.h>
#include "tfm_arch.h"
#include "tfm_thread.h"
-#include "tfm_utils.h"
+#include "utilities.h"
#include "tfm_memory_utils.h"
#include "tfm/tfm_core_svc.h"
#include "spm_api.h"
diff --git a/secure_fw/spm/model_ipc/tfm_wait.c b/secure_fw/spm/model_ipc/tfm_wait.c
index efb7be6..c199c88 100644
--- a/secure_fw/spm/model_ipc/tfm_wait.c
+++ b/secure_fw/spm/model_ipc/tfm_wait.c
@@ -5,7 +5,7 @@
*
*/
#include "tfm_thread.h"
-#include "tfm_utils.h"
+#include "utilities.h"
#include "tfm_wait.h"
void tfm_event_wait(struct tfm_event_t *pevnt)
diff --git a/secure_fw/spm/runtime/tfm_core_utils.c b/secure_fw/spm/runtime/tfm_core_utils.c
index ba9a4ea..341e75c 100644
--- a/secure_fw/spm/runtime/tfm_core_utils.c
+++ b/secure_fw/spm/runtime/tfm_core_utils.c
@@ -1,12 +1,12 @@
/*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
#include <stdint.h>
-#include "tfm_utils.h"
+#include "utilities.h"
#include "tfm_core_utils.h"
union tfm_core_addr_t {
diff --git a/secure_fw/spm/runtime/tfm_secure_api.c b/secure_fw/spm/runtime/tfm_secure_api.c
deleted file mode 100644
index 7748c5c..0000000
--- a/secure_fw/spm/runtime/tfm_secure_api.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#include <stdbool.h>
-#include "spm_api.h"
-#include "tfm_secure_api.h"
-
-/* This is the "Big Lock" on the secure side, to guarantee single entry
- * to SPE
- */
-int32_t tfm_secure_lock;
-
-bool tfm_is_one_bit_set(uint32_t n)
-{
- return ((n && !(n & (n-1))) ? true : false);
-}
-
-enum tfm_status_e check_address_range(const void *p, size_t s,
- uintptr_t region_start,
- uintptr_t region_limit)
-{
- int32_t range_in_region;
-
- /* Check for overflow in the range parameters */
- if ((uintptr_t)p > UINTPTR_MAX - s) {
- return TFM_ERROR_GENERIC;
- }
-
- /* We trust the region parameters, and don't check for overflow */
-
- /* Calculate the result */
- range_in_region = ((uintptr_t)p >= region_start) &&
- ((uintptr_t)((char *) p + s - 1) <= region_limit);
- if (range_in_region) {
- return TFM_SUCCESS;
- } else {
- return TFM_ERROR_GENERIC;
- }
-}
-
-void tfm_secure_api_error_handler(void)
-{
- ERROR_MSG("Security violation when calling secure API");
- tfm_core_panic();
-}
-
-#ifndef TFM_PSA_API
-int32_t tfm_core_partition_request(uint32_t id, bool is_ns, void *fn,
- int32_t arg1, int32_t arg2, int32_t arg3, int32_t arg4)
-{
- int32_t args[4] = {arg1, arg2, arg3, arg4};
- struct tfm_sfn_req_s desc, *desc_ptr = &desc;
-
- desc.sp_id = id;
- desc.sfn = (sfn_t) fn;
- desc.args = args;
- desc.ns_caller = is_ns;
-
- if (__get_active_exc_num() != EXC_NUM_THREAD_MODE) {
- /* The veneer of a secure service had been called from Handler mode.
- * This violates TF-M's programming model, and is considered an
- * unrecoverable error.
- */
- tfm_core_panic();
- } else {
- if (desc.ns_caller) {
- return tfm_core_sfn_request(desc_ptr);
- } else {
- return tfm_spm_sfn_request_thread_mode(desc_ptr);
- }
- }
- return TFM_ERROR_GENERIC;
-}
-#endif
diff --git a/secure_fw/spm/runtime/tfm_spm_services.c b/secure_fw/spm/runtime/tfm_spm_services.c
index 7b73d4c..9d23442 100644
--- a/secure_fw/spm/runtime/tfm_spm_services.c
+++ b/secure_fw/spm/runtime/tfm_spm_services.c
@@ -10,7 +10,7 @@
#include "tfm/tfm_core_svc.h"
#include "tfm_secure_api.h"
#include "tfm_internal.h"
-#include "tfm/tfm_spm_services_api.h"
+#include "tfm/tfm_spm_services.h"
#include "spm_api.h"
#include "psa/service.h"
diff --git a/secure_fw/spm/runtime/tfm_utils.c b/secure_fw/spm/runtime/utilities.c
similarity index 77%
rename from secure_fw/spm/runtime/tfm_utils.c
rename to secure_fw/spm/runtime/utilities.c
index c1d9d35..c601311 100644
--- a/secure_fw/spm/runtime/tfm_utils.c
+++ b/secure_fw/spm/runtime/utilities.c
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
#include <inttypes.h>
-#include "tfm_utils.h"
+#include "utilities.h"
#include "tfm_spm_hal.h"
void tfm_core_panic(void)
@@ -20,3 +20,8 @@
*/
tfm_spm_hal_system_reset();
}
+
+bool tfm_is_one_bit_set(uint32_t n)
+{
+ return ((n && !(n & (n-1))) ? true : false);
+}