4 * Copyright (c) 2010 The DragonFly Project. All rights reserved.
6 * This code is derived from software contributed to The DragonFly Project
7 * by Matthew Dillon <dillon@backplane.com>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
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
17 * the documentation and/or other materials provided with the
19 * 3. Neither the name of The DragonFly Project nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific, prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
31 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/kernel.h>
42 #include <sys/malloc.h>
46 #include <sys/event.h>
47 #include <sys/vnode.h>
49 #include <sys/thread.h>
50 #include <sys/thread2.h>
52 #include <machine/console.h>
57 sw_probe(keyboard_switch_t *sw, int unit, void *arg, int flags)
61 error = (*sw->probe)(unit, arg, flags);
66 sw_init(keyboard_switch_t *sw, int unit, keyboard_t **kbdpp,
71 error = (*sw->init)(unit, kbdpp, arg, flags);
76 kbd_term(keyboard_t *kbd)
81 error = (*kbdsw[kbd->kb_index]->term)(kbd);
83 KBD_ALWAYS_UNLOCK(kbd);
84 /* kbd structure is stale if error is 0 */
89 kbd_intr(keyboard_t *kbd, void *arg)
95 error = (*kbdsw[kbd->kb_index]->intr)(kbd, arg);
102 kbd_test_if(keyboard_t *kbd)
108 error = (*kbdsw[kbd->kb_index]->test_if)(kbd);
115 kbd_enable(keyboard_t *kbd)
121 error = (*kbdsw[kbd->kb_index]->enable)(kbd);
128 kbd_disable(keyboard_t *kbd)
134 error = (*kbdsw[kbd->kb_index]->disable)(kbd);
141 kbd_read(keyboard_t *kbd, int wait)
147 error = (*kbdsw[kbd->kb_index]->read)(kbd, wait);
154 kbd_check(keyboard_t *kbd)
160 error = (*kbdsw[kbd->kb_index]->check)(kbd);
167 kbd_read_char(keyboard_t *kbd, int wait)
173 error = (*kbdsw[kbd->kb_index]->read_char)(kbd, wait);
180 kbd_check_char(keyboard_t *kbd)
186 error = (*kbdsw[kbd->kb_index]->check_char)(kbd);
193 kbd_ioctl(keyboard_t *kbd, u_long cmd, caddr_t data)
200 error = (*kbdsw[kbd->kb_index]->ioctl)(kbd, cmd, data);
209 kbd_lock(keyboard_t *kbd, int xlock)
215 error = (*kbdsw[kbd->kb_index]->lock)(kbd, xlock);
222 kbd_clear_state(keyboard_t *kbd)
227 (*kbdsw[kbd->kb_index]->clear_state)(kbd);
232 kbd_get_state(keyboard_t *kbd, void *buf, size_t len)
238 error = (*kbdsw[kbd->kb_index]->get_state)(kbd, buf, len);
245 kbd_set_state(keyboard_t *kbd, void *buf, size_t len)
251 error = (*kbdsw[kbd->kb_index]->set_state)(kbd, buf, len);
258 kbd_get_fkeystr(keyboard_t *kbd, int fkey, size_t *len)
264 retstr = (*kbdsw[kbd->kb_index]->get_fkeystr)(kbd, fkey, len);
271 * Polling mode set by debugger, we cannot lock!
274 kbd_poll(keyboard_t *kbd, int on)
280 error = (*kbdsw[kbd->kb_index]->poll)(kbd, on);
288 kbd_diag(keyboard_t *kbd, int level)
293 (*kbdsw[kbd->kb_index]->diag)(kbd, level);