fixed some assembly

This commit is contained in:
Gregory Kenneth Bowne 2024-08-29 00:13:40 -07:00
parent e6ca3f7488
commit 73ad94400b
14 changed files with 29 additions and 317 deletions

BIN
.vscode/browse.vc.db vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,231 +6,11 @@
#IncludeRegexTransform: #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 /home/gbowne1/Documents/ClassicOS/src/kernel/./arch/x86/gdt.h
stdint.h
-
stdbool.h stdbool.h
- -
stdint.h
-
/home/gbowne1/Documents/ClassicOS/src/kernel/./arch/x86/idt.h /home/gbowne1/Documents/ClassicOS/src/kernel/./arch/x86/idt.h
include/types.h include/types.h
@ -273,18 +53,8 @@ sys/cdefs.h
- -
/home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/gdt.h /home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/gdt.h
stdint.h
-
stdbool.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 stdint.h
- -
@ -294,56 +64,14 @@ include/types.h
stdbool.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 /home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/include/types.h
stdint.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 /home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/isr/isr.h
../include/types.h ../include/types.h
/home/gbowne1/Documents/ClassicOS/src/kernel/arch/x86/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 /home/gbowne1/Documents/ClassicOS/src/kernel/kernel.c
kernel.h kernel.h
/home/gbowne1/Documents/ClassicOS/src/kernel/kernel.h /home/gbowne1/Documents/ClassicOS/src/kernel/kernel.h
@ -382,15 +110,3 @@ stddef.h
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

View File

@ -0,0 +1 @@
empty

View File

@ -0,0 +1 @@
empty

View File

@ -0,0 +1 @@
empty

Binary file not shown.

View File

@ -2,9 +2,7 @@ global LoadGDT
section .text section .text
LoadGDT: LoadGDT:
/* LGDT [ESP + 32]
RET
*/
mov eax, [esp+4] ; Get the pointer to the GDT pointer structure mov eax, [esp+4] ; Get the pointer to the GDT pointer structure
lgdt [eax] ; Load the GDT lgdt [eax] ; Load the GDT
mov ax, 0x10 ; Set the kernel data segment selector mov ax, 0x10 ; Set the kernel data segment selector

View File

@ -57,6 +57,7 @@ extern bool gdt_init(void)
// Set up GDT pointer // Set up GDT pointer
struct gdt_ptr gp; struct gdt_ptr gp;
gp.limit = (sizeof(struct gdt_entry) * 3) - 1; gp.limit = (sizeof(struct gdt_entry) * 3) - 1;
gp.base = (uintptr_t)&gdt_entries[0];
// Initialize GDT entries // Initialize GDT entries
gdt_set_gate(0, 0, 0, 0, 0, &gdt_entries[0]); // Null segment 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 gdt_set_gate(2, 0, 0xFFFFFFFF, 0x92, 0xCF, &gdt_entries[2]); // Data segment
// Load GDT // Load GDT
struct gdt_ptr gdtp; LoadGDT(&gp);
gdtp.limit = gp.limit;
gdtp.base = (uint32_t)&gdt_entries[0];
LoadGDT(&gdtp);
// Switch to protected mode // Switch to protected mode
__asm__ volatile( __asm__ volatile(
"cli\n\t" // Disable interrupts "movw $0x10, %%ax\n\t"
"mov %[base], %%eax\n\t" // Move the base address of the GDT to eax "movw %%ax, %%ds\n\t"
"mov %[limit], %%ebx\n\t" // Move the limit of the GDT to ebx "movw %%ax, %%es\n\t"
"shl $16, %%ebx\n\t" // Shift left 16 bits to get the full 32-bit value "movw %%ax, %%fs\n\t"
"or %%eax, %%ebx\n\t" // Combine the base and limit "movw %%ax, %%gs\n\t"
"mov %[address], %%ecx\n\t" // Move the address of gdtr to ecx "movw %%ax, %%ss\n\t"
"mov %%ebx, (%[address])\n\t" // Store the combined value at gdtr "ljmp $0x08, $1f\n\t"
"lgdt (%[address])\n\t" // Load the GDT "1:\n\t"
"sti\n\t" // Enable interrupts
: :
: [base] "a"(gdtp.base), [limit] "b"(gdtp.limit), [address] "c"(&gdtp) :
: "%ebx", "%ecx", "%edx"); : "ax");
return true; // Indicate successful GDT initialization
} }
// Exception handlers // Exception handlers

View File

@ -1,8 +1,8 @@
#ifndef GDT_H #ifndef GDT_H
#define GDT_H #define GDT_H
#include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h>
// GDT entry structure // GDT entry structure
struct gdt_entry struct gdt_entry
@ -16,10 +16,9 @@ struct gdt_entry
} __attribute__((packed)); } __attribute__((packed));
// GDT pointer structure // GDT pointer structure
struct gdt_ptr struct gdt_ptr {
{ uint16_t limit;
uint16_t limit; // The upper 16 bits of all selector limits uintptr_t base;
uint32_t base; // The address of the first gdt_entry_t struct
} __attribute__((packed)); } __attribute__((packed));
// Function prototypes // Function prototypes

View File

@ -1,12 +1,10 @@
global LoadIDT ; Declare function as global global LoadIDT ; Declare function as global
_offset idt db 0 section .data
idt_offset db 0
section .text ; Code section section .text ; Code section
%include "idt.h"
LoadIDT: LoadIDT:
mov eax, [esp + 4] ; Get IDT address (ensure offset idt is defined) mov eax, [esp + 4] ; Get IDT address
LIDT [eax] ; Load timer interrupt entry (check for correct brackets) lidt [eax] ; Load IDT
RET ; Return from function ret ; Return from function