From 3a87b742244ff6d9e2f078b06c6a8939233e90fd Mon Sep 17 00:00:00 2001 From: Nigel Date: Tue, 16 Nov 2021 13:57:15 +0100 Subject: [PATCH] Renaming/Moving stuff into a different file structure --- Makefile | 16 +++--- src/kernel/{arch/i386 => }/boot.S | 49 +++---------------- src/kernel/bootcheck.h | 2 +- src/kernel/{arch/i386 => }/crti.s | 0 src/kernel/{arch/i386 => }/crtn.s | 0 src/kernel/{arch/i386 => }/gdt/gdt.s | 40 ++++++++++++++- src/kernel/{arch/i386 => }/gdt/gdtc.cpp | 0 src/kernel/{arch/i386 => }/gdt/gdtc.h | 0 src/kernel/{arch/i386 => }/idt/idt.cpp | 0 src/kernel/{arch/i386 => }/idt/idt.h | 0 src/kernel/{arch/i386 => }/idt/idt.s | 0 .../{arch/i386 => }/idt/scancodes/set1.h | 0 src/kernel/{arch/i386 => }/irq_table.s | 0 src/kernel/{arch/i386 => }/irs_table.s | 0 src/kernel/kernel.cpp | 3 ++ src/kernel/kernel.h | 8 +-- src/kernel/{arch/i386 => }/linker.ld | 0 src/kernel/memory/PageDirectory.cpp | 2 +- src/kernel/{arch/i386 => }/paging.s | 0 src/kernel/{arch/i386 => }/pic/pic.cpp | 0 src/kernel/{arch/i386 => }/pic/pic.h | 2 +- src/kernel/{arch/i386 => }/ports/serial.cpp | 0 src/kernel/{arch/i386 => }/ports/serial.h | 0 src/kernel/serial.h | 2 +- src/kernel/{arch/i386 => }/tty/kterm.cpp | 0 src/kernel/{arch/i386 => }/tty/kterm.h | 4 +- src/kernel/{arch/i386 => }/vga/VBE.h | 0 src/kernel/{arch/i386 => }/vga/colors.h | 0 28 files changed, 66 insertions(+), 62 deletions(-) rename src/kernel/{arch/i386 => }/boot.S (58%) rename src/kernel/{arch/i386 => }/crti.s (100%) rename src/kernel/{arch/i386 => }/crtn.s (100%) rename src/kernel/{arch/i386 => }/gdt/gdt.s (63%) rename src/kernel/{arch/i386 => }/gdt/gdtc.cpp (100%) rename src/kernel/{arch/i386 => }/gdt/gdtc.h (100%) rename src/kernel/{arch/i386 => }/idt/idt.cpp (100%) rename src/kernel/{arch/i386 => }/idt/idt.h (100%) rename src/kernel/{arch/i386 => }/idt/idt.s (100%) rename src/kernel/{arch/i386 => }/idt/scancodes/set1.h (100%) rename src/kernel/{arch/i386 => }/irq_table.s (100%) rename src/kernel/{arch/i386 => }/irs_table.s (100%) rename src/kernel/{arch/i386 => }/linker.ld (100%) rename src/kernel/{arch/i386 => }/paging.s (100%) rename src/kernel/{arch/i386 => }/pic/pic.cpp (100%) rename src/kernel/{arch/i386 => }/pic/pic.h (95%) rename src/kernel/{arch/i386 => }/ports/serial.cpp (100%) rename src/kernel/{arch/i386 => }/ports/serial.h (100%) rename src/kernel/{arch/i386 => }/tty/kterm.cpp (100%) rename src/kernel/{arch/i386 => }/tty/kterm.h (93%) rename src/kernel/{arch/i386 => }/vga/VBE.h (100%) rename src/kernel/{arch/i386 => }/vga/colors.h (100%) diff --git a/Makefile b/Makefile index c287066..d983334 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ test: build_kernel: $(OBJ_LINK_LIST) - $(CC) -T $(SRC_DIR)/kernel/arch/i386/linker.ld -o $(BUILD_DIR)/myos.bin \ + $(CC) -T $(SRC_DIR)/kernel//linker.ld -o $(BUILD_DIR)/myos.bin \ -ffreestanding -O2 -nostdlib $(OBJ_LINK_LIST) -lgcc build_x86_64: @@ -57,16 +57,16 @@ $(BUILD_DIR)/kernel.o: $(CPP) -c $(SRC_DIR)/kernel/kernel.cpp -o $(BUILD_DIR)/kernel.o $(CFLAGS) -fno-exceptions -fno-rtti $(BUILD_DIR)/kterm.o: - $(CPP) -c $(SRC_DIR)/kernel/arch/i386/tty/kterm.cpp -o $(BUILD_DIR)/kterm.o $(CFLAGS) -fno-exceptions -fno-rtti + $(CPP) -c $(SRC_DIR)/kernel/tty/kterm.cpp -o $(BUILD_DIR)/kterm.o $(CFLAGS) -fno-exceptions -fno-rtti $(BUILD_DIR)/boot.o: - $(AS) $(SRC_DIR)/kernel/arch/i386/boot.S -o $(BUILD_DIR)/boot.o + $(AS) $(SRC_DIR)/kernel//boot.S -o $(BUILD_DIR)/boot.o $(BUILD_DIR)/crti.o: - $(AS) $(SRC_DIR)/kernel/arch/i386/crti.s -o $(BUILD_DIR)/crti.o + $(AS) $(SRC_DIR)/kernel/crti.s -o $(BUILD_DIR)/crti.o $(BUILD_DIR)/crtn.o: - $(AS) $(SRC_DIR)/kernel/arch/i386/crtn.s -o $(BUILD_DIR)/crtn.o + $(AS) $(SRC_DIR)/kernel/crtn.s -o $(BUILD_DIR)/crtn.o $(BUILD_DIR)/io.o: $(CPP) -c $(SRC_DIR)/kernel/io.cpp -o $(BUILD_DIR)/io.o $(CFLAGS) -fno-exceptions -fno-rtti @@ -75,14 +75,14 @@ $(BUILD_DIR)/PageDirectory.o: $(CPP) -c $(SRC_DIR)/kernel/memory/PageDirectory.cpp -o $(BUILD_DIR)/PageDirectory.o $(CFLAGS) -fno-exceptions -fno-rtti $(BUILD_DIR)/idt.o: - $(CPP) -c $(SRC_DIR)/kernel/arch/i386/idt/idt.cpp -o $(BUILD_DIR)/idt.o $(CFLAGS) -fno-exceptions -fno-rtti + $(CPP) -c $(SRC_DIR)/kernel/idt/idt.cpp -o $(BUILD_DIR)/idt.o $(CFLAGS) -fno-exceptions -fno-rtti $(BUILD_DIR)/gdtc.o: - $(CPP) -c $(SRC_DIR)/kernel/arch/i386/gdt/gdtc.cpp -o $(BUILD_DIR)/gdtc.o $(CFLAGS) -fno-exceptions -fno-rtti + $(CPP) -c $(SRC_DIR)/kernel/gdt/gdtc.cpp -o $(BUILD_DIR)/gdtc.o $(CFLAGS) -fno-exceptions -fno-rtti $(BUILD_DIR)/pic.o: - $(CPP) -c $(SRC_DIR)/kernel/arch/i386/pic/pic.cpp -o $(BUILD_DIR)/pic.o $(CFLAGS) -fno-exceptions -fno-rtti + $(CPP) -c $(SRC_DIR)/kernel/pic/pic.cpp -o $(BUILD_DIR)/pic.o $(CFLAGS) -fno-exceptions -fno-rtti $(BUILD_DIR)/string.o: $(CC) -c $(SRC_DIR)/libc/include/string.c -o $(BUILD_DIR)/string.o $(CFLAGS) -std=gnu99 diff --git a/src/kernel/arch/i386/boot.S b/src/kernel/boot.S similarity index 58% rename from src/kernel/arch/i386/boot.S rename to src/kernel/boot.S index edfd9a4..f9ea085 100644 --- a/src/kernel/arch/i386/boot.S +++ b/src/kernel/boot.S @@ -21,10 +21,10 @@ stack_bottom: stack_top: .section .text -.include "./src/kernel/arch/i386/irs_table.s" -.include "./src/kernel/arch/i386/irq_table.s" -.include "./src/kernel/arch/i386/idt/idt.s" -.include "./src/kernel/arch/i386/paging.s" +.include "./src/kernel/irs_table.s" +.include "./src/kernel/irq_table.s" +.include "./src/kernel/idt/idt.s" +.include "./src/kernel/paging.s" .global _start @@ -46,44 +46,7 @@ _start: call early_main cli - .global load_gdt - load_gdt: - lgdt gdt - - # set the segment selecters - - movw $0x10, %ax - movw %ax, %ds - movw %ax, %es - movw %ax, %fs - movw %ax, %gs - movw %ax, %ss - ljmp $0x08, $flush - - flush: - - - #load idt - call init_idt - sti - - # Try enable A20 - # mov $0x2401, %ax - # int $0x15 - - - # enable protected mode - mov %cr0, %eax - or $1, %eax - mov %eax, %cr0 - - - call kernel_main - - - cli - 1: hlt - jmp 1b + -.include "./src/kernel/arch/i386/gdt/gdt.s" +.include "./src/kernel/gdt/gdt.s" diff --git a/src/kernel/bootcheck.h b/src/kernel/bootcheck.h index 6fbe49b..028eeba 100644 --- a/src/kernel/bootcheck.h +++ b/src/kernel/bootcheck.h @@ -2,7 +2,7 @@ #include "bootloader/multiboot.h" #define CHECK_FLAG(flags, bit) ((flags) & (1 <<(bit))) -#include "arch/i386/tty/kterm.h" +#include "tty/kterm.h" diff --git a/src/kernel/arch/i386/crti.s b/src/kernel/crti.s similarity index 100% rename from src/kernel/arch/i386/crti.s rename to src/kernel/crti.s diff --git a/src/kernel/arch/i386/crtn.s b/src/kernel/crtn.s similarity index 100% rename from src/kernel/arch/i386/crtn.s rename to src/kernel/crtn.s diff --git a/src/kernel/arch/i386/gdt/gdt.s b/src/kernel/gdt/gdt.s similarity index 63% rename from src/kernel/arch/i386/gdt/gdt.s rename to src/kernel/gdt/gdt.s index 066cd1f..25f7cd5 100644 --- a/src/kernel/arch/i386/gdt/gdt.s +++ b/src/kernel/gdt/gdt.s @@ -6,10 +6,48 @@ gdt: .att_syntax +.global load_gdt + load_gdt: + lgdt gdt + + # set the segment selecters + + movw $0x10, %ax + movw %ax, %ds + movw %ax, %es + movw %ax, %fs + movw %ax, %gs + movw %ax, %ss + ljmp $0x08, $flush + + flush: + + + #load idt + call init_idt + sti + + # Try enable A20 + # mov $0x2401, %ax + # int $0x15 + + + # enable protected mode + mov %cr0, %eax + or $1, %eax + mov %eax, %cr0 + + + call kernel_main + + + cli + 1: hlt + jmp 1b + .size _start, . - _start - /* * Create the GDT */ diff --git a/src/kernel/arch/i386/gdt/gdtc.cpp b/src/kernel/gdt/gdtc.cpp similarity index 100% rename from src/kernel/arch/i386/gdt/gdtc.cpp rename to src/kernel/gdt/gdtc.cpp diff --git a/src/kernel/arch/i386/gdt/gdtc.h b/src/kernel/gdt/gdtc.h similarity index 100% rename from src/kernel/arch/i386/gdt/gdtc.h rename to src/kernel/gdt/gdtc.h diff --git a/src/kernel/arch/i386/idt/idt.cpp b/src/kernel/idt/idt.cpp similarity index 100% rename from src/kernel/arch/i386/idt/idt.cpp rename to src/kernel/idt/idt.cpp diff --git a/src/kernel/arch/i386/idt/idt.h b/src/kernel/idt/idt.h similarity index 100% rename from src/kernel/arch/i386/idt/idt.h rename to src/kernel/idt/idt.h diff --git a/src/kernel/arch/i386/idt/idt.s b/src/kernel/idt/idt.s similarity index 100% rename from src/kernel/arch/i386/idt/idt.s rename to src/kernel/idt/idt.s diff --git a/src/kernel/arch/i386/idt/scancodes/set1.h b/src/kernel/idt/scancodes/set1.h similarity index 100% rename from src/kernel/arch/i386/idt/scancodes/set1.h rename to src/kernel/idt/scancodes/set1.h diff --git a/src/kernel/arch/i386/irq_table.s b/src/kernel/irq_table.s similarity index 100% rename from src/kernel/arch/i386/irq_table.s rename to src/kernel/irq_table.s diff --git a/src/kernel/arch/i386/irs_table.s b/src/kernel/irs_table.s similarity index 100% rename from src/kernel/arch/i386/irs_table.s rename to src/kernel/irs_table.s diff --git a/src/kernel/kernel.cpp b/src/kernel/kernel.cpp index 72e5622..cb338d2 100644 --- a/src/kernel/kernel.cpp +++ b/src/kernel/kernel.cpp @@ -43,6 +43,9 @@ printf( "UTC time: %02d-%02d-%02d %02d:%02d:%02d [ Formatted as YY-MM-DD h:mm:ss]\r" ,year, month, day, hour, minute, second); delay(1000); } + + + } diff --git a/src/kernel/kernel.h b/src/kernel/kernel.h index 2c61697..f82f5da 100644 --- a/src/kernel/kernel.h +++ b/src/kernel/kernel.h @@ -2,15 +2,15 @@ extern "C"{ #include "../libc/include/string.h" } -#include "arch/i386/vga/VBE.h" -#include "arch/i386/tty/kterm.h" +#include "vga/VBE.h" +#include "tty/kterm.h" #include "./bootloader/multiboot.h" #include "bootcheck.h" #include "memory/PhysicalMemoryManager.h" -#include "arch/i386/gdt/gdtc.h" -#include "arch/i386/idt/idt.h" +#include "gdt/gdtc.h" +#include "idt/idt.h" #include "io.h" #include "time.h" diff --git a/src/kernel/arch/i386/linker.ld b/src/kernel/linker.ld similarity index 100% rename from src/kernel/arch/i386/linker.ld rename to src/kernel/linker.ld diff --git a/src/kernel/memory/PageDirectory.cpp b/src/kernel/memory/PageDirectory.cpp index ca7a6d5..f740680 100644 --- a/src/kernel/memory/PageDirectory.cpp +++ b/src/kernel/memory/PageDirectory.cpp @@ -4,7 +4,7 @@ void PageDirectory::enable(){ - + // https://wiki.osdev.org/Setting_Up_Paging //set each entry to not present int i; for(i = 0; i < 1024; i++) diff --git a/src/kernel/arch/i386/paging.s b/src/kernel/paging.s similarity index 100% rename from src/kernel/arch/i386/paging.s rename to src/kernel/paging.s diff --git a/src/kernel/arch/i386/pic/pic.cpp b/src/kernel/pic/pic.cpp similarity index 100% rename from src/kernel/arch/i386/pic/pic.cpp rename to src/kernel/pic/pic.cpp diff --git a/src/kernel/arch/i386/pic/pic.h b/src/kernel/pic/pic.h similarity index 95% rename from src/kernel/arch/i386/pic/pic.h rename to src/kernel/pic/pic.h index 3248187..9560cea 100644 --- a/src/kernel/arch/i386/pic/pic.h +++ b/src/kernel/pic/pic.h @@ -1,5 +1,5 @@ #pragma once -#include "../../../io.h" +#include "../io.h" #define PIC1 0x20 /* IO base address for master PIC */ #define PIC2 0xA0 /* IO base address for slave PIC */ diff --git a/src/kernel/arch/i386/ports/serial.cpp b/src/kernel/ports/serial.cpp similarity index 100% rename from src/kernel/arch/i386/ports/serial.cpp rename to src/kernel/ports/serial.cpp diff --git a/src/kernel/arch/i386/ports/serial.h b/src/kernel/ports/serial.h similarity index 100% rename from src/kernel/arch/i386/ports/serial.h rename to src/kernel/ports/serial.h diff --git a/src/kernel/serial.h b/src/kernel/serial.h index b14db96..ecc82db 100644 --- a/src/kernel/serial.h +++ b/src/kernel/serial.h @@ -1,6 +1,6 @@ #pragma once -#include "arch/i386/tty/kterm.h" +#include "tty/kterm.h" #include "io.h" #define PORT 0x3f8 static int init_serial() { diff --git a/src/kernel/arch/i386/tty/kterm.cpp b/src/kernel/tty/kterm.cpp similarity index 100% rename from src/kernel/arch/i386/tty/kterm.cpp rename to src/kernel/tty/kterm.cpp diff --git a/src/kernel/arch/i386/tty/kterm.h b/src/kernel/tty/kterm.h similarity index 93% rename from src/kernel/arch/i386/tty/kterm.h rename to src/kernel/tty/kterm.h index 7d2ace6..4f048d0 100644 --- a/src/kernel/arch/i386/tty/kterm.h +++ b/src/kernel/tty/kterm.h @@ -5,10 +5,10 @@ #include #include "../vga/colors.h" -#include "../../../io.h" +#include "../io.h" extern "C"{ - #include "./../../../../libc/include/string.h" + #include "./../../libc/include/string.h" } void kterm_init(); diff --git a/src/kernel/arch/i386/vga/VBE.h b/src/kernel/vga/VBE.h similarity index 100% rename from src/kernel/arch/i386/vga/VBE.h rename to src/kernel/vga/VBE.h diff --git a/src/kernel/arch/i386/vga/colors.h b/src/kernel/vga/colors.h similarity index 100% rename from src/kernel/arch/i386/vga/colors.h rename to src/kernel/vga/colors.h