aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMingyang Sun <mingyang.sun@arm.com>2021-04-20 15:52:18 +0800
committerMingyang Sun <mingyang.sun@arm.com>2021-04-22 13:47:34 +0800
commit783a59bc7b1a2e7806b96f892a0cdc8b2a45db16 (patch)
treefd21b45a06d95f92051804a193e45573e455c1d9
parentaa74ab66a71424c05f4f5760d96eee67c26e465a (diff)
downloadtrusted-firmware-m-783a59bc7b1a2e7806b96f892a0cdc8b2a45db16.tar.gz
SPM: Update service structure
Prepare for partition storage arrangement, normalize the structure name: - Change the service structure name to 'service_t' - Change the global service lists name to 'g_services' Change-Id: Ic35c9b27f03054c46127b3453e71d70da78e05f6 Signed-off-by: Mingyang Sun <mingyang.sun@arm.com>
-rw-r--r--secure_fw/partitions/tfm_service_list.inc.template2
-rw-r--r--secure_fw/spm/cmsis_psa/spm_ipc.c41
-rw-r--r--secure_fw/spm/cmsis_psa/spm_ipc.h29
-rw-r--r--secure_fw/spm/ffm/psa_client_service_apis.c2
-rw-r--r--secure_fw/spm/ffm/spm_psa_client_call.c8
5 files changed, 40 insertions, 42 deletions
diff --git a/secure_fw/partitions/tfm_service_list.inc.template b/secure_fw/partitions/tfm_service_list.inc.template
index 75e99498b..ba5a5ccd1 100644
--- a/secure_fw/partitions/tfm_service_list.inc.template
+++ b/secure_fw/partitions/tfm_service_list.inc.template
@@ -66,7 +66,7 @@ const struct tfm_spm_service_db_t service_db[] =
/**************************************************************************/
/** The service list */
/**************************************************************************/
-struct tfm_spm_service_t service[] =
+struct service_t g_services[] =
{
{% for partition in partitions %}
{% if partition.attr.tfm_partition_ipc %}
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.c b/secure_fw/spm/cmsis_psa/spm_ipc.c
index 65b1bd72f..f8c5b5ea8 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.c
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.c
@@ -128,9 +128,8 @@ struct tfm_conn_handle_t *tfm_spm_to_handle_instance(psa_handle_t user_handle)
}
/* Service handle management functions */
-struct tfm_conn_handle_t *tfm_spm_create_conn_handle(
- struct tfm_spm_service_t *service,
- int32_t client_id)
+struct tfm_conn_handle_t *tfm_spm_create_conn_handle(struct service_t *service,
+ int32_t client_id)
{
struct tfm_conn_handle_t *p_handle;
@@ -170,7 +169,7 @@ int32_t tfm_spm_validate_conn_handle(
return SPM_SUCCESS;
}
-int32_t tfm_spm_free_conn_handle(struct tfm_spm_service_t *service,
+int32_t tfm_spm_free_conn_handle(struct service_t *service,
struct tfm_conn_handle_t *conn_handle)
{
TFM_CORE_ASSERT(service);
@@ -187,7 +186,7 @@ int32_t tfm_spm_free_conn_handle(struct tfm_spm_service_t *service,
return SPM_SUCCESS;
}
-int32_t tfm_spm_set_rhandle(struct tfm_spm_service_t *service,
+int32_t tfm_spm_set_rhandle(struct service_t *service,
struct tfm_conn_handle_t *conn_handle,
void *rhandle)
{
@@ -212,7 +211,7 @@ int32_t tfm_spm_set_rhandle(struct tfm_spm_service_t *service,
* hanlde is \ref PSA_NULL_HANDLE
* handle node does not be found
*/
-static void *tfm_spm_get_rhandle(struct tfm_spm_service_t *service,
+static void *tfm_spm_get_rhandle(struct service_t *service,
struct tfm_conn_handle_t *conn_handle)
{
TFM_CORE_ASSERT(service);
@@ -340,14 +339,14 @@ bool tfm_is_partition_privileged(uint32_t partition_idx)
TFM_PARTITION_PRIVILEGED_MODE;
}
-struct tfm_spm_service_t *tfm_spm_get_service_by_sid(uint32_t sid)
+struct service_t *tfm_spm_get_service_by_sid(uint32_t sid)
{
uint32_t i, num;
- num = sizeof(service) / sizeof(struct tfm_spm_service_t);
+ num = sizeof(g_services) / sizeof(struct service_t);
for (i = 0; i < num; i++) {
- if (service[i].service_db->sid == sid) {
- return &service[i];
+ if (g_services[i].service_db->sid == sid) {
+ return &g_services[i];
}
}
@@ -383,7 +382,7 @@ struct partition_t *tfm_spm_get_running_partition(void)
return partition;
}
-int32_t tfm_spm_check_client_version(struct tfm_spm_service_t *service,
+int32_t tfm_spm_check_client_version(struct service_t *service,
uint32_t version)
{
TFM_CORE_ASSERT(service);
@@ -406,7 +405,7 @@ int32_t tfm_spm_check_client_version(struct tfm_spm_service_t *service,
}
int32_t tfm_spm_check_authorization(uint32_t sid,
- struct tfm_spm_service_t *service,
+ struct service_t *service,
bool ns_caller)
{
struct partition_t *partition = NULL;
@@ -488,7 +487,7 @@ struct tfm_msg_body_t *
}
void tfm_spm_fill_msg(struct tfm_msg_body_t *msg,
- struct tfm_spm_service_t *service,
+ struct service_t *service,
psa_handle_t handle,
int32_t type, int32_t client_id,
psa_invec *invec, size_t in_len,
@@ -545,7 +544,7 @@ void tfm_spm_fill_msg(struct tfm_msg_body_t *msg,
}
}
-void tfm_spm_send_event(struct tfm_spm_service_t *service,
+void tfm_spm_send_event(struct service_t *service,
struct tfm_msg_body_t *msg)
{
struct partition_t *partition = NULL;
@@ -739,23 +738,23 @@ uint32_t tfm_spm_init(void)
}
/* Init Service */
- num = sizeof(service) / sizeof(struct tfm_spm_service_t);
+ num = sizeof(g_services) / sizeof(struct service_t);
for (i = 0; i < num; i++) {
int32_t j = 0;
- service[i].service_db = &service_db[i];
+ g_services[i].service_db = &service_db[i];
partition =
- tfm_spm_get_partition_by_id(service[i].service_db->partition_id);
+ tfm_spm_get_partition_by_id(g_services[i].service_db->partition_id);
if (!partition) {
tfm_core_panic();
}
- service[i].partition = partition;
- partition->signals_allowed |= service[i].service_db->signal;
+ g_services[i].partition = partition;
+ partition->signals_allowed |= g_services[i].service_db->signal;
/* Populate the p_service of stateless_service_ref[] */
if (service_db[i].connection_based == false) {
for (j = 0; j < STATIC_HANDLE_NUM_LIMIT; j++) {
if (stateless_service_ref[j].sid == service_db[i].sid) {
- stateless_service_ref[j].p_service = &service[i];
+ stateless_service_ref[j].p_service = &g_services[i];
break;
}
}
@@ -765,7 +764,7 @@ uint32_t tfm_spm_init(void)
}
}
- BI_LIST_INIT_NODE(&service[i].handle_list);
+ BI_LIST_INIT_NODE(&g_services[i].handle_list);
}
/*
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.h b/secure_fw/spm/cmsis_psa/spm_ipc.h
index 1a1384fda..892bad1f7 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.h
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.h
@@ -78,7 +78,7 @@
/* Message struct to collect parameter from client */
struct tfm_msg_body_t {
int32_t magic;
- struct tfm_spm_service_t *service; /* RoT service pointer */
+ struct service_t *service; /* RoT service pointer */
struct tfm_event_t ack_evnt; /* Event for ack reponse */
psa_msg_t msg; /* PSA message body */
psa_invec invec[PSA_MAX_IOVEC]; /* Put in/out vectors in msg body */
@@ -160,7 +160,7 @@ struct tfm_spm_service_db_t {
};
/* RoT Service data */
-struct tfm_spm_service_t {
+struct service_t {
const struct tfm_spm_service_db_t *service_db;/* Service database pointer */
struct partition_t *partition; /*
* Point to secure partition
@@ -173,7 +173,7 @@ struct tfm_spm_service_t {
/* Stateless RoT service tracking array item type. Indexed by static handle */
struct stateless_service_tracking_t {
uint32_t sid; /* Service ID */
- struct tfm_spm_service_t *p_service; /* Service instance */
+ struct service_t *p_service; /* Service instance */
};
/* RoT connection handle list */
@@ -193,7 +193,7 @@ struct tfm_conn_handle_t {
* - non secure client endpoint id.
*/
struct tfm_msg_body_t internal_msg; /* Internal message for message queue */
- struct tfm_spm_service_t *service; /* RoT service pointer */
+ struct service_t *service; /* RoT service pointer */
struct bi_list_node_t list; /* list node */
};
@@ -236,9 +236,8 @@ uint32_t tfm_spm_partition_get_running_partition_id(void);
* \retval NULL Create failed
* \retval "Not NULL" Service handle created
*/
-struct tfm_conn_handle_t *tfm_spm_create_conn_handle(
- struct tfm_spm_service_t *service,
- int32_t client_id);
+struct tfm_conn_handle_t *tfm_spm_create_conn_handle(struct service_t *service,
+ int32_t client_id);
/**
* \brief Validate connection handle for client connect
@@ -264,7 +263,7 @@ int32_t tfm_spm_validate_conn_handle(
* \retval SPM_ERROR_BAD_PARAMETERS Bad parameters input
* \retval "Does not return" Panic for not find service by handle
*/
-int32_t tfm_spm_free_conn_handle(struct tfm_spm_service_t *service,
+int32_t tfm_spm_free_conn_handle(struct service_t *service,
struct tfm_conn_handle_t *conn_handle);
/******************** Partition management functions *************************/
@@ -300,9 +299,9 @@ struct partition_t *tfm_spm_get_running_partition(void);
*
* \retval NULL Failed
* \retval "Not NULL" Target service context pointer,
- * \ref tfm_spm_service_t structures
+ * \ref service_t structures
*/
-struct tfm_spm_service_t *tfm_spm_get_service_by_sid(uint32_t sid);
+struct service_t *tfm_spm_get_service_by_sid(uint32_t sid);
/************************ Message functions **********************************/
@@ -345,7 +344,7 @@ struct tfm_msg_body_t *
* \param[in] caller_outvec Array of caller output \ref psa_outvec structures
*/
void tfm_spm_fill_msg(struct tfm_msg_body_t *msg,
- struct tfm_spm_service_t *service,
+ struct service_t *service,
psa_handle_t handle,
int32_t type, int32_t client_id,
psa_invec *invec, size_t in_len,
@@ -362,7 +361,7 @@ void tfm_spm_fill_msg(struct tfm_msg_body_t *msg,
* \param[in] msg message created by tfm_spm_create_msg()
* \ref tfm_msg_body_t structures
*/
-void tfm_spm_send_event(struct tfm_spm_service_t *service,
+void tfm_spm_send_event(struct service_t *service,
struct tfm_msg_body_t *msg);
/**
@@ -377,7 +376,7 @@ void tfm_spm_send_event(struct tfm_spm_service_t *service,
* \retval SPM_ERROR_BAD_PARAMETERS Bad parameters input
* \retval SPM_ERROR_VERSION Check failed
*/
-int32_t tfm_spm_check_client_version(struct tfm_spm_service_t *service,
+int32_t tfm_spm_check_client_version(struct service_t *service,
uint32_t version);
/**
@@ -392,7 +391,7 @@ int32_t tfm_spm_check_client_version(struct tfm_spm_service_t *service,
* \retval SPM_ERROR_GENERIC Authorization check failed
*/
int32_t tfm_spm_check_authorization(uint32_t sid,
- struct tfm_spm_service_t *service,
+ struct service_t *service,
bool ns_caller);
/**
@@ -499,7 +498,7 @@ void tfm_core_handler_mode(void);
* \retval SPM_ERROR_BAD_PARAMETERS Bad parameters input
* \retval "Does not return" Panic for not find handle node
*/
-int32_t tfm_spm_set_rhandle(struct tfm_spm_service_t *service,
+int32_t tfm_spm_set_rhandle(struct service_t *service,
struct tfm_conn_handle_t *conn_handle,
void *rhandle);
diff --git a/secure_fw/spm/ffm/psa_client_service_apis.c b/secure_fw/spm/ffm/psa_client_service_apis.c
index a1bbc1016..9f2e95f71 100644
--- a/secure_fw/spm/ffm/psa_client_service_apis.c
+++ b/secure_fw/spm/ffm/psa_client_service_apis.c
@@ -457,7 +457,7 @@ void tfm_spm_psa_reply(uint32_t *args)
{
psa_handle_t msg_handle;
psa_status_t status;
- struct tfm_spm_service_t *service = NULL;
+ struct service_t *service = NULL;
struct tfm_msg_body_t *msg = NULL;
int32_t ret = PSA_SUCCESS;
struct tfm_conn_handle_t *conn_handle;
diff --git a/secure_fw/spm/ffm/spm_psa_client_call.c b/secure_fw/spm/ffm/spm_psa_client_call.c
index 7e186e4a2..a30b8778b 100644
--- a/secure_fw/spm/ffm/spm_psa_client_call.c
+++ b/secure_fw/spm/ffm/spm_psa_client_call.c
@@ -27,7 +27,7 @@ uint32_t tfm_spm_client_psa_framework_version(void)
uint32_t tfm_spm_client_psa_version(uint32_t sid, bool ns_caller)
{
- struct tfm_spm_service_t *service;
+ struct service_t *service;
/*
* It should return PSA_VERSION_NONE if the RoT Service is not
@@ -52,7 +52,7 @@ uint32_t tfm_spm_client_psa_version(uint32_t sid, bool ns_caller)
psa_status_t tfm_spm_client_psa_connect(uint32_t sid, uint32_t version,
bool ns_caller)
{
- struct tfm_spm_service_t *service;
+ struct service_t *service;
struct tfm_msg_body_t *msg;
struct tfm_conn_handle_t *connect_handle;
int32_t client_id;
@@ -131,7 +131,7 @@ psa_status_t tfm_spm_client_psa_call(psa_handle_t handle, int32_t type,
psa_invec invecs[PSA_MAX_IOVEC];
psa_outvec outvecs[PSA_MAX_IOVEC];
struct tfm_conn_handle_t *conn_handle;
- struct tfm_spm_service_t *service;
+ struct service_t *service;
struct tfm_msg_body_t *msg;
int i, j;
int32_t client_id;
@@ -306,7 +306,7 @@ psa_status_t tfm_spm_client_psa_call(psa_handle_t handle, int32_t type,
void tfm_spm_client_psa_close(psa_handle_t handle, bool ns_caller)
{
- struct tfm_spm_service_t *service;
+ struct service_t *service;
struct tfm_msg_body_t *msg;
struct tfm_conn_handle_t *conn_handle;
int32_t client_id;