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>
diff --git a/secure_fw/partitions/tfm_service_list.inc.template b/secure_fw/partitions/tfm_service_list.inc.template
index 75e9949..ba5a5cc 100644
--- a/secure_fw/partitions/tfm_service_list.inc.template
+++ b/secure_fw/partitions/tfm_service_list.inc.template
@@ -66,7 +66,7 @@
 /**************************************************************************/
 /** 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 65b1bd7..f8c5b5e 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.c
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.c
@@ -128,9 +128,8 @@
 }
 
 /* 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 @@
     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 @@
     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 @@
  *                              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 @@
            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 @@
     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_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 @@
 }
 
 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_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 @@
     }
 
     /* 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 @@
             }
         }
 
-        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 1a1384f..892bad1 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 @@
 };
 
 /* 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 @@
 /* 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 @@
                                          *  - 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 @@
  * \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 @@
  * \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 @@
  *
  * \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 @@
  * \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 @@
  * \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 @@
  * \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 @@
  * \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 @@
  * \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 a1bbc10..9f2e95f 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 @@
 {
     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 7e186e4..a30b877 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_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 @@
 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_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 @@
 
 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;