feat(amd): add test for TF-A feature check API
Add test for the tf_a_feature_check API within the TF-A test
framework. The purpose of this test is retrieve the supported
API Version.
Change-Id: I3d03661aec29814132d2635e7187442fb52af067
Signed-off-by: Madhav Bhatt <madhav.bhatt@amd.com>
diff --git a/tftf/tests/plat/amd/common/common_files/eemi_api.c b/tftf/tests/plat/amd/common/common_files/eemi_api.c
index 3f0a407..529c755 100644
--- a/tftf/tests/plat/amd/common/common_files/eemi_api.c
+++ b/tftf/tests/plat/amd/common/common_files/eemi_api.c
@@ -414,3 +414,15 @@
return ret;
}
+
+int tf_a_feature_check(const uint32_t api_id, uint32_t *const version)
+{
+ uint32_t ret_payload[PAYLOAD_ARG_CNT];
+ int ret;
+
+ ret = eemi_call(TF_A_FEATURE_CHECK, api_id, 0, 0, 0, 0, 0, 0, ret_payload);
+ if (ret == PM_RET_SUCCESS)
+ *version = ret_payload[1];
+
+ return ret;
+}
diff --git a/tftf/tests/plat/amd/common/common_files/eemi_api.h b/tftf/tests/plat/amd/common/common_files/eemi_api.h
index d51b496..3e460fe 100644
--- a/tftf/tests/plat/amd/common/common_files/eemi_api.h
+++ b/tftf/tests/plat/amd/common/common_files/eemi_api.h
@@ -65,5 +65,6 @@
const uint32_t param_val);
int xpm_init_finalize(void);
int get_trustzone_version(uint32_t *tz_version);
+int tf_a_feature_check(const uint32_t api_id, uint32_t *const version);
#endif /* __EEMI_API_H__ */
diff --git a/tftf/tests/plat/amd/common/common_files/xpm_defs.h b/tftf/tests/plat/amd/common/common_files/xpm_defs.h
index 2551110..502c5f2 100644
--- a/tftf/tests/plat/amd/common/common_files/xpm_defs.h
+++ b/tftf/tests/plat/amd/common/common_files/xpm_defs.h
@@ -29,6 +29,7 @@
#define PM_ERR_VERSION 2014L
/* TF-A only commands */
+#define TF_A_FEATURE_CHECK 0xa00U
#define PM_GET_CALLBACK_DATA 0xa01U
#define PM_GET_TRUSTZONE_VERSION 0xa03U
#define TF_A_PM_REGISTER_SGI 0xa04U
diff --git a/tftf/tests/plat/amd/common/tf_a_feature_check/tf_a_feature_check.c b/tftf/tests/plat/amd/common/tf_a_feature_check/tf_a_feature_check.c
new file mode 100644
index 0000000..1eea396
--- /dev/null
+++ b/tftf/tests/plat/amd/common/tf_a_feature_check/tf_a_feature_check.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2025, Advanced Micro Devices, Inc. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "eemi_api.h"
+#include "xpm_defs.h"
+
+int api_id_list[] = {
+ PM_GET_CALLBACK_DATA,
+ PM_GET_TRUSTZONE_VERSION,
+ TF_A_PM_REGISTER_SGI,
+ TF_A_FEATURE_CHECK,
+};
+
+/*
+ * This function tests the behavior of the tf_a_feature_check() function, which
+ * retrieves the supported API Version.
+ */
+test_result_t test_tf_a_feature_check(void)
+{
+ uint32_t version = 0U;
+ int32_t status, index;
+
+ for (index = 0; index < ARRAY_SIZE(api_id_list); index++) {
+ status = tf_a_feature_check(api_id_list[index], &version);
+
+ if (status != PM_RET_SUCCESS) {
+ tftf_testcase_printf("%s ERROR fetching the supported version for %x, "
+ "Status: 0x%x\n", __func__, api_id_list[index],
+ status);
+ return TEST_RESULT_FAIL;
+ }
+
+ tftf_testcase_printf("Api Id: 0x%x Version: %u Status: %s\n\n",
+ api_id_list[index], version,
+ ((status == 0U) ? "Supported" : "Not Supported"));
+ }
+
+ return TEST_RESULT_SUCCESS;
+}
diff --git a/tftf/tests/tests-versal.xml b/tftf/tests/tests-versal.xml
index 8dbf3d0..a70b2c0 100644
--- a/tftf/tests/tests-versal.xml
+++ b/tftf/tests/tests-versal.xml
@@ -30,6 +30,7 @@
<testcase name="Set pin parameter without requesting pin" function="test_set_pin_parameter_of_unrequested_pin" />
<testcase name="PM Init Finalize" function="test_init_finalize" />
<testcase name="Trustzone version" function="test_trustzone_version" />
+ <testcase name="TF-A feature check" function="test_tf_a_feature_check" />
</testsuite>
</testsuites>