diff --git a/Makefile b/Makefile index ebca54f..a175557 100644 --- a/Makefile +++ b/Makefile @@ -15,15 +15,16 @@ VMFLAGS = # Do not touch these. C_SOURCES = $(wildcard kernel/*.c drivers/*.c lib/*.c) +ASM_SOURCES = $(wildcard kernel/*.asm drivers/*.asm lib/*.asm) HEADERS = $(wildcard kernel/*.h drivers/*.h lib/*.h) OBJ = $(C_SOURCES:.c=.o) +AOBJ = $(ASM_SOURCES:.asm=.o) all: eos.iso run: all $(VM) $(VMFLAGS) eos.iso - drun: clean run grub: eos_grub.iso @@ -38,10 +39,9 @@ eos_grub.iso : kernel.bin grub/grub.cfg eos.iso: bootloader/bootloader.bin kernel.bin cat $^ > eos.iso -kernel.bin: kernel/multiboot2.o kernel/kernel_entry.o kernel/enable_paging.o $(OBJ) +kernel.bin: kernel/kernel_entry.o $(OBJ) $(AOBJ) $(LD) -o $@ $^ $(LDFLAGS) - %.o : %.c ${HEADERS} $(CC) $(CFLAGS) -c $< -o $@ diff --git a/kernel/interupt.asm b/kernel/interupt.asm new file mode 100644 index 0000000..6f0891d --- /dev/null +++ b/kernel/interupt.asm @@ -0,0 +1,55 @@ +; osdev crap + +%macro isr_err_stub 1 +isr_stub_%+%1: + call exception_handler + iret +%endmacro + +%macro isr_no_err_stub 1 +isr_stub_%+%1: + call exception_handler + iret +%endmacro + +extern exception_handler +isr_no_err_stub 0 +isr_no_err_stub 1 +isr_no_err_stub 2 +isr_no_err_stub 3 +isr_no_err_stub 4 +isr_no_err_stub 5 +isr_no_err_stub 6 +isr_no_err_stub 7 +isr_err_stub 8 +isr_no_err_stub 9 +isr_err_stub 10 +isr_err_stub 11 +isr_err_stub 12 +isr_err_stub 13 +isr_err_stub 14 +isr_no_err_stub 15 +isr_no_err_stub 16 +isr_err_stub 17 +isr_no_err_stub 18 +isr_no_err_stub 19 +isr_no_err_stub 20 +isr_no_err_stub 21 +isr_no_err_stub 22 +isr_no_err_stub 23 +isr_no_err_stub 24 +isr_no_err_stub 25 +isr_no_err_stub 26 +isr_no_err_stub 27 +isr_no_err_stub 28 +isr_no_err_stub 29 +isr_err_stub 30 +isr_no_err_stub 31 + +global isr_stub_table +isr_stub_table: + %assign i 0 + %rep 32 + dd isr_stub_%+i + %assign i i+1 + %endrep diff --git a/kernel/interupt.h b/kernel/interupt.h index 6119cd9..189b9f6 100644 --- a/kernel/interupt.h +++ b/kernel/interupt.h @@ -1 +1,7 @@ #include "../lib/types.h" + +__attribute__((noreturn)) +void exception_handler(); + +__attribute__((noreturn)) +void interupt_handler();