diff --git a/Makefile b/Makefile index 2d4aee8..b75931b 100644 --- a/Makefile +++ b/Makefile @@ -8,14 +8,15 @@ CFLAGS += -m32 -Wall -Wextra -Werror -ffreestanding -fno-exceptions -fno-pie -fn CXXFLAGS += -m32 -Wall -Wextra -Werror -ffreestanding -fno-exceptions -fno-rtti -fno-pie DEBUG_FLAGS += -g -Og -DDEBUG -fno-omit-frame-pointer -fno-inline -SUBDIRS := core drivers tests +ARCH?=x86 +SUBDIRS := core drivers tests arch/$(ARCH) CPPFLAGS += $(foreach dir, $(SUBDIRS), -I$(dir)) asmsrc=$(wildcard *.asm) asmobj=$(asmsrc:%.asm=%.o) csrc=$(shell find $(SUBDIRS) -type f -name "*.c")# $(wildcard *.c) -cobj=$(csrc:%.c=%.o) core/cpu_context_switch.o drivers/irq_pit.o +cobj=$(csrc:%.c=%.o) arch/$(ARCH)/cpu_context_switch.o arch/$(ARCH)/irq_pit.o deps = $(csrc:%.c=%.d) kernel:$(asmobj) $(cobj) linker.ld @@ -31,9 +32,9 @@ fd.iso: kernel #https://gcc.gnu.org/onlinedocs/gcc/x86-Function-Attributes.html#x86-Function-Attributes -core/exception_handler.o:core/exception_handler.c +arch/$(ARCH)/exception_handler.o:arch/$(ARCH)/exception_handler.c $(CC) $(CFLAGS) $(CPPFLAGS) -mgeneral-regs-only -c $< -o $@ -core/irq_handler.o:core/irq_handler.c +arch/$(ARCH)/irq_handler.o:arch/$(ARCH)/irq_handler.c $(CC) $(CFLAGS) $(CPPFLAGS) -mgeneral-regs-only -c $< -o $@ %.o:%.asm diff --git a/core/cpu_context.c b/arch/x86/cpu_context.c similarity index 100% rename from core/cpu_context.c rename to arch/x86/cpu_context.c diff --git a/core/cpu_context_switch.S b/arch/x86/cpu_context_switch.S similarity index 100% rename from core/cpu_context_switch.S rename to arch/x86/cpu_context_switch.S diff --git a/core/exception.c b/arch/x86/exception.c similarity index 100% rename from core/exception.c rename to arch/x86/exception.c diff --git a/core/exception.h b/arch/x86/exception.h similarity index 100% rename from core/exception.h rename to arch/x86/exception.h diff --git a/core/exception_handler.c b/arch/x86/exception_handler.c similarity index 100% rename from core/exception_handler.c rename to arch/x86/exception_handler.c diff --git a/core/gdt.c b/arch/x86/gdt.c similarity index 100% rename from core/gdt.c rename to arch/x86/gdt.c diff --git a/core/gdt.h b/arch/x86/gdt.h similarity index 100% rename from core/gdt.h rename to arch/x86/gdt.h diff --git a/core/idt.c b/arch/x86/idt.c similarity index 100% rename from core/idt.c rename to arch/x86/idt.c diff --git a/core/idt.h b/arch/x86/idt.h similarity index 100% rename from core/idt.h rename to arch/x86/idt.h diff --git a/core/interrupt.h b/arch/x86/interrupt.h similarity index 99% rename from core/interrupt.h rename to arch/x86/interrupt.h index 0be216b..5b27cd9 100644 --- a/core/interrupt.h +++ b/arch/x86/interrupt.h @@ -10,7 +10,6 @@ struct interrupt_frame { uint32_t ss; }; -// Exception // Exception #define DECLARE_INTERRUPT(int_nb) \ void print_handler_##int_nb(struct interrupt_frame *frame, ulong error_code); diff --git a/core/irq.c b/arch/x86/irq.c similarity index 100% rename from core/irq.c rename to arch/x86/irq.c diff --git a/core/irq.h b/arch/x86/irq.h similarity index 100% rename from core/irq.h rename to arch/x86/irq.h diff --git a/core/irq_handler.c b/arch/x86/irq_handler.c similarity index 100% rename from core/irq_handler.c rename to arch/x86/irq_handler.c diff --git a/drivers/irq_pit.S b/arch/x86/irq_pit.S similarity index 100% rename from drivers/irq_pit.S rename to arch/x86/irq_pit.S diff --git a/core/paging.c b/arch/x86/paging.c similarity index 100% rename from core/paging.c rename to arch/x86/paging.c diff --git a/core/paging.h b/arch/x86/paging.h similarity index 100% rename from core/paging.h rename to arch/x86/paging.h