StupidOS/boot/loader/video.inc

116 lines
2.4 KiB
PHP
Raw Normal View History

2024-07-07 13:48:22 +00:00
;; File: video.inc
2024-04-14 05:35:43 +00:00
struc VesaInfo
{
2024-06-29 14:29:15 +00:00
.Signature dd 'VBE2'
2024-04-14 05:35:43 +00:00
.Version dw ?
.OEMNamePtr dd ?
.Capabilities dd ?
2024-06-29 14:29:15 +00:00
.VideoModesPtr dw ?
2024-04-14 05:35:43 +00:00
.CountOf64KBlocks dw ?
.OEMSoftwareRevision dw ?
.OEMVendorNamePtr dd ?
.OEMProductNamePtr dd ?
.OEMProductRevisionPtr dd ?
.Reserved db 222 dup(?)
.OEMData db 256 dup(?)
}
struc VesaModeInfo
{
.ModeAttributes dw ?
.WindowAAttributes db ?
.WindowBAttributes db ?
.WindowGranularity dw ?
.WindowSize dw ?
.SegmentWindowA dw ?
.SegmentWindowB dw ?
.WindowPositioning dd ?
.BytesPerScanLine dw ?
; --
.Width dw ?
.Height dw ?
.WidthChar db ?
.HeightChar db ?
.PlanesCount db ?
.BitsPerPixel db ?
.BanksCount db ?
.MemoryModel db ?
.BankSize db ?
.ImagePagesCount db ?
.Reserved db ?
.RedMaskSize db ?
.RedFieldPosition db ?
.GreenMaskSize db ?
.GreenFieldPosition db ?
.BlueMaskSize db ?
.BlueFieldPosition db ?
.ReservedMaskSize db ?
.ReservedMaskPosition db ?
.DirectColorModeInfo db ?
; -- VBE v1.2+
.Framebuffer dd ?
.OffScreenMemoryOffset dd ?
.OffScreenMemorySize dd ?
.Reserved2 db 206 dup(?)
}
2024-07-05 06:16:40 +00:00
;; Function: video_setup
video_setup:
2024-06-29 14:29:15 +00:00
mov si, szMsgDetectVideo
call bios_log
2024-04-28 06:41:36 +00:00
clc
2024-06-29 14:29:15 +00:00
xor ax, ax
mov es, ax
mov di, vesa_block_buffer
2024-04-28 06:41:36 +00:00
mov ax, 0x4F00
int 0x10
cmp ax, 0x004F
jne .err
2024-06-29 14:29:15 +00:00
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
2024-04-28 06:41:36 +00:00
mov di, vesa_info_block_buffer
2024-06-29 14:29:15 +00:00
mov bx, [vesa_block_buffer.VideoModesPtr]
2024-04-28 06:41:36 +00:00
mov cx, [bx]
cmp cx, 0xFFFF
je .err
2024-06-29 14:29:15 +00:00
clc
2024-04-28 06:41:36 +00:00
mov ax, 0x4F01
int 0x10
cmp ax, 0x004F
jne .err
2024-06-29 14:29:15 +00:00
push dword [vesa_info_block_buffer.Framebuffer]
mov si, szMsgFramebuffer
call bios_log
ret
2024-04-28 06:41:36 +00:00
.err:
2024-06-29 14:29:15 +00:00
mov si, szMsgErrorVesa
call bios_log
2024-04-28 06:41:36 +00:00
stc
ret
2024-06-29 14:29:15 +00:00
align 4
2024-04-28 06:41:36 +00:00
vesa_block_buffer VesaInfo
vesa_info_block_buffer VesaModeInfo
2024-06-29 14:29:15 +00:00
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
2024-07-02 08:32:11 +00:00
szMsgFramebuffer db "Fb: %x", 0
2024-06-29 14:29:15 +00:00
szMsgErrorVesa db "Failed to detect VBE mode", 0