aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Hu <david.hu@arm.com>2021-04-07 15:58:53 +0800
committerDavid Hu <david.hu@arm.com>2021-04-29 08:56:18 +0200
commitc686ecbe98e674d2e60a938fcc18ee5104f9ec9d (patch)
tree3f9225a56aba4fa162cb353e8c6a82c54af20b7e
parent5079a041bfb366594cdf6c72f173921ab34b2a92 (diff)
downloadtrusted-firmware-m-c686ecbe98e674d2e60a938fcc18ee5104f9ec9d.tar.gz
Interface: Remove NS specific implementation of test interface
Remove some test interface files to decouple TF-M from NS speific implementation. Those files will be moved to tf-m-tests. Those files include NS client identification management and NS mailbox test utilities. Change-Id: I963ccae2b50d6124e3ac84547d91b09b28fddfd5 Signed-off-by: David Hu <david.hu@arm.com>
-rw-r--r--cmake/install.cmake14
-rw-r--r--docs/technical_references/tfm_ns_client_identification.rst21
-rw-r--r--interface/include/tfm_ns_svc.h68
-rw-r--r--interface/include/tfm_nspm_api.h28
-rw-r--r--interface/include/tfm_nspm_svc_handler.h30
-rw-r--r--interface/src/multi_core/tfm_ns_mailbox_test.c78
-rw-r--r--interface/src/tfm_nspm_api.c82
-rw-r--r--interface/src/tfm_nspm_svc_handler.c20
8 files changed, 2 insertions, 339 deletions
diff --git a/cmake/install.cmake b/cmake/install.cmake
index b7941441d4..2187e62063 100644
--- a/cmake/install.cmake
+++ b/cmake/install.cmake
@@ -39,7 +39,6 @@ install(FILES ${CMAKE_BINARY_DIR}/generated/interface/include/psa_manifest
install(FILES ${INTERFACE_INC_DIR}/tfm_api.h
${INTERFACE_INC_DIR}/tfm_ns_interface.h
- ${INTERFACE_INC_DIR}/tfm_ns_svc.h
DESTINATION ${INSTALL_INTERFACE_INC_DIR})
install(FILES ${INTERFACE_INC_DIR}/ext/tz_context.h
@@ -56,12 +55,6 @@ else()
DESTINATION ${INSTALL_INTERFACE_INC_DIR}/tfm/veneers)
endif()
-if (TFM_NS_CLIENT_IDENTIFICATION)
- install(FILES ${INTERFACE_INC_DIR}/tfm_nspm_api.h
- ${INTERFACE_INC_DIR}/tfm_nspm_svc_handler.h
- DESTINATION ${INSTALL_INTERFACE_INC_DIR})
-endif()
-
if (TFM_PARTITION_PROTECTED_STORAGE OR FORWARD_PROT_MSG)
install(FILES ${INTERFACE_INC_DIR}/psa/protected_storage.h
DESTINATION ${INSTALL_INTERFACE_INC_DIR}/psa)
@@ -117,7 +110,6 @@ if (TFM_MULTI_CORE_TOPOLOGY)
${INTERFACE_SRC_DIR}/multi_core/tfm_multi_core_ns_api.c
${INTERFACE_SRC_DIR}/multi_core/tfm_multi_core_psa_ns_api.c
${INTERFACE_SRC_DIR}/multi_core/tfm_ns_mailbox_thread.c
- ${INTERFACE_SRC_DIR}/multi_core/tfm_ns_mailbox_test.c
DESTINATION ${INSTALL_INTERFACE_SRC_DIR})
else()
if(TFM_PSA_API)
@@ -129,12 +121,6 @@ else()
DESTINATION ${INSTALL_INTERFACE_SRC_DIR})
endif()
-if (TFM_NS_CLIENT_IDENTIFICATION)
- install(FILES ${INTERFACE_SRC_DIR}/tfm_nspm_api.c
- ${INTERFACE_SRC_DIR}/tfm_nspm_svc_handler.c
- DESTINATION ${INSTALL_INTERFACE_SRC_DIR})
-endif()
-
if (TFM_PARTITION_PROTECTED_STORAGE OR FORWARD_PROT_MSG)
if (TFM_PSA_API)
install(FILES ${INTERFACE_SRC_DIR}/tfm_ps_ipc_api.c
diff --git a/docs/technical_references/tfm_ns_client_identification.rst b/docs/technical_references/tfm_ns_client_identification.rst
index 44fd3435ad..4ef8e90d0a 100644
--- a/docs/technical_references/tfm_ns_client_identification.rst
+++ b/docs/technical_references/tfm_ns_client_identification.rst
@@ -15,24 +15,7 @@ Thread Context Management for Armv8-M TrustZone APIs, as described
However TF-M needs an extra API, to assign a client ID to the TZ context created
as a result of the
``TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module)`` call.
-
-To do this, the
-``enum tfm_status_e tfm_register_client_id (int32_t ns_client_id)`` have to be
-called from an SVC handler, with the client ID of the currently running client.
-
-In the current implementation of TF-M, an SVC call is provided for the NS
-clients to be called at the beginning of their main function.
-
-``SVC(SVC_TFM_NSPM_REGISTER_CLIENT_ID);``
-
-The SVC call handler of the above SVC maps the name of the current thread to a
-hardcoded client id, and sends it to the TF-M core via the earlier discussed
-API.
-
-The mapping is implemented in ``interface/src/tfm_nspm_svc_handler.c``.
-
-The system integrators **may** implement the non-secure ID mapping based on
-their application/threat model.
+See ``interface/include/ext/tz_context.h`` for details of API declarations.
In case the NS OS doesn't use the Thread Context Management for Armv8-M
TrustZone APIs, then TF-M considers the NS SW as a single client, and assigns a
@@ -40,4 +23,4 @@ client ID to it automatically.
--------------
-*Copyright (c) 2018-2020, Arm Limited. All rights reserved.*
+*Copyright (c) 2018-2021, Arm Limited. All rights reserved.*
diff --git a/interface/include/tfm_ns_svc.h b/interface/include/tfm_ns_svc.h
deleted file mode 100644
index def0c2f7ee..0000000000
--- a/interface/include/tfm_ns_svc.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#include <stdio.h>
-#include "cmsis_compiler.h"
-
-#ifndef __TFM_NS_SVC_H__
-#define __TFM_NS_SVC_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief Include all the SVC handler headers
- */
-#include "tfm_nspm_svc_handler.h"
-
-/**
- * \brief Macro to encode an svc instruction
- *
- */
-#define SVC(code) __ASM volatile("svc %0" : : "I" (code))
-
-/**
- * \def LIST_SVC_NSPM
- *
- * \brief This is an X macro which lists
- * the SVC interface exposed by TF-M
- * for the NS OS.
- *
- */
-#define LIST_SVC_NSPM \
- X(SVC_TFM_NSPM_REGISTER_CLIENT_ID, tfm_nspm_svc_register_client_id) \
-
-/**
- * \brief Numbers associated to each SVC available
- *
- * \details Start from 1 as 0 is reserved by RTX
- */
-enum tfm_svc_num {
- SVC_INVALID = 0,
-
-#define X(SVC_ENUM, SVC_HANDLER) SVC_ENUM,
-
- /* SVC API for Services */
-#ifdef TFM_NS_CLIENT_IDENTIFICATION
- LIST_SVC_NSPM
-#endif
-
-#undef X
-
- /* add all the new entries above this line */
- SVC_TFM_MAX,
-};
-
-/* number of user SVC functions */
-#define USER_SVC_COUNT ((uint32_t)SVC_TFM_MAX - 1)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __TFM_NS_SVC_H__ */
diff --git a/interface/include/tfm_nspm_api.h b/interface/include/tfm_nspm_api.h
deleted file mode 100644
index 5f03845bcd..0000000000
--- a/interface/include/tfm_nspm_api.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#ifndef __TFM_NSPM_API_H__
-#define __TFM_NSPM_API_H__
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief Reports the client ID of this task to TF-M
- *
- * \return Returns 1 if the client ID was successfully reported 0 otherwise
- */
-uint32_t tfm_nspm_register_client_id(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __TFM_NSPM_API_H__ */
diff --git a/interface/include/tfm_nspm_svc_handler.h b/interface/include/tfm_nspm_svc_handler.h
deleted file mode 100644
index 73f75a95e1..0000000000
--- a/interface/include/tfm_nspm_svc_handler.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#ifndef __TFM_NSPM_SVC_HANDLER_H__
-#define __TFM_NSPM_SVC_HANDLER_H__
-
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief Reports the client ID of this task to TF-M (SVC function)
- *
- * \param [in] client_id Client ID to register.
- *
- * \return Returns 1 if the client ID was successfully reported 0 otherwise
- */
-uint32_t tfm_nspm_svc_register_client_id(uint32_t client_id);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __TFM_NSPM_SVC_HANDLER_H__ */
diff --git a/interface/src/multi_core/tfm_ns_mailbox_test.c b/interface/src/multi_core/tfm_ns_mailbox_test.c
deleted file mode 100644
index e12cdc9567..0000000000
--- a/interface/src/multi_core/tfm_ns_mailbox_test.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#include "tfm_ns_mailbox.h"
-
-static struct ns_mailbox_queue_t *stats_queue_ptr = NULL;
-
-void tfm_ns_mailbox_tx_stats_init(struct ns_mailbox_queue_t *ns_queue)
-{
- if (!ns_queue) {
- return;
- }
-
- ns_queue->nr_tx = 0;
- ns_queue->nr_used_slots = 0;
-
- stats_queue_ptr = ns_queue;
-}
-
-int32_t tfm_ns_mailbox_tx_stats_reinit(void)
-{
- if (!stats_queue_ptr) {
- return MAILBOX_INVAL_PARAMS;
- }
-
- stats_queue_ptr->nr_tx = 0;
- stats_queue_ptr->nr_used_slots = 0;
-
- return MAILBOX_SUCCESS;
-}
-
-void tfm_ns_mailbox_tx_stats_update(void)
-{
- mailbox_queue_status_t empty_status;
- uint8_t idx, nr_empty = 0;
-
- if (!stats_queue_ptr) {
- return;
- }
-
- ns_mailbox_spin_lock();
- /* Count the number of used slots when this tx arrives */
- empty_status = stats_queue_ptr->empty_slots;
- ns_mailbox_spin_unlock();
-
- if (empty_status) {
- for (idx = 0; idx < NUM_MAILBOX_QUEUE_SLOT; idx++) {
- if (empty_status & (0x1UL << idx)) {
- nr_empty++;
- }
- }
- }
-
- ns_mailbox_spin_lock();
- stats_queue_ptr->nr_used_slots += (NUM_MAILBOX_QUEUE_SLOT - nr_empty);
- stats_queue_ptr->nr_tx++;
- ns_mailbox_spin_unlock();
-}
-
-void tfm_ns_mailbox_stats_avg_slot(struct ns_mailbox_stats_res_t *stats_res)
-{
- uint32_t nr_used_slots, nr_tx;
-
- if (!stats_queue_ptr || !stats_res) {
- return;
- }
-
- nr_used_slots = stats_queue_ptr->nr_used_slots;
- nr_tx = stats_queue_ptr->nr_tx;
-
- stats_res->avg_nr_slots = nr_used_slots / nr_tx;
- nr_used_slots %= nr_tx;
- stats_res->avg_nr_slots_tenths = nr_used_slots * 10 / nr_tx;
-}
diff --git a/interface/src/tfm_nspm_api.c b/interface/src/tfm_nspm_api.c
deleted file mode 100644
index a540e8ca3d..0000000000
--- a/interface/src/tfm_nspm_api.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#include "tfm_nspm_api.h"
-
-#include <string.h>
-#include <stdint.h>
-
-#include "cmsis_os2.h"
-#include "tfm_ns_svc.h"
-
-/* Translation table pair between OS threads and client IDs */
-struct thread_test_clientid_pair {
- const char* t_name; /*!< Task/Thread name */
- int32_t client_id; /*!< Client ID used in assets definition */
-};
-
-static struct thread_test_clientid_pair test_ns_policy_table[] =
-{
- {"Thread_A", -1},
- {"Thread_B", -2},
- {"Thread_C", -3},
- {"Thread_D", -4},
- {"seq_task", -5},
- {"mid_task", -6},
- {"pri_task", -7},
-#ifdef PSA_API_TEST_NS
- {"psa_api_test", -8}
-#endif
-};
-
-/**
- * \brief Gets the client ID based on the thread name
- *
- * \return If the thread name is in the test_ns_policy_table, it returns the
- * client ID. Otherwise, it returns 0 as an error code.
- */
-static uint32_t get_client_id(void)
-{
- uint32_t i;
- static uint32_t test_table_size = (sizeof(test_ns_policy_table) /
- sizeof(test_ns_policy_table[0]));
- const char* p_thread_name;
- osThreadId_t thread_id;
-
- /* Get thread name */
- thread_id = osThreadGetId();
- p_thread_name = osThreadGetName(thread_id);
-
- for (i = 0; i < test_table_size; i++) {
- if (strcmp(test_ns_policy_table[i].t_name, p_thread_name) == 0) {
- return test_ns_policy_table[i].client_id;
- }
- }
-
- return 0;
-}
-
-__attribute__ ((naked))
-static uint32_t tfm_nspm_svc_register_client(uint32_t client_id)
-{
- SVC(SVC_TFM_NSPM_REGISTER_CLIENT_ID);
- __ASM volatile("BX LR");
-}
-
-uint32_t tfm_nspm_register_client_id(void)
-{
- uint32_t client_id;
-
- client_id = get_client_id();
- if (client_id == 0) {
- return 0;
- }
-
- return tfm_nspm_svc_register_client(client_id);
-}
-
-
diff --git a/interface/src/tfm_nspm_svc_handler.c b/interface/src/tfm_nspm_svc_handler.c
deleted file mode 100644
index 3ec2cb03d2..0000000000
--- a/interface/src/tfm_nspm_svc_handler.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#include "tfm_nspm_svc_handler.h"
-#include "tfm_api.h"
-#include "tfm_ns_svc.h"
-
-/* SVC function implementations */
-uint32_t tfm_nspm_svc_register_client_id(uint32_t client_id)
-{
- if (tfm_register_client_id(client_id) == TFM_SUCCESS) {
- return 1;
- }
-
- return 0;
-}