From 28703190c508bd3fce0707743392b78592a14b67 Mon Sep 17 00:00:00 2001 From: Guido van Rooij Date: Mon, 10 Dec 2001 20:02:22 +0000 Subject: [PATCH] Add new boot flag to i386 boot: -p. This flag adds a pausing utility. When ran with -p, during the kernel probing phase, the kernel will pause after each line of output. This pausing can be ended with the '.' key, and is automatically suspended when entering ddb. This flag comes in handy at systems without a serial port that either hang during booting or reser. Reviewed by: (partly by jlemon) MFC after: 1 week --- sbin/reboot/boot_i386.8 | 2 ++ sys/amd64/amd64/autoconf.c | 2 +- sys/boot/i386/libi386/bootinfo.c | 3 +++ sys/boot/i386/libi386/bootinfo32.c | 3 +++ sys/boot/i386/libi386/bootinfo64.c | 3 +++ sys/i386/i386/autoconf.c | 2 +- sys/kern/tty_cons.c | 24 ++++++++++++++++++++++++ sys/sys/cons.h | 1 + sys/sys/reboot.h | 1 + 9 files changed, 39 insertions(+), 2 deletions(-) diff --git a/sbin/reboot/boot_i386.8 b/sbin/reboot/boot_i386.8 index 05c44c76aa82..2879a3aa3096 100644 --- a/sbin/reboot/boot_i386.8 +++ b/sbin/reboot/boot_i386.8 @@ -223,6 +223,8 @@ probe the keyboard. If no keyboard is found, the and .Fl h options are automatically set. +.It Fl p +pause after each attached device during the device probing phase. .It Fl r use the statically configured default for the device containing the root file system diff --git a/sys/amd64/amd64/autoconf.c b/sys/amd64/amd64/autoconf.c index 95943cd20990..a816eedecfde 100644 --- a/sys/amd64/amd64/autoconf.c +++ b/sys/amd64/amd64/autoconf.c @@ -176,7 +176,7 @@ configure_final(dummy) { int i; -/* cninit_finish(); */ + cninit_finish(); if (bootverbose) { diff --git a/sys/boot/i386/libi386/bootinfo.c b/sys/boot/i386/libi386/bootinfo.c index 8e5c752fe4c3..1c6b1d23e228 100644 --- a/sys/boot/i386/libi386/bootinfo.c +++ b/sys/boot/i386/libi386/bootinfo.c @@ -100,6 +100,9 @@ bi_getboothowto(char *kargs) case 'h': howto |= RB_SERIAL; break; + case 'p': + howto |= RB_PAUSE; + break; case 'r': howto |= RB_DFLTROOT; break; diff --git a/sys/boot/i386/libi386/bootinfo32.c b/sys/boot/i386/libi386/bootinfo32.c index 8e5c752fe4c3..1c6b1d23e228 100644 --- a/sys/boot/i386/libi386/bootinfo32.c +++ b/sys/boot/i386/libi386/bootinfo32.c @@ -100,6 +100,9 @@ bi_getboothowto(char *kargs) case 'h': howto |= RB_SERIAL; break; + case 'p': + howto |= RB_PAUSE; + break; case 'r': howto |= RB_DFLTROOT; break; diff --git a/sys/boot/i386/libi386/bootinfo64.c b/sys/boot/i386/libi386/bootinfo64.c index 8e5c752fe4c3..1c6b1d23e228 100644 --- a/sys/boot/i386/libi386/bootinfo64.c +++ b/sys/boot/i386/libi386/bootinfo64.c @@ -100,6 +100,9 @@ bi_getboothowto(char *kargs) case 'h': howto |= RB_SERIAL; break; + case 'p': + howto |= RB_PAUSE; + break; case 'r': howto |= RB_DFLTROOT; break; diff --git a/sys/i386/i386/autoconf.c b/sys/i386/i386/autoconf.c index 95943cd20990..a816eedecfde 100644 --- a/sys/i386/i386/autoconf.c +++ b/sys/i386/i386/autoconf.c @@ -176,7 +176,7 @@ configure_final(dummy) { int i; -/* cninit_finish(); */ + cninit_finish(); if (bootverbose) { diff --git a/sys/kern/tty_cons.c b/sys/kern/tty_cons.c index d25e42037054..ad752057c7dd 100644 --- a/sys/kern/tty_cons.c +++ b/sys/kern/tty_cons.c @@ -55,6 +55,8 @@ #include #include +#include + #include static d_open_t cnopen; @@ -112,6 +114,9 @@ static int cn_mute; static int openflag; /* how /dev/console was opened */ static int cn_is_open; static dev_t cn_devfsdev; /* represents the device private info */ +static u_char console_pausing; /* pause after each line during probe */ +static char *console_pausestr= +""; void cndebug(char *); @@ -162,12 +167,20 @@ cninit(void) cnadd(best_cn); best_cn->cn_init(best_cn); } + if (boothowto & RB_PAUSE) + console_pausing = 1; /* * Make the best console the preferred console. */ cnselect(best_cn); } +void +cninit_finish() +{ + console_pausing = 0; +} + /* add a new physical console to back the virtual console */ int cnadd(struct consdev *cn) @@ -526,6 +539,7 @@ cnputc(int c) { struct cn_device *cnd; struct consdev *cn; + char *cp; if (cn_mute || c == '\0') return; @@ -535,6 +549,16 @@ cnputc(int c) cn->cn_putc(cn->cn_dev, '\r'); cn->cn_putc(cn->cn_dev, c); } + if (console_pausing && !db_active && (c == '\n')) { + for (cp = console_pausestr; *cp != '\0'; cp++) + cnputc(*cp); + if (cngetc() == '.') + console_pausing = 0; + cnputc('\r'); + for (cp = console_pausestr; *cp != '\0'; cp++) + cnputc(' '); + cnputc('\r'); + } } void diff --git a/sys/sys/cons.h b/sys/sys/cons.h index 73f2e9da6c54..a65647ec0387 100644 --- a/sys/sys/cons.h +++ b/sys/sys/cons.h @@ -88,6 +88,7 @@ extern int cons_unavail; /* Other kernel entry points. */ void cninit(void); +void cninit_finish(void); int cnadd(struct consdev *); void cnremove(struct consdev *); void cnselect(struct consdev *); diff --git a/sys/sys/reboot.h b/sys/sys/reboot.h index 19e7cc36405c..0a45bcba0495 100644 --- a/sys/sys/reboot.h +++ b/sys/sys/reboot.h @@ -61,6 +61,7 @@ #define RB_GDB 0x8000 /* use GDB remote debugger instead of DDB */ #define RB_MUTE 0x10000 /* Come up with the console muted */ #define RB_SELFTEST 0x20000 /* don't boot to normal operation, do selftest */ +#define RB_PAUSE 0x40000 /* pause after each output line during probe */ #define RB_MULTIPLE 0x20000000 /* Use multiple consoles */ #define RB_BOOTINFO 0x80000000 /* have `struct bootinfo *' arg */