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+
0 commit comments