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