App, Test: Updates for thread mode NS-S transition

 - Remove the SVC call framework from the non-secure
 - Update the S and NS tests to work with the new concept
 - Update documentation to reflect changes

Change-Id: Iac4e1b7d11f264f1905e71a81a1d622421ea5d6d
Signed-off-by: Mate Toth-Pal <mate.toth-pal@arm.com>
diff --git a/interface/src/tfm_ns_lock_rtx.c b/interface/src/tfm_ns_lock_rtx.c
index 5ec6638..ef6cfe0 100644
--- a/interface/src/tfm_ns_lock_rtx.c
+++ b/interface/src/tfm_ns_lock_rtx.c
@@ -11,7 +11,7 @@
 #include "cmsis_os2.h"
 
 #include "tfm_api.h"
-#include "tfm_ns_svc.h"
+#include "tfm_ns_lock.h"
 
 /**
  * \brief struct ns_lock_state type
@@ -36,86 +36,27 @@
 };
 
 /**
- * \def TFM_SVC_DISPATCH_NAME
- *
- * \brief Macro to declare a SVC dispatch function name
- */
-#define TFM_SVC_DISPATCH_NAME(SVC_ENUM) tfm_svc_dispatch_##SVC_ENUM
-
-/**
- * \def TFM_SVC_DISPATCH_FUNCTION
- *
- * \brief Macro to declare a SVC dispatch naked function body (4 bytes each)
- */
-#define TFM_SVC_DISPATCH_FUNCTION(SVC_ENUM) \
-    __attribute__((naked)) \
-    static uint32_t TFM_SVC_DISPATCH_NAME(SVC_ENUM)(uint32_t arg0, \
-                                                    uint32_t arg1, \
-                                                    uint32_t arg2, \
-                                                    uint32_t arg3) \
-    { \
-        SVC(SVC_ENUM); \
-        __ASM("BX LR"); \
-    }
-
-/**
- * \brief Naked functions associated to each
- *        SVC in the list of X macros
- *        \ref LIST_SVC_DISPATCHERS
- */
-#define X(SVC_ENUM, SVC_HANDLER) TFM_SVC_DISPATCH_FUNCTION(SVC_ENUM);
-LIST_SVC_DISPATCHERS
-#undef X
-
-/**
- * \brief Array with function pointers to the
- *        naked functions. Entry 0 is treated
- *        as invalid. The other entries are
- *        taken automatically from the list of
- *        X macros \ref LIST_SVC_DISPATCHERS
- */
-static void *tfm_svc_dispatch_functions[] = {
-    (void *) NULL, /* SVC_INVALID */
-#define X(SVC_ENUM, SVC_HANDLER) (void *)TFM_SVC_DISPATCH_NAME(SVC_ENUM),
-    LIST_SVC_DISPATCHERS
-#undef X
-};
-
-/**
  * \brief NS world, NS lock based dispatcher
  */
-uint32_t tfm_ns_lock_svc_dispatch(enum tfm_svc_num svc_num,
-                                  uint32_t arg0,
-                                  uint32_t arg1,
-                                  uint32_t arg2,
-                                  uint32_t arg3)
+uint32_t tfm_ns_lock_dispatch(veneer_fn fn,
+                              uint32_t arg0, uint32_t arg1,
+                              uint32_t arg2, uint32_t arg3)
 {
     uint32_t result;
-    uint32_t (*tfm_svc_dispatch_function_p)(uint32_t, uint32_t,
-                                            uint32_t, uint32_t);
-
-    const uint32_t num_svc_dispatchers =
-      sizeof(tfm_svc_dispatch_functions)/sizeof(tfm_svc_dispatch_functions[0]);
 
     /* Check the NS lock has been initialized */
     if (ns_lock.init == false) {
         return TFM_ERROR_GENERIC;
     }
 
-    /* Validate the SVC number requested */
-    if ((svc_num > SVC_INVALID) && (svc_num < num_svc_dispatchers)) {
-        tfm_svc_dispatch_function_p = tfm_svc_dispatch_functions[svc_num];
+    /* TFM request protected by NS lock */
+    osMutexAcquire(ns_lock.id,osWaitForever);
 
-        /* TFM request protected by NS lock */
-        osMutexAcquire(ns_lock.id,osWaitForever);
-        result = (*tfm_svc_dispatch_function_p)(arg0, arg1, arg2, arg3);
-        osMutexRelease(ns_lock.id);
+    result = fn(arg0, arg1, arg2, arg3);
 
-        return result;
-    }
-    else {
-        return TFM_ERROR_GENERIC;
-    }
+    osMutexRelease(ns_lock.id);
+
+    return result;
 }
 
 /**
@@ -132,3 +73,9 @@
         return TFM_ERROR_GENERIC;
     }
 }
+
+bool tfm_ns_lock_get_init_state()
+{
+    return ns_lock.init;
+}
+