[INTERRUPTS] Exception handling
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
#include <debug.h>
|
||||
#include <int.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <vga.h>
|
||||
#include <serial.h>
|
||||
#include <registers.h>
|
||||
|
||||
void debug_init()
|
||||
{
|
||||
@@ -130,3 +132,15 @@ void debug_printf(char *str, ...)
|
||||
debug_vprintf(str, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void print_registers(registers_t *r)
|
||||
{
|
||||
debug("Num:%x Error:%x\n", r->int_no, r->err_code);
|
||||
debug("RAX:%x RBX:%x RCX:%x RDX:%x\n", r->rax, r->rbx, r->rcx, r->rdx);
|
||||
debug("RSI:%x RDI:%x RBP:%x RSP:%x\n", r->rsi, r->rdi, r->rbp, r->rsp);
|
||||
debug("R8:%x R9:%x R10:%x R11:%x\n", r->r8, r->r9, r->r10, r->r11);
|
||||
debug("R12:%x R13:%x R14:%x R15:%x\n", r->r12, r->r13, r->r14, r->r15);
|
||||
debug("RIP:%x RFL:%x\n", r->rip, r->rflags);
|
||||
debug("CS:%x SS:%x\n", r->cs, r->ss);
|
||||
debug("CR0:%x CR2:%x CR3:%x CR4:%x\n", read_cr0(), read_cr2(), read_cr3(), read_cr4());
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <debug.h>
|
||||
#include <int.h>
|
||||
#include <multiboot.h>
|
||||
#include <mem.h>
|
||||
|
||||
@@ -8,8 +9,15 @@ int kmain(uint64_t multiboot_magic, void *multiboot_data)
|
||||
debug_ok("MITTOS64 kernel booted\n");
|
||||
debug_build_time();
|
||||
debug_git_info();
|
||||
|
||||
interrupt_init();
|
||||
multiboot_init(multiboot_magic, P2V(multiboot_data));
|
||||
|
||||
debug_info("BOOT COMPLETE\n");
|
||||
// Cause a divide-by-zero exception
|
||||
int a = 5, b = 0;
|
||||
int c = a/b;
|
||||
(void)c;
|
||||
|
||||
for(;;)asm("hlt");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user