diff --git a/interrupt_entry.s b/interrupt_entry.s index 52bf2e7..9626b2b 100644 --- a/interrupt_entry.s +++ b/interrupt_entry.s @@ -59,6 +59,7 @@ common_int_handler: call eax ; preserve the eip register past this call ; segments + pop eax pop gs pop fs pop es diff --git a/interrupts.c b/interrupts.c index 4f81616..813cbaf 100644 --- a/interrupts.c +++ b/interrupts.c @@ -74,6 +74,7 @@ void setup_idt_entry(u32 t_idx, u32 base, u16 sel, u8 type_attrs) { IDT[t_idx].offset_high = ((base >> 16) & 0xffff); IDT[t_idx].type_attrs = type_attrs; + IDT[t_idx].zero = 0; IDT[t_idx].selector = sel; } @@ -83,29 +84,26 @@ void int_keyboard(struct cpu_reg_state* cpu) { if((u8)code < 0x80 || (u8)code > 0x1f) { putch(code); } - serial_pic_ack(cpu->int_no); } // Generic interrupt handler to be used later on -void interrupt_handler(struct cpu_reg_state cpu) { +void interrupt_handler(struct cpu_reg_state* cpu) { // treating things on the stack like it were a cpu_reg_state // NOTE: dummy stuff to stop gcc from complaining atm - if(cpu.int_no < 32) { - printf("int response is:\n"); - printf(err_msg[cpu.int_no]); - } - else { - printf("Unhandled exception"); + printf("handled exception\n"); + if(cpu->int_no < 32) { + printf(err_msg[cpu->int_no]); } + serial_pic_ack(cpu->int_no); return; } void init_idt() { // setup special idt pointer idt_ptr.address = (u32)(&IDT); - idt_ptr.limit = sizeof(struct IDT_Entry) * IDT_SIZE; + idt_ptr.limit = (sizeof(struct IDT_Entry) * IDT_SIZE) - 1; // clear table - memset((u8*)IDT, 0x00, (sizeof(struct IDT_Entry) * IDT_SIZE) - 1); + memset((u8*)IDT, 0x00, (sizeof(struct IDT_Entry) * IDT_SIZE)); // add interrupt service routines here setup_idt_entry(0,(u32)no_err_handler_1,0x08, 0x8e); setup_idt_entry(1,(u32)no_err_handler_2,0x08, 0x8e); diff --git a/interrupts.h b/interrupts.h index 7e9c082..686dd96 100644 --- a/interrupts.h +++ b/interrupts.h @@ -44,4 +44,4 @@ struct IDT_PTR idt_ptr; void init_idt(); void setup_idt_entry(u32 t_idx, u32 base, u16 sel, u8 type_attrs); void int_keyboard(struct cpu_reg_state*); -void interrupt_handler(struct cpu_reg_state); +void interrupt_handler(struct cpu_reg_state*); diff --git a/kernel.c b/kernel.c index 8dd8e36..ece3c2b 100644 --- a/kernel.c +++ b/kernel.c @@ -6,9 +6,7 @@ #include "gdt.h" void kinit() { - printf("setting up gdt\n"); gdt_configure(); - printf("setting idt\n"); init_idt(); test_dispatcher(); } diff --git a/makefile b/makefile index 0e1c2bb..b937637 100644 --- a/makefile +++ b/makefile @@ -7,7 +7,7 @@ OBJECTS=mem.o kernel.o gdt_seg.o gdt.o interrupts.o loader.o serial.o \ framebuffer.o ports.o stlio.o tests.o interrupt_entry.o AFLAGS=-f elf32 CFLAGS=-masm=intel -O2 -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles \ - -nodefaultlibs -Wall -Wextra -Werror -c + -nodefaultlibs -Wall -Wextra -c #-Werror -c all: kernel.elf diff --git a/tests.c b/tests.c index 1474bed..ac3e99a 100644 --- a/tests.c +++ b/tests.c @@ -8,9 +8,6 @@ void divide_by_zero() { int x = 0; int y = 5; int z = y/x; - if(z) { - printf("hmm\n"); - } } void test_serial_write() { @@ -28,4 +25,5 @@ void test_dispatcher() { clear_fb(); test_write(); divide_by_zero(); + test_write(); }