summaryrefslogtreecommitdiffstats
path: root/sys/dev/syscons
diff options
context:
space:
mode:
authoremax <emax@FreeBSD.org>2006-02-28 23:46:23 +0000
committeremax <emax@FreeBSD.org>2006-02-28 23:46:23 +0000
commit1fe6de0cf418e43c04586dd954ccfcc43563cff3 (patch)
tree1dfe4b5e62c72a4a8be5ecf2979324cfc038d50e /sys/dev/syscons
parent8bb537fa797e0a20081f3e20ee8696b83d766291 (diff)
downloadFreeBSD-src-1fe6de0cf418e43c04586dd954ccfcc43563cff3.zip
FreeBSD-src-1fe6de0cf418e43c04586dd954ccfcc43563cff3.tar.gz
Integrate kbdmux(4) into syscons(4) and kbd code.
By default syscons(4) will look for the kbdmux(4) keyboard first, and then, if not found, look for any keyboard. Current kbd code is modified so if kbdmux(4) is the current keyboard, all new keyboards are automatically added to the kbdmux(4). Switch to kbdmux(4) can be done at boot time, by loading kbdmux module at the loader prompt, or at runtime, by kldload'ing the kbdmux module and releasing current active keyboard. If, for whatever reason, kbdmux(4) is not required/desired then just do not load it and everything should work as before. It is also possible to kldunload kbdmux at runtime and syscons(4) will automatically switch to the first available keyboard. No response from: freebsd-current@ MFC after: 1 day
Diffstat (limited to 'sys/dev/syscons')
-rw-r--r--sys/dev/syscons/syscons.c46
1 files changed, 42 insertions, 4 deletions
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index e1228d4..d98611b 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -165,6 +165,7 @@ SYSCTL_INT(_machdep, OID_AUTO, enable_panic_key, CTLFLAG_RW, &enable_panic_key,
static int debugger;
/* prototypes */
+static int sc_allocate_keyboard(sc_softc_t *sc, int unit);
static struct tty *sc_alloc_tty(struct cdev *dev);
static int scvidprobe(int unit, int flags, int cons);
static int sckbdprobe(int unit, int flags, int cons);
@@ -1676,8 +1677,7 @@ scrn_timer(void *arg)
if ((sc->kbd == NULL) && (sc->config & SC_AUTODETECT_KBD)) {
/* try to allocate a keyboard automatically */
if (++kbd_interval >= 25) {
- sc->keyboard = kbd_allocate("*", -1, (void *)&sc->keyboard,
- sckbdevent, sc);
+ sc->keyboard = sc_allocate_keyboard(sc, -1);
if (sc->keyboard >= 0) {
sc->kbd = kbd_get_keyboard(sc->keyboard);
kbd_ioctl(sc->kbd, KDSKBMODE,
@@ -2663,9 +2663,10 @@ scinit(int unit, int flags)
sc->adapter = vid_allocate("*", unit, (void *)&sc->adapter);
sc->adp = vid_get_adapter(sc->adapter);
/* assert((sc->adapter >= 0) && (sc->adp != NULL)) */
- sc->keyboard = kbd_allocate("*", unit, (void *)&sc->keyboard,
- sckbdevent, sc);
+
+ sc->keyboard = sc_allocate_keyboard(sc, unit);
DPRINTF(1, ("sc%d: keyboard %d\n", unit, sc->keyboard));
+
sc->kbd = kbd_get_keyboard(sc->keyboard);
if (sc->kbd != NULL) {
DPRINTF(1, ("sc%d: kbd index:%d, unit:%d, flags:0x%x\n",
@@ -3610,3 +3611,40 @@ sc_get_stat(struct cdev *devptr)
return (&main_console);
return (SC_STAT(devptr));
}
+
+/*
+ * Allocate active keyboard. Try to allocate "kbdmux" keyboard first, and,
+ * if found, add all non-busy keyboards to "kbdmux". Otherwise look for
+ * any keyboard.
+ */
+
+static int
+sc_allocate_keyboard(sc_softc_t *sc, int unit)
+{
+ int idx0, idx;
+ keyboard_t *k0, *k;
+ keyboard_info_t ki;
+
+ idx0 = kbd_allocate("kbdmux", -1, (void *)&sc->keyboard, sckbdevent, sc);
+ if (idx0 != -1) {
+ k0 = kbd_get_keyboard(idx0);
+
+ for (idx = kbd_find_keyboard2("*", -1, 0);
+ idx != -1;
+ idx = kbd_find_keyboard2("*", -1, idx + 1)) {
+ k = kbd_get_keyboard(idx);
+
+ if (idx == idx0 || KBD_IS_BUSY(k))
+ continue;
+
+ bzero(&ki, sizeof(ki));
+ strcpy(ki.kb_name, k->kb_name);
+ ki.kb_unit = k->kb_unit;
+
+ kbd_ioctl(k0, KBADDKBD, (caddr_t) &ki);
+ }
+ } else
+ idx0 = kbd_allocate("*", unit, (void *)&sc->keyboard, sckbdevent, sc);
+
+ return (idx0);
+}
OpenPOWER on IntegriCloud