svn commit: r235405 - in stable/9/sys: dev/cfe dev/dcons dev/ofw dev/sio dev/syscons dev/uart dev/usb/serial dev/xen/console gdb i386/conf ia64/ia64 kern mips/adm5120 pc98/cbus powerpc/mambo sys

Andriy Gapon avg at FreeBSD.org
Sun May 13 17:04:48 UTC 2012


Author: avg
Date: Sun May 13 17:04:46 2012
New Revision: 235405
URL: http://svn.freebsd.org/changeset/base/235405

Log:
  MFC r228631: kern cons: introduce infrastructure for console grabbing by
  kernel

Modified:
  stable/9/sys/dev/cfe/cfe_console.c
  stable/9/sys/dev/dcons/dcons_os.c
  stable/9/sys/dev/ofw/ofw_console.c
  stable/9/sys/dev/sio/sio.c
  stable/9/sys/dev/syscons/syscons.c
  stable/9/sys/dev/uart/uart_tty.c
  stable/9/sys/dev/usb/serial/usb_serial.c
  stable/9/sys/dev/xen/console/console.c
  stable/9/sys/gdb/gdb_cons.c
  stable/9/sys/ia64/ia64/ssc.c
  stable/9/sys/kern/kern_cons.c
  stable/9/sys/mips/adm5120/console.c
  stable/9/sys/pc98/cbus/sio.c
  stable/9/sys/powerpc/mambo/mambo_console.c
  stable/9/sys/sys/cons.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/cfe/cfe_console.c
==============================================================================
--- stable/9/sys/dev/cfe/cfe_console.c	Sun May 13 17:01:32 2012	(r235404)
+++ stable/9/sys/dev/cfe/cfe_console.c	Sun May 13 17:04:46 2012	(r235405)
@@ -76,6 +76,8 @@ static cn_init_t	cfe_cninit;
 static cn_term_t	cfe_cnterm;
 static cn_getc_t	cfe_cngetc;
 static cn_putc_t	cfe_cnputc;
+static cn_grab_t	cfe_cngrab;
+static cn_ungrab_t	cfe_cnungrab;
 
 CONSOLE_DRIVER(cfe);
 
@@ -183,6 +185,18 @@ cfe_cnterm(struct consdev *cp)
 
 }
 
+static void
+cfe_cngrab(struct consdev *cp)
+{
+
+}
+
+static void
+cfe_cnungrab(struct consdev *cp)
+{
+
+}
+
 static int
 cfe_cngetc(struct consdev *cp)
 {

Modified: stable/9/sys/dev/dcons/dcons_os.c
==============================================================================
--- stable/9/sys/dev/dcons/dcons_os.c	Sun May 13 17:01:32 2012	(r235404)
+++ stable/9/sys/dev/dcons/dcons_os.c	Sun May 13 17:04:46 2012	(r235405)
@@ -109,6 +109,8 @@ static cn_init_t	dcons_cninit;
 static cn_term_t	dcons_cnterm;
 static cn_getc_t	dcons_cngetc;
 static cn_putc_t	dcons_cnputc;
+static cn_grab_t	dcons_cngrab;
+static cn_ungrab_t	dcons_cnungrab;
 
 CONSOLE_DRIVER(dcons);
 
@@ -246,6 +248,16 @@ dcons_cnterm(struct consdev *cp)
 {
 }
 
+static void
+dcons_cngrab(struct consdev *cp)
+{
+}
+
+static void
+dcons_cnungrab(struct consdev *cp)
+{
+}
+
 static int
 dcons_cngetc(struct consdev *cp)
 {

Modified: stable/9/sys/dev/ofw/ofw_console.c
==============================================================================
--- stable/9/sys/dev/ofw/ofw_console.c	Sun May 13 17:01:32 2012	(r235404)
+++ stable/9/sys/dev/ofw/ofw_console.c	Sun May 13 17:04:46 2012	(r235405)
@@ -74,6 +74,8 @@ static cn_init_t	ofw_cninit;
 static cn_term_t	ofw_cnterm;
 static cn_getc_t	ofw_cngetc;
 static cn_putc_t	ofw_cnputc;
+static cn_grab_t	ofw_cngrab;
+static cn_ungrab_t	ofw_cnungrab;
 
 CONSOLE_DRIVER(ofw);
 
@@ -192,6 +194,16 @@ ofw_cnterm(struct consdev *cp)
 {
 }
 
+static void
+ofw_cngrab(struct consdev *cp)
+{
+}
+
+static void
+ofw_cnungrab(struct consdev *cp)
+{
+}
+
 static int
 ofw_cngetc(struct consdev *cp)
 {

Modified: stable/9/sys/dev/sio/sio.c
==============================================================================
--- stable/9/sys/dev/sio/sio.c	Sun May 13 17:01:32 2012	(r235404)
+++ stable/9/sys/dev/sio/sio.c	Sun May 13 17:04:46 2012	(r235405)
@@ -2293,6 +2293,8 @@ static cn_init_t sio_cninit;
 static cn_term_t sio_cnterm;
 static cn_getc_t sio_cngetc;
 static cn_putc_t sio_cnputc;
+static cn_grab_t sio_cngrab;
+static cn_ungrab_t sio_cnungrab;
 
 CONSOLE_DRIVER(sio);
 
@@ -2512,6 +2514,16 @@ sio_cnterm(cp)
 	comconsole = -1;
 }
 
+static void
+sio_cngrab(struct consdev *cp)
+{
+}
+
+static void
+sio_cnungrab(struct consdev *cp)
+{
+}
+
 static int
 sio_cngetc(struct consdev *cd)
 {

Modified: stable/9/sys/dev/syscons/syscons.c
==============================================================================
--- stable/9/sys/dev/syscons/syscons.c	Sun May 13 17:01:32 2012	(r235404)
+++ stable/9/sys/dev/syscons/syscons.c	Sun May 13 17:04:46 2012	(r235405)
@@ -229,6 +229,8 @@ static cn_init_t	sc_cninit;
 static cn_term_t	sc_cnterm;
 static cn_getc_t	sc_cngetc;
 static cn_putc_t	sc_cnputc;
+static cn_grab_t	sc_cngrab;
+static cn_ungrab_t	sc_cnungrab;
 
 CONSOLE_DRIVER(sc);
 
@@ -1609,6 +1611,16 @@ sc_cnterm(struct consdev *cp)
 }
 
 static void
+sc_cngrab(struct consdev *cp)
+{
+}
+
+static void
+sc_cnungrab(struct consdev *cp)
+{
+}
+
+static void
 sc_cnputc(struct consdev *cd, int c)
 {
     u_char buf[1];

Modified: stable/9/sys/dev/uart/uart_tty.c
==============================================================================
--- stable/9/sys/dev/uart/uart_tty.c	Sun May 13 17:01:32 2012	(r235404)
+++ stable/9/sys/dev/uart/uart_tty.c	Sun May 13 17:04:46 2012	(r235405)
@@ -54,6 +54,8 @@ static cn_init_t uart_cninit;
 static cn_term_t uart_cnterm;
 static cn_getc_t uart_cngetc;
 static cn_putc_t uart_cnputc;
+static cn_grab_t uart_cngrab;
+static cn_ungrab_t uart_cnungrab;
 
 CONSOLE_DRIVER(uart);
 
@@ -108,6 +110,16 @@ uart_cnterm(struct consdev *cp)
 }
 
 static void
+uart_cngrab(struct consdev *cp)
+{
+}
+
+static void
+uart_cnungrab(struct consdev *cp)
+{
+}
+
+static void
 uart_cnputc(struct consdev *cp, int c)
 {
 

Modified: stable/9/sys/dev/usb/serial/usb_serial.c
==============================================================================
--- stable/9/sys/dev/usb/serial/usb_serial.c	Sun May 13 17:01:32 2012	(r235404)
+++ stable/9/sys/dev/usb/serial/usb_serial.c	Sun May 13 17:04:46 2012	(r235405)
@@ -1336,6 +1336,8 @@ static cn_init_t ucom_cninit;
 static cn_term_t ucom_cnterm;
 static cn_getc_t ucom_cngetc;
 static cn_putc_t ucom_cnputc;
+static cn_grab_t ucom_cngrab;
+static cn_ungrab_t ucom_cnungrab;
 
 CONSOLE_DRIVER(ucom);
 
@@ -1360,6 +1362,16 @@ ucom_cnterm(struct consdev  *cp)
 {
 }
 
+static void
+ucom_cngrab(struct consdev *cp)
+{
+}
+
+static void
+ucom_cnungrab(struct consdev *cp)
+{
+}
+
 static int
 ucom_cngetc(struct consdev *cd)
 {

Modified: stable/9/sys/dev/xen/console/console.c
==============================================================================
--- stable/9/sys/dev/xen/console/console.c	Sun May 13 17:01:32 2012	(r235404)
+++ stable/9/sys/dev/xen/console/console.c	Sun May 13 17:04:46 2012	(r235405)
@@ -50,6 +50,8 @@ static cn_init_t        xc_cninit;
 static cn_term_t        xc_cnterm;
 static cn_getc_t        xc_cngetc;
 static cn_putc_t        xc_cnputc;
+static cn_grab_t        xc_cngrab;
+static cn_ungrab_t      xc_cnungrab;
 
 #define XC_POLLTIME 	(hz/10)
 
@@ -126,6 +128,16 @@ xc_cnterm(struct consdev *cp)
 { 
 }
 
+static void
+xc_cngrab(struct consdev *cp)
+{
+}
+
+static void
+xc_cnungrab(struct consdev *cp)
+{
+}
+
 static int
 xc_cngetc(struct consdev *dev)
 {

Modified: stable/9/sys/gdb/gdb_cons.c
==============================================================================
--- stable/9/sys/gdb/gdb_cons.c	Sun May 13 17:01:32 2012	(r235404)
+++ stable/9/sys/gdb/gdb_cons.c	Sun May 13 17:04:46 2012	(r235405)
@@ -87,6 +87,16 @@ gdb_cnterm(struct consdev *cp)
 {
 }
 
+static void
+gdb_cngrab(struct consdev *cp)
+{
+}
+
+static void
+gdb_cnungrab(struct consdev *cp)
+{
+}
+
 static int
 gdb_cngetc(struct consdev *cp)
 {

Modified: stable/9/sys/ia64/ia64/ssc.c
==============================================================================
--- stable/9/sys/ia64/ia64/ssc.c	Sun May 13 17:01:32 2012	(r235404)
+++ stable/9/sys/ia64/ia64/ssc.c	Sun May 13 17:04:46 2012	(r235405)
@@ -102,6 +102,16 @@ ssc_cnterm(struct consdev *cp)
 }
 
 static void
+ssc_cngrab(struct consdev *cp)
+{
+}
+
+static void
+ssc_cnungrab(struct consdev *cp)
+{
+}
+
+static void
 ssc_cnattach(void *arg)
 {
 	struct tty *tp;

Modified: stable/9/sys/kern/kern_cons.c
==============================================================================
--- stable/9/sys/kern/kern_cons.c	Sun May 13 17:01:32 2012	(r235404)
+++ stable/9/sys/kern/kern_cons.c	Sun May 13 17:04:46 2012	(r235405)
@@ -344,6 +344,32 @@ SYSCTL_PROC(_kern, OID_AUTO, consmute, C
 	0, sizeof(cn_mute), sysctl_kern_consmute, "I",
 	"State of the console muting");
 
+void
+cngrab()
+{
+	struct cn_device *cnd;
+	struct consdev *cn;
+
+	STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) {
+		cn = cnd->cnd_cn;
+		if (!kdb_active || !(cn->cn_flags & CN_FLAG_NODEBUG))
+			cn->cn_ops->cn_grab(cn);
+	}
+}
+
+void
+cnungrab()
+{
+	struct cn_device *cnd;
+	struct consdev *cn;
+
+	STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) {
+		cn = cnd->cnd_cn;
+		if (!kdb_active || !(cn->cn_flags & CN_FLAG_NODEBUG))
+			cn->cn_ops->cn_ungrab(cn);
+	}
+}
+
 /*
  * Low level console routines.
  */

Modified: stable/9/sys/mips/adm5120/console.c
==============================================================================
--- stable/9/sys/mips/adm5120/console.c	Sun May 13 17:01:32 2012	(r235404)
+++ stable/9/sys/mips/adm5120/console.c	Sun May 13 17:04:46 2012	(r235405)
@@ -49,6 +49,8 @@ static cn_init_t	uart_cninit;
 static cn_term_t	uart_cnterm;
 static cn_getc_t	uart_cngetc;
 static cn_putc_t	uart_cnputc;
+static cn_grab_t	uart_cngrab;
+static cn_ungrab_t	uart_cnungrab;
 
 static void
 uart_cnprobe(struct consdev *cp)
@@ -90,4 +92,16 @@ uart_cnterm(struct consdev * cp)
 
 }
 
+static void
+uart_cngrab(struct consdev *cp)
+{
+
+}
+
+static void
+uart_cnungrab(struct consdev *cp)
+{
+
+}
+
 CONSOLE_DRIVER(uart);

Modified: stable/9/sys/pc98/cbus/sio.c
==============================================================================
--- stable/9/sys/pc98/cbus/sio.c	Sun May 13 17:01:32 2012	(r235404)
+++ stable/9/sys/pc98/cbus/sio.c	Sun May 13 17:04:46 2012	(r235405)
@@ -3460,6 +3460,8 @@ static cn_init_t sio_cninit;
 static cn_term_t sio_cnterm;
 static cn_getc_t sio_cngetc;
 static cn_putc_t sio_cnputc;
+static cn_grab_t sio_cngrab;
+static cn_ungrab_t sio_cnungrab;
 
 CONSOLE_DRIVER(sio);
 
@@ -3679,6 +3681,16 @@ sio_cnterm(cp)
 	comconsole = -1;
 }
 
+static void
+sio_cngrab(struct consdev *cp)
+{
+}
+
+static void
+sio_cnungrab(struct consdev *cp)
+{
+}
+
 static int
 sio_cngetc(struct consdev *cd)
 {

Modified: stable/9/sys/powerpc/mambo/mambo_console.c
==============================================================================
--- stable/9/sys/powerpc/mambo/mambo_console.c	Sun May 13 17:01:32 2012	(r235404)
+++ stable/9/sys/powerpc/mambo/mambo_console.c	Sun May 13 17:04:46 2012	(r235405)
@@ -69,6 +69,8 @@ static cn_init_t	mambo_cninit;
 static cn_term_t	mambo_cnterm;
 static cn_getc_t	mambo_cngetc;
 static cn_putc_t	mambo_cnputc;
+static cn_grab_t	mambo_cngrab;
+static cn_ungrab_t	mambo_cnungrab;
 
 CONSOLE_DRIVER(mambo);
 
@@ -146,6 +148,16 @@ mambo_cnterm(struct consdev *cp)
 {
 }
 
+static void
+mambo_cngrab(struct consdev *cp)
+{
+}
+
+static void
+mambo_cnungrab(struct consdev *cp)
+{
+}
+
 static int
 mambo_cngetc(struct consdev *cp)
 {

Modified: stable/9/sys/sys/cons.h
==============================================================================
--- stable/9/sys/sys/cons.h	Sun May 13 17:01:32 2012	(r235404)
+++ stable/9/sys/sys/cons.h	Sun May 13 17:04:46 2012	(r235405)
@@ -44,6 +44,8 @@ struct tty;
 typedef	void	cn_probe_t(struct consdev *);
 typedef	void	cn_init_t(struct consdev *);
 typedef	void	cn_term_t(struct consdev *);
+typedef	void	cn_grab_t(struct consdev *);
+typedef	void	cn_ungrab_t(struct consdev *);
 typedef	int	cn_getc_t(struct consdev *);
 typedef	void	cn_putc_t(struct consdev *, int);
 
@@ -58,6 +60,10 @@ struct consdev_ops {
 				/* kernel getchar interface */
 	cn_putc_t	*cn_putc;
 				/* kernel putchar interface */
+	cn_grab_t	*cn_grab;
+				/* grab console for exclusive kernel use */
+	cn_ungrab_t	*cn_ungrab;
+				/* ungrab console */
 };
 
 struct consdev {
@@ -99,6 +105,8 @@ extern	struct tty *constty;	/* Temporary
 		.cn_term = name##_cnterm,				\
 		.cn_getc = name##_cngetc,				\
 		.cn_putc = name##_cnputc,				\
+		.cn_grab = name##_cngrab,				\
+		.cn_ungrab = name##_cnungrab,				\
 	};								\
 	CONSOLE_DEVICE(name##_consdev, name##_consdev_ops, NULL)
 
@@ -109,6 +117,8 @@ int	cnadd(struct consdev *);
 void	cnavailable(struct consdev *, int);
 void	cnremove(struct consdev *);
 void	cnselect(struct consdev *);
+void	cngrab(void);
+void	cnungrab(void);
 int	cncheckc(void);
 int	cngetc(void);
 void	cnputc(int);


More information about the svn-src-all mailing list