summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2011-12-17 15:57:39 +0000
committeravg <avg@FreeBSD.org>2011-12-17 15:57:39 +0000
commitfbf65ae4d96ff39ba7fb93a69693826ee378cd3c (patch)
treef4ce5ee7915aba4862196e01d66e166c4a6c407f /sys/dev
parent34b585c85317ba8042b1a3bb6c3f7ed15617b595 (diff)
downloadFreeBSD-src-fbf65ae4d96ff39ba7fb93a69693826ee378cd3c.zip
FreeBSD-src-fbf65ae4d96ff39ba7fb93a69693826ee378cd3c.tar.gz
syscons: provide a first iteration of cngrab/cnungrab implementation
- put underlying keyboard(s) into the polling mode for the whole duration of the grab, instead of the previous behavior of going into and out of the polling mode around each polling attempt - ditto for setting K_XLATE mode and enabling a disabled keyboard Inspired by: bde MFC after: 2 months
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/syscons/syscons.c54
-rw-r--r--sys/dev/syscons/syscons.h2
2 files changed, 37 insertions, 19 deletions
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index f25026e..cc54de1 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -1613,11 +1613,46 @@ sc_cnterm(struct consdev *cp)
static void
sc_cngrab(struct consdev *cp)
{
+ scr_stat *scp;
+
+ scp = sc_console->sc->cur_scp;
+ if (scp->sc->kbd == NULL)
+ return;
+
+ if (scp->grabbed++ > 0)
+ return;
+
+ /*
+ * Make sure the keyboard is accessible even when the kbd device
+ * driver is disabled.
+ */
+ kbdd_enable(scp->sc->kbd);
+
+ /* we shall always use the keyboard in the XLATE mode here */
+ scp->kbd_prev_mode = scp->kbd_mode;
+ scp->kbd_mode = K_XLATE;
+ (void)kbdd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
+
+ kbdd_poll(scp->sc->kbd, TRUE);
}
static void
sc_cnungrab(struct consdev *cp)
{
+ scr_stat *scp;
+
+ scp = sc_console->sc->cur_scp; /* XXX */
+ if (scp->sc->kbd == NULL)
+ return;
+
+ if (--scp->grabbed > 0)
+ return;
+
+ kbdd_poll(scp->sc->kbd, FALSE);
+
+ scp->kbd_mode = scp->kbd_prev_mode;
+ (void)kbdd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
+ kbdd_disable(scp->sc->kbd);
}
static void
@@ -1675,7 +1710,6 @@ sc_cngetc(struct consdev *cd)
static int fkeycp;
scr_stat *scp;
const u_char *p;
- int cur_mode;
int s = spltty(); /* block sckbdevent and scrn_timer while we poll */
int c;
@@ -1699,25 +1733,7 @@ sc_cngetc(struct consdev *cd)
return -1;
}
- /*
- * Make sure the keyboard is accessible even when the kbd device
- * driver is disabled.
- */
- 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;
- (void)kbdd_ioctl(scp->sc->kbd, KDSKBMODE, (caddr_t)&scp->kbd_mode);
-
- kbdd_poll(scp->sc->kbd, TRUE);
c = scgetc(scp->sc, SCGETC_CN | SCGETC_NONBLOCK);
- kbdd_poll(scp->sc->kbd, FALSE);
-
- scp->kbd_mode = cur_mode;
- (void)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 */
diff --git a/sys/dev/syscons/syscons.h b/sys/dev/syscons/syscons.h
index 7280d89..e88ac43 100644
--- a/sys/dev/syscons/syscons.h
+++ b/sys/dev/syscons/syscons.h
@@ -301,7 +301,9 @@ typedef struct scr_stat {
void *ts;
int status; /* status (bitfield) */
+ int grabbed;
int kbd_mode; /* keyboard I/O mode */
+ int kbd_prev_mode; /* keyboard I/O mode */
int cursor_pos; /* cursor buffer position */
int cursor_oldpos; /* cursor old buffer position */
OpenPOWER on IntegriCloud