2 * PROJECT: ReactOS VGA Miniport Driver
3 * LICENSE: Microsoft NT4 DDK Sample Code License
4 * FILE: boot/drivers/video/miniport/vga/vgadata.c
5 * PURPOSE: Handles switching to VGA Modes and holds VGA Built-in Modes
6 * PROGRAMMERS: Copyright (c) 1992 Microsoft Corporation
7 * ReactOS Portable Systems Group
13 // This structure describes to which ports access is required.
16 VIDEO_ACCESS_RANGE VgaAccessRange
[] = {
18 {{VGA_BASE_IO_PORT
, 0x00000000}}, // 64-bit linear base address
20 VGA_START_BREAK_PORT
- VGA_BASE_IO_PORT
+ 1, // # of ports
21 1, // range is in I/O space
22 1, // range should be visible
23 0 // range should be shareable
26 {{VGA_END_BREAK_PORT
, 0x00000000}},
27 VGA_MAX_IO_PORT
- VGA_END_BREAK_PORT
+ 1,
34 // This next region also includes Memory mapped IO. In MMIO, the ports are
35 // repeated every 256 bytes from b8000 to bff00.
39 {{MEM_VGA
, 0x00000000}},
45 // eVb: 4.1 [VGA] - Add ATI/Mach64 VGA registers
51 {{0x1CE, 0x00000000}},
58 {{0x2E8, 0x00000000}},
68 // 640x480 256-color 60Hz mode (BIOS mode 12) set command string for
71 // eVb: 4.2 [VGA] - Add VGA command streams instead of Cirrus
72 USHORT VGA_640x480
[] = {
76 0x100, // start sync reset
77 0x0101,0x0F02,0x0003,0x0604, // program up sequencer
80 MISC_OUTPUT_REG_WRITE_PORT
,
83 OW
, // text/graphics bit
95 OW
, // unprotect crtc 0-7
96 CRTC_ADDRESS_PORT_COLOR
,
99 METAOUT
+INDXOUT
, // program gdc registers
101 VGA_NUM_CRTC_PORTS
,0, // count, startindex
102 0x5F,0x4F,0x50,0x82,0x54,0x80,0x0B,0x3E,0x00,0x40,0x0,0x0,0x0,0x0,0x0,0x0,
103 0xEA,0x8C,0xDF,0x28,0x0,0xE7,0x4,0xE3,0xFF,
105 IB
, // prepare atc for writing
106 INPUT_STATUS_1_COLOR
,
108 METAOUT
+ATCOUT
, // program atc registers
110 VGA_NUM_ATTRIB_CONT_PORTS
,0, // count, startindex
111 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
112 0x17, 0x38, 0x39, 0x3A, 0x3B, 0x3C,
113 0x3D, 0x3E, 0x3F, 0x3F, 0x01, 0x00,
116 METAOUT
+INDXOUT
, // program gdc registers
118 VGA_NUM_GRAPH_CONT_PORTS
,0, // count, startindex
119 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
126 IB
, // prepare atc for writing
127 INPUT_STATUS_1_COLOR
,
129 OB
, // turn video on.
137 // 720x400 color text mode (BIOS mode 3) set command string for
141 USHORT VGA_TEXT_0
[] = {
142 OWM
, // begin setmode
145 0x100, // start sync reset
146 0x0101,0x0302,0x0003,0x0204, // program up sequencer
148 OB
, // misc. register
149 MISC_OUTPUT_REG_WRITE_PORT
,
152 OW
, // text/graphics bit
156 OW
, // end sync reset
162 END_SYNC_RESET_VALUE
,
164 OW
, // unprotect crtc 0-7
165 CRTC_ADDRESS_PORT_COLOR
,
168 METAOUT
+INDXOUT
, // program gdc registers
170 VGA_NUM_CRTC_PORTS
,0, // count, startindex
171 0x5F,0x4F,0x50,0x82,0x55,0x81,0xBF,0x1F,0x00,0x4F,0xD,0xE,0x0,0x0,0x0,0x0,
172 0x9c,0x8E,0x8F,0x28,0x1F,0x96,0xB9,0xA3,0xFF,
174 IB
, // prepare atc for writing
175 INPUT_STATUS_1_COLOR
,
177 METAOUT
+ATCOUT
, // program atc registers
179 VGA_NUM_ATTRIB_CONT_PORTS
,0, // count, startindex
180 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
181 0x17, 0x38, 0x39, 0x3A, 0x3B, 0x3C,
182 0x3D, 0x3E, 0x3F, 0x3F, 0x04, 0x00,
185 METAOUT
+INDXOUT
, // program gdc registers
187 VGA_NUM_GRAPH_CONT_PORTS
,0, // count, startindex
188 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
195 IB
, // prepare atc for writing
196 INPUT_STATUS_1_COLOR
,
198 OB
, // turn video on.
206 // 640x400 color text mode (BIOS mode 3) set command string for
210 USHORT VGA_TEXT_1
[] = {
211 OWM
, // begin setmode
214 0x100, // start sync reset
215 0x0101,0x0302,0x0003,0x0204, // program up sequencer
217 OB
, // misc. register
218 MISC_OUTPUT_REG_WRITE_PORT
,
221 OW
, // text/graphics bit
225 OW
, // end sync reset
231 END_SYNC_RESET_VALUE
,
233 OW
, // unprotect crtc 0-7
234 CRTC_ADDRESS_PORT_COLOR
,
237 METAOUT
+INDXOUT
, // program gdc registers
239 VGA_NUM_CRTC_PORTS
,0, // count, startindex
240 0x5F,0x4F,0x50,0x82,0x55,0x81,0xBF,0x1F,0x00,0x4D,0xB,0xC,0x0,0x0,0x0,0x0,
241 0x83,0x85,0x5D,0x28,0x1F,0x63,0xBA,0xA3,0xFF,
243 IB
, // prepare atc for writing
244 INPUT_STATUS_1_COLOR
,
246 METAOUT
+ATCOUT
, // program atc registers
248 VGA_NUM_ATTRIB_CONT_PORTS
,0, // count, startindex
249 0x00, 0x01, 0x02, 0x03, 0x04, 0x05,
250 0x17, 0x38, 0x39, 0x3A, 0x3B, 0x3C,
251 0x3D, 0x3E, 0x3F, 0x3F, 0x04, 0x00,
254 METAOUT
+INDXOUT
, // program gdc registers
256 VGA_NUM_GRAPH_CONT_PORTS
,0, // count, startindex
257 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
264 IB
, // prepare atc for writing
265 INPUT_STATUS_1_COLOR
,
267 OB
, // turn video on.
275 // Video mode table - contains information and commands for initializing each
276 // mode. These entries must correspond with those in VIDEO_MODE_VGA. The first
277 // entry is commented; the rest follow the same format, but are not so
278 // heavily commented.
280 // eVb: 4.3 [VGA] - Add VGA, ModeX and SVGA mode instead of Cirrus Modes
281 VIDEOMODE ModesVGA
[] =
283 // Color text mode 3, 720x400, 9x16 char cell (VGA).
286 VIDEO_MODE_BANKED
| VIDEO_MODE_COLOR
, // flags that this mode is a color mode, but not graphics
288 1, // one bit of colour per plane
289 80, 25, // 80x25 text resolution
290 720, 400, // 720x400 pixels on screen
291 1, // only support one frequency, non-interlaced
292 160, 0x10000, // 160 bytes per scan line, 64K of CPU-addressable bitmap
294 0x3, VGA_TEXT_0
, // Mode 3, I/O initialization stream
295 0xA0000, // Physical address at 0xA0000
297 0x20000, // 2 banks of 64K, 128KB total memory
298 720, // 720 pixels per scan line
304 // Color text mode 3, 640x350, 8x14 char cell (EGA).
307 VIDEO_MODE_BANKED
| VIDEO_MODE_COLOR
,
325 // Standard VGA Color graphics mode 0x12, 640x480 16 colors.
328 VIDEO_MODE_BANKED
| VIDEO_MODE_COLOR
| VIDEO_MODE_GRAPHICS
,
345 VIDEO_MODE_BANKED
| VIDEO_MODE_COLOR
| VIDEO_MODE_GRAPHICS
,
362 VIDEO_MODE_BANKED
| VIDEO_MODE_COLOR
| VIDEO_MODE_GRAPHICS
,
379 VIDEO_MODE_BANKED
| VIDEO_MODE_COLOR
| VIDEO_MODE_GRAPHICS
,
396 VIDEO_MODE_BANKED
| VIDEO_MODE_COLOR
| VIDEO_MODE_GRAPHICS
,
413 // 800x600 16 colors.
416 VIDEO_MODE_BANKED
| VIDEO_MODE_COLOR
| VIDEO_MODE_GRAPHICS
,
423 (0x102 << 16) | VBE_SET_VBE_MODE
, NULL
,
433 ULONG NumVideoModes
= sizeof(ModesVGA
) / sizeof(VIDEOMODE
);
434 PVIDEOMODE VgaModeList
;
439 // Data used to set the Graphics and Sequence Controllers to put the
440 // VGA into a planar state at A0000 for 64K, with plane 2 enabled for
441 // reads and writes, so that a font can be loaded, and to disable that mode.
444 // Settings to enable planar mode with plane 2 enabled.
447 USHORT EnableA000Data
[] = {
456 0x0204, // Read Map = plane 2
457 0x0005, // Graphics Mode = read mode 0, write mode 0
458 0x0406, // Graphics Miscellaneous register = A0000 for 64K, not odd/even,
463 0x0402, // Map Mask = write to plane 2 only
464 0x0404, // Memory Mode = not odd/even, not full memory, graphics mode
465 0x0300, // end sync reset
470 // Settings to disable the font-loading planar mode.
473 USHORT DisableA000Color
[] = {
482 0x0004, 0x1005, 0x0E06,
487 0x0302, 0x0204, 0x0300, // end sync reset