No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / hp300 / stand / common / hil.c
blob2481266b496e3fd3fa9c87ad194c374b2af86bbb
1 /* $NetBSD: hil.c,v 1.11 2006/08/28 14:31:45 tsutsui Exp $ */
3 /*-
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * Copyright (c) 1990, 1993
34 * The Regents of the University of California. All rights reserved.
36 * This code is derived from software contributed to Berkeley by
37 * the Systems Programming Group of the University of Utah Computer
38 * Science Department.
40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions
42 * are met:
43 * 1. Redistributions of source code must retain the above copyright
44 * notice, this list of conditions and the following disclaimer.
45 * 2. Redistributions in binary form must reproduce the above copyright
46 * notice, this list of conditions and the following disclaimer in the
47 * documentation and/or other materials provided with the distribution.
48 * 3. Neither the name of the University nor the names of its contributors
49 * may be used to endorse or promote products derived from this software
50 * without specific prior written permission.
52 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
53 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
56 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62 * SUCH DAMAGE.
64 * from: Utah Hdr: hil.c 1.1 89/08/22
66 * @(#)hil.c 8.1 (Berkeley) 6/10/93
69 * Copyright (c) 1988 University of Utah.
71 * This code is derived from software contributed to Berkeley by
72 * the Systems Programming Group of the University of Utah Computer
73 * Science Department.
75 * Redistribution and use in source and binary forms, with or without
76 * modification, are permitted provided that the following conditions
77 * are met:
78 * 1. Redistributions of source code must retain the above copyright
79 * notice, this list of conditions and the following disclaimer.
80 * 2. Redistributions in binary form must reproduce the above copyright
81 * notice, this list of conditions and the following disclaimer in the
82 * documentation and/or other materials provided with the distribution.
83 * 3. All advertising materials mentioning features or use of this software
84 * must display the following acknowledgement:
85 * This product includes software developed by the University of
86 * California, Berkeley and its contributors.
87 * 4. Neither the name of the University nor the names of its contributors
88 * may be used to endorse or promote products derived from this software
89 * without specific prior written permission.
91 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
92 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
93 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
94 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
95 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
96 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
97 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
98 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
99 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
100 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
101 * SUCH DAMAGE.
103 * from: Utah Hdr: hil.c 1.1 89/08/22
105 * @(#)hil.c 8.1 (Berkeley) 6/10/93
109 * HIL keyboard routines for the standalone ITE.
112 #if defined(ITECONSOLE) && defined(HIL_KEYBOARD)
114 #include <sys/param.h>
116 #include <hp300/dev/hilreg.h>
117 #include <hp300/dev/kbdmap.h>
118 #include <hp300/dev/itevar.h>
120 #include <hp300/stand/common/samachdep.h>
121 #include <hp300/stand/common/kbdvar.h>
123 #ifndef SMALL
126 * HIL cooked keyboard keymaps.
127 * Supports only unshifted, shifted and control keys.
129 char hil_us_keymap[] = {
130 '\0', '`', '\\', ESC, '\0', DEL, '\0', '\0',
131 '\n', '\t', '\0', '\0', '\0', '\0', '\0', '\0',
132 '\0', '\n', '\0', '\0', '\0', '\0', '\0', '\0',
133 '\0', '\t', '\0', '\0', '\0', '\0', '\0', '\0',
134 '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
135 '\0', '\0', '\0', '\0', '\0', '\0', '\b', '\0',
136 '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
137 ESC, '\r', '\0', '\n', '0', '.', ',', '+',
138 '1', '2', '3', '-', '4', '5', '6', '*',
139 '7', '8', '9', '/', 'E', '(', ')', '^',
140 '1', '2', '3', '4', '5', '6', '7', '8',
141 '9', '0', '-', '=', '[', ']', ';', '\'',
142 ',', '.', '/', '\040', 'o', 'p', 'k', 'l',
143 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
144 'a', 's', 'd', 'f', 'g', 'h', 'j', 'm',
145 'z', 'x', 'c', 'v', 'b', 'n', '\0', '\0'
148 char hil_us_shiftmap[] = {
149 '\0', '~', '|', DEL, '\0', DEL, '\0', '\0',
150 '\n', '\t', '\0', '\0', '\0', '\0', '\0', '\0',
151 '\0', '\n', '\0', '\0', '\0', '\0', '\0', '\0',
152 '\0', '\t', '\0', '\0', '\0', '\0', '\0', '\0',
153 '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
154 '\0', '\0', '\0', '\0', '\0', '\0', DEL, '\0',
155 '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
156 ESC, '\r', '\0', '\n', '0', '.', ',', '+',
157 '1', '2', '3', '-', '4', '5', '6', '*',
158 '7', '8', '9', '/', '`', '|', '\\', '~',
159 '!', '@', '#', '$', '%', '^', '&', '*',
160 '(', ')', '_', '+', '{', '}', ':', '\"',
161 '<', '>', '?', '\040', 'O', 'P', 'K', 'L',
162 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
163 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'M',
164 'Z', 'X', 'C', 'V', 'B', 'N', '\0', '\0'
167 char hil_us_ctrlmap[] = {
168 '\0', '`', '\034', ESC, '\0', DEL, '\0', '\0',
169 '\n', '\t', '\0', '\0', '\0', '\0', '\0', '\0',
170 '\0', '\n', '\0', '\0', '\0', '\0', '\0', '\0',
171 '\0', '\t', '\0', '\0', '\0', '\0', '\0', '\0',
172 '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
173 '\0', '\0', '\0', '\0', '\0', '\0', '\b', '\0',
174 '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
175 ESC, '\r', '\0', '\n', '0', '.', ',', '+',
176 '1', '2', '3', '-', '4', '5', '6', '*',
177 '7', '8', '9', '/', 'E', '(', ')', '\036',
178 '1', '2', '3', '4', '5', '6', '7', '8',
179 '9', '0', '-', '=', '\033', '\035', ';', '\'',
180 ',', '.', '/', '\040', '\017', '\020', '\013', '\014',
181 '\021', '\027', '\005', '\022', '\024', '\031', '\025', '\011',
182 '\001', '\023', '\004', '\006', '\007', '\010', '\012', '\015',
183 '\032', '\030', '\003', '\026', '\002', '\016', '\0', '\0'
186 #ifdef UK_KEYBOARD
187 char hil_uk_keymap[] = {
188 '\0', '`', '<', ESC, '\0', DEL, '\0', '\0',
189 '\n', '\t', '\0', '\0', '\0', '\0', '\0', '\0',
190 '\0', '\n', '\0', '\0', '\0', '\0', '\0', '\0',
191 '\0', '\t', '\0', '\0', '\0', '\0', '\0', '\0',
192 '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
193 '\0', '\0', '\0', '\0', '\0', '\0', '\b', '\0',
194 '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
195 ESC, '\r', '\0', '\n', '0', '.', ',', '+',
196 '1', '2', '3', '-', '4', '5', '6', '*',
197 '7', '8', '9', '/', 'E', '(', ')', '^',
198 '1', '2', '3', '4', '5', '6', '7', '8',
199 '9', '0', '+', '\'', '[', ']', '*', '\\',
200 ',', '.', '-', '\040', 'o', 'p', 'k', 'l',
201 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
202 'a', 's', 'd', 'f', 'g', 'h', 'j', 'm',
203 'z', 'x', 'c', 'v', 'b', 'n', '\0', '\0'
206 char hil_uk_shiftmap[] = {
207 '\0', '~', '>', DEL, '\0', DEL, '\0', '\0',
208 '\n', '\t', '\0', '\0', '\0', '\0', '\0', '\0',
209 '\0', '\n', '\0', '\0', '\0', '\0', '\0', '\0',
210 '\0', '\t', '\0', '\0', '\0', '\0', '\0', '\0',
211 '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
212 '\0', '\0', '\0', '\0', '\0', '\0', DEL, '\0',
213 '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
214 ESC, '\r', '\0', '\n', '0', '.', ',', '+',
215 '1', '2', '3', '-', '4', '5', '6', '*',
216 '7', '8', '9', '/', '`', '|', '\\', '~',
217 '!', '\"', '#', '$', '%', '&', '^', '(',
218 ')', '=', '?', '/', '{', '}', '@', '|',
219 ';', ':', '_', '\040', 'O', 'P', 'K', 'L',
220 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
221 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'M',
222 'Z', 'X', 'C', 'V', 'B', 'N', '\0', '\0'
225 char hil_uk_ctrlmap[] = {
226 '\0', '`', '<', ESC, '\0', DEL, '\0', '\0',
227 '\n', '\t', '\0', '\0', '\0', '\0', '\0', '\0',
228 '\0', '\n', '\0', '\0', '\0', '\0', '\0', '\0',
229 '\0', '\t', '\0', '\0', '\0', '\0', '\0', '\0',
230 '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
231 '\0', '\0', '\0', '\0', '\0', '\0', '\b', '\0',
232 '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
233 ESC, '\r', '\0', '\n', '0', '.', ',', '+',
234 '1', '2', '3', '-', '4', '5', '6', '*',
235 '7', '8', '9', '/', 'E', '(', ')', '\036',
236 '1', '2', '3', '4', '5', '6', '7', '8',
237 '9', '0', '+', '\'', '\033', '\035', '*', '\034',
238 ',', '.', '/', '\040', '\017', '\020', '\013', '\014',
239 '\021', '\027', '\005', '\022', '\024', '\031', '\025', '\011',
240 '\001', '\023', '\004', '\006', '\007', '\010', '\012', '\015',
241 '\032', '\030', '\003', '\026', '\002', '\016', '\0', '\0'
243 #endif
246 * The keyboard map table.
247 * Lookup is by hardware returned language code.
249 struct kbdmap hilkbd_map[] = {
250 { KBD_US, "",
251 hil_us_keymap, hil_us_shiftmap, hil_us_ctrlmap, NULL, NULL},
253 #ifdef UK_KEYBOARD
254 { KBD_UK, "",
255 hil_uk_keymap, hil_uk_shiftmap, hil_uk_ctrlmap, NULL, NULL},
256 #endif
258 { 0, "",
259 NULL, NULL, NULL, NULL, NULL},
262 char *hilkbd_keymap = hil_us_keymap;
263 char *hilkbd_shiftmap = hil_us_shiftmap;
264 char *hilkbd_ctrlmap = hil_us_ctrlmap;
267 hilkbd_getc(void)
269 int status, c;
270 struct hil_dev *hiladdr = HILADDR;
272 status = hiladdr->hil_stat;
273 if ((status & HIL_DATA_RDY) == 0)
274 return 0;
275 c = hiladdr->hil_data;
276 switch ((status>>KBD_SSHIFT) & KBD_SMASK) {
277 case KBD_SHIFT:
278 c = hilkbd_shiftmap[c & KBD_CHARMASK];
279 break;
280 case KBD_CTRL:
281 c = hilkbd_ctrlmap[c & KBD_CHARMASK];
282 break;
283 case KBD_KEY:
284 c = hilkbd_keymap[c & KBD_CHARMASK];
285 break;
286 default:
287 c = 0;
288 break;
290 return c;
292 #endif /* SMALL */
294 void
295 hilkbd_nmi(void)
297 struct hil_dev *hiladdr = HILADDR;
299 HILWAIT(hiladdr);
300 hiladdr->hil_cmd = HIL_CNMT;
301 HILWAIT(hiladdr);
302 hiladdr->hil_cmd = HIL_CNMT;
303 HILWAIT(hiladdr);
307 hilkbd_init(void)
309 struct hil_dev *hiladdr = HILADDR;
310 struct kbdmap *km;
311 u_char lang;
314 * Determine the existence of a HIL keyboard.
316 HILWAIT(hiladdr);
317 hiladdr->hil_cmd = HIL_READKBDSADR;
318 HILDATAWAIT(hiladdr);
319 lang = hiladdr->hil_data;
320 if (lang == 0)
321 return 0;
323 HILWAIT(hiladdr);
324 hiladdr->hil_cmd = HIL_SETARR;
325 HILWAIT(hiladdr);
326 hiladdr->hil_data = ar_format(KBD_ARR);
327 HILWAIT(hiladdr);
328 hiladdr->hil_cmd = HIL_READKBDLANG;
329 HILDATAWAIT(hiladdr);
330 lang = hiladdr->hil_data;
331 for (km = hilkbd_map; km->kbd_code; km++) {
332 if (km->kbd_code == lang) {
333 hilkbd_keymap = km->kbd_keymap;
334 hilkbd_shiftmap = km->kbd_shiftmap;
335 hilkbd_ctrlmap = km->kbd_ctrlmap;
338 HILWAIT(hiladdr);
339 hiladdr->hil_cmd = HIL_INTON;
340 return 1;
342 #endif /* ITECONSOLE && HIL_KEYBOARD */