From 02f14113cbf14c6f842fb43ecbc68d0c851ef3b0 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 24 May 2020 11:02:43 -0400 Subject: very basic vga, ata, serial drivers. start of fat and fs drivers --- src/kernel/panic.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/kernel/panic.c (limited to 'src/kernel/panic.c') diff --git a/src/kernel/panic.c b/src/kernel/panic.c new file mode 100644 index 0000000..49d4a27 --- /dev/null +++ b/src/kernel/panic.c @@ -0,0 +1,31 @@ +#include +#include "vga.h" +#include "serial.h" +#include "util.h" + +void halt() { + while (1) + asm volatile ("hlt"); +} + +void panic(uint8_t *message) { + uint32_t frame; + asm ( + "movl %%ebp, %0" + : "=r" (frame)); + vga_set_color(0x4f); + vga_blank(); + vga_printsz("Kernel panic: "); + vga_printsz(message); + vga_printsz("\n\nStack trace:"); + uint8_t stb[6]; + while (1) { + uint32_t ip = *(uint32_t *)(0x38000 + frame + 4); + if (!ip) + halt(); + vga_printsz("\n 0x"); + u16_hex(ip - 0x30000 - 5, stb);//assumes would return to just after a call instruction + vga_printsz(stb); + frame = *(uint32_t *)(0x38000 + frame); + } +} \ No newline at end of file -- cgit v1.2.3