1 /* $NetBSD: dnkbd.c,v 1.4 1997/10/09 08:57:11 jtc 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 FOUNDATION OR CONTRIBUTORS 30 * BE 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/frodoreg.h> /* for apci offsets */ 48 #include <hp300/dev/dcareg.h> /* for the register bit defintions */ 49 #include <hp300/dev/apcireg.h> /* for the apci registers */ 50 51 #include <hp300/stand/common/samachdep.h> 52 #include <hp300/stand/common/kbdvar.h> 53 54 #ifndef SMALL 55 56 /* 57 * The Apollo keyboard is used in `cooked' mode as configured by the 58 * firmware; only one table is required. 59 * 60 * Note that if an entry in this table is set to 0, the key is passed 61 * through untranslated. If the entry is 0xff, the key is ignored. 62 */ 63 u_char dnkbd_keymap[] = { 64 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 07 */ 65 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0f */ 66 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 17 */ 67 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1f */ 68 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 27 */ 69 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 2f */ 70 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 37 */ 71 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 3f */ 72 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 47 */ 73 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 4f */ 74 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 57 */ 75 0x00, 0x00, 0x00, '{', 0x00, '}', 0x00, 0x00, /* 5f */ 76 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 67 */ 77 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 6f */ 78 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 77 */ 79 0x00, 0x00, 0x00, '[', 0x00, ']', 0x00, 0x00, /* 7f */ 80 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 87 */ 81 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 8f */ 82 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 97 */ 83 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* 9f */ 84 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* a7 */ 85 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* af */ 86 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* b7 */ 87 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* bf */ 88 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* c7 */ 89 '\\', '|', 0x09, 0x0a, '/', 0xff, 0xff, 0xff, /* cf */ 90 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* d7 */ 91 0xff, 0xff, 0xff, 0xff, '?', 0xff, 0x08, 0xff, /* df */ 92 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* e7 */ 93 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* ef */ 94 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* f7 */ 95 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* ff */ 96 }; 97 98 int dnkbd_ignore; /* for ignoring mouse packets */ 99 100 int 101 dnkbd_getc() 102 { 103 struct apciregs *apci = 104 (struct apciregs *)IIOV(FRODO_BASE + FRODO_APCI_OFFSET(0)); 105 int c; 106 107 /* default to `no key' */ 108 c = 0; 109 110 /* Is data in the UART? */ 111 if (apci->ap_lsr & LSR_RXRDY) { 112 /* Get the character. */ 113 c = apci->ap_data; 114 115 /* Ignoring mouse? */ 116 if (dnkbd_ignore) { 117 dnkbd_ignore--; 118 return (0); 119 } 120 121 /* Is this the start of a mouse packet? */ 122 if (c == 0xdf) { 123 dnkbd_ignore = 3; /* 3 bytes of junk */ 124 return (0); 125 } 126 127 /* It's a keyboard event. */ 128 switch (dnkbd_keymap[c]) { 129 case 0x00: 130 /* passthrough */ 131 break; 132 133 case 0xff: 134 /* ignore */ 135 c = 0; 136 break; 137 138 default: 139 c = dnkbd_keymap[c]; 140 break; 141 } 142 } 143 144 return (c); 145 } 146 #endif /* SMALL */ 147 148 void 149 dnkbd_nmi() 150 { 151 152 /* 153 * XXX Should we do anything? Can we even generate one? 154 */ 155 } 156 157 int 158 dnkbd_init() 159 { 160 161 /* 162 * 400, 425, and 433 models can have a Domain keyboard. 163 */ 164 switch (machineid) { 165 case HP_400: 166 case HP_425: 167 case HP_433: 168 break; 169 default: 170 return (0); 171 } 172 173 /* 174 * Look for a Frodo utility chip. If we find one, assume there 175 * is a Domain keyboard attached. 176 */ 177 if (badaddr((caddr_t)IIOV(FRODO_BASE + FRODO_APCI_OFFSET(0)))) 178 return (0); 179 180 /* 181 * XXX Any other initialization? This appears to work ok. 182 */ 183 return (1); 184 } 185 #endif /* ITECONSOLE && DOMAIN_KEYBOARD */ 186