diff options
author | Soby Mathew <soby.mathew@arm.com> | 2016-07-04 17:39:34 +0100 |
---|---|---|
committer | Sandrine Bailleux <sandrine.bailleux@arm.com> | 2016-07-14 15:00:55 +0100 |
commit | 87efb3474ac4f168c364d76db26909a1ee1a5207 (patch) | |
tree | dcb771d969d1617c069f3426247a0b4a7bedba1d | |
parent | b9724af4d9244ec6372b6bf5453d07fb2847ab9b (diff) |
Add helper for querying PSCI_FEATURES
This patch adds a new helper `tftf_get_psci_feature_info()` to
query the PSCI_FEATURES API. The tests which used PSCI_FEATURES API
are modified to use this new helper function.
Change-Id: If26e7739eafb6d6c410023e2cdc36f02fbb24823
4 files changed, 24 insertions, 43 deletions
diff --git a/include/lib/tftf_lib.h b/include/lib/tftf_lib.h index 2059934..7e5ede5 100644 --- a/include/lib/tftf_lib.h +++ b/include/lib/tftf_lib.h @@ -74,6 +74,7 @@ int32_t tftf_psci_cpu_on(uint64_t target_cpu, int32_t tftf_psci_cpu_off(void); int32_t tftf_psci_affinity_info(uint64_t target_affinity, uint32_t lowest_affinity_level); +int32_t tftf_get_psci_feature_info(uint32_t psci_func_id); /* * PSCI Helper functions diff --git a/lib/psci/psci.c b/lib/psci/psci.c index 472afc8..d761747 100644 --- a/lib/psci/psci.c +++ b/lib/psci/psci.c @@ -116,6 +116,18 @@ int32_t tftf_psci_affinity_info(uint64_t target_affinity, return ret_vals.ret0; } +int32_t tftf_get_psci_feature_info(uint32_t psci_func_id) +{ + smc64_args args = { + SMC_PSCI_FEATURES, + psci_func_id + }; + smc64_ret_values ret; + + ret = tftf_smc64(&args); + return ret.ret0; +} + int tftf_psci_make_composite_state_id(uint32_t affinity_level, uint32_t state_type, uint32_t *state_id) { @@ -157,13 +169,9 @@ int tftf_psci_make_composite_state_id(uint32_t affinity_level, static unsigned int tftf_psci_get_pstate_format(void) { - smc64_args args = { - SMC_PSCI_FEATURES, - SMC_PSCI_CPU_SUSPEND_AARCH64 - }; - smc64_ret_values ret; + int ret; - ret = tftf_smc64(&args); + ret = tftf_get_psci_feature_info(SMC_PSCI_CPU_SUSPEND_AARCH64); /* * If error is returned, then it probably means that the PSCI version @@ -172,14 +180,14 @@ static unsigned int tftf_psci_get_pstate_format(void) * mandatory API is not implemented which implies that only the * original format is supported. */ - if (ret.ret0 == PSCI_E_NOT_SUPPORTED) + if (ret == PSCI_E_NOT_SUPPORTED) return CPU_SUSPEND_FEAT_PSTATE_FORMAT_ORIGINAL; /* Treat the invalid return value as PSCI FEATURES not supported */ - if ((ret.ret0 & ~CPU_SUSPEND_FEAT_VALID_MASK) != 0) + if ((ret & ~CPU_SUSPEND_FEAT_VALID_MASK) != 0) return CPU_SUSPEND_FEAT_PSTATE_FORMAT_ORIGINAL; - return (ret.ret0 >> CPU_SUSPEND_FEAT_PSTATE_FORMAT_SHIFT) & 0x1; + return (ret >> CPU_SUSPEND_FEAT_PSTATE_FORMAT_SHIFT) & 0x1; } /* Make the power state in the original format */ diff --git a/tests/runtime_services/standard_service/psci/api_tests/psci_features/test_psci_features.c b/tests/runtime_services/standard_service/psci/api_tests/psci_features/test_psci_features.c index db0baac..10a4492 100644 --- a/tests/runtime_services/standard_service/psci/api_tests/psci_features/test_psci_features.c +++ b/tests/runtime_services/standard_service/psci/api_tests/psci_features/test_psci_features.c @@ -34,24 +34,6 @@ #include <tftf_lib.h> /* - * Helper function to query PSCI features. - * Requires the PSCI function ID to query as an argument. - * Returns: Return code of the PSCI_FEATURES call - * (refer to the PSCI specification for details) - */ -static inline int32_t get_psci_feature_info(uint32_t psci_func_id) -{ - smc64_args args = { - SMC_PSCI_FEATURES, - psci_func_id - }; - smc64_ret_values ret; - - ret = tftf_smc64(&args); - return ret.ret0; -} - -/* * @Test_Aim@ Check the list of PSCI functions for PSCI support * * Call PSCI_FEATURES for each PSCI function ID. @@ -69,7 +51,7 @@ test_result_t test_psci_features(void) for (unsigned int i = 0; i < PSCI_NUM_CALLS; i++) { psci_fn = &psci_functions[i]; - ret_flag = get_psci_feature_info(psci_fn->id); + ret_flag = tftf_get_psci_feature_info(psci_fn->id); if (!psci_fn->mandatory) { /* @@ -124,7 +106,7 @@ test_result_t test_psci_features_invalid_id(void) { /* Invalid function ids for negative testing */ uint32_t invalid_psci_func = 0xc400a011; - uint32_t ret_flag = get_psci_feature_info(invalid_psci_func); + uint32_t ret_flag = tftf_get_psci_feature_info(invalid_psci_func); if (ret_flag == PSCI_E_NOT_SUPPORTED) return TEST_RESULT_SUCCESS; diff --git a/tests/runtime_services/standard_service/psci/api_tests/system_suspend/test_psci_system_suspend.c b/tests/runtime_services/standard_service/psci/api_tests/system_suspend/test_psci_system_suspend.c index 06dbdf5..dbb896e 100644 --- a/tests/runtime_services/standard_service/psci/api_tests/system_suspend/test_psci_system_suspend.c +++ b/tests/runtime_services/standard_service/psci/api_tests/system_suspend/test_psci_system_suspend.c @@ -50,6 +50,10 @@ #define SUSPEND_TIME_10_SECS 10000 #define TEST_ITERATION_COUNT 0x5 +/* Helper macro to verify if system suspend API is supported */ +#define is_psci_sys_susp_supported(void) \ + tftf_get_psci_feature_info(SMC_PSCI_SYSTEM_SUSPEND64) + static unsigned int deepest_power_state; static unsigned int test_target_node = PWR_DOMAIN_INIT; static event_t cpu_ready[PLATFORM_CORE_COUNT]; @@ -91,20 +95,6 @@ static int is_sys_suspend_state_ready(void) return 1; } -/* Helper function to verify if system suspend API is supported */ -static test_result_t is_psci_sys_susp_supported(void) -{ - smc64_args args = { - SMC_PSCI_FEATURES, - SMC_PSCI_SYSTEM_SUSPEND64 - }; - - smc64_ret_values ret; - - ret = tftf_smc64(&args); - return ret.ret0; -} - static int suspend_wakeup_handler(void *data) { unsigned int core_pos = platform_get_core_pos(read_mpidr_el1()); |