mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-15 10:17:20 +00:00
Remove explicit calls to keyboard methods with their respective variants
implemented with macros. This patch improves code readability. Reasoning behind kbdd_* is a "keyboard discipline". List of macros is supposed to be complete--all methods of keyboard_switch should have their respective macros from now on. Functionally, this code should be no-op. My intention is to leave current behaviour of code as is. Glanced at by: rwatson Reviewed by: emax, marcel Approved by: cognet
This commit is contained in:
parent
f1c24d6d4c
commit
259699b294
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=174984
@ -162,15 +162,15 @@ atkbd_timeout(void *arg)
|
||||
*/
|
||||
s = spltty();
|
||||
kbd = (keyboard_t *)arg;
|
||||
if ((*kbdsw[kbd->kb_index]->lock)(kbd, TRUE)) {
|
||||
if (kbdd_lock(kbd, TRUE)) {
|
||||
/*
|
||||
* We have seen the lock flag is not set. Let's reset
|
||||
* the flag early, otherwise the LED update routine fails
|
||||
* which may want the lock during the interrupt routine.
|
||||
*/
|
||||
(*kbdsw[kbd->kb_index]->lock)(kbd, FALSE);
|
||||
if ((*kbdsw[kbd->kb_index]->check_char)(kbd))
|
||||
(*kbdsw[kbd->kb_index]->intr)(kbd, NULL);
|
||||
kbdd_lock(kbd, FALSE);
|
||||
if (kbdd_check_char(kbd))
|
||||
kbdd_intr(kbd, NULL);
|
||||
}
|
||||
splx(s);
|
||||
timeout(atkbd_timeout, arg, hz/10);
|
||||
|
@ -158,9 +158,9 @@ atkbdresume(device_t dev)
|
||||
kbd->kb_flags &= ~KB_INITIALIZED;
|
||||
args[0] = device_get_unit(device_get_parent(dev));
|
||||
args[1] = rman_get_start(sc->intr);
|
||||
(*kbdsw[kbd->kb_index]->init)(device_get_unit(dev), &kbd,
|
||||
args, device_get_flags(dev));
|
||||
(*kbdsw[kbd->kb_index]->clear_state)(kbd);
|
||||
kbdd_init(kbd, device_get_unit(dev), &kbd, args,
|
||||
device_get_flags(dev));
|
||||
kbdd_clear_state(kbd);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -171,7 +171,7 @@ atkbdintr(void *arg)
|
||||
keyboard_t *kbd;
|
||||
|
||||
kbd = (keyboard_t *)arg;
|
||||
(*kbdsw[kbd->kb_index]->intr)(kbd, NULL);
|
||||
kbdd_intr(kbd, NULL);
|
||||
}
|
||||
|
||||
DRIVER_MODULE(atkbd, atkbdc, atkbd_driver, atkbd_devclass, 0, 0);
|
||||
|
@ -219,8 +219,7 @@ kbd_register(keyboard_t *kbd)
|
||||
strcpy(ki.kb_name, kbd->kb_name);
|
||||
ki.kb_unit = kbd->kb_unit;
|
||||
|
||||
(*kbdsw[mux->kb_index]->ioctl)
|
||||
(mux, KBADDKBD, (caddr_t) &ki);
|
||||
kbdd_ioctl(mux, KBADDKBD, (caddr_t) &ki);
|
||||
}
|
||||
|
||||
return (index);
|
||||
@ -237,8 +236,7 @@ kbd_register(keyboard_t *kbd)
|
||||
strcpy(ki.kb_name, kbd->kb_name);
|
||||
ki.kb_unit = kbd->kb_unit;
|
||||
|
||||
(*kbdsw[mux->kb_index]->ioctl)
|
||||
(mux, KBADDKBD, (caddr_t) &ki);
|
||||
kbdd_ioctl(mux, KBADDKBD, (caddr_t) &ki);
|
||||
}
|
||||
|
||||
return (index);
|
||||
@ -363,7 +361,7 @@ kbd_allocate(char *driver, int unit, void *id, kbd_callback_func_t *func,
|
||||
KBD_BUSY(keyboard[index]);
|
||||
keyboard[index]->kb_callback.kc_func = func;
|
||||
keyboard[index]->kb_callback.kc_arg = arg;
|
||||
(*kbdsw[index]->clear_state)(keyboard[index]);
|
||||
kbdd_clear_state(keyboard[index]);
|
||||
}
|
||||
splx(s);
|
||||
return (index);
|
||||
@ -385,7 +383,7 @@ kbd_release(keyboard_t *kbd, void *id)
|
||||
KBD_UNBUSY(kbd);
|
||||
kbd->kb_callback.kc_func = NULL;
|
||||
kbd->kb_callback.kc_arg = NULL;
|
||||
(*kbdsw[kbd->kb_index]->clear_state)(kbd);
|
||||
kbdd_clear_state(kbd);
|
||||
error = 0;
|
||||
}
|
||||
splx(s);
|
||||
@ -664,7 +662,7 @@ genkbdioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *
|
||||
kbd = kbd_get_keyboard(KBD_INDEX(dev));
|
||||
if ((kbd == NULL) || !KBD_IS_VALID(kbd))
|
||||
return (ENXIO);
|
||||
error = (*kbdsw[kbd->kb_index]->ioctl)(kbd, cmd, arg);
|
||||
error = kbdd_ioctl(kbd, cmd, arg);
|
||||
if (error == ENOIOCTL)
|
||||
error = ENODEV;
|
||||
return (error);
|
||||
@ -723,12 +721,12 @@ genkbd_event(keyboard_t *kbd, int event, void *arg)
|
||||
}
|
||||
|
||||
/* obtain the current key input mode */
|
||||
if ((*kbdsw[kbd->kb_index]->ioctl)(kbd, KDGKBMODE, (caddr_t)&mode))
|
||||
if (kbdd_ioctl(kbd, KDGKBMODE, (caddr_t)&mode))
|
||||
mode = K_XLATE;
|
||||
|
||||
/* read all pending input */
|
||||
while ((*kbdsw[kbd->kb_index]->check_char)(kbd)) {
|
||||
c = (*kbdsw[kbd->kb_index]->read_char)(kbd, FALSE);
|
||||
while (kbdd_check_char(kbd)) {
|
||||
c = kbdd_read_char(kbd, FALSE);
|
||||
if (c == NOKEY)
|
||||
continue;
|
||||
if (c == ERRKEY) /* XXX: ring bell? */
|
||||
@ -771,8 +769,7 @@ genkbd_event(keyboard_t *kbd, int event, void *arg)
|
||||
putc(KEYCHAR(c), &sc->gkb_q);
|
||||
break;
|
||||
case FKEY | SPCLKEY: /* a function key, return string */
|
||||
cp = (*kbdsw[kbd->kb_index]->get_fkeystr)(kbd,
|
||||
KEYCHAR(c), &len);
|
||||
cp = kbdd_get_fkeystr(kbd, KEYCHAR(c), &len);
|
||||
if (cp != NULL) {
|
||||
while (len-- > 0)
|
||||
putc(*cp++, &sc->gkb_q);
|
||||
@ -1110,7 +1107,7 @@ genkbd_diag(keyboard_t *kbd, int level)
|
||||
(s) |= l ## DOWN; \
|
||||
(s) ^= l ## ED; \
|
||||
i = (s) & LOCK_MASK; \
|
||||
(*kbdsw[(k)->kb_index]->ioctl)((k), KDSETLED, (caddr_t)&i); \
|
||||
kbdd_ioctl((k), KDSETLED, (caddr_t)&i); \
|
||||
}
|
||||
|
||||
static u_int
|
||||
@ -1270,8 +1267,7 @@ genkbd_keyaction(keyboard_t *kbd, int keycode, int up, int *shiftstate,
|
||||
#else
|
||||
state &= ~CLKED;
|
||||
i = state & LOCK_MASK;
|
||||
(*kbdsw[kbd->kb_index]->ioctl)(kbd, KDSETLED,
|
||||
(caddr_t)&i);
|
||||
kbdd_ioctl(kbd, KDSETLED, (caddr_t)&i);
|
||||
#endif
|
||||
break;
|
||||
case SLK:
|
||||
@ -1307,8 +1303,7 @@ genkbd_keyaction(keyboard_t *kbd, int keycode, int up, int *shiftstate,
|
||||
#else
|
||||
state |= CLKED;
|
||||
i = state & LOCK_MASK;
|
||||
(*kbdsw[kbd->kb_index]->ioctl)(kbd, KDSETLED,
|
||||
(caddr_t)&i);
|
||||
kbdd_ioctl(kbd, KDSETLED, (caddr_t)&i);
|
||||
#endif
|
||||
break;
|
||||
case SLK:
|
||||
|
@ -157,6 +157,50 @@ typedef struct keyboard_switch {
|
||||
kbd_diag_t *diag;
|
||||
} keyboard_switch_t;
|
||||
|
||||
/*
|
||||
* Keyboard disciplines: call actual handlers via kbdsw[].
|
||||
*/
|
||||
#define kbdd_probe(kbd, unit, arg, flags) \
|
||||
(*kbdsw[(kbd)->kb_index]->probe)((unit), (arg), (flags))
|
||||
#define kbdd_init(kbd, unit, kbdpp, arg, flags) \
|
||||
(*kbdsw[(kbd)->kb_index]->init)((unit), (kbdpp), (arg), (flags))
|
||||
#define kbdd_term(kbd) \
|
||||
(*kbdsw[(kbd)->kb_index]->term)((kbd))
|
||||
#define kbdd_intr(kbd, arg) \
|
||||
(*kbdsw[(kbd)->kb_index]->intr)((kbd), (arg))
|
||||
#define kbdd_test_if(kbd) \
|
||||
(*kbdsw[(kbd)->kb_index]->test_if)((kbd))
|
||||
#define kbdd_enable(kbd) \
|
||||
(*kbdsw[(kbd)->kb_index]->enable)((kbd))
|
||||
#define kbdd_disable(kbd) \
|
||||
(*kbdsw[(kbd)->kb_index]->disable)((kbd))
|
||||
#define kbdd_read(kbd, wait) \
|
||||
(*kbdsw[(kbd)->kb_index]->read)((kbd), (wait))
|
||||
#define kbdd_check(kbd) \
|
||||
(*kbdsw[(kbd)->kb_index]->check)((kbd))
|
||||
#define kbdd_read_char(kbd, wait) \
|
||||
(*kbdsw[(kbd)->kb_index]->read_char)((kbd), (wait))
|
||||
#define kbdd_check_char(kbd) \
|
||||
(*kbdsw[(kbd)->kb_index]->check_char)((kbd))
|
||||
#define kbdd_ioctl(kbd, cmd, arg) \
|
||||
(((kbd) == NULL) ? \
|
||||
ENODEV : \
|
||||
(*kbdsw[(kbd)->kb_index]->ioctl)((kbd), (cmd), (arg)))
|
||||
#define kbdd_lock(kbd, lockf) \
|
||||
(*kbdsw[(kbd)->kb_index]->lock)((kbd), (lockf))
|
||||
#define kbdd_clear_state(kbd) \
|
||||
(*kbdsw[(kbd)->kb_index]->clear_state)((kbd))
|
||||
#define kbdd_get_state(kbd, buf, len) \
|
||||
(*kbdsw[(kbd)->kb_index]->get_state)((kbd), (buf), (len))
|
||||
#define kbdd_set_state(kbd, buf, len) \
|
||||
(*kbdsw[(kbd)->kb_index]->set_state)((kbd), (buf), (len))
|
||||
#define kbdd_get_fkeystr(kbd, fkey, len) \
|
||||
(*kbdsw[(kbd)->kb_index]->get_fkeystr)((kbd), (fkey), (len))
|
||||
#define kbdd_poll(kbd, on) \
|
||||
(*kbdsw[(kbd)->kb_index]->poll)((kbd), (on))
|
||||
#define kbdd_diag(kbd, level) \
|
||||
(*kbdsw[(kbd)->kb_index]->diag)((kbd), (leve))
|
||||
|
||||
/* keyboard driver */
|
||||
typedef struct keyboard_driver {
|
||||
SLIST_ENTRY(keyboard_driver) link;
|
||||
|
@ -118,27 +118,6 @@ MALLOC_DEFINE(M_KBDMUX, KEYBOARD_NAME, "Keyboard multiplexor");
|
||||
taskqueue_enqueue(taskqueue_swi_giant, &(s)->ks_task)
|
||||
#endif /* not yet */
|
||||
|
||||
#define KBDMUX_INTR(kbd, arg) \
|
||||
(*kbdsw[(kbd)->kb_index]->intr)((kbd), (arg))
|
||||
|
||||
#define KBDMUX_IOCTL(kbd, cmd, arg) \
|
||||
(*kbdsw[(kbd)->kb_index]->ioctl)((kbd), (cmd), (caddr_t) (arg))
|
||||
|
||||
#define KBDMUX_CHECK_CHAR(kbd) \
|
||||
(*kbdsw[(kbd)->kb_index]->check_char)((kbd))
|
||||
|
||||
#define KBDMUX_READ_CHAR(kbd, wait) \
|
||||
(*kbdsw[(kbd)->kb_index]->read_char)((kbd), (wait))
|
||||
|
||||
#define KBDMUX_ENABLE(kbd) \
|
||||
(*kbdsw[(kbd)->kb_index]->enable)((kbd))
|
||||
|
||||
#define KBDMUX_POLL(kbd, on) \
|
||||
(*kbdsw[(kbd)->kb_index]->poll)((kbd), (on))
|
||||
|
||||
#define KBDMUX_CLEAR_STATE(kbd) \
|
||||
(*kbdsw[(kbd)->kb_index]->clear_state)((kbd))
|
||||
|
||||
/*
|
||||
* kbdmux keyboard
|
||||
*/
|
||||
@ -197,7 +176,7 @@ kbdmux_kbd_intr(void *xkbd, int pending)
|
||||
keyboard_t *kbd = (keyboard_t *) xkbd;
|
||||
kbdmux_state_t *state = (kbdmux_state_t *) kbd->kb_data;
|
||||
|
||||
KBDMUX_INTR(kbd, NULL);
|
||||
kbdd_intr(kbd, NULL);
|
||||
|
||||
KBDMUX_LOCK(state);
|
||||
|
||||
@ -258,8 +237,8 @@ kbdmux_kbd_event(keyboard_t *kbd, int event, void *arg)
|
||||
* NOKEY.
|
||||
*/
|
||||
|
||||
while (KBDMUX_CHECK_CHAR(kbd)) {
|
||||
c = KBDMUX_READ_CHAR(kbd, 0);
|
||||
while (kbdd_check_char(kbd)) {
|
||||
c = kbdd_read_char(kbd, 0);
|
||||
if (c == NOKEY)
|
||||
break;
|
||||
if (c == ERRKEY)
|
||||
@ -662,8 +641,8 @@ kbdmux_read_char(keyboard_t *kbd, int wait)
|
||||
kbdmux_kbd_t *k;
|
||||
|
||||
SLIST_FOREACH(k, &state->ks_kbds, next) {
|
||||
while (KBDMUX_CHECK_CHAR(k->kbd)) {
|
||||
scancode = KBDMUX_READ_CHAR(k->kbd, 0);
|
||||
while (kbdd_check_char(k->kbd)) {
|
||||
scancode = kbdd_read_char(k->kbd, 0);
|
||||
if (scancode == NOKEY)
|
||||
break;
|
||||
if (scancode == ERRKEY)
|
||||
@ -992,16 +971,16 @@ kbdmux_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
|
||||
return (EINVAL); /* bad keyboard */
|
||||
}
|
||||
|
||||
KBDMUX_ENABLE(k->kbd);
|
||||
KBDMUX_CLEAR_STATE(k->kbd);
|
||||
kbdd_enable(k->kbd);
|
||||
kbdd_clear_state(k->kbd);
|
||||
|
||||
/* set K_RAW mode on slave keyboard */
|
||||
mode = K_RAW;
|
||||
error = KBDMUX_IOCTL(k->kbd, KDSKBMODE, &mode);
|
||||
error = kbdd_ioctl(k->kbd, KDSKBMODE, (caddr_t)&mode);
|
||||
if (error == 0) {
|
||||
/* set lock keys state on slave keyboard */
|
||||
mode = state->ks_state & LOCK_MASK;
|
||||
error = KBDMUX_IOCTL(k->kbd, KDSKBSTATE, &mode);
|
||||
error = kbdd_ioctl(k->kbd, KDSKBSTATE, (caddr_t)&mode);
|
||||
}
|
||||
|
||||
if (error != 0) {
|
||||
@ -1115,7 +1094,7 @@ kbdmux_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
|
||||
|
||||
/* KDSETLED on all slave keyboards */
|
||||
SLIST_FOREACH(k, &state->ks_kbds, next)
|
||||
KBDMUX_IOCTL(k->kbd, KDSETLED, arg);
|
||||
kbdd_ioctl(k->kbd, KDSETLED, arg);
|
||||
|
||||
KBDMUX_UNLOCK(state);
|
||||
break;
|
||||
@ -1146,7 +1125,7 @@ kbdmux_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
|
||||
|
||||
/* KDSKBSTATE on all slave keyboards */
|
||||
SLIST_FOREACH(k, &state->ks_kbds, next)
|
||||
KBDMUX_IOCTL(k->kbd, KDSKBSTATE, arg);
|
||||
kbdd_ioctl(k->kbd, KDSKBSTATE, arg);
|
||||
|
||||
KBDMUX_UNLOCK(state);
|
||||
|
||||
@ -1192,7 +1171,7 @@ kbdmux_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
|
||||
|
||||
/* perform command on all slave keyboards */
|
||||
SLIST_FOREACH(k, &state->ks_kbds, next)
|
||||
KBDMUX_IOCTL(k->kbd, cmd, arg);
|
||||
kbdd_ioctl(k->kbd, cmd, arg);
|
||||
|
||||
KBDMUX_UNLOCK(state);
|
||||
break;
|
||||
@ -1205,7 +1184,7 @@ kbdmux_ioctl(keyboard_t *kbd, u_long cmd, caddr_t arg)
|
||||
|
||||
/* perform command on all slave keyboards */
|
||||
SLIST_FOREACH(k, &state->ks_kbds, next)
|
||||
KBDMUX_IOCTL(k->kbd, cmd, arg);
|
||||
kbdd_ioctl(k->kbd, cmd, arg);
|
||||
|
||||
KBDMUX_UNLOCK(state);
|
||||
/* FALLTHROUGH */
|
||||
@ -1302,7 +1281,7 @@ kbdmux_poll(keyboard_t *kbd, int on)
|
||||
|
||||
/* set poll on slave keyboards */
|
||||
SLIST_FOREACH(k, &state->ks_kbds, next)
|
||||
KBDMUX_POLL(k->kbd, on);
|
||||
kbdd_poll(k->kbd, on);
|
||||
|
||||
KBDMUX_UNLOCK(state);
|
||||
|
||||
|
@ -393,7 +393,7 @@ sc_attach_unit(int unit, int flags)
|
||||
scrn_timer(sc);
|
||||
|
||||
/* set up the keyboard */
|
||||
kbd_ioctl(sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
|
||||
kbdd_ioctl(sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
|
||||
update_kbd_state(scp, scp->status, LOCK_MASK);
|
||||
|
||||
printf("%s%d: %s <%d virtual consoles, flags=0x%x>\n",
|
||||
@ -510,7 +510,7 @@ scopen(struct cdev *dev, int flag, int mode, struct thread *td)
|
||||
#ifndef __sparc64__
|
||||
if (sc->kbd != NULL) {
|
||||
key.keynum = KEYCODE_BS;
|
||||
kbd_ioctl(sc->kbd, GIO_KEYMAPENT, (caddr_t)&key);
|
||||
kbdd_ioctl(sc->kbd, GIO_KEYMAPENT, (caddr_t)&key);
|
||||
tp->t_cc[VERASE] = key.key.map[0];
|
||||
}
|
||||
#endif
|
||||
@ -577,7 +577,7 @@ scclose(struct cdev *dev, int flag, int mode, struct thread *td)
|
||||
#endif
|
||||
scp->kbd_mode = K_XLATE;
|
||||
if (scp == scp->sc->cur_scp)
|
||||
kbd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
|
||||
kbdd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
|
||||
DPRINTF(5, ("done.\n"));
|
||||
}
|
||||
spltty();
|
||||
@ -641,7 +641,7 @@ sckbdevent(keyboard_t *thiskbd, int event, void *arg)
|
||||
ttyld_rint(cur_tty, KEYCHAR(c));
|
||||
break;
|
||||
case FKEY: /* function key, return string */
|
||||
cp = kbd_get_fkeystr(thiskbd, KEYCHAR(c), &len);
|
||||
cp = kbdd_get_fkeystr(thiskbd, KEYCHAR(c), &len);
|
||||
if (cp != NULL) {
|
||||
while (len-- > 0)
|
||||
ttyld_rint(cur_tty, *cp++);
|
||||
@ -1137,7 +1137,7 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
||||
|
||||
case KDGETREPEAT: /* get keyboard repeat & delay rates */
|
||||
case KDSETREPEAT: /* set keyboard repeat & delay rates (new) */
|
||||
error = kbd_ioctl(sc->kbd, cmd, data);
|
||||
error = kbdd_ioctl(sc->kbd, cmd, data);
|
||||
if (error == ENOIOCTL)
|
||||
error = ENODEV;
|
||||
return error;
|
||||
@ -1152,7 +1152,7 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
||||
case KDSETRAD: /* set keyboard repeat & delay rates (old) */
|
||||
if (*(int *)data & ~0x7f)
|
||||
return EINVAL;
|
||||
error = kbd_ioctl(sc->kbd, KDSETRAD, data);
|
||||
error = kbdd_ioctl(sc->kbd, KDSETRAD, data);
|
||||
if (error == ENOIOCTL)
|
||||
error = ENODEV;
|
||||
return error;
|
||||
@ -1171,7 +1171,7 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
||||
case K_CODE: /* switch to CODE mode */
|
||||
scp->kbd_mode = *(int *)data;
|
||||
if (scp == sc->cur_scp)
|
||||
kbd_ioctl(sc->kbd, KDSKBMODE, data);
|
||||
kbdd_ioctl(sc->kbd, KDSKBMODE, data);
|
||||
return 0;
|
||||
default:
|
||||
return EINVAL;
|
||||
@ -1183,7 +1183,7 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
||||
return 0;
|
||||
|
||||
case KDGKBINFO:
|
||||
error = kbd_ioctl(sc->kbd, cmd, data);
|
||||
error = kbdd_ioctl(sc->kbd, cmd, data);
|
||||
if (error == ENOIOCTL)
|
||||
error = ENODEV;
|
||||
return error;
|
||||
@ -1220,7 +1220,7 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
||||
return 0;
|
||||
|
||||
case KDGKBTYPE: /* get keyboard type */
|
||||
error = kbd_ioctl(sc->kbd, cmd, data);
|
||||
error = kbdd_ioctl(sc->kbd, cmd, data);
|
||||
if (error == ENOIOCTL) {
|
||||
/* always return something? XXX */
|
||||
*(int *)data = 0;
|
||||
@ -1251,7 +1251,7 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
||||
|
||||
case KBADDKBD: /* add/remove keyboard to/from mux */
|
||||
case KBRELKBD:
|
||||
error = kbd_ioctl(sc->kbd, cmd, data);
|
||||
error = kbdd_ioctl(sc->kbd, cmd, data);
|
||||
if (error == ENOIOCTL)
|
||||
error = ENODEV;
|
||||
return error;
|
||||
@ -1285,7 +1285,7 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
||||
}
|
||||
sc->kbd = kbd_get_keyboard(i); /* sc->kbd == newkbd */
|
||||
sc->keyboard = i;
|
||||
kbd_ioctl(sc->kbd, KDSKBMODE,
|
||||
kbdd_ioctl(sc->kbd, KDSKBMODE,
|
||||
(caddr_t)&sc->cur_scp->kbd_mode);
|
||||
update_kbd_state(sc->cur_scp, sc->cur_scp->status,
|
||||
LOCK_MASK);
|
||||
@ -1359,7 +1359,7 @@ scioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
|
||||
case PIO_DEADKEYMAP: /* set accent key translation table */
|
||||
case GETFKEY: /* get function key string */
|
||||
case SETFKEY: /* set function key string */
|
||||
error = kbd_ioctl(sc->kbd, cmd, data);
|
||||
error = kbdd_ioctl(sc->kbd, cmd, data);
|
||||
if (error == ENOIOCTL)
|
||||
error = ENODEV;
|
||||
return error;
|
||||
@ -1612,27 +1612,27 @@ sccngetch(int flags)
|
||||
* Make sure the keyboard is accessible even when the kbd device
|
||||
* driver is disabled.
|
||||
*/
|
||||
kbd_enable(scp->sc->kbd);
|
||||
kbdd_enable(scp->sc->kbd);
|
||||
|
||||
/* we shall always use the keyboard in the XLATE mode here */
|
||||
cur_mode = scp->kbd_mode;
|
||||
scp->kbd_mode = K_XLATE;
|
||||
kbd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
|
||||
kbdd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
|
||||
|
||||
kbd_poll(scp->sc->kbd, TRUE);
|
||||
kbdd_poll(scp->sc->kbd, TRUE);
|
||||
c = scgetc(scp->sc, SCGETC_CN | flags);
|
||||
kbd_poll(scp->sc->kbd, FALSE);
|
||||
kbdd_poll(scp->sc->kbd, FALSE);
|
||||
|
||||
scp->kbd_mode = cur_mode;
|
||||
kbd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
|
||||
kbd_disable(scp->sc->kbd);
|
||||
kbdd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
|
||||
kbdd_disable(scp->sc->kbd);
|
||||
splx(s);
|
||||
|
||||
switch (KEYFLAGS(c)) {
|
||||
case 0: /* normal char */
|
||||
return KEYCHAR(c);
|
||||
case FKEY: /* function key */
|
||||
p = kbd_get_fkeystr(scp->sc->kbd, KEYCHAR(c), (size_t *)&fkeycp);
|
||||
p = kbdd_get_fkeystr(scp->sc->kbd, KEYCHAR(c), (size_t *)&fkeycp);
|
||||
fkey.len = fkeycp;
|
||||
if ((p != NULL) && (fkey.len > 0)) {
|
||||
bcopy(p, fkey.str, fkey.len);
|
||||
@ -1717,7 +1717,7 @@ scrn_timer(void *arg)
|
||||
sc->keyboard = sc_allocate_keyboard(sc, -1);
|
||||
if (sc->keyboard >= 0) {
|
||||
sc->kbd = kbd_get_keyboard(sc->keyboard);
|
||||
kbd_ioctl(sc->kbd, KDSKBMODE,
|
||||
kbdd_ioctl(sc->kbd, KDSKBMODE,
|
||||
(caddr_t)&sc->cur_scp->kbd_mode);
|
||||
update_kbd_state(sc->cur_scp, sc->cur_scp->status,
|
||||
LOCK_MASK);
|
||||
@ -2501,7 +2501,7 @@ exchange_scr(sc_softc_t *sc)
|
||||
|
||||
/* set up the keyboard for the new screen */
|
||||
if (sc->old_scp->kbd_mode != scp->kbd_mode)
|
||||
kbd_ioctl(sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
|
||||
kbdd_ioctl(sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
|
||||
update_kbd_state(scp, scp->status, LOCK_MASK);
|
||||
|
||||
mark_all(scp);
|
||||
@ -3182,7 +3182,7 @@ scgetc(sc_softc_t *sc, u_int flags)
|
||||
scp = sc->cur_scp;
|
||||
/* first see if there is something in the keyboard port */
|
||||
for (;;) {
|
||||
c = kbd_read_char(sc->kbd, !(flags & SCGETC_NONBLOCK));
|
||||
c = kbdd_read_char(sc->kbd, !(flags & SCGETC_NONBLOCK));
|
||||
if (c == ERRKEY) {
|
||||
if (!(flags & SCGETC_CN))
|
||||
sc_bell(scp, bios_value.bell_pitch, BELL_DURATION);
|
||||
@ -3278,7 +3278,7 @@ scgetc(sc_softc_t *sc, u_int flags)
|
||||
case NLK: case CLK: case ALK:
|
||||
break;
|
||||
case SLK:
|
||||
kbd_ioctl(sc->kbd, KDGKBSTATE, (caddr_t)&f);
|
||||
kbdd_ioctl(sc->kbd, KDGKBSTATE, (caddr_t)&f);
|
||||
if (f & SLKED) {
|
||||
scp->status |= SLKED;
|
||||
} else {
|
||||
@ -3446,7 +3446,7 @@ save_kbd_state(scr_stat *scp)
|
||||
int state;
|
||||
int error;
|
||||
|
||||
error = kbd_ioctl(scp->sc->kbd, KDGKBSTATE, (caddr_t)&state);
|
||||
error = kbdd_ioctl(scp->sc->kbd, KDGKBSTATE, (caddr_t)&state);
|
||||
if (error == ENOIOCTL)
|
||||
error = ENODEV;
|
||||
if (error == 0) {
|
||||
@ -3463,7 +3463,7 @@ update_kbd_state(scr_stat *scp, int new_bits, int mask)
|
||||
int error;
|
||||
|
||||
if (mask != LOCK_MASK) {
|
||||
error = kbd_ioctl(scp->sc->kbd, KDGKBSTATE, (caddr_t)&state);
|
||||
error = kbdd_ioctl(scp->sc->kbd, KDGKBSTATE, (caddr_t)&state);
|
||||
if (error == ENOIOCTL)
|
||||
error = ENODEV;
|
||||
if (error)
|
||||
@ -3473,7 +3473,7 @@ update_kbd_state(scr_stat *scp, int new_bits, int mask)
|
||||
} else {
|
||||
state = new_bits & LOCK_MASK;
|
||||
}
|
||||
error = kbd_ioctl(scp->sc->kbd, KDSKBSTATE, (caddr_t)&state);
|
||||
error = kbdd_ioctl(scp->sc->kbd, KDSKBSTATE, (caddr_t)&state);
|
||||
if (error == ENOIOCTL)
|
||||
error = ENODEV;
|
||||
return error;
|
||||
@ -3485,7 +3485,7 @@ update_kbd_leds(scr_stat *scp, int which)
|
||||
int error;
|
||||
|
||||
which &= LOCK_MASK;
|
||||
error = kbd_ioctl(scp->sc->kbd, KDSETLED, (caddr_t)&which);
|
||||
error = kbdd_ioctl(scp->sc->kbd, KDSETLED, (caddr_t)&which);
|
||||
if (error == ENOIOCTL)
|
||||
error = ENODEV;
|
||||
return error;
|
||||
@ -3693,7 +3693,7 @@ sc_allocate_keyboard(sc_softc_t *sc, int unit)
|
||||
strcpy(ki.kb_name, k->kb_name);
|
||||
ki.kb_unit = k->kb_unit;
|
||||
|
||||
kbd_ioctl(k0, KBADDKBD, (caddr_t) &ki);
|
||||
kbdd_ioctl(k0, KBADDKBD, (caddr_t) &ki);
|
||||
}
|
||||
} else
|
||||
idx0 = kbd_allocate("*", unit, (void *)&sc->keyboard, sckbdevent, sc);
|
||||
|
@ -516,26 +516,6 @@ typedef struct {
|
||||
|
||||
#define ISSIGVALID(sig) ((sig) > 0 && (sig) < NSIG)
|
||||
|
||||
#define kbd_read_char(kbd, wait) \
|
||||
(*kbdsw[(kbd)->kb_index]->read_char)((kbd), (wait))
|
||||
#define kbd_check_char(kbd) \
|
||||
(*kbdsw[(kbd)->kb_index]->check_char)((kbd))
|
||||
#define kbd_enable(kbd) \
|
||||
(*kbdsw[(kbd)->kb_index]->enable)((kbd))
|
||||
#define kbd_disable(kbd) \
|
||||
(*kbdsw[(kbd)->kb_index]->disable)((kbd))
|
||||
#define kbd_lock(kbd, lockf) \
|
||||
(*kbdsw[(kbd)->kb_index]->lock)((kbd), (lockf))
|
||||
#define kbd_ioctl(kbd, cmd, arg) \
|
||||
(((kbd) == NULL) ? \
|
||||
ENODEV : (*kbdsw[(kbd)->kb_index]->ioctl)((kbd), (cmd), (arg)))
|
||||
#define kbd_clear_state(kbd) \
|
||||
(*kbdsw[(kbd)->kb_index]->clear_state)((kbd))
|
||||
#define kbd_get_fkeystr(kbd, fkey, len) \
|
||||
(*kbdsw[(kbd)->kb_index]->get_fkeystr)((kbd), (fkey), (len))
|
||||
#define kbd_poll(kbd, on) \
|
||||
(*kbdsw[(kbd)->kb_index]->poll)((kbd), (on))
|
||||
|
||||
#define SC_VIDEO_LOCKINIT(sc) \
|
||||
mtx_init(&(sc)->video_mtx, "syscons video lock", NULL,MTX_SPIN);
|
||||
#define SC_VIDEO_LOCK(sc) \
|
||||
|
@ -222,14 +222,14 @@ ukbd_detach(device_t self)
|
||||
DPRINTF(("%s: keyboard not attached!?\n", device_get_nameunit(self)));
|
||||
return ENXIO;
|
||||
}
|
||||
(*kbdsw[kbd->kb_index]->disable)(kbd);
|
||||
kbdd_disable(kbd);
|
||||
|
||||
#ifdef KBD_INSTALL_CDEV
|
||||
error = kbd_detach(kbd);
|
||||
if (error)
|
||||
return error;
|
||||
#endif
|
||||
error = (*kbdsw[kbd->kb_index]->term)(kbd);
|
||||
error = kbdd_term(kbd);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
@ -246,7 +246,7 @@ ukbd_resume(device_t self)
|
||||
kbd = kbd_get_keyboard(kbd_find_keyboard(DRIVER_NAME,
|
||||
device_get_unit(self)));
|
||||
if (kbd)
|
||||
(*kbdsw[kbd->kb_index]->clear_state)(kbd);
|
||||
kbdd_clear_state(kbd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -255,7 +255,7 @@ ukbd_intr(usbd_xfer_handle xfer, usbd_private_handle addr, usbd_status status)
|
||||
{
|
||||
keyboard_t *kbd = (keyboard_t *)addr;
|
||||
|
||||
(*kbdsw[kbd->kb_index]->intr)(kbd, (void *)status);
|
||||
kbdd_intr(kbd, (void *)status);
|
||||
}
|
||||
|
||||
#define UKBD_DEFAULT 0
|
||||
@ -705,7 +705,7 @@ ukbd_timeout(void *arg)
|
||||
kbd = (keyboard_t *)arg;
|
||||
state = (ukbd_state_t *)kbd->kb_data;
|
||||
s = splusb();
|
||||
(*kbdsw[kbd->kb_index]->intr)(kbd, (void *)USBD_NORMAL_COMPLETION);
|
||||
kbdd_intr(kbd, (void *)USBD_NORMAL_COMPLETION);
|
||||
callout_reset(&state->ks_timeout_handle, hz / 40, ukbd_timeout, arg);
|
||||
splx(s);
|
||||
}
|
||||
|
@ -278,11 +278,11 @@ vkbd_dev_close(struct cdev *dev, int foo, int bar, struct thread *td)
|
||||
|
||||
VKBD_UNLOCK(state);
|
||||
|
||||
(*kbdsw[kbd->kb_index]->disable)(kbd);
|
||||
kbdd_disable(kbd);
|
||||
#ifdef KBD_INSTALL_CDEV
|
||||
kbd_detach(kbd);
|
||||
#endif /* def KBD_INSTALL_CDEV */
|
||||
(*kbdsw[kbd->kb_index]->term)(kbd);
|
||||
kbdd_term(kbd);
|
||||
|
||||
/* XXX FIXME: dev->si_drv1 locking */
|
||||
dev->si_drv1 = NULL;
|
||||
@ -437,8 +437,7 @@ vkbd_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thre
|
||||
{
|
||||
keyboard_t *kbd = VKBD_KEYBOARD(dev);
|
||||
|
||||
return ((kbd == NULL)? ENXIO :
|
||||
(*kbdsw[kbd->kb_index]->ioctl)(kbd, cmd, data));
|
||||
return ((kbd == NULL)? ENXIO : kbdd_ioctl(kbd, cmd, data));
|
||||
}
|
||||
|
||||
/* Poll device */
|
||||
@ -482,7 +481,7 @@ vkbd_dev_intr(void *xkbd, int pending)
|
||||
keyboard_t *kbd = (keyboard_t *) xkbd;
|
||||
vkbd_state_t *state = (vkbd_state_t *) kbd->kb_data;
|
||||
|
||||
(*kbdsw[kbd->kb_index]->intr)(kbd, NULL);
|
||||
kbdd_intr(kbd, NULL);
|
||||
|
||||
VKBD_LOCK(state);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user