diff --git a/Makefile b/Makefile index 5cc40b7..9e03db7 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,11 @@ CC = i686-elf-gcc INCLUDE = -I./include -I./lib CFLAGS = -Wall -Wextra -Werror -ffreestanding $(INCLUDE) -LDFLAGS = -T kernel.ld -ffreestanding -O3 -nostdlib -lgcc +LDFLAGS = -T kernel/kernel.ld -ffreestanding -O3 -nostdlib -lgcc BUILDDIR = build -KERNELSRC := $(shell find . -name '*.c' -o -name '*.asm') +KERNELSRC := $(shell find ./kernel -name '*.c' -o -name '*.asm') KERNELOBJ := $(addprefix $(BUILDDIR)/, \ $(notdir \ $(patsubst %.c,%.o,\ @@ -28,9 +28,9 @@ kernel: $(KERNELIMG) $(KERNELIMG): $(KERNELOBJ) $(CC) $^ -o $@ $(LDFLAGS) -$(BUILDDIR)/%.o: %.c +$(BUILDDIR)/%.o: */%.c $(CC) $(CFLAGS) -c $^ -o $@ -$(BUILDDIR)/%.o: %.asm +$(BUILDDIR)/%.o: */%.asm nasm -felf32 $^ -o $@ qemu: kernel diff --git a/include/acpi.h b/include/kernel/acpi.h similarity index 100% rename from include/acpi.h rename to include/kernel/acpi.h diff --git a/include/gdt.h b/include/kernel/gdt.h similarity index 98% rename from include/gdt.h rename to include/kernel/gdt.h index d0d3477..7edb5a2 100644 --- a/include/gdt.h +++ b/include/kernel/gdt.h @@ -2,7 +2,7 @@ #define RK_GDT_H_ #include -#include +#include #define GDT_NULL 0 #define GDT_KERNEL_CODE 1 diff --git a/include/ide.h b/include/kernel/ide.h similarity index 100% rename from include/ide.h rename to include/kernel/ide.h diff --git a/include/idt.h b/include/kernel/idt.h similarity index 100% rename from include/idt.h rename to include/kernel/idt.h diff --git a/include/io.h b/include/kernel/io.h similarity index 100% rename from include/io.h rename to include/kernel/io.h diff --git a/include/kernel.h b/include/kernel/kernel.h similarity index 85% rename from include/kernel.h rename to include/kernel/kernel.h index 044e6cd..a6a12a0 100644 --- a/include/kernel.h +++ b/include/kernel/kernel.h @@ -1,8 +1,8 @@ #ifndef RK_KERNEL_H_ #define RK_KERNEL_H_ -#include -#include +#include +#include struct kernel_context { struct rsdp *rsdp; diff --git a/include/mem.h b/include/kernel/mem.h similarity index 95% rename from include/mem.h rename to include/kernel/mem.h index 1e7e296..d74de14 100644 --- a/include/mem.h +++ b/include/kernel/mem.h @@ -1,7 +1,7 @@ #ifndef RK_MEM_H_ #define RK_MEM_H_ -#include +#include #include #define KERNEL_START 0x1000000 // 1 MiB diff --git a/include/multiboot.h b/include/kernel/multiboot.h similarity index 100% rename from include/multiboot.h rename to include/kernel/multiboot.h diff --git a/include/pci.h b/include/kernel/pci.h similarity index 98% rename from include/pci.h rename to include/kernel/pci.h index 3611004..79cc2a7 100644 --- a/include/pci.h +++ b/include/kernel/pci.h @@ -2,7 +2,7 @@ #define RK_PCI_H_ #include -#include +#include #define PCI_ADDR(addr, bus, device, func) (addr + ((bus) << 20 | device << 15 | func << 12)) diff --git a/include/pic8259.h b/include/kernel/pic8259.h similarity index 95% rename from include/pic8259.h rename to include/kernel/pic8259.h index a2e78e0..2d543a0 100644 --- a/include/pic8259.h +++ b/include/kernel/pic8259.h @@ -14,7 +14,7 @@ #define PIC_1_ICW3 0x04 #define PIC_2_ICW3 0x02 -#include +#include enum ICW1 { ICW4_NEEDED = 0x01, diff --git a/include/printf.h b/include/kernel/printf.h similarity index 100% rename from include/printf.h rename to include/kernel/printf.h diff --git a/include/ps2.h b/include/kernel/ps2.h similarity index 100% rename from include/ps2.h rename to include/kernel/ps2.h diff --git a/include/strcmp.h b/include/kernel/strcmp.h similarity index 100% rename from include/strcmp.h rename to include/kernel/strcmp.h diff --git a/include/vga.h b/include/kernel/vga.h similarity index 100% rename from include/vga.h rename to include/kernel/vga.h diff --git a/acpi.c b/kernel/acpi.c similarity index 96% rename from acpi.c rename to kernel/acpi.c index d58081c..7141150 100644 --- a/acpi.c +++ b/kernel/acpi.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include struct rsdp *acpi_locate_rsdp() { char *ptr = (char *)BIOS_START; diff --git a/gdt.c b/kernel/gdt.c similarity index 97% rename from gdt.c rename to kernel/gdt.c index f5a8af2..cbd306a 100644 --- a/gdt.c +++ b/kernel/gdt.c @@ -1,4 +1,4 @@ -#include +#include void write_tss(struct tss_entry *tss, struct gdt_entry *gdt, int num, uint16_t ss0, uint32_t esp0) { uint32_t base = (uint32_t)tss; diff --git a/ide.c b/kernel/ide.c similarity index 97% rename from ide.c rename to kernel/ide.c index 789598c..d746d1d 100644 --- a/ide.c +++ b/kernel/ide.c @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include uint16_t ide_select_drive(uint8_t bus, uint8_t drive) { if (bus == ATA_PRIMARY) { diff --git a/idt.c b/kernel/idt.c similarity index 91% rename from idt.c rename to kernel/idt.c index e020b10..a16fb8e 100644 --- a/idt.c +++ b/kernel/idt.c @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include void encode_idt_entry(struct idt_entry idt[], int i, uint32_t offset, uint16_t segment_selector, uint8_t attributes) { idt[i].offset_lo = (uint16_t)(offset & 0xFFFF); diff --git a/io.c b/kernel/io.c similarity index 95% rename from io.c rename to kernel/io.c index 207ee25..f57f6b1 100644 --- a/io.c +++ b/kernel/io.c @@ -1,4 +1,4 @@ -#include +#include uint8_t inportb(uint16_t port) { uint8_t result; diff --git a/kernel.ld b/kernel/kernel.ld similarity index 100% rename from kernel.ld rename to kernel/kernel.ld diff --git a/kmain.c b/kernel/kmain.c similarity index 95% rename from kmain.c rename to kernel/kmain.c index c436ea5..cf7024a 100644 --- a/kmain.c +++ b/kernel/kmain.c @@ -1,16 +1,16 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #define MAGIC_BREAKPOINT __asm__ volatile("xchgw %bx, %bx"); #define FD_STDOUT 0 diff --git a/mem.c b/kernel/mem.c similarity index 98% rename from mem.c rename to kernel/mem.c index 20e6924..f74fc59 100644 --- a/mem.c +++ b/kernel/mem.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include // TODO: Fix this, it wastes memory when switching regions because the previous offset isnt being subtracted // Should work fine for now? diff --git a/multiboot.asm b/kernel/multiboot.asm similarity index 100% rename from multiboot.asm rename to kernel/multiboot.asm diff --git a/pci.c b/kernel/pci.c similarity index 96% rename from pci.c rename to kernel/pci.c index ae1d2a4..6aaa02e 100644 --- a/pci.c +++ b/kernel/pci.c @@ -1,4 +1,4 @@ -#include +#include struct pci_config_space *pcie_find_device(struct mcfg *mcfg, uint8_t class, uint8_t subclass) { int entries = (mcfg->h.Length - 44) / 16; diff --git a/pic8259.c b/kernel/pic8259.c similarity index 96% rename from pic8259.c rename to kernel/pic8259.c index 51b3024..a33a0d2 100644 --- a/pic8259.c +++ b/kernel/pic8259.c @@ -1,4 +1,4 @@ -#include +#include void pic_send_eoi(uint8_t irq) { if (irq > 7) diff --git a/printf.c b/kernel/printf.c similarity index 96% rename from printf.c rename to kernel/printf.c index 7cec77a..9f644a8 100644 --- a/printf.c +++ b/kernel/printf.c @@ -33,7 +33,7 @@ #include #include -#include "printf.h" +#include // define this globally (e.g. gcc -DPRINTF_INCLUDE_CONFIG_H ...) to include the diff --git a/ps2.c b/kernel/ps2.c similarity index 98% rename from ps2.c rename to kernel/ps2.c index 0f67b43..87480ac 100644 --- a/ps2.c +++ b/kernel/ps2.c @@ -1,11 +1,11 @@ -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #define cpu_relax asm volatile ("pause" ::); diff --git a/strcmp.c b/kernel/strcmp.c similarity index 94% rename from strcmp.c rename to kernel/strcmp.c index 6c4226a..852489f 100644 --- a/strcmp.c +++ b/kernel/strcmp.c @@ -1,4 +1,4 @@ -#include +#include int strcmp(const char *s1, const char *s2) { diff --git a/vga.c b/kernel/vga.c similarity index 96% rename from vga.c rename to kernel/vga.c index 4a26359..e4b369d 100644 --- a/vga.c +++ b/kernel/vga.c @@ -6,9 +6,9 @@ * @date 2024-02-03 */ -#include -#include -#include +#include +#include +#include enum VGA_COLOR vga_color = VGA_COLOR_WHITE;