itevar.h revision 1.1 1 /* $NetBSD: itevar.h,v 1.1 1997/02/04 03:52:38 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 1988 University of Utah.
5 * Copyright (c) 1990, 1993
6 * The Regents of the University of California. 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.15 92/12/20$
41 *
42 * @(#)itevar.h 8.1 (Berkeley) 6/10/93
43 */
44
45 /*
46 * Standalone version of hp300 ITE.
47 */
48
49 #define ITEUNIT(dev) minor(dev)
50
51 #define getbyte(ip, offset) \
52 ((*(ip)->isw->ite_readbyte)(ip, offset))
53
54 #define getword(ip, offset) \
55 ((getbyte(ip, offset) << 8) | getbyte(ip, (offset) + 2))
56
57 #define writeglyph(ip, offset, fontbuf) \
58 ((*(ip)->isw->ite_writeglyph)((ip), (offset), (fontbuf)))
59
60 struct ite_data {
61 int flags;
62 struct tty *tty;
63 struct itesw *isw;
64 struct grf_data *grf;
65 caddr_t regbase, fbbase;
66 short curx, cury;
67 short cursorx, cursory;
68 short cblankx, cblanky;
69 short rows, cols;
70 short cpl;
71 short dheight, dwidth;
72 short fbheight, fbwidth;
73 short ftheight, ftwidth;
74 short fontx, fonty;
75 short attribute;
76 u_char *attrbuf;
77 short planemask;
78 short pos;
79 char imode, escape, fpd, hold;
80 caddr_t devdata; /* display dependent data */
81 };
82
83 struct itesw {
84 int ite_hwid;
85 void (*ite_init) __P((struct ite_data *));
86 void (*ite_deinit) __P((struct ite_data *));
87 void (*ite_clear) __P((struct ite_data *, int, int, int, int));
88 void (*ite_putc) __P((struct ite_data *, int, int, int, int));
89 void (*ite_cursor) __P((struct ite_data *, int));
90 void (*ite_scroll) __P((struct ite_data *, int, int, int, int));
91 u_char (*ite_readbyte) __P((struct ite_data *, int));
92 void (*ite_writeglyph) __P((struct ite_data *, u_char *, u_char *));
93 };
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 #define ITE_CURSORON 0x40 /* cursor being tracked */
103
104 #define attrloc(ip, y, x) \
105 (ip->attrbuf + ((y) * ip->cols) + (x))
106
107 #define attrclr(ip, sy, sx, h, w) \
108 bzero(ip->attrbuf + ((sy) * ip->cols) + (sx), (h) * (w))
109
110 #define attrmov(ip, sy, sx, dy, dx, h, w) \
111 bcopy(ip->attrbuf + ((sy) * ip->cols) + (sx), \
112 ip->attrbuf + ((dy) * ip->cols) + (dx), \
113 (h) * (w))
114
115 #define attrtest(ip, attr) \
116 ((* (u_char *) attrloc(ip, ip->cury, ip->curx)) & attr)
117
118 #define attrset(ip, attr) \
119 ((* (u_char *) attrloc(ip, ip->cury, ip->curx)) = attr)
120
121 /*
122 * X and Y location of character 'c' in the framebuffer, in pixels.
123 */
124 #define charX(ip,c) \
125 (((c) % (ip)->cpl) * (ip)->ftwidth + (ip)->fontx)
126
127 #define charY(ip,c) \
128 (((c) / (ip)->cpl) * (ip)->ftheight + (ip)->fonty)
129
130 /*
131 * The cursor is just an inverted space.
132 */
133 #define draw_cursor(ip) { \
134 WINDOWMOVER(ip, ip->cblanky, ip->cblankx, \
135 ip->cury * ip->ftheight, \
136 ip->curx * ip->ftwidth, \
137 ip->ftheight, ip->ftwidth, RR_XOR); \
138 ip->cursorx = ip->curx; \
139 ip->cursory = ip->cury; }
140
141 #define erase_cursor(ip) \
142 WINDOWMOVER(ip, ip->cblanky, ip->cblankx, \
143 ip->cursory * ip->ftheight, \
144 ip->cursorx * ip->ftwidth, \
145 ip->ftheight, ip->ftwidth, RR_XOR);
146
147 /* Character attributes */
148 #define ATTR_NOR 0x0 /* normal */
149 #define ATTR_INV 0x1 /* inverse */
150 #define ATTR_UL 0x2 /* underline */
151 #define ATTR_ALL (ATTR_INV | ATTR_UL)
152
153 /* Keyboard attributes */
154 #define ATTR_KPAD 0x4 /* keypad transmit */
155
156 /* Replacement Rules */
157 #define RR_CLEAR 0x0
158 #define RR_COPY 0x3
159 #define RR_XOR 0x6
160 #define RR_COPYINVERTED 0xc
161
162 #define SCROLL_UP 0x01
163 #define SCROLL_DOWN 0x02
164 #define SCROLL_LEFT 0x03
165 #define SCROLL_RIGHT 0x04
166 #define DRAW_CURSOR 0x05
167 #define ERASE_CURSOR 0x06
168 #define MOVE_CURSOR 0x07
169
170 #define KBD_SSHIFT 4 /* bits to shift status */
171 #define KBD_CHARMASK 0x7F
172
173 /* keyboard status */
174 #define KBD_SMASK 0xF /* service request status mask */
175 #define KBD_CTRLSHIFT 0x8 /* key + CTRL + SHIFT */
176 #define KBD_CTRL 0x9 /* key + CTRL */
177 #define KBD_SHIFT 0xA /* key + SHIFT */
178 #define KBD_KEY 0xB /* key only */
179
180 #define KBD_CAPSLOCK 0x18
181
182 #define KBD_EXT_LEFT_DOWN 0x12
183 #define KBD_EXT_LEFT_UP 0x92
184 #define KBD_EXT_RIGHT_DOWN 0x13
185 #define KBD_EXT_RIGHT_UP 0x93
186
187 #define TABSIZE 8
188 #define TABEND(ip) ((ip)->tty->t_winsize.ws_col - TABSIZE)
189
190 extern struct ite_data ite_data[];
191 extern struct itesw itesw[];
192 extern int nitesw;
193
194 /*
195 * Prototypes.
196 */
197 u_char ite_readbyte __P((struct ite_data *, int));
198 void ite_writeglyph __P((struct ite_data *, u_char *, u_char *));
199
200 /*
201 * Framebuffer-specific ITE prototypes.
202 */
203 void topcat_init __P((struct ite_data *));
204 void topcat_clear __P((struct ite_data *, int, int, int, int));
205 void topcat_putc __P((struct ite_data *, int, int, int, int));
206 void topcat_cursor __P((struct ite_data *, int));
207 void topcat_scroll __P((struct ite_data *, int, int, int, int));
208
209 void gbox_init __P((struct ite_data *));
210 void gbox_clear __P((struct ite_data *, int, int, int, int));
211 void gbox_putc __P((struct ite_data *, int, int, int, int));
212 void gbox_cursor __P((struct ite_data *, int));
213 void gbox_scroll __P((struct ite_data *, int, int, int, int));
214
215 void rbox_init __P((struct ite_data *));
216 void rbox_clear __P((struct ite_data *, int, int, int, int));
217 void rbox_putc __P((struct ite_data *, int, int, int, int));
218 void rbox_cursor __P((struct ite_data *, int));
219 void rbox_scroll __P((struct ite_data *, int, int, int, int));
220
221 void dvbox_init __P((struct ite_data *));
222 void dvbox_clear __P((struct ite_data *, int, int, int, int));
223 void dvbox_putc __P((struct ite_data *, int, int, int, int));
224 void dvbox_cursor __P((struct ite_data *, int));
225 void dvbox_scroll __P((struct ite_data *, int, int, int, int));
226
227 void hyper_init __P((struct ite_data *));
228 void hyper_clear __P((struct ite_data *, int, int, int, int));
229 void hyper_putc __P((struct ite_data *, int, int, int, int));
230 void hyper_cursor __P((struct ite_data *, int));
231 void hyper_scroll __P((struct ite_data *, int, int, int, int));
232