From 8b4bed0ba7f80387f22e7ec8a1a88f0648f62579 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Wed, 6 Jul 2022 07:31:59 +0300 Subject: [PATCH] added video bios vector detection and attempt to initialize it if it's missing --- efitest.asm | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/efitest.asm b/efitest.asm index 0feb61d..3ca78d0 100644 --- a/efitest.asm +++ b/efitest.asm @@ -138,6 +138,29 @@ start16: 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 @@ -175,8 +198,40 @@ start16: 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 @@ -197,7 +252,7 @@ print_ivt: call ser_putchar add bx, 4 - cmp bx, 64 << 2 + cmp bx, 33 << 2 jnz .loop ret -- 1.7.10.4