diff --git a/sys/kern/kern_cons.c b/sys/kern/kern_cons.c index a99699ed5bce..040aa3932a1a 100644 --- a/sys/kern/kern_cons.c +++ b/sys/kern/kern_cons.c @@ -103,7 +103,7 @@ int cons_avail_mask = 0; /* Bit mask. Each registered low level console * this bit cleared. */ -static int cn_mute; +int cn_mute; SYSCTL_INT(_kern, OID_AUTO, consmute, CTLFLAG_RW, &cn_mute, 0, "State of the console muting"); @@ -138,6 +138,18 @@ kbdinit(void) } +static void +mute_console(void *data __unused) +{ + + if ((boothowto & (RB_MUTEMSGS | RB_VERBOSE)) == RB_MUTEMSGS) { + printf("-- Muting boot messages --\n"); + cn_mute = 1; + } +} + +SYSINIT(mute_console, SI_SUB_COPYRIGHT, SI_ORDER_ANY, mute_console, NULL); + void cninit(void) { diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c index b0a3c3fa9e91..afeb320405d0 100644 --- a/sys/kern/kern_shutdown.c +++ b/sys/kern/kern_shutdown.c @@ -942,6 +942,9 @@ vpanic(const char *fmt, va_list ap) newpanic = 1; } + /* Unmute when panic */ + cn_mute = 0; + if (newpanic) { (void)vsnprintf(buf, sizeof(buf), fmt, ap); panicstr = buf; diff --git a/sys/kern/subr_boot.c b/sys/kern/subr_boot.c index 5b80200a2f7d..b721abf7013c 100644 --- a/sys/kern/subr_boot.c +++ b/sys/kern/subr_boot.c @@ -70,6 +70,7 @@ static struct { "boot_gdb", RB_GDB}, { "boot_multicons", RB_MULTIPLE}, { "boot_mute", RB_MUTE}, + { "boot_mutemsgs", RB_MUTEMSGS}, { "boot_pause", RB_PAUSE}, { "boot_serial", RB_SERIAL}, { "boot_single", RB_SINGLE}, @@ -133,10 +134,10 @@ boot_parse_arg(const char *v) #if 0 /* Need to see if this is better or worse than the meat of the #else */ -static const char howto_switches[] = "aCdrgDmphsv"; +static const char howto_switches[] = "aCdrgDmMphsv"; static int howto_masks[] = { RB_ASKNAME, RB_CDROM, RB_KDB, RB_DFLTROOT, RB_GDB, RB_MULTIPLE, - RB_MUTE, RB_PAUSE, RB_SERIAL, RB_SINGLE, RB_VERBOSE + RB_MUTE, RB_MUTEMSGS, RB_PAUSE, RB_SERIAL, RB_SINGLE, RB_VERBOSE }; opts = strchr(kargs, '-'); @@ -160,6 +161,7 @@ static int howto_masks[] = { case 'd': howto |= RB_KDB; break; case 'D': howto |= RB_MULTIPLE; break; case 'm': howto |= RB_MUTE; break; + case 'M': howto |= RB_MUTEMSGS; break; case 'g': howto |= RB_GDB; break; case 'h': howto |= RB_SERIAL; break; case 'p': howto |= RB_PAUSE; break; diff --git a/sys/sys/cons.h b/sys/sys/cons.h index 191d77598b77..78df26858376 100644 --- a/sys/sys/cons.h +++ b/sys/sys/cons.h @@ -94,6 +94,8 @@ struct consdev { #ifdef _KERNEL +extern int cn_mute; + extern struct msgbuf consmsgbuf; /* Message buffer for constty. */ extern struct tty *constty; /* Temporary virtual console. */ diff --git a/sys/sys/reboot.h b/sys/sys/reboot.h index 78572365e158..26e78632fb2c 100644 --- a/sys/sys/reboot.h +++ b/sys/sys/reboot.h @@ -60,6 +60,7 @@ #define RB_PAUSE 0x100000 /* pause after each output line during probe */ #define RB_REROOT 0x200000 /* unmount the rootfs and mount it again */ #define RB_POWERCYCLE 0x400000 /* Power cycle if possible */ +#define RB_MUTEMSGS 0x800000 /* start up with console muted after banner */ #define RB_PROBE 0x10000000 /* Probe multiple consoles */ #define RB_MULTIPLE 0x20000000 /* use multiple consoles */