aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-11-16 15:16:32 -0700
committerJosh Rahm <joshuarahm@gmail.com>2024-11-16 15:16:32 -0700
commit4c0d75cccc41335bcc39677d39d6761b77024dc6 (patch)
treed03ca6385ca9ab9db5c5f324e27e441d533d9b6e /src
parent9a29506823896c53b4334c5ee202ce01306d921f (diff)
downloadch573-4c0d75cccc41335bcc39677d39d6761b77024dc6.tar.gz
ch573-4c0d75cccc41335bcc39677d39d6761b77024dc6.tar.bz2
ch573-4c0d75cccc41335bcc39677d39d6761b77024dc6.zip
Minor changes to exception handling.
Diffstat (limited to 'src')
-rw-r--r--src/exc.c12
-rw-r--r--src/main.c7
2 files changed, 12 insertions, 7 deletions
diff --git a/src/exc.c b/src/exc.c
index 707d3b0..657ddb8 100644
--- a/src/exc.c
+++ b/src/exc.c
@@ -19,9 +19,9 @@ IRQ(exc)
asm volatile("csrr %0, mtval" : "=r"(mtval));
printf("Hardware Exception Caught:\n");
- printf(" mcause: 0x%80x\n", mcause);
- printf(" mepc: 0x%80x\n", mepc);
- printf(" mtval: 0x%80x\n", mtval);
+ printf(" mcause: 0x%08x\n", mcause);
+ printf(" mepc: 0x%08x\n", mepc);
+ printf(" mtval: 0x%08x\n", mtval);
panic(mcause);
}
@@ -35,9 +35,9 @@ IRQ(nmi)
asm volatile("csrr %0, mtval" : "=r"(mtval));
printf("Unhandled NMI Caught:\n");
- printf(" mcause: 0x%80x\n", mcause);
- printf(" mepc: 0x%80x\n", mepc);
- printf(" mtval: 0x%80x\n", mtval);
+ printf(" mcause: 0x%08x\n", mcause);
+ printf(" mepc: 0x%08x\n", mepc);
+ printf(" mtval: 0x%08x\n", mtval);
panic(mcause);
}
diff --git a/src/main.c b/src/main.c
index ed82a3a..d7eab9b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -105,6 +105,8 @@ const char* hello_world_static = "Hello, World!\r\n";
int test(char ch, ...);
+volatile int zero = 0;
+
/* Main routine. This is called on_reset once everything else has been set up.
*/
int main(void)
@@ -123,9 +125,12 @@ int main(void)
volatile uint32_t dl = (10 * 6400000 / 8 / BAUD_RATE + 5) / 10;
UART.dl.set(UART1, dl);
- char buf[32] = { 0 };
+ char buf[32] = {0};
volatile uint32_t i = 0xdeadbeef;
+ asm volatile("ebreak");
+
+
panic(0xdeadbeef);
stack_dump(&i);