feat(interrupts): query last serviced interrupt
This patch introduces a helper API to request Cactus SP to return the
ID of the last serviced secure virtual interrupt. It is built on cactus
command framework by leveraging direct message request and response
pair.
Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
Change-Id: I316268f4d9b80f29c308d1a1488945a272ffbc93
diff --git a/include/runtime_services/cactus_test_cmds.h b/include/runtime_services/cactus_test_cmds.h
index 97624f7..1c1c21d 100644
--- a/include/runtime_services/cactus_test_cmds.h
+++ b/include/runtime_services/cactus_test_cmds.h
@@ -545,4 +545,17 @@
return (uint32_t)ret.ret4;
}
+/**
+ * Request SP to return the last serviced secure virtual interrupt.
+ *
+ * The command id is the hex representaton of the string "vINT"
+ */
+#define CACTUS_LAST_INTERRUPT_SERVICED_CMD U(0x76494e54)
+
+static inline smc_ret_values cactus_get_last_interrupt_cmd(
+ ffa_id_t source, ffa_id_t dest)
+{
+ return cactus_send_cmd(source, dest, CACTUS_LAST_INTERRUPT_SERVICED_CMD,
+ 0, 0, 0, 0);
+}
#endif
diff --git a/spm/cactus/cactus_interrupt.c b/spm/cactus/cactus_interrupt.c
index f0d916f..2305b01 100644
--- a/spm/cactus/cactus_interrupt.c
+++ b/spm/cactus/cactus_interrupt.c
@@ -22,11 +22,15 @@
extern ffa_id_t g_ffa_id;
+/* Secure virtual interrupt that was last handled by Cactus SP. */
+uint32_t last_serviced_interrupt[PLATFORM_CORE_COUNT];
+
extern spinlock_t sp_handler_lock[NUM_VINT_ID];
void cactus_interrupt_handler(void)
{
uint32_t intid = spm_interrupt_get();
+ unsigned int core_pos = get_current_core_id();
switch (intid) {
case MANAGED_EXIT_INTERRUPT_ID:
@@ -62,6 +66,8 @@
panic();
}
+ last_serviced_interrupt[core_pos] = intid;
+
/* Invoke the tail end handler registered by the SP. */
spin_lock(&sp_handler_lock[intid]);
if (sp_interrupt_tail_end_handler[intid]) {
diff --git a/spm/cactus/cactus_tests/cactus_test_interrupts.c b/spm/cactus/cactus_tests/cactus_test_interrupts.c
index 3fa5f23..dc64512 100644
--- a/spm/cactus/cactus_tests/cactus_test_interrupts.c
+++ b/spm/cactus/cactus_tests/cactus_test_interrupts.c
@@ -14,6 +14,8 @@
#include <platform.h>
+/* Secure virtual interrupt that was last handled by Cactus SP. */
+extern uint32_t last_serviced_interrupt[PLATFORM_CORE_COUNT];
static int flag_set;
static void sec_wdog_interrupt_handled(void)
@@ -167,3 +169,12 @@
ffa_dir_msg_source(*args),
CACTUS_ERROR_TEST);
}
+
+CACTUS_CMD_HANDLER(interrupt_serviced_cmd, CACTUS_LAST_INTERRUPT_SERVICED_CMD)
+{
+ unsigned int core_pos = get_current_core_id();
+
+ return cactus_response(ffa_dir_msg_dest(*args),
+ ffa_dir_msg_source(*args),
+ last_serviced_interrupt[core_pos]);
+}