1 /*- 2 * Copyright (c) 2005 Marcel Moolenaar 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * 26 * $FreeBSD$ 27 */ 28 29 #ifndef _DEV_VT_HW_VGA_VGA_REG_H_ 30 #define _DEV_VT_HW_VGA_VGA_REG_H_ 31 32 /* 33 * The VGA adapter uses two I/O port blocks. One of these blocks, the CRT 34 * controller registers, can be located either at 0x3B0 or at 0x3D0 in I/O 35 * port space. This allows compatibility with the monochrome adapter, which 36 * has the CRT controller registers at 0x3B0. 37 * 38 * It is assumed that compatibility with the monochrome adapter is not of 39 * interest anymore. As such, the CRT controller can be located at 0x3D0 in 40 * I/O port space unconditionally. This means that the 2 I/O blocks are 41 * always adjacent and can therefore be treated as a single logical I/O port 42 * range. In practical terms: there only has to be a single tag and handle 43 * to access all registers. 44 * 45 * The following definitions are taken from or inspired by: 46 * Programmer's Guide to the EGA, VGA, and Super VGA Cards -- 3rd ed., 47 * Richard F. Ferraro, Addison-Wesley, ISBN 0-201-62490-7 48 */ 49 50 #define VGA_MEM_BASE 0xA0000 51 #define VGA_MEM_SIZE 0x10000 52 #define VGA_TXT_BASE 0xB8000 53 #define VGA_TXT_SIZE 0x08000 54 #define VGA_REG_BASE 0x3c0 55 #define VGA_REG_SIZE 0x10+0x0c 56 57 /* Attribute controller registers. */ 58 #define VGA_AC_WRITE 0x00 59 #define VGA_AC_READ 0x01 60 #define VGA_AC_PALETTE(x) (x) /* 0 <= x <= 15 */ 61 #define VGA_AC_PAL_SR 0x20 /* Secondary red */ 62 #define VGA_AC_PAL_SG 0x10 /* Secondary green */ 63 #define VGA_AC_PAL_SB 0x08 /* Secondary blue */ 64 #define VGA_AC_PAL_R 0x04 /* Red */ 65 #define VGA_AC_PAL_G 0x02 /* Green */ 66 #define VGA_AC_PAL_B 0x01 /* Blue */ 67 #define VGA_AC_MODE_CONTROL (32+16) 68 #define VGA_AC_MC_IPS 0x80 /* Internal palette size */ 69 #define VGA_AC_MC_PCS 0x40 /* Pixel clock select */ 70 #define VGA_AC_MC_PPC 0x20 /* Pixel panning compat. */ 71 #define VGA_AC_MC_BI 0x08 /* Blink/intensity */ 72 #define VGA_AC_MC_ELG 0x04 /* Enable line graphics cc. */ 73 #define VGA_AC_MC_DT 0x02 /* Display type */ 74 #define VGA_AC_MC_GA 0x01 /* Graphics/alphanumeric */ 75 #define VGA_AC_OVERSCAN_COLOR (32+17) 76 #define VGA_AC_COLOR_PLANE_ENABLE (32+18) 77 #define VGA_AC_HORIZ_PIXEL_PANNING (32+19) 78 #define VGA_AC_COLOR_SELECT (32+20) 79 #define VGA_AC_CS_C67 0x0C /* Color reg. addr. bits 6+7 */ 80 #define VGA_AC_CS_C45 0x03 /* Color reg. addr. bits 4+5 */ 81 82 /* General registers. */ 83 #define VGA_GEN_MISC_OUTPUT_W 0x02 /* Write only. */ 84 #define VGA_GEN_MISC_OUTPUT_R 0x0c /* Read only. */ 85 #define VGA_GEN_MO_VSP 0x80 /* Vertical sync. polarity */ 86 #define VGA_GEN_MO_HSP 0x40 /* Horiz. sync. polarity */ 87 #define VGA_GEN_MO_PB 0x20 /* Page bit for odd/even */ 88 #define VGA_GEN_MO_CS 0x0C /* Clock select */ 89 #define VGA_GEN_MO_ER 0x02 /* Enable RAM */ 90 #define VGA_GEN_MO_IOA 0x01 /* Input/output address */ 91 #define VGA_GEN_INPUT_STAT_0 0x02 /* Read only. */ 92 #define VGA_GEN_FEATURE_CTRL_W 0x1a /* Write only. */ 93 #define VGA_GEN_FEATURE_CTRL_R 0x0a /* Read only. */ 94 #define VGA_GEN_INPUT_STAT_1 0x1a /* Read only. */ 95 #define VGA_GEN_IS1_VR 0x08 /* Vertical retrace */ 96 #define VGA_GEN_IS1_DE 0x01 /* Display enable not */ 97 98 /* Sequencer registers. */ 99 #define VGA_SEQ_ADDRESS 0x04 100 #define VGA_SEQ_RESET 0 101 #define VGA_SEQ_RST_SR 0x02 /* Synchronous reset */ 102 #define VGA_SEQ_RST_NAR 0x01 /* No async. reset */ 103 #define VGA_SEQ_CLOCKING_MODE 1 104 #define VGA_SEQ_CM_SO 0x20 /* Screen off */ 105 #define VGA_SEQ_CM_S4 0x10 /* Shift four */ 106 #define VGA_SEQ_CM_DC 0x08 /* Dot clock */ 107 #define VGA_SEQ_CM_SL 0x04 /* Shift load */ 108 #define VGA_SEQ_CM_89 0x01 /* 8/9 Dot clocks */ 109 #define VGA_SEQ_MAP_MASK 2 110 #define VGA_SEQ_MM_EM3 0x08 /* Enable memory plane 3 */ 111 #define VGA_SEQ_MM_EM2 0x04 /* Enable memory plane 2 */ 112 #define VGA_SEQ_MM_EM1 0x02 /* Enable memory plane 1 */ 113 #define VGA_SEQ_MM_EM0 0x01 /* Enable memory plane 0 */ 114 #define VGA_SEQ_CHAR_MAP_SELECT 3 115 #define VGA_SEQ_CMS_SAH 0x20 /* Char. A (bit 2) */ 116 #define VGA_SEQ_CMS_SBH 0x10 /* Char. B (bit 2) */ 117 #define VGA_SEQ_CMS_SA 0x0C /* Char. A (bit 0+1) */ 118 #define VGA_SEQ_CMS_SB 0x03 /* Char. B (bit 0+1) */ 119 #define VGA_SEQ_MEMORY_MODE 4 120 #define VGA_SEQ_MM_C4 0x08 /* Chain four */ 121 #define VGA_SEQ_MM_OE 0x04 /* Odd/even */ 122 #define VGA_SEQ_MM_EM 0x02 /* Extended memory */ 123 #define VGA_SEQ_DATA 0x05 124 125 /* Color registers. */ 126 #define VGA_PEL_MASK 0x06 127 #define VGA_PEL_ADDR_RD_MODE 0x07 /* Write only. */ 128 #define VGA_DAC_STATE 0x07 /* Read only. */ 129 #define VGA_PEL_ADDR_WR_MODE 0x08 130 #define VGA_PEL_DATA 0x09 131 132 /* Graphics controller registers. */ 133 #define VGA_GC_ADDRESS 0x0e 134 #define VGA_GC_SET_RESET 0 135 #define VGA_GC_ENABLE_SET_RESET 1 136 #define VGA_GC_COLOR_COMPARE 2 137 #define VGA_GC_DATA_ROTATE 3 138 #define VGA_GC_DR_FS_XOR 0x18 /* Function select - XOR */ 139 #define VGA_GC_DR_FS_OR 0x10 /* Function select - OR */ 140 #define VGA_GC_DR_FS_AND 0x08 /* Function select - AND */ 141 #define VGA_GC_DR_RC 0x07 /* Rotate count */ 142 #define VGA_GC_READ_MAP_SELECT 4 143 #define VGA_GC_MODE 5 144 #define VGA_GC_MODE_SR 0x60 /* Shift register */ 145 #define VGA_GC_MODE_OE 0x10 /* Odd/even */ 146 #define VGA_GC_MODE_RM 0x08 /* Read mode */ 147 #define VGA_GC_MODE_WM 0x03 /* Write mode */ 148 #define VGA_GC_MISCELLANEOUS 6 149 #define VGA_GC_MISC_MM 0x0C /* memory map */ 150 #define VGA_GC_MISC_COE 0x02 /* Chain odd/even */ 151 #define VGA_GC_MISC_GA 0x01 /* Graphics/text mode */ 152 #define VGA_GC_COLOR_DONT_CARE 7 153 #define VGA_GC_BIT_MASK 8 154 #define VGA_GC_DATA 0x0f 155 156 /* CRT controller registers. */ 157 #define VGA_CRTC_ADDRESS 0x14 158 #define VGA_CRTC_HORIZ_TOTAL 0 159 #define VGA_CRTC_HORIZ_DISP_END 1 160 #define VGA_CRTC_START_HORIZ_BLANK 2 161 #define VGA_CRTC_END_HORIZ_BLANK 3 162 #define VGA_CRTC_EHB_CR 0x80 /* Compatible read */ 163 #define VGA_CRTC_EHB_DES 0x60 /* Display enable skew */ 164 #define VGA_CRTC_EHB_EHB 0x1F /* End horizontal blank */ 165 #define VGA_CRTC_START_HORIZ_RETRACE 4 166 #define VGA_CRTC_END_HORIZ_RETRACE 5 167 #define VGA_CRTC_EHR_EHB 0x80 /* End horizontal blanking */ 168 #define VGA_CRTC_EHR_HRD 0x60 /* Horizontal retrace delay */ 169 #define VGA_CRTC_EHR_EHR 0x1F /* End horizontal retrace */ 170 #define VGA_CRTC_VERT_TOTAL 6 171 #define VGA_CRTC_OVERFLOW 7 172 #define VGA_CRTC_OF_VRS9 0x80 /* Vertical retrace start */ 173 #define VGA_CRTC_OF_VDE9 0x40 /* Vertical disp. enable end */ 174 #define VGA_CRTC_OF_VT9 0x20 /* Vertical total (bit 9) */ 175 #define VGA_CRTC_OF_LC8 0x10 /* Line compare */ 176 #define VGA_CRTC_OF_VBS8 0x08 /* Start vertical blanking */ 177 #define VGA_CRTC_OF_VRS8 0x04 /* Vertical retrace start */ 178 #define VGA_CRTC_OF_VDE8 0x02 /* Vertical disp. enable end */ 179 #define VGA_CRTC_OF_VT8 0x01 /* Vertical total (bit 8) */ 180 #define VGA_CRTC_PRESET_ROW_SCAN 8 181 #define VGA_CRTC_PRS_BP 0x60 /* Byte panning */ 182 #define VGA_CRTC_PRS_PRS 0x1F /* Preset row scan */ 183 #define VGA_CRTC_MAX_SCAN_LINE 9 184 #define VGA_CRTC_MSL_2T4 0x80 /* 200-to-400 line conversion */ 185 #define VGA_CRTC_MSL_LC9 0x40 /* Line compare (bit 9) */ 186 #define VGA_CRTC_MSL_VBS9 0x20 /* Start vertical blanking */ 187 #define VGA_CRTC_MSL_MSL 0x1F /* Maximum scan line */ 188 #define VGA_CRTC_CURSOR_START 10 189 #define VGA_CRTC_CS_COO 0x20 /* Cursor on/off */ 190 #define VGA_CRTC_CS_CS 0x1F /* Cursor start */ 191 #define VGA_CRTC_CURSOR_END 11 192 #define VGA_CRTC_CE_CSK 0x60 /* Cursor skew */ 193 #define VGA_CRTC_CE_CE 0x1F /* Cursor end */ 194 #define VGA_CRTC_START_ADDR_HIGH 12 195 #define VGA_CRTC_START_ADDR_LOW 13 196 #define VGA_CRTC_CURSOR_LOC_HIGH 14 197 #define VGA_CRTC_CURSOR_LOC_LOW 15 198 #define VGA_CRTC_VERT_RETRACE_START 16 199 #define VGA_CRTC_VERT_RETRACE_END 17 200 #define VGA_CRTC_VRE_PR 0x80 /* Protect register 0-7 */ 201 #define VGA_CRTC_VRE_BW 0x40 /* Bandwidth */ 202 #define VGA_CRTC_VRE_VRE 0x1F /* Vertical retrace end */ 203 #define VGA_CRTC_VERT_DISPLAY_END 18 204 #define VGA_CRTC_OFFSET 19 205 #define VGA_CRTC_UNDERLINE_LOC 20 206 #define VGA_CRTC_UL_DW 0x40 /* Double word mode */ 207 #define VGA_CRTC_UL_CB4 0x20 /* Count by four */ 208 #define VGA_CRTC_UL_UL 0x1F /* Underline location */ 209 #define VGA_CRTC_START_VERT_BLANK 21 210 #define VGA_CRTC_END_VERT_BLANK 22 211 #define VGA_CRTC_MODE_CONTROL 23 212 #define VGA_CRTC_MC_HR 0x80 /* hardware reset */ 213 #define VGA_CRTC_MC_WB 0x40 /* Word/byte mode */ 214 #define VGA_CRTC_MC_AW 0x20 /* Address wrap */ 215 #define VGA_CRTC_MC_CBT 0x08 /* Count by two */ 216 #define VGA_CRTC_MC_HRS 0x04 /* Horizontal retrace select */ 217 #define VGA_CRTC_MC_SRS 0x02 /* Select row scan counter */ 218 #define VGA_CRTC_MC_CMS 0x01 /* Compatibility mode support */ 219 #define VGA_CRTC_LINE_COMPARE 24 220 #define VGA_CRTC_DATA 0x15 221 222 #endif /* !_DEV_VT_HW_VGA_VGA_REG_H_ */ 223