Home | History | Annotate | Line # | Download | only in dev
itevar.h revision 1.1.1.1
      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  */
     42 
     43 #define UNIT(dev)       minor(dev)
     44 
     45 struct ite_softc;
     46 
     47 struct itesw {
     48 	int	(*ite_cnprobe) __P((int minor));
     49 	void	(*ite_init) __P((struct ite_softc *));
     50 	void	(*ite_deinit) __P((struct ite_softc *));
     51 	void	(*ite_clear) __P((struct ite_softc *,int,int,int,int));
     52 	void	(*ite_putc) __P((struct ite_softc *,int,int,int,int));
     53 	void	(*ite_cursor) __P((struct ite_softc *,int));
     54 	void	(*ite_scroll) __P((struct ite_softc *,int,int,int,int));
     55 };
     56 
     57 enum ite_arraymaxs {
     58 	MAX_ARGSIZE = 256,
     59 	MAX_TABS = 256,
     60 };
     61 
     62 /* maximum number of argument characters (<CSI>33;34;3m for example) */
     63 #define ARGBUF_SIZE 256
     64 
     65 struct ite_softc {
     66 	struct	device device;
     67 	struct grf_softc *grf;
     68 	struct	itesw *isw;
     69 	int	flags;
     70 	int	type;
     71 	int	open_cnt;
     72 	void	*priv;
     73 	short	curx, cury;
     74 	short   cursorx, cursory;
     75 	u_char	*font;
     76 	u_char	*cursor;
     77 	u_char	font_lo, font_hi;
     78 	short	rows, cols;
     79 	short   cpl;
     80 	short	ftheight, ftwidth, ftbaseline, ftboldsmear;
     81 	short   attribute;
     82 	u_char	*attrbuf;
     83 	short	planemask;
     84 	short	pos;
     85 	char	imode, fpd, hold;
     86 	u_char  escape, cursor_opt, key_repeat;
     87 	char	*GL, *GR, *save_GL;
     88 	char	G0, G1, G2, G3;
     89 	char	fgcolor, bgcolor;
     90 	char	linefeed_newline, auto_wrap;
     91 	char	cursor_appmode, keypad_appmode;
     92 	char	argbuf[ARGBUF_SIZE], *ap, *tabs;
     93 	char	emul_level, eightbit_C1;
     94 	int	top_margin, bottom_margin;
     95 	char	inside_margins, sc_om;
     96 	short	save_curx, save_cury, save_attribute, save_char;
     97 	char	sc_G0, sc_G1, sc_G2, sc_G3;
     98 	char	*sc_GL, *sc_GR;
     99 };
    100 
    101 enum emul_level {
    102 	EMUL_VT100 = 1,
    103 	EMUL_VT300_8,
    104 	EMUL_VT300_7
    105 };
    106 
    107 /* Flags */
    108 #define ITE_ALIVE	0x01	/* hardware exists */
    109 #define ITE_INITED	0x02	/* device has been initialized */
    110 #define ITE_CONSOLE	0x04	/* device can be console */
    111 #define ITE_ISCONS	0x08	/* device is console */
    112 #define ITE_ACTIVE	0x10	/* device is being used as ITE */
    113 #define ITE_INGRF	0x20	/* device in use as non-ITE */
    114 
    115 #ifdef DO_WEIRD_ATTRIBUTES
    116 #define attrloc(ip, y, x) \
    117 	(ip->attrbuf + ((y) * ip->cols) + (x))
    118 
    119 #define attrclr(ip, sy, sx, h, w) \
    120 	bzero(ip->attrbuf + ((sy) * ip->cols) + (sx), (h) * (w))
    121 
    122 #define attrmov(ip, sy, sx, dy, dx, h, w) \
    123 	bcopy(ip->attrbuf + ((sy) * ip->cols) + (sx), \
    124 	      ip->attrbuf + ((dy) * ip->cols) + (dx), \
    125 	      (h) * (w))
    126 
    127 #define attrtest(ip, attr) \
    128 	((* (u_char *) attrloc(ip, ip->cury, ip->curx)) & attr)
    129 
    130 #define attrset(ip, attr) \
    131 	((* (u_char *) attrloc(ip, ip->cury, ip->curx)) = attr)
    132 #else
    133 #define attrloc(ip, y, x) 0
    134 #define attrclr(ip, sy, sx, h, w)
    135 #define attrmov(ip, sy, sx, dy, dx, h, w)
    136 #define attrtest(ip, attr) 0
    137 #define attrset(ip, attr)
    138 #endif
    139 
    140 
    141 /*
    142  * X and Y location of character 'c' in the framebuffer, in pixels.
    143  */
    144 #define	charX(ip,c)	\
    145 	(((c) % (ip)->cpl) * (ip)->ftwidth + (ip)->fontx)
    146 
    147 #define	charY(ip,c)	\
    148 	(((c) / (ip)->cpl) * (ip)->ftheight + (ip)->fonty)
    149 
    150 /* Character attributes */
    151 #define ATTR_NOR        0x0             /* normal */
    152 #define	ATTR_INV	0x1		/* inverse */
    153 #define	ATTR_UL		0x2		/* underline */
    154 #define ATTR_BOLD	0x4		/* bold */
    155 #define ATTR_BLINK	0x8		/* blink */
    156 #define ATTR_ALL	(ATTR_INV | ATTR_UL|ATTR_BOLD|ATTR_BLINK)
    157 
    158 /* Keyboard attributes */
    159 #define ATTR_KPAD	0x80		/* keypad transmit */
    160 
    161 /* Replacement Rules */
    162 #define RR_CLEAR		0x0
    163 #define RR_COPY			0x3
    164 #define RR_XOR			0x6
    165 #define RR_COPYINVERTED  	0xc
    166 
    167 #define SCROLL_UP	0x01
    168 #define SCROLL_DOWN	0x02
    169 #define SCROLL_LEFT	0x03
    170 #define SCROLL_RIGHT	0x04
    171 #define DRAW_CURSOR	0x05
    172 #define ERASE_CURSOR    0x06
    173 #define MOVE_CURSOR	0x07
    174 #define START_CURSOROPT	0x08	/* at start of output. May disable cursor */
    175 #define END_CURSOROPT	0x09	/* at end, make sure cursor state is ok */
    176 
    177 /* special key codes */
    178 #define KBD_LEFT_SHIFT	0x70
    179 #define KBD_RIGHT_SHIFT	0x70
    180 #define KBD_CAPS_LOCK	0x5d
    181 #define KBD_CTRL	0x71
    182 #define KBD_LEFT_ALT	0x55
    183 #define KBD_RIGHT_ALT	0x58
    184 #define KBD_LEFT_META	0x56
    185 #define KBD_RIGHT_META	0x57
    186 #define KBD_OPT1	0x72
    187 #define KBD_OPT2	0x73
    188 #define KBD_RECONNECT	0x7f
    189 
    190 /* modifier map for use in itefilter() */
    191 #define KBD_MOD_LSHIFT	(1<<0)
    192 #define KBD_MOD_RSHIFT	(1<<1)
    193 #define KBD_MOD_SHIFT	(KBD_MOD_LSHIFT | KBD_MOD_RSHIFT)
    194 #define KBD_MOD_CTRL	(1<<2)
    195 #define KBD_MOD_LALT	(1<<3)
    196 #define KBD_MOD_RALT	(1<<4)
    197 #define KBD_MOD_ALT	(KBD_MOD_LALT | KBD_MOD_RALT)
    198 #define KBD_MOD_LMETA	(1<<5)
    199 #define KBD_MOD_RMETA	(1<<6)
    200 #define KBD_MOD_META	(KBD_MOD_LMETA | KBD_MOD_RMETA)
    201 #define KBD_MOD_CAPS	(1<<7)
    202 #define KBD_MOD_OPT1	(1<<8)
    203 #define KBD_MOD_OPT2	(1<<9)
    204 
    205 /* type for the second argument to itefilter(). Note that the
    206    driver doesn't support key-repeat for console-mode, since it can't use
    207    timeout() for polled I/O. */
    208 
    209 enum caller { ITEFILT_TTY, ITEFILT_CONSOLE, ITEFILT_REPEATER };
    210 
    211 enum tab_size { TABSIZE = 8 };
    212 #define TABEND(u) (ite_tty[u]->t_windsize.ws_col - TABSIZE) /* XXX */
    213 
    214 #define set_attr(ip, attr)	((ip)->attribute |= (attr))
    215 #define clr_attr(ip, attr)	((ip)->attribute &= ~(attr))
    216 #define attrloc(ip, y, x) 0
    217 #define attrclr(ip, sy, sx, h, w)
    218 #define attrmov(ip, sy, sx, dy, dx, h, w)
    219 #define attrtest(ip, attr) 0
    220 #define attrset(ip, attr)
    221 
    222 /* character set */
    223 #define CSET_MULTI	0x80 /* multibytes flag */
    224 #define CSET_ASCII	0 /* ascii */
    225 #define CSET_JISROMA	1 /* iso2022jp romaji */
    226 #define CSET_JISKANA	2 /* iso2022jp kana */
    227 #define CSET_JIS1978	(3|CSET_MULTI) /* iso2022jp old jis kanji */
    228 #define CSET_JIS1983	(4|CSET_MULTI) /* iso2022jp new jis kanji */
    229 #define CSET_JIS1990	(5|CSET_MULTI) /* iso2022jp hojo kanji */
    230 
    231 struct consdev;
    232 
    233 /* console related function */
    234 void	itecnprobe __P((struct consdev *));
    235 void	itecninit __P((struct consdev *));
    236 int	itecngetc __P((dev_t));
    237 void	itecnputc __P((dev_t, int));
    238 void	itecnfinish __P((struct ite_softc *));
    239 
    240 /* standard ite device entry points. */
    241 void	iteinit __P((dev_t));
    242 int	iteopen __P((dev_t, int, int, struct proc *));
    243 int	iteclose __P((dev_t, int, int, struct proc *));
    244 int	iteread __P((dev_t, struct uio *, int));
    245 int	itewrite __P((dev_t, struct uio *, int));
    246 int	iteioctl __P((dev_t, u_long, caddr_t, int, struct proc *));
    247 void	itestart __P((struct tty *));
    248 
    249 /* ite functions */
    250 int	ite_on __P((dev_t, int));
    251 int	ite_off __P((dev_t, int));
    252 void	ite_reinit __P((dev_t));
    253 void	ite_reset __P((struct ite_softc *));
    254 int	ite_cnfilter __P((u_char, enum caller));
    255 void	ite_filter __P((u_char ,enum caller));
    256 
    257 /* lower layer functions */
    258 int	view_cnprobe __P((int));
    259 void	view_init __P((struct ite_softc *));
    260 void	view_deinit __P((struct ite_softc *));
    261 
    262 #ifdef _KERNEL
    263 extern	struct ite_softc ite_softc[];
    264 #if ITEKANJI
    265 extern unsigned char kern_font[];
    266 #endif
    267 #if x68k
    268 /* keyboard LED status variable */
    269 extern unsigned char kbdled;
    270 #endif
    271 #endif
    272