feat(interrupts): support for registering custom handler

This patch provides support for registering and unregistering
handler that is invoked by SP at the tail end of the virtual interrupt
processing.

Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com>
Change-Id: Ia12686361063bb680ff32b4f4bf90e0af2521c36
diff --git a/spm/cactus/cactus_interrupt.c b/spm/cactus/cactus_interrupt.c
index ef3d5cc..f0d916f 100644
--- a/spm/cactus/cactus_interrupt.c
+++ b/spm/cactus/cactus_interrupt.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Arm Limited. All rights reserved.
+ * Copyright (c) 2021-2022, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -22,6 +22,8 @@
 
 extern ffa_id_t g_ffa_id;
 
+extern spinlock_t sp_handler_lock[NUM_VINT_ID];
+
 void cactus_interrupt_handler(void)
 {
 	uint32_t intid = spm_interrupt_get();
@@ -59,4 +61,11 @@
 			 intid);
 		panic();
 	}
+
+	/* Invoke the tail end handler registered by the SP. */
+	spin_lock(&sp_handler_lock[intid]);
+	if (sp_interrupt_tail_end_handler[intid]) {
+		sp_interrupt_tail_end_handler[intid]();
+	}
+	spin_unlock(&sp_handler_lock[intid]);
 }