ReactOS  0.4.13-dev-479-gec9c8fd
svga.h
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: GPL - See COPYING in the top level directory
3  * PROJECT: ReactOS Virtual DOS Machine
4  * FILE: subsystems/mvdm/ntvdm/hardware/video/svga.h
5  * PURPOSE: SuperVGA hardware emulation (Cirrus Logic CL-GD5434 compatible)
6  * PROGRAMMERS: Aleksandar Andrejevic <theflash AT sdf DOT lonestar DOT org>
7  */
8 
9 #ifndef _SVGA_H_
10 #define _SVGA_H_
11 
12 /* DEFINES ********************************************************************/
13 
14 #define VGA_NUM_BANKS 4
15 #define VGA_BANK_SIZE 0x10000
16 #define VGA_MAX_COLORS 256
17 #define VGA_PALETTE_SIZE (VGA_MAX_COLORS * 3)
18 #define VGA_BITMAP_INFO_SIZE (sizeof(BITMAPINFOHEADER) + 2 * (VGA_PALETTE_SIZE / 3))
19 #define VGA_MINIMUM_WIDTH 400
20 #define VGA_MINIMUM_HEIGHT 300
21 #define VGA_DAC_TO_COLOR(x) (((x) << 2) | ((x) >> 4))
22 #define VGA_COLOR_TO_DAC(x) ((x) >> 2)
23 #define VGA_INTERLACE_HIGH_BIT (1 << 13)
24 #define VGA_FONT_BANK 2
25 #define VGA_FONT_CHARACTERS 256
26 #define VGA_MAX_FONT_HEIGHT 32
27 #define VGA_FONT_SIZE (VGA_FONT_CHARACTERS * VGA_MAX_FONT_HEIGHT)
28 #define VGA_CLOCK_BASE 14318181
29 
30 #define SVGA_IS_UNLOCKED (VgaSeqRegisters[SVGA_SEQ_UNLOCK_REG] == SVGA_SEQ_UNLOCKED)
31 #define SVGA_BANK_SIZE 0x100000
32 
33 #define SVGA_SEQ_MAX_UNLOCKED_REG (SVGA_IS_UNLOCKED ? SVGA_SEQ_MAX_REG : SVGA_SEQ_EXT_MODE_REG)
34 #define SVGA_CRTC_MAX_UNLOCKED_REG (SVGA_IS_UNLOCKED ? SVGA_CRTC_MAX_REG : VGA_CRTC_MAX_REG)
35 #define SVGA_GC_MAX_UNLOCKED_REG (SVGA_IS_UNLOCKED ? SVGA_GC_MAX_REG : VGA_GC_MAX_REG)
36 
37 /* Register I/O ports */
38 
39 #define VGA_MISC_READ 0x3CC
40 #define VGA_MISC_WRITE 0x3C2
41 
42 #define VGA_INSTAT0_READ 0x3C2
43 
44 #define VGA_INSTAT1_READ_MONO 0x3BA
45 #define VGA_INSTAT1_READ_COLOR 0x3DA
46 
47 #define VGA_FEATURE_READ 0x3CA
48 #define VGA_FEATURE_WRITE_MONO 0x3BA
49 #define VGA_FEATURE_WRITE_COLOR 0x3DA
50 
51 #define VGA_AC_INDEX 0x3C0
52 #define VGA_AC_WRITE 0x3C0
53 #define VGA_AC_READ 0x3C1
54 
55 #define VGA_SEQ_INDEX 0x3C4
56 #define VGA_SEQ_DATA 0x3C5
57 
58 #define VGA_DAC_MASK 0x3C6
59 #define VGA_DAC_READ_INDEX 0x3C7
60 #define VGA_DAC_WRITE_INDEX 0x3C8
61 #define VGA_DAC_DATA 0x3C9
62 
63 #define VGA_CRTC_INDEX_MONO 0x3B4
64 #define VGA_CRTC_DATA_MONO 0x3B5
65 #define VGA_CRTC_INDEX_COLOR 0x3D4
66 #define VGA_CRTC_DATA_COLOR 0x3D5
67 
68 #define VGA_GC_INDEX 0x3CE
69 #define VGA_GC_DATA 0x3CF
70 
71 #define VGA_SEQ_INDEX_MASK 0x1F
72 #define VGA_GC_INDEX_MASK 0x3F
73 #define VGA_CRTC_INDEX_MASK 0x3F
74 
75 
76 
77 //
78 // Miscellaneous and Status Registers
79 //
80 
81 /* Miscellaneous register bits */
82 #define VGA_MISC_COLOR (1 << 0)
83 #define VGA_MISC_RAM_ENABLED (1 << 1)
84 // #define VGA_MISC_CSEL1 (1 << 2)
85 // #define VGA_MISC_CSEL2 (1 << 3)
86 #define VGA_MISC_OE_PAGESEL (1 << 5)
87 #define VGA_MISC_HSYNCP (1 << 6)
88 #define VGA_MISC_VSYNCP (1 << 7)
89 
90 /* Status register flags */
91 #define VGA_STAT_DD (1 << 0)
92 #define VGA_STAT_VRETRACE (1 << 3)
93 
94 
95 //
96 // Sequencer Registers
97 //
98 
99 /* Sequencer reset register bits */
100 #define VGA_SEQ_RESET_AR (1 << 0)
101 #define VGA_SEQ_RESET_SR (1 << 1)
102 
103 /* Sequencer clock register bits */
104 #define VGA_SEQ_CLOCK_98DM (1 << 0)
105 #define VGA_SEQ_CLOCK_SLR (1 << 2)
106 #define VGA_SEQ_CLOCK_DCR (1 << 3)
107 #define VGA_SEQ_CLOCK_S4 (1 << 4)
108 #define VGA_SEQ_CLOCK_SD (1 << 5)
109 
110 /* Sequencer memory register bits */
111 #define VGA_SEQ_MEM_EXT (1 << 1)
112 #define VGA_SEQ_MEM_OE_DIS (1 << 2)
113 #define VGA_SEQ_MEM_C4 (1 << 3)
114 
115 #define SVGA_SEQ_LOCKED 0x0F
116 #define SVGA_SEQ_UNLOCK_MASK 0x17
117 #define SVGA_SEQ_UNLOCKED 0x12
118 
119 /* Sequencer extended mode register bits */
120 #define SVGA_SEQ_EXT_MODE_HIGH_RES (1 << 0)
121 
122 /* Sequencer extended control register bits */
123 #define SVGA_SEQ_EXT_CONTROL_MMIO (1 << 2)
124 #define SVGA_SEQ_EXT_CONTROL_MMIO_HIGH (1 << 6)
125 
126 /* MCLK register bits */
127 #define SVGA_SEQ_MCLK_VCLK (1 << 6)
128 
129 enum
130 {
164 };
165 
166 //
167 // CRT Controller Registers
168 //
169 
170 /* CRTC overflow register bits */
171 #define VGA_CRTC_OVERFLOW_VT8 (1 << 0)
172 #define VGA_CRTC_OVERFLOW_VDE8 (1 << 1)
173 #define VGA_CRTC_OVERFLOW_VRS8 (1 << 2)
174 #define VGA_CRTC_OVERFLOW_SVB8 (1 << 3)
175 #define VGA_CRTC_OVERFLOW_LC8 (1 << 4)
176 #define VGA_CRTC_OVERFLOW_VT9 (1 << 5)
177 #define VGA_CRTC_OVERFLOW_VDE9 (1 << 6)
178 #define VGA_CRTC_OVERFLOW_VRS9 (1 << 7)
179 
180 /* CRTC underline register bits */
181 #define VGA_CRTC_UNDERLINE_DWORD (1 << 6)
182 
183 /* CRTC max scanline register bits */
184 #define VGA_CRTC_MAXSCANLINE_DOUBLE (1 << 7)
185 #define VGA_CRTC_MAXSCANLINE_LC9 (1 << 6)
186 
187 /* CRTC mode control register bits */
188 #define VGA_CRTC_MODE_CONTROL_WRAP (1 << 5)
189 #define VGA_CRTC_MODE_CONTROL_BYTE (1 << 6)
190 #define VGA_CRTC_MODE_CONTROL_SYNC (1 << 7)
191 
192 /* CRTC extended display register bits */
193 #define SVGA_CRTC_EXT_ADDR_BIT16 (1 << 0)
194 #define SVGA_CRTC_EXT_ADDR_WRAP (1 << 1)
195 #define SVGA_CRTC_EXT_ADDR_BITS1718 ((1 << 2) | (1 << 3))
196 #define SVGA_CRTC_EXT_OFFSET_BIT8 (1 << 4)
197 
198 /* CRTC extended overlay register bits */
199 #define SVGA_CRTC_EXT_ADDR_BIT19 (1 << 7)
200 
201 enum
202 {
245 };
246 
247 
248 //
249 // Graphics Controller Registers
250 //
251 
252 /* Graphics controller mode register bits */
253 #define VGA_GC_MODE_READ (1 << 3)
254 #define VGA_GC_MODE_OE (1 << 4)
255 #define VGA_GC_MODE_SHIFTREG (1 << 5)
256 #define VGA_GC_MODE_SHIFT256 (1 << 6)
257 
258 /* Graphics controller miscellaneous register bits */
259 #define VGA_GC_MISC_NOALPHA (1 << 0)
260 #define VGA_GC_MISC_OE (1 << 1)
261 
262 /* Graphics controller extended mode register bits */
263 #define SVGA_GC_EXT_MODE_WND_B (1 << 0)
264 #define SVGA_GC_EXT_MODE_GRAN (1 << 5)
265 
266 enum
267 {
322 };
323 
324 
325 //
326 // Attribute Controller Registers
327 // They are a relinquish of the CGA/EGA era.
328 //
329 
330 /* AC mode control register bits */
331 #define VGA_AC_CONTROL_ATGE (1 << 0)
332 #define VGA_AC_CONTROL_MONO (1 << 1)
333 #define VGA_AC_CONTROL_LGE (1 << 2)
334 #define VGA_AC_CONTROL_BLINK (1 << 3)
335 #define VGA_AC_CONTROL_PPM (1 << 5)
336 #define VGA_AC_CONTROL_8BIT (1 << 6)
337 #define VGA_AC_CONTROL_P54S (1 << 7)
338 
339 enum
340 {
363 };
364 
365 
366 typedef struct _VGA_REGISTERS
367 {
368  UCHAR Misc;
374 
375 typedef struct _SVGA_REGISTERS
376 {
384 
385 
386 /*
387  * Console interface -- VGA-mode-agnostic
388  */
389 // WARNING! This structure *MUST BE* in sync with the one in consrv/include/conio_winsrv.h
390 typedef struct _CHAR_CELL
391 {
395 C_ASSERT(sizeof(CHAR_CELL) == 2);
396 
397 /* FUNCTIONS ******************************************************************/
398 
403 VOID VgaWriteTextModeFont(UINT FontNumber, CONST UCHAR *FontData, UINT Height);
405 
406 BOOLEAN VgaInitialize(HANDLE TextHandle);
408 
409 #endif /* _SVGA_H_ */
UCHAR Attribute[VGA_AC_MAX_REG]
Definition: svga.h:382
UCHAR Sequencer[5]
Definition: blue.c:51
char CHAR
Definition: xmlstorage.h:175
#define FASTCALL
Definition: nt_native.h:50
struct _VGA_REGISTERS VGA_REGISTERS
BYTE Attributes
Definition: svga.h:393
VOID VgaClearMemory(VOID)
Definition: svga.c:2074
C_ASSERT(sizeof(CHAR_CELL)==2)
VOID VgaCleanup(VOID)
Definition: svga.c:2145
UCHAR Misc
Definition: blue.c:52
unsigned char BOOLEAN
static WCHAR Address[46]
Definition: ping.c:68
Definition: bufpool.h:45
BOOLEAN FASTCALL VgaWriteMemory(ULONG Address, PVOID Buffer, ULONG Size)
Definition: svga.c:1982
CHAR Char
Definition: svga.h:392
struct _SVGA_REGISTERS SVGA_REGISTERS
VOID VgaRefreshDisplay(VOID)
Definition: svga.c:1783
VOID VgaWriteTextModeFont(UINT FontNumber, CONST UCHAR *FontData, UINT Height)
Definition: svga.c:2079
UCHAR Hidden
Definition: svga.h:378
UCHAR CRT[24]
Definition: blue.c:48
unsigned char UCHAR
Definition: xmlstorage.h:181
UCHAR CRT[SVGA_CRTC_MAX_REG]
Definition: svga.h:380
UCHAR FontData[256 *BOOTCHAR_HEIGHT]
Definition: bootdata.c:57
UCHAR Attribute[21]
Definition: blue.c:49
unsigned char BYTE
Definition: mem.h:68
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
UCHAR Sequencer[SVGA_SEQ_MAX_REG]
Definition: svga.h:379
Definition: bl.h:1338
COORD VgaGetDisplayResolution(VOID)
Definition: svga.c:1727
struct _VGA_REGISTERS * PVGA_REGISTERS
struct _CHAR_CELL * PCHAR_CELL
UCHAR Misc
Definition: svga.h:377
unsigned int UINT
Definition: ndis.h:50
BOOLEAN VgaInitialize(HANDLE TextHandle)
Definition: svga.c:2100
unsigned int ULONG
Definition: retypes.h:1
VOID FASTCALL VgaReadMemory(ULONG Address, PVOID Buffer, ULONG Size)
Definition: svga.c:1802
#define CONST
Definition: pedump.c:81
struct _CHAR_CELL CHAR_CELL
struct _SVGA_REGISTERS * PSVGA_REGISTERS