xref: /reactos/drivers/base/bootvid/i386/pc/vga.h (revision df23bb77)
1*df23bb77SDmitry Borisov /*
2*df23bb77SDmitry Borisov  * PROJECT:         ReactOS VGA Miniport Driver
3*df23bb77SDmitry Borisov  * LICENSE:         Microsoft NT4 DDK Sample Code License
4*df23bb77SDmitry Borisov  * PURPOSE:         Definitions for VGA
5*df23bb77SDmitry Borisov  * PROGRAMMERS:     Copyright (c) 1992  Microsoft Corporation
6*df23bb77SDmitry Borisov  *                  ReactOS Portable Systems Group
7*df23bb77SDmitry Borisov  */
8*df23bb77SDmitry Borisov 
9*df23bb77SDmitry Borisov #ifndef _BOOTVID_VGA_H_
10*df23bb77SDmitry Borisov #define _BOOTVID_VGA_H_
11*df23bb77SDmitry Borisov 
12*df23bb77SDmitry Borisov #pragma once
13*df23bb77SDmitry Borisov 
14*df23bb77SDmitry Borisov #include "cmdcnst.h"
15*df23bb77SDmitry Borisov 
16*df23bb77SDmitry Borisov //
17*df23bb77SDmitry Borisov // Base address of VGA memory range.  Also used as base address of VGA
18*df23bb77SDmitry Borisov // memory when loading a font, which is done with the VGA mapped at A0000.
19*df23bb77SDmitry Borisov //
20*df23bb77SDmitry Borisov 
21*df23bb77SDmitry Borisov #define MEM_VGA      0xA0000
22*df23bb77SDmitry Borisov #define MEM_VGA_SIZE 0x20000
23*df23bb77SDmitry Borisov 
24*df23bb77SDmitry Borisov //
25*df23bb77SDmitry Borisov // For memory mapped IO
26*df23bb77SDmitry Borisov //
27*df23bb77SDmitry Borisov 
28*df23bb77SDmitry Borisov #define MEMORY_MAPPED_IO_OFFSET (0xB8000 - 0xA0000)
29*df23bb77SDmitry Borisov 
30*df23bb77SDmitry Borisov //
31*df23bb77SDmitry Borisov // Port definitions for filling the ACCESS_RANGES structure in the miniport
32*df23bb77SDmitry Borisov // information, defines the range of I/O ports the VGA spans.
33*df23bb77SDmitry Borisov // There is a break in the IO ports - a few ports are used for the parallel
34*df23bb77SDmitry Borisov // port. Those cannot be defined in the ACCESS_RANGE, but are still mapped
35*df23bb77SDmitry Borisov // so all VGA ports are in one address range.
36*df23bb77SDmitry Borisov //
37*df23bb77SDmitry Borisov 
38*df23bb77SDmitry Borisov #define VGA_BASE_IO_PORT      0x000003B0
39*df23bb77SDmitry Borisov #define VGA_START_BREAK_PORT  0x000003BB
40*df23bb77SDmitry Borisov #define VGA_END_BREAK_PORT    0x000003C0
41*df23bb77SDmitry Borisov #define VGA_MAX_IO_PORT       0x000003DF
42*df23bb77SDmitry Borisov 
43*df23bb77SDmitry Borisov //
44*df23bb77SDmitry Borisov // VGA register definitions
45*df23bb77SDmitry Borisov //
46*df23bb77SDmitry Borisov // eVb: 3.1 [VGA] - Use offsets from the VGA Port Address instead of absolute
47*df23bb77SDmitry Borisov #define CRTC_ADDRESS_PORT_MONO      0x0004  // CRT Controller Address and
48*df23bb77SDmitry Borisov #define CRTC_DATA_PORT_MONO         0x0005  // Data registers in mono mode
49*df23bb77SDmitry Borisov #define FEAT_CTRL_WRITE_PORT_MONO   0x000A  // Feature Control write port
50*df23bb77SDmitry Borisov                                             // in mono mode
51*df23bb77SDmitry Borisov #define INPUT_STATUS_1_MONO         0x000A  // Input Status 1 register read
52*df23bb77SDmitry Borisov                                             // port in mono mode
53*df23bb77SDmitry Borisov #define ATT_INITIALIZE_PORT_MONO    INPUT_STATUS_1_MONO
54*df23bb77SDmitry Borisov                                             // Register to read to reset
55*df23bb77SDmitry Borisov                                             // Attribute Controller index/data
56*df23bb77SDmitry Borisov 
57*df23bb77SDmitry Borisov #define ATT_ADDRESS_PORT            0x0010  // Attribute Controller Address and
58*df23bb77SDmitry Borisov #define ATT_DATA_WRITE_PORT         0x0010  // Data registers share one port
59*df23bb77SDmitry Borisov                                             // for writes, but only Address is
60*df23bb77SDmitry Borisov                                             // readable at 0x3C0
61*df23bb77SDmitry Borisov #define ATT_DATA_READ_PORT          0x0011  // Attribute Controller Data reg is
62*df23bb77SDmitry Borisov                                             // readable here
63*df23bb77SDmitry Borisov #define MISC_OUTPUT_REG_WRITE_PORT  0x0012  // Miscellaneous Output reg write
64*df23bb77SDmitry Borisov                                             // port
65*df23bb77SDmitry Borisov #define INPUT_STATUS_0_PORT         0x0012  // Input Status 0 register read
66*df23bb77SDmitry Borisov                                             // port
67*df23bb77SDmitry Borisov #define VIDEO_SUBSYSTEM_ENABLE_PORT 0x0013  // Bit 0 enables/disables the
68*df23bb77SDmitry Borisov                                             // entire VGA subsystem
69*df23bb77SDmitry Borisov #define SEQ_ADDRESS_PORT            0x0014  // Sequence Controller Address and
70*df23bb77SDmitry Borisov #define SEQ_DATA_PORT               0x0015  // Data registers
71*df23bb77SDmitry Borisov #define DAC_PIXEL_MASK_PORT         0x0016  // DAC pixel mask reg
72*df23bb77SDmitry Borisov #define DAC_ADDRESS_READ_PORT       0x0017  // DAC register read index reg,
73*df23bb77SDmitry Borisov                                             // write-only
74*df23bb77SDmitry Borisov #define DAC_STATE_PORT              0x0017  // DAC state (read/write),
75*df23bb77SDmitry Borisov                                             // read-only
76*df23bb77SDmitry Borisov #define DAC_ADDRESS_WRITE_PORT      0x0018  // DAC register write index reg
77*df23bb77SDmitry Borisov #define DAC_DATA_REG_PORT           0x0019  // DAC data transfer reg
78*df23bb77SDmitry Borisov #define FEAT_CTRL_READ_PORT         0x001A  // Feature Control read port
79*df23bb77SDmitry Borisov #define MISC_OUTPUT_REG_READ_PORT   0x001C  // Miscellaneous Output reg read
80*df23bb77SDmitry Borisov                                             // port
81*df23bb77SDmitry Borisov #define GRAPH_ADDRESS_PORT          0x001E  // Graphics Controller Address
82*df23bb77SDmitry Borisov #define GRAPH_DATA_PORT             0x001F  // and Data registers
83*df23bb77SDmitry Borisov 
84*df23bb77SDmitry Borisov #define CRTC_ADDRESS_PORT_COLOR     0x0024  // CRT Controller Address and
85*df23bb77SDmitry Borisov #define CRTC_DATA_PORT_COLOR        0x0025  // Data registers in color mode
86*df23bb77SDmitry Borisov #define FEAT_CTRL_WRITE_PORT_COLOR  0x002A  // Feature Control write port
87*df23bb77SDmitry Borisov #define INPUT_STATUS_1_COLOR        0x002A  // Input Status 1 register read
88*df23bb77SDmitry Borisov                                             // port in color mode
89*df23bb77SDmitry Borisov // eVb: 3.2 [END]
90*df23bb77SDmitry Borisov #define ATT_INITIALIZE_PORT_COLOR   INPUT_STATUS_1_COLOR
91*df23bb77SDmitry Borisov                                             // Register to read to reset
92*df23bb77SDmitry Borisov                                             // Attribute Controller index/data
93*df23bb77SDmitry Borisov                                             // toggle in color mode
94*df23bb77SDmitry Borisov 
95*df23bb77SDmitry Borisov //
96*df23bb77SDmitry Borisov // VGA indexed register indexes.
97*df23bb77SDmitry Borisov //
98*df23bb77SDmitry Borisov 
99*df23bb77SDmitry Borisov #define IND_CURSOR_START        0x0A    // index in CRTC of the Cursor Start
100*df23bb77SDmitry Borisov #define IND_CURSOR_END          0x0B    //  and End registers
101*df23bb77SDmitry Borisov #define IND_CURSOR_HIGH_LOC     0x0E    // index in CRTC of the Cursor Location
102*df23bb77SDmitry Borisov #define IND_CURSOR_LOW_LOC      0x0F    //  High and Low Registers
103*df23bb77SDmitry Borisov #define IND_VSYNC_END           0x11    // index in CRTC of the Vertical Sync
104*df23bb77SDmitry Borisov                                         //  End register, which has the bit
105*df23bb77SDmitry Borisov                                         //  that protects/unprotects CRTC
106*df23bb77SDmitry Borisov                                         //  index registers 0-7
107*df23bb77SDmitry Borisov #define IND_CR2C                0x2C    // Nordic LCD Interface Register
108*df23bb77SDmitry Borisov #define IND_CR2D                0x2D    // Nordic LCD Display Control
109*df23bb77SDmitry Borisov #define IND_SET_RESET_ENABLE    0x01    // index of Set/Reset Enable reg in GC
110*df23bb77SDmitry Borisov #define IND_DATA_ROTATE         0x03    // index of Data Rotate reg in GC
111*df23bb77SDmitry Borisov #define IND_READ_MAP            0x04    // index of Read Map reg in Graph Ctlr
112*df23bb77SDmitry Borisov #define IND_GRAPH_MODE          0x05    // index of Mode reg in Graph Ctlr
113*df23bb77SDmitry Borisov #define IND_GRAPH_MISC          0x06    // index of Misc reg in Graph Ctlr
114*df23bb77SDmitry Borisov #define IND_BIT_MASK            0x08    // index of Bit Mask reg in Graph Ctlr
115*df23bb77SDmitry Borisov #define IND_SYNC_RESET          0x00    // index of Sync Reset reg in Seq
116*df23bb77SDmitry Borisov #define IND_MAP_MASK            0x02    // index of Map Mask in Sequencer
117*df23bb77SDmitry Borisov #define IND_MEMORY_MODE         0x04    // index of Memory Mode reg in Seq
118*df23bb77SDmitry Borisov #define IND_CRTC_PROTECT        0x11    // index of reg containing regs 0-7 in
119*df23bb77SDmitry Borisov                                         //  CRTC
120*df23bb77SDmitry Borisov #define IND_CRTC_COMPAT         0x34    // index of CRTC Compatibility reg
121*df23bb77SDmitry Borisov                                         //  in CRTC
122*df23bb77SDmitry Borisov #define IND_PERF_TUNING         0x16    // index of performance tuning in Seq
123*df23bb77SDmitry Borisov #define START_SYNC_RESET_VALUE  0x01    // value for Sync Reset reg to start
124*df23bb77SDmitry Borisov                                         //  synchronous reset
125*df23bb77SDmitry Borisov #define END_SYNC_RESET_VALUE    0x03    // value for Sync Reset reg to end
126*df23bb77SDmitry Borisov                                         //  synchronous reset
127*df23bb77SDmitry Borisov 
128*df23bb77SDmitry Borisov //
129*df23bb77SDmitry Borisov // Values for Attribute Controller Index register to turn video off
130*df23bb77SDmitry Borisov // and on, by setting bit 5 to 0 (off) or 1 (on).
131*df23bb77SDmitry Borisov //
132*df23bb77SDmitry Borisov 
133*df23bb77SDmitry Borisov #define VIDEO_DISABLE 0
134*df23bb77SDmitry Borisov #define VIDEO_ENABLE  0x20
135*df23bb77SDmitry Borisov 
136*df23bb77SDmitry Borisov #define INDEX_ENABLE_AUTO_START 0x31
137*df23bb77SDmitry Borisov 
138*df23bb77SDmitry Borisov // Masks to keep only the significant bits of the Graphics Controller and
139*df23bb77SDmitry Borisov // Sequencer Address registers. Masking is necessary because some VGAs, such
140*df23bb77SDmitry Borisov // as S3-based ones, don't return unused bits set to 0, and some SVGAs use
141*df23bb77SDmitry Borisov // these bits if extensions are enabled.
142*df23bb77SDmitry Borisov //
143*df23bb77SDmitry Borisov 
144*df23bb77SDmitry Borisov #define GRAPH_ADDR_MASK 0x0F
145*df23bb77SDmitry Borisov #define SEQ_ADDR_MASK   0x07
146*df23bb77SDmitry Borisov 
147*df23bb77SDmitry Borisov //
148*df23bb77SDmitry Borisov // Mask used to toggle Chain4 bit in the Sequencer's Memory Mode register.
149*df23bb77SDmitry Borisov //
150*df23bb77SDmitry Borisov 
151*df23bb77SDmitry Borisov #define CHAIN4_MASK 0x08
152*df23bb77SDmitry Borisov 
153*df23bb77SDmitry Borisov //
154*df23bb77SDmitry Borisov // Value written to the Read Map register when identifying the existence of
155*df23bb77SDmitry Borisov // a VGA in VgaInitialize. This value must be different from the final test
156*df23bb77SDmitry Borisov // value written to the Bit Mask in that routine.
157*df23bb77SDmitry Borisov //
158*df23bb77SDmitry Borisov 
159*df23bb77SDmitry Borisov #define READ_MAP_TEST_SETTING 0x03
160*df23bb77SDmitry Borisov 
161*df23bb77SDmitry Borisov //
162*df23bb77SDmitry Borisov // Default text mode setting for various registers, used to restore their
163*df23bb77SDmitry Borisov // states if VGA detection fails after they've been modified.
164*df23bb77SDmitry Borisov //
165*df23bb77SDmitry Borisov 
166*df23bb77SDmitry Borisov #define MEMORY_MODE_TEXT_DEFAULT 0x02
167*df23bb77SDmitry Borisov #define BIT_MASK_DEFAULT 0xFF
168*df23bb77SDmitry Borisov #define READ_MAP_DEFAULT 0x00
169*df23bb77SDmitry Borisov 
170*df23bb77SDmitry Borisov 
171*df23bb77SDmitry Borisov //
172*df23bb77SDmitry Borisov // Palette-related info.
173*df23bb77SDmitry Borisov //
174*df23bb77SDmitry Borisov 
175*df23bb77SDmitry Borisov //
176*df23bb77SDmitry Borisov // Highest valid DAC color register index.
177*df23bb77SDmitry Borisov //
178*df23bb77SDmitry Borisov 
179*df23bb77SDmitry Borisov #define VIDEO_MAX_COLOR_REGISTER  0xFF
180*df23bb77SDmitry Borisov 
181*df23bb77SDmitry Borisov //
182*df23bb77SDmitry Borisov // Highest valid palette register index
183*df23bb77SDmitry Borisov //
184*df23bb77SDmitry Borisov 
185*df23bb77SDmitry Borisov #define VIDEO_MAX_PALETTE_REGISTER 0x0F
186*df23bb77SDmitry Borisov 
187*df23bb77SDmitry Borisov //
188*df23bb77SDmitry Borisov // Mode into which to put the VGA before starting a VDM, so it's a plain
189*df23bb77SDmitry Borisov // vanilla VGA.  (This is the mode's index in ModesVGA[], currently standard
190*df23bb77SDmitry Borisov // 80x25 text mode.)
191*df23bb77SDmitry Borisov //
192*df23bb77SDmitry Borisov 
193*df23bb77SDmitry Borisov #define DEFAULT_MODE 0
194*df23bb77SDmitry Borisov 
195*df23bb77SDmitry Borisov //
196*df23bb77SDmitry Borisov // Number of bytes to save in each plane.
197*df23bb77SDmitry Borisov //
198*df23bb77SDmitry Borisov 
199*df23bb77SDmitry Borisov #define VGA_PLANE_SIZE 0x10000
200*df23bb77SDmitry Borisov 
201*df23bb77SDmitry Borisov //
202*df23bb77SDmitry Borisov // Number of each type of indexed register in a standard VGA, used by
203*df23bb77SDmitry Borisov // validator and state save/restore functions.
204*df23bb77SDmitry Borisov //
205*df23bb77SDmitry Borisov // Note: VDMs currently only support basic VGAs only.
206*df23bb77SDmitry Borisov //
207*df23bb77SDmitry Borisov 
208*df23bb77SDmitry Borisov #define VGA_NUM_SEQUENCER_PORTS     5
209*df23bb77SDmitry Borisov #define VGA_NUM_CRTC_PORTS         25
210*df23bb77SDmitry Borisov #define VGA_NUM_GRAPH_CONT_PORTS    9
211*df23bb77SDmitry Borisov #define VGA_NUM_ATTRIB_CONT_PORTS  21
212*df23bb77SDmitry Borisov #define VGA_NUM_DAC_ENTRIES       256
213*df23bb77SDmitry Borisov 
214*df23bb77SDmitry Borisov #define EXT_NUM_GRAPH_CONT_PORTS    0
215*df23bb77SDmitry Borisov #define EXT_NUM_SEQUENCER_PORTS     0
216*df23bb77SDmitry Borisov #define EXT_NUM_CRTC_PORTS          0
217*df23bb77SDmitry Borisov #define EXT_NUM_ATTRIB_CONT_PORTS   0
218*df23bb77SDmitry Borisov #define EXT_NUM_DAC_ENTRIES         0
219*df23bb77SDmitry Borisov 
220*df23bb77SDmitry Borisov #endif /* _BOOTVID_VGA_H_ */
221