Hallo Leute!
Ich hab da ein Problem mit der GDT.
static void Gdt_SetEntry(uint32 index, uint32 base, uint32 limit, uint8 access,
uint8 gran) {
gdt.entry[index].base_low = (base & 0xFFFF);
gdt.entry[index].base_middle = (base >> 16) & 0xFF;
gdt.entry[index].base_high = (base >> 24) & 0xFF;
gdt.entry[index].limit_low = (limit & 0xFFFF);
gdt.entry[index].granularity = (limit >> 16) & 0x0F;
gdt.entry[index].granularity |= gran & 0xF0;
gdt.entry[index].access = access;
}
static void Gdt_InstallEntries() {
gdt_ptr.limit = (sizeof(gdt_entry) * GDT_ENTRIES) - 1;
gdt_ptr.base = (int) &gdt.entry[0];
Gdt_SetEntry(0, 0, 0, 0, 0);
Gdt_SetEntry(1, 0, 0xFFFFFFFF, 0x9A, 0xCF);
Gdt_SetEntry(2, 0, 0xFFFFFFFF, 0x92, 0xCF);
Gdt_SetEntry(3, 0, 0xFFFFFFFF, 0xFA, 0xCF);
Gdt_SetEntry(4, 0, 0xFFFFFFFF, 0xF2, 0xCF);
dprint("[GDT] sizeof gdt_entry %d Bytes", sizeof(gdt_entry));
dprint("[GDT] gdt_ptr.base 0x%X", gdt_ptr.base);
dprint("[GDT] gdt_ptr.limit 0x%X (GDT size %d Bytes)", gdt_ptr.limit, gdt_ptr.limit + 1);
dprint("[GDT] entry 1 0x%X", &gdt.entry[0]);
dprint("[GDT] entry 2 0x%X", &gdt.entry[1]);
dprint("[GDT] entry 3 0x%X", &gdt.entry[2]);
dprint("[GDT] entry 4 0x%X", &gdt.entry[3]);
dprint("[GDT] entry 5 0x%X", &gdt.entry[4]);
Gdt_Flush((uint32) &gdt_ptr);
dprint("[GDT] Returning from Gdt_Flush()");
}
global Gdt_Flush
Gdt_Flush:
mov eax, [esp+4] ; Get the pointer to the GDT, passed as parameter
lgdt [eax] ; Load new GDT Pointer
mov ax, 0x10 ; 0x10 is the offset in the GDT to out data segment
mov ds, ax ; Load all data segment selectors
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
jmp 0x08:.flush ; 0x08 is the offset to our code segment: Far jump
.flush:
ret
Output:
[GDT] Initializing GDT
[GDT] sizeof gdt_entry 8 Bytes
[GDT] gdt_ptr.base 0x102000
[GDT] gdt_ptr.limit 0x27 (GDT size 40 Bytes)
[GDT] entry 1 0x102000
[GDT] entry 2 0x102008
[GDT] entry 3 0x102010
[GDT] entry 4 0x102018
[GDT] entry 5 0x102020
Leider fehlt die letzte Zeile [GDT] Returning from Gdt_Flush(). Da dürfte
wohl etwas nicht funktioniert haben.
Da ich den Fehler nicht finden kann, wollte ich fragen ob jemand weiß was
ich falsch gemacht habe.
LG; nnosdev