xref: /qemu/hw/display/vga_regs.h (revision 435262605fa2737af73b7057f525f8fe221c1006)
1b134886aSBlue Swirl /*
2b134886aSBlue Swirl  * linux/include/video/vga.h -- standard VGA chipset interaction
3b134886aSBlue Swirl  *
4b134886aSBlue Swirl  * Copyright 1999 Jeff Garzik <jgarzik@pobox.com>
5b134886aSBlue Swirl  *
6b134886aSBlue Swirl  * Copyright history from vga16fb.c:
7b134886aSBlue Swirl  *  Copyright 1999 Ben Pfaff and Petr Vandrovec
8b134886aSBlue Swirl  *  Based on VGA info at http://www.osdever.net/FreeVGA/home.htm
9b134886aSBlue Swirl  *  Based on VESA framebuffer (c) 1998 Gerd Knorr
10b134886aSBlue Swirl  *
11b134886aSBlue Swirl  * This file is subject to the terms and conditions of the GNU General
12b134886aSBlue Swirl  * Public License.  See the file COPYING in the main directory of this
13b134886aSBlue Swirl  * archive for more details.
14b134886aSBlue Swirl  *
15b134886aSBlue Swirl  */
16b134886aSBlue Swirl 
1758ea30f5SMarkus Armbruster #ifndef HW_VGA_REGS_H
1858ea30f5SMarkus Armbruster #define HW_VGA_REGS_H
19b134886aSBlue Swirl 
20b134886aSBlue Swirl /* Some of the code below is taken from SVGAlib.  The original,
21b134886aSBlue Swirl    unmodified copyright notice for that code is below. */
22b134886aSBlue Swirl /* VGAlib version 1.2 - (c) 1993 Tommy Frandsen                    */
23b134886aSBlue Swirl /*                                                                 */
24b134886aSBlue Swirl /* This library is free software; you can redistribute it and/or   */
25b134886aSBlue Swirl /* modify it without any restrictions. This library is distributed */
26b134886aSBlue Swirl /* in the hope that it will be useful, but without any warranty.   */
27b134886aSBlue Swirl 
28b134886aSBlue Swirl /* Multi-chipset support Copyright 1993 Harm Hanemaayer */
29b134886aSBlue Swirl /* partially copyrighted (C) 1993 by Hartmut Schirmer */
30b134886aSBlue Swirl 
31b134886aSBlue Swirl /* VGA data register ports */
32b134886aSBlue Swirl #define VGA_CRT_DC      0x3D5   /* CRT Controller Data Register - color emulation */
33b134886aSBlue Swirl #define VGA_CRT_DM      0x3B5   /* CRT Controller Data Register - mono emulation */
34b134886aSBlue Swirl #define VGA_ATT_R       0x3C1   /* Attribute Controller Data Read Register */
35b134886aSBlue Swirl #define VGA_ATT_W       0x3C0   /* Attribute Controller Data Write Register */
36b134886aSBlue Swirl #define VGA_GFX_D       0x3CF   /* Graphics Controller Data Register */
37b134886aSBlue Swirl #define VGA_SEQ_D       0x3C5   /* Sequencer Data Register */
38b134886aSBlue Swirl #define VGA_MIS_R       0x3CC   /* Misc Output Read Register */
39b134886aSBlue Swirl #define VGA_MIS_W       0x3C2   /* Misc Output Write Register */
40b134886aSBlue Swirl #define VGA_FTC_R       0x3CA   /* Feature Control Read Register */
41b134886aSBlue Swirl #define VGA_IS1_RC      0x3DA   /* Input Status Register 1 - color emulation */
42b134886aSBlue Swirl #define VGA_IS1_RM      0x3BA   /* Input Status Register 1 - mono emulation */
43b134886aSBlue Swirl #define VGA_PEL_D       0x3C9   /* PEL Data Register */
44b134886aSBlue Swirl #define VGA_PEL_MSK     0x3C6   /* PEL mask register */
45b134886aSBlue Swirl 
46b134886aSBlue Swirl /* EGA-specific registers */
47b134886aSBlue Swirl #define EGA_GFX_E0      0x3CC   /* Graphics enable processor 0 */
48b134886aSBlue Swirl #define EGA_GFX_E1      0x3CA   /* Graphics enable processor 1 */
49b134886aSBlue Swirl 
50b134886aSBlue Swirl /* VGA index register ports */
51b134886aSBlue Swirl #define VGA_CRT_IC      0x3D4   /* CRT Controller Index - color emulation */
52b134886aSBlue Swirl #define VGA_CRT_IM      0x3B4   /* CRT Controller Index - mono emulation */
53b134886aSBlue Swirl #define VGA_ATT_IW      0x3C0   /* Attribute Controller Index & Data Write Register */
54b134886aSBlue Swirl #define VGA_GFX_I       0x3CE   /* Graphics Controller Index */
55b134886aSBlue Swirl #define VGA_SEQ_I       0x3C4   /* Sequencer Index */
56b134886aSBlue Swirl #define VGA_PEL_IW      0x3C8   /* PEL Write Index */
57b134886aSBlue Swirl #define VGA_PEL_IR      0x3C7   /* PEL Read Index */
58b134886aSBlue Swirl 
59b134886aSBlue Swirl /* standard VGA indexes max counts */
60b134886aSBlue Swirl #define VGA_CRT_C       0x19    /* Number of CRT Controller Registers */
61b134886aSBlue Swirl #define VGA_ATT_C       0x15    /* Number of Attribute Controller Registers */
62b134886aSBlue Swirl #define VGA_GFX_C       0x09    /* Number of Graphics Controller Registers */
63b134886aSBlue Swirl #define VGA_SEQ_C       0x05    /* Number of Sequencer Registers */
64b134886aSBlue Swirl #define VGA_MIS_C       0x01    /* Number of Misc Output Register */
65b134886aSBlue Swirl 
66b134886aSBlue Swirl /* VGA misc register bit masks */
67b134886aSBlue Swirl #define VGA_MIS_COLOR           0x01
68b134886aSBlue Swirl #define VGA_MIS_ENB_MEM_ACCESS  0x02
69b134886aSBlue Swirl #define VGA_MIS_DCLK_28322_720  0x04
70b134886aSBlue Swirl #define VGA_MIS_ENB_PLL_LOAD    (0x04 | 0x08)
71b134886aSBlue Swirl #define VGA_MIS_SEL_HIGH_PAGE   0x20
72b134886aSBlue Swirl 
73b134886aSBlue Swirl /* VGA CRT controller register indices */
74b134886aSBlue Swirl #define VGA_CRTC_H_TOTAL        0
75b134886aSBlue Swirl #define VGA_CRTC_H_DISP         1
76b134886aSBlue Swirl #define VGA_CRTC_H_BLANK_START  2
77b134886aSBlue Swirl #define VGA_CRTC_H_BLANK_END    3
78b134886aSBlue Swirl #define VGA_CRTC_H_SYNC_START   4
79b134886aSBlue Swirl #define VGA_CRTC_H_SYNC_END     5
80b134886aSBlue Swirl #define VGA_CRTC_V_TOTAL        6
81b134886aSBlue Swirl #define VGA_CRTC_OVERFLOW       7
82b134886aSBlue Swirl #define VGA_CRTC_PRESET_ROW     8
83b134886aSBlue Swirl #define VGA_CRTC_MAX_SCAN       9
84b134886aSBlue Swirl #define VGA_CRTC_CURSOR_START   0x0A
85b134886aSBlue Swirl #define VGA_CRTC_CURSOR_END     0x0B
86b134886aSBlue Swirl #define VGA_CRTC_START_HI       0x0C
87b134886aSBlue Swirl #define VGA_CRTC_START_LO       0x0D
88b134886aSBlue Swirl #define VGA_CRTC_CURSOR_HI      0x0E
89b134886aSBlue Swirl #define VGA_CRTC_CURSOR_LO      0x0F
90b134886aSBlue Swirl #define VGA_CRTC_V_SYNC_START   0x10
91b134886aSBlue Swirl #define VGA_CRTC_V_SYNC_END     0x11
92b134886aSBlue Swirl #define VGA_CRTC_V_DISP_END     0x12
93b134886aSBlue Swirl #define VGA_CRTC_OFFSET         0x13
94b134886aSBlue Swirl #define VGA_CRTC_UNDERLINE      0x14
95b134886aSBlue Swirl #define VGA_CRTC_V_BLANK_START  0x15
96b134886aSBlue Swirl #define VGA_CRTC_V_BLANK_END    0x16
97b134886aSBlue Swirl #define VGA_CRTC_MODE           0x17
98b134886aSBlue Swirl #define VGA_CRTC_LINE_COMPARE   0x18
99b134886aSBlue Swirl #define VGA_CRTC_REGS           VGA_CRT_C
100b134886aSBlue Swirl 
101b134886aSBlue Swirl /* VGA CRT controller bit masks */
102b134886aSBlue Swirl #define VGA_CR11_LOCK_CR0_CR7   0x80 /* lock writes to CR0 - CR7 */
103*43526260SPaolo Bonzini #define VGA_CR14_DW             0x40
104b134886aSBlue Swirl #define VGA_CR17_H_V_SIGNALS_ENABLED 0x80
105*43526260SPaolo Bonzini #define VGA_CR17_WORD_BYTE      0x40
106b134886aSBlue Swirl 
107b134886aSBlue Swirl /* VGA attribute controller register indices */
108b134886aSBlue Swirl #define VGA_ATC_PALETTE0        0x00
109b134886aSBlue Swirl #define VGA_ATC_PALETTE1        0x01
110b134886aSBlue Swirl #define VGA_ATC_PALETTE2        0x02
111b134886aSBlue Swirl #define VGA_ATC_PALETTE3        0x03
112b134886aSBlue Swirl #define VGA_ATC_PALETTE4        0x04
113b134886aSBlue Swirl #define VGA_ATC_PALETTE5        0x05
114b134886aSBlue Swirl #define VGA_ATC_PALETTE6        0x06
115b134886aSBlue Swirl #define VGA_ATC_PALETTE7        0x07
116b134886aSBlue Swirl #define VGA_ATC_PALETTE8        0x08
117b134886aSBlue Swirl #define VGA_ATC_PALETTE9        0x09
118b134886aSBlue Swirl #define VGA_ATC_PALETTEA        0x0A
119b134886aSBlue Swirl #define VGA_ATC_PALETTEB        0x0B
120b134886aSBlue Swirl #define VGA_ATC_PALETTEC        0x0C
121b134886aSBlue Swirl #define VGA_ATC_PALETTED        0x0D
122b134886aSBlue Swirl #define VGA_ATC_PALETTEE        0x0E
123b134886aSBlue Swirl #define VGA_ATC_PALETTEF        0x0F
124b134886aSBlue Swirl #define VGA_ATC_MODE            0x10
125b134886aSBlue Swirl #define VGA_ATC_OVERSCAN        0x11
126b134886aSBlue Swirl #define VGA_ATC_PLANE_ENABLE    0x12
127b134886aSBlue Swirl #define VGA_ATC_PEL             0x13
128b134886aSBlue Swirl #define VGA_ATC_COLOR_PAGE      0x14
129b134886aSBlue Swirl 
130b134886aSBlue Swirl #define VGA_AR_ENABLE_DISPLAY   0x20
131b134886aSBlue Swirl 
132b134886aSBlue Swirl /* VGA sequencer register indices */
133b134886aSBlue Swirl #define VGA_SEQ_RESET           0x00
134b134886aSBlue Swirl #define VGA_SEQ_CLOCK_MODE      0x01
135b134886aSBlue Swirl #define VGA_SEQ_PLANE_WRITE     0x02
136b134886aSBlue Swirl #define VGA_SEQ_CHARACTER_MAP   0x03
137b134886aSBlue Swirl #define VGA_SEQ_MEMORY_MODE     0x04
138b134886aSBlue Swirl 
139b134886aSBlue Swirl /* VGA sequencer register bit masks */
140b134886aSBlue Swirl #define VGA_SR01_CHAR_CLK_8DOTS 0x01 /* bit 0: character clocks 8 dots wide are generated */
141b134886aSBlue Swirl #define VGA_SR01_SCREEN_OFF     0x20 /* bit 5: Screen is off */
142b134886aSBlue Swirl #define VGA_SR02_ALL_PLANES     0x0F /* bits 3-0: enable access to all planes */
143b134886aSBlue Swirl #define VGA_SR04_EXT_MEM        0x02 /* bit 1: allows complete mem access to 256K */
144b134886aSBlue Swirl #define VGA_SR04_SEQ_MODE       0x04 /* bit 2: directs system to use a sequential addressing mode */
145b134886aSBlue Swirl #define VGA_SR04_CHN_4M         0x08 /* bit 3: selects modulo 4 addressing for CPU access to display memory */
146b134886aSBlue Swirl 
147b134886aSBlue Swirl /* VGA graphics controller register indices */
148b134886aSBlue Swirl #define VGA_GFX_SR_VALUE        0x00
149b134886aSBlue Swirl #define VGA_GFX_SR_ENABLE       0x01
150b134886aSBlue Swirl #define VGA_GFX_COMPARE_VALUE   0x02
151b134886aSBlue Swirl #define VGA_GFX_DATA_ROTATE     0x03
152b134886aSBlue Swirl #define VGA_GFX_PLANE_READ      0x04
153b134886aSBlue Swirl #define VGA_GFX_MODE            0x05
154b134886aSBlue Swirl #define VGA_GFX_MISC            0x06
155b134886aSBlue Swirl #define VGA_GFX_COMPARE_MASK    0x07
156b134886aSBlue Swirl #define VGA_GFX_BIT_MASK        0x08
157b134886aSBlue Swirl 
158b134886aSBlue Swirl /* VGA graphics controller bit masks */
159*43526260SPaolo Bonzini #define VGA_GR05_HOST_ODD_EVEN  0x10
160b134886aSBlue Swirl #define VGA_GR06_GRAPHICS_MODE  0x01
161*43526260SPaolo Bonzini #define VGA_GR06_CHAIN_ODD_EVEN 0x02
162b134886aSBlue Swirl 
16358ea30f5SMarkus Armbruster #endif /* HW_VGA_REGS_H */
164