]>
Commit | Line | Data |
---|---|---|
656419f9 RC |
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.\r | |
5 | ;\r | |
6 | ; Copyright (C) 2020, Rebecca Cran <rebecca@bsdio.com>\r | |
7 | ; Copyright (C) 2015, Nahanni Systems, Inc.\r | |
8 | ; Copyright (C) 2014, Red Hat, Inc.\r | |
9 | ; Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>\r | |
10 | ;\r | |
11 | ; SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
12 | ;\r | |
13 | ;------------------------------------------------------------------------------\r | |
14 | \r | |
15 | ; enable this macro for debug messages\r | |
16 | %define DEBUG\r | |
17 | \r | |
18 | %macro DebugLog 1\r | |
19 | %ifdef DEBUG\r | |
20 | push si\r | |
21 | mov si, %1\r | |
22 | call PrintStringSi\r | |
23 | pop si\r | |
24 | %endif\r | |
25 | %endmacro\r | |
26 | \r | |
27 | \r | |
28 | BITS 16\r | |
29 | ORG 0\r | |
30 | \r | |
31 | VbeInfo:\r | |
32 | TIMES 256 nop\r | |
33 | \r | |
34 | VbeModeInfo:\r | |
35 | VbeMode1:\r | |
36 | TIMES 50 nop\r | |
37 | VbeMode2:\r | |
38 | TIMES 50 nop\r | |
39 | VbeMode3:\r | |
40 | TIMES 50 nop\r | |
41 | VbeMode4:\r | |
42 | TIMES 50 nop\r | |
43 | TIMES 56 nop ; filler for 256 bytes\r | |
44 | \r | |
45 | Handler:\r | |
46 | cmp ax, 0x4f00\r | |
47 | je GetInfo\r | |
48 | cmp ax, 0x4f01\r | |
49 | je GetModeInfo\r | |
50 | cmp ax, 0x4f02\r | |
51 | je SetMode\r | |
52 | cmp ax, 0x4f03\r | |
53 | je GetMode\r | |
54 | cmp ax, 0x4f10\r | |
55 | je GetPmCapabilities\r | |
56 | cmp ax, 0x4f15\r | |
57 | je ReadEdid\r | |
58 | cmp ah, 0x00\r | |
59 | je SetModeLegacy\r | |
60 | DebugLog StrUnkownFunction\r | |
61 | Hang:\r | |
62 | jmp Hang\r | |
63 | \r | |
64 | \r | |
65 | GetInfo:\r | |
66 | push es\r | |
67 | push di\r | |
68 | push ds\r | |
69 | push si\r | |
70 | push cx\r | |
71 | \r | |
72 | DebugLog StrEnterGetInfo\r | |
73 | \r | |
74 | ; target (es:di) set on input\r | |
75 | push cs\r | |
76 | pop ds\r | |
77 | mov si, VbeInfo\r | |
78 | ; source (ds:si) set now\r | |
79 | \r | |
80 | mov cx, 256\r | |
81 | cld\r | |
82 | rep movsb\r | |
83 | \r | |
84 | pop cx\r | |
85 | pop si\r | |
86 | pop ds\r | |
87 | pop di\r | |
88 | pop es\r | |
89 | jmp Success\r | |
90 | \r | |
91 | \r | |
92 | GetModeInfo:\r | |
93 | push es\r | |
94 | push di\r | |
95 | push ds\r | |
96 | push si\r | |
97 | push cx\r | |
98 | \r | |
99 | DebugLog StrEnterGetModeInfo\r | |
100 | \r | |
101 | and cx, ~0x4000 ; clear potentially set LFB bit in mode number\r | |
102 | \r | |
103 | cmp cx, 0x013f\r | |
104 | je gKnownMode1\r | |
105 | cmp cx, 0x0140\r | |
106 | je gKnownMode2\r | |
107 | cmp cx, 0x0141\r | |
108 | je gKnownMode3\r | |
109 | \r | |
110 | DebugLog StrUnkownMode\r | |
111 | jmp Hang\r | |
112 | gKnownMode1:\r | |
113 | DebugLog StrMode1\r | |
114 | mov si, VbeMode1\r | |
115 | jmp CopyModeInfo\r | |
116 | gKnownMode2:\r | |
117 | DebugLog StrMode2\r | |
118 | mov si, VbeMode2\r | |
119 | jmp CopyModeInfo\r | |
120 | gKnownMode3:\r | |
121 | DebugLog StrMode3\r | |
122 | mov si, VbeMode3\r | |
123 | jmp CopyModeInfo\r | |
124 | gKnownMode4:\r | |
125 | DebugLog StrMode4\r | |
126 | mov si, VbeMode4\r | |
127 | jmp CopyModeInfo\r | |
128 | \r | |
129 | CopyModeInfo:\r | |
130 | ; target (es:di) set on input\r | |
131 | push cs\r | |
132 | pop ds\r | |
133 | ;mov si, VbeModeInfo\r | |
134 | ; source (ds:si) set now\r | |
135 | \r | |
136 | ;mov cx, 256\r | |
137 | mov cx, 50\r | |
138 | cld\r | |
139 | rep movsb\r | |
140 | \r | |
141 | pop cx\r | |
142 | pop si\r | |
143 | pop ds\r | |
144 | pop di\r | |
145 | pop es\r | |
146 | jmp Success\r | |
147 | \r | |
148 | \r | |
149 | SetMode:\r | |
150 | push dx\r | |
151 | push ax\r | |
152 | \r | |
153 | DebugLog StrEnterSetMode\r | |
154 | \r | |
155 | and bx, ~0x4000 ; clear potentially set LFB bit in mode number\r | |
156 | cmp bx, 0x013f\r | |
157 | je KnownMode1\r | |
158 | cmp bx, 0x0140\r | |
159 | je KnownMode2\r | |
160 | cmp bx, 0x0141\r | |
161 | je KnownMode3\r | |
162 | DebugLog StrUnkownMode\r | |
163 | jmp Hang\r | |
164 | KnownMode1:\r | |
165 | DebugLog StrMode1\r | |
166 | jmp SetModeDone\r | |
167 | KnownMode2:\r | |
168 | DebugLog StrMode2\r | |
169 | jmp SetModeDone\r | |
170 | KnownMode3:\r | |
171 | DebugLog StrMode3\r | |
172 | jmp SetModeDone\r | |
173 | KnownMode4:\r | |
174 | DebugLog StrMode4\r | |
175 | \r | |
176 | SetModeDone:\r | |
177 | mov [CurMode], bl\r | |
178 | mov [CurMode+1], bh\r | |
179 | pop ax\r | |
180 | pop dx\r | |
181 | jmp Success\r | |
182 | \r | |
183 | \r | |
184 | GetMode:\r | |
185 | DebugLog StrEnterGetMode\r | |
186 | mov bl, [CurMode]\r | |
187 | mov bh, [CurMode+1]\r | |
188 | jmp Success\r | |
189 | \r | |
190 | \r | |
191 | GetPmCapabilities:\r | |
192 | DebugLog StrGetPmCapabilities\r | |
193 | mov bx, 0x0080\r | |
194 | jmp Success\r | |
195 | \r | |
196 | \r | |
197 | ReadEdid:\r | |
198 | push es\r | |
199 | push di\r | |
200 | push ds\r | |
201 | push si\r | |
202 | push cx\r | |
203 | \r | |
204 | DebugLog StrReadEdid\r | |
205 | \r | |
206 | ; target (es:di) set on input\r | |
207 | push cs\r | |
208 | pop ds\r | |
209 | mov si, Edid\r | |
210 | ; source (ds:si) set now\r | |
211 | \r | |
212 | mov cx, 128\r | |
213 | cld\r | |
214 | rep movsb\r | |
215 | \r | |
216 | pop cx\r | |
217 | pop si\r | |
218 | pop ds\r | |
219 | pop di\r | |
220 | pop es\r | |
221 | jmp Success\r | |
222 | \r | |
223 | \r | |
224 | SetModeLegacy:\r | |
225 | DebugLog StrEnterSetModeLegacy\r | |
226 | \r | |
227 | cmp al, 0x03\r | |
228 | je sKnownMode3\r | |
229 | cmp al, 0x12\r | |
230 | je sKnownMode4\r | |
231 | DebugLog StrUnkownMode\r | |
232 | jmp Hang\r | |
233 | sKnownMode3:\r | |
234 | DebugLog StrLegacyMode3\r | |
235 | mov al, 0 ; 0x30\r | |
236 | jmp SetModeLegacyDone\r | |
237 | sKnownMode4:\r | |
238 | mov al, 0 ;0x20\r | |
239 | SetModeLegacyDone:\r | |
240 | DebugLog StrExitSuccess\r | |
241 | iret\r | |
242 | \r | |
243 | \r | |
244 | Success:\r | |
245 | DebugLog StrExitSuccess\r | |
246 | mov ax, 0x004f\r | |
247 | iret\r | |
248 | \r | |
249 | \r | |
250 | Unsupported:\r | |
251 | DebugLog StrExitUnsupported\r | |
252 | mov ax, 0x024f\r | |
253 | iret\r | |
254 | \r | |
255 | \r | |
256 | %ifdef DEBUG\r | |
257 | PrintStringSi:\r | |
258 | pusha\r | |
259 | push ds ; save original\r | |
260 | push cs\r | |
261 | pop ds\r | |
262 | mov dx, 0x220 ; bhyve debug cons port\r | |
263 | mov ax, 0\r | |
264 | PrintStringSiLoop:\r | |
265 | lodsb\r | |
266 | cmp al, 0\r | |
267 | je PrintStringSiDone\r | |
268 | out dx, al\r | |
269 | jmp PrintStringSiLoop\r | |
270 | PrintStringSiDone:\r | |
271 | pop ds ; restore original\r | |
272 | popa\r | |
273 | ret\r | |
274 | \r | |
275 | \r | |
276 | StrExitSuccess:\r | |
277 | db 'vOk', 0x0d, 0x0a, 0\r | |
278 | \r | |
279 | StrExitUnsupported:\r | |
280 | db 'vUnsupported', 0x0d, 0x0a, 0\r | |
281 | \r | |
282 | StrUnkownFunction:\r | |
283 | db 'vUnknown Function', 0x0d, 0x0a, 0\r | |
284 | \r | |
285 | StrEnterGetInfo:\r | |
286 | db 'vGetInfo', 0x0d, 0x0a, 0\r | |
287 | \r | |
288 | StrEnterGetModeInfo:\r | |
289 | db 'vGetModeInfo', 0x0d, 0x0a, 0\r | |
290 | \r | |
291 | StrEnterGetMode:\r | |
292 | db 'vGetMode', 0x0d, 0x0a, 0\r | |
293 | \r | |
294 | StrEnterSetMode:\r | |
295 | db 'vSetMode', 0x0d, 0x0a, 0\r | |
296 | \r | |
297 | StrEnterSetModeLegacy:\r | |
298 | db 'vSetModeLegacy', 0x0d, 0x0a, 0\r | |
299 | \r | |
300 | StrUnkownMode:\r | |
301 | db 'vUnkown Mode', 0x0d, 0x0a, 0\r | |
302 | \r | |
303 | StrGetPmCapabilities:\r | |
304 | db 'vGetPmCapabilities', 0x0d, 0x0a, 0\r | |
305 | \r | |
306 | StrReadEdid:\r | |
307 | db 'vReadEdid', 0x0d, 0x0a, 0\r | |
308 | \r | |
309 | StrLegacyMode3:\r | |
310 | db 'vLegacyMode3', 0x0d, 0x0a, 0\r | |
311 | \r | |
312 | \r | |
313 | StrMode1:\r | |
314 | db 'mode_640x480x32', 0x0d, 0x0a, 0\r | |
315 | StrMode2:\r | |
316 | db 'mode_800x600x32', 0x0d, 0x0a, 0\r | |
317 | StrMode3:\r | |
318 | db 'mode_1024x768x32', 0x0d, 0x0a, 0\r | |
319 | StrMode4:\r | |
320 | db 'mode_unused', 0x0d, 0x0a, 0\r | |
321 | %endif\r | |
322 | \r | |
323 | CurMode:\r | |
324 | db 0x00, 0x00\r | |
325 | \r | |
326 | ;\r | |
327 | ; EDID stores monitor information. For now, just send back an null item.\r | |
328 | ;\r | |
329 | Edid:\r | |
330 | db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r | |
331 | db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r | |
332 | db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r | |
333 | db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r | |
334 | db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r | |
335 | db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r | |
336 | db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r | |
337 | db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r | |
338 | db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r | |
339 | db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r | |
340 | db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r | |
341 | db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r | |
342 | db 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r |