summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2022-06-13 04:03:53 +0300
committerAnup Patel <anup@brainfault.org>2022-06-13 09:24:06 +0300
commit69be3dff9df767c19a461fadf73ad7331b4bdb4c (patch)
tree9ca1324a308731dd34dcb330d23b239d063b60ba /lib
parent2b79b694a80513696daf072db0fd980e7573b212 (diff)
downloadopensbi-69be3dff9df767c19a461fadf73ad7331b4bdb4c.tar.xz
lib: utils/irqchip: Add FDT wrappers for PLIC save/restore functions
These functions save/restore the state of the PLIC associated with the current hart. The context save/restore functions only manipulate a single context, since most likely the M-mode context is unused and does not need to be saved. Signed-off-by: Samuel Holland <samuel@sholland.org> Reviewed-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/utils/irqchip/fdt_irqchip_plic.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/utils/irqchip/fdt_irqchip_plic.c b/lib/utils/irqchip/fdt_irqchip_plic.c
index b2d2a1b..89b12d4 100644
--- a/lib/utils/irqchip/fdt_irqchip_plic.c
+++ b/lib/utils/irqchip/fdt_irqchip_plic.c
@@ -24,6 +24,38 @@ static struct plic_data plic[PLIC_MAX_NR];
static struct plic_data *plic_hartid2data[SBI_HARTMASK_MAX_BITS];
static int plic_hartid2context[SBI_HARTMASK_MAX_BITS][2];
+void fdt_plic_priority_save(u8 *priority)
+{
+ struct plic_data *plic = plic_hartid2data[current_hartid()];
+
+ plic_priority_save(plic, priority);
+}
+
+void fdt_plic_priority_restore(const u8 *priority)
+{
+ struct plic_data *plic = plic_hartid2data[current_hartid()];
+
+ plic_priority_restore(plic, priority);
+}
+
+void fdt_plic_context_save(bool smode, u32 *enable, u32 *threshold)
+{
+ u32 hartid = current_hartid();
+
+ plic_context_save(plic_hartid2data[hartid],
+ plic_hartid2context[hartid][smode],
+ enable, threshold);
+}
+
+void fdt_plic_context_restore(bool smode, const u32 *enable, u32 threshold)
+{
+ u32 hartid = current_hartid();
+
+ plic_context_restore(plic_hartid2data[hartid],
+ plic_hartid2context[hartid][smode],
+ enable, threshold);
+}
+
static int irqchip_plic_warm_init(void)
{
u32 hartid = current_hartid();