1 /* $NetBSD: ite.c,v 1.8 2007/03/04 05:59:50 christos 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: ite.c 1.24 93/06/25$
37 * @(#)ite.c 8.1 (Berkeley) 7/8/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: ite.c 1.24 93/06/25$
76 * @(#)ite.c 8.1 (Berkeley) 7/8/93
80 * Standalone Internal Terminal Emulator (CRT and keyboard)
85 #include <sys/param.h>
88 #include <hp300/dev/grfreg.h>
89 #include <hp300/dev/intioreg.h>
91 #include <hp300/stand/common/device.h>
92 #include <hp300/stand/common/itevar.h>
93 #include <hp300/stand/common/kbdvar.h>
94 #include <hp300/stand/common/consdefs.h>
95 #include <hp300/stand/common/samachdep.h>
97 static void iteconfig(void);
98 static void ite_deinit_noop(struct ite_data
*);
99 static void ite_clrtoeol(struct ite_data
*, struct itesw
*, int, int);
100 static void itecheckwrap(struct ite_data
*, struct itesw
*);
102 struct itesw itesw
[] = {
104 topcat_init
, ite_deinit_noop
, topcat_clear
, topcat_putc
,
105 topcat_cursor
, topcat_scroll
, ite_readbyte
, ite_writeglyph
},
108 gbox_init
, ite_deinit_noop
, gbox_clear
, gbox_putc
,
109 gbox_cursor
, gbox_scroll
, ite_readbyte
, ite_writeglyph
},
112 rbox_init
, ite_deinit_noop
, rbox_clear
, rbox_putc
,
113 rbox_cursor
, rbox_scroll
, ite_readbyte
, ite_writeglyph
},
116 topcat_init
, ite_deinit_noop
, topcat_clear
, topcat_putc
,
117 topcat_cursor
, topcat_scroll
, ite_readbyte
, ite_writeglyph
},
120 topcat_init
, ite_deinit_noop
, topcat_clear
, topcat_putc
,
121 topcat_cursor
, topcat_scroll
, ite_readbyte
, ite_writeglyph
},
124 topcat_init
, ite_deinit_noop
, topcat_clear
, topcat_putc
,
125 topcat_cursor
, topcat_scroll
, ite_readbyte
, ite_writeglyph
},
128 dvbox_init
, ite_deinit_noop
, dvbox_clear
, dvbox_putc
,
129 dvbox_cursor
, dvbox_scroll
, ite_readbyte
, ite_writeglyph
},
132 hyper_init
, ite_deinit_noop
, hyper_clear
, hyper_putc
,
133 hyper_cursor
, hyper_scroll
, ite_readbyte
, ite_writeglyph
},
135 int nitesw
= sizeof(itesw
) / sizeof(itesw
[0]);
137 /* these guys need to be in initialized data */
139 struct ite_data ite_data
[NITE
] = { { 0 } };
140 int ite_scode
[NITE
] = { 0 };
143 * Locate all bitmapped displays
154 for (hw
= sc_table
; hw
< &sc_table
[MAXCTLRS
]; hw
++) {
155 if (!HW_ISDEV(hw
, D_BITMAP
))
157 gr
= (struct grfreg
*) hw
->hw_kva
;
158 /* XXX: redundent but safe */
159 if (badaddr((void *)gr
) || gr
->gr_id
!= GRFHWID
)
161 for (dtype
= 0; dtype
< nitesw
; dtype
++)
162 if (itesw
[dtype
].ite_hwid
== gr
->gr_id2
)
168 ite_scode
[i
] = hw
->hw_sc
;
170 ip
->isw
= &itesw
[dtype
];
171 ip
->regbase
= (void *) gr
;
172 fboff
= (gr
->gr_fbomsb
<< 8) | gr
->gr_fbolsb
;
173 ip
->fbbase
= (void *)(*((u_char
*)ip
->regbase
+ fboff
) << 16);
174 /* DIO II: FB offset is relative to select code space */
175 if (ip
->regbase
>= (void *)DIOIIBASE
)
176 ip
->fbbase
= (char*)ip
->fbbase
+ (int)ip
->regbase
;
177 ip
->fbwidth
= gr
->gr_fbwidth_h
<< 8 | gr
->gr_fbwidth_l
;
178 ip
->fbheight
= gr
->gr_fbheight_h
<< 8 | gr
->gr_fbheight_l
;
179 ip
->dwidth
= gr
->gr_dwidth_h
<< 8 | gr
->gr_dwidth_l
;
180 ip
->dheight
= gr
->gr_dheight_h
<< 8 | gr
->gr_dheight_l
;
182 * XXX some displays (e.g. the davinci) appear
183 * to return a display height greater than the
184 * returned FB height. Guess we should go back
185 * to getting the display dimensions from the
188 if (ip
->dwidth
> ip
->fbwidth
)
189 ip
->dwidth
= ip
->fbwidth
;
190 if (ip
->dheight
> ip
->fbheight
)
191 ip
->dheight
= ip
->fbheight
;
192 ip
->flags
= ITE_ALIVE
|ITE_CONSOLE
;
199 * Allows us to cycle through all possible consoles (NITE ites and serial port)
200 * by using SHIFT-RESET on the keyboard.
202 int whichconsole
= -1;
206 iteprobe(struct consdev
*cp
)
213 whichconsole
= ++whichconsole
% (NITE
+1);
222 for (ite
= 0; ite
< NITE
; ite
++) {
224 if (ite
< whichconsole
)
228 if ((ip
->flags
& (ITE_ALIVE
|ITE_CONSOLE
))
229 != (ITE_ALIVE
|ITE_CONSOLE
))
231 if ((int)ip
->regbase
== INTIOBASE
+ FB_BASE
) {
234 } else if (unit
< 0) {
239 curcons_scode
= ite_scode
[unit
];
245 iteinit(struct consdev
*cp
)
247 int ite
= cp
->cn_dev
;
260 (*ip
->isw
->ite_init
)(ip
);
261 (*ip
->isw
->ite_cursor
)(ip
, DRAW_CURSOR
);
269 iteputchar(dev_t dev
, int c
)
271 struct ite_data
*ip
= &ite_data
[itecons
];
272 struct itesw
*sp
= ip
->isw
;
278 if (++ip
->cury
== ip
->rows
) {
280 (*sp
->ite_scroll
)(ip
, 1, 0, 1, SCROLL_UP
);
281 ite_clrtoeol(ip
, sp
, ip
->cury
, 0);
284 (*sp
->ite_cursor
)(ip
, MOVE_CURSOR
);
289 (*sp
->ite_cursor
)(ip
, MOVE_CURSOR
);
296 (*sp
->ite_cursor
)(ip
, MOVE_CURSOR
);
300 if (c
< ' ' || c
== 0177)
302 (*sp
->ite_putc
)(ip
, c
, ip
->cury
, ip
->curx
, ATTR_NOR
);
303 (*sp
->ite_cursor
)(ip
, DRAW_CURSOR
);
304 itecheckwrap(ip
, sp
);
310 itecheckwrap(struct ite_data
*ip
, struct itesw
*sp
)
312 if (++ip
->curx
== ip
->cols
) {
314 if (++ip
->cury
== ip
->rows
) {
316 (*sp
->ite_scroll
)(ip
, 1, 0, 1, SCROLL_UP
);
317 ite_clrtoeol(ip
, sp
, ip
->cury
, 0);
321 (*sp
->ite_cursor
)(ip
, MOVE_CURSOR
);
325 ite_clrtoeol(struct ite_data
*ip
, struct itesw
*sp
, int y
, int x
)
328 (*sp
->ite_clear
)(ip
, y
, x
, 1, ip
->cols
- x
);
329 (*sp
->ite_cursor
)(ip
, DRAW_CURSOR
);
334 itegetchar(dev_t dev
)
347 ite_deinit_noop(struct ite_data
*ip
)