feat: fetch VESA information
This commit is contained in:
parent
c682f38209
commit
16d9802872
|
@ -59,7 +59,7 @@ _start:
|
|||
; StupidFS layout
|
||||
; +---------+---------+---------....--+----....---+
|
||||
; | bootsec | stpd sb | i-nodes ... | data |
|
||||
; +---------+---------+---------0...--+----....---+
|
||||
; +---------+---------+---------....--+----....---+
|
||||
; 0 512 1024 XXXX XXXX
|
||||
;
|
||||
|
||||
|
@ -95,8 +95,7 @@ _start:
|
|||
xor bx, bx
|
||||
call fat_load_binary
|
||||
|
||||
xchg bx, bx
|
||||
; fetch memory map from bios
|
||||
; fetch memory map from bios
|
||||
call memory_get_map
|
||||
jc .error_memory
|
||||
|
||||
|
@ -186,10 +185,10 @@ common32:
|
|||
cmp esi, MULTIBOOT_BASE
|
||||
jl .2
|
||||
.2:
|
||||
|
||||
|
||||
.3:
|
||||
|
||||
|
||||
push STPDBOOT_MAGIC
|
||||
|
||||
mov eax, 0xC0000000
|
||||
|
|
|
@ -48,9 +48,15 @@ defn AddressRange
|
|||
;; ECX - Buffer Size
|
||||
;; EBX - Continuation
|
||||
memory_e820_get_map:
|
||||
clc
|
||||
@@:
|
||||
mov eax, 0xE820
|
||||
mov ebx, 0x0
|
||||
mov ecx, 'SMAP'
|
||||
mov edx, 'SMAP'
|
||||
jc @f
|
||||
cmp eax, 'SMAP'
|
||||
jne @f
|
||||
@@:
|
||||
|
||||
ret
|
||||
|
||||
|
@ -71,10 +77,8 @@ memory_get_for_large_conf:
|
|||
int 0x15
|
||||
jc @f
|
||||
xor ecx, ecx
|
||||
mov cx, ax
|
||||
push ecx
|
||||
mov cx, bx
|
||||
push ecx
|
||||
push ax
|
||||
push bx
|
||||
mov si, szMsgLarge
|
||||
call bios_log
|
||||
@@:
|
||||
|
@ -89,6 +93,9 @@ memory_get_for_large_conf:
|
|||
;; CF - Non-Carry - indicates no error
|
||||
;; AX - Number of contiguous KB above 1MB
|
||||
memory_get_map:
|
||||
call memory_e820_get_map
|
||||
jnc .end
|
||||
|
||||
call memory_get_for_large_conf
|
||||
jnc .end
|
||||
clc
|
||||
|
@ -115,4 +122,4 @@ memory_get_map:
|
|||
|
||||
szMsgMaxMemKB db "%x KB above 1MB", 0
|
||||
szMsgMaxPage db "%x pages", 0
|
||||
szMsgLarge db "%x KB above 1MB - %x * 64 KB above 16MB", 0
|
||||
szMsgLarge db "%d KB above 1MB - %d * 64 KB above 16MB", 0
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
struc VesaInfo
|
||||
{
|
||||
.Signature dd ?
|
||||
.Signature dd 'VBE2'
|
||||
.Version dw ?
|
||||
.OEMNamePtr dd ?
|
||||
.Capabilities dd ?
|
||||
.VideoModesOffset dw ?
|
||||
.VideoModesSegment dw ?
|
||||
.VideoModesPtr dw ?
|
||||
.CountOf64KBlocks dw ?
|
||||
.OEMSoftwareRevision dw ?
|
||||
.OEMVendorNamePtr dd ?
|
||||
|
@ -14,7 +13,6 @@ struc VesaInfo
|
|||
.Reserved db 222 dup(?)
|
||||
.OEMData db 256 dup(?)
|
||||
}
|
||||
defn VesaInfo
|
||||
|
||||
struc VesaModeInfo
|
||||
{
|
||||
|
@ -57,32 +55,59 @@ struc VesaModeInfo
|
|||
.OffScreenMemorySize dd ?
|
||||
.Reserved2 db 206 dup(?)
|
||||
}
|
||||
defn VesaModeInfo
|
||||
|
||||
video_setup:
|
||||
mov si, szMsgDetectVideo
|
||||
call bios_log
|
||||
clc
|
||||
mov di, [vesa_block_buffer]
|
||||
xchg bx, bx
|
||||
xor ax, ax
|
||||
mov es, ax
|
||||
mov di, vesa_block_buffer
|
||||
mov ax, 0x4F00
|
||||
int 0x10
|
||||
cmp ax, 0x004F
|
||||
jne .err
|
||||
cmp [vesa_block_buffer.Signature], 'VESA'
|
||||
jne .err
|
||||
|
||||
push [vesa_block_buffer.OEMProductNamePtr]
|
||||
push [vesa_block_buffer.OEMVendorNamePtr]
|
||||
push [vesa_block_buffer.CountOf64KBlocks]
|
||||
push [vesa_block_buffer.OEMNamePtr]
|
||||
xor ecx, ecx
|
||||
mov cx, [vesa_block_buffer.Version]
|
||||
push ecx
|
||||
mov si, szMsgVesaInfo
|
||||
call bios_log
|
||||
|
||||
push word [vesa_block_buffer + VesaInfo.VideoModesSegment]
|
||||
pop es
|
||||
mov di, vesa_info_block_buffer
|
||||
mov bx, [vesa_block_buffer + VesaInfo.VideoModesOffset]
|
||||
mov bx, [vesa_block_buffer.VideoModesPtr]
|
||||
mov cx, [bx]
|
||||
cmp cx, 0xFFFF
|
||||
je .err
|
||||
|
||||
clc
|
||||
mov ax, 0x4F01
|
||||
int 0x10
|
||||
cmp ax, 0x004F
|
||||
jne .err
|
||||
|
||||
push dword [vesa_info_block_buffer.Framebuffer]
|
||||
mov si, szMsgFramebuffer
|
||||
call bios_log
|
||||
ret
|
||||
.err:
|
||||
mov si, szMsgErrorVesa
|
||||
call bios_log
|
||||
stc
|
||||
ret
|
||||
|
||||
align 4
|
||||
vesa_block_buffer VesaInfo
|
||||
vesa_info_block_buffer VesaModeInfo
|
||||
|
||||
szMsgVesaInfo db "Version: %x", CR, LF, "OEM Name: %s", CR, LF, "Total Memory: %d", CR, LF, "Vendor name: %s", CR, LF, "Product name: %s", 0
|
||||
szMsgDetectVideo db "Fetch video information.", 0
|
||||
szMsgFramebuffer db "Fb: 0x%x", 0
|
||||
szMsgErrorVesa db "Failed to detect VBE mode", 0
|
||||
|
|
Loading…
Reference in a new issue