Date: Sat, 17 Dec 2011 15:08:44 +0000 (UTC) From: Andriy Gapon <avg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r228631 - in head/sys: dev/cfe dev/dcons dev/ofw dev/sio dev/syscons dev/uart dev/usb/serial dev/xen/console gdb ia64/ia64 kern mips/adm5120 pc98/cbus powerpc/mambo sys Message-ID: <201112171508.pBHF8ibC064202@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: avg Date: Sat Dec 17 15:08:43 2011 New Revision: 228631 URL: http://svn.freebsd.org/changeset/base/228631 Log: kern cons: introduce infrastructure for console grabbing by kernel At the moment grab and ungrab methods of all console drivers are no-ops. Current intended meaning of the calls is that the kernel takes control of console input. In the future the semantics may be extended to mean that the calling thread takes full ownership of the console (e.g. console output from other threads could be suspended). Inspired by: bde MFC after: 2 months Modified: head/sys/dev/cfe/cfe_console.c head/sys/dev/dcons/dcons_os.c head/sys/dev/ofw/ofw_console.c head/sys/dev/sio/sio.c head/sys/dev/syscons/syscons.c head/sys/dev/uart/uart_tty.c head/sys/dev/usb/serial/usb_serial.c head/sys/dev/xen/console/console.c head/sys/gdb/gdb_cons.c head/sys/ia64/ia64/ssc.c head/sys/kern/kern_cons.c head/sys/mips/adm5120/console.c head/sys/pc98/cbus/sio.c head/sys/powerpc/mambo/mambo_console.c head/sys/sys/cons.h Modified: head/sys/dev/cfe/cfe_console.c ============================================================================== --- head/sys/dev/cfe/cfe_console.c Sat Dec 17 14:55:19 2011 (r228630) +++ head/sys/dev/cfe/cfe_console.c Sat Dec 17 15:08:43 2011 (r228631) @@ -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: head/sys/dev/dcons/dcons_os.c ============================================================================== --- head/sys/dev/dcons/dcons_os.c Sat Dec 17 14:55:19 2011 (r228630) +++ head/sys/dev/dcons/dcons_os.c Sat Dec 17 15:08:43 2011 (r228631) @@ -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: head/sys/dev/ofw/ofw_console.c ============================================================================== --- head/sys/dev/ofw/ofw_console.c Sat Dec 17 14:55:19 2011 (r228630) +++ head/sys/dev/ofw/ofw_console.c Sat Dec 17 15:08:43 2011 (r228631) @@ -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: head/sys/dev/sio/sio.c ============================================================================== --- head/sys/dev/sio/sio.c Sat Dec 17 14:55:19 2011 (r228630) +++ head/sys/dev/sio/sio.c Sat Dec 17 15:08:43 2011 (r228631) @@ -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: head/sys/dev/syscons/syscons.c ============================================================================== --- head/sys/dev/syscons/syscons.c Sat Dec 17 14:55:19 2011 (r228630) +++ head/sys/dev/syscons/syscons.c Sat Dec 17 15:08:43 2011 (r228631) @@ -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: head/sys/dev/uart/uart_tty.c ============================================================================== --- head/sys/dev/uart/uart_tty.c Sat Dec 17 14:55:19 2011 (r228630) +++ head/sys/dev/uart/uart_tty.c Sat Dec 17 15:08:43 2011 (r228631) @@ -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: head/sys/dev/usb/serial/usb_serial.c ============================================================================== --- head/sys/dev/usb/serial/usb_serial.c Sat Dec 17 14:55:19 2011 (r228630) +++ head/sys/dev/usb/serial/usb_serial.c Sat Dec 17 15:08:43 2011 (r228631) @@ -1308,6 +1308,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); @@ -1332,6 +1334,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: head/sys/dev/xen/console/console.c ============================================================================== --- head/sys/dev/xen/console/console.c Sat Dec 17 14:55:19 2011 (r228630) +++ head/sys/dev/xen/console/console.c Sat Dec 17 15:08:43 2011 (r228631) @@ -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: head/sys/gdb/gdb_cons.c ============================================================================== --- head/sys/gdb/gdb_cons.c Sat Dec 17 14:55:19 2011 (r228630) +++ head/sys/gdb/gdb_cons.c Sat Dec 17 15:08:43 2011 (r228631) @@ -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: head/sys/ia64/ia64/ssc.c ============================================================================== --- head/sys/ia64/ia64/ssc.c Sat Dec 17 14:55:19 2011 (r228630) +++ head/sys/ia64/ia64/ssc.c Sat Dec 17 15:08:43 2011 (r228631) @@ -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: head/sys/kern/kern_cons.c ============================================================================== --- head/sys/kern/kern_cons.c Sat Dec 17 14:55:19 2011 (r228630) +++ head/sys/kern/kern_cons.c Sat Dec 17 15:08:43 2011 (r228631) @@ -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: head/sys/mips/adm5120/console.c ============================================================================== --- head/sys/mips/adm5120/console.c Sat Dec 17 14:55:19 2011 (r228630) +++ head/sys/mips/adm5120/console.c Sat Dec 17 15:08:43 2011 (r228631) @@ -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: head/sys/pc98/cbus/sio.c ============================================================================== --- head/sys/pc98/cbus/sio.c Sat Dec 17 14:55:19 2011 (r228630) +++ head/sys/pc98/cbus/sio.c Sat Dec 17 15:08:43 2011 (r228631) @@ -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: head/sys/powerpc/mambo/mambo_console.c ============================================================================== --- head/sys/powerpc/mambo/mambo_console.c Sat Dec 17 14:55:19 2011 (r228630) +++ head/sys/powerpc/mambo/mambo_console.c Sat Dec 17 15:08:43 2011 (r228631) @@ -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: head/sys/sys/cons.h ============================================================================== --- head/sys/sys/cons.h Sat Dec 17 14:55:19 2011 (r228630) +++ head/sys/sys/cons.h Sat Dec 17 15:08:43 2011 (r228631) @@ -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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201112171508.pBHF8ibC064202>