I can't figure out why...
My kernel is loaded by grub, so naturally, the first thing I want to do is to reload the gdt.
reloading the GDT goes well, by something is certainly messed up since when the line
Code: Select all
jmp dword 0x8:jmp_code_segment ; reinit code seg
Any insights/criticism please?
Thank you.
Code: Select all
[BITS 32]
[SECTION .text]
GLOBAL kmain
kmain:
;Init gdt pointer
mov eax, gdtend ; calc of GDT size
mov ebx, gdt
sub eax, ebx
mov word [gdtptr], ax
xor eax, eax ; calc linear address of GDT
xor ebx, ebx
mov ax, ds
mov ecx, eax
shl ecx, 4
mov ebx, gdt
add ecx, ebx
mov dword [gdtptr+2], ecx
lgdt [gdtptr] ; load GDT
jmp dword 0x8:jmp_code_segment ; reinit code seg
jmp_code_segment:
xor eax, eax
mov ax,0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov esp,8000h
end:
jmp end
;--------------------------------------------------------------------
gdt:
db 0, 0, 0, 0, 0, 0, 0, 0
gdt_cs:
db 0xFF, 0xFF, 0x0, 0x0, 0x0, 10011011b, 11011111b, 0x0
gdt_ds:
db 0xFF, 0xFF, 0x0, 0x0, 0x0, 10010011b, 11011111b, 0x0
gdtend:
;--------------------------------------------------------------------
gdtptr:
dw 0 ; limit
dd 0 ; base
;--------------------------------------------------------------------