From 48b7662deee7e08cc21813f94cf0438330971230 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Wed, 30 Oct 2019 18:37:08 -0700 Subject: [PATCH 1/6] removing Werror _for now_ while I debug isr's --- makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 7eb8da29fc54f016e642069d065ce8fdf78108d1 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Wed, 30 Oct 2019 18:37:37 -0700 Subject: [PATCH 2/6] more concise tests --- tests.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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(); } From e5c2553bf5a5fc6391dcf1ce7ad0bdc15edd16b3 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Wed, 30 Oct 2019 18:39:26 -0700 Subject: [PATCH 3/6] * setting ID[i].zero to 0 * also adding louder prints to interrupt handler for now --- interrupts.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/interrupts.c b/interrupts.c index 4f81616..8a97a0f 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; } @@ -90,12 +91,12 @@ void int_keyboard(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 + printf("handled exception\n"); if(cpu.int_no < 32) { - printf("int response is:\n"); - printf(err_msg[cpu.int_no]); + printf("handled exception\n"); } else { - printf("Unhandled exception"); + printf("Unimplemented exception"); } return; } @@ -103,9 +104,9 @@ void interrupt_handler(struct cpu_reg_state cpu) { 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); From d706c5c3f4cd592bcaedb5d6896685f44843caf5 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Wed, 30 Oct 2019 18:39:54 -0700 Subject: [PATCH 4/6] fixes broken segment reconstruction(i hope) --- interrupt_entry.s | 1 + 1 file changed, 1 insertion(+) 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 From 35985d91991705ffa3f961c567a1503f360cb31c Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Wed, 30 Oct 2019 18:40:07 -0700 Subject: [PATCH 5/6] removed fluff prints --- kernel.c | 2 -- 1 file changed, 2 deletions(-) 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(); } From 80a4e7069a78bbacba0069f850a3250d678371b4 Mon Sep 17 00:00:00 2001 From: shockrahwow Date: Wed, 30 Oct 2019 23:18:49 -0700 Subject: [PATCH 6/6] changing main interrupt_handler to take a pointer also moving some logic around to help reson what's happening in recent errors --- interrupts.c | 11 ++++------- interrupts.h | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/interrupts.c b/interrupts.c index 8a97a0f..813cbaf 100644 --- a/interrupts.c +++ b/interrupts.c @@ -84,20 +84,17 @@ 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 printf("handled exception\n"); - if(cpu.int_no < 32) { - printf("handled exception\n"); - } - else { - printf("Unimplemented exception"); + if(cpu->int_no < 32) { + printf(err_msg[cpu->int_no]); } + serial_pic_ack(cpu->int_no); return; } 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*);