From 4b1ec863484fde949c353281bb3c489b2506ffc1 Mon Sep 17 00:00:00 2001 From: okuji Date: Sat, 23 Oct 1999 19:38:45 +0000 Subject: [PATCH] some bugfixes and documentation updates. --- ChangeLog | 11 ++++ NEWS | 2 +- TODO | 6 ++- docs/new-grub.texi | 1 - docs/prog-ref.texi | 25 ++++----- docs/user-ref.texi | 130 ++++++++++++++++++++++++++++----------------- stage2/builtins.c | 46 +++++++++------- 7 files changed, 134 insertions(+), 87 deletions(-) diff --git a/ChangeLog b/ChangeLog index 967602147..ace0bae6e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +1999-10-23 OKUJI Yoshinori + + * stage2/builtins.c (map_func): If BIOS_DRIVE_MAP already + contains FROM, override the existsing entry. + If TO is equal to FROM, delete the existing entry if any. + (keycode_func): Likewise. + * docs/user-ref.texi (Command): Use the list of `@deffn's + instead of @table. + (Basic usage): Use @option instead of @code. + (Invoking mbchk): Likewise. + 1999-10-23 OKUJI Yoshinori * stage2/asm.S [!STAGE1_5] (set_int15_handler): New function. diff --git a/NEWS b/NEWS index 8b296262a..f7648704e 100644 --- a/NEWS +++ b/NEWS @@ -14,7 +14,7 @@ New in 0.5.94: * A simple checker for the format of a Multiboot kernel, ``mbchk'', is added. * The command "find" searches for a filename in all devices and print - the list of the device which contain the file. + the list of the devices which contain the file. * The command "map" maps a drive to another drive so that we can chain-load some foolish operating systems (such as DOS) even if such an operating system resides at a non-first drive. diff --git a/TODO b/TODO index 780623c95..1b4531dab 100644 --- a/TODO +++ b/TODO @@ -30,10 +30,12 @@ Priorities: parameters. !! * Support embedding a Stage 1.5 in the "bootloader" area of a FFS partition. !!! -* Add keyboard layout configuration support. ! -* Clean up and enhance the manuals, especially concept indexes. !!! +* Clean up and enhance the manuals, especially indices. !!! * Add more filesystems support (XFS, NTFS, etc.) * Add remote console support (serial, parallel and net). * Add RAID support. * Complete the netboot support. ! * Add automatic configuration support. +* Add bunzip2 support. +* Define the module system. ! +* Add ISA PnP support. diff --git a/docs/new-grub.texi b/docs/new-grub.texi index 89956eb7c..909364f42 100644 --- a/docs/new-grub.texi +++ b/docs/new-grub.texi @@ -131,7 +131,6 @@ Appendices and Indices * Obtaining and Building GRUB:: How to obtain and build GRUB * Reporting bugs:: Where you should send a bug report * Index:: - @end menu @iftex diff --git a/docs/prog-ref.texi b/docs/prog-ref.texi index 60c35328d..f07fbf98a 100644 --- a/docs/prog-ref.texi +++ b/docs/prog-ref.texi @@ -290,16 +290,17 @@ However, GRUB is a very large program, so we break GRUB into 2 (or 3) distinct components, @dfn{stage1} and @dfn{stage2} (and optionally @dfn{stage1.5}). @xref{Memory map}, for more information. -We embed @dfn{stage1} in a MBR or in a partition table, and place -@dfn{stage2} in a filesystem. The optional @dfn{stage1.5} can be -installed in a filesystem, in the @dfn{bootloader} area in a FFS, and in -the sectors right after a MBR, because @dfn{stage1.5} is enough small -and the sectors right after a MBR is normally an unused region. The size -of this region is the number of sectors per head minus 1. +We embed @dfn{stage1} in a MBR or in the boot sector of a partition +table, and place @dfn{stage2} in a filesystem. The optional +@dfn{stage1.5} can be installed in a filesystem, in the @dfn{bootloader} +area in a FFS, and in the sectors right after a MBR, because +@dfn{stage1.5} is enough small and the sectors right after a MBR is +normally an unused region. The size of this region is the number of +sectors per head minus 1. Thus, all the @dfn{stage1} must do is just load a @dfn{stage2} or @dfn{stage1.5}. But even if @dfn{stage1} needs not to support the user -interface or the filesystem interfave, it is impossible to make +interface or the filesystem interface, it is impossible to make @dfn{stage1} less than 400 bytes, because GRUB should support both the CHS mode and the LBA mode (@pxref{Low-level disk I/O}). @@ -325,9 +326,9 @@ The flow of @dfn{stage2} (and @dfn{stage1.5}) is: @enumerate @item -Load the rest of itself to the real starting address, the starting -address plus 512 bytes. The blocklists is stored in the last part of the -first sector. +Load the rest of itself to the real starting address, that is, the +starting address plus 512 bytes. The blocklists are stored in the last +part of the first sector. @item Long jump to the real starting address. @@ -989,10 +990,6 @@ of maximum cylinder number in bits 6-7. @item @code{ES:DI} @tab Drive parameter table (floppies only). @end multitable -GRUB does not use this call for floppies, but attempts to read the first -sector from the last head of the last cylinder to determine the maximum -head number and the maximum cylinder number. - @node LBA mode disk I/O @section INT 13H, AH=4xh interrupt call diff --git a/docs/user-ref.texi b/docs/user-ref.texi index 56833074d..086061373 100644 --- a/docs/user-ref.texi +++ b/docs/user-ref.texi @@ -420,7 +420,7 @@ configuration file and in the command line. @menu * Menu-specific commands:: -* General commads:: +* General commands:: * Command-line-specific commands:: @end menu @@ -459,40 +459,43 @@ start, where they are ignored. Commands usable in the menu only. -@table @code -@item default @var{num} +@deffn Command default num Set the default entry to the entry number @var{num} (if not specified, it is 0, the first entry). +@end deffn -@item fallback @var{num} +@deffn Command fallback num Go into unattended boot mode: if the default boot entry has any errors, instead of waiting for the user to do anything, it immediately starts over using the @var{num} entry (same numbering as the @code{default} command). This obviously won't help if the machine was rebooted by a kernel that GRUB loaded. +@end deffn -@item password @var{passwd} @var{new-config-file} +@deffn Command password passwd new-config-file Disable all interactive editing control (menu entry editor and command line). If the password @var{passwd} is entered, it loads the @var{new-config-file} as a new config file and restarts the GRUB Stage 2. +@end deffn -@item timeout @var{sec} +@deffn Command timeout sec Set a timeout, in @var{sec} seconds, before automatically booting the default entry (normally the first entry defined). +@end deffn -@item title @var{name}@dots{} +@deffn Command title name @dots{} Start a new boot entry, and set its name to the contents of the rest of the line, starting with the first non-space character. -@end table +@end deffn -@node General commads + +@node General commands @section The list of general commands Commands usable both in the menu and in the command line. -@table @code -@item color @var{normal} [@var{highlight}] +@deffn Command color normal [highlight] Change the menu colors. The color @var{normal} is used for most lines in the menu, and the color @var{highlight} is used to highlight the line where the cursor points. If you omit @var{highlight}, then the @@ -569,8 +572,9 @@ color light-gray/blue black/light-gray title OS-BS like color magenta/blue black/magenta @end example +@end deffn -@item device @var{drive} @var{file} +@deffn Command device drive file In the grub shell, specify the file @var{file} as the actual drive for a @sc{bios} drive @var{drive}. You can use this command to create a disk image and to fix the drives guessed by GRUB when GRUB fails to determine @@ -582,17 +586,19 @@ grub> device (hd0) /dev/sd0 @end example This command is just ignored in Stage 2. +@end deffn -@item hide @var{partition} +@deffn Command hide partition Hide @var{partition} by setting the @dfn{hidden} bit in its partition type code. This is useful only for DOS or Windows when multiple primary partitions exist in one disk. +@end deffn -@item unhide @var{partition} +@deffn Command unhide partition Unhide @var{partition} by clearing the @dfn{hidden} bit in its partition type code. This is useful only for DOS or Windows when multiple primary partitions exist in one disk. -@end table +@end deffn @node Command-line-specific commands @@ -601,36 +607,40 @@ partitions exist in one disk. These commands are usable only in the command line and in menu entries. If you forget some command, run the command @command{help}. -@table @code -@item boot +@deffn Command boot This boots the OS/chain-loader which has been loaded. Only necessary if running the fully interactive command line (it is implicit at the end of a config-file entry). +@end deffn -@item cat @var{file} +@deffn Command cat file Display the contents of the file @var{file}. This command may be useful to remind you of your OS's root partition: @example grub> cat /etc/fstab @end example +@end deffn -@item chainloader @var{file} +@deffn Command chainloader file Load @var{file} as a chain-loader. Like any other file loaded by the filesystem code, it can use the blocklist notation to grab the first sector of the current partition with @samp{+1}. +@end deffn -@item configfile @var{file} +@deffn Command configfile @var{file} Load @var{file} as the configuration file. +@end deffn -@item embed @var{stage1_5} @var{device} +@deffn Command embed stage1_5 device Embed the Stage 1.5 @var{stage1_5} in the sectors after the MBR if @var{device} is a drive, or in the @dfn{bootloader} area if @var{device} is a FFS partition.@footnote{The latter feature has not been implemented yet.} Print the number of sectors which @var{stage1_5} occupies if successful. +@end deffn -@item displaymem +@deffn Command displaymem Display what GRUB thinks the system address space map of the machine is, including all regions of physical @sc{ram} installed. GRUB's @dfn{upper/lower memory} display uses the standard BIOS interface for @@ -639,13 +649,15 @@ synthesized number from various BIOS interfaces of the memory starting at 1MB and going up to the first chipset hole for @dfn{upper memory} (the standard PC @dfn{upper memory} interface is limited to reporting a maximum of 64MB). +@end deffn -@item find @var{filename} +@deffn Command find filename Search for the filename @var{filename} in all of partitions and print the list of the devices which contain the file. @var{filename} should be an absolute filename like @code{/boot/grub/stage1}. +@end deffn -@item fstest +@deffn Command fstest Toggle filesystem test mode. Filesystem test mode, when turned on, prints out data corresponding to @@ -657,63 +669,71 @@ requests from the disk. Filesystem test mode is turned off by any use of the @command{install} or @command{testload} commands. +@end deffn -@item geometry @var{drive} [@var{cylinder} @var{head} @var{sector} [@var{total_sector}]] +@deffn Command geometry drive [cylinder head sector [total_sector]] Print the information for the drive @var{drive}. In the grub shell, you can set the geometry of the drive arbitrarily. The number of the cylinders, the one of the heads, the one of the sectors and the one of the total sectors are set to CYLINDER, HEAD, SECTOR and TOTAL_SECTOR, respectively. If you omit TOTAL_SECTOR, then it will be calculated based on the C/H/S values automatically. +@end deffn -@item help [@var{pattern} @dots{}] +@deffn Command help [pattern @dots{}] Display helpful information about builtin commands. If you do not specify @var{pattern}, this command lists the short documents of all available commands, and, if you specify one or more @var{pattern}s, it displays long documents of the commands which match @var{pattern}. +@end deffn -@item impsprobe +@deffn Command impsprobe Probe the Intel Multiprocessor Specification 1.1 or 1.4 configuration table and boot the various CPUs which are found into a tight loop. +@end deffn -@item initrd @var{file} @dots{} +@deffn Command initrd file @dots{} Load an initial ramdisk for a Linux format boot image and set the appropriate parameters in the Linux setup area in memory. +@end deffn -@item install @var{stage1-file} [d] @var{dest-device} @var{file} [@var{addr}] [p] [@var{config-file}] +@deffn Command install stage1_file [@option{d}] dest_dev file [addr] [@option{p}] [config_file] This command is fairly complex, and you should not use this command unless you are familiar with GRUB. In short, it will perform a full install presuming the Stage 2 or Stage 1.5@footnote{They're loaded the same way, so we will refer to the Stage 1.5 as a Stage 2 from now on.} is in its final install location. -In slightly more detail, it will load @var{stage1-file}, validate that +In slightly more detail, it will load @var{stage1_file}, validate that it is a GRUB Stage 1 of the right version number, install a blocklist for -loading @var{file} as a Stage 2. If the option @samp{d} is present, the +loading @var{file} as a Stage 2. If the option @option{d} is present, the Stage 1 will always look for the actual disk @var{file} was installed on, rather than using the booting drive. The Stage 2 will be loaded at address @var{addr}, which must be @samp{0x8000} for a true Stage 2, and @samp{0x2000} for a Stage 1.5. If @var{addr} is not present, GRUB will determine the address automatically. It then writes the completed Stage 1 -to the first block of the device @var{dest-dev}. If the options @samp{p} -or @var{config-file} are present, then it reads the first block of +to the first block of the device @var{dest_dev}. If the options @option{p} +or @var{config_file} are present, then it reads the first block of stage2, modifies it with the values of the partition @var{file} was -found on (for @samp{p}) or places the string @var{config-file} into the +found on (for @option{p}) or places the string @var{config_file} into the area telling the stage2 where to look for a configuration file at boot time. This command preserves the DOS BPB (and for hard disks, the partition table) of the sector the Stage 1 is to be installed into. +@end deffn -@item kernel @var{file} @dots{} +@deffn Command kernel file @dots{} Attempt to load the primary boot image (Multiboot a.out or @sc{elf}, Linux zImage or bzImage, FreeBSD a.out, NetBSD a.out, etc.) from @var{file}. The rest of the line is passed verbatim as the @dfn{kernel command line}. Any modules must be reloaded after using this command. +@end deffn -@item makeactive +@deffn Command makeactive Set the active partition on the root disk to GRUB's root device. This command is limited to @emph{primary} PC partitions on a hard disk. +@end deffn -@item map @var{to_drive} @var{from_drive} +@deffn Command map to_drive from_drive Map the drive @var{from_drive} to the drive @var{to_drive}. This is necessary when you chain-load some operating systems, such as DOS, if such an OS resides at a non-first drive. Here is an example: @@ -725,34 +745,40 @@ grub> map (hd1) (hd0) The example exchanges the order between the first hard disk and the second hard disk. +@end deffn -@item module @var{file} @dots{} +@deffn Command module file @dots{} Load a boot module @var{file} for a Multiboot format boot image (no interpretation of the file contents are made, so that user of this command must know what the kernel in question expects). The rest of the line is passed as the @dfn{module command line}, like the @command{kernel} command. You must load a Multiboot kernel image before loading any module. +@end deffn -@item modulenounzip @var{file} @dots{} +@deffn Command modulenounzip file @dots{} The same as @command{module}, except that automatic decompression is disabled. +@end deffn -@item pause @var{message}@dots{} +@deffn Command pause message @dots{} Print the @var{message}, then wait until a key is pressed. Note that placing @key{^G} (ASCII code 7) in the message will cause the speaker to emit the standard beep sound, which is useful when prompting the user to change floppies. +@end deffn -@item quit +@deffn Command quit Exit from the GRUB shell @command{grub} (@pxref{Invoking the grub shell}). This command is ignored in the native Stage 2. +@end deffn -@item read @var{addr} +@deffn Command read addr Read a 32-bit value from memory at address @var{addr} and display it in hex format. +@end deffn -@item root @var{device} [@var{hdbias}] +@deffn Command root device [hdbias] Set the current @dfn{root device} to the device @var{device}, then attempt to mount it to get the partition size (for passing the partition descriptor in @code{ES:ESI}, used by some chain-loaded bootloaders), the @@ -763,15 +789,17 @@ kernel how many BIOS drive numbers are on controllers before the current one. For example, if there is an IDE disk and a SCSI disk, and your FreeBSD root partition is on the SCSI disk, then use a @samp{1} for @var{hdbias}. +@end deffn -@item rootnoverify @var{device} [@var{hdbias}] +@deffn Command rootnoverify device [hdbias] Similar to @command{root}, but don't attempt to mount the partition. This is useful for when an OS is outside of the area of the disk that GRUB can read, but setting the correct root device is still desired. Note that the items mentioned in @command{root} above which derived from attempting the mount will @emph{not} work correctly. +@end deffn -@item setup @var{install_device} [@var{image_device}] +@deffn Command setup install_device [image_device] Set up the installation of GRUB automatically. This command uses the more flexible command @command{install} in the backend and installs GRUB into the device @var{install_device}. If @var{image_device} is @@ -779,8 +807,9 @@ specified, then find the GRUB images in the device @var{image_device}, otherwise use the current @dfn{root device}, which can be set by the command @command{root}. If @var{install_dvice} is a hard disk, then embed a Stage 1.5 in the disk if possible. +@end deffn -@item testload @var{file} +@deffn Command testload file Read the entire contents of @var{file} in several different ways and compares them, to test the filesystem code. The output is somewhat cryptic , but if no errors are reported and the final @samp{i=@var{X}, @@ -788,8 +817,9 @@ filepos=@var{Y}} reading has @var{X} and @var{Y} equal, then it is definitely consistent, and very likely works correctly subject to a consistent offset error. If this test succeeds, then a good next step is to try loading a kernel. +@end deffn -@item uppermem @var{kbytes} +@deffn uppermem kbytes Force GRUB to assume that only @var{kbytes} kilobytes of upper memory are installed. Any system address range maps are discarded. @@ -797,7 +827,7 @@ are installed. Any system address range maps are discarded. only be necessary on some old machines. GRUB's BIOS probe can pick up all @sc{ram} on all new machines the author has ever heard of. It can also be used for debugging purposes to lie to an OS. -@end table +@end deffn @node Troubleshooting @@ -1034,7 +1064,7 @@ calls with UNIX system calls and libc functions. The command @command{grub} accepts the following options: -@table @code +@table @option @item --help Print a summary of the command line options and exit. @@ -1177,7 +1207,7 @@ by GRUB. @command{mbchk} accepts the following options: -@table @code +@table @option @item --help Print a summary of the command line options and exit. diff --git a/stage2/builtins.c b/stage2/builtins.c index bf38e54a4..f008adad2 100644 --- a/stage2/builtins.c +++ b/stage2/builtins.c @@ -1464,8 +1464,7 @@ static struct builtin builtin_kernel = kernel_func, BUILTIN_CMDLINE, "kernel FILE [ARG ...]", - "Attempt to load the primary boot image (Multiboot a.out or ELF," - " Linux zImage or bzImage, FreeBSD a.out, or NetBSD a.out) from" + "Attempt to load the primary boot image from" " FILE. The rest of the line is passed verbatim as the" " \"kernel command line\". Any modules must be reloaded after" " using this command." @@ -1503,10 +1502,6 @@ keycode_func (char *arg, int flags) return 1; } - /* If TO is identical with FROM, do nothing. */ - if (to == from) - return 0; - /* Find an empty slot. */ for (i = 0; i < KEY_MAP_SIZE; i++) { @@ -1526,7 +1521,12 @@ keycode_func (char *arg, int flags) return 1; } - key_map[i] = (to << 8) | from; + if (to == from) + /* If TO is equal to FROM, delete the entry. */ + grub_memmove ((char *) &key_map[i], (char *) &key_map[i + 1], + sizeof (unsigned short) * (KEY_MAP_SIZE - i)); + else + key_map[i] = (to << 8) | from; /* Ugly but should work. */ unset_int15_handler (); @@ -1562,7 +1562,7 @@ static struct builtin builtin_makeactive = makeactive_func, BUILTIN_CMDLINE, "makeactive", - "Set the active partition on the root disk to GRUB's root partition." + "Set the active partition on the root disk to GRUB's root device." " This command is limited to _primary_ PC partitions on a hard disk." }; @@ -1592,14 +1592,16 @@ map_func (char *arg, int flags) return 1; from = current_drive; - /* If TO and FROM is the same, do nothing. */ - if (to == from) - return 0; - /* Search for an empty slot in BIOS_DRIVE_MAP. */ for (i = 0; i < DRIVE_MAP_SIZE; i++) - if (! bios_drive_map[i]) - break; + { + /* Perhaps the user wants to override the map. */ + if ((bios_drive_map[i] & 0xff) == from) + break; + + if (! bios_drive_map[i]) + break; + } if (i == DRIVE_MAP_SIZE) { @@ -1607,7 +1609,13 @@ map_func (char *arg, int flags) return 1; } - bios_drive_map[i] = from | (to << 8); + if (to == from) + /* If TO is equal to FROM, delete the entry. */ + grub_memmove ((char *) &bios_drive_map[i], (char *) &bios_drive_map[i + 1], + sizeof (unsigned short) * (DRIVE_MAP_SIZE - i)); + else + bios_drive_map[i] = from | (to << 8); + return 0; } @@ -1618,7 +1626,7 @@ static struct builtin builtin_map = BUILTIN_CMDLINE, "map TO_DRIVE FROM_DRIVE", "Map the drive FROM_DRIVE to the drive TO_DRIVE. This is necessary" - " when you chain-load some operating systems, such as DOS, if such a" + " when you chain-load some operating systems, such as DOS, if such an" " OS resides at a non-first drive." }; @@ -1838,7 +1846,7 @@ static struct builtin builtin_root = root_func, BUILTIN_CMDLINE, "root DEVICE [HDBIAS]", - "Set the current \"root partition\" to the device DEVICE, then" + "Set the current \"root device\" to the device DEVICE, then" " attempt to mount it to get the partition size (for passing the" " partition descriptor in `ES:ESI', used by some chain-loaded" " bootloaders), the BSD drive-type (for booting BSD kernels using" @@ -1872,7 +1880,7 @@ static struct builtin builtin_rootnoverify = "rootnoverify DEVICE [HDBIAS]", "Similar to `root', but don't attempt to mount the partition. This" " is useful for when an OS is outside of the area of the disk that" - " GRUB can read, but setting the correct root partition is still" + " GRUB can read, but setting the correct root device is still" " desired. Note that the items mentioned in `root' which" " derived from attempting the mount will NOT work correctly." }; @@ -2080,7 +2088,7 @@ static struct builtin builtin_setup = " the more flexible command \"install\" in the backend and installs" " GRUB into the device INSTALL_DEVICE. If IMAGE_DEVICE is specified," " then find the GRUB images in the device IMAGE_DEVICE, otherwise" - " use the current \"root partition\", which can be set by the command" + " use the current \"root device\", which can be set by the command" " \"root\"." };