Add stvec trap

This commit is contained in:
Rodrigo Arias Mallo 2024-08-21 10:03:19 +02:00
parent baf45e6749
commit 90df8a3ccb

View File

@ -1,5 +1,5 @@
diff --git a/lib/sbi/sbi_irqchip.c b/lib/sbi/sbi_irqchip.c diff --git a/lib/sbi/sbi_irqchip.c b/lib/sbi/sbi_irqchip.c
index 0ae604a..a3df88c 100644 index 0ae604a..3708c3a 100644
--- a/lib/sbi/sbi_irqchip.c --- a/lib/sbi/sbi_irqchip.c
+++ b/lib/sbi/sbi_irqchip.c +++ b/lib/sbi/sbi_irqchip.c
@@ -9,6 +9,9 @@ @@ -9,6 +9,9 @@
@ -25,7 +25,7 @@ index 0ae604a..a3df88c 100644
return 0; return 0;
} }
@@ -47,8 +52,151 @@ void sbi_irqchip_exit(struct sbi_scratch *scratch) @@ -47,8 +52,156 @@ void sbi_irqchip_exit(struct sbi_scratch *scratch)
{ {
const struct sbi_platform *plat = sbi_platform_ptr(scratch); const struct sbi_platform *plat = sbi_platform_ptr(scratch);
@ -117,6 +117,10 @@ index 0ae604a..a3df88c 100644
+ return 0; + return 0;
+} +}
+ +
+static void supervisor_trap_entry(void)
+{
+ sbi_printf("\nSupervisor Trap Entry Reached!\n");
+}
+ +
+static void do_plic_test(void) +static void do_plic_test(void)
+{ +{
@ -134,6 +138,7 @@ index 0ae604a..a3df88c 100644
+ csr_set(CSR_SIE, SIE_SEIE); // Enable supervisor external interrupts + csr_set(CSR_SIE, SIE_SEIE); // Enable supervisor external interrupts
+ csr_set(CSR_SSTATUS, SSTATUS_SIE); // Enable global interrupts in supervisor mode + csr_set(CSR_SSTATUS, SSTATUS_SIE); // Enable global interrupts in supervisor mode
+ csr_set(CSR_MIDELEG, MIDELEG_SEIE); // Delegate machine interrupts to supervisor mode + csr_set(CSR_MIDELEG, MIDELEG_SEIE); // Delegate machine interrupts to supervisor mode
+ asm volatile("csrw stvec, %0" : : "r"(&supervisor_trap_entry));
+ sbi_printf("Enabled supervisor delegation:\n"); + sbi_printf("Enabled supervisor delegation:\n");
+ +
+ dumpregs(); + dumpregs();