From c84997dea0576e369e78cd4d6463fe1d1cb8ea2a Mon Sep 17 00:00:00 2001 From: shockrah Date: Sun, 13 Oct 2019 23:13:20 -0700 Subject: [PATCH] global descriptor table things cleaner/ready to be registered --- gdt.h | 13 ++++++++----- gdt.s | 3 +++ loader.s | 3 --- makefile | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/gdt.h b/gdt.h index 0b23c66..21b22e6 100644 --- a/gdt.h +++ b/gdt.h @@ -2,15 +2,18 @@ #include "types.h" -struct example { - int a; - int b; +// Container for our gdt entries + +struct GDT_Entry { }; struct GDT { - u32 address; u16 size; + u32 address; }__attribute__((packed)); -static void load_gdt(const GDT* table); +struct GDT_Entry entries[2]; +struct GDT GDT_P; + +extern void load_gdt(); diff --git a/gdt.s b/gdt.s index 2c7274e..0d683dd 100644 --- a/gdt.s +++ b/gdt.s @@ -1,5 +1,8 @@ global load_gdt ; lgdt can only be used from assembly so here we are +extern GDT_PTR load_gdt: lgdt [eax] + ret + diff --git a/loader.s b/loader.s index 74a7fd8..086ca1d 100644 --- a/loader.s +++ b/loader.s @@ -10,8 +10,6 @@ CHECKSUM equ -MAGIC_NUMBER ; size in bytes of stack KERNEL_STACK_SIZE equ 4096 extern test_dispatcher -extern load_gdt -extern struct example section .text ; align all instructions to 4 byte boundary by the x86 instruction set law @@ -24,7 +22,6 @@ align 4 ; sets up our gdt and segment selectors for later use loader: - call load_gdt call test_dispatcher .loop: diff --git a/makefile b/makefile index c4d6045..5a3b5b0 100644 --- a/makefile +++ b/makefile @@ -3,7 +3,7 @@ ASM=nasm LINK=ld ISO=genisoimage -OBJECTS=loader.o serial.o framebuffer.o ports.o stlio.o tests.o +OBJECTS=interrupts.o interrupt_entry.o loader.o serial.o framebuffer.o ports.o stlio.o tests.o AFLAGS=-f elf32 CFLAGS=-m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles \ -nodefaultlibs -Wall -Wextra -Werror -c