Code: Select all
;;Bootloader stage 2
VESAINFO db 'VBE2' ;; Space for info ret by vid BIOS
times 508 db 0
MODEINFO times 256 db 0
frame_buffer dd 0
init_vesa:
mov DI, VESAINFO
mov AX, 4F00h
int 10h
cmp AX, 4Fh
jne vesa_init_failed ; Function Call not supported/ No Vesa present
mov DX,0h ; We'll use the DX register to test the modes
call find_mode
find_mode:
Inc DX
cmp DX, 0xffff ; Have we finished testing all the modes
JZ vesa_init_failed ; If this is the case, we couldn't find the mode we want
mov CX,DX ; Else,let's go on testing the mode until we find the one we need
mov AX, 4F01h ; CX contains the mode no. for the Mode Info Call
mov DI, MODEINFO
int 10h
cmp AX,4Fh
jne find_mode ; Mode Info Call not supported
mov AX, word [MODEINFO] ;; Get the first word of the buffer
bt AX, 0 ;; Is the mode supported?
jnc find_mode
bt AX, 4 ;; Is this mode a graphics mode?
jnc find_mode
bt AX, 7 ;; Does this mode support a linear frame buffer?
jnc find_mode
mov Ax, word [MODEINFO+18]
cmp ax,1024 ;; Is the horizontal resolution = 1024?
jnz find_mode
mov Ax, word [MODEINFO+20]
cmp ax,768 ;; Is the vertical resolution = 768?
jnz find_mode
mov al, byte [MODEINFO+25]
cmp al,24 ;; Is the bits per pixel = 24 ?
jnz find_mode
;; If we reached this point,we found our mode
mov eax,Dword [MODEINFO+40] ;; Adress of PhysBasePtr(LFB)
mov [frame_buffer],eax
MOV AX, 04F02h ; Set VESA Video Mode
MOV BX, DX ; DX contains the mode we want 1024x768x24bpp
INT 10h ; Video Interrupt
CMP AX, 04Fh ; AX = 04Fh ?
JNz vesa_init_failed ; If No Then Video Error
vesa_init_failed:
cli
hlt
Have I missed something in the configuration of BOCHS(since it works fine with QEMU) or is my code to determine the adress of Linear frame Buffer wrong? Please Help!!
EDIT: Brendan added some code tags..