Exception stuff

master
E. Almqvist 3 years ago
parent aa71984ae0
commit 901ab00dfd
  1. 2
      Makefile
  2. 2
      kernel/idt.c
  3. 4
      kernel/isr.asm
  4. 2
      kernel/kernel.c
  5. 8
      lib/conv.c

@ -10,7 +10,7 @@ LDFLAGS = -Wl,--oformat=binary -ffreestanding -nostdlib -shared -Ttext 0x1000 -
# VM/Debug settings # VM/Debug settings
VM = qemu-system-x86_64 VM = qemu-system-x86_64
VMFLAGS = -serial stdio VMFLAGS = -serial stdio -no-reboot -no-shutdown -d int
# Do not touch these. # Do not touch these.

@ -31,7 +31,7 @@ void exception_handler() {
uint* eip_ptr = 0xe223; uint* eip_ptr = 0xe223;
uint eip = *eip_ptr; uint eip = *eip_ptr;
buf = itoa(eip, buf, 16); buf = itoa(eip, buf, 16);
print(" ptr: ", EXC_COLOR); print(" eax= ", EXC_COLOR);
print(buf, 0x0e); print(buf, 0x0e);
} }

@ -7,10 +7,8 @@ isr_stub_%+%1:
mov [isr_debug_ptr], byte %1 mov [isr_debug_ptr], byte %1
; Save the instruction pointer ; Save the instruction pointer
push eax
;mov eax, eip
mov [isr_eip_ptr], dword eax
pop eax pop eax
mov [isr_eip_ptr], dword eax
; Handle the exception ; Handle the exception
call exception_handler call exception_handler

@ -66,7 +66,7 @@ void kernel_init() {
clear_screen(); clear_screen();
print_kernel_motd(); print_kernel_motd();
//print_kernel_stats(); print_kernel_stats();
char* buf; char* buf;
uint i = 0; uint i = 0;

@ -6,7 +6,6 @@ char* itoa( int value, char * str, int base ) {
char* ptr; char* ptr;
char* low; char* low;
// Check for supported base.
if( base < 2 || base > 36 ) { if( base < 2 || base > 36 ) {
*str = '\0'; *str = '\0';
return str; return str;
@ -21,21 +20,16 @@ char* itoa( int value, char * str, int base ) {
if(value < 0) if(value < 0)
*ptr++ = '-'; *ptr++ = '-';
} }
// Remember where the numbers start.
low = ptr; low = ptr;
// The actual conversion.
do { do {
// Modulo is negative for negative value. This trick makes abs() unnecessary.
*ptr++ = "zyxwvutsrqponmlkjihgfedcba9876543210123456789abcdefghijklmnopqrstuvwxyz"[35 + value % base]; *ptr++ = "zyxwvutsrqponmlkjihgfedcba9876543210123456789abcdefghijklmnopqrstuvwxyz"[35 + value % base];
value /= base; value /= base;
} while(value); } while(value);
// Terminating the string.
*ptr-- = '\0'; *ptr-- = '\0';
// Invert the numbers. // Invert
while ( low < ptr ) { while ( low < ptr ) {
char tmp = *low; char tmp = *low;
*low++ = *ptr; *low++ = *ptr;

Loading…
Cancel
Save