Trying to execute RETF after loading GDT causes triple fault
Posted: Mon Dec 28, 2020 12:40 pm
I've been trying to get a GDT to work for like 2 days and i tried countless methods.
My "kernel" is in long mode
This is Util.asm
My "kernel" is in long mode
Code: Select all
void GDTInstall();
void LoadGDT()
{
// NULL DESCRIPTOR
PushEntry(0x0000000000000000);
// DATA
PushEntry(0xFFFF00000092C700);
// CODE
PushEntry(0x0000000000BAAF00);
__gdt_pointer.limit = sizeof(struct GDTEntry) * 3 - 1;
__gdt_pointer.addr = &entries[0];
GDTInstall();
}
Code: Select all
section .text
extern __gdt_pointer
global GDTInstall
GDTInstall:
CLI
LGDT [__gdt_pointer]
PUSH WORD 0x10
PUSH QWORD Stage2
RETF
Stage2:
MOV AX, 0x8
MOV DS, AX
MOV ES, AX
MOV FS, AX
MOV GS, AX
MOV SS, AX
STI