From d895d72c4e8625b435add9067fe8f7298de2d301 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Duje=20Mihanovi=C4=87?= Date: Tue, 21 Jun 2022 16:54:06 +0200 Subject: [PATCH] Separate generic and arch-specific headers --- Makefile | 8 +++----- kernel/arch/x86/halt.s | 9 +++++++++ {include => kernel/include}/arch/x86/io.h | 0 {include => kernel/include}/arch/x86/irq/i8259a.h | 0 {include => kernel/include}/arch/x86/irq/idt.h | 0 {include => kernel/include}/arch/x86/mm/paging.h | 0 {include/arch/x86 => kernel/include}/panic.h | 8 +------- {include/arch/x86 => kernel/include}/tty.h | 4 ++-- 8 files changed, 15 insertions(+), 14 deletions(-) create mode 100644 kernel/arch/x86/halt.s rename {include => kernel/include}/arch/x86/io.h (100%) rename {include => kernel/include}/arch/x86/irq/i8259a.h (100%) rename {include => kernel/include}/arch/x86/irq/idt.h (100%) rename {include => kernel/include}/arch/x86/mm/paging.h (100%) rename {include/arch/x86 => kernel/include}/panic.h (87%) rename {include/arch/x86 => kernel/include}/tty.h (95%) diff --git a/Makefile b/Makefile index 0e56c23..714528a 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,13 @@ export AS = yasm +ASFLAGS = -g dwarf2 -f elf export CC = i686-elf-gcc QEMU = qemu-system-i386 -monitor stdio export GIT_REV = $(shell git describe --long HEAD) -CFLAGS = -g -fgnu89-inline -Iinclude/arch/x86 -ffreestanding -DGIT_COMMIT=\"$(GIT_REV)\" +CFLAGS = -g -fgnu89-inline -Ikernel/include -Ikernel/include/arch/x86 -ffreestanding -DGIT_COMMIT=\"$(GIT_REV)\" -KERNEL_OBJ = kernel/entry.o kernel/arch/x86/tty/tty.o kernel/drivers/irq/i8259a.o kernel/arch/x86/irq/idt.o kernel/arch/x86/irq/sample_handler.o kernel/kernel.o +KERNEL_OBJ = kernel/entry.o kernel/arch/x86/halt.o kernel/arch/x86/tty/tty.o kernel/drivers/irq/i8259a.o kernel/arch/x86/irq/idt.o kernel/arch/x86/irq/sample_handler.o kernel/kernel.o BOOTLOADER_OBJ = boot/x86/mbr boot/x86/vbr-fat32 boot/x86/stage3/LOADER.BIN boot/x86/stage3/loader.elf @@ -41,9 +42,6 @@ boot/x86/disk.img: boot/x86/mbr boot/x86/vbr-fat32 boot/x86/stage3/LOADER.BIN bo kernel/kernel.bin: ${KERNEL_OBJ} kernel/linker.ld $(CC) -ffreestanding -nostdlib -o $@ -T kernel/linker.ld ${KERNEL_OBJ} -kernel/entry.o: kernel/entry.s - $(AS) -f elf $< -o $@ - kernel/arch/x86/irq/sample_handler.o: kernel/arch/x86/irq/sample_handler.c $(CC) $(CFLAGS) -mgeneral-regs-only -c $< -o $@ diff --git a/kernel/arch/x86/halt.s b/kernel/arch/x86/halt.s new file mode 100644 index 0000000..aded520 --- /dev/null +++ b/kernel/arch/x86/halt.s @@ -0,0 +1,9 @@ +; x86-specific routine for halting + +bits 32 +global halt + +halt: + cli + hlt + jmp $-1 diff --git a/include/arch/x86/io.h b/kernel/include/arch/x86/io.h similarity index 100% rename from include/arch/x86/io.h rename to kernel/include/arch/x86/io.h diff --git a/include/arch/x86/irq/i8259a.h b/kernel/include/arch/x86/irq/i8259a.h similarity index 100% rename from include/arch/x86/irq/i8259a.h rename to kernel/include/arch/x86/irq/i8259a.h diff --git a/include/arch/x86/irq/idt.h b/kernel/include/arch/x86/irq/idt.h similarity index 100% rename from include/arch/x86/irq/idt.h rename to kernel/include/arch/x86/irq/idt.h diff --git a/include/arch/x86/mm/paging.h b/kernel/include/arch/x86/mm/paging.h similarity index 100% rename from include/arch/x86/mm/paging.h rename to kernel/include/arch/x86/mm/paging.h diff --git a/include/arch/x86/panic.h b/kernel/include/panic.h similarity index 87% rename from include/arch/x86/panic.h rename to kernel/include/panic.h index c66d6c7..f481e0c 100644 --- a/include/arch/x86/panic.h +++ b/kernel/include/panic.h @@ -1,13 +1,7 @@ #ifndef PANIC_H #define PANIC_H -void halt() -{ - asm("cli":); -loop: - asm("hlt":); - goto loop; -} +extern void halt(); #define PANIC(msg) \ kprint("PANIC (", VGA_COLOR_BRIGHT_RED);\ diff --git a/include/arch/x86/tty.h b/kernel/include/tty.h similarity index 95% rename from include/arch/x86/tty.h rename to kernel/include/tty.h index f2049a2..3e1aab0 100644 --- a/include/arch/x86/tty.h +++ b/kernel/include/tty.h @@ -1,5 +1,5 @@ -#ifndef X86_TTY_H -#define X86_TTY_H +#ifndef TTY_H +#define TTY_H #include -- 2.39.2