GDT entries and 0xFF

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
OSNewbie

GDT entries and 0xFF

Post by OSNewbie »

ok, i had 3 entries in the gdt which were working fine for my code, data, and console output. i added a fourth and tried to read/write to it, but everytime i read something from it like this:

mov ax, SEL_KEYBOARD
mov ds, ax
mov byte [ds:0], 0
mov al, [ds:0]

al ended up containing 0xFF and i dont know why. here is the gdt:

gdtr:
dw gdt_end-gdt-1
dd 0;gdt+0x10000

gdt:
gdt0: ;Null Descriptor (0)
dd 0
dd 0
SEL_CODE equ 1*8
gdtCode: ;Code Descriptor (1)
dw 0ffffh
dw 0x0 ;base=0x10000
db 0x1
db 10011010b ;present, dpl 0, non-system, type code/execute/read (0Ah)
db 01000001b ;g=1, d/b=1
db 0

SEL_DATA equ 2*8
gdtData: ;Data Descriptor (2)
dw 0ffffh
dw 0x0 ;base=0x10000
db 0x1
db 10010010b ;present, dpl 0, non-system, type data/read/write (02h)
db 01000001b ;g=1, d/b=1
db 0

SEL_CONSOLE equ 3*8
gdtConsole: ;Video (Text-Console) Memory Descriptor (3) 64k
dw 0ffffh
dw 08000h
db 0Bh
db 10010010b
db 01000000b
db 0

SEL_KEYBOARD equ 4*8
gdtKeyboard:
dw 0xffff
dw 2048
db 0x4
db 10010010b
db 01000000b
db 0x0


gdt_end:

GDTR is loaded with [gdtr] and console output, code running, and getting data from SEL_DATA works fine, but i try to read/write from segment SEL_KEYBOARD and it always returns 0xFF in al no matter what... any ideas?

thanks
Post Reply