From ee9056d097bafe2324d4adaf912364aa9e7fd296 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 18 Apr 2010 16:35:08 +0200 Subject: [PATCH] Support cross-disk installs. On non-cross-disk retrieve bootpath from chosen/bootpath --- boot/sparc64/ieee1275/boot.S | 16 ++++++++++++++++ include/grub/sparc64/ieee1275/boot.h | 4 ++-- util/sparc64/ieee1275/grub-setup.c | 27 +++++++++++++++++++-------- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/boot/sparc64/ieee1275/boot.S b/boot/sparc64/ieee1275/boot.S index 167406017..4008b1b54 100644 --- a/boot/sparc64/ieee1275/boot.S +++ b/boot/sparc64/ieee1275/boot.S @@ -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. * diff --git a/include/grub/sparc64/ieee1275/boot.h b/include/grub/sparc64/ieee1275/boot.h index e1c1aa675..7b2137664 100644 --- a/include/grub/sparc64/ieee1275/boot.h +++ b/include/grub/sparc64/ieee1275/boot.h @@ -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) diff --git a/util/sparc64/ieee1275/grub-setup.c b/util/sparc64/ieee1275/grub-setup.c index cfd58a08f..97cc89301 100644 --- a/util/sparc64/ieee1275/grub-setup.c +++ b/util/sparc64/ieee1275/grub-setup.c @@ -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);