pass the boot partition information to a chain-loader, in the partition table area of the loader.

This commit is contained in:
okuji 2000-02-16 11:14:36 +00:00
parent 687f54b6b8
commit 7c4acb2539
4 changed files with 71 additions and 17 deletions

View file

@ -1,3 +1,29 @@
2000-02-16 OKUJI Yoshinori <okuji@gnu.org>
Pass the boot partition information to a chain-loader, in the
partition table area of the loader, instead of right before the
loaded address. Reported by takehiro@coral.ocn.ne.jp (Takehiro
Suzuki).
* stage2/builtins.c (chainloader_func): Embed the partition
table of the boot drive in the partition table area of the
chain-loader, if the boot drive is a hard disk drive.
Pass BOOT_PART_ADDR instead of (BOOTSEC_LOCATION - 16) as the
third argument for the function chain_stage1.
* stage2/disk_io.c [!STAGE1_5] (boot_part_addr): New variable.
[!STAGE1_5] (boot_part_offset): Likewise.
[!STAGE1_5] (cur_part_offset): Likewise.
[!STAGE1_5] (cur_part_addr): Likewise.
[!STAGE1_5] (cur_part_desc): Removed.
(real_open_partition) [!STAGE1_5]: Set CUR_PART_OFFSET and
CUR_PART_ADDR to PART_OFFSET and (BOOTSEC_LOCATION +
PC_SLICE_OFFSET + (i << 4)), respectively.
[!STAGE1_5] (set_bootdev): Set BOOT_PART_OFFSET and
BOOT_PART_ADDR to CUR_PART_OFFSET and CUR_PART_ADDR,
respectively.
* stage2/shared.h (boot_part_addr): Declared.
(boot_part_offset): Likewise.
2000-02-12 OKUJI Yoshinori <okuji@gnu.org> 2000-02-12 OKUJI Yoshinori <okuji@gnu.org>
* stage2/builtins.c (geometry_func): Attempt to read the first * stage2/builtins.c (geometry_func): Attempt to read the first

View file

@ -217,7 +217,28 @@ boot_func (char *arg, int flags)
gateA20 (0); gateA20 (0);
boot_drive = saved_drive; boot_drive = saved_drive;
chain_stage1 (0, BOOTSEC_LOCATION, BOOTSEC_LOCATION - 16);
/* Copy the boot partition information to the chain-loader, if
BOOT_DRIVE is a hard disk drive. */
if (boot_drive & 0x80)
{
/* Read the MBR here, because it might be modified
after opening the partition. */
if (! rawread (boot_drive, boot_part_offset,
0, SECTOR_SIZE, (char *) SCRATCHADDR))
{
/* This should never happen. */
errnum = ERR_READ;
return 0;
}
/* Need only the partition table. */
grub_memmove ((char *) BOOTSEC_LOCATION + BOOTSEC_PART_OFFSET,
(char *) SCRATCHADDR + BOOTSEC_PART_OFFSET,
BOOTSEC_PART_LENGTH);
}
chain_stage1 (0, BOOTSEC_LOCATION, boot_part_addr);
break; break;
case KERNEL_TYPE_MULTIBOOT: case KERNEL_TYPE_MULTIBOOT:

View file

@ -67,6 +67,13 @@ struct fsys_entry fsys_table[NUM_FSYS + 1] =
unsigned long current_drive = 0xFF; unsigned long current_drive = 0xFF;
unsigned long current_partition; unsigned long current_partition;
#ifndef STAGE1_5
/* The register ESI should contain the address of the partition to be
used for loading a chain-loader when chain-loading the loader. */
unsigned long boot_part_addr;
unsigned long boot_part_offset;
#endif
/* /*
* Global variables describing details of the filesystem * Global variables describing details of the filesystem
*/ */
@ -451,16 +458,16 @@ check_BSD_parts (int flags)
return 0; return 0;
} }
#ifndef STAGE1_5 #ifndef STAGE1_5
static char cur_part_desc[16]; static unsigned long cur_part_offset;
static unsigned long cur_part_addr;
#endif #endif
int int
real_open_partition (int flags) real_open_partition (int flags)
{ {
char mbr_buf[SECTOR_SIZE];
int i, part_no, slice_no, ext = 0; int i, part_no, slice_no, ext = 0;
char mbr_buf[SECTOR_SIZE];
#ifndef STAGE1_5 #ifndef STAGE1_5
/* network drive */ /* network drive */
@ -527,9 +534,8 @@ real_open_partition (int flags)
part_start = part_offset + PC_SLICE_START (mbr_buf, i); part_start = part_offset + PC_SLICE_START (mbr_buf, i);
part_length = PC_SLICE_LENGTH (mbr_buf, i); part_length = PC_SLICE_LENGTH (mbr_buf, i);
#ifndef STAGE1_5 #ifndef STAGE1_5
grub_memmove (cur_part_desc, cur_part_offset = part_offset;
mbr_buf + PC_SLICE_OFFSET + (i << 4), cur_part_addr = BOOTSEC_LOCATION + PC_SLICE_OFFSET + (i << 4);
16);
#endif #endif
/* /*
@ -848,10 +854,9 @@ set_bootdev (int hdbias)
{ {
int i, j; int i, j;
/* /* Save the boot partition for chain-loading. */
* Set chainloader boot device. boot_part_offset = cur_part_offset;
*/ boot_part_addr = cur_part_addr;
memmove ((char *) (BOOTSEC_LOCATION - 16), cur_part_desc, 16);
/* /*
* Set BSD boot device. * Set BSD boot device.

View file

@ -415,6 +415,8 @@ typedef enum
extern unsigned long install_partition; extern unsigned long install_partition;
extern unsigned long boot_drive; extern unsigned long boot_drive;
extern unsigned long boot_part_addr;
extern unsigned long boot_part_offset;
extern char version_string[]; extern char version_string[];
extern char config_file[]; extern char config_file[];