Merge branch 'master' of gitlab.com:shockrah/jankos

This commit is contained in:
shockrah 2019-11-03 23:54:59 -08:00
commit 847a4090b8
6 changed files with 12 additions and 17 deletions

View File

@ -59,6 +59,7 @@ common_int_handler:
call eax ; preserve the eip register past this call call eax ; preserve the eip register past this call
; segments ; segments
pop eax
pop gs pop gs
pop fs pop fs
pop es pop es

View File

@ -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].offset_high = ((base >> 16) & 0xffff);
IDT[t_idx].type_attrs = type_attrs; IDT[t_idx].type_attrs = type_attrs;
IDT[t_idx].zero = 0;
IDT[t_idx].selector = sel; IDT[t_idx].selector = sel;
} }
@ -83,29 +84,26 @@ void int_keyboard(struct cpu_reg_state* cpu) {
if((u8)code < 0x80 || (u8)code > 0x1f) { if((u8)code < 0x80 || (u8)code > 0x1f) {
putch(code); putch(code);
} }
serial_pic_ack(cpu->int_no);
} }
// Generic interrupt handler to be used later on // 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 // treating things on the stack like it were a cpu_reg_state
// NOTE: dummy stuff to stop gcc from complaining atm // NOTE: dummy stuff to stop gcc from complaining atm
if(cpu.int_no < 32) { printf("handled exception\n");
printf("int response is:\n"); if(cpu->int_no < 32) {
printf(err_msg[cpu.int_no]); printf(err_msg[cpu->int_no]);
}
else {
printf("Unhandled exception");
} }
serial_pic_ack(cpu->int_no);
return; return;
} }
void init_idt() { void init_idt() {
// setup special idt pointer // setup special idt pointer
idt_ptr.address = (u32)(&IDT); 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 // 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 // add interrupt service routines here
setup_idt_entry(0,(u32)no_err_handler_1,0x08, 0x8e); setup_idt_entry(0,(u32)no_err_handler_1,0x08, 0x8e);
setup_idt_entry(1,(u32)no_err_handler_2,0x08, 0x8e); setup_idt_entry(1,(u32)no_err_handler_2,0x08, 0x8e);

View File

@ -44,4 +44,4 @@ struct IDT_PTR idt_ptr;
void init_idt(); void init_idt();
void setup_idt_entry(u32 t_idx, u32 base, u16 sel, u8 type_attrs); void setup_idt_entry(u32 t_idx, u32 base, u16 sel, u8 type_attrs);
void int_keyboard(struct cpu_reg_state*); void int_keyboard(struct cpu_reg_state*);
void interrupt_handler(struct cpu_reg_state); void interrupt_handler(struct cpu_reg_state*);

View File

@ -6,9 +6,7 @@
#include "gdt.h" #include "gdt.h"
void kinit() { void kinit() {
printf("setting up gdt\n");
gdt_configure(); gdt_configure();
printf("setting idt\n");
init_idt(); init_idt();
test_dispatcher(); test_dispatcher();
} }

View File

@ -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 framebuffer.o ports.o stlio.o tests.o interrupt_entry.o
AFLAGS=-f elf32 AFLAGS=-f elf32
CFLAGS=-masm=intel -O2 -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles \ 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 all: kernel.elf

View File

@ -8,9 +8,6 @@ void divide_by_zero() {
int x = 0; int x = 0;
int y = 5; int y = 5;
int z = y/x; int z = y/x;
if(z) {
printf("hmm\n");
}
} }
void test_serial_write() { void test_serial_write() {
@ -28,4 +25,5 @@ void test_dispatcher() {
clear_fb(); clear_fb();
test_write(); test_write();
divide_by_zero(); divide_by_zero();
test_write();
} }