call print_ivt
+detect_vbios:
+ ; make sure we have video bios vector installed in 10h
+ mov ax, [10h * 4 + 2]
+ test ax, ax
+ jnz .notnull
+ call init_vbios
+ jnc vbios_present
+ jmp halt
+.notnull: ; beyond being non-zero, the video bios should really be at c0000h
+ cmp ax, 0c000h
+ jz vbios_present
+ ; unexpected address, make sure it starts with 0aa55h
+ mov es, ax
+ xor bx, bx
+ mov ax, [es:bx]
+ cmp ax, 0aa55h
+ call init_vbios ; seems like garbage, try init
+ jc halt
+
+vbios_present:
+ mov si, msg_vbios_test
+ call ser_putstr
+
; run 16bit video bios test
mov ax, 13h
int 10h
jnz .yloop
; halt for ever
-.hang: hlt
- jmp .hang
+halt: hlt
+ jmp halt
+
+init_vbios:
+ mov ax, 0c000h
+ mov es, ax
+ xor bx, bx
+ cmp word [es:bx], 0aa55h
+ jz .foundsig
+ mov si, err_vbios_notfound
+ call ser_putstr
+ mov ax, [es:bx]
+ call printhex16
+ mov al, 13
+ call ser_putchar
+ mov al, 10
+ call ser_putchar
+ stc
+ ret
+.foundsig:
+ mov si, msg_vbios_init
+ call ser_putstr
+ ; don't bother with CRC, just call it
+ push es
+ push word 4
+ mov bp, sp
+ call far [bp]
+ add sp, 4
+ clc
+ ret
+
+msg_vbios_test db 'running video BIOS test',13,10,0
+msg_vbios_init db 'attempting to initialize video BIOS',13,10,0
+err_vbios_notfound db 'failed to initialize video BIOS, sig not found at c0000h: ',0
print_ivt:
xor bx, bx
call ser_putchar
add bx, 4
- cmp bx, 64 << 2
+ cmp bx, 33 << 2
jnz .loop
ret