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