diff --git a/Makefile b/Makefile index 861baf0..87de96c 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,15 @@ AS=nasm ASFLAGS += -f elf32 LDFLAGS += -m32 -nostdlib -static -fno-common -fno-use-cxa-atexit -fno-exceptions -fno-non-call-exceptions -fno-weak -fno-rtti -fno-stack-protector CFLAGS += -m32 -Wall -Wextra -Werror -ffreestanding -fno-exceptions -fno-pie -fno-stack-protector -CXXFLAGS += -m32 -Wall -Wextra -Werror -ffreestanding -fno-exceptions -fno-rtti -fno-pie +CXXFLAGS += -m32 -Wall -Wextra -Werror -ffreestanding -fno-exceptions -fno-rtti -fno-pie +SUBDIRS := core drivers + +CPPFLAGS += $(foreach dir, $(SUBDIRS), -I$(dir)) asmsrc=$(wildcard *.asm) asmobj=$(asmsrc:%.asm=%.o) -csrc=$(wildcard *.c) +csrc=$(shell find $(SUBDIRS) -type f -name "*.c")# $(wildcard *.c) cobj=$(csrc:%.c=%.o) deps = $(csrc:%.c=%.d) @@ -21,10 +24,10 @@ fd.img: kernel dd if=$< of=$@ conv=notrunc #https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html#x86-Function-Attributes -exception_handler.o:exception_handler.c - $(CC) $(CPPFLAGS) $(CFLAGS) -mgeneral-regs-only -c $< -irq_handler.o:irq_handler.c - $(CC) $(CPPFLAGS) $(CFLAGS) -mgeneral-regs-only -c $< +core/exception_handler.o:core/exception_handler.c + $(CC) $(CPPFLAGS) $(CFLAGS) -mgeneral-regs-only -c $< -o $@ +core/irq_handler.o:core/irq_handler.c + $(CC) $(CPPFLAGS) $(CFLAGS) -mgeneral-regs-only -c $< -o $@ %.o:%.asm $(AS) $(ASFLAGS) -o $@ $< diff --git a/exception.c b/core/exception.c similarity index 100% rename from exception.c rename to core/exception.c diff --git a/core/exception.d b/core/exception.d new file mode 100644 index 0000000..fe80462 --- /dev/null +++ b/core/exception.d @@ -0,0 +1,2 @@ +core/exception.o: core/exception.c core/exception.h core/interrupt.h \ + core/types.h core/idt.h core/irq.h diff --git a/exception.h b/core/exception.h similarity index 100% rename from exception.h rename to core/exception.h diff --git a/core/exception.o b/core/exception.o new file mode 100644 index 0000000..e11db92 Binary files /dev/null and b/core/exception.o differ diff --git a/exception_handler.c b/core/exception_handler.c similarity index 100% rename from exception_handler.c rename to core/exception_handler.c diff --git a/core/exception_handler.d b/core/exception_handler.d new file mode 100644 index 0000000..4861b41 --- /dev/null +++ b/core/exception_handler.d @@ -0,0 +1,2 @@ +core/exception_handler.o: core/exception_handler.c core/exception.h \ + core/interrupt.h core/types.h drivers/vga.h diff --git a/core/exception_handler.o b/core/exception_handler.o new file mode 100644 index 0000000..35919bf Binary files /dev/null and b/core/exception_handler.o differ diff --git a/gdt.c b/core/gdt.c similarity index 100% rename from gdt.c rename to core/gdt.c diff --git a/core/gdt.d b/core/gdt.d new file mode 100644 index 0000000..18f7804 --- /dev/null +++ b/core/gdt.d @@ -0,0 +1 @@ +core/gdt.o: core/gdt.c core/segment.h core/types.h core/gdt.h diff --git a/gdt.h b/core/gdt.h similarity index 100% rename from gdt.h rename to core/gdt.h diff --git a/core/gdt.o b/core/gdt.o new file mode 100644 index 0000000..8eb0902 Binary files /dev/null and b/core/gdt.o differ diff --git a/idt.c b/core/idt.c similarity index 100% rename from idt.c rename to core/idt.c diff --git a/core/idt.d b/core/idt.d new file mode 100644 index 0000000..583e8c3 --- /dev/null +++ b/core/idt.d @@ -0,0 +1 @@ +core/idt.o: core/idt.c core/idt.h core/types.h diff --git a/idt.h b/core/idt.h similarity index 100% rename from idt.h rename to core/idt.h diff --git a/core/idt.o b/core/idt.o new file mode 100644 index 0000000..6d4e41f Binary files /dev/null and b/core/idt.o differ diff --git a/interrupt.h b/core/interrupt.h similarity index 100% rename from interrupt.h rename to core/interrupt.h diff --git a/io.h b/core/io.h similarity index 100% rename from io.h rename to core/io.h diff --git a/irq.c b/core/irq.c similarity index 100% rename from irq.c rename to core/irq.c diff --git a/core/irq.d b/core/irq.d new file mode 100644 index 0000000..90732f6 --- /dev/null +++ b/core/irq.d @@ -0,0 +1,2 @@ +core/irq.o: core/irq.c core/irq.h core/interrupt.h core/types.h \ + core/idt.h drivers/pic.h diff --git a/irq.h b/core/irq.h similarity index 100% rename from irq.h rename to core/irq.h diff --git a/core/irq.o b/core/irq.o new file mode 100644 index 0000000..6877255 Binary files /dev/null and b/core/irq.o differ diff --git a/irq_handler.c b/core/irq_handler.c similarity index 100% rename from irq_handler.c rename to core/irq_handler.c diff --git a/core/irq_handler.d b/core/irq_handler.d new file mode 100644 index 0000000..396327a --- /dev/null +++ b/core/irq_handler.d @@ -0,0 +1,2 @@ +core/irq_handler.o: core/irq_handler.c core/interrupt.h core/types.h \ + core/io.h core/irq.h drivers/pic.h drivers/vga.h diff --git a/core/irq_handler.o b/core/irq_handler.o new file mode 100644 index 0000000..de621bd Binary files /dev/null and b/core/irq_handler.o differ diff --git a/klibc.c b/core/klibc.c similarity index 100% rename from klibc.c rename to core/klibc.c diff --git a/core/klibc.d b/core/klibc.d new file mode 100644 index 0000000..f52007a --- /dev/null +++ b/core/klibc.d @@ -0,0 +1 @@ +core/klibc.o: core/klibc.c core/klibc.h core/types.h diff --git a/klibc.h b/core/klibc.h similarity index 100% rename from klibc.h rename to core/klibc.h diff --git a/core/klibc.o b/core/klibc.o new file mode 100644 index 0000000..e638fd2 Binary files /dev/null and b/core/klibc.o differ diff --git a/main.c b/core/main.c similarity index 100% rename from main.c rename to core/main.c diff --git a/core/main.d b/core/main.d new file mode 100644 index 0000000..b210ef6 --- /dev/null +++ b/core/main.d @@ -0,0 +1,2 @@ +core/main.o: core/main.c core/exception.h core/interrupt.h core/types.h \ + core/gdt.h core/idt.h core/io.h core/irq.h drivers/pit.h drivers/vga.h diff --git a/core/main.o b/core/main.o new file mode 100644 index 0000000..01f4334 Binary files /dev/null and b/core/main.o differ diff --git a/segment.h b/core/segment.h similarity index 100% rename from segment.h rename to core/segment.h diff --git a/types.h b/core/types.h similarity index 100% rename from types.h rename to core/types.h diff --git a/pic.c b/drivers/pic.c similarity index 100% rename from pic.c rename to drivers/pic.c diff --git a/drivers/pic.d b/drivers/pic.d new file mode 100644 index 0000000..67cd314 --- /dev/null +++ b/drivers/pic.d @@ -0,0 +1,2 @@ +drivers/pic.o: drivers/pic.c drivers/pic.h core/io.h core/types.h \ + core/irq.h core/interrupt.h diff --git a/pic.h b/drivers/pic.h similarity index 100% rename from pic.h rename to drivers/pic.h diff --git a/drivers/pic.o b/drivers/pic.o new file mode 100644 index 0000000..fc0813b Binary files /dev/null and b/drivers/pic.o differ diff --git a/pit.c b/drivers/pit.c similarity index 100% rename from pit.c rename to drivers/pit.c diff --git a/drivers/pit.d b/drivers/pit.d new file mode 100644 index 0000000..e570f13 --- /dev/null +++ b/drivers/pit.d @@ -0,0 +1 @@ +drivers/pit.o: drivers/pit.c drivers/pit.h core/io.h core/types.h diff --git a/pit.h b/drivers/pit.h similarity index 100% rename from pit.h rename to drivers/pit.h diff --git a/drivers/pit.o b/drivers/pit.o new file mode 100644 index 0000000..58447e4 Binary files /dev/null and b/drivers/pit.o differ diff --git a/vga.c b/drivers/vga.c similarity index 100% rename from vga.c rename to drivers/vga.c diff --git a/drivers/vga.d b/drivers/vga.d new file mode 100644 index 0000000..8950c40 --- /dev/null +++ b/drivers/vga.d @@ -0,0 +1,2 @@ +drivers/vga.o: drivers/vga.c drivers/vga.h core/types.h core/io.h \ + core/klibc.h diff --git a/vga.h b/drivers/vga.h similarity index 100% rename from vga.h rename to drivers/vga.h diff --git a/drivers/vga.o b/drivers/vga.o new file mode 100644 index 0000000..35142b5 Binary files /dev/null and b/drivers/vga.o differ