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/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);
+}