diff options
author | Benji Dial <benji6283@gmail.com> | 2021-02-18 11:56:08 -0500 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2021-02-18 11:56:08 -0500 |
commit | 00cc8736f10098dedf6b856b9ad8bd0094211263 (patch) | |
tree | 4cd252a614b26cb3dcf4a20c142feeffbb4c3c2a /src/boot.asm | |
parent | 9d8ce7688f051fc5cd9e917faf3b1e49a3e620ab (diff) | |
download | portland-os-00cc8736f10098dedf6b856b9ad8bd0094211263.tar.gz |
vbe support, truecolor window manager pixbufs
Diffstat (limited to 'src/boot.asm')
-rw-r--r-- | src/boot.asm | 119 |
1 files changed, 114 insertions, 5 deletions
diff --git a/src/boot.asm b/src/boot.asm index 08b2834..c19534e 100644 --- a/src/boot.asm +++ b/src/boot.asm @@ -8,6 +8,11 @@ support_flags equ 0x4000 pci_hw_char equ 0x4001 pci_ver equ 0x4002 last_pci_bus equ 0x4004 +bios_mmap_len equ 0x4006 +vbe_mode equ 0x4008 + +vbe_block equ 0x4200 +vbe_mode_info equ 0x4400 pci_support equ 0x80 pae_support equ 0x40 @@ -18,10 +23,7 @@ pae_support equ 0x40 xor ax, ax mov ss, ax - mov sp, 0x7ffc - - mov ax, 0x0013 - int 0x10 + mov sp, 0x8000 mov ax, kernel_segment mov es, ax @@ -72,7 +74,95 @@ mmap_loop: test ebx, ebx jnz mmap_loop mmap_end: - mov word [0x4006], di + mov word [bios_mmap_len], di + + xor ax, ax + mov es, ax + mov di, vbe_block + mov ah, 0x4f + + mov dword [di], 0x32454256;'VBE2' + + int 0x10 + + cmp dword [di], 0x41534556;'VESA' + jne no_vbe + + mov bx, word [di + 0x0e] + mov ax, word [di + 0x10] + mov fs, ax + xor esi, esi + mov bp, 0xffff + mov di, 0x5000 + +vbe_loop: + max_height equ 800 + ;fs:bx is mode pointer + ;esi is highest resolution yet (width * height) + ;bp is that mode's number + ;uses 0x5000 - 0x50ff as mode info buffer + ;skips those without byte-aligned pixels + + mov cx, word [fs:bx] + cmp cx, 0xffff + je got_highest_vbe + + add bx, 4 + + mov ax, 0x4f01 + int 0x10 + + mov al, byte [di] + + test al, 0x01 + jz vbe_loop + + test al, 0x10 + jz vbe_loop + + test al, 0x80 + jz vbe_loop + + mov dx, word [di + 0x14];height + cmp dx, max_height + jg vbe_loop + + mov ax, word [di + 0x12];width + mul dx + + shl edx, 16 + mov dx, ax + + xor eax, eax + + mov al, byte [di + 0x19];bpp + test al, 0x07 + jnz vbe_loop + + mul edx + + cmp eax, esi + jle vbe_loop + + mov esi, eax + mov bp, cx + jmp vbe_loop + +got_highest_vbe: + cmp bp, 0xffff + je no_vbe + + mov cx, bp + mov ax, 0x4f01 + mov di, vbe_mode_info + int 0x10 + + or ch, 0x40 + mov word [vbe_mode], cx + + mov ax, 0x4f02 + mov bx, cx + int 0x10 cli @@ -84,6 +174,25 @@ mmap_end: jmp 0x10:pmode +no_vbe: + xor ax, ax + mov es, ax + + mov ax, 0x1300 + mov bx, 0x004f + mov cx, no_vbe_str.len + xor dx, dx + mov bp, no_vbe_str + int 0x10 + +real_halt: + hlt + jmp real_halt + +no_vbe_str: + db "NO VBE2!" +.len equ $ - no_vbe_str + bits 32 pmode: |