]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Support cross-disk installs. On non-cross-disk retrieve bootpath from chosen/bootpath
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 18 Apr 2010 14:35:08 +0000 (16:35 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 18 Apr 2010 14:35:08 +0000 (16:35 +0200)
boot/sparc64/ieee1275/boot.S
include/grub/sparc64/ieee1275/boot.h
util/sparc64/ieee1275/grub-setup.c

index 1674060175fbb0dc4acb3504b365dbe07ecaafe2..4008b1b5499de0de9b3cc3a0869a568f7f74b879 100644 (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.
         *
index e1c1aa67590e43e4416bd7f2fb201983649e0d5e..7b2137664711e1e6616125f08778c31244a3d991 100644 (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)
index cfd58a08f9e157e176e743e9b2c823f27613ae29..97cc893019b006dd603c60b1cb97c568512746f4 100644 (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);