Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 May 2012 17:11:50 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r235408 - in stable/9/sys: dev/syscons i386/conf kern
Message-ID:  <201205131711.q4DHBoOi092587@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Sun May 13 17:11:49 2012
New Revision: 235408
URL: http://svn.freebsd.org/changeset/base/235408

Log:
  MFC r228644: syscons: provide a first iteration of cngrab/cnungrab
  implementation

Modified:
  stable/9/sys/dev/syscons/syscons.c
  stable/9/sys/dev/syscons/syscons.h
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/amd64/include/xen/   (props changed)
  stable/9/sys/boot/   (props changed)
  stable/9/sys/boot/i386/efi/   (props changed)
  stable/9/sys/boot/ia64/efi/   (props changed)
  stable/9/sys/boot/ia64/ski/   (props changed)
  stable/9/sys/boot/powerpc/boot1.chrp/   (props changed)
  stable/9/sys/boot/powerpc/ofw/   (props changed)
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)
  stable/9/sys/conf/   (props changed)
  stable/9/sys/contrib/dev/acpica/   (props changed)
  stable/9/sys/contrib/octeon-sdk/   (props changed)
  stable/9/sys/contrib/pf/   (props changed)
  stable/9/sys/contrib/x86emu/   (props changed)
  stable/9/sys/fs/   (props changed)
  stable/9/sys/fs/ntfs/   (props changed)
  stable/9/sys/i386/conf/XENHVM   (props changed)
  stable/9/sys/kern/subr_witness.c   (props changed)

Modified: stable/9/sys/dev/syscons/syscons.c
==============================================================================
--- stable/9/sys/dev/syscons/syscons.c	Sun May 13 17:10:38 2012	(r235407)
+++ stable/9/sys/dev/syscons/syscons.c	Sun May 13 17:11:49 2012	(r235408)
@@ -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 */

Modified: stable/9/sys/dev/syscons/syscons.h
==============================================================================
--- stable/9/sys/dev/syscons/syscons.h	Sun May 13 17:10:38 2012	(r235407)
+++ stable/9/sys/dev/syscons/syscons.h	Sun May 13 17:11:49 2012	(r235408)
@@ -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 */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201205131711.q4DHBoOi092587>