Skip to content

Commit 38186d4

Browse files
vesa2uefi nueva fun
1 parent 090ce1a commit 38186d4

5 files changed

Lines changed: 118 additions & 47 deletions

File tree

asm/bios/mbr.asm

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -323,53 +323,6 @@ a20_check:
323323
ret
324324

325325

326-
;;==============================================================================
327-
;; vesa |
328-
;;==============================================================================
329-
;; No me gusta esta fun definida aqui y llamada en start. Luego veo que hacer.
330-
;; Esto es transitorio por cuestiones de espacio.
331-
;;==============================================================================
332-
333-
334-
335-
vesa:
336-
337-
mov cx, 0x4000 - 1 ; Start looking from here
338-
.vbe_search:
339-
inc cx
340-
mov bx, cx ; Mode is saved to BX for the set command later
341-
cmp cx, 0x5000
342-
343-
;;TO-DO: falta load mensaje error.
344-
je failure
345-
346-
mov edi, VBEModeInfoBlock ; VBE data will be stored at this address
347-
mov ax, 0x4F01 ; VESA SuperVGA BIOS - GET SuperVGA MODE INFORMATION - http://www.ctyme.com/intr/rb-0274.htm
348-
int 0x10
349-
cmp ax, 0x004F ; Return value in AX should equal 0x004F if command supported and successful
350-
jne .vbe_search ; Try next mode
351-
cmp byte [VBEModeInfoBlock.BitsPerPixel], 32 ; Desired bit depth
352-
jne .vbe_search ; If not equal, try next mode
353-
cmp word [VBEModeInfoBlock.XResolution], Horizontal_Resolution ; Desired XRes here
354-
jne .vbe_search
355-
cmp word [VBEModeInfoBlock.YResolution], Vertical_Resolution ; Desired YRes here
356-
jne .vbe_search
357-
or bx, 0x4000 ; Use linear/flat frame buffer model (set bit 14)
358-
mov ax, 0x4F02 ; VESA SuperVGA BIOS - SET SuperVGA VIDEO MODE - http://www.ctyme.com/intr/rb-0275.htm
359-
int 0x10
360-
cmp ax, 0x004F ; Return value in AX should equal 0x004F if supported and successful
361-
362-
;;TO-DO: falta load mensaje error.
363-
jne failure
364-
365-
366-
ret
367-
368-
369-
370-
371-
372-
373326
;;==============================================================================
374327
;; section .data
375328
;;==============================================================================

asm/bios/start16.asm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ extern tmpGDTR64 ;; Only for bios boot. See tsl.asm 1178 TO-DO.
3535
extern SYS64_CODE_SEL
3636

3737

38+
;;==============================================================================
39+
;;
40+
;;==============================================================================
41+
3842
BITS 16
3943

4044
start16:

asm/lib/bios.asm

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,117 @@
55

66

77

8+
;;==============================================================================
9+
;; vesa |
10+
;;==============================================================================
11+
;; No me gusta esta fun definida aqui y llamada en start. Luego veo que hacer.
12+
;; Esto es transitorio por cuestiones de espacio.
13+
;;==============================================================================
14+
15+
vesa:
16+
mov cx, 0x4000 - 1 ; Start looking from here
17+
18+
.vbe_search:
19+
inc cx
20+
mov bx, cx ; Mode is saved to BX for the set command later
21+
cmp cx, 0x5000
22+
23+
;;TO-DO: falta load mensaje error.
24+
je failure
25+
26+
mov edi, VBEModeInfoBlock ; VBE data will be stored at this address
27+
mov ax, 0x4F01 ; VESA SuperVGA BIOS - GET SuperVGA MODE INFORMATION - http://www.ctyme.com/intr/rb-0274.htm
28+
int 0x10
29+
cmp ax, 0x004F ; Return value in AX should equal 0x004F if command supported and successful
30+
jne .vbe_search ; Try next mode
31+
cmp byte [VBEModeInfoBlock.BitsPerPixel], 32 ; Desired bit depth
32+
jne .vbe_search ; If not equal, try next mode
33+
cmp word [VBEModeInfoBlock.XResolution], Horizontal_Resolution ; Desired XRes here
34+
jne .vbe_search
35+
cmp word [VBEModeInfoBlock.YResolution], Vertical_Resolution ; Desired YRes here
36+
jne .vbe_search
37+
or bx, 0x4000 ; Use linear/flat frame buffer model (set bit 14)
38+
mov ax, 0x4F02 ; VESA SuperVGA BIOS - SET SuperVGA VIDEO MODE - http://www.ctyme.com/intr/rb-0275.htm
39+
int 0x10
40+
cmp ax, 0x004F ; Return value in AX should equal 0x004F if supported and successful
41+
42+
;;TO-DO: falta load mensaje error.
43+
jne failure
44+
45+
ret
46+
47+
48+
;;==============================================================================
49+
;; vesa2uefi | pasa info de vesa a tabla para compatibilidad con uefi
50+
;;==============================================================================
51+
;; Video info pasado de bios. Difiere de uefi, por lo que se formatea para dejar
52+
;; las igual.
53+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
54+
;;==============================================================================
55+
56+
vesa2uefi:
57+
58+
; Save the frame buffer address, size (after its calculated), and the screen x,y
59+
xor eax, eax
60+
xor ebx, ebx
61+
62+
mov ax, [0x5F00 + 16] ; BytesPerScanLine (modo vesa)
63+
push eax
64+
65+
mov bx, [0x5F00 + 16 + 2 * 2] ; YResolution (vesa)
66+
push ebx
67+
68+
mov ax, [0x5F00 + 16 + 2] ; XResolution (vesa)
69+
push eax
70+
71+
mul ebx
72+
mov ecx, eax
73+
shl ecx, 2 ; Quick multiply by 4
74+
75+
76+
;; aqui en bios, deja las cosas en el mismo orden que uefi
77+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
78+
;;;[0x00005F00] ; Frame buffer base
79+
;;;[0x00005F08] ; Frame buffer size (bytes)
80+
;;;[0x00005F10] ; Screen X
81+
;;;;[0x00005F12] ; Screen Y
82+
;;;;[0x00005F14] ; PixelsPerScanLine
83+
;;;;; recontramega importante (para bios, no uefi), aqui va a colocar
84+
85+
mov edi, 0x5F00
86+
mov eax, [0x5F00 + 40];;;; ya que para bios, el vbeinfoblock tiene esta estructura (framebuffer en +40)
87+
stosd ; 64-bit Frame Buffer Base (low)
88+
;;;;;;;; y pasandolo aqui 0x5f00 esta unificando un vbeInfoblock con estructura nueva tanto
89+
;;;;;;;; para efi como para bios
90+
91+
xor eax, eax
92+
stosd ; 64-bit Frame Buffer Base (high) completa qword
93+
94+
mov eax, ecx
95+
stosd ; 64-bit Frame Buffer Size in bytes (low)
96+
xor eax, eax
97+
stosd ; 64-bit Frame Buffer Size in bytes (high)
98+
99+
pop eax
100+
stosw ; 16-bit Screen X
101+
102+
pop eax
103+
stosw ; 16-bit Screen Y
104+
105+
pop eax
106+
shr eax, 2 ; 4 bytes / px => bpsl/4
107+
stosw ; PixelsPerScanLine
108+
mov eax, 32
109+
stosw ; BitsPerPixel
110+
111+
; Clear memory for the Page Descriptor Entries (0x10000 - 0x5FFFF)
112+
mov edi, 0x00210000
113+
mov ecx, 81920
114+
rep stosd ; Write 320KiB
115+
116+
ret
117+
118+
119+
120+
121+

obj/mbr.o

32 Bytes
Binary file not shown.

out/mbr.sys

9 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)