Commit | Line | Data |
---|---|---|
a8fd2d0d KM |
1 | /* |
2 | * Copyright (c) 1988 University of Utah. | |
3 | * Copyright (c) 1990 The Regents of the University of California. | |
4 | * All rights reserved. | |
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 | * | |
10 | * %sccs.include.redist.c% | |
11 | * | |
12 | * from: Utah $Hdr: ite.c 1.19 89/08/22$ | |
13 | * | |
b28b3a13 | 14 | * @(#)ite.c 7.2 (Berkeley) %G% |
a8fd2d0d KM |
15 | */ |
16 | ||
17 | /* | |
18 | * Standalone Internal Terminal Emulator (CRT and keyboard) | |
19 | */ | |
20 | #include "samachdep.h" | |
21 | ||
22 | #ifdef ITECONSOLE | |
23 | ||
b28b3a13 KB |
24 | #include "sys/param.h" |
25 | #include "../hp300/cons.h" | |
26 | #include "../dev/device.h" | |
27 | #include "../dev/itevar.h" | |
28 | #include "../dev/grfvar.h" | |
a8fd2d0d KM |
29 | |
30 | int nodev(); | |
31 | ||
32 | int topcat_init(), topcat_putc(); | |
33 | int topcat_clear(), topcat_cursor(), topcat_scroll(); | |
34 | int gatorbox_init(), gatorbox_clear(); | |
35 | int gatorbox_putc(), gatorbox_cursor(), gatorbox_scroll(); | |
36 | int rbox_init(), rbox_clear(); | |
37 | int rbox_putc(), rbox_cursor(), rbox_scroll(); | |
38 | int dvbox_init(), dvbox_clear(); | |
39 | int dvbox_putc(), dvbox_cursor(), dvbox_scroll(); | |
40 | ||
41 | struct itesw itesw[] = { | |
42 | topcat_init, nodev, topcat_clear, | |
43 | topcat_putc, topcat_cursor, topcat_scroll, | |
44 | ||
45 | gatorbox_init, nodev, gatorbox_clear, | |
46 | gatorbox_putc, gatorbox_cursor, gatorbox_scroll, | |
47 | ||
48 | rbox_init, nodev, rbox_clear, | |
49 | rbox_putc, rbox_cursor, rbox_scroll, | |
50 | ||
51 | dvbox_init, nodev, dvbox_clear, | |
52 | dvbox_putc, dvbox_cursor, dvbox_scroll, | |
53 | }; | |
54 | ||
55 | /* these guys need to be in initialized data */ | |
56 | int itecons = -1; | |
57 | struct ite_softc ite_softc[NITE] = { 0 }; | |
58 | ||
59 | /* | |
60 | * Locate all bitmapped displays | |
61 | */ | |
62 | iteconfig() | |
63 | { | |
64 | extern struct hp_hw sc_table[]; | |
65 | int dtype, fboff, i; | |
66 | struct hp_hw *hw; | |
67 | struct grfreg *gr; | |
68 | struct ite_softc *ip; | |
69 | ||
70 | i = 0; | |
71 | for (hw = sc_table; hw < &sc_table[MAX_CTLR]; hw++) { | |
72 | if (hw->hw_type != BITMAP) | |
73 | continue; | |
74 | gr = (struct grfreg *) hw->hw_addr; | |
75 | /* XXX: redundent but safe */ | |
76 | if (badaddr((caddr_t)gr) || gr->gr_id != GRFHWID) | |
77 | continue; | |
78 | switch (gr->gr_id2) { | |
79 | case GID_GATORBOX: | |
80 | dtype = ITE_GATORBOX; | |
81 | break; | |
82 | case GID_TOPCAT: | |
83 | case GID_LRCATSEYE: | |
84 | case GID_HRCCATSEYE: | |
85 | case GID_HRMCATSEYE: | |
86 | dtype = ITE_TOPCAT; | |
87 | break; | |
88 | case GID_RENAISSANCE: | |
89 | dtype = ITE_RENAISSANCE; | |
90 | break; | |
91 | case GID_DAVINCI: | |
92 | dtype = ITE_DAVINCI; | |
93 | break; | |
94 | default: | |
95 | continue; | |
96 | } | |
97 | if (i >= NITE) | |
98 | break; | |
99 | ip = &ite_softc[i]; | |
100 | ip->regbase = (caddr_t) gr; | |
101 | fboff = (gr->gr_fbomsb << 8) | gr->gr_fbolsb; | |
102 | ip->fbbase = (caddr_t) (*((u_char *)ip->regbase+fboff) << 16); | |
103 | /* DIO II: FB offset is relative to select code space */ | |
104 | if (ip->regbase >= (caddr_t)0x1000000) | |
105 | ip->fbbase += (int)ip->regbase; | |
106 | ip->flags = ITE_ALIVE|ITE_CONSOLE; | |
107 | ip->type = dtype; | |
108 | i++; | |
109 | } | |
110 | } | |
111 | ||
112 | #ifdef CONSDEBUG | |
113 | /* | |
114 | * Allows us to cycle through all possible consoles (NITE ites and serial port) | |
115 | * by using SHIFT-RESET on the keyboard. | |
116 | */ | |
117 | int whichconsole = -1; | |
118 | #endif | |
119 | ||
120 | iteprobe(cp) | |
121 | struct consdev *cp; | |
122 | { | |
123 | register int ite; | |
124 | register struct ite_softc *ip; | |
125 | int unit, pri; | |
126 | ||
127 | #ifdef CONSDEBUG | |
128 | whichconsole = ++whichconsole % (NITE+1); | |
129 | #endif | |
130 | ||
131 | if (itecons != -1) | |
132 | return(1); | |
133 | ||
134 | iteconfig(); | |
135 | unit = -1; | |
136 | pri = CN_DEAD; | |
137 | for (ite = 0; ite < NITE; ite++) { | |
138 | #ifdef CONSDEBUG | |
139 | if (ite < whichconsole) | |
140 | continue; | |
141 | #endif | |
142 | ip = &ite_softc[ite]; | |
143 | if ((ip->flags & (ITE_ALIVE|ITE_CONSOLE)) | |
144 | != (ITE_ALIVE|ITE_CONSOLE)) | |
145 | continue; | |
146 | if ((int)ip->regbase == GRFIADDR) { | |
147 | pri = CN_INTERNAL; | |
148 | unit = ite; | |
149 | } else if (unit < 0) { | |
150 | pri = CN_NORMAL; | |
151 | unit = ite; | |
152 | } | |
153 | } | |
154 | cp->cn_dev = unit; | |
155 | cp->cn_pri = pri; | |
156 | } | |
157 | ||
158 | iteinit(cp) | |
159 | struct consdev *cp; | |
160 | { | |
161 | int ite = cp->cn_dev; | |
162 | struct ite_softc *ip; | |
163 | ||
164 | if (itecons != -1) | |
165 | return(1); | |
166 | ||
167 | ip = &ite_softc[ite]; | |
168 | ||
169 | ip->curx = 0; | |
170 | ip->cury = 0; | |
171 | ip->cursorx = 0; | |
172 | ip->cursory = 0; | |
173 | ||
174 | (*itesw[ip->type].ite_init)(ip); | |
175 | (*itesw[ip->type].ite_cursor)(ip, DRAW_CURSOR); | |
176 | ||
177 | itecons = ite; | |
178 | kbdinit(); | |
179 | } | |
180 | ||
181 | iteputchar(c) | |
182 | register int c; | |
183 | { | |
184 | register struct ite_softc *ip = &ite_softc[itecons]; | |
185 | register struct itesw *sp = &itesw[ip->type]; | |
186 | ||
187 | c &= 0x7F; | |
188 | switch (c) { | |
189 | ||
190 | case '\n': | |
191 | if (++ip->cury == ip->rows) { | |
192 | ip->cury--; | |
193 | (*sp->ite_scroll)(ip, 1, 0, 1, SCROLL_UP); | |
194 | ite_clrtoeol(ip, sp, ip->cury, 0); | |
195 | } | |
196 | else | |
197 | (*sp->ite_cursor)(ip, MOVE_CURSOR); | |
198 | break; | |
199 | ||
200 | case '\r': | |
201 | ip->curx = 0; | |
202 | (*sp->ite_cursor)(ip, MOVE_CURSOR); | |
203 | break; | |
204 | ||
205 | case '\b': | |
206 | if (--ip->curx < 0) | |
207 | ip->curx = 0; | |
208 | else | |
209 | (*sp->ite_cursor)(ip, MOVE_CURSOR); | |
210 | break; | |
211 | ||
212 | default: | |
213 | if (c < ' ' || c == 0177) | |
214 | break; | |
215 | (*sp->ite_putc)(ip, c, ip->cury, ip->curx, ATTR_NOR); | |
216 | (*sp->ite_cursor)(ip, DRAW_CURSOR); | |
217 | itecheckwrap(ip, sp); | |
218 | break; | |
219 | } | |
220 | } | |
221 | ||
222 | itecheckwrap(ip, sp) | |
223 | register struct ite_softc *ip; | |
224 | register struct itesw *sp; | |
225 | { | |
226 | if (++ip->curx == ip->cols) { | |
227 | ip->curx = 0; | |
228 | if (++ip->cury == ip->rows) { | |
229 | --ip->cury; | |
230 | (*sp->ite_scroll)(ip, 1, 0, 1, SCROLL_UP); | |
231 | ite_clrtoeol(ip, sp, ip->cury, 0); | |
232 | return; | |
233 | } | |
234 | } | |
235 | (*sp->ite_cursor)(ip, MOVE_CURSOR); | |
236 | } | |
237 | ||
238 | ite_clrtoeol(ip, sp, y, x) | |
239 | register struct ite_softc *ip; | |
240 | register struct itesw *sp; | |
241 | register int y, x; | |
242 | { | |
243 | (*sp->ite_clear)(ip, y, x, 1, ip->cols - x); | |
244 | (*sp->ite_cursor)(ip, DRAW_CURSOR); | |
245 | } | |
246 | ||
247 | itegetchar() | |
248 | { | |
249 | #ifdef SMALL | |
250 | return (0); | |
251 | #else | |
252 | return (kbdgetc()); | |
253 | #endif | |
254 | } | |
255 | #endif |