dnkbd.c revision 1.1 1 /* $NetBSD: dnkbd.c,v 1.1 1997/04/14 19:03:13 thorpej Exp $ */
2
3 /*-
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Michael Smith and Jason R. Thorpe.
9 *
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 NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * Apollo Domain keyboard routines for the standalone ITE.
41 */
42
43 #if defined(ITECONSOLE) && defined(DOMAIN_KEYBOARD)
44
45 #include <sys/param.h>
46
47 #include <hp300/dev/dcareg.h> /* for the register bit defintions */
48 #include <hp300/dev/apcireg.h> /* for the apci registers */
49
50 #include <hp300/stand/common/samachdep.h>
51 #include <hp300/stand/common/kbdvar.h>
52
53 #ifndef SMALL
54
55 /*
56 * The Apollo keyboard is used in `cooked' mode as configured by the
57 * firmware; only one table is required.
58 *
59 * Note that if an entry in this table is set to 0, the key is passed
60 * through untranslated. If the entry is 0xff, the key is ignored.
61 */
62 u_char dnkbd_keymap[] = {
63 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 07 */
64 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0f */
65 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 17 */
66 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1f */
67 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 27 */
68 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 2f */
69 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 37 */
70 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 3f */
71 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 47 */
72 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 4f */
73 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 57 */
74 0x00, 0x00, 0x00, '{', 0x00, '}', 0x00, 0x00, /* 5f */
75 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 67 */
76 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 6f */
77 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 77 */
78 0x00, 0x00, 0x00, '[', 0x00, ']', 0x00, 0x00, /* 7f */
79 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 87 */
80 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 8f */
81 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 97 */
82 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 9f */
83 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* a7 */
84 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* af */
85 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* b7 */
86 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* bf */
87 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* c7 */
88 '\\', '|', 0x09, 0x0a, '/', 0xff, 0xff, 0xff, /* cf */
89 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* d7 */
90 0xff, 0xff, 0xff, 0xff, '?', 0xff, 0x08, 0xff, /* df */
91 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* e7 */
92 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* ef */
93 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* f7 */
94 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* ff */
95 };
96
97 int dnkbd_ignore; /* for ignoring mouse packets */
98
99 int
100 dnkbd_getc()
101 {
102 struct apciregs *apci = (struct apciregs *)0x41c000; /* XXX */
103 int c;
104
105 /* default to `no key' */
106 c = 0;
107
108 /* Is data in the UART? */
109 if (apci->ap_lsr & LSR_RXRDY) {
110 /* Get the character. */
111 c = apci->ap_data;
112
113 /* Ignoring mouse? */
114 if (dnkbd_ignore) {
115 dnkbd_ignore--;
116 return (0);
117 }
118
119 /* Is this the start of a mouse packet? */
120 if (c == 0xdf) {
121 dnkbd_ignore = 3; /* 3 bytes of junk */
122 return (0);
123 }
124
125 /* It's a keyboard event. */
126 switch (dnkbd_keymap[c]) {
127 case 0x00:
128 /* passthrough */
129 break;
130
131 case 0xff:
132 /* ignore */
133 c = 0;
134 break;
135
136 default:
137 c = dnkbd_keymap[c];
138 break;
139 }
140 }
141
142 return (c);
143 }
144 #endif /* SMALL */
145
146 void
147 dnkbd_nmi()
148 {
149
150 /*
151 * XXX Should we do anything? Can we even generate one?
152 */
153 }
154
155 int
156 dnkbd_init()
157 {
158
159 /*
160 * Look for a Frodo utility chip. If we find one, assume there
161 * is a Domain keyboard attached.
162 *
163 * XXX This could be improved.
164 */
165 if (badaddr(0x41c000))
166 return (0);
167
168 /*
169 * XXX Any other initialization? This appears to work ok.
170 */
171 return (1);
172 }
173 #endif /* ITECONSOLE && DOMAIN_KEYBOARD */
174