gdt help
Posted: Fri Oct 07, 2005 11:00 pm
I am having problems loading a generic gdt
here is my code, along with my a20 enabler code incase that causes some problem
bochs reports that the index requested is greater than the limit which it says is 0 but it should be 3(or 24 bytes)
here is my code, along with my a20 enabler code incase that causes some problem
bochs reports that the index requested is greater than the limit which it says is 0 but it should be 3(or 24 bytes)
Code: Select all
[BITS 16]
jmp strt
tGDT:
;null;this is a generic gdt
dw 0
dw 0
dw 0
dw 0
;data
dw 0xffff
dw 0
db 0
db 0x92
db 0xff
db 0
;code
dw 0xffff
dw 0
db 0
db 0x9A
db 0xff
db 0
tGDT_END:
GDTR:
GDTsize DW 8*3-1
GDTbase DD tGDT
wkc:
xor al,al
in al, 0x64 ; get kbd status
test al, 2 ; is bit 1 clear?
jnz wkc ; if not wait some more
ret
halt:
mov byte [gs:0],al
mov byte [gs:1],0x04
cli
hlt
;; 'wait keyboard to be full' function ;;
wkf:
xor cx,cx
in al, 0x64 ; get kbd status
test al, 1 ; is bit 0 clear?
jz wkf ; if not wait some more
ret
strt:
;enable a20
cli
call wkc ; wait for kbd buffer to clear
mov al,0xd1 ; tell it we want to write to output port
out 0x64,al
call wkc ; wait again for kbd to clear
mov al,0xdf ; set desired settings (A20 gate)
out 0x60,al ; send value to data reg
call wkc ; wait for kbd to clear
mov cx,0x10
kbdwait:
xor ax,ax ; do anything
out 0xe0,ax ; some mor nonsense
loop kbdwait ; loop to waste time
;check if a20 was enabled
mov al,0xd0
out 0x64,al ; tell kbdc we want to read output port
call wkf ; wait for data to get in it
in al,0x60 ; get it
test al,2 ; test if A20 is on
jnz a20_on ; if it is clear, then it is off
mov al,'A' ; Error: A20 gate not enabled, halt pc
call halt
a20_on:
xor edx,edx
xor eax,eax
;says data not relocatable for 16bit stuff
mov eax,cr0
or al,1
cli
mov bx,0xb800
mov es,bx
mov bx,0
mov byte [es:bx],'h'
mov cr0,eax
[bits 32]
lgdt [GDTR]
mov bx,0x08
mov ds,bx
mov es,bx
mov ss,bx
mov gs,bx
mov fs,bx
jmp 0x10:t
t: