diff --git a/.vscode/browse.vc.db b/.vscode/browse.vc.db index 7a3a68d..c0a03b5 100644 Binary files a/.vscode/browse.vc.db and b/.vscode/browse.vc.db differ diff --git a/.vscode/browse.vc.db-shm b/.vscode/browse.vc.db-shm index b388bf7..729ccb5 100644 Binary files a/.vscode/browse.vc.db-shm and b/.vscode/browse.vc.db-shm differ diff --git a/.vscode/browse.vc.db-wal b/.vscode/browse.vc.db-wal index a52d088..e69de29 100644 Binary files a/.vscode/browse.vc.db-wal and b/.vscode/browse.vc.db-wal differ diff --git a/build/CMakeFiles/ClassicOS.dir/C.includecache b/build/CMakeFiles/ClassicOS.dir/C.includecache index 9775286..8277cf5 100644 --- a/build/CMakeFiles/ClassicOS.dir/C.includecache +++ b/build/CMakeFiles/ClassicOS.dir/C.includecache @@ -6,231 +6,11 @@ #IncludeRegexTransform: -/home/gbowne1/Documents/ClassicOS/src/drivers/audio/audio.c -audio.h -/home/gbowne1/Documents/ClassicOS/src/drivers/audio/audio.h -time.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/audio/audio.h -stdint.h -- -stddef.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/bus/eisa.c -eisa.h -/home/gbowne1/Documents/ClassicOS/src/drivers/bus/eisa.h -stdarg.h -- -stdbool.h -- -stddef.h -- -stdint.h -- -stdio.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/bus/eisa.h -stdbool.h -- -stddef.h -- -stdint.h -- -stdio.h -- -stdarg.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/bus/isa.c -isa.h -/home/gbowne1/Documents/ClassicOS/src/drivers/bus/isa.h -stdbool.h -- -stddef.h -- -stdint.h -- -stdarg.h -- -stdio.h -- -string.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/bus/isa.h -stdbool.h -- -stddef.h -- -stdint.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/bus/mca.c -mca.h -/home/gbowne1/Documents/ClassicOS/src/drivers/bus/mca.h -stdbool.h -- -stddef.h -- -stdint.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/bus/mca.h -stdbool.h -- -stddef.h -- -stdint.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/bus/pci.c -pci.h -/home/gbowne1/Documents/ClassicOS/src/drivers/bus/pci.h -stdbool.h -- -stddef.h -- -stdint.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/bus/pci.h -stdbool.h -- -stddef.h -- -stdint.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/bus/vesa.c -vesa.h -/home/gbowne1/Documents/ClassicOS/src/drivers/bus/vesa.h -stdbool.h -- -stddef.h -- -stdint.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/bus/vesa.h -stdbool.h -- -stddef.h -- -stdint.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/display/display.c -display.h -/home/gbowne1/Documents/ClassicOS/src/drivers/display/display.h -stdbool.h -- -stddef.h -- -stdint.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/display/display.h -stdbool.h -- -stddef.h -- -stdint.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/io/io.c -io.h -/home/gbowne1/Documents/ClassicOS/src/drivers/io/io.h - -/home/gbowne1/Documents/ClassicOS/src/drivers/io/io.h -stdint.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/keyboard/keyboard.c -keyboard.h -/home/gbowne1/Documents/ClassicOS/src/drivers/keyboard/keyboard.h -../io/io.h -/home/gbowne1/Documents/ClassicOS/src/drivers/io/io.h -stdbool.h -- -stddef.h -- -stdint.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/keyboard/keyboard.h -stdbool.h -- -stdint.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/screen/screen.c -screen.h -/home/gbowne1/Documents/ClassicOS/src/drivers/screen/screen.h -stdbool.h -- -stddef.h -- -stdint.h -- -stdio.h -- -stdlib.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/screen/screen.h -stdbool.h -- -stddef.h -- -stdint.h -- -stdio.h -- -stdlib.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/tty/./tty.h -stdio.h -- -stdlib.h -- -stdint.h -- -stddef.h -- -stdbool.h -- - -/home/gbowne1/Documents/ClassicOS/src/drivers/tty/tty.c -stdbool.h -- -stddef.h -- -stdint.h -- -stdio.h -- -stdlib.h -- -../display/display.h -/home/gbowne1/Documents/ClassicOS/src/drivers/display/display.h -../io/io.h -/home/gbowne1/Documents/ClassicOS/src/drivers/io/io.h -../keyboard/keyboard.h -/home/gbowne1/Documents/ClassicOS/src/drivers/keyboard/keyboard.h -../screen/screen.h -/home/gbowne1/Documents/ClassicOS/src/drivers/screen/screen.h -./tty.h -/home/gbowne1/Documents/ClassicOS/src/drivers/tty/./tty.h - /home/gbowne1/Documents/ClassicOS/src/kernel/./arch/x86/gdt.h -stdint.h -- stdbool.h - +stdint.h +- /home/gbowne1/Documents/ClassicOS/src/kernel/./arch/x86/idt.h include/types.h @@ -273,18 +53,8 @@ sys/cdefs.h - /home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/gdt.h -stdint.h -- stdbool.h - - -/home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/idt.c -idt.h -/home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/idt.h -../../../drivers/keyboard/keyboard.h -/home/gbowne1/Documents/ClassicOS/src/drivers/keyboard/keyboard.h -isr/isr.h -/home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/isr/isr.h stdint.h - @@ -294,56 +64,14 @@ include/types.h stdbool.h - -/home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/include/memory.h -stddef.h -- -stdint.h -- - /home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/include/types.h stdint.h - -/home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/isr/exceptions.c -exceptions.h -/home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/isr/exceptions.h -setjmp.h -- -signal.h -- -stdio.h -- -stdlib.h -- -stdint.h -- - -/home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/isr/exceptions.h -stddef.h -- -stdint.h -- - -/home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/isr/isr.c -isr.h -/home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/isr/isr.h -stdbool.h -- -stdio.h -- - /home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/isr/isr.h ../include/types.h /home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/include/types.h -/home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/memory/memory.c -../include/memory.h -/home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/include/memory.h -stddef.h -- -string.h -- - /home/gbowne1/Documents/ClassicOS/src/kernel/kernel.c kernel.h /home/gbowne1/Documents/ClassicOS/src/kernel/kernel.h @@ -382,15 +110,3 @@ stddef.h stddef.h - -/home/gbowne1/Documents/ClassicOS/src/kernel/print.c -kernel.h -/home/gbowne1/Documents/ClassicOS/src/kernel/kernel.h -stdio.h -- - -/home/gbowne1/Documents/ClassicOS/src/kernel/stack.c -stack.h -/home/gbowne1/Documents/ClassicOS/src/kernel/stack.h - -/home/gbowne1/Documents/ClassicOS/src/kernel/stack.h - diff --git a/build/CMakeFiles/Progress/1 b/build/CMakeFiles/Progress/3 similarity index 100% rename from build/CMakeFiles/Progress/1 rename to build/CMakeFiles/Progress/3 diff --git a/build/CMakeFiles/Progress/2 b/build/CMakeFiles/Progress/5 similarity index 100% rename from build/CMakeFiles/Progress/2 rename to build/CMakeFiles/Progress/5 diff --git a/build/CMakeFiles/Progress/6 b/build/CMakeFiles/Progress/6 new file mode 100644 index 0000000..7b4d68d --- /dev/null +++ b/build/CMakeFiles/Progress/6 @@ -0,0 +1 @@ +empty \ No newline at end of file diff --git a/build/CMakeFiles/Progress/7 b/build/CMakeFiles/Progress/7 new file mode 100644 index 0000000..7b4d68d --- /dev/null +++ b/build/CMakeFiles/Progress/7 @@ -0,0 +1 @@ +empty \ No newline at end of file diff --git a/build/CMakeFiles/Progress/8 b/build/CMakeFiles/Progress/8 new file mode 100644 index 0000000..7b4d68d --- /dev/null +++ b/build/CMakeFiles/Progress/8 @@ -0,0 +1 @@ +empty \ No newline at end of file diff --git a/build/ClassicOS b/build/ClassicOS deleted file mode 100755 index 7885402..0000000 Binary files a/build/ClassicOS and /dev/null differ diff --git a/src/kernel/arch/x86/gdt.asm b/src/kernel/arch/x86/gdt.asm index 4cd8bc9..6732dd7 100644 --- a/src/kernel/arch/x86/gdt.asm +++ b/src/kernel/arch/x86/gdt.asm @@ -2,9 +2,7 @@ global LoadGDT section .text LoadGDT: - /* LGDT [ESP + 32] - RET - */ + mov eax, [esp+4] ; Get the pointer to the GDT pointer structure lgdt [eax] ; Load the GDT mov ax, 0x10 ; Set the kernel data segment selector diff --git a/src/kernel/arch/x86/gdt.c b/src/kernel/arch/x86/gdt.c index 9ee02b0..c34d662 100644 --- a/src/kernel/arch/x86/gdt.c +++ b/src/kernel/arch/x86/gdt.c @@ -57,6 +57,7 @@ extern bool gdt_init(void) // Set up GDT pointer struct gdt_ptr gp; gp.limit = (sizeof(struct gdt_entry) * 3) - 1; + gp.base = (uintptr_t)&gdt_entries[0]; // Initialize GDT entries gdt_set_gate(0, 0, 0, 0, 0, &gdt_entries[0]); // Null segment @@ -64,26 +65,23 @@ extern bool gdt_init(void) gdt_set_gate(2, 0, 0xFFFFFFFF, 0x92, 0xCF, &gdt_entries[2]); // Data segment // Load GDT - struct gdt_ptr gdtp; - gdtp.limit = gp.limit; - gdtp.base = (uint32_t)&gdt_entries[0]; - - LoadGDT(&gdtp); + LoadGDT(&gp); // Switch to protected mode __asm__ volatile( - "cli\n\t" // Disable interrupts - "mov %[base], %%eax\n\t" // Move the base address of the GDT to eax - "mov %[limit], %%ebx\n\t" // Move the limit of the GDT to ebx - "shl $16, %%ebx\n\t" // Shift left 16 bits to get the full 32-bit value - "or %%eax, %%ebx\n\t" // Combine the base and limit - "mov %[address], %%ecx\n\t" // Move the address of gdtr to ecx - "mov %%ebx, (%[address])\n\t" // Store the combined value at gdtr - "lgdt (%[address])\n\t" // Load the GDT - "sti\n\t" // Enable interrupts + "movw $0x10, %%ax\n\t" + "movw %%ax, %%ds\n\t" + "movw %%ax, %%es\n\t" + "movw %%ax, %%fs\n\t" + "movw %%ax, %%gs\n\t" + "movw %%ax, %%ss\n\t" + "ljmp $0x08, $1f\n\t" + "1:\n\t" : - : [base] "a"(gdtp.base), [limit] "b"(gdtp.limit), [address] "c"(&gdtp) - : "%ebx", "%ecx", "%edx"); + : + : "ax"); + + return true; // Indicate successful GDT initialization } // Exception handlers diff --git a/src/kernel/arch/x86/gdt.h b/src/kernel/arch/x86/gdt.h index 0d7e335..24a8538 100644 --- a/src/kernel/arch/x86/gdt.h +++ b/src/kernel/arch/x86/gdt.h @@ -1,8 +1,8 @@ #ifndef GDT_H #define GDT_H -#include #include +#include // GDT entry structure struct gdt_entry @@ -16,10 +16,9 @@ struct gdt_entry } __attribute__((packed)); // GDT pointer structure -struct gdt_ptr -{ - uint16_t limit; // The upper 16 bits of all selector limits - uint32_t base; // The address of the first gdt_entry_t struct +struct gdt_ptr { + uint16_t limit; + uintptr_t base; } __attribute__((packed)); // Function prototypes diff --git a/src/kernel/arch/x86/idt.asm b/src/kernel/arch/x86/idt.asm index 09bfeab..b5ef51a 100644 --- a/src/kernel/arch/x86/idt.asm +++ b/src/kernel/arch/x86/idt.asm @@ -1,12 +1,10 @@ global LoadIDT ; Declare function as global -_offset idt db 0 - +section .data + idt_offset db 0 section .text ; Code section -%include "idt.h" - LoadIDT: - mov eax, [esp + 4] ; Get IDT address (ensure offset idt is defined) - LIDT [eax] ; Load timer interrupt entry (check for correct brackets) - RET ; Return from function \ No newline at end of file + mov eax, [esp + 4] ; Get IDT address + lidt [eax] ; Load IDT + ret ; Return from function \ No newline at end of file