Index: sbin/reboot/boot_i386.8 =================================================================== --- sbin/reboot/boot_i386.8 +++ sbin/reboot/boot_i386.8 @@ -105,7 +105,7 @@ .Ar bios_drive : interface ( unit , Oo Ar slice , Oc Ar part ) .Ar filename .Sm on -.Op Fl aCcDdghmnPprsv +.Op Fl aCcDdghmnPpRrsv .Op Fl S Ns Ar speed .Xc Specify boot file and flags. @@ -166,7 +166,7 @@ Defaults to .Pa /boot/kernel/kernel . Symbolic links are not supported (hard links are). -.It Xo Op Fl aCcDdghmnPpqrsv +.It Xo Op Fl aCcDdghmnPpqRrsv .Op Fl S Ns Ar speed .Xc Boot flags: @@ -230,6 +230,15 @@ combination with the .Fl m option. +.It Fl R +reset the serial terminal if serial console is enabled. This option could +help if previous boot stages (BIOS, for example) leave the serial terminal +in an unspecified or bogus state. The reset sequence is "\ec" by default +unless it has been overridden by setting +.Va BOOT_COMCONSOLE_RESET_TERM_CMD +in +.Xr make.conf 5 +and recompiling and reinstalling the boot blocks. .It Fl r use the statically configured default for the device containing the root file system Index: stand/common/rbx.h =================================================================== --- stand/common/rbx.h +++ stand/common/rbx.h @@ -43,6 +43,7 @@ #define RBX_NOINTR 0x1c /* -n */ /* 0x1d is reserved for log2(RB_MULTIPLE) and is just misnamed here. */ #define RBX_DUAL 0x1d /* -D */ +#define RBX_RTERM 0x1e /* -R */ /* 0x1f is reserved for log2(RB_BOOTINFO). */ /* pass: -a, -s, -r, -d, -c, -v, -h, -C, -g, -m, -p, -D */ Index: stand/defs.mk =================================================================== --- stand/defs.mk +++ stand/defs.mk @@ -190,6 +190,8 @@ # Make sure we use the machine link we're about to create CFLAGS+=-I. +BOOT_COMCONSOLE_RESET_TERM_CMD?= "\ec" + all: ${PROG} CLEANFILES+= teken_state.h Index: stand/i386/boot2/Makefile =================================================================== --- stand/i386/boot2/Makefile +++ stand/i386/boot2/Makefile @@ -28,6 +28,7 @@ -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ -DSIOFMT=${B2SIOFMT} \ -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ + -DSIORST=\"${BOOT_COMCONSOLE_RESET_TERM_CMD}\" \ -I${LDRSRC} \ -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \ -Wmissing-declarations -Wmissing-prototypes -Wnested-externs \ Index: stand/i386/boot2/boot2.c =================================================================== --- stand/i386/boot2/boot2.c +++ stand/i386/boot2/boot2.c @@ -55,7 +55,7 @@ #define SECOND 18 /* Circa that many ticks in a second. */ #define ARGS 0x900 -#define NOPT 14 +#define NOPT 15 #define NDEV 3 #define MEM_BASE 0x12 #define MEM_EXT 0x15 @@ -70,7 +70,7 @@ extern uint32_t _end; -static const char optstr[NOPT] = "DhaCcdgmnpqrsv"; /* Also 'P', 'S' */ +static const char optstr[NOPT] = "DhaCcdgmnpqRrsv"; /* Also 'P', 'S' */ static const unsigned char flags[NOPT] = { RBX_DUAL, RBX_SERIAL, @@ -83,6 +83,7 @@ RBX_NOINTR, RBX_PAUSE, RBX_QUIET, + RBX_RTERM, RBX_DFLTROOT, RBX_SINGLE, RBX_VERBOSE @@ -107,6 +108,7 @@ #if SERIAL static int comspeed = SIOSPD; static uint8_t ioctrl = IO_KEYBOARD; +static const char resettermcmd[] = SIORST; #endif int main(void); @@ -408,8 +410,13 @@ ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) : OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD; if (DO_SIO) { - if (sio_init(115200 / comspeed) != 0) + if (sio_init(115200 / comspeed) != 0) { ioctrl &= ~IO_SERIAL; + } else if (OPT_CHECK(RBX_RTERM)) { + for (i = 0; resettermcmd[i]; i++) + sio_putc(resettermcmd[i]); + sio_flush(); + } } #endif } else { Index: stand/i386/gptboot/Makefile =================================================================== --- stand/i386/gptboot/Makefile +++ stand/i386/gptboot/Makefile @@ -27,6 +27,7 @@ -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ -DSIOFMT=${B2SIOFMT} \ -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ + -DSIORST=\"${BOOT_COMCONSOLE_RESET_TERM_CMD}\" \ -I${LDRSRC} \ -I${BOOTSRC}/i386/common \ -I${BOOTSRC}/i386/boot2 \ Index: stand/i386/gptboot/gptboot.c =================================================================== --- stand/i386/gptboot/gptboot.c +++ stand/i386/gptboot/gptboot.c @@ -43,7 +43,7 @@ #include "paths.h" #define ARGS 0x900 -#define NOPT 14 +#define NOPT 15 #define NDEV 3 #define MEM_BASE 0x12 #define MEM_EXT 0x15 @@ -59,7 +59,7 @@ extern uint32_t _end; static const uuid_t freebsd_ufs_uuid = GPT_ENT_TYPE_FREEBSD_UFS; -static const char optstr[NOPT] = "DhaCcdgmnpqrsv"; /* Also 'P', 'S' */ +static const char optstr[NOPT] = "DhaCcdgmnpqRrsv"; /* Also 'P', 'S' */ static const unsigned char flags[NOPT] = { RBX_DUAL, RBX_SERIAL, @@ -72,6 +72,7 @@ RBX_NOINTR, RBX_PAUSE, RBX_QUIET, + RBX_RTERM, RBX_DFLTROOT, RBX_SINGLE, RBX_VERBOSE @@ -83,6 +84,7 @@ static char kname[1024]; static int comspeed = SIOSPD; +static const char resettermcmd[] = SIORST; static struct bootinfo bootinfo; #ifdef LOADER_GELI_SUPPORT static struct geli_boot_args geliargs; @@ -549,8 +551,13 @@ ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) : OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD; if (ioctrl & IO_SERIAL) { - if (sio_init(115200 / comspeed) != 0) + if (sio_init(115200 / comspeed) != 0) { ioctrl &= ~IO_SERIAL; + } else if (OPT_CHECK(RBX_RTERM)) { + for (i = 0; resettermcmd[i]; i++) + sio_putc(resettermcmd[i]); + sio_flush(); + } } } else { for (q = arg--; *q && *q != '('; q++); Index: stand/i386/gptzfsboot/Makefile =================================================================== --- stand/i386/gptzfsboot/Makefile +++ stand/i386/gptzfsboot/Makefile @@ -26,6 +26,7 @@ -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ -DSIOFMT=${B2SIOFMT} \ -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ + -DSIORST=\"${BOOT_COMCONSOLE_RESET_TERM_CMD}\" \ -I${LDRSRC} \ -I${BOOTSRC}/i386/common \ -I${BOOTSRC}/i386/libi386 \ Index: stand/i386/isoboot/Makefile =================================================================== --- stand/i386/isoboot/Makefile +++ stand/i386/isoboot/Makefile @@ -23,6 +23,7 @@ -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ -DSIOFMT=${B2SIOFMT} \ -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ + -DSIORST=\"${BOOT_COMCONSOLE_RESET_TERM_CMD}\" \ -I${LDRSRC} \ -I${BOOTSRC}/i386/common \ -I${BOOTSRC}/i386/boot2 \ Index: stand/i386/isoboot/isoboot.c =================================================================== --- stand/i386/isoboot/isoboot.c +++ stand/i386/isoboot/isoboot.c @@ -43,7 +43,7 @@ #include "paths.h" #define ARGS 0x900 -#define NOPT 14 +#define NOPT 15 #define NDEV 3 #define MEM_BASE 0x12 #define MEM_EXT 0x15 @@ -58,7 +58,7 @@ extern uint32_t _end; -static const char optstr[NOPT] = "DhaCcdgmnpqrsv"; /* Also 'P', 'S' */ +static const char optstr[NOPT] = "DhaCcdgmnpqRrsv"; /* Also 'P', 'S' */ static const unsigned char flags[NOPT] = { RBX_DUAL, RBX_SERIAL, @@ -71,6 +71,7 @@ RBX_NOINTR, RBX_PAUSE, RBX_QUIET, + RBX_RTERM, RBX_DFLTROOT, RBX_SINGLE, RBX_VERBOSE @@ -83,6 +84,7 @@ static struct dsk dsk; static char kname[1024]; static int comspeed = SIOSPD; +static const char resettermcmd[] = SIORST; static struct bootinfo bootinfo; static vm_offset_t high_heap_base; @@ -472,8 +474,13 @@ ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) : OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD; if (ioctrl & IO_SERIAL) { - if (sio_init(115200 / comspeed) != 0) + if (sio_init(115200 / comspeed) != 0) { ioctrl &= ~IO_SERIAL; + } else if (OPT_CHECK(RBX_RTERM)) { + for (i = 0; resettermcmd[i]; i++) + sio_putc(resettermcmd[i]); + sio_flush(); + } } } else { for (q = arg--; *q && *q != '('; q++); Index: stand/i386/zfsboot/Makefile =================================================================== --- stand/i386/zfsboot/Makefile +++ stand/i386/zfsboot/Makefile @@ -25,6 +25,7 @@ -DSIOPRT=${BOOT_COMCONSOLE_PORT} \ -DSIOFMT=${B2SIOFMT} \ -DSIOSPD=${BOOT_COMCONSOLE_SPEED} \ + -DSIORST=\"${BOOT_COMCONSOLE_RESET_TERM_CMD}\" \ -I${LDRSRC} \ -I${BOOTSRC}/i386/common \ -I${BOOTSRC}/i386/libi386 \ Index: stand/i386/zfsboot/zfsboot.c =================================================================== --- stand/i386/zfsboot/zfsboot.c +++ stand/i386/zfsboot/zfsboot.c @@ -53,7 +53,7 @@ #include "libzfs.h" #define ARGS 0x900 -#define NOPT 14 +#define NOPT 15 #define NDEV 3 #define BIOS_NUMDRIVES 0x475 @@ -67,7 +67,7 @@ extern uint32_t _end; -static const char optstr[NOPT] = "DhaCcdgmnpqrsv"; /* Also 'P', 'S' */ +static const char optstr[NOPT] = "DhaCcdgmnpqRrsv"; /* Also 'P', 'S' */ static const unsigned char flags[NOPT] = { RBX_DUAL, RBX_SERIAL, @@ -80,6 +80,7 @@ RBX_NOINTR, RBX_PAUSE, RBX_QUIET, + RBX_RTERM, RBX_DFLTROOT, RBX_SINGLE, RBX_VERBOSE @@ -111,6 +112,7 @@ static char cmddup[512]; static char kname[1024]; static int comspeed = SIOSPD; +static const char resettermcmd[] = SIORST; static struct bootinfo bootinfo; static uint32_t bootdev; static struct zfs_boot_args zfsargs; @@ -610,8 +612,13 @@ ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) : OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD; if (ioctrl & IO_SERIAL) { - if (sio_init(115200 / comspeed) != 0) + if (sio_init(115200 / comspeed) != 0) { ioctrl &= ~IO_SERIAL; + } else if (OPT_CHECK(RBX_RTERM)) { + for (i = 0; resettermcmd[i]; i++) + sio_putc(resettermcmd[i]); + sio_flush(); + } } } if (c == '?') { printf("\n");