diff --git a/kernel/idt.c b/kernel/idt.c index 5c00ea5..af480f0 100644 --- a/kernel/idt.c +++ b/kernel/idt.c @@ -24,9 +24,18 @@ void exception_handler() { char* buf; print("[exc] ", EXC_COLOR); - buf = itoa(debug, buf, 10); - println(buf, 0x0c); + print(buf, 0x0c); + + if( debug == 13 ) { // General Protection Fault + uint* eip_ptr = 0xe223; + uint eip = *eip_ptr; + buf = itoa(eip, buf, 16); + print(" ptr: ", EXC_COLOR); + print(buf, 0x0e); + } + + new_line(); __asm__ __volatile__("cli; hlt"); } diff --git a/kernel/isr.asm b/kernel/isr.asm index 42c30c4..25e01bd 100644 --- a/kernel/isr.asm +++ b/kernel/isr.asm @@ -1,8 +1,18 @@ isr_debug_ptr equ 0xe222 +isr_eip_ptr equ 0xe223 %macro isr_err_stub 1 isr_stub_%+%1: + ; Save exception vec mov [isr_debug_ptr], byte %1 + + ; Save the instruction pointer + push eax + ;mov eax, eip + mov [isr_eip_ptr], dword eax + pop eax + + ; Handle the exception call exception_handler iret %endmacro @@ -24,7 +34,7 @@ isr_no_err_stub 4 isr_no_err_stub 5 isr_no_err_stub 6 isr_no_err_stub 7 -isr_no_err_stub 8 ; err +isr_err_stub 8 ; err isr_no_err_stub 9 isr_err_stub 10 isr_err_stub 11 diff --git a/lib/conv.c b/lib/conv.c index 2ef7e81..338cf70 100644 --- a/lib/conv.c +++ b/lib/conv.c @@ -22,9 +22,6 @@ char* itoa( int value, char * str, int base ) { *ptr++ = '-'; } -// if(value < 0 && base == 10 ) // sign -// *ptr++ = '-'; - // Remember where the numbers start. low = ptr;