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