From 133581fe5c0b46c131c47c8939c6d49cd1281108 Mon Sep 17 00:00:00 2001 From: okuji Date: Sun, 19 Sep 1999 21:00:59 +0000 Subject: [PATCH] make the argument address for the command install optional. --- ChangeLog | 19 +++++++++++++++++++ NEWS | 1 + docs/grub.texi | 37 ++++++++++++++++++++++--------------- docs/menu.lst | 6 +++--- stage2/builtins.c | 32 ++++++++++++++++++++++++++------ 5 files changed, 71 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index b1de12f2b..ef6a70990 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +1999-09-20 OKUJI Yoshinori + + The argument ADDR for the command install is now optional. + + * stage2/builtins.c (install_func): If parsing ADDR fails, set + INSTALLADDR to zero and set PTR to ADDR. + If INSTALLADDR is zero after parsing the command-line, check if + the Stage 2 id is STAGE2_ID_STAGE2. If so, set INSTALLADDR to + 0x8000, otherwise set it to 0x2000. + Set the install address in the Stage 1 after the automatic + determination is completed. + (builtin_install): Say that ADDR is optional in the help + message. + * docs/grub.texi: Synchronize the description about install to + builtins.c. Remove explicit address arguments from all the + examples. Add a description about help. + * docs/menu.lst: Do not specify the address argument for + install. + 1999-09-19 OKUJI Yoshinori The completion code is heavily modified. diff --git a/NEWS b/NEWS index 02bbcedf1..fa16e3b0e 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,7 @@ New in 0.5.93: * FreeBSD support in the grub shell is improved. * Killing (C-u and C-k), yanking (C-y) and manipulating the history (C-p and C-n) are supported. +* The address argument for the command "install" is now optional. New in 0.5.92 - 1999-07-26: * Bug fixes (i.e. Stage 1.5 can work fine again). diff --git a/docs/grub.texi b/docs/grub.texi index f640ec059..8a9faec85 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -431,7 +431,7 @@ configuration file), then run the following command at GRUB's command line (after booting from the GRUB floppy): @example -install (fd0)+1 (hd0) (hd0,1)/boot/grub/stage2 0x8000 p +install (fd0)+1 (hd0) (hd0,1)/boot/grub/stage2 p @end example This tells GRUB to grab the first sector of the floppy and use it as the @@ -448,7 +448,7 @@ telling GRUB's stage1 to read from the first hard disk no matter where the stage1 was loaded from: @example -install (fd0)+1 d (fd0) (hd0,1)/boot/grub/stage2 0x8000 p +install (fd0)+1 d (fd0) (hd0,1)/boot/grub/stage2 p @end example By default, GRUB loads the stage2 from the disk where the stage1 was @@ -474,7 +474,7 @@ dd if=stage2/e2fs_stage1_5 of=/dev/hda bs=512 seek=1 Second, specify the stage1.5 argument in blocklist format: @example -install (fd0)+1 (hd0) (hd0)1+1 0x2000 p (hd0,1)/boot/grub/stage2 +install (fd0)+1 (hd0) (hd0)1+1 p (hd0,1)/boot/grub/stage2 @end example @item @@ -485,7 +485,7 @@ hard disk, and setting the stage2's @dfn{configuration file} to @file{(hd1,a)/grubdir/configfile}: @example -install (hd0,1)/boot/grub/stage1 (hd1) (hd1,a)/boot/grub/stage2 0x8000 p /grubdir/configfile +install (hd0,1)/boot/grub/stage1 (hd1) (hd1,a)/boot/grub/stage2 p /grubdir/configfile @end example @end itemize @@ -497,7 +497,7 @@ and a configuration file which contains entries such as: title GNU/Linux installation # Installation command: -install (fd0)+1 (hd0) (hd0,1)/boot/grub/stage2 0x8000 p +install (fd0)+1 (hd0) (hd0,1)/boot/grub/stage2 p # Actually boot here: root (hd0,1) @@ -784,6 +784,12 @@ requests from the disk. Filesystem test mode is turned off by any use of the @command{install} or @command{testload} commands. +@item help [@var{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}. + @item hide @var{partition} Hide @var{partition} by setting the @dfn{hidden} bit in its partition type code. @@ -796,7 +802,7 @@ table and boot the various CPUs which are found into a tight loop. Load an initial ramdisk for a Linux format boot image and set the appropriate parameters in the Linux setup area in memory. -@item install @var{stage1-file} [d] @var{dest-device} @var{file} @var{addr} [p] [@var{config-file}] +@item install @var{stage1-file} [d] @var{dest-device} @var{file} [@var{addr}] [p] [@var{config-file}] This command is fairly complex, and for detailed examples one should look at @ref{Automated install}. In short, it will perform a full install presuming the stage2 or stage1.5@footnote{They're loaded the @@ -809,14 +815,15 @@ loading @var{file} as a stage2. If the option @samp{d} is present, the stage1 will always look for the actual disk @var{file} was installed on, rather than using the booting drive. The stage2 will be loaded at address @var{addr}, which must be @samp{0x8000} for a true stage2, and -@samp{0x2000} for a stage1.5. It then writes the completed stage1 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 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 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 stage1 is to be installed into. +@samp{0x2000} for a stage1.5. If @var{addr} is not present, GRUB will +determine the address automatically. It then writes the completed stage1 +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 +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 +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 stage1 is to be installed into. @item kernel @var{file} @dots{} Attempt to load the primary boot image (Multiboot a.out or @sc{elf}, @@ -1286,7 +1293,7 @@ option in the command line. This is a simple example: /sbin/grub --batch </dev/null 2>/dev/null root (hd0,0) -install /boot/grub/stage1 (hd0) /boot/grub/stage2 0x8000 p +install /boot/grub/stage1 (hd0) /boot/grub/stage2 p quit EOT @end example diff --git a/docs/menu.lst b/docs/menu.lst index 114f077bf..327f7ad49 100644 --- a/docs/menu.lst +++ b/docs/menu.lst @@ -44,10 +44,10 @@ title Windows NT / Windows 95 boot menu root (hd0,0) makeactive chainloader +1 +# For loading DOS if Windows NT is installed +# chainload /bootsect.dos # For installing GRUB into the hard disk title Install GRUB into the hard disk root (hd0,0) -install /boot/grub/stage1 d (hd0) /boot/grub/stage2 0x8000 p -# For loading DOS if Windows NT is installed -# chainload /bootsect.dos +install /boot/grub/stage1 d (hd0) /boot/grub/stage2 p diff --git a/stage2/builtins.c b/stage2/builtins.c index 4433f64d7..515403633 100644 --- a/stage2/builtins.c +++ b/stage2/builtins.c @@ -768,7 +768,14 @@ install_func (char *arg, int flags) /* Get the installation address. */ if (! safe_parse_maxint (&addr, &installaddr)) - return 1; + { + /* ADDR is not specified. */ + installaddr = 0; + ptr = addr; + errnum = 0; + } + else + ptr = skip_to (0, addr); /* Read Stage 1. */ if (! grub_open (stage1_file) @@ -867,8 +874,6 @@ install_func (char *arg, int flags) *((unsigned char *) (BOOTSEC_LOCATION + STAGE1_FIRSTLIST)) = new_drive; - *((unsigned short *) (BOOTSEC_LOCATION + STAGE1_INSTALLADDR)) - = installaddr; i = BOOTSEC_LOCATION+STAGE1_FIRSTLIST - 4; while (*((unsigned long *) i)) @@ -905,8 +910,23 @@ install_func (char *arg, int flags) return 1; } + /* If INSTALLADDR is not specified explicitly in the command-line, + determine it by the Stage 2 id. */ + if (! installaddr) + { + if (*((unsigned char *) (SCRATCHADDR + STAGE2_STAGE2_ID)) + == STAGE2_ID_STAGE2) + /* Stage 2. */ + installaddr = 0x8000; + else + /* Stage 1.5. */ + installaddr = 0x2000; + } + + *((unsigned short *) (BOOTSEC_LOCATION + STAGE1_INSTALLADDR)) + = installaddr; + stage2_sect = installsect; - ptr = skip_to (0, addr); if (*ptr == 'p') { @@ -965,12 +985,12 @@ static struct builtin builtin_install = "install", install_func, BUILTIN_CMDLINE, - "install STAGE1 [d] DEVICE STAGE2 ADDR [p] [CONFIG_FILE]", + "install STAGE1 [d] DEVICE STAGE2 [ADDR] [p] [CONFIG_FILE]", "Install STAGE1 on DEVICE, and install a blocklist for loading STAGE2" " as a Stage 2. If the option `d' is present, the Stage 1 will always" " look for the disk where STAGE2 was installed, rather than using" " the booting drive. The Stage 2 will be loaded at address ADDR, which" - " must be 0x8000 for a true Stage 2, and 0x2000 for a Stage 1.5. If" + " will be determined automatically if you don't specify it. If" " the option `p' or CONFIG_FILE is present, then the first block" " of Stage 2 is patched with new values of the partition and name" " of the configuration file used by the true Stage 2 (for a Stage 1.5,"