SPM: TFTF test of FFA_VERSION interface

Implemented test to FFA_VERSION interface:
- "test_ffa_version.c" contains functions to test FFA_VERSION ABI;
- Test suite for FFA_VERSION ABI in tests-spm.xml;
- Helper macros changed in "ffa_helpers.h".

Signed-off-by: J-Alves <joao.alves@arm.com>
Change-Id: I6b0e937e30fceaa21a57c4ba0761a62049b16c0d
diff --git a/include/common/test_helpers.h b/include/common/test_helpers.h
index 33fce53..bf14a80 100644
--- a/include/common/test_helpers.h
+++ b/include/common/test_helpers.h
@@ -7,15 +7,16 @@
 #ifndef __TEST_HELPERS_H__
 #define __TEST_HELPERS_H__
 
+#include <uuid.h>
 #include <arch_features.h>
-#include <plat_topology.h>
-#include <psci.h>
+#include <ffa_helpers.h>
 #include <ffa_svc.h>
+#include <psci.h>
 #include <tftf_lib.h>
 #include <trusted_os.h>
 #include <tsp.h>
-#include <uuid.h>
 #include <uuid_utils.h>
+#include <plat_topology.h>
 
 typedef struct {
 	uintptr_t addr;
@@ -148,41 +149,42 @@
 		}								\
 										\
 		if (version < MM_VERSION_FORM(major, minor)) {			\
-			tftf_testcase_printf("MM_VERSION returned %d.%d\n"	\
-					     "The required version is %d.%d\n",	\
-					     version >> MM_VERSION_MAJOR_SHIFT,	\
-					     version & MM_VERSION_MINOR_MASK,	\
-					     major, minor);			\
+			tftf_testcase_printf("MM_VERSION returned %u.%u\n"	\
+					"The required version is %u.%u\n",	\
+					version >> MM_VERSION_MAJOR_SHIFT,	\
+					version & MM_VERSION_MINOR_MASK,	\
+					major, minor);				\
 			return TEST_RESULT_SKIPPED;				\
 		}								\
 										\
-		VERBOSE("MM_VERSION returned %d.%d\n",				\
+		VERBOSE("MM_VERSION returned %u.%u\n",				\
 			version >> MM_VERSION_MAJOR_SHIFT,			\
 			version & MM_VERSION_MINOR_MASK);			\
 	} while (0)
 
 #define SKIP_TEST_IF_FFA_VERSION_LESS_THAN(major, minor)			\
 	do {									\
-		smc_args version_smc = { FFA_VERSION };			\
-		smc_ret_values smc_ret = tftf_smc(&version_smc);		\
-		uint32_t version = smc_ret.ret2;				\
+		smc_ret_values smc_ret = ffa_version(				\
+					MAKE_FFA_VERSION(major, minor));	\
+		uint32_t version = smc_ret.ret0;				\
 										\
-		if (smc_ret.ret0 != FFA_SUCCESS_SMC32) {			\
-			tftf_testcase_printf("SPM not detected.\n");		\
+		if (version == FFA_ERROR_NOT_SUPPORTED) {			\
+			tftf_testcase_printf("FFA_VERSION not supported.\n");	\
 			return TEST_RESULT_SKIPPED;				\
 		}								\
-                                                                                \
-		if ((version & FFA_VERSION_BIT31_MASK) != 0) {                 \
-			tftf_testcase_printf("FFA_VERSION bad response.\n");	\
-			return TEST_RESULT_SKIPPED;                             \
-		}                                                               \
 										\
-		if (version < MAKE_FFA_VERSION(major, minor)) {		\
-			tftf_testcase_printf("FFA_VERSION returned %d.%d\n"	\
-					     "The required version is %d.%d\n",	\
-					     version >> FFA_VERSION_MAJOR_SHIFT,\
-					     version & FFA_VERSION_MINOR_MASK,	\
-					     major, minor);			\
+		if ((version & FFA_VERSION_BIT31_MASK) != 0U) {				\
+			tftf_testcase_printf("FFA_VERSION bad response: %x\n",	\
+					version);				\
+			return TEST_RESULT_FAIL;				\
+		}								\
+										\
+		if (version < MAKE_FFA_VERSION(major, minor)) {			\
+			tftf_testcase_printf("FFA_VERSION returned %u.%u\n"	\
+					"The required version is %u.%u\n",	\
+					version >> FFA_VERSION_MAJOR_SHIFT,	\
+					version & FFA_VERSION_MINOR_MASK,	\
+					major, minor);				\
 			return TEST_RESULT_SKIPPED;				\
 		}								\
 	} while (0)
@@ -202,12 +204,12 @@
 
 /* Helper macro to verify if system suspend API is supported */
 #define is_psci_sys_susp_supported()	\
-		(tftf_get_psci_feature_info(SMC_PSCI_SYSTEM_SUSPEND)	\
+		(tftf_get_psci_feature_info(SMC_PSCI_SYSTEM_SUSPEND)		\
 					== PSCI_E_SUCCESS)
 
 /* Helper macro to verify if PSCI_STAT_COUNT API is supported */
 #define is_psci_stat_count_supported()	\
-		(tftf_get_psci_feature_info(SMC_PSCI_STAT_COUNT)	\
+		(tftf_get_psci_feature_info(SMC_PSCI_STAT_COUNT)		\
 					== PSCI_E_SUCCESS)
 
 /*