- Add a new command 'lsdev' to list devices which might be likely to host

filesystems.
 - New 'help' command and data in the help.* files (not yet installed),
   provides topic and subtopic help, indexes, etc.
 - Don't crash if the user tries to set an invalid console.  Be helpful
   instead.
 - Expand tabs (badly) on the i386 video console.
 - Some minor cosmetic changes.
This commit is contained in:
Mike Smith 1998-10-31 02:53:12 +00:00
parent 2baf3bb5a0
commit dc8be6a8f5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=40775
8 changed files with 657 additions and 22 deletions

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: boot.c,v 1.6 1998/10/11 10:10:41 peter Exp $
* $Id: boot.c,v 1.7 1998/10/14 00:41:17 peter Exp $
*/
/*
@ -203,11 +203,13 @@ autoboot(int delay, char *prompt)
break;
}
if (ntime != otime) {
printf("\rBooting [%s] in %d seconds...", getbootfile(0), (int)(when - ntime));
printf("\rBooting [%s] in %d seconds... ", getbootfile(0), (int)(when - ntime));
otime = ntime;
cr = 1;
}
}
if (yes)
printf("\rBooting [%s]... ", getbootfile(0));
if (cr)
putchar('\n');
if (yes) {
@ -245,7 +247,7 @@ getbootfile(int try)
try--;
}
if (spec != NULL) {
if ((ep = strchr(spec, ',')) != NULL) {
if ((ep = strchr(spec, ';')) != NULL) {
len = ep - spec;
} else {
len = strlen(spec);

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: commands.c,v 1.5 1998/10/09 07:09:22 msmith Exp $
* $Id: commands.c,v 1.6 1998/10/21 20:07:04 msmith Exp $
*/
#include <stand.h>
@ -34,29 +34,175 @@
char *command_errmsg;
char command_errbuf[256]; /* XXX should have procedural interface for setting, size limit? */
/*
* Help is read from a formatted text file.
*
* Entries in the file are formatted as
# Ttopic [Ssubtopic] Ddescription
help
text
here
#
*
* Note that for code simplicity's sake, the above format must be followed
* exactly.
*
* Subtopic entries must immediately follow the topic (this is used to
* produce the listing of subtopics).
*
* If no argument(s) are supplied by the user, the help for 'help' is displayed.
*/
COMMAND_SET(help, "help", "detailed help", command_help);
static int
command_help(int argc, char *argv[])
help_getnext(int fd, char **topic, char **subtopic, char **desc)
{
char helppath[80]; /* XXX buffer size? */
char line[81], *cp, *ep;
for (;;) {
if (fgetstr(line, 80, fd) < 0)
return(0);
if ((strlen(line) < 3) || (line[0] != '#') || (line[1] != ' '))
continue;
*topic = *subtopic = *desc = NULL;
cp = line + 2;
while((cp != NULL) && (*cp != 0)) {
ep = strchr(cp, ' ');
if ((*cp == 'T') && (*topic == NULL)) {
if (ep != NULL)
*ep++ = 0;
*topic = strdup(cp + 1);
} else if ((*cp == 'S') && (*subtopic == NULL)) {
if (ep != NULL)
*ep++ = 0;
*subtopic = strdup(cp + 1);
} else if (*cp == 'D') {
*desc = strdup(cp + 1);
ep = NULL;
}
cp = ep;
}
if (*topic == NULL) {
if (*subtopic != NULL)
free(*subtopic);
if (*desc != NULL)
free(*desc);
continue;
}
return(1);
}
}
static void
help_emitsummary(char *topic, char *subtopic, char *desc)
{
int i;
pager_output(" ");
pager_output(topic);
i = strlen(topic);
if (subtopic != NULL) {
pager_output(" ");
pager_output(subtopic);
i += strlen(subtopic) + 1;
}
if (desc != NULL) {
do {
pager_output(" ");
} while (i++ < 30);
pager_output(desc);
}
pager_output("\n");
}
static int
command_help(int argc, char *argv[])
{
char buf[81]; /* XXX buffer size? */
int hfd, matched, doindex;
char *topic, *subtopic, *t, *s, *d;
/* page the help text from our load path */
sprintf(helppath, "%s/boot/boot.help", getenv("loaddev"));
printf("%s\n", helppath);
if (pager_file(helppath) == -1)
sprintf(buf, "%s/boot/loader.help", getenv("loaddev"));
if ((hfd = open(buf, O_RDONLY)) < 0) {
printf("Verbose help not available, use '?' to list commands\n");
return(CMD_OK);
}
/* pick up request from arguments */
topic = subtopic = NULL;
switch(argc) {
case 3:
subtopic = strdup(argv[2]);
case 2:
topic = strdup(argv[1]);
break;
case 1:
topic = strdup("help");
break;
default:
command_errmsg = "usage is 'help <topic> [<subtopic>]";
return(CMD_ERROR);
}
/* magic "index" keyword */
doindex = !strcmp(topic, "index");
matched = doindex;
/* Scan the helpfile looking for help matching the request */
pager_open();
while(help_getnext(hfd, &t, &s, &d)) {
if (doindex) { /* dink around formatting */
help_emitsummary(t, s, d);
} else if (strcmp(topic, t)) {
/* topic mismatch */
if(matched) /* nothing more on this topic, stop scanning */
break;
} else {
/* topic matched */
matched = 1;
if (((subtopic == NULL) && (s == NULL)) ||
((subtopic != NULL) && (s != NULL) && !strcmp(subtopic, s))) {
/* exact match, print text */
while((fgetstr(buf, 80, hfd) >= 0) && (buf[0] != '#')) {
pager_output(buf);
pager_output("\n");
}
} else if ((subtopic == NULL) && (s != NULL)) {
/* topic match, list subtopics */
help_emitsummary(t, s, d);
}
}
free(t);
free(s);
free(d);
}
pager_close();
close(hfd);
if (!matched) {
sprintf(command_errbuf, "no help available for '%s'", topic);
return(CMD_ERROR);
}
return(CMD_OK);
}
COMMAND_SET(commandlist, "?", "list commands", command_commandlist);
static int
command_commandlist(int argc, char *argv[])
{
struct bootblk_command **cmdp;
int i;
printf("Available commands:\n");
SET_FOREACH(cmdp, Xcommand_set) {
@ -234,3 +380,45 @@ command_read(int argc, char *argv[])
setenv(name, buf, 1);
return(CMD_OK);
}
/*
* List all disk-like devices
*/
COMMAND_SET(lsdev, "lsdev", NULL, command_lsdev);
static int
command_lsdev(int argc, char *argv[])
{
int verbose, ch, i;
char line[80];
verbose = 0;
optind = 1;
while ((ch = getopt(argc, argv, "v")) != -1) {
switch(ch) {
case 'v':
verbose = 1;
break;
case '?':
default:
/* getopt has already reported an error */
return(CMD_OK);
}
}
argv += (optind);
argc -= (optind);
pager_open();
for (i = 0; devsw[i] != NULL; i++) {
if (devsw[i]->dv_print != NULL){
sprintf(line, "%s @ %p\n", devsw[i]->dv_name, devsw[i]->dv_print);
pager_output(line);
devsw[i]->dv_print(verbose);
} else {
sprintf(line, "%s: (unknown)\n", devsw[i]->dv_name);
pager_output(line);
}
}
pager_close();
return(CMD_OK);
}

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: console.c,v 1.2 1998/09/26 01:29:13 msmith Exp $
* $Id: console.c,v 1.3 1998/10/11 10:19:11 peter Exp $
*/
#include <stand.h>
@ -150,8 +150,12 @@ cons_set(struct env_var *ev, int flags, void *value)
{
int cons, active;
if ((active = cons_find(value)) == -1) {
printf("no such console '%s'\n", (char *)value);
if ((value == NULL) || ((active = cons_find(value)) == -1)) {
if (value != NULL)
printf("no such console '%s'\n", (char *)value);
printf("Available consoles:\n");
for (cons = 0; consoles[cons] != NULL; cons++)
printf(" %s\n", consoles[cons]->c_name);
return(CMD_ERROR);
}

214
sys/boot/common/help.common Normal file
View File

@ -0,0 +1,214 @@
################################################################################
# Thelp DDisplay command help
help [topic [subtopic]]
?
The help command displays help on commands and their usage.
In command help, a term enclosed with <...> indicates a value as
described by the term. A term enclosed with [...] is optional,
and may not be required by all forms of the command.
Some commands may not be availalble. Use the '?' command to list
most available commands.
################################################################################
# Tautoboot DBoot after a delay
autoboot [<delay> [<prompt>]]
Displays <prompt> or a default prompt, and counts down <delay> seconds
before attempting to boot. If <delay> is not specified, the default
value is 10.
################################################################################
# Tboot DBoot immediately
boot [-<arg> ...] [<kernelname>]
Boot the system. If arguments are specified, they are added to the
arguments for the kernel. If <kernelname> is specified, and a kernel
has not already been loaded, it will be booted instead of the default
kernel.
################################################################################
# Techo DEcho arguments
echo [-n] [<message>]
Emits <message>, with no trailing newline if -n is specified. This is
most useful in conjunction with scripts and the '@' line prefix.
Variables are substituted by prefixing them with $, eg.
echo Current device is $currdev
will print the current device.
################################################################################
# Tload DLoad a kernel or module
load [-t <type>] <filename>
Loads the module contained in <filename> into memory. If no other
modules are loaded, <filename> must be a kernel or the command will
fail.
If -t is specified, the module is loaded as raw data of <type>, for
later use by the kernel or other modules. <type> may be any string.
################################################################################
# Tls DList files
ls [-l] [<path>]
Displays a listing of files in the directory <path>, or the root
directory of the current device if <path> is not specified.
The -l argument displays file sizes as well; the process of obtaining
file sizes on some media may be very slow.
################################################################################
# Tlsdev DList devices
lsdev [-v]
List all of the devices from which it may be possible to load modules.
If -v is specified, print more details.
################################################################################
# Tlsmod DList modules
lsmod [-v]
List loaded modules. If [-v] is specified, print more details.
################################################################################
# Tpnpscan DScan for PnP devices
pnpscan [-v]
Scan for Plug-and-Play devices. This command is normally automatically
run as part of the boot process, in order to dynamically load modules
required for system operation.
If the -v argument is specified, details on the devices found will
be printed.
################################################################################
# Tset DSet a variable
set <variable name>
set <variable name>=<value>
The set command is used to set variables.
################################################################################
# Tset Sautboot_delay DSet the default autoboot delay
set autoboot_delay=<value>
Sets the default delay for the autoboot command to <value> seconds.
################################################################################
# Tset Sbootfile DSet the default boot file set
set bootfile=<filename>[,<filename>...]
The default search path for bootable kernels is /kernel,/kernel.old.
It may be overridden by setting the bootfile variable to a
semicolon-separated list of paths, which will be searched for in turn.
################################################################################
# Tset Sconsole DSet the current console
set console[=<value>]
Sets the current console. If <value> is omitted, a list of valid
consoles will be displayed.
################################################################################
# Tset Scurrdev DSet the current device
set currdev=<device>
Selects the default device. Syntax for devices is odd.
################################################################################
# Tset Smodule_path DSet the module search path
set module_path=<path>[,<path>...]
Sets the list of directories which will be searched in for modules
named in a load command or implicitly required by a dependancy.
################################################################################
# Tset Sprompt DSet the command prompt
set prompt=<value>
The command prompt is displayed when the loader is waiting for input.
Variable substitution is performed on the prompt. The default
prompt can be set with:
set prompt=\$currdev>
################################################################################
# Tshow DShow the values of variables
show [<variable>]
Displays the value of <variable>, or all variables if not specified.
Multiple paths can be separated with a semicolon.
See the set command for a list of some variables.
################################################################################
# Tsource DRead commands from a script file
source <filename>
The entire contents of <filename> are read into memory before executing
commands, so it is safe to source a file from removable media.
A number of modifiers may be prefixed to commands within a script file
to alter their behaviour:
@ Suppresses the printing of the command when executed.
- Prevents the script from terminating if the command returns
an error.
################################################################################
# Tread DRead input from the terminal
read [-t <value>] [-p <prompt>] [<variable name>]
The read command reads a line of input from the terminal. If the
-t argument is specified, it will return nothing if no input has been
received after <value> seconds. (Any keypress will cancel the
timeout).
If -p is specified, <prompt> is printed before reading input. No
newline is emitted after the prompt.
If a variable name is supplied, the variable is set to the value read,
less any terminating newline.
################################################################################
# Tunload DRemove all modules from memory
unload
This command removes any kernel and all loaded modules from memory.
################################################################################
# Tunset DUnset a variable
unset <variable name>
If allowed, the named variable's value is discarded and the variable
is removed.
################################################################################

183
sys/boot/common/pnpdata Normal file
View File

@ -0,0 +1,183 @@
#
# $Id$
#
# This file contains the system default Plug-and-Play data. It is
# derived from a number of sources, including:
#
# - The Microsoft "Windows Generic Device IDs" document
#
[pci]
######################################################################
# PCI devices.
#
# Required attributes:
#
# ident= PCI identifier in the form 0xDDDDVVVV where
# 'VVVV' is the 4-digit hex form of the vendor ID and
# 'DDDD' is the 4-digit hex form of the device ID.
# or
#
# vendor= 0xVVVV where 'VVVV' is above
# name= Vendor name
vendor=0x8086 name=Intel
[isa]
######################################################################
# ISA PnP devices
#
# Required attributes:
#
# ident= ISA PnP identifier in the form AAAIIRR where
# 'AAA' is the EISA vendor ID, 'II' is the device ID
# and 'RR' is the revision ID.
# or
#
# vendor= AAA to register just a vendor name.
# name= Vendor name
#
# Optional attributes:
#
# module= Support module identifier.
#
# args= Arguments to pass to the support module.
#
vendor=CSC name=Crystal Semiconductor
vendor=CTL name=Creative Labs
vendor=PNP name=Generic
# From "Windows Generic Device IDs"
#
# --Parallel Devices--
ident=PNP0400 module=lpt # Standard LPT printer port
ident=PNP0401 module=lpt # ECP printer port
# --Serial Devices--
ident=PNP0500 module=sio # Standard PC COM port
ident=PNP0501 module=sio # 16550A-compatible COM port
ident=PNP0502 module=sio # Multiport serial device (non-intelligent 16550)
# --Disk Controllers--
ident=PNP0600 module=wd # Generic ESDI/IDE/ATA compatible hard disk controller
ident=PNP0603 module=wd # Generic IDE supporting Microsoft Device Bay Specification
ident=PNP0700 module=fd # PC standard floppy disk controller
ident=PNP0701 module=fd # Standard floppy controller supporting MS Device Bay Spec
# --Peripheral Buses--
ident=PNP0A00 module=isa # ISA Bus
ident=PNP0A01 module=eisa # EISA Bus
ident=PNP0A03 module=pci # PCI Bus
ident=PNP0A04 module=isa # VESA/VL Bus
# -- Real Time Clock, BIOS, System board devices--
ident=PNP0C04 module=npx # Math Coprocessor
ident=PNP0C05 module=apm # APM BIOS (Version independent)
# --PCMCIA Controller Chipsets--
ident=PNP0E00 module=pcic # Intel 82365-Compatible PCMCIA Controller
ident=PNP0E01 module=pcic # Cirrus Logic CL-PD6720 PCMCIA Controller
ident=PNP0E02 module=pcic # VLSI VL82C146 PCMCIA Controller
ident=PNP0E03 module=pcic # Intel 82365-compatible CardBus controller
# --Network Adapters--
ident=PNP8001 module=ed # Novell/Anthem NE3200
ident=PNP8004 # Compaq NE3200
ident=PNP80d3 module=ed # Novell/Anthem NE1000
ident=PNP80d4 module=ed # Novell/Anthem NE2000
ident=PNP80d5 module=ed # NE1000 Compatible
ident=PNP80d6 module=ed # NE2000 Compatible
ident=PNP80d8 module=lnc # Novell/Anthem NE2100
ident=PNP80e9 module=le # DEC (DE200) EtherWorks Turbo
ident=PNP80eb module=le # DEC (DE201) EtherWorks Turbo/TP
ident=PNP80ec module=le # DEC (DE202) EtherWorks Turbo/TP_BNC
ident=PNP80f1 module=eg # 3Com EtherLink Plus
ident=PNP80f3 module=ed # 3Com EtherLink II or IITP (8 or 16-bit)
ident=PNP80f6 module=ed # 3Com EtherLink 16
ident=PNP80f7 module=ep # 3Com EtherLink III
ident=PNP80f8 module=ep # 3Com Generic Etherlink Plug and Play Device
ident=PNP8123 module=ed # SMC StarCard PLUS (WD/8003S)
ident=PNP8124 module=ed # SMC StarCard PLUS With On Board Hub (WD/8003SH)
ident=PNP8125 module=ed # SMC EtherCard PLUS (WD/8003E)
ident=PNP8126 module=ed # SMC EtherCard PLUS With Boot ROM Socket (WD/8003EBT)
ident=PNP8127 module=ed # SMC EtherCard PLUS With Boot ROM Socket (WD/8003EB)
ident=PNP8128 module=ed # SMC EtherCard PLUS TP (WD/8003WT)
ident=PNP812a module=ed # SMC EtherCard PLUS 16 With Boot ROM Socket (WD/8013EBT)
ident=PNP812d module=ie # Intel EtherExpress 16 or 16TP
ident=PNP8137 module=ed # Artisoft AE-1
ident=PNP8138 module=ed # Artisoft AE-2 or AE-3
ident=PNP8158 module=ed # HP PC LAN Adapter/16 TP Plus (HP27247B)
ident=PNP8159 module=ed # HP PC LAN Adapter/16 TL Plus (HP27252)
ident=PNP81c3 module=ed # SMC EtherCard PLUS Elite (WD/8003EP)
ident=PNP81c4 module=ed # SMC EtherCard PLUS 10T (WD/8003W)
ident=PNP81c5 module=ed # SMC EtherCard PLUS Elite 16 (WD/8013EP)
ident=PNP81c6 module=ed # SMC EtherCard PLUS Elite 16T (WD/8013W)
ident=PNP81c7 module=ed # SMC EtherCard PLUS Elite 16 Combo (WD/8013EW or 8013EWC)
ident=PNP81c8 module=ed # SMC EtherElite Ultra 16
ident=PNP820a module=ed # Zenith Data Systems NE2000-Compatible
ident=PNP8231 module=lnc # Advanced Micro Devices AM2100/AM1500T
ident=PNP828C module=lnc # AMD PCNet Family cards
ident=PNP828D module=lnc # AMD PCNet32 (VL version)
ident=PNP8323 module=ed # SMC EtherCard (All Types except 8013/A)
ident=PNP8390 module=ed # Generic network adapter
# --SCSI, Proprietary CD Adapters--
ident=PNPA003 module=matcd # Panasonic proprietary CD-ROM adapter (SBPro/SB16)
ident=PNPA02B module=scd # Sony proprietary CD-ROM controller
ident=PNPA030 module=mcd # Mitsumi LU-005 Single Speed CD-ROM controller + drive
ident=PNPA031 module=mcd # Mitsumi FX-001 Single Speed CD-ROM controller + drive
ident=PNPA032 module=mcd # Mitsumi FX-001 Double Speed CD-ROM controller + drive
# --Sound/Video-capture, multimedia--
ident=PNPB000 module=pcm # Sound Blaster 1.5 sound device
ident=PNPB001 module=pcm # Sound Blaster 2.0 sound device
ident=PNPB002 module=pcm # Sound Blaster Pro sound device
ident=PNPB003 module=pcm # Sound Blaster 16 sound device
ident=PNPB007 module=pcm # Microsoft Windows Sound System-compatible sound device
ident=PNPB009 module=pcm # Plug and Play Microsoft Windows Sound System Device
ident=PNPB020 module=pcm # Yamaha OPL3-compatible FM synthesizer device
ident=PNPB02F module=joy # Joystick/Game port
# --Compatibility with early device ID list--
ident=PNP0802 module=pcm # Microsoft Sound System compatible device (obsolete, use PNPB0xx instead)
# --Modems--
ident=PNPC000 module=sio # Compaq 14400 Modem (TBD)
ident=PNPC001 module=sio # Compaq 2400/9600 Modem (TBD)
# Vendor supplied IDs.
# --Parallel Devices--
# --Serial Devices--
# --Disk Controllers--
# --Peripheral Buses--
# --Real Time Clock, BIOS, System board devices--
# --PCMCIA Controller Chipsets--
# --Network Adapters--
ident=CSC6040 module=cs # Crystal Semiconductor CS8920
# --SCSI, Proprietary CD Adapters--
# --Sound/Video-capture, multimedia--
# --Modems--
[com]
######################################################################
# COM PnP devices
#
[lpt]
######################################################################
# LPT PnP devices
#

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: biosdisk.c,v 1.14 1998/10/11 10:29:49 peter Exp $
* $Id: biosdisk.c,v 1.15 1998/10/30 07:15:52 luoqi Exp $
*/
/*
@ -105,6 +105,7 @@ static int bd_init(void);
static int bd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize);
static int bd_open(struct open_file *f, ...);
static int bd_close(struct open_file *f);
static void bd_print(int verbose);
struct devsw biosdisk = {
"disk",
@ -113,7 +114,8 @@ struct devsw biosdisk = {
bd_strategy,
bd_open,
bd_close,
noioctl
noioctl,
bd_print
};
static int bd_opendisk(struct open_disk **odp, struct i386_devdesc *dev);
@ -199,6 +201,24 @@ bd_int13probe(struct bdinfo *bd)
return(0);
}
/*
* Print information about disks
*/
static void
bd_print(int verbose)
{
int i;
char line[80];
for (i = 0; i < nbdinfo; i++) {
sprintf(line, " disk%d: BIOS drive %c:", i,
(bdinfo[i].bd_unit < 0x80) ? ('A' + bdinfo[i].bd_unit) : ('C' + bdinfo[i].bd_unit - 0x80));
pager_output(line);
/* XXX more detail? */
pager_output("\n");
}
}
/*
* Attempt to open the disk described by (dev) for use by (f).
*

View File

@ -26,7 +26,7 @@
*
* From Id: probe_keyboard.c,v 1.13 1997/06/09 05:10:55 bde Exp
*
* $Id: vidconsole.c,v 1.6 1998/10/11 10:07:52 peter Exp $
* $Id: vidconsole.c,v 1.7 1998/10/28 19:24:15 msmith Exp $
*/
#include <stand.h>
@ -92,11 +92,19 @@ vidc_init(int arg)
static void
vidc_putchar(int c)
{
v86.ctl = 0;
v86.addr = 0x10;
v86.eax = 0xe00 | c;
v86.ebx = 0x7;
v86int();
int i;
if (c == '\t') {
/* lame tab expansion */
for (i = 0; i < 8; i++)
vidc_putchar(' ');
} else {
v86.ctl = 0;
v86.addr = 0x10;
v86.eax = 0xe00 | c;
v86.ebx = 0x7;
v86int();
}
}
static int

View File

@ -0,0 +1,16 @@
################################################################################
# Treboot DReboot the system
reboot
Causes the system to immediately reboot.
################################################################################
# Theap DDisplay memory management statistics
heap
Requests debugging output from the heap manager. For debugging use
only.
################################################################################