Annotation of sys/arch/mac68k/dev/akbd_machdep.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: akbd_machdep.c,v 1.2 2006/01/20 00:10:09 miod Exp $ */
2: /* $NetBSD: akbd.c,v 1.17 2005/01/15 16:00:59 chs Exp $ */
3:
4: /*
5: * Copyright (C) 1998 Colin Wood
6: * All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions
10: * are met:
11: * 1. Redistributions of source code must retain the above copyright
12: * notice, this list of conditions and the following disclaimer.
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in the
15: * documentation and/or other materials provided with the distribution.
16: * 3. All advertising materials mentioning features or use of this software
17: * must display the following acknowledgement:
18: * This product includes software developed by Colin Wood.
19: * 4. The name of the author may not be used to endorse or promote products
20: * derived from this software without specific prior written permission.
21: *
22: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32: */
33:
34: #include <sys/param.h>
35: #include <sys/timeout.h>
36: #include <sys/kernel.h>
37: #include <sys/device.h>
38: #include <sys/fcntl.h>
39: #include <sys/poll.h>
40: #include <sys/selinfo.h>
41: #include <sys/proc.h>
42: #include <sys/signalvar.h>
43: #include <sys/systm.h>
44:
45: #include <dev/wscons/wsconsio.h>
46: #include <dev/wscons/wskbdvar.h>
47:
48: #include <machine/cpu.h>
49: #include <machine/viareg.h>
50:
51: #include <dev/adb/adb.h>
52: #include <dev/adb/akbdvar.h>
53: #include <dev/adb/keyboard.h>
54:
55: void akbd_cnbell(void *, u_int, u_int, u_int);
56: void akbd_cngetc(void *, u_int *, int *);
57: void akbd_cnpollc(void *, int);
58:
59: struct wskbd_consops akbd_consops = {
60: akbd_cngetc,
61: akbd_cnpollc,
62: akbd_cnbell
63: };
64:
65: int
66: akbd_is_console(void)
67: {
68: return ((mac68k_machine.serial_console & 0x03) == 0);
69: }
70:
71: int
72: akbd_cnattach(void)
73: {
74: wskbd_cnattach(&akbd_consops, NULL, &akbd_keymapdata);
75: return 0;
76: }
77:
78: void
79: akbd_cngetc(void *v, u_int *type, int *data)
80: {
81: int intbits, key, press, val;
82: int s;
83: extern int adb_intr(void *);
84: extern void pm_intr(void *);
85:
86: s = splhigh();
87:
88: adb_polledkey = -1;
89: adb_polling = 1;
90:
91: while (adb_polledkey == -1) {
92: intbits = via_reg(VIA1, vIFR);
93:
94: if (intbits & V1IF_ADBRDY) {
95: adb_intr(NULL);
96: via_reg(VIA1, vIFR) = V1IF_ADBRDY;
97: }
98: if (intbits & V1IF_ADBCLK) {
99: pm_intr(NULL);
100: via_reg(VIA1, vIFR) = 0x10;
101: }
102: }
103:
104: adb_polling = 0;
105: splx(s);
106:
107: key = adb_polledkey;
108: press = ADBK_PRESS(key);
109: val = ADBK_KEYVAL(key);
110:
111: *data = val;
112: *type = press ? WSCONS_EVENT_KEY_DOWN : WSCONS_EVENT_KEY_UP;
113: }
114:
115: void
116: akbd_cnpollc(void *v, int on)
117: {
118: }
119:
120: void
121: akbd_cnbell(void *v, u_int pitch, u_int period, u_int volume)
122: {
123: mac68k_ring_bell(pitch, period * hz / 1000, volume);
124: }
CVSweb