3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
4 * Portions from Linux video.S - Display adapter & video mode setup, version 2.13 (14-May-99)
5 * Copyright (C) 1995 -- 1999 Martin Mares <mj@ucw.cz>
6 * Based on the original setup.S code (C) Linus Torvalds and Mats Anderson
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 UCHAR Signature
[4]; // (ret) signature ("VESA")
31 // (call) VESA 2.0 request signature ("VBE2"), required to receive
33 USHORT VesaVersion
; // VESA version number (one-digit minor version -- 0102h = v1.2)
34 ULONG OemNamePtr
; // pointer to OEM name
35 // "761295520" for ATI
36 ULONG Capabilities
; // capabilities flags (see #00078)
37 ULONG SupportedModeListPtr
; // pointer to list of supported VESA and OEM video modes
38 // (list of words terminated with FFFFh)
39 USHORT TotalVideoMemory
; // total amount of video memory in 64K blocks
42 //UCHAR Reserved[236];
45 USHORT OemSoftwareVersion
; // OEM software version (BCD, high byte = major, low byte = minor)
46 ULONG VendorNamePtr
; // pointer to vendor name
47 ULONG ProductNamePtr
; // pointer to product name
48 ULONG ProductRevisionStringPtr
; // pointer to product revision string
49 USHORT VBE_AF_Version
; // (if capabilities bit 3 set) VBE/AF version (BCD)
51 ULONG AcceleratedModeListPtr
; // (if capabilities bit 3 set) pointer to list of supported
52 // accelerated video modes (list of words terminated with FFFFh)
53 UCHAR Reserved
[216]; // reserved for VBE implementation
54 UCHAR ScratchPad
[256]; // OEM scratchpad (for OEM strings, etc.)
55 } PACKED VESA_SVGA_INFO
, *PVESA_SVGA_INFO
;
57 // Bitfields for VESA capabilities:
59 // Bit(s) Description (Table 00078)
60 // 0 DAC can be switched into 8-bit mode
61 // 1 non-VGA controller
62 // 2 programmed DAC with blank bit (i.e. only during blanking interval)
63 // 3 (VBE v3.0) controller supports hardware stereoscopic signalling
64 // 3 controller supports VBE/AF v1.0P extensions
65 // 4 (VBE v3.0) if bit 3 set:
66 // =0 stereo signalling via external VESA stereo connector
67 // =1 stereo signalling via VESA EVC connector
68 // 4 (VBE/AF v1.0P) must call EnableDirectAccess to access framebuffer
69 // 5 (VBE/AF v1.0P) controller supports hardware mouse cursor
70 // 6 (VBE/AF v1.0P) controller supports hardware clipping
71 // 7 (VBE/AF v1.0P) controller supports transparent BitBLT
74 // Notes: The list of supported video modes is stored in the reserved
75 // portion of the SuperVGA information record by some implementations,
76 // and it may thus be necessary to either copy the mode list or use a
77 // different buffer for all subsequent VESA calls. Not all of the video
78 // modes in the list of mode numbers may be supported, e.g. if they require
79 // more memory than currently installed or are not supported by the
80 // attached monitor. Check any mode you intend to use through AX=4F01h first..
81 // The 1.1 VESA document specifies 242 reserved bytes at the end, so the
82 // buffer should be 262 bytes to ensure that it is not overrun; for v2.0,
83 // the buffer should be 512 bytes. The S3 specific video modes will most
84 // likely follow the FFFFh terminator at the end of the standard modes.
85 // A search must then be made to find them, FFFFh will also terminate this
86 // second list. In some cases, only a "stub" VBE may be present, supporting
87 // only AX=4F00h; this case may be assumed if the list of supported video modes
88 // is empty (consisting of a single word of FFFFh)
90 static VOID
BiosSetVideoFont8x16(VOID
)
95 // VIDEO - TEXT-MODE CHARGEN - LOAD ROM 8x16 CHARACTER SET (VGA)
103 Int386(0x10, &Regs
, &Regs
);
106 static VOID
VideoSetTextCursorPosition(ULONG X
, ULONG Y
)
110 static ULONG
VideoGetTextCursorPositionX(VOID
)
115 // VIDEO - GET CURSOR POSITION AND SIZE
121 // 0 in graphics modes
123 // AX = 0000h (Phoenix BIOS)
124 // CH = start scan line
125 // CL = end scan line
126 // DH = row (00h is top)
127 // DL = column (00h is left)
130 Int386(0x10, &Regs
, &Regs
);
135 static ULONG
VideoGetTextCursorPositionY(VOID
)
140 // VIDEO - GET CURSOR POSITION AND SIZE
146 // 0 in graphics modes
148 // AX = 0000h (Phoenix BIOS)
149 // CH = start scan line
150 // CL = end scan line
151 // DH = row (00h is top)
152 // DL = column (00h is left)
155 Int386(0x10, &Regs
, &Regs
);
161 USHORT
BiosIsVesaSupported(VOID
)
164 PVESA_SVGA_INFO SvgaInfo
= (PVESA_SVGA_INFO
)BIOSCALLBUFFER
;
165 //USHORT* VideoModes;
168 DbgPrint((DPRINT_UI
, "BiosIsVesaSupported()\n"));
170 RtlZeroMemory(SvgaInfo
, sizeof(VESA_SVGA_INFO
));
172 // Make sure we receive version 2.0 info
173 SvgaInfo
->Signature
[0] = 'V';
174 SvgaInfo
->Signature
[1] = 'B';
175 SvgaInfo
->Signature
[2] = 'E';
176 SvgaInfo
->Signature
[3] = '2';
179 // VESA SuperVGA BIOS (VBE) - GET SuperVGA INFORMATION
182 // ES:DI -> buffer for SuperVGA information (see #00077)
184 // AL = 4Fh if function supported
187 // ES:DI buffer filled
190 // 02h function not supported by current hardware configuration
191 // 03h function invalid in current video mode
193 // Determine whether VESA BIOS extensions are present and the
194 // capabilities supported by the display adapter
196 // Installation check;VESA SuperVGA
198 Regs
.w
.es
= BIOSCALLBUFSEGMENT
;
199 Regs
.w
.di
= BIOSCALLBUFOFFSET
;
200 Int386(0x10, &Regs
, &Regs
);
202 DbgPrint((DPRINT_UI
, "AL = 0x%x\n", Regs
.b
.al
));
203 DbgPrint((DPRINT_UI
, "AH = 0x%x\n", Regs
.b
.ah
));
205 if (Regs
.w
.ax
!= 0x004F)
207 DbgPrint((DPRINT_UI
, "Failed.\n"));
211 DbgPrint((DPRINT_UI
, "Supported.\n"));
212 DbgPrint((DPRINT_UI
, "SvgaInfo->Signature[4] = %c%c%c%c\n", SvgaInfo
->Signature
[0], SvgaInfo
->Signature
[1], SvgaInfo
->Signature
[2], SvgaInfo
->Signature
[3]));
213 DbgPrint((DPRINT_UI
, "SvgaInfo->VesaVersion = v%d.%d\n", ((SvgaInfo
->VesaVersion
>> 8) & 0xFF), (SvgaInfo
->VesaVersion
& 0xFF)));
214 DbgPrint((DPRINT_UI
, "SvgaInfo->OemNamePtr = 0x%x\n", SvgaInfo
->OemNamePtr
));
215 DbgPrint((DPRINT_UI
, "SvgaInfo->Capabilities = 0x%x\n", SvgaInfo
->Capabilities
));
216 DbgPrint((DPRINT_UI
, "SvgaInfo->VideoMemory = %dK\n", SvgaInfo
->TotalVideoMemory
* 64));
217 DbgPrint((DPRINT_UI
, "---VBE v2.0 ---\n"));
218 DbgPrint((DPRINT_UI
, "SvgaInfo->OemSoftwareVersion = v%d.%d\n", ((SvgaInfo
->OemSoftwareVersion
>> 8) & 0x0F) + (((SvgaInfo
->OemSoftwareVersion
>> 12) & 0x0F) * 10), (SvgaInfo
->OemSoftwareVersion
& 0x0F) + (((SvgaInfo
->OemSoftwareVersion
>> 4) & 0x0F) * 10)));
219 DbgPrint((DPRINT_UI
, "SvgaInfo->VendorNamePtr = 0x%x\n", SvgaInfo
->VendorNamePtr
));
220 DbgPrint((DPRINT_UI
, "SvgaInfo->ProductNamePtr = 0x%x\n", SvgaInfo
->ProductNamePtr
));
221 DbgPrint((DPRINT_UI
, "SvgaInfo->ProductRevisionStringPtr = 0x%x\n", SvgaInfo
->ProductRevisionStringPtr
));
222 DbgPrint((DPRINT_UI
, "SvgaInfo->VBE/AF Version = 0x%x (BCD WORD)\n", SvgaInfo
->VBE_AF_Version
));
224 //DbgPrint((DPRINT_UI, "\nSupported VESA and OEM video modes:\n"));
225 //VideoModes = (USHORT*)SvgaInfo->SupportedModeListPtr;
226 //for (Index=0; VideoModes[Index]!=0xFFFF; Index++)
228 // DbgPrint((DPRINT_UI, "Mode %d: 0x%x\n", Index, VideoModes[Index]));
231 //if (SvgaInfo->VesaVersion >= 0x0200)
233 // DbgPrint((DPRINT_UI, "\nSupported accelerated video modes (VESA v2.0):\n"));
234 // VideoModes = (USHORT*)SvgaInfo->AcceleratedModeListPtr;
235 // for (Index=0; VideoModes[Index]!=0xFFFF; Index++)
237 // DbgPrint((DPRINT_UI, "Mode %d: 0x%x\n", Index, VideoModes[Index]));
241 DbgPrint((DPRINT_UI
, "\n"));
243 return SvgaInfo
->VesaVersion
;