]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/QemuVideoDxe/VbeShim.asm
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / OvmfPkg / QemuVideoDxe / VbeShim.asm
CommitLineData
90803342
LE
1;------------------------------------------------------------------------------\r
2; @file\r
3; A minimal Int10h stub that allows the Windows 2008 R2 SP1 UEFI guest's buggy,\r
4; default VGA driver to switch to 1024x768x32, on the stdvga and QXL video\r
5; cards of QEMU.\r
6;\r
7; Copyright (C) 2014, Red Hat, Inc.\r
8; Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>\r
9;\r
b26f0cf9 10; SPDX-License-Identifier: BSD-2-Clause-Patent\r
90803342
LE
11;\r
12;------------------------------------------------------------------------------\r
13\r
14; enable this macro for debug messages\r
15;%define DEBUG\r
16\r
17%macro DebugLog 1\r
18%ifdef DEBUG\r
19 push si\r
20 mov si, %1\r
21 call PrintStringSi\r
22 pop si\r
23%endif\r
24%endmacro\r
25\r
26\r
27BITS 16\r
28ORG 0\r
29\r
30VbeInfo:\r
31TIMES 256 nop\r
32\r
33VbeModeInfo:\r
34TIMES 256 nop\r
35\r
36\r
37Handler:\r
38 cmp ax, 0x4f00\r
39 je GetInfo\r
40 cmp ax, 0x4f01\r
41 je GetModeInfo\r
42 cmp ax, 0x4f02\r
43 je SetMode\r
44 cmp ax, 0x4f03\r
45 je GetMode\r
46 cmp ax, 0x4f10\r
47 je GetPmCapabilities\r
48 cmp ax, 0x4f15\r
49 je ReadEdid\r
50 cmp ah, 0x00\r
51 je SetModeLegacy\r
a2e75595 52 DebugLog StrUnknownFunction\r
90803342
LE
53Hang:\r
54 jmp Hang\r
55\r
56\r
57GetInfo:\r
58 push es\r
59 push di\r
60 push ds\r
61 push si\r
62 push cx\r
63\r
64 DebugLog StrEnterGetInfo\r
65\r
66 ; target (es:di) set on input\r
67 push cs\r
68 pop ds\r
69 mov si, VbeInfo\r
70 ; source (ds:si) set now\r
71\r
72 mov cx, 256\r
73 cld\r
74 rep movsb\r
75\r
76 pop cx\r
77 pop si\r
78 pop ds\r
79 pop di\r
80 pop es\r
81 jmp Success\r
82\r
83\r
84GetModeInfo:\r
85 push es\r
86 push di\r
87 push ds\r
88 push si\r
89 push cx\r
90\r
91 DebugLog StrEnterGetModeInfo\r
92\r
93 and cx, ~0x4000 ; clear potentially set LFB bit in mode number\r
94 cmp cx, 0x00f1\r
95 je KnownMode1\r
a2e75595 96 DebugLog StrUnknownMode\r
90803342
LE
97 jmp Hang\r
98KnownMode1:\r
99 ; target (es:di) set on input\r
100 push cs\r
101 pop ds\r
102 mov si, VbeModeInfo\r
103 ; source (ds:si) set now\r
104\r
105 mov cx, 256\r
106 cld\r
107 rep movsb\r
108\r
109 pop cx\r
110 pop si\r
111 pop ds\r
112 pop di\r
113 pop es\r
114 jmp Success\r
115\r
116\r
117%define ATT_ADDRESS_REGISTER 0x03c0\r
118%define VBE_DISPI_IOPORT_INDEX 0x01ce\r
119%define VBE_DISPI_IOPORT_DATA 0x01d0\r
120\r
121%define VBE_DISPI_INDEX_XRES 0x1\r
122%define VBE_DISPI_INDEX_YRES 0x2\r
123%define VBE_DISPI_INDEX_BPP 0x3\r
124%define VBE_DISPI_INDEX_ENABLE 0x4\r
125%define VBE_DISPI_INDEX_BANK 0x5\r
126%define VBE_DISPI_INDEX_VIRT_WIDTH 0x6\r
127%define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7\r
128%define VBE_DISPI_INDEX_X_OFFSET 0x8\r
129%define VBE_DISPI_INDEX_Y_OFFSET 0x9\r
130\r
131%define VBE_DISPI_ENABLED 0x01\r
132%define VBE_DISPI_LFB_ENABLED 0x40\r
133\r
134%macro BochsWrite 2\r
135 push dx\r
136 push ax\r
137\r
138 mov dx, VBE_DISPI_IOPORT_INDEX\r
139 mov ax, %1\r
140 out dx, ax\r
141\r
142 mov dx, VBE_DISPI_IOPORT_DATA\r
143 mov ax, %2\r
144 out dx, ax\r
145\r
146 pop ax\r
147 pop dx\r
148%endmacro\r
149\r
150SetMode:\r
151 push dx\r
152 push ax\r
153\r
154 DebugLog StrEnterSetMode\r
155\r
156 cmp bx, 0x40f1\r
157 je KnownMode2\r
a2e75595 158 DebugLog StrUnknownMode\r
90803342
LE
159 jmp Hang\r
160KnownMode2:\r
161\r
162 ; unblank\r
163 mov dx, ATT_ADDRESS_REGISTER\r
164 mov al, 0x20\r
165 out dx, al\r
166\r
167 BochsWrite VBE_DISPI_INDEX_ENABLE, 0\r
168 BochsWrite VBE_DISPI_INDEX_BANK, 0\r
169 BochsWrite VBE_DISPI_INDEX_X_OFFSET, 0\r
170 BochsWrite VBE_DISPI_INDEX_Y_OFFSET, 0\r
171 BochsWrite VBE_DISPI_INDEX_BPP, 32\r
172 BochsWrite VBE_DISPI_INDEX_XRES, 1024\r
173 BochsWrite VBE_DISPI_INDEX_VIRT_WIDTH, 1024\r
174 BochsWrite VBE_DISPI_INDEX_YRES, 768\r
175 BochsWrite VBE_DISPI_INDEX_VIRT_HEIGHT, 768\r
176 BochsWrite VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED\r
177\r
178 pop ax\r
179 pop dx\r
180 jmp Success\r
181\r
182\r
183GetMode:\r
184 DebugLog StrEnterGetMode\r
185 mov bx, 0x40f1\r
186 jmp Success\r
187\r
188\r
189GetPmCapabilities:\r
190 DebugLog StrGetPmCapabilities\r
191 jmp Unsupported\r
192\r
193\r
194ReadEdid:\r
195 DebugLog StrReadEdid\r
196 jmp Unsupported\r
197\r
198\r
199SetModeLegacy:\r
200 DebugLog StrEnterSetModeLegacy\r
201\r
202 cmp al, 0x03\r
203 je KnownMode3\r
204 cmp al, 0x12\r
205 je KnownMode4\r
a2e75595 206 DebugLog StrUnknownMode\r
90803342
LE
207 jmp Hang\r
208KnownMode3:\r
209 mov al, 0x30\r
210 jmp SetModeLegacyDone\r
211KnownMode4:\r
212 mov al, 0x20\r
213SetModeLegacyDone:\r
214 DebugLog StrExitSuccess\r
215 iret\r
216\r
217\r
218Success:\r
219 DebugLog StrExitSuccess\r
220 mov ax, 0x004f\r
221 iret\r
222\r
223\r
224Unsupported:\r
225 DebugLog StrExitUnsupported\r
226 mov ax, 0x014f\r
227 iret\r
228\r
229\r
230%ifdef DEBUG\r
231PrintStringSi:\r
232 pusha\r
233 push ds ; save original\r
234 push cs\r
235 pop ds\r
236 mov dx, 0x0402\r
237PrintStringSiLoop:\r
238 lodsb\r
239 cmp al, 0\r
240 je PrintStringSiDone\r
241 out dx, al\r
242 jmp PrintStringSiLoop\r
243PrintStringSiDone:\r
244 pop ds ; restore original\r
245 popa\r
246 ret\r
247\r
248\r
249StrExitSuccess:\r
250 db 'Exit', 0x0a, 0\r
251\r
252StrExitUnsupported:\r
253 db 'Unsupported', 0x0a, 0\r
254\r
a2e75595 255StrUnknownFunction:\r
90803342
LE
256 db 'Unknown Function', 0x0a, 0\r
257\r
258StrEnterGetInfo:\r
259 db 'GetInfo', 0x0a, 0\r
260\r
261StrEnterGetModeInfo:\r
262 db 'GetModeInfo', 0x0a, 0\r
263\r
264StrEnterGetMode:\r
265 db 'GetMode', 0x0a, 0\r
266\r
267StrEnterSetMode:\r
268 db 'SetMode', 0x0a, 0\r
269\r
270StrEnterSetModeLegacy:\r
271 db 'SetModeLegacy', 0x0a, 0\r
272\r
a2e75595
AC
273StrUnknownMode:\r
274 db 'Unknown Mode', 0x0a, 0\r
90803342
LE
275\r
276StrGetPmCapabilities:\r
277 db 'GetPmCapabilities', 0x0a, 0\r
278\r
279StrReadEdid:\r
280 db 'ReadEdid', 0x0a, 0\r
281%endif\r