diff options
author | emax <emax@FreeBSD.org> | 2005-07-14 22:43:20 +0000 |
---|---|---|
committer | emax <emax@FreeBSD.org> | 2005-07-14 22:43:20 +0000 |
commit | d2de93780cda13f880d4a89bafd3fb9440420da5 (patch) | |
tree | af08529cd4d19775f2d0bfdaea819dcfeb31f2c0 /sys | |
parent | c224d596cf8de5c957244e362536d42d21579fa4 (diff) | |
download | FreeBSD-src-d2de93780cda13f880d4a89bafd3fb9440420da5.zip FreeBSD-src-d2de93780cda13f880d4a89bafd3fb9440420da5.tar.gz |
kbdmux(4) keyboard multiplexer integration
o Slightly change KBADDKBD and KBRELKBD ioctl() interface. Instead of passing
keyboard index pass keyboard_info_t structure with populated 'kb_unit' and
'kb_name' fields. Keyboard index is not very user-friendly and is not very
easy to obtain. Keyboard driver name and unit, on the other hand, is much
more user friendly and known almost all the time;
o Move definition of keyboard_info_t structure up;
o Teach kbdcontrol(1) how to attach/detach keyboards to/from the keyboard
multiplexor;
o Update kbdcontrol(1) man page and document new functionality.
To attach/detach keyboard to/from keyboard multiplexor one needs to use
keyboard device name (i.e. ukbd0).
MFC after: 1 week
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/kbdmux/kbdmux.c | 43 | ||||
-rw-r--r-- | sys/sys/kbio.h | 21 |
2 files changed, 35 insertions, 29 deletions
diff --git a/sys/dev/kbdmux/kbdmux.c b/sys/dev/kbdmux/kbdmux.c index 4a36513..f052a8e 100644 --- a/sys/dev/kbdmux/kbdmux.c +++ b/sys/dev/kbdmux/kbdmux.c @@ -143,7 +143,6 @@ MALLOC_DEFINE(M_KBDMUX, KEYBOARD_NAME, "Keyboard multiplexor"); struct kbdmux_kbd { keyboard_t *kbd; /* keyboard */ - int idx; /* keyboard index */ SLIST_ENTRY(kbdmux_kbd) next; /* link to next */ }; @@ -282,7 +281,6 @@ kbdmux_kbd_event(keyboard_t *kbd, int event, void *arg) SLIST_REMOVE(&state->ks_kbds, k, kbdmux_kbd, next); k->kbd = NULL; - k->idx = -1; free(k, M_KBDMUX); } @@ -500,7 +498,6 @@ kbdmux_term(keyboard_t *kbd) SLIST_REMOVE_HEAD(&state->ks_kbds, next); k->kbd = NULL; - k->idx = -1; free(k, M_KBDMUX); } @@ -903,6 +900,7 @@ kbdmux_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) kbdmux_state_t *state = (kbdmux_state_t *) kbd->kb_data; kbdmux_kbd_t *k; + keyboard_info_t *ki; int error = 0, mode; if (state == NULL) @@ -910,10 +908,17 @@ kbdmux_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) switch (cmd) { case KBADDKBD: /* add keyboard to the mux */ + ki = (keyboard_info_t *) arg; + + if (ki == NULL || ki->kb_unit < 0 || ki->kb_name[0] == '\0' || + strcmp(ki->kb_name, "*") == 0) + return (EINVAL); /* bad input */ + KBDMUX_LOCK(state); SLIST_FOREACH(k, &state->ks_kbds, next) - if (k->idx == *((int *) arg)) + if (k->kbd->kb_unit == ki->kb_unit && + strcmp(k->kbd->kb_name, ki->kb_name) == 0) break; if (k != NULL) { @@ -929,22 +934,17 @@ kbdmux_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) return (ENOMEM); /* out of memory */ } - k->kbd = kbd_get_keyboard(*((int *) arg)); - if (k->kbd == NULL) { - KBDMUX_UNLOCK(state); - free(k, M_KBDMUX); - - return (EINVAL); /* bad keyboard index */ - } - - k->idx = kbd_allocate(k->kbd->kb_name, k->kbd->kb_unit, + k->kbd = kbd_get_keyboard( + kbd_allocate( + ki->kb_name, + ki->kb_unit, (void *) &k->kbd, - kbdmux_kbd_event, (void *) state); - if (k->idx == -1) { + kbdmux_kbd_event, (void *) state)); + if (k->kbd == NULL) { KBDMUX_UNLOCK(state); free(k, M_KBDMUX); - return (EBUSY); /* keyboard is busy */ + return (EINVAL); /* bad keyboard */ } KBDMUX_ENABLE(k->kbd); @@ -964,7 +964,6 @@ kbdmux_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) kbd_release(k->kbd, &k->kbd); k->kbd = NULL; - k->idx = -1; free(k, M_KBDMUX); @@ -977,10 +976,17 @@ kbdmux_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) break; case KBRELKBD: /* release keyboard from the mux */ + ki = (keyboard_info_t *) arg; + + if (ki == NULL || ki->kb_unit < 0 || ki->kb_name[0] == '\0' || + strcmp(ki->kb_name, "*") == 0) + return (EINVAL); /* bad input */ + KBDMUX_LOCK(state); SLIST_FOREACH(k, &state->ks_kbds, next) - if (k->idx == *((int *) arg)) + if (k->kbd->kb_unit == ki->kb_unit && + strcmp(k->kbd->kb_name, ki->kb_name) == 0) break; if (k != NULL) { @@ -989,7 +995,6 @@ kbdmux_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg) SLIST_REMOVE(&state->ks_kbds, k, kbdmux_kbd, next); k->kbd = NULL; - k->idx = -1; free(k, M_KBDMUX); } diff --git a/sys/sys/kbio.h b/sys/sys/kbio.h index e357582..a4b1f04 100644 --- a/sys/sys/kbio.h +++ b/sys/sys/kbio.h @@ -60,16 +60,6 @@ /* 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) -#endif - -/* get keyboard information */ struct keyboard_info { int kb_index; /* kbdio index# */ char kb_name[16]; /* driver name */ @@ -79,6 +69,17 @@ struct keyboard_info { int kb_flags; /* internal flags */ }; typedef struct keyboard_info keyboard_info_t; + +/* add/remove keyboard to/from mux */ +#define KBADDKBD _IOW('K', 68, keyboard_info_t) /* add keyboard */ +#define KBRELKBD _IOW('K', 69, keyboard_info_t) /* release keyboard */ + +/* see console.h for the definition of the following ioctl */ +#if notdef +#define KDRASTER _IOW('K', 100, scr_size_t) +#endif + +/* get keyboard information */ #define KDGKBINFO _IOR('K', 101, keyboard_info_t) /* set/get keyboard repeat rate (new interface) */ |