feat(interrupts): support for registering irq handlers
This patch provides support for registering and unregistering
handler that is invoked by Cactus SP while processing virtual
irq interrupt. For this, we simply repurpose the existing framework
that was used to perform tail end of interrupt handling.
Also, this patch increases the count of virtual interrupts supported
by Cactus SP inline with the corresponding change in Hafnium[1].
[1] https://review.trustedfirmware.org/c/hafnium/hafnium/+/19232
Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
Change-Id: Ife41f0d3bb7eebb7c78657abb5b4c5ad41202bb9
diff --git a/spm/common/sp_helpers.c b/spm/common/sp_helpers.c
index 448084f..eeb0d19 100644
--- a/spm/common/sp_helpers.c
+++ b/spm/common/sp_helpers.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2022, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2023, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -15,7 +15,7 @@
spinlock_t sp_handler_lock[NUM_VINT_ID];
-void (*sp_interrupt_tail_end_handler[NUM_VINT_ID])(void);
+void (*sp_interrupt_handler[NUM_VINT_ID])(void);
uintptr_t bound_rand(uintptr_t min, uintptr_t max)
{
@@ -92,7 +92,7 @@
}
}
-void sp_register_interrupt_tail_end_handler(void (*handler)(void),
+void sp_register_interrupt_handler(void (*handler)(void),
uint32_t interrupt_id)
{
if (interrupt_id >= NUM_VINT_ID) {
@@ -101,11 +101,11 @@
}
spin_lock(&sp_handler_lock[interrupt_id]);
- sp_interrupt_tail_end_handler[interrupt_id] = handler;
+ sp_interrupt_handler[interrupt_id] = handler;
spin_unlock(&sp_handler_lock[interrupt_id]);
}
-void sp_unregister_interrupt_tail_end_handler(uint32_t interrupt_id)
+void sp_unregister_interrupt_handler(uint32_t interrupt_id)
{
if (interrupt_id >= NUM_VINT_ID) {
ERROR("Cannot unregister handler for interrupt %u\n", interrupt_id);
@@ -113,6 +113,6 @@
}
spin_lock(&sp_handler_lock[interrupt_id]);
- sp_interrupt_tail_end_handler[interrupt_id] = NULL;
+ sp_interrupt_handler[interrupt_id] = NULL;
spin_unlock(&sp_handler_lock[interrupt_id]);
}
diff --git a/spm/common/sp_helpers.h b/spm/common/sp_helpers.h
index 98af484..629801e 100644
--- a/spm/common/sp_helpers.h
+++ b/spm/common/sp_helpers.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2022, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2023, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -12,8 +12,8 @@
#include <spm_common.h>
#include <spinlock.h>
-/* Currently, Hafnium/SPM supports only 64 virtual interrupt IDs. */
-#define NUM_VINT_ID 64
+/* Currently, Hafnium/SPM supports 1024 virtual interrupt IDs. */
+#define NUM_VINT_ID 1024
typedef struct {
u_register_t fid;
@@ -68,16 +68,18 @@
void sp_handler_spin_lock_init(void);
-/* Handler invoked at the tail end of interrupt processing by SP. */
-extern void (*sp_interrupt_tail_end_handler[NUM_VINT_ID])(void);
+/* Handler invoked by SP while processing interrupt. */
+extern void (*sp_interrupt_handler[NUM_VINT_ID])(void);
/* Register the handler. */
-void sp_register_interrupt_tail_end_handler(void (*handler)(void),
+void sp_register_interrupt_handler(void (*handler)(void),
uint32_t interrupt_id);
/* Un-register the handler. */
-void sp_unregister_interrupt_tail_end_handler(uint32_t interrupt_id);
+void sp_unregister_interrupt_handler(uint32_t interrupt_id);
void discover_managed_exit_interrupt_id(void);
+void register_maintenance_interrupt_handlers(void);
+
#endif /* SP_HELPERS_H */