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" #include "types.h"
struct example { // Container for our gdt entries
int a;
int b; struct GDT_Entry {
}; };
struct GDT { struct GDT {
u32 address;
u16 size; u16 size;
u32 address;
}__attribute__((packed)); }__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 global load_gdt
; lgdt can only be used from assembly so here we are ; lgdt can only be used from assembly so here we are
extern GDT_PTR
load_gdt: load_gdt:
lgdt [eax] lgdt [eax]
ret

View File

@ -10,8 +10,6 @@ CHECKSUM equ -MAGIC_NUMBER
; size in bytes of stack ; size in bytes of stack
KERNEL_STACK_SIZE equ 4096 KERNEL_STACK_SIZE equ 4096
extern test_dispatcher extern test_dispatcher
extern load_gdt
extern struct example
section .text section .text
; align all instructions to 4 byte boundary by the x86 instruction set law ; 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 ; sets up our gdt and segment selectors for later use
loader: loader:
call load_gdt
call test_dispatcher call test_dispatcher
.loop: .loop:

View File

@ -3,7 +3,7 @@ ASM=nasm
LINK=ld LINK=ld
ISO=genisoimage 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 AFLAGS=-f elf32
CFLAGS=-m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles \ CFLAGS=-m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles \
-nodefaultlibs -Wall -Wextra -Werror -c -nodefaultlibs -Wall -Wextra -Werror -c