VESA modes array malformed
Posted: Sat May 08, 2021 3:39 pm
I'm following Omar's VESA tutorial to change VESA mode in my bootloader.
I've retrieved the 512 bytes info block from the bios with int 10h/AX=0x4F00 and I'm sure this worked since the signature field of this block is correctly set to "VESA".
After inspecting the retuned data I noticed that the amount of KBs of available video memory is set to zero, a bit awkward but not yet a problem.
There is a field that the tutorial calls video_modes which is a pointer in segment:offset to the array of available video modes (terminated by 0xFFFF). I writed some code to iterate that array but I read really weird values... I don't think what I'm reading is correct.
This is my code:
Is there something wrong with it that you can find?
PS:
I don't think this is relevant but i test my code using QEMU and i run it with this line:
I've retrieved the 512 bytes info block from the bios with int 10h/AX=0x4F00 and I'm sure this worked since the signature field of this block is correctly set to "VESA".
After inspecting the retuned data I noticed that the amount of KBs of available video memory is set to zero, a bit awkward but not yet a problem.
There is a field that the tutorial calls video_modes which is a pointer in segment:offset to the array of available video modes (terminated by 0xFFFF). I writed some code to iterate that array but I read really weird values... I don't think what I'm reading is correct.
This is my code:
Code: Select all
SetVbeMode:
mov al, 'V'
mov [Mem.VESA.Info], al
mov al, 'B'
mov [Mem.VESA.Info + 1], al
mov al, 'E'
mov [Mem.VESA.Info + 2], al
mov al, '2'
mov [Mem.VESA.Info + 3], al
push es ; preserve es
mov ax, 0x4F00 ; get VBE BIOS info (es:di address)
mov di, Mem.VESA.Info
int 0x10
pop es ; restore ES
cmp ax, 0x004F ; BIOS doesn't support VBE?
jne .error
mov ax, word[Mem.VESA.Info + 18]
mov [.offset], ax
mov ax, word[Mem.VESA.Info + 18 + 2]
mov [.segment], ax
mov ax, [.segment]
mov ds, ax
mov si, [.offset]
.find_mode:
cld
lodsw
cmp ax, 0xFFFF
je .error
push 16
push ax
call _printw
jmp .find_mode
.done:
clc
ret
.error:
hlt
jmp $
stc
ret
PS:
I don't think this is relevant but i test my code using QEMU and i run it with this line:
Code: Select all
qemu-system-x86_64 -M q35 -m 512M -hda BonsOS.img -no-reboot -no-shutdown -S -gdb tcp::9000