No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / hp300 / stand / common / dnkbd.c
blob3add8c20a12e1b42af93a8f5e162e1aa7fb9844a
1 /* $NetBSD: dnkbd.c,v 1.11 2007/03/04 05:59:50 christos 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 Michael Smith and 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 * Apollo Domain keyboard routines for the standalone ITE.
36 #if defined(ITECONSOLE) && defined(DOMAIN_KEYBOARD)
38 #include <sys/param.h>
40 #include <hp300/dev/frodoreg.h> /* for apci offsets */
41 #include <hp300/dev/intioreg.h> /* for frodo offsets */
43 #include <hp300/stand/common/dcareg.h> /* for the register bit definitions */
44 #include <hp300/stand/common/apcireg.h> /* for the apci registers */
45 #include <hp300/stand/common/samachdep.h>
46 #include <hp300/stand/common/kbdvar.h>
48 #ifndef SMALL
51 * The Apollo keyboard is used in `cooked' mode as configured by the
52 * firmware; only one table is required.
54 * Note that if an entry in this table is set to 0, the key is passed
55 * through untranslated. If the entry is 0xff, the key is ignored.
57 u_char dnkbd_keymap[] = {
58 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 07 */
59 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0f */
60 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 17 */
61 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1f */
62 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 27 */
63 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 2f */
64 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 37 */
65 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 3f */
66 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 47 */
67 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 4f */
68 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 57 */
69 0x00, 0x00, 0x00, '{', 0x00, '}', 0x00, 0x00, /* 5f */
70 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 67 */
71 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 6f */
72 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 77 */
73 0x00, 0x00, 0x00, '[', 0x00, ']', 0x00, 0x00, /* 7f */
74 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 87 */
75 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 8f */
76 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 97 */
77 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 9f */
78 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* a7 */
79 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* af */
80 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* b7 */
81 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* bf */
82 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* c7 */
83 '\\', '|', 0x09, 0x0a, '/', 0xff, 0xff, 0xff, /* cf */
84 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* d7 */
85 0xff, 0xff, 0xff, 0xff, '?', 0xff, 0x08, 0xff, /* df */
86 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* e7 */
87 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* ef */
88 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* f7 */
89 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* ff */
92 int dnkbd_ignore; /* for ignoring mouse packets */
94 int
95 dnkbd_getc(void)
97 struct apciregs *apci =
98 (struct apciregs *)IIOV(FRODO_BASE + FRODO_APCI_OFFSET(0));
99 int c;
101 /* default to `no key' */
102 c = 0;
104 /* Is data in the UART? */
105 if (apci->ap_lsr & LSR_RXRDY) {
106 /* Get the character. */
107 c = apci->ap_data;
109 /* Ignoring mouse? */
110 if (dnkbd_ignore) {
111 dnkbd_ignore--;
112 return 0;
115 /* Is this the start of a mouse packet? */
116 if (c == 0xdf) {
117 dnkbd_ignore = 3; /* 3 bytes of junk */
118 return 0;
121 /* It's a keyboard event. */
122 switch (dnkbd_keymap[c]) {
123 case 0x00:
124 /* passthrough */
125 break;
127 case 0xff:
128 /* ignore */
129 c = 0;
130 break;
132 default:
133 c = dnkbd_keymap[c];
134 break;
138 return c;
140 #endif /* SMALL */
142 void
143 dnkbd_nmi(void)
147 * XXX Should we do anything? Can we even generate one?
152 dnkbd_init(void)
156 * 400, 425, and 433 models can have a Domain keyboard.
158 switch (machineid) {
159 case HP_400:
160 case HP_425:
161 case HP_433:
162 break;
163 default:
164 return 0;
168 * Look for a Frodo utility chip. If we find one, assume there
169 * is a Domain keyboard attached.
171 if (badaddr((void *)IIOV(FRODO_BASE + FRODO_APCI_OFFSET(0))))
172 return 0;
175 * XXX Any other initialization? This appears to work ok.
177 return 1;
179 #endif /* ITECONSOLE && DOMAIN_KEYBOARD */