Home | History | Annotate | Line # | Download | only in dev
grf_etreg.h revision 1.1.78.1
      1  1.1.78.1  yamt /*	$NetBSD: grf_etreg.h,v 1.1.78.1 2007/09/03 14:23:37 yamt Exp $	*/
      2       1.1   leo 
      3       1.1   leo /*
      4       1.1   leo  * Copyright (c) 1996 Tobias Abt
      5       1.1   leo  * Copyright (c) 1995 Ezra Story
      6       1.1   leo  * Copyright (c) 1995 Kari Mettinen
      7       1.1   leo  * Copyright (c) 1994 Markus Wild
      8       1.1   leo  * Copyright (c) 1994 Lutz Vieweg
      9       1.1   leo  * All rights reserved.
     10       1.1   leo  *
     11       1.1   leo  * Redistribution and use in source and binary forms, with or without
     12       1.1   leo  * modification, are permitted provided that the following conditions
     13       1.1   leo  * are met:
     14       1.1   leo  * 1. Redistributions of source code must retain the above copyright
     15       1.1   leo  *    notice, this list of conditions and the following disclaimer.
     16       1.1   leo  * 2. Redistributions in binary form must reproduce the above copyright
     17       1.1   leo  *    notice, this list of conditions and the following disclaimer in the
     18       1.1   leo  *    documentation and/or other materials provided with the distribution.
     19       1.1   leo  * 3. All advertising materials mentioning features or use of this software
     20       1.1   leo  *    must display the following acknowledgement:
     21       1.1   leo  *      This product includes software developed by Lutz Vieweg.
     22       1.1   leo  * 4. The name of the author may not be used to endorse or promote products
     23       1.1   leo  *    derived from this software without specific prior written permission
     24       1.1   leo  *
     25       1.1   leo  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     26       1.1   leo  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     27       1.1   leo  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     28       1.1   leo  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     29       1.1   leo  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     30       1.1   leo  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     31       1.1   leo  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     32       1.1   leo  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     33       1.1   leo  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     34       1.1   leo  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     35       1.1   leo  */
     36       1.1   leo 
     37       1.1   leo #ifndef _GRF_ETREG_H
     38       1.1   leo #define _GRF_ETREG_H
     39       1.1   leo 
     40       1.1   leo /*
     41       1.1   leo  * Written & Copyright by Kari Mettinen, Ezra Story.
     42       1.1   leo  *
     43       1.1   leo  * This is derived from Cirrus driver source
     44       1.1   leo  */
     45       1.1   leo 
     46       1.1   leo /*
     47       1.1   leo  * read/write VGA registers
     48       1.1   leo  */
     49       1.1   leo #define vgar(ba, reg)		(*(((volatile u_char *)ba)+reg))
     50       1.1   leo #define vgaw(ba, reg, val)	*(((volatile u_char *)ba)+reg) = ((u_char)val)
     51       1.1   leo 
     52       1.1   leo /*
     53       1.1   leo  * defines for the used register addresses (mw)
     54       1.1   leo  *
     55       1.1   leo  * NOTE: there are some registers that have different addresses when
     56       1.1   leo  *       in mono or color mode. We only support color mode, and thus
     57       1.1   leo  *       some addresses won't work in mono-mode!
     58       1.1   leo  *
     59       1.1   leo  * General and VGA-registers taken from retina driver. Fixed a few
     60       1.1   leo  * bugs in it. (SR and GR read address is Port + 1, NOT Port)
     61       1.1   leo  *
     62       1.1   leo  */
     63       1.1   leo 
     64       1.1   leo /* General Registers: */
     65       1.1   leo #define GREG_STATUS0_R		0x03C2
     66       1.1   leo #define GREG_STATUS1_R		0x03DA
     67       1.1   leo #define GREG_MISC_OUTPUT_R	0x03CC
     68       1.1   leo #define GREG_MISC_OUTPUT_W	0x03C2
     69       1.1   leo #define GREG_FEATURE_CONTROL_R	0x03CA
     70       1.1   leo #define GREG_FEATURE_CONTROL_W	0x03DA
     71       1.1   leo #define GREG_POS		0x0102
     72       1.1   leo #define	GREG_HERCULESCOMPAT	0x03BF
     73       1.1   leo #define	GREG_VIDEOSYSENABLE	0x03C3
     74       1.1   leo #define	GREG_DISPMODECONTROL	0x03D8
     75       1.1   leo #define	GREG_COLORSELECT	0x03D9
     76       1.1   leo #define	GREG_ATNTMODECONTROL	0x03DE
     77       1.1   leo #define	GREG_SEGMENTSELECT	0x03CD
     78       1.1   leo 
     79       1.1   leo /* Attribute Controller: */
     80       1.1   leo #define ACT_ADDRESS		0x03C0
     81       1.1   leo #define ACT_ADDRESS_R		0x03C1
     82       1.1   leo #define ACT_ADDRESS_W		0x03C0
     83       1.1   leo #define ACT_ADDRESS_RESET	0x03DA
     84       1.1   leo #define ACT_ID_PALETTE0		0x00
     85       1.1   leo #define ACT_ID_PALETTE1		0x01
     86       1.1   leo #define ACT_ID_PALETTE2		0x02
     87       1.1   leo #define ACT_ID_PALETTE3		0x03
     88       1.1   leo #define ACT_ID_PALETTE4		0x04
     89       1.1   leo #define ACT_ID_PALETTE5		0x05
     90       1.1   leo #define ACT_ID_PALETTE6		0x06
     91       1.1   leo #define ACT_ID_PALETTE7		0x07
     92       1.1   leo #define ACT_ID_PALETTE8		0x08
     93       1.1   leo #define ACT_ID_PALETTE9		0x09
     94       1.1   leo #define ACT_ID_PALETTE10	0x0A
     95       1.1   leo #define ACT_ID_PALETTE11	0x0B
     96       1.1   leo #define ACT_ID_PALETTE12	0x0C
     97       1.1   leo #define ACT_ID_PALETTE13	0x0D
     98       1.1   leo #define ACT_ID_PALETTE14	0x0E
     99       1.1   leo #define ACT_ID_PALETTE15	0x0F
    100       1.1   leo #define ACT_ID_ATTR_MODE_CNTL	0x10
    101       1.1   leo #define ACT_ID_OVERSCAN_COLOR	0x11
    102       1.1   leo #define ACT_ID_COLOR_PLANE_ENA	0x12
    103       1.1   leo #define ACT_ID_HOR_PEL_PANNING	0x13
    104       1.1   leo #define ACT_ID_COLOR_SELECT	0x14
    105       1.1   leo #define	ACT_ID_MISCELLANEOUS	0x16
    106       1.1   leo 
    107       1.1   leo /* Graphics Controller: */
    108       1.1   leo #define GCT_ADDRESS		0x03CE
    109       1.1   leo #define GCT_ADDRESS_R		0x03CF
    110       1.1   leo #define GCT_ADDRESS_W		0x03CF
    111       1.1   leo #define GCT_ID_SET_RESET	0x00
    112       1.1   leo #define GCT_ID_ENABLE_SET_RESET	0x01
    113       1.1   leo #define GCT_ID_COLOR_COMPARE	0x02
    114       1.1   leo #define GCT_ID_DATA_ROTATE	0x03
    115       1.1   leo #define GCT_ID_READ_MAP_SELECT	0x04
    116       1.1   leo #define GCT_ID_GRAPHICS_MODE	0x05
    117       1.1   leo #define GCT_ID_MISC		0x06
    118       1.1   leo #define GCT_ID_COLOR_XCARE	0x07
    119       1.1   leo #define GCT_ID_BITMASK		0x08
    120       1.1   leo 
    121       1.1   leo /* Sequencer: */
    122       1.1   leo #define SEQ_ADDRESS		0x03C4
    123       1.1   leo #define SEQ_ADDRESS_R		0x03C5
    124       1.1   leo #define SEQ_ADDRESS_W		0x03C5
    125       1.1   leo #define SEQ_ID_RESET		0x00
    126       1.1   leo #define SEQ_ID_CLOCKING_MODE	0x01
    127       1.1   leo #define SEQ_ID_MAP_MASK		0x02
    128       1.1   leo #define SEQ_ID_CHAR_MAP_SELECT	0x03
    129       1.1   leo #define SEQ_ID_MEMORY_MODE	0x04
    130       1.1   leo #define	SEQ_ID_STATE_CONTROL	0x06
    131       1.1   leo #define	SEQ_ID_AUXILIARY_MODE	0x07
    132       1.1   leo 
    133       1.1   leo /* CRT Controller: */
    134       1.1   leo #define CRT_ADDRESS		0x03D4
    135       1.1   leo #define CRT_ADDRESS_R		0x03D5
    136       1.1   leo #define CRT_ADDRESS_W		0x03D5
    137       1.1   leo #define CRT_ID_HOR_TOTAL	0x00
    138       1.1   leo #define CRT_ID_HOR_DISP_ENA_END	0x01
    139       1.1   leo #define CRT_ID_START_HOR_BLANK	0x02
    140       1.1   leo #define CRT_ID_END_HOR_BLANK	0x03
    141       1.1   leo #define CRT_ID_START_HOR_RETR	0x04
    142       1.1   leo #define CRT_ID_END_HOR_RETR	0x05
    143       1.1   leo #define CRT_ID_VER_TOTAL	0x06
    144       1.1   leo #define CRT_ID_OVERFLOW		0x07
    145       1.1   leo #define CRT_ID_PRESET_ROW_SCAN	0x08
    146       1.1   leo #define	CRT_ID_MAX_ROW_ADDRESS	0x09
    147       1.1   leo #define CRT_ID_CURSOR_START	0x0A
    148       1.1   leo #define CRT_ID_CURSOR_END	0x0B
    149       1.1   leo #define CRT_ID_START_ADDR_HIGH	0x0C
    150       1.1   leo #define CRT_ID_START_ADDR_LOW	0x0D
    151       1.1   leo #define CRT_ID_CURSOR_LOC_HIGH	0x0E
    152       1.1   leo #define CRT_ID_CURSOR_LOC_LOW	0x0F
    153       1.1   leo #define CRT_ID_START_VER_RETR	0x10
    154       1.1   leo #define CRT_ID_END_VER_RETR	0x11
    155       1.1   leo #define CRT_ID_VER_DISP_ENA_END	0x12
    156       1.1   leo #define CRT_ID_OFFSET		0x13
    157       1.1   leo #define CRT_ID_UNDERLINE_LOC	0x14
    158       1.1   leo #define CRT_ID_START_VER_BLANK	0x15
    159       1.1   leo #define CRT_ID_END_VER_BLANK	0x16
    160       1.1   leo #define CRT_ID_MODE_CONTROL	0x17
    161       1.1   leo #define CRT_ID_LINE_COMPARE	0x18
    162       1.1   leo 
    163       1.1   leo #define	CRT_ID_SEGMENT_COMP	0x30
    164       1.1   leo #define	CRT_ID_GENERAL_PURPOSE	0x31
    165       1.1   leo #define	CRT_ID_RASCAS_CONFIG	0x32
    166       1.1   leo #define	CTR_ID_EXT_START	0x33
    167       1.1   leo #define	CRT_ID_6845_COMPAT	0x34
    168       1.1   leo #define	CRT_ID_OVERFLOW_HIGH	0x35
    169       1.1   leo #define	CRT_ID_VIDEO_CONFIG1	0x36
    170       1.1   leo #define	CRT_ID_VIDEO_CONFIG2	0x37
    171       1.1   leo #define	CRT_ID_HOR_OVERFLOW	0x3f
    172       1.1   leo 
    173       1.1   leo /* Video DAC */
    174       1.1   leo #define VDAC_ADDRESS		0x03c8
    175       1.1   leo #define VDAC_ADDRESS_W		0x03c8
    176       1.1   leo #define VDAC_ADDRESS_R		0x03c7
    177       1.1   leo #define VDAC_STATE		0x03c7
    178       1.1   leo #define VDAC_DATA		0x03c9
    179       1.1   leo #define VDAC_MASK		0x03c6
    180       1.1   leo #define HDR			0x03c6	/* Hidden DAC regs, 4 reads to access */
    181       1.1   leo 
    182       1.1   leo #define VDAC_COMMAND		0x03c6
    183       1.1   leo #define VDAC_XINDEX		0x03c7
    184       1.1   leo #define VDAC_XDATA		0x03c8
    185       1.1   leo 
    186       1.1   leo #define WGfx(ba, idx, val)			\
    187       1.1   leo 	do {					\
    188       1.1   leo 		vgaw(ba, GCT_ADDRESS, idx);	\
    189       1.1   leo 		vgaw(ba, GCT_ADDRESS_W , val);	\
    190       1.1   leo 	} while (0)
    191       1.1   leo 
    192       1.1   leo #define WSeq(ba, idx, val)			\
    193       1.1   leo 	do {					\
    194       1.1   leo 		vgaw(ba, SEQ_ADDRESS, idx);	\
    195       1.1   leo 		vgaw(ba, SEQ_ADDRESS_W , val);	\
    196       1.1   leo 	} while (0)
    197       1.1   leo 
    198       1.1   leo #define WCrt(ba, idx, val)			\
    199       1.1   leo 	do {					\
    200       1.1   leo 		vgaw(ba, CRT_ADDRESS, idx);	\
    201       1.1   leo 		vgaw(ba, CRT_ADDRESS_W , val);	\
    202       1.1   leo 	} while (0)
    203       1.1   leo 
    204       1.1   leo #define WIma(ba, idx, val)			\
    205       1.1   leo 	do {					\
    206       1.1   leo 		vgaw(ba, IMA_ADDRESS, idx);	\
    207       1.1   leo 		vgaw(ba, IMA_ADDRESS_W , val);	\
    208       1.1   leo 	} while (0)
    209       1.1   leo 
    210       1.1   leo #define WAttr(ba, idx, val)			\
    211       1.1   leo 	do {					\
    212       1.1   leo 		if(vgar(ba, GREG_STATUS1_R))	\
    213       1.1   leo 			;			\
    214       1.1   leo 		vgaw(ba, ACT_ADDRESS_W, idx);	\
    215       1.1   leo 		vgaw(ba, ACT_ADDRESS_W, val);	\
    216       1.1   leo 	} while (0)
    217       1.1   leo 
    218  1.1.78.1  yamt static inline u_char RAttr(volatile void *ba, short idx) {
    219       1.1   leo 	if(vgar(ba, GREG_STATUS1_R))
    220       1.1   leo 		;
    221       1.1   leo 	vgaw(ba, ACT_ADDRESS_W, idx);
    222       1.1   leo 	return vgar(ba, ACT_ADDRESS_R);
    223       1.1   leo }
    224       1.1   leo 
    225  1.1.78.1  yamt static inline u_char RSeq(volatile void *ba, short idx) {
    226       1.1   leo 	vgaw(ba, SEQ_ADDRESS, idx);
    227       1.1   leo 	return vgar(ba, SEQ_ADDRESS_R);
    228       1.1   leo }
    229       1.1   leo 
    230  1.1.78.1  yamt static inline u_char RCrt(volatile void *ba, short idx) {
    231       1.1   leo 	vgaw(ba, CRT_ADDRESS, idx);
    232       1.1   leo 	return vgar(ba, CRT_ADDRESS_R);
    233       1.1   leo }
    234       1.1   leo 
    235  1.1.78.1  yamt static inline u_char RGfx(volatile void *ba, short idx) {
    236       1.1   leo 	vgaw(ba, GCT_ADDRESS, idx);
    237       1.1   leo 	return vgar(ba, GCT_ADDRESS_R);
    238       1.1   leo }
    239       1.1   leo 
    240       1.1   leo #endif /* _GRF_ETREG_H */
    241