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