]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2010-02-13 Vladimir Serbinenko <phcoder@gmail.com>
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 13 Feb 2010 15:13:28 +0000 (16:13 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 13 Feb 2010 15:13:28 +0000 (16:13 +0100)
Fix over-4GiB seek on sparc64.

* include/grub/ieee1275/ieee1275.h (grub_ieee1275_seek):
Replace pos_i and pos_lo with pos. All users updated.
* include/grub/powerpc/ieee1275/ieee1275.h (GRUB_IEEE1275_CELL_SIZEOF):
New constant.
* include/grub/sparc64/ieee1275/ieee1275.h (GRUB_IEEE1275_CELL_SIZEOF):
Likewise.
* kern/ieee1275/ieee1275.c (grub_ieee1275_seek): Split pos into pos_hi
and pos_lo.

ChangeLog
disk/ieee1275/ofdisk.c
include/grub/ieee1275/ieee1275.h
include/grub/powerpc/ieee1275/ieee1275.h
include/grub/sparc64/ieee1275/ieee1275.h
kern/ieee1275/ieee1275.c

index 760ac720c7c81c3fa30c54be9a6df5d82d1858d5..6f1820d5ea9703b49b3b457704fb9125b7c70210 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2010-02-13  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Fix over-4GiB seek on sparc64.
+
+       * include/grub/ieee1275/ieee1275.h (grub_ieee1275_seek):
+       Replace pos_i and pos_lo with pos. All users updated.
+       * include/grub/powerpc/ieee1275/ieee1275.h (GRUB_IEEE1275_CELL_SIZEOF):
+       New constant.
+       * include/grub/sparc64/ieee1275/ieee1275.h (GRUB_IEEE1275_CELL_SIZEOF):
+       Likewise.
+       * kern/ieee1275/ieee1275.c (grub_ieee1275_seek): Split pos into pos_hi
+       and pos_lo.
+
 2010-02-13  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * util/grub-mkrawimage.c (main): Call set_program_name.
index 238cff33dc3dceb746ffd6c0a63ab375196cfa75..0adedf33f8f394c2529e75645ca99d13c9257ffa 100644 (file)
@@ -241,7 +241,7 @@ grub_ofdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
   pos = sector * 512UL;
 
   grub_ieee1275_seek ((grub_ieee1275_ihandle_t) (unsigned long) disk->data,
-                     (int) (pos >> 32), (int) pos & 0xFFFFFFFFUL, &status);
+                     pos, &status);
   if (status < 0)
     return grub_error (GRUB_ERR_READ_ERROR,
                       "seek error, can't seek block %llu",
index 8b31e32e292c0461b0c5be9242db4bace04e791f..a852a7b614d7b8c98e14ba8e4665afb91dcbb6a8 100644 (file)
@@ -138,7 +138,7 @@ int EXPORT_FUNC(grub_ieee1275_read) (grub_ieee1275_ihandle_t ihandle,
                                     void *buffer, grub_size_t len,
                                     grub_ssize_t *actualp);
 int EXPORT_FUNC(grub_ieee1275_seek) (grub_ieee1275_ihandle_t ihandle,
-                                    int pos_hi, int pos_lo,
+                                    grub_disk_addr_t pos,
                                     grub_ssize_t *result);
 int EXPORT_FUNC(grub_ieee1275_peer) (grub_ieee1275_phandle_t node,
                                     grub_ieee1275_phandle_t *result);
index 7e93055c9c46ed8abea42aa51f46ec47c842043b..3c7683fad2af94bf79e6f2db3273bd2451bcb9f5 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <grub/types.h>
 
+#define GRUB_IEEE1275_CELL_SIZEOF 4
 typedef grub_uint32_t grub_ieee1275_cell_t;
 
 #endif /* ! GRUB_IEEE1275_MACHINE_HEADER */
index b25e98a6d34270b0567b7a6176a614b04ef2dc29..1619510fb0ddfa710ed2e264df09cee2efc1ee8b 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <grub/types.h>
 
+#define GRUB_IEEE1275_CELL_SIZEOF 8
 typedef grub_uint64_t grub_ieee1275_cell_t;
 
 /* Encoding of 'mode' argument to grub_ieee1275_map_physical() */
index 8a5773c235b066550d98eba1ee49e416464d42df..9e29191723c3bd788186199e36e0fe6597ed5f73 100644 (file)
@@ -284,8 +284,8 @@ grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer,
 }
 
 int
-grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, int pos_hi,
-                   int pos_lo, grub_ssize_t *result)
+grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, grub_disk_addr_t pos,
+                   grub_ssize_t *result)
 {
   struct write_args
   {
@@ -299,8 +299,15 @@ grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, int pos_hi,
 
   INIT_IEEE1275_COMMON (&args.common, "seek", 3, 1);
   args.ihandle = ihandle;
-  args.pos_hi = (grub_ieee1275_cell_t) pos_hi;
-  args.pos_lo = (grub_ieee1275_cell_t) pos_lo;
+  /* To prevent stupid gcc warning.  */
+#if GRUB_IEEE1275_CELL_SIZEOF >= 8
+  args.pos_hi = 0;
+  args.pos_lo = pos;
+#else
+  args.pos_hi = (grub_ieee1275_cell_t) (pos >> (8 * GRUB_IEEE1275_CELL_SIZEOF));
+  args.pos_lo = (grub_ieee1275_cell_t) 
+    (pos & ((1ULL << (8 * GRUB_IEEE1275_CELL_SIZEOF)) - 1));
+#endif
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;