global descriptor table things cleaner/ready to be registered

This commit is contained in:
shockrah 2019-10-13 23:13:20 -07:00
parent ec9cd34dc6
commit c84997dea0
4 changed files with 12 additions and 9 deletions

13
gdt.h
View File

@ -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();

3
gdt.s
View File

@ -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

View File

@ -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:

View File

@ -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