2007-05-05 Robert Millan <rmh@aybabtu.com>

* conf/i386-pc.rmk (grub_setup_SOURCES): Add partmap/gpt.c.
	(grub_probe_SOURCES): Likewise.
	* util/i386/pc/biosdisk.c (grub_util_biosdisk_get_grub_dev): Detect
	GPT and initialize dos_part and bsd_part accordingly.
	* util/i386/pc/grub-setup.c (setup): Ditto for install_dos_part and
	install_bsd_part.
	(main): Activate gpt module for use during partition identification,
	and deactivate it afterwards.
	* util/i386/pc/grub-install.in: Add gpt module to core.img.
	* util/i386/pc/grub-probe.c (main): Activate gpt module for use during
	partition identification, and deactivate it afterwards.
This commit is contained in:
robertmh 2007-05-04 23:00:56 +00:00
parent 99123174c9
commit 20b976586e
6 changed files with 81 additions and 29 deletions

View file

@ -1,3 +1,17 @@
2007-05-05 Robert Millan <rmh@aybabtu.com>
* conf/i386-pc.rmk (grub_setup_SOURCES): Add partmap/gpt.c.
(grub_probe_SOURCES): Likewise.
* util/i386/pc/biosdisk.c (grub_util_biosdisk_get_grub_dev): Detect
GPT and initialize dos_part and bsd_part accordingly.
* util/i386/pc/grub-setup.c (setup): Ditto for install_dos_part and
install_bsd_part.
(main): Activate gpt module for use during partition identification,
and deactivate it afterwards.
* util/i386/pc/grub-install.in: Add gpt module to core.img.
* util/i386/pc/grub-probe.c (main): Activate gpt module for use during
partition identification, and deactivate it afterwards.
2007-05-05 Robert Millan <rmh@aybabtu.com>
* term/i386/pc/console.c (grub_console_fini): Call

View file

@ -66,8 +66,9 @@ grub_setup_SOURCES = util/i386/pc/grub-setup.c util/i386/pc/biosdisk.c \
util/misc.c util/i386/pc/getroot.c kern/device.c kern/disk.c \
kern/err.c kern/misc.c fs/fat.c fs/ext2.c fs/xfs.c fs/affs.c \
fs/sfs.c kern/parser.c kern/partition.c partmap/pc.c \
fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c fs/hfsplus.c kern/file.c \
kern/fs.c kern/env.c fs/fshelp.c util/raid.c util/lvm.c
partmap/gpt.c fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c \
fs/hfsplus.c kern/file.c kern/fs.c kern/env.c fs/fshelp.c \
util/raid.c util/lvm.c
# For grub-mkdevicemap.
grub_mkdevicemap_SOURCES = util/i386/pc/grub-mkdevicemap.c util/misc.c
@ -76,9 +77,10 @@ grub_mkdevicemap_SOURCES = util/i386/pc/grub-mkdevicemap.c util/misc.c
grub_probe_SOURCES = util/i386/pc/grub-probe.c \
util/i386/pc/biosdisk.c util/misc.c util/i386/pc/getroot.c \
kern/device.c kern/disk.c kern/err.c kern/misc.c fs/fat.c \
fs/ext2.c kern/parser.c kern/partition.c partmap/pc.c fs/ufs.c \
fs/minix.c fs/hfs.c fs/jfs.c kern/fs.c kern/env.c fs/fshelp.c \
fs/xfs.c fs/affs.c fs/sfs.c fs/hfsplus.c disk/lvm.c disk/raid.c
fs/ext2.c kern/parser.c kern/partition.c partmap/pc.c \
partmap/gpt.c fs/ufs.c fs/minix.c fs/hfs.c fs/jfs.c kern/fs.c \
kern/env.c fs/fshelp.c fs/xfs.c fs/affs.c fs/sfs.c fs/hfsplus.c \
disk/lvm.c disk/raid.c
# For grub-emu.
grub_emu_DEPENDENCIES = grub_script.tab.c grub_script.tab.h \

View file

@ -1,7 +1,7 @@
/* biosdisk.c - emulate biosdisk */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004,2006 Free Software Foundation, Inc.
* Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2007 Free Software Foundation, Inc.
*
* GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -743,9 +743,12 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
const grub_partition_t partition)
{
struct grub_pc_partition *pcdata = 0;
int gpt = 0;
if (strcmp (partition->partmap->name, "pc_partition_map") == 0)
pcdata = partition->data;
else if (strcmp (partition->partmap->name, "gpt_partition_map") == 0)
gpt = 1;
if (pcdata)
{
@ -757,6 +760,11 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
pcdata->dos_part, pcdata->bsd_part + 'a',
partition->start);
}
else if (gpt)
{
grub_util_info ("GPT partition %d starts from %lu",
partition->index, partition->start);
}
if (hdg.start == partition->start)
{
@ -765,6 +773,11 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
dos_part = pcdata->dos_part;
bsd_part = pcdata->bsd_part;
}
else if (gpt)
{
dos_part = grub_cpu_to_le32 (partition->index);
bsd_part = grub_cpu_to_le32 (-1);
}
else
{
dos_part = 0;

View file

@ -216,8 +216,8 @@ if test "x$fs_module" = x -a "x$modules" = x; then
exit 1
fi
# Typically, _chain and pc are required.
modules="$modules $fs_module _chain pc"
# Typically, _chain, pc and gpt are required.
modules="$modules $fs_module _chain pc gpt"
$grub_mkimage --output=${grubdir}/core.img $modules || exit 1

View file

@ -244,6 +244,7 @@ main (int argc, char *argv[])
/* Initialize the emulated biosdisk driver. */
grub_util_biosdisk_init (dev_map ? : DEFAULT_DEVICE_MAP);
grub_pc_partition_map_init ();
grub_gpt_partition_map_init ();
grub_raid_init ();
grub_lvm_init ();
@ -268,6 +269,7 @@ main (int argc, char *argv[])
grub_lvm_fini ();
grub_raid_fini ();
grub_gpt_partition_map_fini ();
grub_pc_partition_map_fini ();
grub_util_biosdisk_fini ();

View file

@ -1,7 +1,7 @@
/* grub-setup.c - make GRUB usable */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006 Free Software Foundation, Inc.
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
*
* GRUB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -288,22 +288,33 @@ setup (const char *prefix, const char *dir,
if (must_embed)
*install_dos_part = *install_bsd_part = grub_cpu_to_le32 (-2);
else if (root_dev->disk->partition)
{
if (strcmp (root_dev->disk->partition->partmap->name,
"pc_partition_map") == 0)
{
struct grub_pc_partition *pcdata =
root_dev->disk->partition->data;
if (strcmp (root_dev->disk->partition->partmap->name,
"pc_partition_map") != 0)
grub_util_error ("No PC style partitions found");
*install_dos_part
= grub_cpu_to_le32 (pcdata->dos_part);
*install_bsd_part
= grub_cpu_to_le32 (pcdata->bsd_part);
}
else if (strcmp (root_dev->disk->partition->partmap->name,
"gpt_partition_map") == 0)
{
*install_dos_part = grub_cpu_to_le32 (root_dev->disk->partition->index);
*install_bsd_part = grub_cpu_to_le32 (-1);
}
else
grub_util_error ("No PC style partitions found");
}
else
*install_dos_part = *install_bsd_part = grub_cpu_to_le32 (-1);
grub_util_info ("dos partition is %d, bsd partition is %d, prefix is %s",
grub_le_to_cpu32 (*install_dos_part),
grub_le_to_cpu32 (*install_bsd_part),
prefix);
strcpy (install_prefix, prefix);
/* Write the core image onto the disk. */
@ -453,18 +464,26 @@ setup (const char *prefix, const char *dir,
root_dev->disk->partition->data;
if (strcmp (root_dev->disk->partition->partmap->name,
"pc_partition_map") != 0)
grub_util_error ("No PC style partitions found");
"pc_partition_map") == 0)
{
*install_dos_part
= grub_cpu_to_le32 (pcdata->dos_part);
*install_bsd_part
= grub_cpu_to_le32 (pcdata->bsd_part);
}
else if (strcmp (root_dev->disk->partition->partmap->name,
"gpt_partition_map") == 0)
{
*install_dos_part = grub_cpu_to_le32 (root_dev->disk->partition->index);
*install_bsd_part = grub_cpu_to_le32 (-1);
}
else
grub_util_error ("No PC style partitions found");
}
else
*install_dos_part = *install_bsd_part = grub_cpu_to_le32 (-1);
grub_util_info ("dos partition is %u, bsd partition is %u, prefix is %s",
grub_util_info ("dos partition is %d, bsd partition is %d, prefix is %s",
grub_le_to_cpu32 (*install_dos_part),
grub_le_to_cpu32 (*install_bsd_part),
prefix);
@ -644,6 +663,7 @@ main (int argc, char *argv[])
/* Initialize the emulated biosdisk driver. */
grub_util_biosdisk_init (dev_map ? : DEFAULT_DEVICE_MAP);
grub_pc_partition_map_init ();
grub_gpt_partition_map_init ();
dest_dev = get_device_name (argv[optind]);
if (! dest_dev)
@ -745,6 +765,7 @@ main (int argc, char *argv[])
grub_hfs_fini ();
grub_jfs_fini ();
grub_gpt_partition_map_fini ();
grub_pc_partition_map_fini ();
grub_util_biosdisk_fini ();