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