diff options
-rw-r--r-- | include/common/test_helpers.h | 2 | ||||
-rw-r--r-- | include/runtime_services/cactus_test_cmds.h | 19 | ||||
-rw-r--r-- | spm/cactus/cactus_tests/cactus_message_loop.c | 42 |
3 files changed, 59 insertions, 4 deletions
diff --git a/include/common/test_helpers.h b/include/common/test_helpers.h index 9031b34..eaea72c 100644 --- a/include/common/test_helpers.h +++ b/include/common/test_helpers.h @@ -9,8 +9,8 @@ #include <arch_features.h> #include <ffa_svc.h> -#include <plat_topology.h> #include <events.h> +#include <plat_topology.h> #include <psci.h> #include <spm_common.h> #include <tftf_lib.h> diff --git a/include/runtime_services/cactus_test_cmds.h b/include/runtime_services/cactus_test_cmds.h index d4cf407..b4fb73f 100644 --- a/include/runtime_services/cactus_test_cmds.h +++ b/include/runtime_services/cactus_test_cmds.h @@ -471,4 +471,23 @@ static inline uint32_t cactus_get_wdog_duration(smc_ret_values ret) return (uint32_t)ret.ret4; } +/** + * Request SP to return the current count of handled requests. + * + * The command id is the hex representation of the string "getnot". + */ +#define CACTUS_GET_REQ_COUNT_CMD U(0x726571636f756e74) + +static inline smc_ret_values cactus_get_req_count_send_cmd( + ffa_id_t source, ffa_id_t dest) +{ + return cactus_send_cmd(source, dest, CACTUS_GET_REQ_COUNT_CMD, 0, 0, 0, + 0); +} + +static inline uint32_t cactus_get_req_count(smc_ret_values ret) +{ + return (uint32_t)ret.ret4; +} + #endif diff --git a/spm/cactus/cactus_tests/cactus_message_loop.c b/spm/cactus/cactus_tests/cactus_message_loop.c index c24f6fc..750c954 100644 --- a/spm/cactus/cactus_tests/cactus_message_loop.c +++ b/spm/cactus/cactus_tests/cactus_message_loop.c @@ -4,11 +4,20 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#include "cactus_message_loop.h" -#include "cactus_test_cmds.h" -#include <ffa_helpers.h> #include <debug.h> +#include <cactus_message_loop.h> +#include <cactus_test_cmds.h> +#include <ffa_helpers.h> +#include <events.h> +#include <platform.h> + +/** + * Counter of the number of handled requests, for each CPU. The number of + * requests can be accessed from another Cactus SP, or from the normal world + * using a special test command. + */ +static uint32_t requests_counter[PLATFORM_CORE_COUNT]; /** * Begin and end of command handler table, respectively. Both symbols defined by @@ -31,6 +40,10 @@ bool cactus_handle_cmd(smc_ret_values *cmd_args, smc_ret_values *ret, { uint64_t in_cmd; + /* Get which core it is running from. */ + unsigned int core_pos = platform_get_core_pos( + read_mpidr_el1() & MPID_MASK); + if (cmd_args == NULL || ret == NULL) { ERROR("Invalid arguments passed to %s!\n", __func__); return false; @@ -45,10 +58,33 @@ bool cactus_handle_cmd(smc_ret_values *cmd_args, smc_ret_values *ret, it_cmd++) { if (it_cmd->id == in_cmd) { *ret = it_cmd->fn(cmd_args, mb); + + /* + * Increment the number of requests handled in current + * core. + */ + requests_counter[core_pos]++; + return true; } } + /* Handle special command. */ + if (in_cmd == CACTUS_GET_REQ_COUNT_CMD) { + uint32_t requests_counter_resp; + + /* Read value from array. */ + requests_counter_resp = requests_counter[core_pos]; + VERBOSE("Requests Counter %u, core: %u\n", requests_counter_resp, + core_pos); + + *ret = cactus_success_resp( + ffa_dir_msg_dest(*cmd_args), + ffa_dir_msg_source(*cmd_args), + requests_counter_resp); + return true; + } + *ret = cactus_error_resp(ffa_dir_msg_dest(*cmd_args), ffa_dir_msg_source(*cmd_args), CACTUS_ERROR_UNHANDLED); |