[SPM] tidying common code to tftf and cactus
This patch moves the code used to test SPM functionality, not explicitly
described in FF-A specification, from ffa_helpers to spm_common which is
built for both tftf and cactus.
Signed-off-by: Max Shvetsov <maksims.svecovs@arm.com>
Change-Id: I461efad977cc4d02701feea7b2215a61453716ef
diff --git a/spm/cactus/cactus.mk b/spm/cactus/cactus.mk
index 4b3f0bd..4a9cfcc 100644
--- a/spm/cactus/cactus.mk
+++ b/spm/cactus/cactus.mk
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+# Copyright (c) 2018-2021, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -46,6 +46,7 @@
tftf/framework/debug.c \
tftf/framework/${ARCH}/asm_debug.S \
tftf/tests/runtime_services/secure_service/ffa_helpers.c \
+ tftf/tests/runtime_services/secure_service/spm_common.c \
tftf/framework/${ARCH}/exceptions.S \
tftf/framework/${ARCH}/exception_report.c
diff --git a/spm/cactus/cactus_ffa_tests.c b/spm/cactus/cactus_ffa_tests.c
index 5863456..a5acc56 100644
--- a/spm/cactus/cactus_ffa_tests.c
+++ b/spm/cactus/cactus_ffa_tests.c
@@ -1,16 +1,17 @@
/*
- * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <assert.h>
#include <debug.h>
#include <errno.h>
-#include <cactus_platform_def.h>
+
#include <cactus_def.h>
+#include <cactus_platform_def.h>
#include <ffa_endpoints.h>
-#include <ffa_helpers.h>
#include <sp_helpers.h>
+#include <spm_common.h>
#include <lib/libc/string.h>
#include <lib/xlat_tables/xlat_tables_v2.h>
@@ -24,39 +25,6 @@
static const uint32_t tertiary_uuid[4] = TERTIARY_UUID;
static const uint32_t null_uuid[4] = {0};
-struct feature_test {
- const char *test_name;
- unsigned int feature;
- unsigned int expected_ret;
-};
-
-static const struct feature_test test_target[] = {
- {"FFA_ERROR_32 check", FFA_ERROR, FFA_SUCCESS_SMC32},
- {"FFA_SUCCESS_32 check", FFA_SUCCESS_SMC32, FFA_SUCCESS_SMC32},
- {"FFA_INTERRUPT_32 check", FFA_INTERRUPT, FFA_SUCCESS_SMC32},
- {"FFA_VERSION_32 check", FFA_VERSION, FFA_SUCCESS_SMC32},
- {"FFA_FEATURES_32 check", FFA_FEATURES, FFA_SUCCESS_SMC32},
- {"FFA_RX_RELEASE_32 check", FFA_RX_RELEASE, FFA_SUCCESS_SMC32},
- {"FFA_RXTX_MAP_32 check", FFA_RXTX_MAP_SMC32, FFA_ERROR},
- {"FFA_RXTX_MAP_64 check", FFA_RXTX_MAP_SMC64, FFA_SUCCESS_SMC32},
- {"FFA_RXTX_UNMAP_32 check", FFA_RXTX_UNMAP, FFA_ERROR},
- {"FFA_PARTITION_INFO_GET_32 check", FFA_PARTITION_INFO_GET, FFA_SUCCESS_SMC32},
- {"FFA_ID_GET_32 check", FFA_ID_GET, FFA_SUCCESS_SMC32},
- {"FFA_MSG_POLL_32 check", FFA_MSG_POLL, FFA_SUCCESS_SMC32},
- {"FFA_MSG_WAIT_32 check", FFA_MSG_WAIT, FFA_SUCCESS_SMC32},
- {"FFA_YIELD_32 check", FFA_MSG_YIELD, FFA_SUCCESS_SMC32},
- {"FFA_RUN_32 check", FFA_MSG_RUN, FFA_SUCCESS_SMC32},
- {"FFA_MSG_SEND_32 check", FFA_MSG_SEND, FFA_SUCCESS_SMC32},
- {"FFA_MEM_DONATE_32 check", FFA_MEM_DONATE_SMC32, FFA_SUCCESS_SMC32},
- {"FFA_MEM_LEND_32 check", FFA_MEM_LEND_SMC32, FFA_SUCCESS_SMC32},
- {"FFA_MEM_SHARE_32 check", FFA_MEM_SHARE_SMC32, FFA_SUCCESS_SMC32},
- {"FFA_MEM_RETRIEVE_REQ_32 check", FFA_MEM_RETRIEVE_REQ_SMC32, FFA_SUCCESS_SMC32},
- {"FFA_MEM_RETRIEVE_RESP_32 check", FFA_MEM_RETRIEVE_RESP, FFA_SUCCESS_SMC32},
- {"FFA_MEM_RELINQUISH_32 check", FFA_MEM_RELINQUISH, FFA_SUCCESS_SMC32},
- {"FFA_MEM_RECLAIM_32 check", FFA_MEM_RECLAIM, FFA_SUCCESS_SMC32},
- {"Check non-existent command", 0xFFFF, FFA_ERROR}
-};
-
/*
* Test FFA_FEATURES interface.
*/
@@ -64,21 +32,23 @@
{
const char *test_features = "FFA Features interface";
smc_ret_values ffa_ret;
+ const struct ffa_features_test *ffa_feature_test_target;
unsigned int i, test_target_size =
- sizeof(test_target) / sizeof(struct feature_test);
+ get_ffa_feature_test_target(&ffa_feature_test_target);
+
announce_test_section_start(test_features);
for (i = 0U; i < test_target_size; i++) {
- announce_test_start(test_target[i].test_name);
+ announce_test_start(ffa_feature_test_target[i].test_name);
- ffa_ret = ffa_features(test_target[i].feature);
- expect(ffa_ret.ret0, test_target[i].expected_ret);
- if (test_target[i].expected_ret == FFA_ERROR) {
+ ffa_ret = ffa_features(ffa_feature_test_target[i].feature);
+ expect(ffa_ret.ret0, ffa_feature_test_target[i].expected_ret);
+ if (ffa_feature_test_target[i].expected_ret == FFA_ERROR) {
expect(ffa_ret.ret2, FFA_ERROR_NOT_SUPPORTED);
}
- announce_test_end(test_target[i].test_name);
+ announce_test_end(ffa_feature_test_target[i].test_name);
}
announce_test_section_end(test_features);
diff --git a/spm/cactus/cactus_main.c b/spm/cactus/cactus_main.c
index e1bfd1f..1d81988 100644
--- a/spm/cactus/cactus_main.c
+++ b/spm/cactus/cactus_main.c
@@ -1,30 +1,29 @@
/*
- * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <assert.h>
#include <errno.h>
-
-#include "cactus.h"
-#include "cactus_def.h"
-#include <cactus_platform_def.h>
-#include "cactus_tests.h"
#include <debug.h>
+
+#include <cactus_platform_def.h>
+#include <cactus_test_cmds.h>
#include <drivers/arm/pl011.h>
#include <drivers/console.h>
-#include <ffa_helpers.h>
#include <lib/aarch64/arch_helpers.h>
#include <lib/xlat_tables/xlat_mmu_helpers.h>
#include <lib/xlat_tables/xlat_tables_v2.h>
+#include <plat_arm.h>
+#include <plat/common/platform.h>
+#include <platform_def.h>
#include <sp_helpers.h>
#include <std_svc.h>
-#include <plat/common/platform.h>
-#include <plat_arm.h>
-#include <platform_def.h>
-#include <cactus_test_cmds.h>
+#include "cactus_def.h"
+#include "cactus_tests.h"
+#include "cactus.h"
/* Host machine information injected by the build system in the ELF file. */
extern const char build_message[];
diff --git a/spm/cactus/cactus_tests.h b/spm/cactus/cactus_tests.h
index fd229bf..8e838cc 100644
--- a/spm/cactus/cactus_tests.h
+++ b/spm/cactus/cactus_tests.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -7,7 +7,7 @@
#ifndef CACTUS_TESTS_H
#define CACTUS_TESTS_H
-#include <ffa_helpers.h>
+#include <spm_common.h>
/*
* Test functions