Interface: Refactor NS lock and SVC's interface

The NS lock implementation is refactored to use X
macros. This improves maintenability and readability
as limits only to tfm_ns_svc.h the file to be modified
when a new SVC interface has to be added. The SVC
declarations are also amended to use X macros.

Change-Id: I5d20e9a99c3193594b8882967be085406b8a354b
Signed-off-by: Antonio de Angelis <antonio.deangelis@arm.com>
diff --git a/interface/include/tfm_ns_svc.h b/interface/include/tfm_ns_svc.h
index 330bd84..4e4d731 100644
--- a/interface/include/tfm_ns_svc.h
+++ b/interface/include/tfm_ns_svc.h
@@ -16,12 +16,85 @@
 #endif
 
 /**
+ * \brief Include all the SVC handler headers
+ */
+#include "tfm_sst_svc_handler.h"
+#include "svc_core_test_ns.h"
+#include "sst_test_service_svc.h"
+
+/**
  * \brief Macro to encode an svc instruction
  *
  */
 #define SVC(code) __ASM("svc %0" : : "I" (code))
 
 /**
+ * \def LIST_SVC_DISPATCHERS
+ *
+ * \brief This is an X macro which lists
+ *        the SVC interface exposed by the
+ *        available secure services. The
+ *        enumerator and corresponding
+ *        SVC handler function need to be
+ *        registered.
+ *
+ */
+#define LIST_SVC_DISPATCHERS \
+    X(SVC_TFM_SST_GET_HANDLE, tfm_sst_svc_get_handle) \
+    X(SVC_TFM_SST_CREATE, tfm_sst_svc_create) \
+    X(SVC_TFM_SST_GET_ATTRIBUTES, tfm_sst_svc_get_attributes) \
+    X(SVC_TFM_SST_READ, tfm_sst_svc_read) \
+    X(SVC_TFM_SST_WRITE, tfm_sst_svc_write) \
+    X(SVC_TFM_SST_DELETE, tfm_sst_svc_delete)
+
+/**
+ * \def LIST_SVC_CORE_TEST_INTERACTIVE
+ *
+ * \brief This is an X macro which lists
+ *        the SVC interface available for
+ *        the CORE_TEST_INTERACTIVE. The
+ *        enumerator and corresponding
+ *        SVC handler function need to be
+ *        registered.
+ *
+ */
+#define LIST_SVC_CORE_TEST_INTERACTIVE \
+    X(SVC_SECURE_DECREMENT_NS_LOCK_1, svc_secure_decrement_ns_lock_1) \
+    X(SVC_SECURE_DECREMENT_NS_LOCK_2, svc_secure_decrement_ns_lock_2)
+
+/**
+ * \def LIST_SVC_TFM_PARTITION_TEST_CORE
+ *
+ * \brief This is an X macro which lists
+ *        the SVC interface available for
+ *        the TEST_CORE partition. The
+ *        enumerator and corresponding
+ *        SVC handler function need to be
+ *        registered.
+ *
+ */
+#define LIST_SVC_TFM_PARTITION_TEST_CORE \
+    X(SVC_TFM_CORE_TEST, svc_tfm_core_test) \
+    X(SVC_TFM_CORE_TEST_MULTIPLE_CALLS, svc_tfm_core_test_multiple_calls)
+
+/**
+ * \def LIST_SVC_TFM_PARTITION_TEST_SST
+ *
+ * \brief This is an X macro which lists
+ *        the SVC interface available for
+ *        TEST_SST partition. The
+ *        enumerator and corresponding
+ *        SVC handler function need to be
+ *        registered.
+ *
+ */
+#define LIST_SVC_TFM_PARTITION_TEST_SST \
+    X(SVC_SST_TEST_SERVICE_SETUP, sst_test_service_svc_setup) \
+    X(SVC_SST_TEST_SERVICE_DUMMY_ENCRYPT, sst_test_service_svc_dummy_encrypt) \
+    X(SVC_SST_TEST_SERVICE_DUMMY_DECRYPT, sst_test_service_svc_dummy_decrypt) \
+    X(SVC_SST_TEST_SERVICE_CLEAN, sst_test_service_svc_clean)
+
+/**
  * \brief Numbers associated to each SVC available
  *
  * \details Start from 1 as 0 is reserved by RTX
@@ -29,31 +102,24 @@
 enum tfm_svc_num {
     SVC_INVALID = 0,
 
-/* SVC API for SST */
-    SVC_TFM_SST_GET_HANDLE,
-    SVC_TFM_SST_CREATE,
-    SVC_TFM_SST_GET_ATTRIBUTES,
-    SVC_TFM_SST_READ,
-    SVC_TFM_SST_WRITE,
-    SVC_TFM_SST_DELETE,
+#define X(SVC_ENUM, SVC_HANDLER) SVC_ENUM,
+    /* SVC API for Services */
+    LIST_SVC_DISPATCHERS
 
 #if defined(CORE_TEST_INTERACTIVE)
-    SVC_SECURE_DECREMENT_NS_LOCK_1,
-    SVC_SECURE_DECREMENT_NS_LOCK_2,
+    LIST_SVC_CORE_TEST_INTERACTIVE
 #endif /* CORE_TEST_INTERACTIVE */
 
 #if defined(TFM_PARTITION_TEST_CORE)
-    SVC_TFM_CORE_TEST,
-    SVC_TFM_CORE_TEST_MULTIPLE_CALLS,
+    LIST_SVC_TFM_PARTITION_TEST_CORE
 #endif /* TFM_PARTITION_TEST_CORE */
 
 #if defined(TFM_PARTITION_TEST_SST)
-    SVC_SST_TEST_SERVICE_SETUP,
-    SVC_SST_TEST_SERVICE_DUMMY_ENCRYPT,
-    SVC_SST_TEST_SERVICE_DUMMY_DECRYPT,
-    SVC_SST_TEST_SERVICE_CLEAN,
+    LIST_SVC_TFM_PARTITION_TEST_SST
 #endif /* TFM_PARTITION_TEST_SST */
 
+#undef X
+
     /* add all the new entries above this line */
     SVC_TFM_MAX,
 };