Print registers in supervisor
This commit is contained in:
parent
706d858347
commit
2c5f8a8ccf
@ -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..177fb6b 100644
|
index 0ae604a..54449c7 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..177fb6b 100644
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -47,8 +52,158 @@ void sbi_irqchip_exit(struct sbi_scratch *scratch)
|
@@ -47,8 +52,161 @@ 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);
|
||||||
|
|
||||||
@ -61,11 +61,12 @@ index 0ae604a..177fb6b 100644
|
|||||||
+#define MSTATUS_MPP_MASK (3 << 11)
|
+#define MSTATUS_MPP_MASK (3 << 11)
|
||||||
+#define MSTATUS_MPP_SUPERVISOR (1 << 11)
|
+#define MSTATUS_MPP_SUPERVISOR (1 << 11)
|
||||||
+
|
+
|
||||||
+static void dumpregs(void)
|
+static void dumpregs(int machine)
|
||||||
+{
|
+{
|
||||||
+ char *prefix = "\t";
|
+ char *prefix = "\t";
|
||||||
+ char *suffix = "\t";
|
+ char *suffix = "\t";
|
||||||
+ sbi_printf("Registers:\n");
|
+ sbi_printf("Registers:\n");
|
||||||
|
+ if (machine) {
|
||||||
+ sbi_printf("%sMIE%s: 0x%" PRILX "\n",
|
+ sbi_printf("%sMIE%s: 0x%" PRILX "\n",
|
||||||
+ prefix, suffix, csr_read(CSR_MIE));
|
+ prefix, suffix, csr_read(CSR_MIE));
|
||||||
+ sbi_printf("%sMIP%s: 0x%" PRILX "\n",
|
+ sbi_printf("%sMIP%s: 0x%" PRILX "\n",
|
||||||
@ -74,6 +75,7 @@ index 0ae604a..177fb6b 100644
|
|||||||
+ prefix, suffix, csr_read(CSR_MSTATUS));
|
+ prefix, suffix, csr_read(CSR_MSTATUS));
|
||||||
+ sbi_printf("%sMIDELEG%s: 0x%" PRILX "\n",
|
+ sbi_printf("%sMIDELEG%s: 0x%" PRILX "\n",
|
||||||
+ prefix, suffix, csr_read(CSR_MIDELEG));
|
+ prefix, suffix, csr_read(CSR_MIDELEG));
|
||||||
|
+ }
|
||||||
+ sbi_printf("%sSIE%s: 0x%" PRILX "\n",
|
+ sbi_printf("%sSIE%s: 0x%" PRILX "\n",
|
||||||
+ prefix, suffix, csr_read(CSR_SIE));
|
+ prefix, suffix, csr_read(CSR_SIE));
|
||||||
+ sbi_printf("%sSIP%s: 0x%" PRILX "\n",
|
+ sbi_printf("%sSIP%s: 0x%" PRILX "\n",
|
||||||
@ -105,6 +107,7 @@ index 0ae604a..177fb6b 100644
|
|||||||
+static int supervisor_mode_code(void)
|
+static int supervisor_mode_code(void)
|
||||||
+{
|
+{
|
||||||
+ sbi_printf("Hello from supervisor\n");
|
+ sbi_printf("Hello from supervisor\n");
|
||||||
|
+ dumpregs(0);
|
||||||
+ sbi_printf("Waiting for interrupt...\n");
|
+ sbi_printf("Waiting for interrupt...\n");
|
||||||
+ int i = 0;
|
+ int i = 0;
|
||||||
+ char *s = "-\\|/";
|
+ char *s = "-\\|/";
|
||||||
@ -141,7 +144,7 @@ index 0ae604a..177fb6b 100644
|
|||||||
+ csr_set(CSR_STVEC, &supervisor_trap_entry);
|
+ csr_set(CSR_STVEC, &supervisor_trap_entry);
|
||||||
+ sbi_printf("Enabled supervisor delegation:\n");
|
+ sbi_printf("Enabled supervisor delegation:\n");
|
||||||
+
|
+
|
||||||
+ dumpregs();
|
+ dumpregs(1);
|
||||||
+
|
+
|
||||||
+ /* Configure PLIC aux timer input */
|
+ /* Configure PLIC aux timer input */
|
||||||
+ volatile unsigned *plic_priority = (unsigned *)(PLIC_BASE + PLIC_PRIORITY_OFFSET + PLIC_TIMER_PORT * 4);
|
+ volatile unsigned *plic_priority = (unsigned *)(PLIC_BASE + PLIC_PRIORITY_OFFSET + PLIC_TIMER_PORT * 4);
|
||||||
@ -177,7 +180,7 @@ index 0ae604a..177fb6b 100644
|
|||||||
+ sbi_printf("Timer alarm programmed\n");
|
+ sbi_printf("Timer alarm programmed\n");
|
||||||
+ sbi_printf("Switching to supervisor\n");
|
+ sbi_printf("Switching to supervisor\n");
|
||||||
+
|
+
|
||||||
+ dumpregs();
|
+ dumpregs(1);
|
||||||
+
|
+
|
||||||
+ switch_to_supervisor_mode(&supervisor_mode_code);
|
+ switch_to_supervisor_mode(&supervisor_mode_code);
|
||||||
+
|
+
|
||||||
|
Loading…
Reference in New Issue
Block a user