feat: add a test command to request a Cactus SP to start wdog timer
cactus_send_twdog_cmd() API sends a direct request message to target
SP which (re)starts the Trusted Watchdog timer. The SP then sends back
a direct response message indicating successful command.
Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
Change-Id: If09ce76b46a6339f08f26be90e566550931fb3c7
diff --git a/include/runtime_services/cactus_test_cmds.h b/include/runtime_services/cactus_test_cmds.h
index b588934..131e964 100644
--- a/include/runtime_services/cactus_test_cmds.h
+++ b/include/runtime_services/cactus_test_cmds.h
@@ -63,7 +63,7 @@
static inline smc_ret_values cactus_response(
ffa_id_t source, ffa_id_t dest, uint32_t response)
{
- return ffa_msg_send_direct_resp64(source, dest, response, 0, 0, 0, 0);
+ return cactus_send_response(source, dest, response, 0, 0, 0, 0);
}
static inline uint32_t cactus_get_response(smc_ret_values ret)
@@ -431,4 +431,23 @@
receiver, sender, notifications, flags);
}
+/**
+ * Request to start trusted watchdog timer.
+ *
+ * The command id is the hex representaton of the string "WDOG"
+ */
+#define CACTUS_TWDOG_START_CMD U(0x57444f47)
+
+static inline smc_ret_values cactus_send_twdog_cmd(
+ ffa_id_t source, ffa_id_t dest, uint64_t time)
+{
+ return cactus_send_cmd(source, dest, CACTUS_TWDOG_START_CMD, time, 0, 0,
+ 0);
+}
+
+static inline uint32_t cactus_get_wdog_duration(smc_ret_values ret)
+{
+ return (uint32_t)ret.ret4;
+}
+
#endif
diff --git a/spm/cactus/cactus_tests/cactus_test_interrupts.c b/spm/cactus/cactus_tests/cactus_test_interrupts.c
index aa39ef2..a79885c 100644
--- a/spm/cactus/cactus_tests/cactus_test_interrupts.c
+++ b/spm/cactus/cactus_tests/cactus_test_interrupts.c
@@ -5,6 +5,7 @@
*/
#include <common/debug.h>
+#include <drivers/arm/sp805.h>
#include <sp_helpers.h>
#include <spm_helpers.h>
@@ -47,3 +48,17 @@
ffa_dir_msg_source(*args),
CACTUS_SUCCESS);
}
+
+CACTUS_CMD_HANDLER(twdog_cmd, CACTUS_TWDOG_START_CMD)
+{
+ ffa_id_t vm_id = ffa_dir_msg_dest(*args);
+ ffa_id_t source = ffa_dir_msg_source(*args);
+
+ uint64_t time_ms = cactus_get_wdog_duration(*args);
+
+ VERBOSE("Starting TWDOG: %llums\n", time_ms);
+ sp805_twdog_refresh();
+ sp805_twdog_start((time_ms * ARM_SP805_TWDG_CLK_HZ) / 1000);
+
+ return cactus_success_resp(vm_id, source, time_ms);
+}