1 /* $NetBSD: itevar.h,v 1.28 2009/03/18 16:00:11 cegger Exp $ */
4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * the Systems Programming Group of the University of Utah Computer
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * from: Utah $Hdr: itevar.h 1.15 92/12/20$
37 * @(#)itevar.h 8.1 (Berkeley) 6/10/93
40 * Copyright (c) 1988 University of Utah.
42 * This code is derived from software contributed to Berkeley by
43 * the Systems Programming Group of the University of Utah Computer
46 * Redistribution and use in source and binary forms, with or without
47 * modification, are permitted provided that the following conditions
49 * 1. Redistributions of source code must retain the above copyright
50 * notice, this list of conditions and the following disclaimer.
51 * 2. Redistributions in binary form must reproduce the above copyright
52 * notice, this list of conditions and the following disclaimer in the
53 * documentation and/or other materials provided with the distribution.
54 * 3. All advertising materials mentioning features or use of this software
55 * must display the following acknowledgement:
56 * This product includes software developed by the University of
57 * California, Berkeley and its contributors.
58 * 4. Neither the name of the University nor the names of its contributors
59 * may be used to endorse or promote products derived from this software
60 * without specific prior written permission.
62 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
63 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
64 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
65 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
66 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
67 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
74 * from: Utah $Hdr: itevar.h 1.15 92/12/20$
76 * @(#)itevar.h 8.1 (Berkeley) 6/10/93
80 #define ITEUNIT(dev) minor(dev)
82 #define getbyte(ip, offset) \
83 ((*(ip)->isw->ite_readbyte)(ip, offset))
85 #define getword(ip, offset) \
86 ((getbyte(ip, offset) << 8) | getbyte(ip, (offset) + 2))
88 #define writeglyph(ip, offset, fontbuf) \
89 ((*(ip)->isw->ite_writeglyph)((ip), (offset), (fontbuf)))
96 uint8_t *regbase
, *fbbase
;
98 short cursorx
, cursory
;
99 short cblankx
, cblanky
;
102 short dheight
, dwidth
;
103 short fbheight
, fbwidth
;
104 short ftheight
, ftwidth
;
110 char imode
, escape
, fpd
, hold
;
111 void * devdata
; /* display dependent data */
115 void (*ite_init
)(struct ite_data
*);
116 void (*ite_deinit
)(struct ite_data
*);
117 void (*ite_clear
)(struct ite_data
*, int, int, int, int);
118 void (*ite_putc
)(struct ite_data
*, int, int, int, int);
119 void (*ite_cursor
)(struct ite_data
*, int);
120 void (*ite_scroll
)(struct ite_data
*, int, int, int, int);
121 u_char (*ite_readbyte
)(struct ite_data
*, int);
122 void (*ite_writeglyph
)(struct ite_data
*, volatile u_char
*, u_char
*);
126 device_t sc_dev
; /* generic device info */
127 struct ite_data
*sc_data
; /* terminal state info */
128 struct grf_softc
*sc_grf
; /* pointer to framebuffer */
133 #define ITE_ALIVE 0x01 /* hardware exists */
134 #define ITE_INITED 0x02 /* device has been initialized */
135 #define ITE_CONSOLE 0x04 /* device can be console */
136 #define ITE_ISCONS 0x08 /* device is console */
137 #define ITE_ACTIVE 0x10 /* device is being used as ITE */
138 #define ITE_INGRF 0x20 /* device in use as non-ITE */
139 #define ITE_CURSORON 0x40 /* cursor being tracked */
141 #define attrloc(ip, y, x) \
142 (ip->attrbuf + ((y) * ip->cols) + (x))
144 #define attrclr(ip, sy, sx, h, w) \
145 memset(ip->attrbuf + ((sy) * ip->cols) + (sx), 0, (h) * (w))
147 #define attrmov(ip, sy, sx, dy, dx, h, w) \
148 memmove(ip->attrbuf + ((dy) * ip->cols) + (dx), \
149 ip->attrbuf + ((sy) * ip->cols) + (sx), \
152 #define attrtest(ip, attr) \
153 ((* (u_char *) attrloc(ip, ip->cury, ip->curx)) & attr)
155 #define attrset(ip, attr) \
156 ((* (u_char *) attrloc(ip, ip->cury, ip->curx)) = attr)
159 * X and Y location of character 'c' in the framebuffer, in pixels.
161 #define charX(ip,c) \
162 (((c) % (ip)->cpl) * (ip)->ftwidth + (ip)->fontx)
164 #define charY(ip,c) \
165 (((c) / (ip)->cpl) * (ip)->ftheight + (ip)->fonty)
168 * The cursor is just an inverted space.
170 #define draw_cursor(ip) { \
171 WINDOWMOVER(ip, ip->cblanky, ip->cblankx, \
172 ip->cury * ip->ftheight, \
173 ip->curx * ip->ftwidth, \
174 ip->ftheight, ip->ftwidth, RR_XOR); \
175 ip->cursorx = ip->curx; \
176 ip->cursory = ip->cury; }
178 #define erase_cursor(ip) \
179 WINDOWMOVER(ip, ip->cblanky, ip->cblankx, \
180 ip->cursory * ip->ftheight, \
181 ip->cursorx * ip->ftwidth, \
182 ip->ftheight, ip->ftwidth, RR_XOR);
184 /* Character attributes */
185 #define ATTR_NOR 0x0 /* normal */
186 #define ATTR_INV 0x1 /* inverse */
187 #define ATTR_UL 0x2 /* underline */
188 #define ATTR_ALL (ATTR_INV | ATTR_UL)
190 /* Keyboard attributes */
191 #define ATTR_KPAD 0x4 /* keypad transmit */
193 /* Replacement Rules */
197 #define RR_COPYINVERTED 0xc
199 #define SCROLL_UP 0x01
200 #define SCROLL_DOWN 0x02
201 #define SCROLL_LEFT 0x03
202 #define SCROLL_RIGHT 0x04
203 #define DRAW_CURSOR 0x05
204 #define ERASE_CURSOR 0x06
205 #define MOVE_CURSOR 0x07
207 #define KBD_SSHIFT 4 /* bits to shift status */
208 #define KBD_CHARMASK 0x7F
210 /* keyboard status */
211 #define KBD_SMASK 0xF /* service request status mask */
212 #define KBD_CTRLSHIFT 0x8 /* key + CTRL + SHIFT */
213 #define KBD_CTRL 0x9 /* key + CTRL */
214 #define KBD_SHIFT 0xA /* key + SHIFT */
215 #define KBD_KEY 0xB /* key only */
217 #define KBD_CAPSLOCK 0x18
219 #define KBD_EXT_LEFT_DOWN 0x12
220 #define KBD_EXT_LEFT_UP 0x92
221 #define KBD_EXT_RIGHT_DOWN 0x13
222 #define KBD_EXT_RIGHT_UP 0x93
226 (((ip)->tty ? (ip)->tty->t_winsize.ws_col : (ip)->cols) - TABSIZE)
232 void (*enable
)(void *);
233 void (*bell
)(void *);
243 /* ite.c prototypes */
244 int iteon(struct ite_data
*, int);
245 void iteoff(struct ite_data
*, int);
246 void iteinstallkeymap(void *);
247 void itefilter(char, char);
249 void itedisplaycnattach(struct grf_data
*, struct itesw
*);
250 void itekbdcnattach(struct ite_kbdops
*, struct ite_kbdmap
*);
251 void itecninit(void);
252 int itecngetc(dev_t
);
253 void itecnputc(dev_t
, int);
255 /* ite_subr.c prototypes */
256 void ite_fontinfo(struct ite_data
*);
257 void ite_fontinit(struct ite_data
*);
258 u_char
ite_readbyte(struct ite_data
*, int);
259 void ite_writeglyph(struct ite_data
*, volatile u_char
*, u_char
*);