Support cross-disk installs. On non-cross-disk retrieve bootpath from chosen/bootpath

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-04-18 16:35:08 +02:00
parent d0faf8a1b3
commit ee9056d097
3 changed files with 37 additions and 10 deletions

View file

@ -152,6 +152,22 @@ boot_continue:
call console_write
mov GRUB_NAME_LEN, %o3
GET_ABS(boot_path, %o3)
ldub [%o3], %o1
brnz,pn %o1, bootpath_known
mov 4, %g1
/* getprop(chosen_node, "bootpath", &buffer, buffer_size) */
GET_ABS(prom_getprop_name, %o0)
mov 1, %o5
mov CHOSEN_NODE_REG, %o1
GET_ABS(prom_bootpath_name, %o2)
mov (kernel_sector - boot_path), %o4
call prom_call
stx %g1, [%l1 + 256]
bootpath_known:
/* Open up the boot_path, and use that handle to read the
* first block of the GRUB kernel image.
*

View file

@ -43,9 +43,9 @@
#define GRUB_BOOT_MACHINE_BOOT_DEVPATH 0x0a
#define GRUB_BOOT_MACHINE_BOOT_DEVPATH_END 0x80
#define GRUB_BOOT_MACHINE_BOOT_DEVPATH_END (0x80 - 40)
#define GRUB_BOOT_MACHINE_KERNEL_SECTOR 0x88
#define GRUB_BOOT_MACHINE_KERNEL_SECTOR (0x80 - 40)
#define GRUB_BOOT_MACHINE_CODE_END \
(0x1fc - GRUB_BOOT_AOUT_HEADER_SIZE)

View file

@ -114,7 +114,7 @@ setup (const char *prefix, const char *dir,
size_t boot_size, core_size;
grub_uint16_t core_sectors;
grub_device_t root_dev, dest_dev;
char *boot_devpath, *dest_ofpath;
char *boot_devpath;
grub_disk_addr_t *kernel_sector;
struct boot_blocklist *first_block, *block;
char *tmp_img;
@ -219,11 +219,6 @@ setup (const char *prefix, const char *dir,
if (! dest_dev)
grub_util_error ("%s", grub_errmsg);
dest_ofpath
= grub_util_devname_to_ofpath (grub_util_biosdisk_get_osdev (dest_dev->disk));
grub_util_info ("dest_ofpath is `%s'", dest_ofpath);
grub_util_info ("setting the root device to `%s'", root);
if (grub_env_set ("root", root) != GRUB_ERR_NONE)
grub_util_error ("%s", grub_errmsg);
@ -332,6 +327,24 @@ setup (const char *prefix, const char *dir,
!= (grub_ssize_t) core_size - GRUB_DISK_SECTOR_SIZE)
grub_util_error ("failed to read the rest sectors of the core image");
if (file->device->disk->id != dest_dev->disk->id)
{
const char *dest_ofpath;
dest_ofpath
= grub_util_devname_to_ofpath (grub_util_biosdisk_get_osdev (file->device->disk));
grub_util_info ("dest_ofpath is `%s'", dest_ofpath);
strncpy (boot_devpath, dest_ofpath, GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
- GRUB_BOOT_MACHINE_BOOT_DEVPATH - 1);
boot_devpath[GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
- GRUB_BOOT_MACHINE_BOOT_DEVPATH - 1] = 0;
}
else
{
grub_util_info ("non cross-disk install");
memset (boot_devpath, 0, GRUB_BOOT_MACHINE_BOOT_DEVPATH_END
- GRUB_BOOT_MACHINE_BOOT_DEVPATH);
}
grub_file_close (file);
free (core_path);
@ -339,8 +352,6 @@ setup (const char *prefix, const char *dir,
*kernel_sector = grub_cpu_to_be64 (first_sector);
strcpy(boot_devpath, dest_ofpath);
grub_util_info ("boot device path %s, prefix is %s, dest is %s",
boot_devpath, prefix, dest);