diff options
-rw-r--r-- | sys/dev/kbd/kbd.c | 20 | ||||
-rw-r--r-- | sys/dev/kbd/kbdreg.h | 1 | ||||
-rw-r--r-- | sys/dev/syscons/syscons.c | 7 | ||||
-rw-r--r-- | sys/sys/kbio.h | 4 |
4 files changed, 29 insertions, 3 deletions
diff --git a/sys/dev/kbd/kbd.c b/sys/dev/kbd/kbd.c index da6ee39..9786441 100644 --- a/sys/dev/kbd/kbd.c +++ b/sys/dev/kbd/kbd.c @@ -282,13 +282,19 @@ keyboard_switch_t * exclusive use. */ -/* find the keyboard specified by a driver name and a unit number */ +/* + * find the keyboard specified by a driver name and a unit number + * starting at given index + */ int -kbd_find_keyboard(char *driver, int unit) +kbd_find_keyboard2(char *driver, int unit, int index) { int i; - for (i = 0; i < keyboards; ++i) { + if ((index < 0) || (index >= keyboards)) + return (-1); + + for (i = index; i < keyboards; ++i) { if (keyboard[i] == NULL) continue; if (!KBD_IS_VALID(keyboard[i])) @@ -299,9 +305,17 @@ kbd_find_keyboard(char *driver, int unit) continue; return (i); } + return (-1); } +/* find the keyboard specified by a driver name and a unit number */ +int +kbd_find_keyboard(char *driver, int unit) +{ + return (kbd_find_keyboard2(driver, unit, 0)); +} + /* allocate a keyboard */ int kbd_allocate(char *driver, int unit, void *id, kbd_callback_func_t *func, diff --git a/sys/dev/kbd/kbdreg.h b/sys/dev/kbd/kbdreg.h index 78a5af4..184c607 100644 --- a/sys/dev/kbd/kbdreg.h +++ b/sys/dev/kbd/kbdreg.h @@ -196,6 +196,7 @@ int kbd_release(keyboard_t *kbd, void *id); int kbd_change_callback(keyboard_t *kbd, void *id, kbd_callback_func_t *func, void *arg); int kbd_find_keyboard(char *driver, int unit); +int kbd_find_keyboard2(char *driver, int unit, int index); keyboard_t *kbd_get_keyboard(int index); /* a back door for the console driver to tickle the keyboard driver XXX */ diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 238c83f..8daca00 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -1164,6 +1164,13 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td) *(int *)data = scp->status & LED_MASK; return 0; + case KBADDKBD: /* add/remove keyboard to/from mux */ + case KBRELKBD: + error = kbd_ioctl(sc->kbd, cmd, data); + if (error == ENOIOCTL) + error = ENODEV; + return error; + case CONS_SETKBD: /* set the new keyboard */ { keyboard_t *newkbd; diff --git a/sys/sys/kbio.h b/sys/sys/kbio.h index 0ea3087..e357582 100644 --- a/sys/sys/kbio.h +++ b/sys/sys/kbio.h @@ -60,6 +60,10 @@ /* set keyboard repeat rate (obsolete, use KDSETREPEAT below) */ #define KDSETRAD _IO('K', 67 /*, int */) +/* add/remove keyboard to/from mux */ +#define KBADDKBD _IOW('K', 68, int) /* add keyboard */ +#define KBRELKBD _IOW('K', 69, int) /* release keyboard */ + /* see console.h for the definition of the following ioctl */ #if notdef #define KDRASTER _IOW('K', 100, scr_size_t) |