Commit | Line | Data |
---|---|---|
a8fd2d0d KM |
1 | /* |
2 | * Copyright (c) 1988 University of Utah. | |
ad787160 C |
3 | * Copyright (c) 1990, 1993 |
4 | * The Regents of the University of California. All rights reserved. | |
a8fd2d0d KM |
5 | * |
6 | * This code is derived from software contributed to Berkeley by | |
7 | * the Systems Programming Group of the University of Utah Computer | |
8 | * Science Department. | |
9 | * | |
ad787160 C |
10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | |
15 | * 2. Redistributions in binary form must reproduce the above copyright | |
16 | * notice, this list of conditions and the following disclaimer in the | |
17 | * documentation and/or other materials provided with the distribution. | |
18 | * 3. All advertising materials mentioning features or use of this software | |
19 | * must display the following acknowledgement: | |
20 | * This product includes software developed by the University of | |
21 | * California, Berkeley and its contributors. | |
22 | * 4. Neither the name of the University nor the names of its contributors | |
23 | * may be used to endorse or promote products derived from this software | |
24 | * without specific prior written permission. | |
a8fd2d0d | 25 | * |
ad787160 C |
26 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
27 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
28 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
29 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
30 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
31 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
32 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
35 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
36 | * SUCH DAMAGE. | |
a8fd2d0d | 37 | * |
ad787160 C |
38 | * from: Utah $Hdr: ite.c 1.24 93/06/25$ |
39 | * | |
40 | * @(#)ite.c 8.1 (Berkeley) 7/8/93 | |
a8fd2d0d KM |
41 | */ |
42 | ||
43 | /* | |
44 | * Standalone Internal Terminal Emulator (CRT and keyboard) | |
45 | */ | |
38a01dbe | 46 | #include <hp300/stand/samachdep.h> |
a8fd2d0d KM |
47 | |
48 | #ifdef ITECONSOLE | |
49 | ||
38a01dbe KB |
50 | #include <sys/param.h> |
51 | #include <hp/dev/cons.h> | |
52 | #include <hp/dev/device.h> | |
53 | #include <hp/dev/itevar.h> | |
54 | #include <hp/dev/grfreg.h> | |
33583b53 MH |
55 | |
56 | extern int nodev(); | |
57 | extern u_char ite_readbyte(); | |
58 | extern int ite_writeglyph(); | |
59 | ||
60 | extern int topcat_init(), topcat_putc(); | |
61 | extern int topcat_clear(), topcat_cursor(), topcat_scroll(); | |
62 | extern int gbox_init(), gbox_clear(); | |
63 | extern int gbox_putc(), gbox_cursor(), gbox_scroll(); | |
64 | extern int rbox_init(), rbox_clear(); | |
65 | extern int rbox_putc(), rbox_cursor(), rbox_scroll(); | |
66 | extern int dvbox_init(), dvbox_clear(); | |
67 | extern int dvbox_putc(), dvbox_cursor(), dvbox_scroll(); | |
68 | extern int hyper_init(), hyper_clear(); | |
69 | extern int hyper_putc(), hyper_cursor(), hyper_scroll(); | |
a8fd2d0d KM |
70 | |
71 | struct itesw itesw[] = { | |
33583b53 MH |
72 | GID_TOPCAT, |
73 | topcat_init, nodev, topcat_clear, topcat_putc, | |
74 | topcat_cursor, topcat_scroll, ite_readbyte, ite_writeglyph, | |
75 | GID_GATORBOX, | |
76 | gbox_init, nodev, gbox_clear, gbox_putc, | |
77 | gbox_cursor, gbox_scroll, ite_readbyte, ite_writeglyph, | |
78 | GID_RENAISSANCE, | |
79 | rbox_init, nodev, rbox_clear, rbox_putc, | |
80 | rbox_cursor, rbox_scroll, ite_readbyte, ite_writeglyph, | |
81 | GID_LRCATSEYE, | |
82 | topcat_init, nodev, topcat_clear, topcat_putc, | |
83 | topcat_cursor, topcat_scroll, ite_readbyte, ite_writeglyph, | |
84 | GID_HRCCATSEYE, | |
85 | topcat_init, nodev, topcat_clear, topcat_putc, | |
86 | topcat_cursor, topcat_scroll, ite_readbyte, ite_writeglyph, | |
87 | GID_HRMCATSEYE, | |
88 | topcat_init, nodev, topcat_clear, topcat_putc, | |
89 | topcat_cursor, topcat_scroll, ite_readbyte, ite_writeglyph, | |
90 | GID_DAVINCI, | |
91 | dvbox_init, nodev, dvbox_clear, dvbox_putc, | |
92 | dvbox_cursor, dvbox_scroll, ite_readbyte, ite_writeglyph, | |
93 | GID_HYPERION, | |
94 | hyper_init, nodev, hyper_clear, hyper_putc, | |
95 | hyper_cursor, hyper_scroll, ite_readbyte, ite_writeglyph, | |
a8fd2d0d | 96 | }; |
33583b53 | 97 | int nitesw = sizeof(itesw) / sizeof(itesw[0]); |
a8fd2d0d KM |
98 | |
99 | /* these guys need to be in initialized data */ | |
100 | int itecons = -1; | |
101 | struct ite_softc ite_softc[NITE] = { 0 }; | |
102 | ||
103 | /* | |
104 | * Locate all bitmapped displays | |
105 | */ | |
106 | iteconfig() | |
107 | { | |
108 | extern struct hp_hw sc_table[]; | |
109 | int dtype, fboff, i; | |
110 | struct hp_hw *hw; | |
111 | struct grfreg *gr; | |
112 | struct ite_softc *ip; | |
113 | ||
114 | i = 0; | |
2bb0988c MH |
115 | for (hw = sc_table; hw < &sc_table[MAXCTLRS]; hw++) { |
116 | if (!HW_ISDEV(hw, D_BITMAP)) | |
a8fd2d0d | 117 | continue; |
2bb0988c | 118 | gr = (struct grfreg *) hw->hw_kva; |
a8fd2d0d KM |
119 | /* XXX: redundent but safe */ |
120 | if (badaddr((caddr_t)gr) || gr->gr_id != GRFHWID) | |
121 | continue; | |
33583b53 MH |
122 | for (dtype = 0; dtype < nitesw; dtype++) |
123 | if (itesw[dtype].ite_hwid == gr->gr_id2) | |
124 | break; | |
125 | if (dtype == nitesw) | |
a8fd2d0d | 126 | continue; |
a8fd2d0d KM |
127 | if (i >= NITE) |
128 | break; | |
129 | ip = &ite_softc[i]; | |
33583b53 | 130 | ip->isw = &itesw[dtype]; |
a8fd2d0d KM |
131 | ip->regbase = (caddr_t) gr; |
132 | fboff = (gr->gr_fbomsb << 8) | gr->gr_fbolsb; | |
133 | ip->fbbase = (caddr_t) (*((u_char *)ip->regbase+fboff) << 16); | |
134 | /* DIO II: FB offset is relative to select code space */ | |
2bb0988c | 135 | if (ip->regbase >= (caddr_t)DIOIIBASE) |
a8fd2d0d | 136 | ip->fbbase += (int)ip->regbase; |
33583b53 MH |
137 | ip->fbwidth = gr->gr_fbwidth_h << 8 | gr->gr_fbwidth_l; |
138 | ip->fbheight = gr->gr_fbheight_h << 8 | gr->gr_fbheight_l; | |
139 | ip->dwidth = gr->gr_dwidth_h << 8 | gr->gr_dwidth_l; | |
140 | ip->dheight = gr->gr_dheight_h << 8 | gr->gr_dheight_l; | |
ad787160 C |
141 | /* |
142 | * XXX some displays (e.g. the davinci) appear | |
143 | * to return a display height greater than the | |
144 | * returned FB height. Guess we should go back | |
145 | * to getting the display dimensions from the | |
146 | * fontrom... | |
147 | */ | |
148 | if (ip->dwidth > ip->fbwidth) | |
149 | ip->dwidth = ip->fbwidth; | |
150 | if (ip->dheight > ip->fbheight) | |
151 | ip->dheight = ip->fbheight; | |
a8fd2d0d | 152 | ip->flags = ITE_ALIVE|ITE_CONSOLE; |
a8fd2d0d KM |
153 | i++; |
154 | } | |
155 | } | |
156 | ||
157 | #ifdef CONSDEBUG | |
158 | /* | |
159 | * Allows us to cycle through all possible consoles (NITE ites and serial port) | |
160 | * by using SHIFT-RESET on the keyboard. | |
161 | */ | |
162 | int whichconsole = -1; | |
163 | #endif | |
164 | ||
165 | iteprobe(cp) | |
166 | struct consdev *cp; | |
167 | { | |
168 | register int ite; | |
169 | register struct ite_softc *ip; | |
170 | int unit, pri; | |
171 | ||
172 | #ifdef CONSDEBUG | |
173 | whichconsole = ++whichconsole % (NITE+1); | |
174 | #endif | |
175 | ||
176 | if (itecons != -1) | |
177 | return(1); | |
178 | ||
179 | iteconfig(); | |
180 | unit = -1; | |
181 | pri = CN_DEAD; | |
182 | for (ite = 0; ite < NITE; ite++) { | |
183 | #ifdef CONSDEBUG | |
184 | if (ite < whichconsole) | |
185 | continue; | |
186 | #endif | |
187 | ip = &ite_softc[ite]; | |
188 | if ((ip->flags & (ITE_ALIVE|ITE_CONSOLE)) | |
189 | != (ITE_ALIVE|ITE_CONSOLE)) | |
190 | continue; | |
191 | if ((int)ip->regbase == GRFIADDR) { | |
192 | pri = CN_INTERNAL; | |
193 | unit = ite; | |
194 | } else if (unit < 0) { | |
195 | pri = CN_NORMAL; | |
196 | unit = ite; | |
197 | } | |
198 | } | |
199 | cp->cn_dev = unit; | |
200 | cp->cn_pri = pri; | |
201 | } | |
202 | ||
203 | iteinit(cp) | |
204 | struct consdev *cp; | |
205 | { | |
206 | int ite = cp->cn_dev; | |
207 | struct ite_softc *ip; | |
208 | ||
209 | if (itecons != -1) | |
210 | return(1); | |
211 | ||
212 | ip = &ite_softc[ite]; | |
213 | ||
214 | ip->curx = 0; | |
215 | ip->cury = 0; | |
216 | ip->cursorx = 0; | |
217 | ip->cursory = 0; | |
218 | ||
33583b53 MH |
219 | (*ip->isw->ite_init)(ip); |
220 | (*ip->isw->ite_cursor)(ip, DRAW_CURSOR); | |
a8fd2d0d KM |
221 | |
222 | itecons = ite; | |
223 | kbdinit(); | |
224 | } | |
225 | ||
226 | iteputchar(c) | |
227 | register int c; | |
228 | { | |
229 | register struct ite_softc *ip = &ite_softc[itecons]; | |
33583b53 | 230 | register struct itesw *sp = ip->isw; |
a8fd2d0d KM |
231 | |
232 | c &= 0x7F; | |
233 | switch (c) { | |
234 | ||
235 | case '\n': | |
236 | if (++ip->cury == ip->rows) { | |
237 | ip->cury--; | |
238 | (*sp->ite_scroll)(ip, 1, 0, 1, SCROLL_UP); | |
239 | ite_clrtoeol(ip, sp, ip->cury, 0); | |
240 | } | |
241 | else | |
242 | (*sp->ite_cursor)(ip, MOVE_CURSOR); | |
243 | break; | |
244 | ||
245 | case '\r': | |
246 | ip->curx = 0; | |
247 | (*sp->ite_cursor)(ip, MOVE_CURSOR); | |
248 | break; | |
249 | ||
250 | case '\b': | |
251 | if (--ip->curx < 0) | |
252 | ip->curx = 0; | |
253 | else | |
254 | (*sp->ite_cursor)(ip, MOVE_CURSOR); | |
255 | break; | |
256 | ||
257 | default: | |
258 | if (c < ' ' || c == 0177) | |
259 | break; | |
260 | (*sp->ite_putc)(ip, c, ip->cury, ip->curx, ATTR_NOR); | |
261 | (*sp->ite_cursor)(ip, DRAW_CURSOR); | |
262 | itecheckwrap(ip, sp); | |
263 | break; | |
264 | } | |
265 | } | |
266 | ||
267 | itecheckwrap(ip, sp) | |
268 | register struct ite_softc *ip; | |
269 | register struct itesw *sp; | |
270 | { | |
271 | if (++ip->curx == ip->cols) { | |
272 | ip->curx = 0; | |
273 | if (++ip->cury == ip->rows) { | |
274 | --ip->cury; | |
275 | (*sp->ite_scroll)(ip, 1, 0, 1, SCROLL_UP); | |
276 | ite_clrtoeol(ip, sp, ip->cury, 0); | |
277 | return; | |
278 | } | |
279 | } | |
280 | (*sp->ite_cursor)(ip, MOVE_CURSOR); | |
281 | } | |
282 | ||
283 | ite_clrtoeol(ip, sp, y, x) | |
284 | register struct ite_softc *ip; | |
285 | register struct itesw *sp; | |
286 | register int y, x; | |
287 | { | |
288 | (*sp->ite_clear)(ip, y, x, 1, ip->cols - x); | |
289 | (*sp->ite_cursor)(ip, DRAW_CURSOR); | |
290 | } | |
291 | ||
292 | itegetchar() | |
293 | { | |
294 | #ifdef SMALL | |
295 | return (0); | |
296 | #else | |
297 | return (kbdgetc()); | |
298 | #endif | |
299 | } | |
300 | #endif |