diff options
-rw-r--r-- | spm/cactus/cactus.mk | 1 | ||||
-rw-r--r-- | spm/cactus/cactus_ffa_tests.c | 41 | ||||
-rw-r--r-- | spm/cactus/cactus_main.c | 20 | ||||
-rw-r--r-- | spm/cactus/cactus_tests.h | 7 | ||||
-rw-r--r-- | spm/cactus/ffa_helpers.h | 11 |
5 files changed, 71 insertions, 9 deletions
diff --git a/spm/cactus/cactus.mk b/spm/cactus/cactus.mk index a32d3d38a..a32b7130e 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 000000000..2143e7535 --- /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 d5d923d16..1508d9839 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 f4bcb7e32..23586f51a 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 8f6beb446..8fdf727e6 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__ */ |