VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/BIOS-new/vbe.c@ 43115

最後變更 在這個檔案從43115是 43115,由 vboxsync 提交於 13 年 前

export to OSE

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 20.1 KB
 
1// ============================================================================================
2//
3// Copyright (C) 2002 Jeroen Janssen
4//
5// This library is free software; you can redistribute it and/or
6// modify it under the terms of the GNU Lesser General Public
7// License as published by the Free Software Foundation; either
8// version 2 of the License, or (at your option) any later version.
9//
10// This library is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13// Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public
16// License along with this library; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18//
19// ============================================================================================
20//
21// This VBE is part of the VGA Bios specific to the plex86/bochs Emulated VGA card.
22// You can NOT drive any physical vga card with it.
23//
24// ============================================================================================
25//
26// This VBE Bios is based on information taken from :
27// - VESA BIOS EXTENSION (VBE) Core Functions Standard Version 3.0 located at www.vesa.org
28//
29// ============================================================================================
30
31
32/*
33 * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
34 * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
35 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
36 * a choice of LGPL license versions is made available with the language indicating
37 * that LGPLv2 or any later version may be used, or where a choice of which version
38 * of the LGPL is applied is otherwise unspecified.
39 */
40
41// Use VBE new dynamic mode list. Note that without this option, no
42// checks are currently done to make sure that modes fit into the
43// framebuffer!
44#define VBE_NEW_DYN_LIST
45
46#include <inttypes.h>
47#include <stddef.h>
48#include "vbe.h"
49#include "vgadefs.h"
50#include "inlines.h"
51
52// disable VESA/VBE2 check in vbe info
53//#define VBE2_NO_VESA_CHECK
54
55// use bytewise i/o (Longhorn beta issue, not in released Vista)
56//#define VBE_BYTEWISE_IO
57
58#ifdef VBE_BYTEWISE_IO
59 extern void do_out_dx_ax();
60 #pragma aux do_out_dx_ax "*";
61 extern void out_w(uint16_t port, uint16_t value);
62 #pragma aux out_w = \
63 "call do_out_dx_ax" \
64 parm [dx] [ax] modify nomemory;
65 extern void do_in_ax_dx();
66 #pragma aux do_in_ax_dx "*";
67 extern uint16_t in_w(uint16_t port);
68 #pragma aux in_w = \
69 "call do_in_ax_dx" \
70 parm [dx] value [ax] modify nomemory;
71#else
72 #define out_w outw
73 #define in_w inw
74#endif
75
76
77/* VESA signatures as integer constants. */
78#define SIG_VBE2 0x32454256 /* 'VBE2' */
79#define SIG_VESA 0x41534556 /* 'VESA' */
80
81
82/* Implemented in assembler. */
83extern void __cdecl vga_compat_setup(void);
84extern void dispi_set_enable(uint16_t enable);
85extern void dispi_set_bank(uint16_t bank);
86extern uint16_t __cdecl dispi_get_max_bpp(void);
87extern void __cdecl dispi_set_bank_farcall(void);
88
89// The current OEM Software Revision of this VBE Bios
90#define VBE_OEM_SOFTWARE_REV 0x0003
91
92// FIXME: 'merge' these (c) etc strings with the vgabios.c strings?
93char vbebios_copyright[] = "VirtualBox VESA BIOS";
94char vbebios_vendor_name[] = VBOX_VENDOR;
95char vbebios_product_name[] = VBOX_PRODUCT " VBE Adapter";
96char vbebios_product_revision[] = VBOX_PRODUCT " Version " VBOX_VERSION_STRING;
97
98char vbebios_info_string[] = "VirtualBox VBE Display Adapter enabled\r\n\r\n";
99char no_vbebios_info_string[] = "No VirtualBox VBE support available!\r\n\r\n";
100
101#ifdef VGA_DEBUG
102char msg_vbe_init[] = "VirtualBox Version " VBOX_VERSION_STRING " VBE Display Adapter\r\n";
103#endif
104
105static void dispi_set_xres(uint16_t xres)
106{
107#ifdef VGA_DEBUG
108 printf("vbe_set_xres: %04x\n", xres);
109#endif
110 out_w(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES);
111 out_w(VBE_DISPI_IOPORT_DATA, xres);
112}
113
114static void dispi_set_yres(uint16_t yres)
115{
116#ifdef VGA_DEBUG
117 printf("vbe_set_yres: %04x\n", yres);
118#endif
119 out_w(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES);
120 out_w(VBE_DISPI_IOPORT_DATA, yres);
121}
122
123static void dispi_set_bpp(uint16_t bpp)
124{
125#ifdef VGA_DEBUG
126 printf("vbe_set_bpp: %02x\n", bpp);
127#endif
128 out_w(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP);
129 out_w(VBE_DISPI_IOPORT_DATA, bpp);
130}
131
132uint16_t in_word(uint16_t port, uint16_t addr)
133{
134 outw(port, addr);
135 return inw(port);
136}
137
138#ifdef VBE_NEW_DYN_LIST
139uint8_t in_byte(uint16_t port, uint16_t addr)
140{
141 outw(port, addr);
142 return inb(port);
143}
144#endif
145
146
147/* Find the offset of the desired mode, given its number. */
148#ifdef VBE_NEW_DYN_LIST
149static uint16_t mode_info_find_mode(uint16_t mode, Boolean using_lfb)
150{
151 uint16_t sig, vmode, attrs;
152 uint16_t cur_info_ofs; /* Current offset in mode list. */
153
154 /* Read and check the VBE Extra Data signature. */
155 sig = in_word(VBE_EXTRA_PORT, 0);
156 if (sig != VBEHEADER_MAGIC) {
157 printf("Signature NOT found! %x\n", sig);
158 return 0;
159 }
160
161 cur_info_ofs = sizeof(VBEHeader);
162
163 vmode = in_word(VBE_EXTRA_PORT, cur_info_ofs + offsetof(ModeInfoListItem, mode)/*&cur_info->mode*/);
164 while (vmode != VBE_VESA_MODE_END_OF_LIST)
165 {
166 attrs = in_word(VBE_EXTRA_PORT, /*&cur_info->info.ModeAttributes*/cur_info_ofs + offsetof(ModeInfoListItem, info.ModeAttributes) );
167
168 if (vmode == mode)
169 {
170 if (!using_lfb)
171 return cur_info_ofs;
172 else if (attrs & VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE)
173 return cur_info_ofs;
174 else {
175 cur_info_ofs += sizeof(ModeInfoListItem);
176 vmode = in_word(VBE_EXTRA_PORT, /*&cur_info->mode*/cur_info_ofs + offsetof(ModeInfoListItem, mode));
177 }
178 } else {
179 cur_info_ofs += sizeof(ModeInfoListItem);
180 vmode = in_word(VBE_EXTRA_PORT, /*&cur_info->mode*/cur_info_ofs + offsetof(ModeInfoListItem, mode));
181 }
182 }
183 return 0;
184}
185#else
186static ModeInfoListItem* mode_info_find_mode(uint16_t mode, Boolean using_lfb)
187{
188 ModeInfoListItem *cur_info = &mode_info_list;
189
190 while (cur_info->mode != VBE_VESA_MODE_END_OF_LIST)
191 {
192 if (cur_info->mode == mode)
193 {
194 if (!using_lfb)
195 return cur_info;
196 else if (cur_info->info.ModeAttributes & VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE)
197 return cur_info;
198 else
199 cur_info++;
200 } else
201 cur_info++;
202 }
203 return 0;
204}
205#endif
206
207#ifndef VBOX
208; VBE Display Info - Display information on screen about the VBE
209
210vbe_display_info:
211 call _vbe_has_vbe_display
212 test ax, ax
213 jz no_vbe_flag
214 mov ax, #0xc000
215 mov ds, ax
216 mov si, #_vbebios_info_string
217 jmp _display_string
218no_vbe_flag:
219 mov ax, #0xc000
220 mov ds, ax
221 mov si, #_no_vbebios_info_string
222 jmp _display_string
223#endif
224
225/** Function 00h - Return VBE Controller Information
226 *
227 * Input:
228 * AX = 4F00h
229 * ES:DI = Pointer to buffer in which to place VbeInfoBlock structure
230 * (VbeSignature should be VBE2 when VBE 2.0 information is desired and
231 * the info block is 512 bytes in size)
232 * Output:
233 * AX = VBE Return Status
234 *
235 */
236void vbe_biosfn_return_controller_information(uint16_t STACK_BASED *AX, uint16_t ES, uint16_t DI)
237{
238 uint16_t status;
239 uint16_t vbe2_info;
240 uint16_t cur_mode = 0;
241 uint16_t cur_ptr=34;
242#ifdef VBE_NEW_DYN_LIST
243 uint16_t cur_info_ofs;
244 uint16_t sig, vmode;
245#else
246 ModeInfoListItem *cur_info = &mode_info_list;
247#endif
248 uint16_t max_bpp = dispi_get_max_bpp();
249 VbeInfoBlock __far *info_block;
250
251 info_block = ES :> (VbeInfoBlock *)DI;
252
253#ifdef VBE_NEW_DYN_LIST
254 /* Read VBE Extra Data signature */
255 sig = in_word(VBE_EXTRA_PORT, 0);
256 if (sig != VBEHEADER_MAGIC)
257 {
258 *AX = 0x0100;
259 printf("Signature NOT found\n");
260 return;
261 }
262 cur_info_ofs = sizeof(VBEHeader);
263#endif
264 status = *AX;
265
266#ifdef VGA_DEBUG
267 printf("VBE vbe_biosfn_return_vbe_info ES%x DI%x AX%x\n",ES,DI,status);
268#endif
269
270 vbe2_info = 0;
271
272 /* Don't use a local copy of VbeInfoBlock on the stack; it's too big.
273 * The Ubuntu 8.04 64 bits splash screen emulator can't handle this.
274 */
275#ifdef VBE2_NO_VESA_CHECK
276#else /* !VBE2_NO_VESA_CHECK */
277 // check for VBE2 signature
278 if (info_block->VbeSignature.Sig32 == SIG_VBE2 || info_block->VbeSignature.Sig32 == SIG_VESA)
279 {
280 vbe2_info = 1;
281#ifdef VGA_DEBUG
282 printf("VBE correct VESA/VBE2 signature found\n");
283#endif
284 }
285#endif /* !VBE2_NO_VESA_CHECK */
286
287 /* VBE Signature - the compiler will optimize this into something sane. */
288 info_block->VbeSignature.SigChr[0] = 'V';
289 info_block->VbeSignature.SigChr[1] = 'E';
290 info_block->VbeSignature.SigChr[2] = 'S';
291 info_block->VbeSignature.SigChr[3] = 'A';
292
293 /* VBE Version supported. */
294 info_block->VbeVersion = 0x0200; /* Version 2.0. */
295
296 /* OEM String. */
297 info_block->OemString.Ptr = &vbebios_copyright;
298
299 /* Capabilities if this implementation. */
300 info_block->Capabilities[0] = VBE_CAPABILITY_8BIT_DAC;
301 info_block->Capabilities[1] = 0;
302 info_block->Capabilities[2] = 0;
303 info_block->Capabilities[3] = 0;
304
305 /* Video mode list pointer (dynamically generated). */
306 info_block->VideoModePtr_Seg = ES;
307 info_block->VideoModePtr_Off = DI + 34;
308
309 /* Total controller memory in 64K units. */
310 info_block->TotalMemory = in_word(VBE_EXTRA_PORT, 0xffff);
311
312 if (vbe2_info)
313 {
314 /* OEM information. */
315 info_block->OemSoftwareRev = VBE_OEM_SOFTWARE_REV;
316 info_block->OemVendorName.Ptr = &vbebios_vendor_name;
317 info_block->OemProductName.Ptr = &vbebios_product_name;
318 info_block->OemProductRev.Ptr = &vbebios_product_revision;
319 }
320
321#ifdef VBE_NEW_DYN_LIST
322 do
323 {
324 uint8_t data_b;
325
326 data_b = in_byte(VBE_EXTRA_PORT, cur_info_ofs + offsetof(ModeInfoListItem, info.BitsPerPixel) /*&cur_info->info.BitsPerPixel*/);
327 if (data_b <= max_bpp)
328 {
329 vmode = in_word(VBE_EXTRA_PORT, cur_info_ofs + offsetof(ModeInfoListItem, mode)/*&cur_info->mode*/);
330#ifdef VGA_DEBUG
331 printf("VBE found mode %x => %x\n", vmode, cur_mode);
332#endif
333 write_word(ES, DI + cur_ptr, vmode);
334 cur_mode++;
335 cur_ptr+=2;
336 }
337 cur_info_ofs += sizeof(ModeInfoListItem);
338 vmode = in_word(VBE_EXTRA_PORT, cur_info_ofs + offsetof(ModeInfoListItem, mode)/*&cur_info->mode*/);
339 } while (vmode != VBE_VESA_MODE_END_OF_LIST);
340
341 // Add vesa mode list terminator
342 write_word(ES, DI + cur_ptr, vmode);
343#else
344 do
345 {
346 if (cur_info->info.BitsPerPixel <= max_bpp) {
347#ifdef VGA_DEBUG
348 printf("VBE found mode %x => %x\n", cur_info->mode,cur_mode);
349#endif
350 write_word(ES, DI + cur_ptr, cur_info->mode);
351 cur_mode++;
352 cur_ptr += 2;
353 }
354 cur_info++;
355 } while (cur_info->mode != VBE_VESA_MODE_END_OF_LIST);
356
357 // Add vesa mode list terminator
358 write_word(ES, DI + cur_ptr, cur_info->mode);
359#endif // VBE_NEW_DYN_LIST
360 *AX = 0x004F;
361}
362
363/** Function 01h - Return VBE Mode Information
364 *
365 * Input:
366 * AX = 4F01h
367 * CX = Mode Number
368 * ES:DI = Pointer to buffer in which to place ModeInfoBlock structure
369 * Output:
370 * AX = VBE Return Status
371 *
372 */
373void vbe_biosfn_return_mode_information(uint16_t STACK_BASED *AX, uint16_t CX, uint16_t ES, uint16_t DI)
374{
375 uint16_t result = 0x0100;
376#ifdef VBE_NEW_DYN_LIST
377 uint16_t cur_info_ofs;
378#else
379 ModeInfoListItem *cur_info;
380#endif
381 Boolean using_lfb;
382 uint8_t win_attr;
383
384#ifdef VGA_DEBUG
385 printf("VBE vbe_biosfn_return_mode_information ES%x DI%x CX%x\n",ES,DI,CX);
386#endif
387
388 using_lfb = ((CX & VBE_MODE_LINEAR_FRAME_BUFFER) == VBE_MODE_LINEAR_FRAME_BUFFER);
389 CX = (CX & 0x1ff);
390
391#ifdef VBE_NEW_DYN_LIST
392 cur_info_ofs = mode_info_find_mode(CX, using_lfb);
393
394 if (cur_info_ofs) {
395 uint16_t i;
396#else
397 cur_info = mode_info_find_mode(CX, using_lfb);
398
399 if (cur_info != 0) {
400#endif
401#ifdef VGA_DEBUG
402 printf("VBE found mode %x\n",CX);
403#endif
404 memsetb(ES, DI, 0, 256); // The mode info size is fixed
405#ifdef VBE_NEW_DYN_LIST
406 for (i = 0; i < sizeof(ModeInfoBlockCompact); i++) {
407 uint8_t b;
408
409 b = in_byte(VBE_EXTRA_PORT, cur_info_ofs + offsetof(ModeInfoListItem, info) + i/*(char *)(&(cur_info->info)) + i*/);
410 write_byte(ES, DI + i, b);
411 }
412#else
413 memcpyb(ES, DI, 0xc000, &(cur_info->info), sizeof(ModeInfoBlockCompact));
414#endif
415 win_attr = read_byte(ES, DI + offsetof(ModeInfoBlock, WinAAttributes));
416 if (win_attr & VBE_WINDOW_ATTRIBUTE_RELOCATABLE) {
417 write_word(ES, DI + offsetof(ModeInfoBlock, WinFuncPtr), (uint16_t)(dispi_set_bank_farcall));
418 // If BIOS not at 0xC000 -> boom
419 write_word(ES, DI + offsetof(ModeInfoBlock, WinFuncPtr) + 2, 0xC000);
420 }
421 // Update the LFB physical address which may change at runtime
422 out_w(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_FB_BASE_HI);
423 write_word(ES, DI + offsetof(ModeInfoBlock, PhysBasePtr) + 2, in_w(VBE_DISPI_IOPORT_DATA));
424
425 result = 0x4f;
426 } else {
427#ifdef VGA_DEBUG
428 printf("VBE *NOT* found mode %x\n",CX);
429#endif
430 result = 0x100;
431 }
432
433 *AX = result;
434}
435
436/** Function 02h - Set VBE Mode
437 *
438 * Input:
439 * AX = 4F02h
440 * BX = Desired Mode to set
441 * ES:DI = Pointer to CRTCInfoBlock structure
442 * Output:
443 * AX = VBE Return Status
444 *
445 */
446void vbe_biosfn_set_mode(uint16_t STACK_BASED *AX, uint16_t BX, uint16_t ES, uint16_t DI)
447{
448 uint16_t result;
449#ifdef VBE_NEW_DYN_LIST
450 uint16_t cur_info_ofs;
451#else
452 ModeInfoListItem *cur_info;
453#endif
454 Boolean using_lfb;
455 uint8_t no_clear;
456 uint8_t lfb_flag;
457
458 using_lfb = ((BX & VBE_MODE_LINEAR_FRAME_BUFFER) == VBE_MODE_LINEAR_FRAME_BUFFER);
459 lfb_flag = using_lfb ? VBE_DISPI_LFB_ENABLED : 0;
460 no_clear = ((BX & VBE_MODE_PRESERVE_DISPLAY_MEMORY) == VBE_MODE_PRESERVE_DISPLAY_MEMORY) ? VBE_DISPI_NOCLEARMEM : 0;
461
462 BX = (BX & 0x1ff);
463
464 // check for non vesa mode
465 if (BX < VBE_MODE_VESA_DEFINED)
466 {
467 uint8_t mode;
468
469 dispi_set_enable(VBE_DISPI_DISABLED);
470 // call the vgabios in order to set the video mode
471 // this allows for going back to textmode with a VBE call (some applications expect that to work)
472 mode = (BX & 0xff);
473 biosfn_set_video_mode(mode);
474 result = 0x4f;
475 goto leave;
476 }
477
478#ifdef VBE_NEW_DYN_LIST
479 cur_info_ofs = mode_info_find_mode(BX, using_lfb);
480
481 if (cur_info_ofs != 0)
482 {
483 uint16_t xres, yres;
484 uint8_t bpp;
485
486 xres = in_word(VBE_EXTRA_PORT, cur_info_ofs + offsetof(ModeInfoListItem, info.XResolution) /*&cur_info->info.XResolution*/);
487 yres = in_word(VBE_EXTRA_PORT, cur_info_ofs + offsetof(ModeInfoListItem, info.YResolution) /*&cur_info->info.YResolution*/);
488 bpp = in_byte(VBE_EXTRA_PORT, cur_info_ofs + offsetof(ModeInfoListItem, info.BitsPerPixel) /*&cur_info->info.BitsPerPixel*/);
489
490#ifdef VGA_DEBUG
491 printf("VBE found mode %x, setting:\n", BX);
492 printf("\txres%x yres%x bpp%x\n", xres, yres, bpp);
493#endif
494#else
495 cur_info = mode_info_find_mode(BX, using_lfb);
496
497 if (cur_info != 0)
498 {
499#ifdef VGA_DEBUG
500 printf("VBE found mode %x, setting:\n", BX);
501 printf("\txres%x yres%x bpp%x\n",
502 cur_info->info.XResolution,
503 cur_info->info.YResolution,
504 cur_info->info.BitsPerPixel);
505#endif
506#endif // VBE_NEW_DYN_LIST
507
508 // first disable current mode (when switching between vesa modi)
509 dispi_set_enable(VBE_DISPI_DISABLED);
510
511#ifdef VBE_NEW_DYN_LIST
512 if (bpp == 4)
513#else
514 if (cur_info->info.BitsPerPixel == 4)
515#endif
516 {
517 biosfn_set_video_mode(0x6a);
518 }
519
520#ifdef VBE_NEW_DYN_LIST
521 dispi_set_bpp(bpp);
522 dispi_set_xres(xres);
523 dispi_set_yres(yres);
524#else
525 dispi_set_bpp(cur_info->info.BitsPerPixel);
526 dispi_set_xres(cur_info->info.XResolution);
527 dispi_set_yres(cur_info->info.YResolution);
528#endif
529 dispi_set_bank(0);
530 dispi_set_enable(VBE_DISPI_ENABLED | no_clear | lfb_flag);
531 vga_compat_setup();
532
533 write_word(BIOSMEM_SEG,BIOSMEM_VBE_MODE,BX);
534 write_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL,(0x60 | no_clear));
535
536 result = 0x4f;
537 }
538 else
539 {
540#ifdef VGA_DEBUG
541 printf("VBE *NOT* found mode %x\n" , BX);
542#endif
543 result = 0x100;
544 }
545
546leave:
547 *AX = result;
548}
549
550uint16_t vbe_biosfn_read_video_state_size(void)
551{
552 return 9 * 2;
553}
554
555void vbe_biosfn_save_video_state(uint16_t ES, uint16_t BX)
556{
557 uint16_t enable, i;
558
559 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
560 enable = inw(VBE_DISPI_IOPORT_DATA);
561 write_word(ES, BX, enable);
562 BX += 2;
563 if (!(enable & VBE_DISPI_ENABLED))
564 return;
565 for(i = VBE_DISPI_INDEX_XRES; i <= VBE_DISPI_INDEX_Y_OFFSET; i++) {
566 if (i != VBE_DISPI_INDEX_ENABLE) {
567 outw(VBE_DISPI_IOPORT_INDEX, i);
568 write_word(ES, BX, inw(VBE_DISPI_IOPORT_DATA));
569 BX += 2;
570 }
571 }
572}
573
574
575void vbe_biosfn_restore_video_state(uint16_t ES, uint16_t BX)
576{
577 uint16_t enable, i;
578
579 enable = read_word(ES, BX);
580 BX += 2;
581
582 if (!(enable & VBE_DISPI_ENABLED)) {
583 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
584 outw(VBE_DISPI_IOPORT_DATA, enable);
585 } else {
586 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES);
587 outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
588 BX += 2;
589 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES);
590 outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
591 BX += 2;
592 outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP);
593 outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
594 BX += 2;
595 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
596 outw(VBE_DISPI_IOPORT_DATA, enable);
597
598 for(i = VBE_DISPI_INDEX_BANK; i <= VBE_DISPI_INDEX_Y_OFFSET; i++) {
599 outw(VBE_DISPI_IOPORT_INDEX, i);
600 outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
601 BX += 2;
602 }
603 }
604}
605
606/** Function 04h - Save/Restore State
607 *
608 * Input:
609 * AX = 4F04h
610 * DL = 00h Return Save/Restore State buffer size
611 * 01h Save State
612 * 02h Restore State
613 * CX = Requested states
614 * ES:BX = Pointer to buffer (if DL <> 00h)
615 * Output:
616 * AX = VBE Return Status
617 * BX = Number of 64-byte blocks to hold the state buffer (if DL=00h)
618 *
619 */
620void vbe_biosfn_save_restore_state(uint16_t STACK_BASED *AX, uint16_t CX, uint16_t DX,
621 uint16_t ES, uint16_t STACK_BASED *BX)
622{
623 uint16_t result, val;
624
625 result = 0x004F;
626 switch(GET_DL()) {
627 case 0x00:
628 val = biosfn_read_video_state_size2(CX);
629#ifdef VGA_DEBUG
630 printf("VGA state size=%x\n", val);
631#endif
632 if (CX & 8)
633 val += vbe_biosfn_read_video_state_size();
634 *BX = (val + 63) / 64;
635 break;
636 case 0x01:
637 val = *BX;
638 val = biosfn_save_video_state(CX, ES, val);
639#ifdef VGA_DEBUG
640 printf("VGA save_state offset=%x\n", val);
641#endif
642 if (CX & 8)
643 vbe_biosfn_save_video_state(ES, val);
644 break;
645 case 0x02:
646 val = *BX;
647 val = biosfn_restore_video_state(CX, ES, val);
648#ifdef VGA_DEBUG
649 printf("VGA restore_state offset=%x\n", val);
650#endif
651 if (CX & 8)
652 vbe_biosfn_restore_video_state(ES, val);
653 break;
654 default:
655 // function failed
656 result = 0x100;
657 break;
658 }
659 *AX = result;
660}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette