Home | History | Annotate | Line # | Download | only in dev
itevar.h revision 1.6
      1 /*
      2  * Copyright (c) 1988 University of Utah.
      3  * Copyright (c) 1990 The Regents of the University of California.
      4  * All rights reserved.
      5  *
      6  * This code is derived from software contributed to Berkeley by
      7  * the Systems Programming Group of the University of Utah Computer
      8  * Science Department.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the University of
     21  *	California, Berkeley and its contributors.
     22  * 4. Neither the name of the University nor the names of its contributors
     23  *    may be used to endorse or promote products derived from this software
     24  *    without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     27  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     30  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     31  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     32  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     35  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     36  * SUCH DAMAGE.
     37  *
     38  * from: Utah $Hdr: itevar.h 1.1 90/07/09$
     39  *
     40  *	@(#)itevar.h	7.2 (Berkeley) 11/4/90
     41  *	$Id: itevar.h,v 1.6 1994/02/11 07:01:54 chopps Exp $
     42  */
     43 
     44 #define UNIT(dev)       minor(dev)
     45 
     46 struct itesw {
     47 	int	(*ite_init)();
     48 	int	(*ite_deinit)();
     49 	int	(*ite_clear)();
     50 	int	(*ite_putc)();
     51 	int	(*ite_cursor)();
     52 	int	(*ite_scroll)();
     53 };
     54 
     55 /* maximum number of argument characters (<CSI>33;34;3m for example) */
     56 #define ARGBUF_SIZE 256
     57 
     58 struct ite_softc {
     59 	int	flags;
     60 	int	type;
     61 	int	open_cnt;
     62 	struct grf_softc *grf;
     63 	void	*priv;
     64 	short	curx, cury;
     65 	short   cursorx, cursory;
     66 	u_char	*font;
     67 	u_char	*cursor;
     68 	u_char	font_lo, font_hi;
     69 	short	rows, cols;
     70 	short   cpl;
     71 	short	ftheight, ftwidth, ftbaseline, ftboldsmear;
     72 	short   attribute;
     73 	u_char	*attrbuf;
     74 	short	planemask;
     75 	short	pos;
     76 	char	imode, fpd, hold;
     77 	u_char  escape, cursor_opt, key_repeat;
     78 	/* not currently used, but maintained */
     79 	char	GL, GR, G0, G1, G2, G3;
     80 	char	linefeed_newline, auto_wrap;
     81 	char	cursor_appmode, keypad_appmode;
     82 	char	argbuf[ARGBUF_SIZE], *ap, *tabs;
     83 	char	emul_level, eightbit_C1;
     84 	int	top_margin, bottom_margin, inside_margins;
     85 	short	save_curx, save_cury, save_attribute;
     86 	/* needed by view code */
     87 	void    *view;
     88 };
     89 
     90 /* emulation levels: */
     91 #define EMUL_VT100	1
     92 #define EMUL_VT300_8	2
     93 #define EMUL_VT300_7	3
     94 
     95 /* Flags */
     96 #define ITE_ALIVE	0x01	/* hardware exists */
     97 #define ITE_INITED	0x02	/* device has been initialized */
     98 #define ITE_CONSOLE	0x04	/* device can be console */
     99 #define ITE_ISCONS	0x08	/* device is console */
    100 #define ITE_ACTIVE	0x10	/* device is being used as ITE */
    101 #define ITE_INGRF	0x20	/* device in use as non-ITE */
    102 
    103 /* Types - indices into itesw */
    104 #define ITE_CUSTOMCHIPS	0
    105 #define ITE_TIGA_A2410	1
    106 #define ITE_RETINA	2
    107 
    108 #ifdef DO_WEIRD_ATTRIBUTES
    109 #define attrloc(ip, y, x) \
    110 	(ip->attrbuf + ((y) * ip->cols) + (x))
    111 
    112 #define attrclr(ip, sy, sx, h, w) \
    113 	bzero(ip->attrbuf + ((sy) * ip->cols) + (sx), (h) * (w))
    114 
    115 #define attrmov(ip, sy, sx, dy, dx, h, w) \
    116 	bcopy(ip->attrbuf + ((sy) * ip->cols) + (sx), \
    117 	      ip->attrbuf + ((dy) * ip->cols) + (dx), \
    118 	      (h) * (w))
    119 
    120 #define attrtest(ip, attr) \
    121 	((* (u_char *) attrloc(ip, ip->cury, ip->curx)) & attr)
    122 
    123 #define attrset(ip, attr) \
    124 	((* (u_char *) attrloc(ip, ip->cury, ip->curx)) = attr)
    125 #else
    126 #define attrloc(ip, y, x) 0
    127 #define attrclr(ip, sy, sx, h, w)
    128 #define attrmov(ip, sy, sx, dy, dx, h, w)
    129 #define attrtest(ip, attr) 0
    130 #define attrset(ip, attr)
    131 #endif
    132 
    133 
    134 /*
    135  * X and Y location of character 'c' in the framebuffer, in pixels.
    136  */
    137 #define	charX(ip,c)	\
    138 	(((c) % (ip)->cpl) * (ip)->ftwidth + (ip)->fontx)
    139 
    140 #define	charY(ip,c)	\
    141 	(((c) / (ip)->cpl) * (ip)->ftheight + (ip)->fonty)
    142 
    143 /* Character attributes */
    144 #define ATTR_NOR        0x0             /* normal */
    145 #define	ATTR_INV	0x1		/* inverse */
    146 #define	ATTR_UL		0x2		/* underline */
    147 #define ATTR_BOLD	0x4		/* bold */
    148 #define ATTR_BLINK	0x8		/* blink */
    149 #define ATTR_ALL	(ATTR_INV | ATTR_UL|ATTR_BOLD|ATTR_BLINK)
    150 
    151 /* Keyboard attributes */
    152 #define ATTR_KPAD	0x80		/* keypad transmit */
    153 
    154 /* Replacement Rules */
    155 #define RR_CLEAR		0x0
    156 #define RR_COPY			0x3
    157 #define RR_XOR			0x6
    158 #define RR_COPYINVERTED  	0xc
    159 
    160 #define SCROLL_UP	0x01
    161 #define SCROLL_DOWN	0x02
    162 #define SCROLL_LEFT	0x03
    163 #define SCROLL_RIGHT	0x04
    164 #define DRAW_CURSOR	0x05
    165 #define ERASE_CURSOR    0x06
    166 #define MOVE_CURSOR	0x07
    167 #define START_CURSOROPT	0x08	/* at start of output. May disable cursor */
    168 #define END_CURSOROPT	0x09	/* at end, make sure cursor state is ok */
    169 
    170 /* special key codes */
    171 #define KBD_LEFT_SHIFT	0x60
    172 #define KBD_RIGHT_SHIFT	0x61
    173 #define KBD_CAPS_LOCK	0x62
    174 #define KBD_CTRL	0x63
    175 #define KBD_LEFT_ALT	0x64
    176 #define KBD_RIGHT_ALT	0x65
    177 #define KBD_LEFT_META	0x66
    178 #define KBD_RIGHT_META	0x67
    179 
    180 /* modifier map for use in itefilter() */
    181 #define KBD_MOD_LSHIFT	(1<<0)
    182 #define KBD_MOD_RSHIFT	(1<<1)
    183 #define KBD_MOD_SHIFT	(KBD_MOD_LSHIFT | KBD_MOD_RSHIFT)
    184 #define KBD_MOD_CTRL	(1<<2)
    185 #define KBD_MOD_LALT	(1<<3)
    186 #define KBD_MOD_RALT	(1<<4)
    187 #define KBD_MOD_ALT	(KBD_MOD_LALT | KBD_MOD_RALT)
    188 #define KBD_MOD_LMETA	(1<<5)
    189 #define KBD_MOD_RMETA	(1<<6)
    190 #define KBD_MOD_META	(KBD_MOD_LMETA | KBD_MOD_RMETA)
    191 #define KBD_MOD_CAPS	(1<<7)
    192 
    193 /* type for the second argument to itefilter(). Note that the
    194    driver doesn't support key-repeat for console-mode, since it can't use
    195    timeout() for polled I/O. */
    196 
    197 enum caller { ITEFILT_TTY, ITEFILT_CONSOLE, ITEFILT_REPEATER };
    198 
    199 #define	TABSIZE		8
    200 #define	TABEND(u)	(ite_tty[u]->t_winsize.ws_col - TABSIZE)
    201 
    202 #ifdef KERNEL
    203 extern	struct ite_softc ite_softc[];
    204 #endif
    205