global descriptor table things cleaner/ready to be registered
This commit is contained in:
parent
ec9cd34dc6
commit
c84997dea0
13
gdt.h
13
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();
|
||||
|
||||
|
3
gdt.s
3
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
|
||||
|
||||
|
3
loader.s
3
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:
|
||||
|
2
makefile
2
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
|
||||
|
Loading…
Reference in New Issue
Block a user