Home | History | Annotate | Line # | Download | only in common
itevar.h revision 1.2
      1 /*	$NetBSD: itevar.h,v 1.2 2003/08/07 16:27:42 agc Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1990, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  *
      7  * This code is derived from software contributed to Berkeley by
      8  * the Systems Programming Group of the University of Utah Computer
      9  * Science Department.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. Neither the name of the University nor the names of its contributors
     20  *    may be used to endorse or promote products derived from this software
     21  *    without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  * SUCH DAMAGE.
     34  *
     35  * from: Utah $Hdr: itevar.h 1.15 92/12/20$
     36  *
     37  *	@(#)itevar.h	8.1 (Berkeley) 6/10/93
     38  */
     39 /*
     40  * Copyright (c) 1988 University of Utah.
     41  *
     42  * This code is derived from software contributed to Berkeley by
     43  * the Systems Programming Group of the University of Utah Computer
     44  * Science Department.
     45  *
     46  * Redistribution and use in source and binary forms, with or without
     47  * modification, are permitted provided that the following conditions
     48  * are met:
     49  * 1. Redistributions of source code must retain the above copyright
     50  *    notice, this list of conditions and the following disclaimer.
     51  * 2. Redistributions in binary form must reproduce the above copyright
     52  *    notice, this list of conditions and the following disclaimer in the
     53  *    documentation and/or other materials provided with the distribution.
     54  * 3. All advertising materials mentioning features or use of this software
     55  *    must display the following acknowledgement:
     56  *	This product includes software developed by the University of
     57  *	California, Berkeley and its contributors.
     58  * 4. Neither the name of the University nor the names of its contributors
     59  *    may be used to endorse or promote products derived from this software
     60  *    without specific prior written permission.
     61  *
     62  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     63  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     64  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     65  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     66  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     67  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     68  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     69  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     70  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     71  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     72  * SUCH DAMAGE.
     73  *
     74  * from: Utah $Hdr: itevar.h 1.15 92/12/20$
     75  *
     76  *	@(#)itevar.h	8.1 (Berkeley) 6/10/93
     77  */
     78 
     79 /*
     80  * Standalone version of hp300 ITE.
     81  */
     82 
     83 #define ITEUNIT(dev)       minor(dev)
     84 
     85 #define getbyte(ip, offset) \
     86 	((*(ip)->isw->ite_readbyte)(ip, offset))
     87 
     88 #define getword(ip, offset) \
     89 	((getbyte(ip, offset) << 8) | getbyte(ip, (offset) + 2))
     90 
     91 #define writeglyph(ip, offset, fontbuf) \
     92 	((*(ip)->isw->ite_writeglyph)((ip), (offset), (fontbuf)))
     93 
     94 struct ite_data {
     95 	int	flags;
     96 	struct	tty *tty;
     97 	struct  itesw *isw;
     98 	struct  grf_data *grf;
     99 	caddr_t regbase, fbbase;
    100 	short	curx, cury;
    101 	short   cursorx, cursory;
    102 	short   cblankx, cblanky;
    103 	short	rows, cols;
    104 	short   cpl;
    105 	short	dheight, dwidth;
    106 	short	fbheight, fbwidth;
    107 	short	ftheight, ftwidth;
    108 	short	fontx, fonty;
    109 	short   attribute;
    110 	u_char	*attrbuf;
    111 	short	planemask;
    112 	short	pos;
    113 	char	imode, escape, fpd, hold;
    114 	caddr_t	devdata;			/* display dependent data */
    115 };
    116 
    117 struct itesw {
    118 	int	ite_hwid;
    119 	void	(*ite_init) __P((struct ite_data *));
    120 	void	(*ite_deinit) __P((struct ite_data *));
    121 	void	(*ite_clear) __P((struct ite_data *, int, int, int, int));
    122 	void	(*ite_putc) __P((struct ite_data *, int, int, int, int));
    123 	void	(*ite_cursor) __P((struct ite_data *, int));
    124 	void	(*ite_scroll) __P((struct ite_data *, int, int, int, int));
    125 	u_char	(*ite_readbyte) __P((struct ite_data *, int));
    126 	void	(*ite_writeglyph) __P((struct ite_data *, u_char *, u_char *));
    127 };
    128 
    129 /* Flags */
    130 #define ITE_ALIVE	0x01	/* hardware exists */
    131 #define ITE_INITED	0x02	/* device has been initialized */
    132 #define ITE_CONSOLE	0x04	/* device can be console */
    133 #define ITE_ISCONS	0x08	/* device is console */
    134 #define ITE_ACTIVE	0x10	/* device is being used as ITE */
    135 #define ITE_INGRF	0x20	/* device in use as non-ITE */
    136 #define ITE_CURSORON	0x40	/* cursor being tracked */
    137 
    138 #define attrloc(ip, y, x) \
    139 	(ip->attrbuf + ((y) * ip->cols) + (x))
    140 
    141 #define attrclr(ip, sy, sx, h, w) \
    142 	bzero(ip->attrbuf + ((sy) * ip->cols) + (sx), (h) * (w))
    143 
    144 #define attrmov(ip, sy, sx, dy, dx, h, w) \
    145 	bcopy(ip->attrbuf + ((sy) * ip->cols) + (sx), \
    146 	      ip->attrbuf + ((dy) * ip->cols) + (dx), \
    147 	      (h) * (w))
    148 
    149 #define attrtest(ip, attr) \
    150 	((* (u_char *) attrloc(ip, ip->cury, ip->curx)) & attr)
    151 
    152 #define attrset(ip, attr) \
    153 	((* (u_char *) attrloc(ip, ip->cury, ip->curx)) = attr)
    154 
    155 /*
    156  * X and Y location of character 'c' in the framebuffer, in pixels.
    157  */
    158 #define	charX(ip,c)	\
    159 	(((c) % (ip)->cpl) * (ip)->ftwidth + (ip)->fontx)
    160 
    161 #define	charY(ip,c)	\
    162 	(((c) / (ip)->cpl) * (ip)->ftheight + (ip)->fonty)
    163 
    164 /*
    165  * The cursor is just an inverted space.
    166  */
    167 #define draw_cursor(ip) { \
    168 	WINDOWMOVER(ip, ip->cblanky, ip->cblankx, \
    169 		    ip->cury * ip->ftheight, \
    170 		    ip->curx * ip->ftwidth, \
    171 		    ip->ftheight, ip->ftwidth, RR_XOR); \
    172         ip->cursorx = ip->curx; \
    173 	ip->cursory = ip->cury; }
    174 
    175 #define erase_cursor(ip) \
    176   	WINDOWMOVER(ip, ip->cblanky, ip->cblankx, \
    177 		    ip->cursory * ip->ftheight, \
    178 		    ip->cursorx * ip->ftwidth, \
    179 		    ip->ftheight, ip->ftwidth, RR_XOR);
    180 
    181 /* Character attributes */
    182 #define ATTR_NOR        0x0             /* normal */
    183 #define	ATTR_INV	0x1		/* inverse */
    184 #define	ATTR_UL		0x2		/* underline */
    185 #define ATTR_ALL	(ATTR_INV | ATTR_UL)
    186 
    187 /* Keyboard attributes */
    188 #define ATTR_KPAD	0x4		/* keypad transmit */
    189 
    190 /* Replacement Rules */
    191 #define RR_CLEAR		0x0
    192 #define RR_COPY			0x3
    193 #define RR_XOR			0x6
    194 #define RR_COPYINVERTED  	0xc
    195 
    196 #define SCROLL_UP	0x01
    197 #define SCROLL_DOWN	0x02
    198 #define SCROLL_LEFT	0x03
    199 #define SCROLL_RIGHT	0x04
    200 #define DRAW_CURSOR	0x05
    201 #define ERASE_CURSOR    0x06
    202 #define MOVE_CURSOR	0x07
    203 
    204 #define KBD_SSHIFT	4		/* bits to shift status */
    205 #define	KBD_CHARMASK	0x7F
    206 
    207 /* keyboard status */
    208 #define	KBD_SMASK	0xF		/* service request status mask */
    209 #define	KBD_CTRLSHIFT	0x8		/* key + CTRL + SHIFT */
    210 #define	KBD_CTRL	0x9		/* key + CTRL */
    211 #define	KBD_SHIFT	0xA		/* key + SHIFT */
    212 #define	KBD_KEY		0xB		/* key only */
    213 
    214 #define KBD_CAPSLOCK    0x18
    215 
    216 #define KBD_EXT_LEFT_DOWN     0x12
    217 #define KBD_EXT_LEFT_UP       0x92
    218 #define KBD_EXT_RIGHT_DOWN    0x13
    219 #define KBD_EXT_RIGHT_UP      0x93
    220 
    221 #define	TABSIZE		8
    222 #define	TABEND(ip)	((ip)->tty->t_winsize.ws_col - TABSIZE)
    223 
    224 extern	struct ite_data ite_data[];
    225 extern	struct itesw itesw[];
    226 extern	int nitesw;
    227 
    228 /*
    229  * Prototypes.
    230  */
    231 u_char	ite_readbyte __P((struct ite_data *, int));
    232 void	ite_writeglyph __P((struct ite_data *, u_char *, u_char *));
    233 
    234 /*
    235  * Framebuffer-specific ITE prototypes.
    236  */
    237 void	topcat_init __P((struct ite_data *));
    238 void	topcat_clear __P((struct ite_data *, int, int, int, int));
    239 void	topcat_putc __P((struct ite_data *, int, int, int, int));
    240 void	topcat_cursor __P((struct ite_data *, int));
    241 void	topcat_scroll __P((struct ite_data *, int, int, int, int));
    242 
    243 void	gbox_init __P((struct ite_data *));
    244 void	gbox_clear __P((struct ite_data *, int, int, int, int));
    245 void	gbox_putc __P((struct ite_data *, int, int, int, int));
    246 void	gbox_cursor __P((struct ite_data *, int));
    247 void	gbox_scroll __P((struct ite_data *, int, int, int, int));
    248 
    249 void	rbox_init __P((struct ite_data *));
    250 void	rbox_clear __P((struct ite_data *, int, int, int, int));
    251 void	rbox_putc __P((struct ite_data *, int, int, int, int));
    252 void	rbox_cursor __P((struct ite_data *, int));
    253 void	rbox_scroll __P((struct ite_data *, int, int, int, int));
    254 
    255 void	dvbox_init __P((struct ite_data *));
    256 void	dvbox_clear __P((struct ite_data *, int, int, int, int));
    257 void	dvbox_putc __P((struct ite_data *, int, int, int, int));
    258 void	dvbox_cursor __P((struct ite_data *, int));
    259 void	dvbox_scroll __P((struct ite_data *, int, int, int, int));
    260 
    261 void	hyper_init __P((struct ite_data *));
    262 void	hyper_clear __P((struct ite_data *, int, int, int, int));
    263 void	hyper_putc __P((struct ite_data *, int, int, int, int));
    264 void	hyper_cursor __P((struct ite_data *, int));
    265 void	hyper_scroll __P((struct ite_data *, int, int, int, int));
    266