diff --git a/JOURNAL.md b/JOURNAL.md index c73db79..110e04b 100644 --- a/JOURNAL.md +++ b/JOURNAL.md @@ -3463,7 +3463,7 @@ Let's set the stvec to zero, so it causes a machine exception. # 2024-08-21 -I tried with the new bitstream (ox_u55c_46619ef4.bit) setting the stvec to zero +I tried with the new bitstream (`ox_u55c_46619ef4.bit`) setting the stvec to zero and I can see the OpenSBI handler stopping, probably due to the jump to zero address: diff --git a/opensbi-test-plic.patch b/opensbi-test-plic.patch index 8f3df08..f676341 100644 --- a/opensbi-test-plic.patch +++ b/opensbi-test-plic.patch @@ -1,5 +1,5 @@ diff --git a/lib/sbi/sbi_irqchip.c b/lib/sbi/sbi_irqchip.c -index 0ae604a..54449c7 100644 +index 0ae604a..c446e60 100644 --- a/lib/sbi/sbi_irqchip.c +++ b/lib/sbi/sbi_irqchip.c @@ -9,6 +9,9 @@ @@ -25,7 +25,7 @@ index 0ae604a..54449c7 100644 return 0; } -@@ -47,8 +52,161 @@ void sbi_irqchip_exit(struct sbi_scratch *scratch) +@@ -47,8 +52,163 @@ void sbi_irqchip_exit(struct sbi_scratch *scratch) { const struct sbi_platform *plat = sbi_platform_ptr(scratch); @@ -61,6 +61,10 @@ index 0ae604a..54449c7 100644 +#define MSTATUS_MPP_MASK (3 << 11) +#define MSTATUS_MPP_SUPERVISOR (1 << 11) + ++static volatile unsigned long *mtime = (unsigned long *)(AUX_TIMER_BASE + MTIME_OFFSET); ++static volatile unsigned long *mtimecmp = (unsigned long *)(AUX_TIMER_BASE + MTIMECMP_OFFSET); ++ ++ +static void dumpregs(int machine) +{ + char *prefix = "\t"; @@ -108,6 +112,11 @@ index 0ae604a..54449c7 100644 +{ + sbi_printf("Hello from supervisor\n"); + dumpregs(0); ++ ++ /* Enable timer interrupt */ ++ *mtimecmp = *mtime + 10000; ++ ++ sbi_printf("Timer alarm programmed\n"); + sbi_printf("Waiting for interrupt...\n"); + int i = 0; + char *s = "-\\|/"; @@ -129,9 +138,6 @@ index 0ae604a..54449c7 100644 +{ + sbi_printf("--- TESTING PLIC ---\n"); + -+ volatile unsigned long *mtime = (unsigned long *)(AUX_TIMER_BASE + MTIME_OFFSET); -+ volatile unsigned long *mtimecmp = (unsigned long *)(AUX_TIMER_BASE + MTIMECMP_OFFSET); -+ + /* Disable auxiliar timer interrupt */ + *mtimecmp = 0xffffffffUL; + sbi_printf("Timer interrupt disabled\n"); @@ -174,10 +180,6 @@ index 0ae604a..54449c7 100644 + //sbi_printf("Enabling MIE in MSTATUS register\n"); + //csr_set(CSR_MSTATUS, MSTATUS_MIE); /* Needed? */ + -+ /* Enable timer interrupt */ -+ *mtimecmp = *mtime + 10000; -+ -+ sbi_printf("Timer alarm programmed\n"); + sbi_printf("Switching to supervisor\n"); + + dumpregs(1);