diff options
author | flipk <flipk@cvs.openbsd.org> | 1997-09-20 22:40:45 +0000 |
---|---|---|
committer | flipk <flipk@cvs.openbsd.org> | 1997-09-20 22:40:45 +0000 |
commit | 1c5b365949990faa58927a05e6e7062fc8482f80 (patch) | |
tree | 53f82ac8604ed6178bfd4d513a9d0411a2b871fe /sys | |
parent | 2f49f029d12cd95e62b6d369737c83ab6662eb5c (diff) |
- add 'stty [baudrate]' command to /boot, for serial consoles
- switch baud rates using i/o instead of bios, since bios commands
have only a limited bitwidth for baudrate, and max out at 9600
- when switching console devices, print msg to both old device and new
- fix timeout bug in com_getc() (dev | 0x80 was reading gobbledygook)
- document 'stty' command in boot(8)
- wording and cleanup in man pages
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/stand/biosboot/biosboot.8 | 31 | ||||
-rw-r--r-- | sys/arch/i386/stand/boot/boot.8 | 96 | ||||
-rw-r--r-- | sys/arch/i386/stand/boot/cmd.c | 30 | ||||
-rw-r--r-- | sys/arch/i386/stand/installboot/installboot.8 | 15 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/bioscons.c | 91 | ||||
-rw-r--r-- | sys/arch/i386/stand/libsa/biosdev.h | 3 | ||||
-rw-r--r-- | sys/stand/boot/cmd.c | 30 |
7 files changed, 223 insertions, 73 deletions
diff --git a/sys/arch/i386/stand/biosboot/biosboot.8 b/sys/arch/i386/stand/biosboot/biosboot.8 index 6c841d96cbf..8b319f43acd 100644 --- a/sys/arch/i386/stand/biosboot/biosboot.8 +++ b/sys/arch/i386/stand/biosboot/biosboot.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: biosboot.8,v 1.4 1997/09/05 21:25:15 weingart Exp $ +.\" $OpenBSD: biosboot.8,v 1.5 1997/09/20 22:40:33 flipk Exp $ .\" .\" Copyright (c) 1997 Michael Shalayeff .\" All rights reserved. @@ -35,28 +35,28 @@ .Sh NAME .Nm biosboot .Nd -primary system bootstrap program +first-stage system bootstrap .Sh DESCRIPTION This small program (roughly 256 bytes of code) is responsible for loading the second stage .Xr boot 8 program, which in turn, will load the kernel. -It is a small piece of code that takes no input or options. +It takes no input or options directly. .Pp -The location of the -.Xr boot 8 -program that +In order for .Nm -loads, is stored in a block table inside the +to load the second-stage bootstrap, it has a table inside it which +describes +.Xr boot 8 's +location. .Nm -program. The +must be installed by, and have its block table filled in by, the .Xr installboot 8 -program is used to fill this table with the location of the -.Nm -program. This location is BIOS dependant, so you have to run the +program. As this data is BIOS dependant, you must re-run .Xr installboot 8 -program to update this table every time you move your disk between -machines and/or controllers. +each time you reinstall +.Xr boot 8 +or move your disk or software between machines and/or controllers. .Pp When .Nm @@ -76,11 +76,12 @@ any media error, including bad sectors (common on floppy disks), and invalid sectors (can occur with messed up geometry translations). .It Er Bad magic The just loaded /boot image contains a bad magic in it's header. This -might indicate some kind of hardware problem, or it may mean that the +might indicate some kind of hardware problem, the .Ar boot argument to the .Xr installboot 8 -command was not a valid /boot program. +command was not a valid /boot program, or /boot or has been moved or +changed. .El .Pp Other common reasons for these errors to appear is that a wrong BIOS geometry diff --git a/sys/arch/i386/stand/boot/boot.8 b/sys/arch/i386/stand/boot/boot.8 index 56d8fdc0f42..907a17d7072 100644 --- a/sys/arch/i386/stand/boot/boot.8 +++ b/sys/arch/i386/stand/boot/boot.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: boot.8,v 1.5 1997/09/07 03:12:37 mickey Exp $ +.\" $OpenBSD: boot.8,v 1.6 1997/09/20 22:40:35 flipk Exp $ .\" .\" Copyright (c) 1997 Michael Shalayeff .\" All rights reserved. @@ -35,75 +35,70 @@ .Sh NAME .Nm boot .Nd -secondary system bootstrap program +second-stage bootstrap .Sh DESCRIPTION The main purpose of this program is to load the system kernel, dealing with -all the bugs and bottlenecks of the PC BIOS ``architecture'' and philosophy. +the downfalls of the PC BIOS architecture. .Pp As described in .Xr boot_i386 8 this program is loaded by the .Xr biosboot 8 -primary bootstrap loader and will give you a convinient way to load the kernel. -This program acts as an enhanced boot monitor or ROM for PC systems, providing -a buffer or common interface for the kernel to start from. +primary bootstrap loader and provides a convenient way to load the kernel. +This program acts as an enhanced boot monitor for PC systems, providing +common interface for the kernel to start from. .Pp Basic operations include: .Bl -bullet -compact .It -Detecting and switching between multiple console types. +Detecting and switching between multiple consoles. .It Loading kernels from any device supported by your system BIOS. .It Loading kernels compressed by -.Xr gzip 1 -program or -.Xr zlib 3 -routines. +.Xr gzip 1 . .It Passing system parameters queried from the BIOS to the kernel. .It Providing an interactive command line. .El .Pp -The sequences of its operation consist of initialization -followed by an interactive command line. While at the command -line you have a timeout of 5 seconds (initially, then increasing -by one second on every subsequent kernel load failure) -to type any commands, if needed. Upon timeout expiration, the -kernel will be loaded according to the current variables -settings (See the +The sequence of its operation is as follows: initialization, +parsing the configuration file, then an interactive command line. +While at the command line you have 5 seconds to type any commands, +if needed. If time expires, the kernel will be loaded according to +the current variable settings (See the .Nm set -command for details). -The sequence of +command). Each time a kernel load fails, the timeout +is increased by one second. The sequence of .Nm operations is as follows: .Bl -enum .It -Setup protected mode involving IDT setup for processor exceptions to -be caught and reported, and setup a simple real-mode BIOS interface. +Set up a protected mode environment which catches and reports processor +exceptions, and provides a simple real-mode BIOS interface. .It -Probe for console devices, which includes the PC VGA+Keyboard console -and up to four serial consoles connected to the serial ports. -Corresponding messages report about the found devices to the default -console device, which is pc0, if present. +Probe for console devices, which includes the (default) PC VGA+Keyboard +console (pc0) and up to four serial consoles (com0 through com3) connected +to the serial ports. Display messages to the default console about the +devices found. .It -Probe for memory. Conventional memory is probed by quering the BIOS. -Extended memory is probed by running through the memory probing -for present pages, which eliminates the BIOS restriction of 64M of memory. +Detect memory. Conventional memory is detected by quering the BIOS. +Extended memory is detected by probing page-by-page through the address +space, rather than asking the BIOS; many BIOS cannot report larger than +64M of memory. All the memory found is reported to the default console device. .It Probe for APM support in the BIOS. Message printed if support is present. .It -Open, and if successfull process +If the file .Pa /etc/boot.conf -file on the same filesystem +exists on the filesystem .Nm -was loaded from. This file may contain any commands +was loaded from, open and parse it. This file may contain any commands .Nm accepts at the interactive prompt. -Usually they are commands that change boot parameters according to your -environment, although default values are usable in most cases. +Though default settings usually suffice, they can be changed here. .It The header line .Pp @@ -133,12 +128,14 @@ Boots kernel image specified by the .Ar image with options if any. Image specification consists of a pair .Nm device : Nm filename , -either of each maybe omitted (':' is not needed if both) +either of each maybe omitted (':' is not needed if both), in which case values from .Nm variables will be used. -.It echo -Prints it's arguments. +.It echo Op Ar args +Displays +.Ar args +on the console device. .It help Prints a list of available commands and machine dependant commands, if any. @@ -159,12 +156,15 @@ Prints contents of processor registers, if defind for this architecture. .It reboot Reboots machine by initiating a warm boot procedure. .It set Op varname Op value -If invoked without arguments will print a list of variables with values. +If invoked without arguments, prints a list of variables and their values. +If only +.Ar varname +is specified, displays contents of that variable. If .Ar varname and .Ar value -present will set variable with that name to the given value. +are both specified, sets that variable to the given value. Variables include: .Pp .Bl -tag -compact -width boothow @@ -183,25 +183,37 @@ Active console device name. .It image File name containing the kernel image. .El +.It stty Op Ar baudrate +Displays or sets the baudrate for serial console. If the currently +active console is a serial console, gives you five seconds of pause +before changing the baud rate to allow you to change your terminal's +speed to match. If the active console is +.Em not +a serial console, sets the baudrate value to be used the +.Em next +time you switch to a serial console. (The baudrate value is not used +for the pc0 console.) +.Pp +The default baudrate if not specifically +set is 9600 baud. .It time Displays system time and date. .El .Sh FILES .Bl -tag -width /usr/mdec/biosbootxx -compact .It Pa /usr/mdec/biosboot -primary bootstrap +first stage bootstrap .It Pa /boot system bootstrap .It Pa /etc/boot.conf system bootstrap's startup file .It Pa /bsd -system code +kernel image .El .Sh SEE ALSO .Xr boot_i386 8 , .Xr fdisk 8 , .Xr installboot 8 , -.Xr boot 8 , .Xr gzip 1 . .Pp RFC 1950 describes the zlib library interface. diff --git a/sys/arch/i386/stand/boot/cmd.c b/sys/arch/i386/stand/boot/cmd.c index 55d8751c246..114af576393 100644 --- a/sys/arch/i386/stand/boot/cmd.c +++ b/sys/arch/i386/stand/boot/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.32 1997/09/17 19:55:34 mickey Exp $ */ +/* $OpenBSD: cmd.c,v 1.33 1997/09/20 22:40:37 flipk Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -34,6 +34,7 @@ #include <sys/param.h> #include <libsa.h> +#include <biosdev.h> #include <sys/reboot.h> #include "cmd.h" @@ -52,6 +53,7 @@ static int Ximage __P((void)); static int Xls __P((void)); static int Xreboot __P((void)); static int Xset __P((void)); +static int Xstty __P((void)); static int Xhowto __P((void)); static int Xtty __P((void)); static int Xtime __P((void)); @@ -83,6 +85,7 @@ static const struct cmd_table cmd_table[] = { #endif {"reboot", CMDT_CMD, Xreboot}, {"set", CMDT_SET, Xset}, + {"stty", CMDT_CMD, Xstty}, {"time", CMDT_CMD, Xtime}, {NULL, 0}, }; @@ -367,6 +370,23 @@ Xset() } static int +Xstty() +{ + int sp; + char *cp; + if (cmd.argc == 1) + printf("com speed is %d\n", com_setsp(0)); + else { + sp = 0; + for (cp = cmd.argv[1]; *cp && isdigit(*cp); cp++) + sp = sp*10 + (*cp - '0'); + com_setsp(sp); + } + + return 0; +} + +static int Xdevice() { if (cmd.argc != 2) @@ -420,8 +440,12 @@ Xtty() dev = ttydev(cmd.argv[1]); if (dev == NODEV) printf("%s not a console device\n", cmd.argv[1]); - else if (cnset(dev)) - printf("%s console not present\n", cmd.argv[1]); + else { + printf("switching console to %s\n", cmd.argv[1]); + if (cnset(dev)) + printf("%s console not present\n", + cmd.argv[1]); + } } return 0; } diff --git a/sys/arch/i386/stand/installboot/installboot.8 b/sys/arch/i386/stand/installboot/installboot.8 index 9d24d6e691f..6e97d52573c 100644 --- a/sys/arch/i386/stand/installboot/installboot.8 +++ b/sys/arch/i386/stand/installboot/installboot.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: installboot.8,v 1.6 1997/09/04 23:20:51 deraadt Exp $ +.\" $OpenBSD: installboot.8,v 1.7 1997/09/20 22:40:40 flipk Exp $ .\" .\" .\" Copyright (c) 1997 Michael Shalayeff @@ -80,23 +80,28 @@ If not specified, this defaults to d_ntracks from the disklabel. The arguments are: .Bl -tag -width biosboot .It Ar boot -The name of the second-stage boot program in the file system +The name of the second-stage boot program in the mounted file system where the first-stage boot program is to be installed. .It Ar biosboot -The name of the prototype file for the first stage boot program. +The name of the prototype file for the first stage boot program, +usually /usr/mdec/biosboot. .It Ar rawdev The name of the raw device in which the first-stage boot program is to be installed. This should correspond to the raw partition of the block device on which the file system containing .Ar boot -is mounted. +is mounted. Note that you must be in single-user mode or have your +kernel in insecure mode (see +.Xr sysctl 8 's +kern.securelevel variable or /etc/rc.securelevel) to be able +to access the raw partition of a mounted disk. .El .Sh BUGS The disklabel d_type field must be set to a value other than "unknown". .Pp You cannot run .Nm installboot -for drives/partitions others then the one you have loaded /bsd from. +for drives/partitions others then the one you want /bsd loaded from. .Sh SEE ALSO .Xr disklabel 8 , .Xr init 8 , diff --git a/sys/arch/i386/stand/libsa/bioscons.c b/sys/arch/i386/stand/libsa/bioscons.c index a495898418a..44b61481d49 100644 --- a/sys/arch/i386/stand/libsa/bioscons.c +++ b/sys/arch/i386/stand/libsa/bioscons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bioscons.c,v 1.8 1997/09/02 20:36:57 mickey Exp $ */ +/* $OpenBSD: bioscons.c,v 1.9 1997/09/20 22:40:42 flipk Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -35,8 +35,11 @@ #include <sys/types.h> #include <machine/biosvar.h> #include <machine/pio.h> +#include <machine/bus.h> #include <dev/isa/isareg.h> #include <dev/ic/mc146818reg.h> +#include <dev/ic/comreg.h> +#include <dev/ic/ns16450reg.h> #include <i386/isa/nvram.h> #include <dev/cons.h> #include <lib/libsa/stand.h> @@ -48,6 +51,10 @@ #define PRESENT_MASK 0 #endif +int com_setsp __P((int)); +static int com_speed = 9600; /* default speed is 9600 baud */ +static const int comports[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; + void pc_probe(cn) struct consdev *cn; @@ -119,10 +126,11 @@ com_init(cn) { register int unit = minor(cn->cn_dev); - /* 9600-N-1 */ + /* let bios do necessary init first, 9600-N-1 */ __asm __volatile(DOINT(0x14) : : "a" (0xe3), "d" (unit) : "%ecx", "cc" ); - printf("using com%d console\n", unit); + /* now just set the speed */ + (void)com_setsp(com_speed); } int @@ -133,7 +141,7 @@ com_getc(dev) if (dev & 0x80) { __asm __volatile(DOINT(0x14) : "=a" (rv) : - "0" (0x300), "d" (minor(dev)) : "%ecx", "cc" ); + "0" (0x300), "d" (minor(dev&0x7f)) : "%ecx", "cc" ); return ((rv & 0x100) == 0x100); } @@ -145,6 +153,81 @@ com_getc(dev) return (rv & 0xff); } +/* ripped screaming from dev/ic/com.c */ +static int +comspeed(speed) + int speed; +{ +#define divrnd(n, q) (((n)*2/(q)+1)/2) /* divide and round off */ + int x, err; + + if (speed == 0) + return 0; + if (speed < 0) + return -1; + x = divrnd((COM_FREQ / 16), speed); + if (x <= 0) + return -1; + err = divrnd((COM_FREQ / 16) * 1000, speed * x) - 1000; + if (err < 0) + err = -err; + if (err > COM_TOLERANCE) + return -1; + return x; +#undef divrnd(n, q) +} + +/* call with sp == 0 to query the current speed */ +int +com_setsp(sp) + int sp; +{ + int unit, i, newsp = comspeed(sp); + + if (sp == 0) + return com_speed; + /* valid baud rate? */ + if (sp > 38400 || sp < 75) + { + badspeed: + printf("invalid terminal speed %d\n", sp); + return 0; + } + for (i=sp; i != 75; i >>= 1) + if (i & 1) + goto badspeed; + /* is current console a com device? */ + if (cn_tab && cn_tab->cn_getc == com_getc) + { + time_t tt; + unit = minor(cn_tab->cn_dev); + if (com_speed != sp) + { + printf("com%d: changing speed from %d to %d\n" + "com%d: change your terminal to match!\n" + "com%d: will change speed in 5 seconds....\n", + unit, com_speed, sp, + unit, unit); + /* let the \n get out and the + user change the terminal */ + for (tt = getsecs() + 5; getsecs() < tt;); + } + bus_space_write_1(I386_BUS_SPACE_IO, comports[unit], + com_cfcr, LCR_DLAB); + bus_space_write_1(I386_BUS_SPACE_IO, comports[unit], + com_dlbl, newsp); + bus_space_write_1(I386_BUS_SPACE_IO, comports[unit], + com_dlbh, newsp>>8); + bus_space_write_1(I386_BUS_SPACE_IO, comports[unit], + com_cfcr, LCR_8BITS); + printf("using com%d console at %d baud\n", unit, sp); + } else { + printf("speed on next com device will be %d\n" + "change your terminal to match!\n", sp); + } + return com_speed = sp; +} + void com_putc(dev, c) dev_t dev; diff --git a/sys/arch/i386/stand/libsa/biosdev.h b/sys/arch/i386/stand/libsa/biosdev.h index eca8f947751..e54a352ba41 100644 --- a/sys/arch/i386/stand/libsa/biosdev.h +++ b/sys/arch/i386/stand/libsa/biosdev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: biosdev.h,v 1.20 1997/09/03 04:32:43 weingart Exp $ */ +/* $OpenBSD: biosdev.h,v 1.21 1997/09/20 22:40:44 flipk Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -52,6 +52,7 @@ void pc_putc __P((dev_t, int)); void pc_pollc __P((dev_t, int)); void com_probe __P((struct consdev *)); void com_init __P((struct consdev *)); +int com_setsp __P((int)); int com_getc __P((dev_t)); void com_putc __P((dev_t, int)); void com_pollc __P((dev_t, int)); diff --git a/sys/stand/boot/cmd.c b/sys/stand/boot/cmd.c index 55d8751c246..114af576393 100644 --- a/sys/stand/boot/cmd.c +++ b/sys/stand/boot/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.32 1997/09/17 19:55:34 mickey Exp $ */ +/* $OpenBSD: cmd.c,v 1.33 1997/09/20 22:40:37 flipk Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -34,6 +34,7 @@ #include <sys/param.h> #include <libsa.h> +#include <biosdev.h> #include <sys/reboot.h> #include "cmd.h" @@ -52,6 +53,7 @@ static int Ximage __P((void)); static int Xls __P((void)); static int Xreboot __P((void)); static int Xset __P((void)); +static int Xstty __P((void)); static int Xhowto __P((void)); static int Xtty __P((void)); static int Xtime __P((void)); @@ -83,6 +85,7 @@ static const struct cmd_table cmd_table[] = { #endif {"reboot", CMDT_CMD, Xreboot}, {"set", CMDT_SET, Xset}, + {"stty", CMDT_CMD, Xstty}, {"time", CMDT_CMD, Xtime}, {NULL, 0}, }; @@ -367,6 +370,23 @@ Xset() } static int +Xstty() +{ + int sp; + char *cp; + if (cmd.argc == 1) + printf("com speed is %d\n", com_setsp(0)); + else { + sp = 0; + for (cp = cmd.argv[1]; *cp && isdigit(*cp); cp++) + sp = sp*10 + (*cp - '0'); + com_setsp(sp); + } + + return 0; +} + +static int Xdevice() { if (cmd.argc != 2) @@ -420,8 +440,12 @@ Xtty() dev = ttydev(cmd.argv[1]); if (dev == NODEV) printf("%s not a console device\n", cmd.argv[1]); - else if (cnset(dev)) - printf("%s console not present\n", cmd.argv[1]); + else { + printf("switching console to %s\n", cmd.argv[1]); + if (cnset(dev)) + printf("%s console not present\n", + cmd.argv[1]); + } } return 0; } |