aboutsummaryrefslogtreecommitdiff
path: root/tftf
diff options
context:
space:
mode:
authorManish V Badarkhe <Manish.Badarkhe@arm.com>2020-04-28 17:59:32 +0100
committerManish V Badarkhe <Manish.Badarkhe@arm.com>2020-04-29 18:10:11 +0100
commitbc93a34c0db8adc674450b3452868ff3a1ec7503 (patch)
tree6b6acd48039dd7808c0e632fcbc2acb73b12b4e6 /tftf
parent705f66bd03095c14e76342c90e30fa3b76671951 (diff)
downloadtf-a-tests-bc93a34c0db8adc674450b3452868ff3a1ec7503.tar.gz
Add test case for SMCCC_ARCH_SOC_ID feature
Added test case for "SMCCC_ARCH_SOC_ID" SMC call. This SMC call is used to retrieve SOC version and SOC revision Test execution output is as below: > Executing 'SMCCC_ARCH_SOC_ID test' TEST COMPLETE Passed SOC Rev is not implemented SOC Ver = 0x43b0000 Signed-off-by: Manish V Badarkhe <Manish.Badarkhe@arm.com> Change-Id: I48668ce22bb5d5767dadb42ce9526d77fd916bed
Diffstat (limited to 'tftf')
-rw-r--r--tftf/tests/runtime_services/arm_arch_svc/smccc_arch_soc_id.c98
-rw-r--r--tftf/tests/tests-cpu-extensions.mk3
-rw-r--r--tftf/tests/tests-cpu-extensions.xml3
3 files changed, 102 insertions, 2 deletions
diff --git a/tftf/tests/runtime_services/arm_arch_svc/smccc_arch_soc_id.c b/tftf/tests/runtime_services/arm_arch_svc/smccc_arch_soc_id.c
new file mode 100644
index 00000000..b866450d
--- /dev/null
+++ b/tftf/tests/runtime_services/arm_arch_svc/smccc_arch_soc_id.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2020, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <arch_helpers.h>
+#include <arm_arch_svc.h>
+#include <debug.h>
+#include <smccc.h>
+#include <string.h>
+#include <tftf_lib.h>
+
+/*
+ * Return SOC ID parameters(SOC revision/SOC version) according
+ * to argument passed
+ */
+static smc_ret_values get_soc_id_param(u_register_t arg)
+{
+ smc_args args;
+ smc_ret_values ret;
+
+ memset(&args, 0, sizeof(args));
+ args.fid = SMCCC_ARCH_SOC_ID;
+ args.arg1 = arg;
+ ret = tftf_smc(&args);
+
+ return ret;
+}
+
+/* Entry function to execute SMCCC_ARCH_SOC_ID test */
+test_result_t test_smccc_arch_soc_id(void)
+{
+ smc_args args;
+ smc_ret_values ret;
+ int32_t expected_ver;
+ int32_t skip_cnt = 0;
+ bool fail_soc_id_test = false;
+
+ /* Check if SMCCC version is at least v1.2 */
+ expected_ver = MAKE_SMCCC_VERSION(1, 2);
+ memset(&args, 0, sizeof(args));
+ args.fid = SMCCC_VERSION;
+ ret = tftf_smc(&args);
+ if ((int32_t)ret.ret0 < expected_ver) {
+ tftf_testcase_printf("Unexpected SMCCC version: 0x%x\n",
+ (int)ret.ret0);
+ return TEST_RESULT_SKIPPED;
+ }
+
+ /* Check if SMCCC_ARCH_SOC_ID is implemented or not */
+ memset(&args, 0, sizeof(args));
+ args.fid = SMCCC_ARCH_FEATURES;
+ args.arg1 = SMCCC_ARCH_SOC_ID;
+ ret = tftf_smc(&args);
+ if ((int)ret.ret0 == SMC_ARCH_CALL_NOT_SUPPORTED) {
+ tftf_testcase_printf("SMCCC_ARCH_SOC_ID is not implemented\n");
+ return TEST_RESULT_FAIL;
+ }
+
+ /* If the call returns SMC_OK then SMCCC_ARCH_SOC_ID is feature available */
+ if ((int)ret.ret0 == SMC_OK) {
+ ret = get_soc_id_param(SMC_GET_SOC_REVISION);
+
+ if ((int)ret.ret0 == SMC_ARCH_CALL_INVAL_PARAM) {
+ ERROR("Invalid param passed to SMCCC_ARCH_SOC_ID\n");
+ fail_soc_id_test = true;
+ } else if ((int)ret.ret0 == SMC_ARCH_CALL_NOT_SUPPORTED) {
+ tftf_testcase_printf("SOC Rev is not implemented\n");
+ skip_cnt++;
+ } else {
+ tftf_testcase_printf("SOC Rev = 0x%x\n", (int)ret.ret0);
+ }
+
+ ret = get_soc_id_param(SMC_GET_SOC_VERSION);
+
+ if ((int)ret.ret0 == SMC_ARCH_CALL_INVAL_PARAM) {
+ ERROR("Invalid param passed to SMCCC_ARCH_SOC_ID\n");
+ fail_soc_id_test = true;
+ } else if ((int)ret.ret0 == SMC_ARCH_CALL_NOT_SUPPORTED) {
+ tftf_testcase_printf("SOC Ver is not implemented\n");
+ skip_cnt++;
+ } else {
+ tftf_testcase_printf("SOC Ver = 0x%x\n", (int)ret.ret0);
+ }
+
+ if (skip_cnt == 2)
+ return TEST_RESULT_SKIPPED;
+ else if (fail_soc_id_test)
+ return TEST_RESULT_FAIL;
+ } else {
+ ERROR("Invalid error during SMCCC_ARCH_FEATURES call = 0x%x\n",
+ (int)ret.ret0);
+ return TEST_RESULT_FAIL;
+ }
+
+ return TEST_RESULT_SUCCESS;
+}
diff --git a/tftf/tests/tests-cpu-extensions.mk b/tftf/tests/tests-cpu-extensions.mk
index 9102b351..1b7743e1 100644
--- a/tftf/tests/tests-cpu-extensions.mk
+++ b/tftf/tests/tests-cpu-extensions.mk
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+# Copyright (c) 2018-2020, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -11,5 +11,6 @@ TESTS_SOURCES += $(addprefix tftf/tests/, \
extensions/sve/test_sve.c \
runtime_services/arm_arch_svc/smccc_arch_workaround_1.c \
runtime_services/arm_arch_svc/smccc_arch_workaround_2.c \
+ runtime_services/arm_arch_svc/smccc_arch_soc_id.c \
extensions/pauth/test_pauth.c \
)
diff --git a/tftf/tests/tests-cpu-extensions.xml b/tftf/tests/tests-cpu-extensions.xml
index 158cb04f..aff6b61e 100644
--- a/tftf/tests/tests-cpu-extensions.xml
+++ b/tftf/tests/tests-cpu-extensions.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
- Copyright (c) 2018-2019, Arm Limited. All rights reserved.
+ Copyright (c) 2018-2020, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
-->
@@ -23,6 +23,7 @@
<testsuite name="ARM_ARCH_SVC" description="Arm Architecture Service tests">
<testcase name="SMCCC_ARCH_WORKAROUND_1 test" function="test_smccc_arch_workaround_1" />
<testcase name="SMCCC_ARCH_WORKAROUND_2 test" function="test_smccc_arch_workaround_2" />
+ <testcase name="SMCCC_ARCH_SOC_ID test" function="test_smccc_arch_soc_id" />
</testsuite>
</testsuites>