refactor(smc_fuzzing): add new test function

Adding the new runtestfunction for easier user introduction
of SMC calls and also creating a new top level device tree file
to encapsulate all SMC calls in one structure.  This includes
only SDEI calls currently.

Signed-off-by: mardyk01 <mark.dykes@arm.com>
Change-Id: I4295de564a1114706aa43c373abb7578c68b7cfa
diff --git a/smc_fuzz/src/randsmcmod.c b/smc_fuzz/src/randsmcmod.c
index bbd5edf..f5b614b 100644
--- a/smc_fuzz/src/randsmcmod.c
+++ b/smc_fuzz/src/randsmcmod.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2023, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -11,15 +11,10 @@
 #include "fifo3d.h"
 #include <libfdt.h>
 
-#include <power_management.h>
-#include <sdei.h>
 #include <tftf_lib.h>
-#include <timer.h>
-
-#include <plat_topology.h>
-#include <platform.h>
 
 extern char _binary___dtb_start[];
+extern void runtestfunction(char *funcstr);
 
 struct memmod tmod __aligned(65536) __section("smcfuzz");
 
@@ -408,68 +403,6 @@
 }
 
 /*
- * Running SMC call from what function name is selected
- */
-void runtestfunction(char *funcstr)
-{
-	if (strcmp(funcstr, "sdei_version") == 0) {
-		long long ret = sdei_version();
-		if (ret != MAKE_SDEI_VERSION(1, 0, 0)) {
-			tftf_testcase_printf("Unexpected SDEI version: 0x%llx\n",
-					     ret);
-		}
-		printf("running %s\n", funcstr);
-	}
-	if (strcmp(funcstr, "sdei_pe_unmask") == 0) {
-		long long ret = sdei_pe_unmask();
-		if (ret < 0) {
-			tftf_testcase_printf("SDEI pe unmask failed: 0x%llx\n",
-					     ret);
-		}
-		printf("running %s\n", funcstr);
-	}
-	if (strcmp(funcstr, "sdei_pe_mask") == 0) {
-		int64_t ret = sdei_pe_mask();
-		if (ret < 0) {
-			tftf_testcase_printf("SDEI pe mask failed: 0x%llx\n", ret);
-		}
-		printf("running %s\n", funcstr);
-	}
-	if (strcmp(funcstr, "sdei_event_status") == 0) {
-		int64_t ret = sdei_event_status(0);
-		if (ret < 0) {
-			tftf_testcase_printf("SDEI event status failed: 0x%llx\n",
-					     ret);
-		}
-		printf("running %s\n", funcstr);
-	}
-	if (strcmp(funcstr, "sdei_event_signal") == 0) {
-		int64_t ret = sdei_event_signal(0);
-		if (ret < 0) {
-			tftf_testcase_printf("SDEI event signal failed: 0x%llx\n",
-					     ret);
-		}
-		printf("running %s\n", funcstr);
-	}
-	if (strcmp(funcstr, "sdei_private_reset") == 0) {
-		int64_t ret = sdei_private_reset();
-		if (ret < 0) {
-			tftf_testcase_printf("SDEI private reset failed: 0x%llx\n",
-					     ret);
-		}
-		printf("running %s\n", funcstr);
-	}
-	if (strcmp(funcstr, "sdei_shared_reset") == 0) {
-		int64_t ret = sdei_shared_reset();
-		if (ret < 0) {
-			tftf_testcase_printf("SDEI shared reset failed: 0x%llx\n",
-					     ret);
-		}
-		printf("running %s\n", funcstr);
-	}
-}
-
-/*
  * Function executes a single SMC fuzz test instance with a supplied seed.
  */
 test_result_t smc_fuzzing_instance(uint32_t seed)
diff --git a/smc_fuzz/src/runtestfunction_helpers.c b/smc_fuzz/src/runtestfunction_helpers.c
new file mode 100644
index 0000000..f932a68
--- /dev/null
+++ b/smc_fuzz/src/runtestfunction_helpers.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2023, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+ #include <power_management.h>
+ #include <sdei.h>
+ #include <test_helpers.h>
+ #include <tftf_lib.h>
+ #include <timer.h>
+
+#define CMP_SUCCESS 0
+
+/*
+ * Invoke the SMC call based on the function name specified.
+ */
+void runtestfunction(char *funcstr)
+{
+	if (strcmp(funcstr, "sdei_version") == CMP_SUCCESS) {
+		long long ret = sdei_version();
+
+		if (ret != MAKE_SDEI_VERSION(1, 0, 0)) {
+			tftf_testcase_printf("Unexpected SDEI version: 0x%llx\n",
+					     ret);
+		}
+		printf("running %s\n", funcstr);
+	}
+	if (strcmp(funcstr, "sdei_pe_unmask") == CMP_SUCCESS) {
+		long long ret = sdei_pe_unmask();
+
+		if (ret < 0) {
+			tftf_testcase_printf("SDEI pe unmask failed: 0x%llx\n",
+					     ret);
+		}
+		printf("running %s\n", funcstr);
+	}
+	if (strcmp(funcstr, "sdei_pe_mask") == CMP_SUCCESS) {
+		int64_t ret = sdei_pe_mask();
+
+		if (ret < 0) {
+			tftf_testcase_printf("SDEI pe mask failed: 0x%llx\n", ret);
+		}
+		printf("running %s\n", funcstr);
+	}
+	if (strcmp(funcstr, "sdei_event_status") == CMP_SUCCESS) {
+		int64_t ret = sdei_event_status(0);
+
+		if (ret < 0) {
+			tftf_testcase_printf("SDEI event status failed: 0x%llx\n",
+					     ret);
+		}
+		printf("running %s\n", funcstr);
+	}
+	if (strcmp(funcstr, "sdei_event_signal") == CMP_SUCCESS) {
+		int64_t ret = sdei_event_signal(0);
+
+		if (ret < 0) {
+			tftf_testcase_printf("SDEI event signal failed: 0x%llx\n",
+					     ret);
+		}
+		printf("running %s\n", funcstr);
+	}
+	if (strcmp(funcstr, "sdei_private_reset") == CMP_SUCCESS) {
+		int64_t ret = sdei_private_reset();
+
+		if (ret < 0) {
+			tftf_testcase_printf("SDEI private reset failed: 0x%llx\n",
+					     ret);
+		}
+		printf("running %s\n", funcstr);
+	}
+	if (strcmp(funcstr, "sdei_shared_reset") == CMP_SUCCESS) {
+		int64_t ret = sdei_shared_reset();
+
+		if (ret < 0) {
+			tftf_testcase_printf("SDEI shared reset failed: 0x%llx\n",
+					     ret);
+		}
+		printf("running %s\n", funcstr);
+	}
+}