kbd.c revision 1.12 1 1.12 christos /* $NetBSD: kbd.c,v 1.12 1996/10/13 04:11:03 christos Exp $ */
2 1.1 leo
3 1.1 leo /*
4 1.1 leo * Copyright (c) 1995 Leo Weppelman
5 1.1 leo * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
6 1.1 leo * All rights reserved.
7 1.1 leo *
8 1.1 leo * Redistribution and use in source and binary forms, with or without
9 1.1 leo * modification, are permitted provided that the following conditions
10 1.1 leo * are met:
11 1.1 leo * 1. Redistributions of source code must retain the above copyright
12 1.1 leo * notice, this list of conditions and the following disclaimer.
13 1.1 leo * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 leo * notice, this list of conditions and the following disclaimer in the
15 1.1 leo * documentation and/or other materials provided with the distribution.
16 1.1 leo * 3. All advertising materials mentioning features or use of this software
17 1.1 leo * must display the following acknowledgement:
18 1.1 leo * This product includes software developed by the University of
19 1.1 leo * California, Berkeley and its contributors.
20 1.1 leo * 4. Neither the name of the University nor the names of its contributors
21 1.1 leo * may be used to endorse or promote products derived from this software
22 1.1 leo * without specific prior written permission.
23 1.1 leo *
24 1.1 leo * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 1.1 leo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 1.1 leo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 1.1 leo * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 1.1 leo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 1.1 leo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 1.1 leo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 1.1 leo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 1.1 leo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 1.1 leo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 1.1 leo * SUCH DAMAGE.
35 1.1 leo */
36 1.1 leo
37 1.1 leo #include <sys/param.h>
38 1.1 leo #include <sys/systm.h>
39 1.1 leo #include <sys/device.h>
40 1.1 leo #include <sys/ioctl.h>
41 1.1 leo #include <sys/tty.h>
42 1.1 leo #include <sys/proc.h>
43 1.1 leo #include <sys/conf.h>
44 1.1 leo #include <sys/file.h>
45 1.1 leo #include <sys/kernel.h>
46 1.9 leo #include <sys/signalvar.h>
47 1.1 leo #include <sys/syslog.h>
48 1.1 leo #include <dev/cons.h>
49 1.1 leo #include <machine/cpu.h>
50 1.1 leo #include <machine/iomap.h>
51 1.1 leo #include <machine/mfp.h>
52 1.1 leo #include <machine/acia.h>
53 1.1 leo #include <atari/dev/itevar.h>
54 1.1 leo #include <atari/dev/event_var.h>
55 1.1 leo #include <atari/dev/vuid_event.h>
56 1.9 leo #include <atari/dev/ym2149reg.h>
57 1.9 leo #include <atari/dev/kbdreg.h>
58 1.9 leo #include <atari/dev/kbdvar.h>
59 1.9 leo #include <atari/dev/msvar.h>
60 1.1 leo
61 1.5 leo #include "mouse.h"
62 1.5 leo
63 1.1 leo static u_char kbd_ring[KBD_RING_SIZE];
64 1.1 leo static volatile u_int kbd_rbput = 0; /* 'put' index */
65 1.1 leo static u_int kbd_rbget = 0; /* 'get' index */
66 1.1 leo static u_char kbd_soft = 0; /* 1: Softint has been scheduled*/
67 1.1 leo
68 1.1 leo static struct kbd_softc kbd_softc;
69 1.1 leo
70 1.6 leo /* {b,c}devsw[] function prototypes */
71 1.6 leo dev_type_open(kbdopen);
72 1.6 leo dev_type_close(kbdclose);
73 1.6 leo dev_type_read(kbdread);
74 1.6 leo dev_type_ioctl(kbdioctl);
75 1.6 leo dev_type_select(kbdselect);
76 1.6 leo
77 1.6 leo /* Interrupt handler */
78 1.6 leo void kbdintr __P((int));
79 1.6 leo
80 1.10 leo static void kbdsoft __P((void *, void *));
81 1.1 leo static void kbdattach __P((struct device *, struct device *, void *));
82 1.7 thorpej static int kbdmatch __P((struct device *, void *, void *));
83 1.4 leo static int kbd_write_poll __P((u_char *, int));
84 1.3 leo static void kbd_pkg_start __P((struct kbd_softc *, u_char));
85 1.1 leo
86 1.7 thorpej struct cfattach kbd_ca = {
87 1.7 thorpej sizeof(struct device), kbdmatch, kbdattach
88 1.7 thorpej };
89 1.1 leo
90 1.7 thorpej struct cfdriver kbd_cd = {
91 1.7 thorpej NULL, "kbd", DV_DULL, NULL, 0
92 1.7 thorpej };
93 1.1 leo
94 1.9 leo
95 1.1 leo /*ARGSUSED*/
96 1.1 leo static int
97 1.7 thorpej kbdmatch(pdp, match, auxp)
98 1.1 leo struct device *pdp;
99 1.7 thorpej void *match, *auxp;
100 1.1 leo {
101 1.3 leo if (!strcmp((char *)auxp, "kbd"))
102 1.3 leo return (1);
103 1.3 leo return (0);
104 1.1 leo }
105 1.1 leo
106 1.1 leo /*ARGSUSED*/
107 1.1 leo static void
108 1.1 leo kbdattach(pdp, dp, auxp)
109 1.1 leo struct device *pdp, *dp;
110 1.1 leo void *auxp;
111 1.1 leo {
112 1.3 leo int timeout;
113 1.4 leo u_char kbd_rst[] = { 0x80, 0x01 };
114 1.4 leo u_char kbd_icmd[] = { 0x12, 0x15 };
115 1.3 leo
116 1.3 leo /*
117 1.3 leo * Disable keyboard interrupts from MFP
118 1.3 leo */
119 1.3 leo MFP->mf_ierb &= ~IB_AINT;
120 1.3 leo
121 1.3 leo /*
122 1.3 leo * Reset ACIA and intialize to:
123 1.3 leo * divide by 16, 8 data, 1 stop, no parity, enable RX interrupts
124 1.3 leo */
125 1.3 leo KBD->ac_cs = A_RESET;
126 1.3 leo delay(100); /* XXX: enough? */
127 1.3 leo KBD->ac_cs = kbd_softc.k_soft_cs = KBD_INIT | A_RXINT;
128 1.3 leo
129 1.3 leo /*
130 1.3 leo * Clear error conditions
131 1.3 leo */
132 1.3 leo while (KBD->ac_cs & (A_IRQ|A_RXRDY))
133 1.3 leo timeout = KBD->ac_da;
134 1.3 leo
135 1.3 leo /*
136 1.3 leo * Now send the reset string, and read+ignore it's response
137 1.3 leo */
138 1.4 leo if (!kbd_write_poll(kbd_rst, 2))
139 1.12 christos printf("kbd: error cannot reset keyboard\n");
140 1.3 leo for (timeout = 1000; timeout > 0; timeout--) {
141 1.3 leo if (KBD->ac_cs & (A_IRQ|A_RXRDY)) {
142 1.3 leo timeout = KBD->ac_da;
143 1.3 leo timeout = 100;
144 1.3 leo }
145 1.3 leo delay(100);
146 1.3 leo }
147 1.4 leo /*
148 1.4 leo * Send init command: disable mice & joysticks
149 1.4 leo */
150 1.4 leo kbd_write_poll(kbd_icmd, sizeof(kbd_icmd));
151 1.3 leo
152 1.12 christos printf("\n");
153 1.1 leo }
154 1.1 leo
155 1.1 leo /* definitions for atari keyboard encoding. */
156 1.3 leo #define KEY_CODE(c) ((u_char)(c) & 0x7f)
157 1.3 leo #define KEY_UP(c) ((u_char)(c) & 0x80)
158 1.3 leo #define IS_KEY(c) ((u_char)(c) < 0xf6)
159 1.1 leo
160 1.1 leo void
161 1.1 leo kbdenable()
162 1.1 leo {
163 1.3 leo int s, code;
164 1.1 leo
165 1.1 leo s = spltty();
166 1.3 leo
167 1.1 leo /*
168 1.3 leo * Clear error conditions...
169 1.1 leo */
170 1.3 leo while (KBD->ac_cs & (A_IRQ|A_RXRDY))
171 1.3 leo code = KBD->ac_da;
172 1.1 leo /*
173 1.1 leo * Enable interrupts from MFP
174 1.1 leo */
175 1.1 leo MFP->mf_iprb &= ~IB_AINT;
176 1.1 leo MFP->mf_ierb |= IB_AINT;
177 1.1 leo MFP->mf_imrb |= IB_AINT;
178 1.1 leo
179 1.1 leo kbd_softc.k_event_mode = 0;
180 1.1 leo kbd_softc.k_events.ev_io = 0;
181 1.3 leo kbd_softc.k_pkg_size = 0;
182 1.1 leo splx(s);
183 1.1 leo }
184 1.1 leo
185 1.1 leo int kbdopen(dev_t dev, int flags, int mode, struct proc *p)
186 1.1 leo {
187 1.3 leo if (kbd_softc.k_events.ev_io)
188 1.1 leo return EBUSY;
189 1.1 leo
190 1.1 leo kbd_softc.k_events.ev_io = p;
191 1.1 leo ev_init(&kbd_softc.k_events);
192 1.1 leo return (0);
193 1.1 leo }
194 1.1 leo
195 1.1 leo int
196 1.1 leo kbdclose(dev_t dev, int flags, int mode, struct proc *p)
197 1.1 leo {
198 1.1 leo /* Turn off event mode, dump the queue */
199 1.1 leo kbd_softc.k_event_mode = 0;
200 1.1 leo ev_fini(&kbd_softc.k_events);
201 1.1 leo kbd_softc.k_events.ev_io = NULL;
202 1.1 leo return (0);
203 1.1 leo }
204 1.1 leo
205 1.1 leo int
206 1.1 leo kbdread(dev_t dev, struct uio *uio, int flags)
207 1.1 leo {
208 1.1 leo return ev_read(&kbd_softc.k_events, uio, flags);
209 1.1 leo }
210 1.1 leo
211 1.1 leo int
212 1.1 leo kbdioctl(dev_t dev,u_long cmd,register caddr_t data,int flag,struct proc *p)
213 1.1 leo {
214 1.1 leo register struct kbd_softc *k = &kbd_softc;
215 1.1 leo
216 1.1 leo switch (cmd) {
217 1.1 leo case KIOCTRANS:
218 1.3 leo if (*(int *)data == TR_UNTRANS_EVENT)
219 1.1 leo return 0;
220 1.1 leo break;
221 1.1 leo
222 1.1 leo case KIOCGTRANS:
223 1.1 leo /*
224 1.1 leo * Get translation mode
225 1.1 leo */
226 1.1 leo *(int *)data = TR_UNTRANS_EVENT;
227 1.1 leo return 0;
228 1.1 leo
229 1.1 leo case KIOCSDIRECT:
230 1.1 leo k->k_event_mode = *(int *)data;
231 1.1 leo return 0;
232 1.1 leo
233 1.1 leo case FIONBIO: /* we will remove this someday (soon???) */
234 1.1 leo return 0;
235 1.1 leo
236 1.1 leo case FIOASYNC:
237 1.1 leo k->k_events.ev_async = *(int *)data != 0;
238 1.1 leo return 0;
239 1.1 leo
240 1.1 leo case TIOCSPGRP:
241 1.3 leo if (*(int *)data != k->k_events.ev_io->p_pgid)
242 1.1 leo return EPERM;
243 1.1 leo return 0;
244 1.1 leo
245 1.1 leo default:
246 1.1 leo return ENOTTY;
247 1.1 leo }
248 1.1 leo
249 1.1 leo /*
250 1.1 leo * We identified the ioctl, but we do not handle it.
251 1.1 leo */
252 1.1 leo return EOPNOTSUPP; /* misuse, but what the heck */
253 1.1 leo }
254 1.1 leo
255 1.1 leo int
256 1.1 leo kbdselect (dev_t dev, int rw, struct proc *p)
257 1.1 leo {
258 1.1 leo return ev_select (&kbd_softc.k_events, rw, p);
259 1.1 leo }
260 1.1 leo
261 1.1 leo /*
262 1.3 leo * Keyboard interrupt handler called straight from MFP at spl6.
263 1.1 leo */
264 1.6 leo void
265 1.1 leo kbdintr(sr)
266 1.1 leo int sr; /* sr at time of interrupt */
267 1.1 leo {
268 1.1 leo int code;
269 1.3 leo int got_char = 0;
270 1.1 leo
271 1.1 leo /*
272 1.1 leo * There may be multiple keys available. Read them all.
273 1.1 leo */
274 1.3 leo while (KBD->ac_cs & (A_RXRDY|A_OE|A_PE)) {
275 1.3 leo got_char = 1;
276 1.3 leo if (KBD->ac_cs & (A_OE|A_PE)) {
277 1.3 leo code = KBD->ac_da; /* Silently ignore errors */
278 1.1 leo continue;
279 1.1 leo }
280 1.1 leo kbd_ring[kbd_rbput++ & KBD_RING_MASK] = KBD->ac_da;
281 1.1 leo }
282 1.3 leo
283 1.3 leo /*
284 1.3 leo * If characters are waiting for transmit, send them.
285 1.3 leo */
286 1.3 leo if ((kbd_softc.k_soft_cs & A_TXINT) && (KBD->ac_cs & A_TXRDY)) {
287 1.3 leo if (kbd_softc.k_sendp != NULL)
288 1.3 leo KBD->ac_da = *kbd_softc.k_sendp++;
289 1.3 leo if (--kbd_softc.k_send_cnt <= 0) {
290 1.3 leo /*
291 1.3 leo * The total package has been transmitted,
292 1.3 leo * wakeup anyone waiting for it.
293 1.3 leo */
294 1.3 leo KBD->ac_cs = (kbd_softc.k_soft_cs &= ~A_TXINT);
295 1.3 leo kbd_softc.k_sendp = NULL;
296 1.3 leo kbd_softc.k_send_cnt = 0;
297 1.3 leo wakeup((caddr_t)&kbd_softc.k_send_cnt);
298 1.3 leo }
299 1.3 leo }
300 1.3 leo
301 1.3 leo /*
302 1.3 leo * Activate software-level to handle possible input.
303 1.3 leo */
304 1.3 leo if (got_char) {
305 1.3 leo if (!BASEPRI(sr)) {
306 1.3 leo if (!kbd_soft++)
307 1.3 leo add_sicallback(kbdsoft, 0, 0);
308 1.3 leo } else {
309 1.3 leo spl1();
310 1.10 leo kbdsoft(NULL, NULL);
311 1.3 leo }
312 1.1 leo }
313 1.1 leo }
314 1.1 leo
315 1.1 leo /*
316 1.1 leo * Keyboard soft interrupt handler
317 1.1 leo */
318 1.1 leo void
319 1.10 leo kbdsoft(junk1, junk2)
320 1.10 leo void *junk1, *junk2;
321 1.1 leo {
322 1.1 leo int s;
323 1.1 leo u_char code;
324 1.1 leo struct kbd_softc *k = &kbd_softc;
325 1.1 leo struct firm_event *fe;
326 1.1 leo int put;
327 1.1 leo int n, get;
328 1.1 leo
329 1.1 leo kbd_soft = 0;
330 1.1 leo get = kbd_rbget;
331 1.1 leo
332 1.3 leo for (;;) {
333 1.1 leo n = kbd_rbput;
334 1.3 leo if (get == n) /* We're done */
335 1.1 leo break;
336 1.1 leo n -= get;
337 1.3 leo if (n > KBD_RING_SIZE) { /* Ring buffer overflow */
338 1.1 leo get += n - KBD_RING_SIZE;
339 1.1 leo n = KBD_RING_SIZE;
340 1.1 leo }
341 1.3 leo while (--n >= 0) {
342 1.1 leo code = kbd_ring[get++ & KBD_RING_MASK];
343 1.1 leo
344 1.1 leo /*
345 1.3 leo * If collecting a package, stuff it in and
346 1.3 leo * continue.
347 1.3 leo */
348 1.3 leo if (k->k_pkg_size && (k->k_pkg_idx < k->k_pkg_size)) {
349 1.9 leo k->k_package[k->k_pkg_idx++] = code;
350 1.9 leo if (k->k_pkg_idx == k->k_pkg_size) {
351 1.9 leo /*
352 1.9 leo * Package is complete.
353 1.9 leo */
354 1.9 leo switch(k->k_pkg_type) {
355 1.5 leo #if NMOUSE > 0
356 1.9 leo case KBD_AMS_PKG:
357 1.9 leo case KBD_RMS_PKG:
358 1.9 leo case KBD_JOY1_PKG:
359 1.9 leo mouse_soft((REL_MOUSE *)k->k_package,
360 1.9 leo k->k_pkg_size, k->k_pkg_type);
361 1.5 leo #endif /* NMOUSE */
362 1.3 leo }
363 1.9 leo k->k_pkg_size = 0;
364 1.9 leo }
365 1.9 leo continue;
366 1.3 leo }
367 1.3 leo /*
368 1.3 leo * If this is a package header, init pkg. handling.
369 1.3 leo */
370 1.3 leo if (!IS_KEY(code)) {
371 1.3 leo kbd_pkg_start(k, code);
372 1.3 leo continue;
373 1.3 leo }
374 1.3 leo /*
375 1.1 leo * if not in event mode, deliver straight to ite to
376 1.1 leo * process key stroke
377 1.1 leo */
378 1.3 leo if (!k->k_event_mode) {
379 1.1 leo /* Gets to spltty() by itself */
380 1.1 leo ite_filter(code, ITEFILT_TTY);
381 1.1 leo continue;
382 1.1 leo }
383 1.1 leo
384 1.1 leo /*
385 1.1 leo * Keyboard is generating events. Turn this keystroke
386 1.1 leo * into an event and put it in the queue. If the queue
387 1.1 leo * is full, the keystroke is lost (sorry!).
388 1.1 leo */
389 1.1 leo s = spltty();
390 1.1 leo put = k->k_events.ev_put;
391 1.1 leo fe = &k->k_events.ev_q[put];
392 1.1 leo put = (put + 1) % EV_QSIZE;
393 1.3 leo if (put == k->k_events.ev_get) {
394 1.1 leo log(LOG_WARNING,
395 1.1 leo "keyboard event queue overflow\n");
396 1.1 leo splx(s);
397 1.1 leo continue;
398 1.1 leo }
399 1.1 leo fe->id = KEY_CODE(code);
400 1.1 leo fe->value = KEY_UP(code) ? VKEY_UP : VKEY_DOWN;
401 1.1 leo fe->time = time;
402 1.1 leo k->k_events.ev_put = put;
403 1.1 leo EV_WAKEUP(&k->k_events);
404 1.1 leo splx(s);
405 1.1 leo }
406 1.1 leo kbd_rbget = get;
407 1.1 leo }
408 1.1 leo }
409 1.1 leo
410 1.1 leo static char sound[] = {
411 1.1 leo 0xA8,0x01,0xA9,0x01,0xAA,0x01,0x00,
412 1.1 leo 0xF8,0x10,0x10,0x10,0x00,0x20,0x03
413 1.1 leo };
414 1.1 leo
415 1.6 leo void
416 1.1 leo kbdbell()
417 1.1 leo {
418 1.3 leo register int i, sps;
419 1.1 leo
420 1.9 leo sps = splhigh();
421 1.3 leo for (i = 0; i < sizeof(sound); i++) {
422 1.8 leo YM2149->sd_selr = i;
423 1.8 leo YM2149->sd_wdat = sound[i];
424 1.3 leo }
425 1.3 leo splx(sps);
426 1.1 leo }
427 1.1 leo
428 1.1 leo int
429 1.1 leo kbdgetcn()
430 1.1 leo {
431 1.1 leo u_char code;
432 1.4 leo int s = spltty();
433 1.4 leo int ints_active;
434 1.1 leo
435 1.4 leo ints_active = 0;
436 1.4 leo if (MFP->mf_imrb & IB_AINT) {
437 1.4 leo ints_active = 1;
438 1.4 leo MFP->mf_imrb &= ~IB_AINT;
439 1.4 leo }
440 1.3 leo for (;;) {
441 1.4 leo while (!((KBD->ac_cs & (A_IRQ|A_RXRDY)) == (A_IRQ|A_RXRDY)))
442 1.3 leo ; /* Wait for key */
443 1.3 leo if (KBD->ac_cs & (A_OE|A_PE)) {
444 1.3 leo code = KBD->ac_da; /* Silently ignore errors */
445 1.3 leo continue;
446 1.3 leo }
447 1.3 leo break;
448 1.3 leo }
449 1.1 leo
450 1.4 leo code = KBD->ac_da;
451 1.4 leo if (ints_active) {
452 1.4 leo MFP->mf_iprb &= ~IB_AINT;
453 1.4 leo MFP->mf_imrb |= IB_AINT;
454 1.4 leo }
455 1.1 leo
456 1.1 leo splx (s);
457 1.1 leo return code;
458 1.3 leo }
459 1.3 leo
460 1.3 leo /*
461 1.3 leo * Write a command to the keyboard in 'polled' mode.
462 1.3 leo */
463 1.3 leo static int
464 1.4 leo kbd_write_poll(cmd, len)
465 1.3 leo u_char *cmd;
466 1.3 leo int len;
467 1.3 leo {
468 1.3 leo int timeout;
469 1.3 leo
470 1.3 leo while (len-- > 0) {
471 1.3 leo KBD->ac_da = *cmd++;
472 1.3 leo for (timeout = 100; !(KBD->ac_cs & A_TXRDY); timeout--)
473 1.3 leo delay(10);
474 1.3 leo if (!(KBD->ac_cs & A_TXRDY))
475 1.3 leo return (0);
476 1.3 leo }
477 1.3 leo return (1);
478 1.3 leo }
479 1.3 leo
480 1.3 leo /*
481 1.3 leo * Write a command to the keyboard. Return when command is send.
482 1.3 leo */
483 1.4 leo void
484 1.3 leo kbd_write(cmd, len)
485 1.3 leo u_char *cmd;
486 1.3 leo int len;
487 1.3 leo {
488 1.3 leo struct kbd_softc *k = &kbd_softc;
489 1.3 leo int sps;
490 1.3 leo
491 1.3 leo /*
492 1.3 leo * Get to splhigh, 'real' interrupts arrive at spl6!
493 1.3 leo */
494 1.3 leo sps = splhigh();
495 1.3 leo
496 1.3 leo /*
497 1.3 leo * Make sure any privious write has ended...
498 1.3 leo */
499 1.3 leo while (k->k_sendp != NULL)
500 1.3 leo tsleep((caddr_t)&k->k_sendp, TTOPRI, "kbd_write1", 0);
501 1.3 leo
502 1.3 leo /*
503 1.3 leo * If the KBD-acia is not currently busy, send the first
504 1.3 leo * character now.
505 1.3 leo */
506 1.3 leo KBD->ac_cs = (k->k_soft_cs |= A_TXINT);
507 1.3 leo if (KBD->ac_cs & A_TXRDY) {
508 1.3 leo KBD->ac_da = *cmd++;
509 1.3 leo len--;
510 1.3 leo }
511 1.3 leo
512 1.3 leo /*
513 1.3 leo * If we're not yet done, wait until all characters are send.
514 1.3 leo */
515 1.3 leo if (len > 0) {
516 1.3 leo k->k_sendp = cmd;
517 1.3 leo k->k_send_cnt = len;
518 1.3 leo tsleep((caddr_t)&k->k_send_cnt, TTOPRI, "kbd_write2", 0);
519 1.3 leo }
520 1.3 leo splx(sps);
521 1.3 leo
522 1.3 leo /*
523 1.3 leo * Wakeup all procs waiting for us.
524 1.3 leo */
525 1.3 leo wakeup((caddr_t)&k->k_sendp);
526 1.3 leo }
527 1.3 leo
528 1.3 leo /*
529 1.3 leo * Setup softc-fields to assemble a keyboard package.
530 1.3 leo */
531 1.3 leo static void
532 1.3 leo kbd_pkg_start(kp, msg_start)
533 1.3 leo struct kbd_softc *kp;
534 1.3 leo u_char msg_start;
535 1.3 leo {
536 1.3 leo kp->k_pkg_idx = 1;
537 1.3 leo kp->k_package[0] = msg_start;
538 1.3 leo switch (msg_start) {
539 1.3 leo case 0xf6:
540 1.9 leo kp->k_pkg_type = KBD_MEM_PKG;
541 1.3 leo kp->k_pkg_size = 8;
542 1.3 leo break;
543 1.3 leo case 0xf7:
544 1.9 leo kp->k_pkg_type = KBD_AMS_PKG;
545 1.3 leo kp->k_pkg_size = 6;
546 1.3 leo break;
547 1.3 leo case 0xf8:
548 1.3 leo case 0xf9:
549 1.3 leo case 0xfa:
550 1.3 leo case 0xfb:
551 1.9 leo kp->k_pkg_type = KBD_RMS_PKG;
552 1.3 leo kp->k_pkg_size = 3;
553 1.3 leo break;
554 1.3 leo case 0xfc:
555 1.9 leo kp->k_pkg_type = KBD_CLK_PKG;
556 1.3 leo kp->k_pkg_size = 7;
557 1.3 leo break;
558 1.3 leo case 0xfe:
559 1.9 leo kp->k_pkg_type = KBD_JOY0_PKG;
560 1.9 leo kp->k_pkg_size = 2;
561 1.9 leo break;
562 1.3 leo case 0xff:
563 1.9 leo kp->k_pkg_type = KBD_JOY1_PKG;
564 1.3 leo kp->k_pkg_size = 2;
565 1.3 leo break;
566 1.3 leo default:
567 1.12 christos printf("kbd: Unknown packet 0x%x\n", msg_start);
568 1.3 leo break;
569 1.3 leo }
570 1.1 leo }
571