aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ-Alves <joao.alves@arm.com>2020-06-17 15:37:59 +0100
committerJ-Alves <joao.alves@arm.com>2020-06-19 11:36:41 +0100
commit9f6f01476c93631455f2a50096574dd98505e830 (patch)
tree65d13a6ff55542e4a3cd511beac65b4e02e1c4d7
parent8f08a05490ed3ce474cc821297929bf8df5691d2 (diff)
downloadtf-a-tests-9f6f01476c93631455f2a50096574dd98505e830.tar.gz
Cactus: FFA Version Test
Added simple test of the FFA interface to cactus: - FFA version ABI helper; - New test file for test to FFA ABIs; - Invoking "ffa_tests" from cactus main. Signed-off-by: J-Alves <joao.alves@arm.com> Change-Id: I8c8445ad6d9da79f1880d143836e7a6da68eaff7
-rw-r--r--spm/cactus/cactus.mk1
-rw-r--r--spm/cactus/cactus_ffa_tests.c41
-rw-r--r--spm/cactus/cactus_main.c20
-rw-r--r--spm/cactus/cactus_tests.h7
-rw-r--r--spm/cactus/ffa_helpers.h11
5 files changed, 71 insertions, 9 deletions
diff --git a/spm/cactus/cactus.mk b/spm/cactus/cactus.mk
index a32d3d3..a32b713 100644
--- a/spm/cactus/cactus.mk
+++ b/spm/cactus/cactus.mk
@@ -25,6 +25,7 @@ CACTUS_SOURCES := \
$(addprefix spm/cactus/, \
aarch64/cactus_entrypoint.S \
cactus_debug.c \
+ cactus_ffa_tests.c \
cactus_main.c \
) \
$(addprefix spm/common/, \
diff --git a/spm/cactus/cactus_ffa_tests.c b/spm/cactus/cactus_ffa_tests.c
new file mode 100644
index 0000000..2143e75
--- /dev/null
+++ b/spm/cactus/cactus_ffa_tests.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+#include <assert.h>
+#include <errno.h>
+#include <debug.h>
+#include "ffa_helpers.h"
+#include <sp_helpers.h>
+
+/* FFA version test helpers */
+#define FFA_MAJOR 1U
+#define FFA_MINOR 0U
+
+void ffa_tests(void)
+{
+ const char *test_ffa = "FFA Interfaces";
+ const char *test_ffa_version = "FFA Version interface";
+
+ announce_test_section_start(test_ffa);
+
+ announce_test_start(test_ffa_version);
+
+ smc_ret_values ret = ffa_version(MAKE_FFA_VERSION(FFA_MAJOR, FFA_MINOR));
+ uint32_t spm_version = (uint32_t)(0xFFFFFFFF & ret.ret0);
+
+ bool ffa_version_compatible = ((spm_version >> FFA_VERSION_MAJOR_SHIFT) == FFA_MAJOR &&
+ (FFA_VERSION_MINOR_MASK & spm_version) >= FFA_MINOR);
+
+ NOTICE("FFA_VERSION returned %u.%u; Compatible: %i\n",
+ spm_version >> FFA_VERSION_MAJOR_SHIFT,
+ spm_version & FFA_VERSION_MINOR_MASK,
+ (int)ffa_version_compatible);
+
+ expect((int)ffa_version_compatible, (int)true);
+
+ announce_test_end(test_ffa_version);
+
+ announce_test_section_end(test_ffa);
+}
diff --git a/spm/cactus/cactus_main.c b/spm/cactus/cactus_main.c
index d5d923d..1508d98 100644
--- a/spm/cactus/cactus_main.c
+++ b/spm/cactus/cactus_main.c
@@ -5,21 +5,22 @@
*/
#include <assert.h>
+#include <errno.h>
+
+#include "cactus.h"
+#include "cactus_def.h"
+#include "cactus_tests.h"
#include <debug.h>
#include <drivers/arm/pl011.h>
#include <drivers/console.h>
-#include <errno.h>
+#include "ffa_helpers.h"
#include <lib/aarch64/arch_helpers.h>
-#include <lib/xlat_tables/xlat_tables_v2.h>
#include <lib/xlat_tables/xlat_mmu_helpers.h>
-#include <plat_arm.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+#include <std_svc.h>
#include <plat/common/platform.h>
+#include <plat_arm.h>
#include <platform_def.h>
-#include <std_svc.h>
-
-#include "cactus.h"
-#include "cactus_def.h"
-#include "ffa_helpers.h"
/* Host machine information injected by the build system in the ELF file. */
extern const char build_message[];
@@ -187,6 +188,9 @@ void __dead2 cactus_main(void)
NOTICE("FFA id: %u\n", ffa_id);
cactus_print_memory_layout(ffa_id);
+ /* Invoking Tests */
+ ffa_tests();
+
/* End up to message loop */
message_loop(ffa_id);
diff --git a/spm/cactus/cactus_tests.h b/spm/cactus/cactus_tests.h
index f4bcb7e..23586f5 100644
--- a/spm/cactus/cactus_tests.h
+++ b/spm/cactus/cactus_tests.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -12,6 +12,11 @@
*/
/*
+ * Test to FFA interfaces.
+ */
+void ffa_tests(void);
+
+/*
* Test other things like the version number returned by SPM.
*/
void misc_tests(void);
diff --git a/spm/cactus/ffa_helpers.h b/spm/cactus/ffa_helpers.h
index 8f6beb4..8fdf727 100644
--- a/spm/cactus/ffa_helpers.h
+++ b/spm/cactus/ffa_helpers.h
@@ -105,4 +105,15 @@ static inline smc_ret_values ffa_error(int32_t error_code)
return tftf_smc(&args);
}
+/* FFA Version ABI helper */
+static inline smc_ret_values ffa_version(uint32_t input_version)
+{
+ smc_args args = {
+ .fid = FFA_VERSION,
+ .arg1 = input_version
+ };
+
+ return tftf_smc(&args);
+}
+
#endif /* __FFA_HELPERS_H__ */