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