From 497e4a1b2f6f9181518e9887991c0464bd8f6bcf Mon Sep 17 00:00:00 2001 From: Richard Qin Date: Wed, 10 Dec 2025 01:19:32 +0800 Subject: feat: Add initial Supervisor Mode Trap Handler Implement the initial mechanism for handling traps and exceptions in Supervisor Mode. Set up the stvec Control and Status Register (CSR) to direct all S-Mode Traps (Interrupts and Exceptions) to a unified assembly entry point. Implemented assembly code for saving and restoring the Trap Context (register state). Provides the foundational framework necessary for future Timer Interrupts and System Calls. --- src/drivers/uart.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/drivers/uart.cc') diff --git a/src/drivers/uart.cc b/src/drivers/uart.cc index 758abd9..a81ba3f 100644 --- a/src/drivers/uart.cc +++ b/src/drivers/uart.cc @@ -54,4 +54,19 @@ namespace Drivers{ uart_putc(*s++); } } + + void print_hex(uint64_t val) + { + char buf[20]; + const char *digits = "0123456789ABCDEF"; + buf[0] = '0'; + buf[1] = 'x'; + for (int i = 0; i < 16; i++) + { + buf[17 - i] = digits[val & 0xF]; + val >>= 4; + } + buf[18] = 0; + Drivers::uart_puts(buf); + } } \ No newline at end of file -- cgit v1.2.3