- applied new patch for the cirrus extension from suzu
[vgabios.git] / vbe.c
blob4c2ad10d8370c192f4ce443d998a01d21b83596d
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.
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.
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
29 // ============================================================================================
32 // defines available
33 // enable LFB support
34 #define VBE_HAVE_LFB
36 // disable VESA/VBE2 check in vbe info
37 //#define VBE2_NO_VESA_CHECK
39 // dynamicly generate a mode_info list
40 #define DYN_LIST
43 #include "vbe.h"
44 #include "vbetables.h"
47 // The current OEM Software Revision of this VBE Bios
48 #define VBE_OEM_SOFTWARE_REV 0x0002;
50 extern char vbebios_copyright;
51 extern char vbebios_vendor_name;
52 extern char vbebios_product_name;
53 extern char vbebios_product_revision;
55 #ifndef DYN_LIST
56 extern Bit16u vbebios_mode_list;
57 #endif
59 ASM_START
60 // FIXME: 'merge' these (c) etc strings with the vgabios.c strings?
61 _vbebios_copyright:
62 .ascii "Bochs/Plex86 VBE(C) 2003 http://savannah.nongnu.org/projects/vgabios/"
63 .byte 0x00
65 _vbebios_vendor_name:
66 .ascii "Bochs/Plex86 Developers"
67 .byte 0x00
69 _vbebios_product_name:
70 .ascii "Bochs/Plex86 VBE Adapter"
71 .byte 0x00
73 _vbebios_product_revision:
74 .ascii "$Id$"
75 .byte 0x00
77 _vbebios_info_string:
78 .ascii "Bochs VBE Display Adapter enabled"
79 .byte 0x0a,0x0d
80 .byte 0x0a,0x0d
81 .byte 0x00
83 _no_vbebios_info_string:
84 .ascii "NO Bochs VBE Support available!"
85 .byte 0x0a,0x0d
86 .byte 0x0a,0x0d
87 .byte 0x00
89 msg_vbe_init:
90 .ascii "VBE Bios $Id$"
91 .byte 0x0a,0x0d, 0x00
94 #ifndef DYN_LIST
95 // FIXME: for each new mode add a statement here
96 // at least until dynamic list creation is working
97 _vbebios_mode_list:
99 .word VBE_VESA_MODE_640X400X8
100 .word VBE_VESA_MODE_640X480X8
101 .word VBE_VESA_MODE_800X600X4
102 .word VBE_VESA_MODE_800X600X8
103 .word VBE_VESA_MODE_1024X768X8
104 .word VBE_VESA_MODE_640X480X1555
105 .word VBE_VESA_MODE_640X480X565
106 .word VBE_VESA_MODE_640X480X888
107 .word VBE_VESA_MODE_800X600X1555
108 .word VBE_VESA_MODE_800X600X565
109 .word VBE_VESA_MODE_800X600X888
110 .word VBE_VESA_MODE_1024X768X1555
111 .word VBE_VESA_MODE_1024X768X565
112 .word VBE_VESA_MODE_1024X768X888
113 .word VBE_OWN_MODE_640X480X8888
114 .word VBE_OWN_MODE_800X600X8888
115 .word VBE_OWN_MODE_1024X768X8888
116 .word VBE_OWN_MODE_320X200X8
117 .word VBE_VESA_MODE_END_OF_LIST
118 #endif
120 ASM_END
122 // from rombios.c
123 #define PANIC_PORT 0x501
125 ASM_START
126 MACRO HALT
127 ;; the HALT macro is called with the line number of the HALT call.
128 ;; The line number is then sent to the PANIC_PORT, causing Bochs to
129 ;; print a BX_PANIC message. This will normally halt the simulation
130 ;; with a message such as "BIOS panic at rombios.c, line 4091".
131 ;; However, users can choose to make panics non-fatal and continue.
132 mov dx,#PANIC_PORT
133 mov ax,#?1
134 out dx,ax
135 MEND
137 ; DISPI ioport functions
139 dispi_get_id:
140 push dx
141 mov dx, # VBE_DISPI_IOPORT_INDEX
142 mov ax, # VBE_DISPI_INDEX_ID
143 out dx, ax
144 mov dx, # VBE_DISPI_IOPORT_DATA
145 in ax, dx
146 pop dx
149 dispi_set_id:
150 push dx
151 push ax
152 mov dx, # VBE_DISPI_IOPORT_INDEX
153 mov ax, # VBE_DISPI_INDEX_ID
154 out dx, ax
155 pop ax
156 mov dx, # VBE_DISPI_IOPORT_DATA
157 out dx, ax
158 pop dx
160 ASM_END
162 static void dispi_set_xres(xres)
163 Bit16u xres;
165 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_XRES);
166 outw(VBE_DISPI_IOPORT_DATA,xres);
169 static void dispi_set_yres(yres)
170 Bit16u yres;
172 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_YRES);
173 outw(VBE_DISPI_IOPORT_DATA,yres);
176 static void dispi_set_bpp(bpp)
177 Bit16u bpp;
179 outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_BPP);
180 outw(VBE_DISPI_IOPORT_DATA,bpp);
183 ASM_START
184 ; AL = bits per pixel / AH = bytes per pixel
185 dispi_get_bpp:
186 push dx
187 mov dx, # VBE_DISPI_IOPORT_INDEX
188 mov ax, # VBE_DISPI_INDEX_BPP
189 out dx, ax
190 mov dx, # VBE_DISPI_IOPORT_DATA
191 in ax, dx
192 mov ah, al
193 shr ah, 3
194 test al, #0x07
195 jz get_bpp_noinc
196 inc ah
197 get_bpp_noinc:
198 pop dx
201 _dispi_get_max_bpp:
202 push dx
203 push bx
204 call dispi_get_enable
205 mov bx, ax
206 or ax, # VBE_DISPI_GETCAPS
207 call _dispi_set_enable
208 mov dx, # VBE_DISPI_IOPORT_INDEX
209 mov ax, # VBE_DISPI_INDEX_BPP
210 out dx, ax
211 mov dx, # VBE_DISPI_IOPORT_DATA
212 in ax, dx
213 push ax
214 mov ax, bx
215 call _dispi_set_enable
216 pop ax
217 pop bx
218 pop dx
221 _dispi_set_enable:
222 push dx
223 push ax
224 mov dx, # VBE_DISPI_IOPORT_INDEX
225 mov ax, # VBE_DISPI_INDEX_ENABLE
226 out dx, ax
227 pop ax
228 mov dx, # VBE_DISPI_IOPORT_DATA
229 out dx, ax
230 pop dx
233 dispi_get_enable:
234 push dx
235 mov dx, # VBE_DISPI_IOPORT_INDEX
236 mov ax, # VBE_DISPI_INDEX_ENABLE
237 out dx, ax
238 mov dx, # VBE_DISPI_IOPORT_DATA
239 in ax, dx
240 pop dx
242 ASM_END
244 ASM_START
245 _dispi_set_bank:
246 push dx
247 push ax
248 mov dx, # VBE_DISPI_IOPORT_INDEX
249 mov ax, # VBE_DISPI_INDEX_BANK
250 out dx, ax
251 pop ax
252 mov dx, # VBE_DISPI_IOPORT_DATA
253 out dx, ax
254 pop dx
257 dispi_get_bank:
258 push dx
259 mov dx, # VBE_DISPI_IOPORT_INDEX
260 mov ax, # VBE_DISPI_INDEX_BANK
261 out dx, ax
262 mov dx, # VBE_DISPI_IOPORT_DATA
263 in ax, dx
264 pop dx
266 ASM_END
268 static void dispi_set_bank_farcall()
270 ASM_START
271 cmp bx,#0x0100
272 je dispi_set_bank_farcall_get
273 or bx,bx
274 jnz dispi_set_bank_farcall_error
275 push dx
276 mov ax,# VBE_DISPI_INDEX_BANK
277 mov dx,# VBE_DISPI_IOPORT_INDEX
278 out dx,ax
279 pop ax
280 mov dx,# VBE_DISPI_IOPORT_DATA
281 out dx,ax
282 retf
283 dispi_set_bank_farcall_get:
284 mov ax,# VBE_DISPI_INDEX_BANK
285 mov dx,# VBE_DISPI_IOPORT_INDEX
286 out dx,ax
287 mov dx,# VBE_DISPI_IOPORT_DATA
288 in ax,dx
289 mov dx,ax
290 retf
291 dispi_set_bank_farcall_error:
292 mov ax,#0x014F
293 retf
294 ASM_END
297 ASM_START
298 dispi_set_x_offset:
299 push dx
300 push ax
301 mov dx, # VBE_DISPI_IOPORT_INDEX
302 mov ax, # VBE_DISPI_INDEX_X_OFFSET
303 out dx, ax
304 pop ax
305 mov dx, # VBE_DISPI_IOPORT_DATA
306 out dx, ax
307 pop dx
310 dispi_get_x_offset:
311 push dx
312 mov dx, # VBE_DISPI_IOPORT_INDEX
313 mov ax, # VBE_DISPI_INDEX_X_OFFSET
314 out dx, ax
315 mov dx, # VBE_DISPI_IOPORT_DATA
316 in ax, dx
317 pop dx
320 dispi_set_y_offset:
321 push dx
322 push ax
323 mov dx, # VBE_DISPI_IOPORT_INDEX
324 mov ax, # VBE_DISPI_INDEX_Y_OFFSET
325 out dx, ax
326 pop ax
327 mov dx, # VBE_DISPI_IOPORT_DATA
328 out dx, ax
329 pop dx
332 dispi_get_y_offset:
333 push dx
334 mov dx, # VBE_DISPI_IOPORT_INDEX
335 mov ax, # VBE_DISPI_INDEX_Y_OFFSET
336 out dx, ax
337 mov dx, # VBE_DISPI_IOPORT_DATA
338 in ax, dx
339 pop dx
342 dispi_set_virt_width:
343 push dx
344 push ax
345 mov dx, # VBE_DISPI_IOPORT_INDEX
346 mov ax, # VBE_DISPI_INDEX_VIRT_WIDTH
347 out dx, ax
348 pop ax
349 mov dx, # VBE_DISPI_IOPORT_DATA
350 out dx, ax
351 pop dx
354 dispi_get_virt_width:
355 push dx
356 mov dx, # VBE_DISPI_IOPORT_INDEX
357 mov ax, # VBE_DISPI_INDEX_VIRT_WIDTH
358 out dx, ax
359 mov dx, # VBE_DISPI_IOPORT_DATA
360 in ax, dx
361 pop dx
364 dispi_get_virt_height:
365 push dx
366 mov dx, # VBE_DISPI_IOPORT_INDEX
367 mov ax, # VBE_DISPI_INDEX_VIRT_HEIGHT
368 out dx, ax
369 mov dx, # VBE_DISPI_IOPORT_DATA
370 in ax, dx
371 pop dx
373 ASM_END
376 // ModeInfo helper function
377 static ModeInfoListItem* mode_info_find_mode(mode, using_lfb)
378 Bit16u mode; Boolean using_lfb;
380 ModeInfoListItem *cur_info=&mode_info_list;
382 while (cur_info->mode != VBE_VESA_MODE_END_OF_LIST)
384 if (cur_info->mode == mode)
386 if (!using_lfb)
388 return cur_info;
390 else if (cur_info->info.ModeAttributes & VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE)
392 return cur_info;
394 else
396 cur_info++;
399 else
401 cur_info++;
405 return 0;
408 ASM_START
410 ; Has VBE display - Returns true if VBE display detected
412 _vbe_has_vbe_display:
413 push ds
414 push bx
415 mov ax, # BIOSMEM_SEG
416 mov ds, ax
417 mov bx, # BIOSMEM_VBE_FLAG
418 mov al, [bx]
419 and al, #0x01
420 xor ah, ah
421 pop bx
422 pop ds
425 ; VBE Init - Initialise the Vesa Bios Extension Code
426 ; This function does a sanity check on the host side display code interface.
428 vbe_init:
429 mov ax, # VBE_DISPI_ID0
430 call dispi_set_id
431 call dispi_get_id
432 cmp ax, # VBE_DISPI_ID0
433 jne no_vbe_interface
434 push ds
435 push bx
436 mov ax, # BIOSMEM_SEG
437 mov ds, ax
438 mov bx, # BIOSMEM_VBE_FLAG
439 mov al, #0x01
440 mov [bx], al
441 pop bx
442 pop ds
443 mov ax, # VBE_DISPI_ID3
444 call dispi_set_id
445 no_vbe_interface:
446 mov bx, #msg_vbe_init
447 push bx
448 call _printf
449 inc sp
450 inc sp
453 ; VBE Display Info - Display information on screen about the VBE
455 vbe_display_info:
456 call _vbe_has_vbe_display
457 test ax, ax
458 jz no_vbe_flag
459 mov ax, #0xc000
460 mov ds, ax
461 mov si, #_vbebios_info_string
462 jmp _display_string
463 no_vbe_flag:
464 mov ax, #0xc000
465 mov ds, ax
466 mov si, #_no_vbebios_info_string
467 jmp _display_string
468 ASM_END
470 /** Function 00h - Return VBE Controller Information
472 * Input:
473 * AX = 4F00h
474 * ES:DI = Pointer to buffer in which to place VbeInfoBlock structure
475 * (VbeSignature should be VBE2 when VBE 2.0 information is desired and
476 * the info block is 512 bytes in size)
477 * Output:
478 * AX = VBE Return Status
481 void vbe_biosfn_return_controller_information(AX, ES, DI)
482 Bit16u *AX;Bit16u ES;Bit16u DI;
484 Bit16u ss=get_SS();
485 VbeInfoBlock vbe_info_block;
486 Bit16u status;
487 Bit16u result;
488 Bit16u vbe2_info;
489 Bit16u cur_mode=0;
490 Bit16u cur_ptr=34;
491 ModeInfoListItem *cur_info=&mode_info_list;
493 status = read_word(ss, AX);
495 #ifdef DEBUG
496 printf("VBE vbe_biosfn_return_vbe_info ES%x DI%x AX%x\n",ES,DI,status);
497 #endif
499 vbe2_info = 0;
500 #ifdef VBE2_NO_VESA_CHECK
501 #else
502 // get vbe_info_block into local variable
503 memcpyb(ss, &vbe_info_block, ES, DI, sizeof(vbe_info_block));
505 // check for VBE2 signature
506 if (((vbe_info_block.VbeSignature[0] == 'V') &&
507 (vbe_info_block.VbeSignature[1] == 'B') &&
508 (vbe_info_block.VbeSignature[2] == 'E') &&
509 (vbe_info_block.VbeSignature[3] == '2')) ||
511 ((vbe_info_block.VbeSignature[0] == 'V') &&
512 (vbe_info_block.VbeSignature[1] == 'E') &&
513 (vbe_info_block.VbeSignature[2] == 'S') &&
514 (vbe_info_block.VbeSignature[3] == 'A')) )
516 vbe2_info = 1;
517 #ifdef DEBUG
518 printf("VBE correct VESA/VBE2 signature found\n");
519 #endif
521 #endif
523 // VBE Signature
524 vbe_info_block.VbeSignature[0] = 'V';
525 vbe_info_block.VbeSignature[1] = 'E';
526 vbe_info_block.VbeSignature[2] = 'S';
527 vbe_info_block.VbeSignature[3] = 'A';
529 // VBE Version supported
530 vbe_info_block.VbeVersion = 0x0200;
532 // OEM String
533 vbe_info_block.OemStringPtr_Seg = 0xc000;
534 vbe_info_block.OemStringPtr_Off = &vbebios_copyright;
536 // Capabilities
537 vbe_info_block.Capabilities[0] = VBE_CAPABILITY_8BIT_DAC;
538 vbe_info_block.Capabilities[1] = 0;
539 vbe_info_block.Capabilities[2] = 0;
540 vbe_info_block.Capabilities[3] = 0;
542 #ifdef DYN_LIST
543 // VBE Video Mode Pointer (dynamicly generated from the mode_info_list)
544 vbe_info_block.VideoModePtr_Seg= ES ;
545 vbe_info_block.VideoModePtr_Off= DI + 34;
546 #else
547 // VBE Video Mode Pointer (staticly in rom)
548 vbe_info_block.VideoModePtr_Seg = 0xc000;
549 vbe_info_block.VideoModePtr_Off = &vbebios_mode_list;
550 #endif
552 // VBE Total Memory (in 64b blocks)
553 vbe_info_block.TotalMemory = VBE_TOTAL_VIDEO_MEMORY_DIV_64K;
555 if (vbe2_info)
557 // OEM Stuff
558 vbe_info_block.OemSoftwareRev = VBE_OEM_SOFTWARE_REV;
559 vbe_info_block.OemVendorNamePtr_Seg = 0xc000;
560 vbe_info_block.OemVendorNamePtr_Off = &vbebios_vendor_name;
561 vbe_info_block.OemProductNamePtr_Seg = 0xc000;
562 vbe_info_block.OemProductNamePtr_Off = &vbebios_product_name;
563 vbe_info_block.OemProductRevPtr_Seg = 0xc000;
564 vbe_info_block.OemProductRevPtr_Off = &vbebios_product_revision;
566 // copy updates in vbe_info_block back
567 memcpyb(ES, DI, ss, &vbe_info_block, sizeof(vbe_info_block));
569 else
571 // copy updates in vbe_info_block back (VBE 1.x compatibility)
572 memcpyb(ES, DI, ss, &vbe_info_block, 256);
575 #ifdef DYN_LIST
578 if (cur_info->info.BitsPerPixel <= dispi_get_max_bpp()) {
579 #ifdef DEBUG
580 printf("VBE found mode %x => %x\n", cur_info->mode,cur_mode);
581 #endif
582 write_word(ES, DI + cur_ptr, cur_info->mode);
583 cur_mode++;
584 cur_ptr+=2;
586 cur_info++;
587 } while (cur_info->mode != VBE_VESA_MODE_END_OF_LIST);
589 // Add vesa mode list terminator
590 write_word(ES, DI + cur_ptr, cur_info->mode);
591 #endif
593 result = 0x4f;
595 write_word(ss, AX, result);
599 /** Function 01h - Return VBE Mode Information
601 * Input:
602 * AX = 4F01h
603 * CX = Mode Number
604 * ES:DI = Pointer to buffer in which to place ModeInfoBlock structure
605 * Output:
606 * AX = VBE Return Status
609 void vbe_biosfn_return_mode_information(AX, CX, ES, DI)
610 Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI;
612 Bit16u result=0x0100;
613 Bit16u ss=get_SS();
614 ModeInfoBlock info;
615 ModeInfoListItem *cur_info;
616 Boolean using_lfb;
618 #ifdef DEBUG
619 printf("VBE vbe_biosfn_return_mode_information ES%x DI%x CX%x\n",ES,DI,CX);
620 #endif
622 using_lfb=((CX & VBE_MODE_LINEAR_FRAME_BUFFER) == VBE_MODE_LINEAR_FRAME_BUFFER);
624 CX = (CX & 0x1ff);
626 cur_info = mode_info_find_mode(CX, using_lfb, &cur_info);
628 if (cur_info != 0)
630 #ifdef DEBUG
631 printf("VBE found mode %x\n",CX);
632 #endif
633 memsetb(ss, &info, 0, sizeof(ModeInfoBlock));
634 memcpyb(ss, &info, 0xc000, &(cur_info->info), sizeof(ModeInfoBlockCompact));
635 if (info.WinAAttributes & VBE_WINDOW_ATTRIBUTE_RELOCATABLE) {
636 info.WinFuncPtr = 0xC0000000UL;
637 *(Bit16u *)&(info.WinFuncPtr) = (Bit16u)(dispi_set_bank_farcall);
640 result = 0x4f;
642 else
644 #ifdef DEBUG
645 printf("VBE *NOT* found mode %x\n",CX);
646 #endif
647 result = 0x100;
650 if (result == 0x4f)
652 // copy updates in mode_info_block back
653 memcpyb(ES, DI, ss, &info, sizeof(info));
656 write_word(ss, AX, result);
659 /** Function 02h - Set VBE Mode
661 * Input:
662 * AX = 4F02h
663 * BX = Desired Mode to set
664 * ES:DI = Pointer to CRTCInfoBlock structure
665 * Output:
666 * AX = VBE Return Status
669 void vbe_biosfn_set_mode(AX, BX, ES, DI)
670 Bit16u *AX;Bit16u BX; Bit16u ES;Bit16u DI;
672 Bit16u ss = get_SS();
673 Bit16u result;
674 ModeInfoListItem *cur_info;
675 Boolean using_lfb;
676 Bit8u no_clear;
677 Bit8u lfb_flag;
679 using_lfb=((BX & VBE_MODE_LINEAR_FRAME_BUFFER) == VBE_MODE_LINEAR_FRAME_BUFFER);
680 lfb_flag=using_lfb?VBE_DISPI_LFB_ENABLED:0;
681 no_clear=((BX & VBE_MODE_PRESERVE_DISPLAY_MEMORY) == VBE_MODE_PRESERVE_DISPLAY_MEMORY)?VBE_DISPI_NOCLEARMEM:0;
683 BX = (BX & 0x1ff);
685 //result=read_word(ss,AX);
687 // check for non vesa mode
688 if (BX<VBE_MODE_VESA_DEFINED)
690 Bit8u mode;
692 dispi_set_enable(VBE_DISPI_DISABLED);
693 // call the vgabios in order to set the video mode
694 // this allows for going back to textmode with a VBE call (some applications expect that to work)
696 mode=(BX & 0xff);
697 biosfn_set_video_mode(mode);
698 result = 0x4f;
701 cur_info = mode_info_find_mode(BX, using_lfb, &cur_info);
703 if (cur_info != 0)
705 #ifdef DEBUG
706 printf("VBE found mode %x, setting:\n", BX);
707 printf("\txres%x yres%x bpp%x\n",
708 cur_info->info.XResolution,
709 cur_info->info.YResolution,
710 cur_info->info.BitsPerPixel);
711 #endif
713 // first disable current mode (when switching between vesa modi)
714 dispi_set_enable(VBE_DISPI_DISABLED);
716 if (cur_info->mode == VBE_VESA_MODE_800X600X4)
718 biosfn_set_video_mode(0x6a);
721 dispi_set_xres(cur_info->info.XResolution);
722 dispi_set_yres(cur_info->info.YResolution);
723 dispi_set_bpp(cur_info->info.BitsPerPixel);
724 dispi_set_bank(0);
725 dispi_set_enable(VBE_DISPI_ENABLED | no_clear | lfb_flag);
727 write_word(BIOSMEM_SEG,BIOSMEM_VBE_MODE,BX);
728 write_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL,(0x60 | no_clear));
730 result = 0x4f;
732 else
734 #ifdef DEBUG
735 printf("VBE *NOT* found mode %x\n" , BX);
736 #endif
737 result = 0x100;
739 // FIXME: redirect non VBE modi to normal VGA bios operation
740 // (switch back to VGA mode
741 if (BX == 3)
742 result = 0x4f;
745 write_word(ss, AX, result);
748 /** Function 03h - Return Current VBE Mode
750 * Input:
751 * AX = 4F03h
752 * Output:
753 * AX = VBE Return Status
754 * BX = Current VBE Mode
757 ASM_START
758 vbe_biosfn_return_current_mode:
759 push ds
760 mov ax, # BIOSMEM_SEG
761 mov ds, ax
762 call dispi_get_enable
763 and ax, # VBE_DISPI_ENABLED
764 jz no_vbe_mode
765 mov bx, # BIOSMEM_VBE_MODE
766 mov ax, [bx]
767 mov bx, ax
768 jnz vbe_03_ok
769 no_vbe_mode:
770 mov bx, # BIOSMEM_CURRENT_MODE
771 mov al, [bx]
772 mov bl, al
773 xor bh, bh
774 vbe_03_ok:
775 mov ax, #0x004f
776 pop ds
778 ASM_END
781 /** Function 04h - Save/Restore State
783 * Input:
784 * AX = 4F04h
785 * DL = 00h Return Save/Restore State buffer size
786 * 01h Save State
787 * 02h Restore State
788 * CX = Requested states
789 * ES:BX = Pointer to buffer (if DL <> 00h)
790 * Output:
791 * AX = VBE Return Status
792 * BX = Number of 64-byte blocks to hold the state buffer (if DL=00h)
795 void vbe_biosfn_save_restore_state(AX, DL, CX, ES, BX)
800 /** Function 05h - Display Window Control
802 * Input:
803 * AX = 4F05h
804 * (16-bit) BH = 00h Set memory window
805 * = 01h Get memory window
806 * BL = Window number
807 * = 00h Window A
808 * = 01h Window B
809 * DX = Window number in video memory in window
810 * granularity units (Set Memory Window only)
811 * Note:
812 * If this function is called while in a linear frame buffer mode,
813 * this function must fail with completion code AH=03h
815 * Output:
816 * AX = VBE Return Status
817 * DX = Window number in window granularity units
818 * (Get Memory Window only)
820 ASM_START
821 vbe_biosfn_display_window_control:
822 cmp bl, #0x00
823 jne vbe_05_failed
824 cmp bh, #0x01
825 je get_display_window
826 jb set_display_window
827 mov ax, #0x0100
829 set_display_window:
830 mov ax, dx
831 call _dispi_set_bank
832 call dispi_get_bank
833 cmp ax, dx
834 jne vbe_05_failed
835 mov ax, #0x004f
837 get_display_window:
838 call dispi_get_bank
839 mov dx, ax
840 mov ax, #0x004f
842 vbe_05_failed:
843 mov ax, #0x014f
845 ASM_END
848 /** Function 06h - Set/Get Logical Scan Line Length
850 * Input:
851 * AX = 4F06h
852 * BL = 00h Set Scan Line Length in Pixels
853 * = 01h Get Scan Line Length
854 * = 02h Set Scan Line Length in Bytes
855 * = 03h Get Maximum Scan Line Length
856 * CX = If BL=00h Desired Width in Pixels
857 * If BL=02h Desired Width in Bytes
858 * (Ignored for Get Functions)
860 * Output:
861 * AX = VBE Return Status
862 * BX = Bytes Per Scan Line
863 * CX = Actual Pixels Per Scan Line
864 * (truncated to nearest complete pixel)
865 * DX = Maximum Number of Scan Lines
867 ASM_START
868 vbe_biosfn_set_get_logical_scan_line_length:
869 mov ax, cx
870 cmp bl, #0x01
871 je get_logical_scan_line_length
872 cmp bl, #0x02
873 je set_logical_scan_line_bytes
874 jb set_logical_scan_line_pixels
875 mov ax, #0x0100
877 set_logical_scan_line_bytes:
878 push ax
879 call dispi_get_bpp
880 xor bh, bh
881 mov bl, ah
882 xor dx, dx
883 pop ax
884 div bx
885 set_logical_scan_line_pixels:
886 call dispi_set_virt_width
887 get_logical_scan_line_length:
888 call dispi_get_bpp
889 xor bh, bh
890 mov bl, ah
891 call dispi_get_virt_width
892 mov cx, ax
893 mul bx
894 mov bx, ax
895 call dispi_get_virt_height
896 mov dx, ax
897 mov ax, #0x004f
899 ASM_END
902 /** Function 07h - Set/Get Display Start
904 * Input(16-bit):
905 * AX = 4F07h
906 * BH = 00h Reserved and must be 00h
907 * BL = 00h Set Display Start
908 * = 01h Get Display Start
909 * = 02h Schedule Display Start (Alternate)
910 * = 03h Schedule Stereoscopic Display Start
911 * = 04h Get Scheduled Display Start Status
912 * = 05h Enable Stereoscopic Mode
913 * = 06h Disable Stereoscopic Mode
914 * = 80h Set Display Start during Vertical Retrace
915 * = 82h Set Display Start during Vertical Retrace (Alternate)
916 * = 83h Set Stereoscopic Display Start during Vertical Retrace
917 * ECX = If BL=02h/82h Display Start Address in bytes
918 * If BL=03h/83h Left Image Start Address in bytes
919 * EDX = If BL=03h/83h Right Image Start Address in bytes
920 * CX = If BL=00h/80h First Displayed Pixel In Scan Line
921 * DX = If BL=00h/80h First Displayed Scan Line
923 * Output:
924 * AX = VBE Return Status
925 * BH = If BL=01h Reserved and will be 0
926 * CX = If BL=01h First Displayed Pixel In Scan Line
927 * If BL=04h 0 if flip has not occurred, not 0 if it has
928 * DX = If BL=01h First Displayed Scan Line
930 * Input(32-bit):
931 * BH = 00h Reserved and must be 00h
932 * BL = 00h Set Display Start
933 * = 80h Set Display Start during Vertical Retrace
934 * CX = Bits 0-15 of display start address
935 * DX = Bits 16-31 of display start address
936 * ES = Selector for memory mapped registers
938 ASM_START
939 vbe_biosfn_set_get_display_start:
940 cmp bl, #0x80
941 je set_display_start
942 cmp bl, #0x01
943 je get_display_start
944 jb set_display_start
945 mov ax, #0x0100
947 set_display_start:
948 mov ax, cx
949 call dispi_set_x_offset
950 mov ax, dx
951 call dispi_set_y_offset
952 mov ax, #0x004f
954 get_display_start:
955 call dispi_get_x_offset
956 mov cx, ax
957 call dispi_get_y_offset
958 mov dx, ax
959 xor bh, bh
960 mov ax, #0x004f
962 ASM_END
965 /** Function 08h - Set/Get Dac Palette Format
967 * Input:
968 * AX = 4F08h
969 * BL = 00h set DAC palette width
970 * = 01h get DAC palette width
971 * BH = If BL=00h: desired number of bits per primary color
972 * Output:
973 * AX = VBE Return Status
974 * BH = current number of bits per primary color (06h = standard VGA)
976 ASM_START
977 vbe_biosfn_set_get_dac_palette_format:
978 cmp bl, #0x01
979 je get_dac_palette_format
980 jb set_dac_palette_format
981 mov ax, #0x0100
983 set_dac_palette_format:
984 call dispi_get_enable
985 cmp bh, #0x06
986 je set_normal_dac
987 cmp bh, #0x08
988 jne vbe_08_unsupported
989 or ax, # VBE_DISPI_8BIT_DAC
990 jnz set_dac_mode
991 set_normal_dac:
992 and ax, #~ VBE_DISPI_8BIT_DAC
993 set_dac_mode:
994 call _dispi_set_enable
995 get_dac_palette_format:
996 mov bh, #0x06
997 call dispi_get_enable
998 and ax, # VBE_DISPI_8BIT_DAC
999 jz vbe_08_ok
1000 mov bh, #0x08
1001 vbe_08_ok:
1002 mov ax, #0x004f
1004 vbe_08_unsupported:
1005 mov ax, #0x014f
1007 ASM_END
1010 /** Function 09h - Set/Get Palette Data
1012 * Input:
1013 * AX = 4F09h
1014 * Output:
1015 * AX = VBE Return Status
1017 * FIXME: incomplete API description, Input & Output
1019 void vbe_biosfn_set_get_palette_data(AX)
1023 /** Function 0Ah - Return VBE Protected Mode Interface
1025 * Input:
1026 * AX = 4F0Ah
1027 * Output:
1028 * AX = VBE Return Status
1030 * FIXME: incomplete API description, Input & Output
1032 void vbe_biosfn_return_protected_mode_interface(AX)