2009-06-11 Vladimir Serbinenko <phcoder@gmail.com>
Drivemap fixes * commands/i386/pc/drivemap.c (grub_get_root_biosnumber_drivemap): new function (grub_get_root_biosnumber_saved): new variable (GRUB_MOD_INIT): register grub_get_root_biosnumber_drivemap (GRUB_MOD_FINI): unregister grub_get_root_biosnumber_drivemap * commands/i386/pc/drivemap_int13h.S (grub_drivemap_handler): restore %dx after the call if necessary * conf/common.rmk (pkglib_MODULES): remove boot.mod (boot_mod_SOURCES): remove (boot_mod_CFLAGS): remove (boot_mod_LDFLAGS): remove * conf/i386-coreboot.rmk (pkglib_MODULES): add boot.mod (boot_mod_SOURCES): new variable (boot_mod_CFLAGS): likewise (boot_mod_LDFLAGS): likewise * conf/i386-efi.rmk: likewise * conf/i386-ieee1275.rmk: likewise * conf/i386-pc.rmk: likewise * conf/powerpc-ieee1275.rmk: likewise * conf/sparc64-ieee1275.rmk: likewise * conf/x86_64-efi.rmk: likewise * include/grub/i386/pc/biosnum.h: new file * lib/i386/pc/biosnum.c: likewise * loader/i386/bsd.c (grub_bsd_get_device): use grub_get_root_biosnumber * loader/i386/multiboot.c (grub_multiboot_get_bootdev): likewise * loader/i386/pc/chainloader.c (grub_chainloader_cmd): likewise
This commit is contained in:
parent
5ac35b35b0
commit
63963d17d0
16 changed files with 269 additions and 67 deletions
|
@ -33,6 +33,12 @@
|
|||
#include <grub/gzio.h>
|
||||
#include <grub/aout.h>
|
||||
#include <grub/command.h>
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
#include <grub/machine/biosnum.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/device.h>
|
||||
#include <grub/partition.h>
|
||||
#endif
|
||||
|
||||
#define ALIGN_DWORD(a) ALIGN_UP (a, 4)
|
||||
#define ALIGN_QWORD(a) ALIGN_UP (a, 8)
|
||||
|
@ -81,23 +87,22 @@ grub_bsd_get_device (grub_uint32_t * biosdev,
|
|||
grub_uint32_t * slice, grub_uint32_t * part)
|
||||
{
|
||||
char *p;
|
||||
grub_device_t dev;
|
||||
|
||||
*biosdev = *unit = *slice = *part = 0;
|
||||
p = grub_env_get ("root");
|
||||
if ((p) && ((p[0] == 'h') || (p[0] == 'f')) && (p[1] == 'd') &&
|
||||
(p[2] >= '0') && (p[2] <= '9'))
|
||||
*biosdev = grub_get_root_biosnumber () & 0xff;
|
||||
*unit = (*biosdev & 0x7f);
|
||||
*slice = 0xff;
|
||||
*part = 0xff;
|
||||
dev = grub_device_open (0);
|
||||
if (dev && dev->disk && dev->disk->partition)
|
||||
{
|
||||
if (p[0] == 'h')
|
||||
*biosdev = 0x80;
|
||||
|
||||
*unit = grub_strtoul (p + 2, &p, 0);
|
||||
*biosdev += *unit;
|
||||
|
||||
if ((p) && (p[0] == ','))
|
||||
p = dev->disk->partition->partmap->get_name (dev->disk->partition);
|
||||
if (p)
|
||||
{
|
||||
if ((p[1] >= '0') && (p[1] <= '9'))
|
||||
if ((p[0] >= '0') && (p[0] <= '9'))
|
||||
{
|
||||
*slice = grub_strtoul (p + 1, &p, 0);
|
||||
*slice = grub_strtoul (p, &p, 0);
|
||||
|
||||
if ((p) && (p[0] == ','))
|
||||
p++;
|
||||
|
@ -107,6 +112,8 @@ grub_bsd_get_device (grub_uint32_t * biosdev,
|
|||
*part = p[0] - 'a';
|
||||
}
|
||||
}
|
||||
if (dev)
|
||||
grub_device_close (dev);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
|
|
|
@ -42,6 +42,12 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/gzio.h>
|
||||
#include <grub/env.h>
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
#include <grub/machine/biosnum.h>
|
||||
#include <grub/disk.h>
|
||||
#include <grub/device.h>
|
||||
#include <grub/partition.h>
|
||||
#endif
|
||||
|
||||
extern grub_dl_t my_mod;
|
||||
static struct grub_multiboot_info *mbi, *mbi_dest;
|
||||
|
@ -148,46 +154,42 @@ grub_multiboot_load_elf (grub_file_t file, void *buffer)
|
|||
static int
|
||||
grub_multiboot_get_bootdev (grub_uint32_t *bootdev)
|
||||
{
|
||||
#ifdef GRUB_MACHINE_PCBIOS
|
||||
char *p;
|
||||
grub_uint32_t biosdev, slice = ~0, part = ~0;
|
||||
grub_device_t dev;
|
||||
|
||||
p = grub_env_get ("root");
|
||||
if ((p) && ((p[0] == 'h') || (p[0] == 'f')) && (p[1] == 'd') &&
|
||||
(p[2] >= '0') && (p[2] <= '9'))
|
||||
biosdev = grub_get_root_biosnumber ();
|
||||
|
||||
dev = grub_device_open (0);
|
||||
if (dev && dev->disk && dev->disk->partition)
|
||||
{
|
||||
grub_uint32_t bd;
|
||||
|
||||
bd = (p[0] == 'h') ? 0x80 : 0;
|
||||
bd += grub_strtoul (p + 2, &p, 0);
|
||||
bd <<= 24;
|
||||
|
||||
if ((p) && (p[0] == ','))
|
||||
p = dev->disk->partition->partmap->get_name (dev->disk->partition);
|
||||
if (p)
|
||||
{
|
||||
if ((p[1] >= '0') && (p[1] <= '9'))
|
||||
if ((p[0] >= '0') && (p[0] <= '9'))
|
||||
{
|
||||
|
||||
bd += ((grub_strtoul (p + 1, &p, 0) - 1) & 0xFF) << 16;
|
||||
slice = grub_strtoul (p, &p, 0);
|
||||
|
||||
if ((p) && (p[0] == ','))
|
||||
p++;
|
||||
}
|
||||
else
|
||||
bd += 0xFF0000;
|
||||
|
||||
if ((p[0] >= 'a') && (p[0] <= 'z'))
|
||||
bd += (p[0] - 'a') << 8;
|
||||
else
|
||||
bd += 0xFF00;
|
||||
part = p[0] - 'a';
|
||||
}
|
||||
else
|
||||
bd += 0xFFFF00;
|
||||
|
||||
bd += 0xFF;
|
||||
|
||||
*bootdev = bd;
|
||||
return 1;
|
||||
}
|
||||
if (dev)
|
||||
grub_device_close (dev);
|
||||
|
||||
*bootdev = ((biosdev & 0xff) << 24) | ((slice & 0xff) << 16)
|
||||
| ((part & 0xff) << 16) | 0xff;
|
||||
return (biosdev != ~0UL);
|
||||
#else
|
||||
*bootdev = 0xffffffff;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <grub/machine/memory.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/command.h>
|
||||
#include <grub/machine/biosnum.h>
|
||||
|
||||
static grub_dl_t my_mod;
|
||||
static int boot_drive;
|
||||
|
@ -89,30 +90,19 @@ grub_chainloader_cmd (const char *filename, grub_chainloader_flags_t flags)
|
|||
grub_file_close (file);
|
||||
|
||||
/* Obtain the partition table from the root device. */
|
||||
drive = grub_get_root_biosnumber ();
|
||||
dev = grub_device_open (0);
|
||||
if (dev)
|
||||
if (dev && dev->disk && dev->disk->partition)
|
||||
{
|
||||
grub_disk_t disk = dev->disk;
|
||||
|
||||
if (disk)
|
||||
{
|
||||
grub_partition_t p = disk->partition;
|
||||
|
||||
/* In i386-pc, the id is equal to the BIOS drive number. */
|
||||
drive = (int) disk->id;
|
||||
|
||||
if (p)
|
||||
{
|
||||
grub_disk_read (disk, p->offset, 446, 64,
|
||||
(void *) GRUB_MEMORY_MACHINE_PART_TABLE_ADDR);
|
||||
part_addr = (void *) (GRUB_MEMORY_MACHINE_PART_TABLE_ADDR
|
||||
+ (p->index << 4));
|
||||
}
|
||||
}
|
||||
|
||||
grub_device_close (dev);
|
||||
grub_disk_read (dev->disk, dev->disk->partition->offset, 446, 64,
|
||||
(void *) GRUB_MEMORY_MACHINE_PART_TABLE_ADDR);
|
||||
part_addr = (void *) (GRUB_MEMORY_MACHINE_PART_TABLE_ADDR
|
||||
+ (dev->disk->partition->index << 4));
|
||||
}
|
||||
|
||||
if (dev)
|
||||
grub_device_close (dev);
|
||||
|
||||
/* Ignore errors. Perhaps it's not fatal. */
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue