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