d993d29491
- Build GRUB2 for ppc64le as LittleEndian and 64bit - Fix timeout issue on ppc64le (bnc#869166) - Add powerpc-utils requires to grub2-powerpc-ieee1275 - added patches: * grub2-ppc64-build-ppc64-32bit.patch * grub2-ppc64-qemu.patch * grub2-ppc64le-01-Add-Little-Endian-support-for-Power64-to-the-build.patch * grub2-ppc64le-02-Build-grub-as-O1-until-we-add-savegpr-and-restgpr-ro.patch * grub2-ppc64le-03-disable-creation-of-vsx-and-altivec-instructions.patch * grub2-ppc64le-04-powerpc64-LE-s-linker-knows-how-to-handle-the-undefi.patch * grub2-ppc64le-05-grub-install-can-now-recognize-and-install-a-LE-grub.patch * grub2-ppc64le-06-set-the-ABI-version-to-0x02-in-the-e_flag-of-the-PPC.patch * grub2-ppc64le-07-Add-IEEE1275_ADDR-helper.patch * grub2-ppc64le-08-Fix-some-more-warnings-when-casting.patch * grub2-ppc64le-09-Add-powerpc64-types.patch * grub2-ppc64le-10-powerpc64-is-not-necessarily-BigEndian-anymore.patch * grub2-ppc64le-11-Fix-warnings-when-building-powerpc-linux-loader-64bi.patch * grub2-ppc64le-12-GRUB_ELF_R_PPC_-processing-is-applicable-only-for-32.patch * grub2-ppc64le-13-Fix-powerpc-setjmp-longjmp-64bit-issues.patch * grub2-ppc64le-14-Add-powerpc64-ieee1275-trampoline.patch * grub2-ppc64le-15-Add-64bit-support-to-powerpc-startup-code.patch * grub2-ppc64le-16-Add-grub_dl_find_section_addr.patch * grub2-ppc64le-17-Add-ppc64-relocations.patch * grub2-ppc64le-18-ppc64-doesn-t-need-libgcc-routines.patch * grub2-ppc64le-19-Use-FUNC_START-FUNC_END-for-powerpc-function-definit.patch * grub2-ppc64le-20-.TOC.-symbol-is-special-in-ppc64le-.-It-maps-to-the-.patch * grub2-ppc64le-21-the-.toc-section-in-powerpc64le-modules-are-sometime.patch * grub2-ppc64le-22-all-parameter-to-firmware-calls-should-to-be-BigEndi.patch * grub2-ppc64le-23-grub-segfaults-if-initrd-is-specified-before-specify.patch * grub2-ppc64le-timeout.patch OBS-URL: https://build.opensuse.org/request/show/229655 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=87
705 lines
23 KiB
Diff
705 lines
23 KiB
Diff
From 4d0c5500be3cb776345e417c542d6d1fea1a3314 Mon Sep 17 00:00:00 2001
|
|
From: Ram Pai <linuxram@us.ibm.com>
|
|
Date: Tue, 25 Feb 2014 22:43:25 +0000
|
|
Subject: [PATCH 22/23] fix parameter to firmware calls
|
|
|
|
all parameter to firmware calls should be BigEndian
|
|
and the results should be CPU endian.
|
|
|
|
Signed-off-by: Ram Pai <linuxram@us.ibm.com>
|
|
---
|
|
grub-core/disk/ieee1275/nand.c | 41 +++++-----
|
|
grub-core/disk/ieee1275/ofdisk.c | 22 ++++--
|
|
grub-core/kern/ieee1275/ieee1275.c | 134 +++++++++++++++++++--------------
|
|
grub-core/kern/ieee1275/openfw.c | 19 ++---
|
|
grub-core/lib/ieee1275/datetime.c | 32 ++++----
|
|
grub-core/net/drivers/ieee1275/ofnet.c | 6 +-
|
|
include/grub/ieee1275/ieee1275.h | 8 +-
|
|
7 files changed, 148 insertions(+), 114 deletions(-)
|
|
|
|
diff --git a/grub-core/disk/ieee1275/nand.c b/grub-core/disk/ieee1275/nand.c
|
|
index 576e9cc..1846c23 100644
|
|
--- a/grub-core/disk/ieee1275/nand.c
|
|
+++ b/grub-core/disk/ieee1275/nand.c
|
|
@@ -102,32 +102,33 @@ grub_nand_open (const char *name, grub_disk_t disk)
|
|
data->handle = dev_ihandle;
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 2);
|
|
- args.method = (grub_ieee1275_cell_t) "block-size";
|
|
- args.ihandle = dev_ihandle;
|
|
- args.result = 1;
|
|
+ args.method = IEEE1275_ADDR("block-size");
|
|
+ args.ihandle = IEEE1275_VALUE(dev_ihandle);
|
|
+ args.result = IEEE1275_VALUE(1);
|
|
|
|
- if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
|
|
+ if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || IEEE1275_VALUE(args.result))
|
|
{
|
|
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't get block size");
|
|
goto fail;
|
|
}
|
|
|
|
+ args.size1 = IEEE1275_VALUE(args.size1);
|
|
data->block_size = (args.size1 >> GRUB_DISK_SECTOR_BITS);
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3);
|
|
- args.method = (grub_ieee1275_cell_t) "size";
|
|
- args.ihandle = dev_ihandle;
|
|
- args.result = 1;
|
|
+ args.method = IEEE1275_ADDR( "size");
|
|
+ args.ihandle = IEEE1275_VALUE(dev_ihandle);
|
|
+ args.result = IEEE1275_VALUE(1);
|
|
|
|
- if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
|
|
+ if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || IEEE1275_VALUE(args.result))
|
|
{
|
|
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't get disk size");
|
|
goto fail;
|
|
}
|
|
|
|
- disk->total_sectors = args.size1;
|
|
+ disk->total_sectors = IEEE1275_VALUE(args.size1);
|
|
disk->total_sectors <<= 32;
|
|
- disk->total_sectors += args.size2;
|
|
+ disk->total_sectors += IEEE1275_VALUE(args.size2);
|
|
disk->total_sectors >>= GRUB_DISK_SECTOR_BITS;
|
|
|
|
disk->id = dev_ihandle;
|
|
@@ -170,10 +171,10 @@ grub_nand_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|
} args;
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1);
|
|
- args.method = (grub_ieee1275_cell_t) "pio-read";
|
|
- args.ihandle = data->handle;
|
|
- args.buf = (grub_ieee1275_cell_t) buf;
|
|
- args.page = (grub_ieee1275_cell_t) ((grub_size_t) sector / data->block_size);
|
|
+ args.method = IEEE1275_ADDR("pio-read");
|
|
+ args.ihandle = IEEE1275_VALUE(data->handle);
|
|
+ args.buf = buf;
|
|
+ args.page = (grub_size_t) sector / data->block_size;
|
|
|
|
ofs = ((grub_size_t) sector % data->block_size) << GRUB_DISK_SECTOR_BITS;
|
|
size <<= GRUB_DISK_SECTOR_BITS;
|
|
@@ -185,16 +186,20 @@ grub_nand_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|
|
|
len = (ofs + size > bsize) ? (bsize - ofs) : size;
|
|
|
|
- args.len = (grub_ieee1275_cell_t) len;
|
|
- args.ofs = (grub_ieee1275_cell_t) ofs;
|
|
- args.result = 1;
|
|
+ args.len = IEEE1275_VALUE(len);
|
|
+ args.ofs = IEEE1275_VALUE(ofs);
|
|
+ args.result = IEEE1275_VALUE(1);
|
|
+ args.buf = IEEE1275_ADDR(args.buf);
|
|
+ args.page = IEEE1275_VALUE(args.page);
|
|
|
|
- if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
|
|
+ if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || IEEE1275_VALUE(args.result))
|
|
return grub_error (GRUB_ERR_READ_ERROR, N_("failure reading sector 0x%llx "
|
|
"from `%s'"),
|
|
(unsigned long long) sector,
|
|
disk->name);
|
|
|
|
+ args.buf = IEEE1275_ADDR(args.buf);
|
|
+ args.page = IEEE1275_VALUE(args.page);
|
|
ofs = 0;
|
|
size -= len;
|
|
args.buf += len;
|
|
diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c
|
|
index d785d6a..72b36c5 100644
|
|
--- a/grub-core/disk/ieee1275/ofdisk.c
|
|
+++ b/grub-core/disk/ieee1275/ofdisk.c
|
|
@@ -225,16 +225,19 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3);
|
|
args.method = IEEE1275_ADDR("vscsi-report-luns");
|
|
- args.ihandle = ihandle;
|
|
- args.table = 0;
|
|
- args.nentries = 0;
|
|
+ args.ihandle = IEEE1275_VALUE(ihandle);
|
|
+ args.table = IEEE1275_ADDR(0);
|
|
+ args.nentries = IEEE1275_VALUE(0);
|
|
|
|
- if (IEEE1275_CALL_ENTRY_FN (&args) == -1 || args.catch_result)
|
|
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1 || IEEE1275_VALUE(args.catch_result))
|
|
{
|
|
grub_ieee1275_close (ihandle);
|
|
return;
|
|
}
|
|
|
|
+ args.table = IEEE1275_ADDR(args.table);
|
|
+ args.nentries = IEEE1275_VALUE(args.nentries);
|
|
+
|
|
buf = grub_malloc (grub_strlen (alias->path) + 32);
|
|
if (!buf)
|
|
return;
|
|
@@ -245,6 +248,7 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
|
|
grub_uint64_t *ptr;
|
|
|
|
ptr = *(grub_uint64_t **) ((grub_addr_t)args.table + 4 + 8 * i);
|
|
+ ptr = (grub_uint64_t *) (grub_addr_t) IEEE1275_ADDR(ptr);
|
|
while (*ptr)
|
|
{
|
|
grub_snprintf (bufptr, 32, "/disk@%" PRIxGRUB_UINT64_T, *ptr++);
|
|
@@ -614,18 +618,20 @@ grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size)
|
|
|
|
INIT_IEEE1275_COMMON (&args_ieee1275.common, "call-method", 2, 2);
|
|
args_ieee1275.method = IEEE1275_ADDR("block-size");
|
|
- args_ieee1275.ihandle = last_ihandle;
|
|
- args_ieee1275.result = 1;
|
|
+ args_ieee1275.ihandle = IEEE1275_VALUE(last_ihandle);
|
|
+ args_ieee1275.result = IEEE1275_VALUE(1);
|
|
|
|
*block_size = GRUB_DISK_SECTOR_SIZE;
|
|
|
|
- if ((IEEE1275_CALL_ENTRY_FN (&args_ieee1275) == -1) || (args_ieee1275.result))
|
|
+ if ((IEEE1275_CALL_ENTRY_FN (&args_ieee1275) == -1) || IEEE1275_VALUE(args_ieee1275.result))
|
|
grub_dprintf ("disk", "can't get block size\n");
|
|
- else
|
|
+ else {
|
|
+ args_ieee1275.size1 = IEEE1275_VALUE(args_ieee1275.size1);
|
|
if (args_ieee1275.size1
|
|
&& !(args_ieee1275.size1 & (args_ieee1275.size1 - 1))
|
|
&& args_ieee1275.size1 >= 512 && args_ieee1275.size1 <= 16384)
|
|
*block_size = args_ieee1275.size1;
|
|
+ }
|
|
|
|
return 0;
|
|
}
|
|
diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c
|
|
index f933c89..df8943c 100644
|
|
--- a/grub-core/kern/ieee1275/ieee1275.c
|
|
+++ b/grub-core/kern/ieee1275/ieee1275.c
|
|
@@ -42,7 +42,7 @@ grub_ieee1275_finddevice (const char *name, grub_ieee1275_phandle_t *phandlep)
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
- *phandlep = args.phandle;
|
|
+ *phandlep = args.phandle = IEEE1275_VALUE(args.phandle);
|
|
if (args.phandle == IEEE1275_PHANDLE_INVALID)
|
|
return -1;
|
|
return 0;
|
|
@@ -65,13 +65,15 @@ grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle,
|
|
args;
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "getprop", 4, 1);
|
|
- args.phandle = phandle;
|
|
+ args.phandle = IEEE1275_VALUE(phandle);
|
|
args.prop = IEEE1275_ADDR(property);
|
|
args.buf = IEEE1275_ADDR(buf);
|
|
- args.buflen = (grub_ieee1275_cell_t) size;
|
|
+ args.buflen = IEEE1275_VALUE(size);
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
+
|
|
+ args.size = IEEE1275_VALUE(args.size);
|
|
if (actual)
|
|
*actual = (grub_ssize_t) args.size;
|
|
if (args.size == IEEE1275_CELL_INVALID)
|
|
@@ -79,6 +81,18 @@ grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle,
|
|
return 0;
|
|
}
|
|
|
|
+#ifdef __powerpc64le__
|
|
+static void
|
|
+grub_swap_bytes(grub_uint32_t *buf, grub_size_t len)
|
|
+{
|
|
+ /* Integer properties are always in big endian. */
|
|
+ unsigned int i;
|
|
+ len /= sizeof (grub_uint32_t);
|
|
+ for (i = 0; i < len; i++)
|
|
+ buf[i] = IEEE1275_VALUE(buf[i]);
|
|
+}
|
|
+#endif
|
|
+
|
|
int
|
|
grub_ieee1275_get_integer_property (grub_ieee1275_phandle_t phandle,
|
|
const char *property, grub_uint32_t *buf,
|
|
@@ -86,16 +100,13 @@ grub_ieee1275_get_integer_property (grub_ieee1275_phandle_t phandle,
|
|
{
|
|
int ret;
|
|
ret = grub_ieee1275_get_property (phandle, property, (void *) buf, size, actual);
|
|
-#ifndef GRUB_CPU_WORDS_BIGENDIAN
|
|
+
|
|
+#ifdef __powerpc64le__
|
|
/* Integer properties are always in big endian. */
|
|
if (ret == 0)
|
|
- {
|
|
- unsigned int i;
|
|
- size /= sizeof (grub_uint32_t);
|
|
- for (i = 0; i < size; i++)
|
|
- buf[i] = grub_be_to_cpu32 (buf[i]);
|
|
- }
|
|
+ grub_swap_bytes(buf, size);
|
|
#endif
|
|
+
|
|
return ret;
|
|
}
|
|
|
|
@@ -114,14 +125,14 @@ grub_ieee1275_next_property (grub_ieee1275_phandle_t phandle, char *prev_prop,
|
|
args;
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "nextprop", 3, 1);
|
|
- args.phandle = phandle;
|
|
+ args.phandle = IEEE1275_VALUE(phandle);
|
|
args.prev_prop = IEEE1275_ADDR(prev_prop);
|
|
args.next_prop = IEEE1275_ADDR(prop);
|
|
- args.flags = (grub_ieee1275_cell_t) -1;
|
|
+ args.flags = IEEE1275_VALUE(-1);
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
- return (int) args.flags;
|
|
+ return (int) IEEE1275_VALUE(args.flags);
|
|
}
|
|
|
|
int
|
|
@@ -138,13 +149,13 @@ grub_ieee1275_get_property_length (grub_ieee1275_phandle_t phandle,
|
|
args;
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "getproplen", 2, 1);
|
|
- args.phandle = phandle;
|
|
+ args.phandle = IEEE1275_VALUE(phandle);
|
|
args.prop = IEEE1275_ADDR(prop);
|
|
- args.length = (grub_ieee1275_cell_t) -1;
|
|
+ args.length = IEEE1275_VALUE(-1);
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
- *length = args.length;
|
|
+ *length = args.length = IEEE1275_VALUE(args.length);
|
|
if (args.length == IEEE1275_CELL_INVALID)
|
|
return -1;
|
|
return 0;
|
|
@@ -163,11 +174,11 @@ grub_ieee1275_instance_to_package (grub_ieee1275_ihandle_t ihandle,
|
|
args;
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "instance-to-package", 1, 1);
|
|
- args.ihandle = ihandle;
|
|
+ args.ihandle = IEEE1275_VALUE(ihandle);
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
- *phandlep = args.phandle;
|
|
+ *phandlep = args.phandle = IEEE1275_VALUE(args.phandle);
|
|
if (args.phandle == IEEE1275_PHANDLE_INVALID)
|
|
return -1;
|
|
return 0;
|
|
@@ -189,12 +200,14 @@ grub_ieee1275_package_to_path (grub_ieee1275_phandle_t phandle,
|
|
args;
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "package-to-path", 3, 1);
|
|
- args.phandle = phandle;
|
|
+ args.phandle = IEEE1275_VALUE(phandle);
|
|
args.buf = IEEE1275_ADDR(path);
|
|
- args.buflen = (grub_ieee1275_cell_t) len;
|
|
+ args.buflen = IEEE1275_VALUE(len);
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
+
|
|
+ args.actual = IEEE1275_VALUE(args.actual);
|
|
if (actual)
|
|
*actual = args.actual;
|
|
if (args.actual == IEEE1275_CELL_INVALID)
|
|
@@ -218,12 +231,14 @@ grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle,
|
|
args;
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "instance-to-path", 3, 1);
|
|
- args.ihandle = ihandle;
|
|
+ args.ihandle = IEEE1275_VALUE(ihandle);
|
|
args.buf = IEEE1275_ADDR(path);
|
|
- args.buflen = (grub_ieee1275_cell_t) len;
|
|
+ args.buflen = IEEE1275_VALUE(len);
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
+
|
|
+ args.actual = IEEE1275_VALUE(args.actual);
|
|
if (actual)
|
|
*actual = args.actual;
|
|
if (args.actual == IEEE1275_CELL_INVALID)
|
|
@@ -231,6 +246,7 @@ grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle,
|
|
return 0;
|
|
}
|
|
|
|
+
|
|
int
|
|
grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, const void *buffer,
|
|
grub_size_t len, grub_ssize_t *actualp)
|
|
@@ -246,12 +262,13 @@ grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, const void *buffer,
|
|
args;
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "write", 3, 1);
|
|
- args.ihandle = ihandle;
|
|
+ args.ihandle = IEEE1275_VALUE(ihandle);
|
|
args.buf = IEEE1275_ADDR(buffer);
|
|
- args.len = (grub_ieee1275_cell_t) len;
|
|
+ args.len = IEEE1275_VALUE(len);
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
+ args.actual = IEEE1275_VALUE(args.actual);
|
|
if (actualp)
|
|
*actualp = args.actual;
|
|
return 0;
|
|
@@ -272,14 +289,16 @@ grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer,
|
|
args;
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "read", 3, 1);
|
|
- args.ihandle = ihandle;
|
|
+ args.ihandle = IEEE1275_VALUE(ihandle);
|
|
args.buf = IEEE1275_ADDR(buffer);
|
|
- args.len = (grub_ieee1275_cell_t) len;
|
|
+ args.len = IEEE1275_VALUE(len);
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
+ args.actual = IEEE1275_VALUE(args.actual);
|
|
if (actualp)
|
|
*actualp = args.actual;
|
|
+
|
|
return 0;
|
|
}
|
|
|
|
@@ -298,20 +317,20 @@ grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, grub_disk_addr_t pos,
|
|
args;
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "seek", 3, 1);
|
|
- args.ihandle = ihandle;
|
|
+ args.ihandle = IEEE1275_VALUE(ihandle);
|
|
/* To prevent stupid gcc warning. */
|
|
#if GRUB_IEEE1275_CELL_SIZEOF >= 8
|
|
args.pos_hi = 0;
|
|
- args.pos_lo = pos;
|
|
+ args.pos_lo = IEEE1275_VALUE(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));
|
|
+ args.pos_hi = IEEE1275_VALUE((pos >> (8 * GRUB_IEEE1275_CELL_SIZEOF)));
|
|
+ args.pos_lo = IEEE1275_VALUE((pos & ((1ULL << (8 * GRUB_IEEE1275_CELL_SIZEOF)) - 1)));
|
|
#endif
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
|
|
+ args.result = IEEE1275_VALUE(args.result);
|
|
if (result)
|
|
*result = args.result;
|
|
return 0;
|
|
@@ -330,11 +349,11 @@ grub_ieee1275_peer (grub_ieee1275_phandle_t node,
|
|
args;
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "peer", 1, 1);
|
|
- args.node = node;
|
|
+ args.node = IEEE1275_VALUE(node);
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
- *result = args.result;
|
|
+ *result = args.result = IEEE1275_VALUE(args.result);
|
|
if (args.result == 0)
|
|
return -1;
|
|
return 0;
|
|
@@ -353,12 +372,12 @@ grub_ieee1275_child (grub_ieee1275_phandle_t node,
|
|
args;
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "child", 1, 1);
|
|
- args.node = node;
|
|
- args.result = IEEE1275_PHANDLE_INVALID;
|
|
+ args.node = IEEE1275_VALUE(node);
|
|
+ args.result = IEEE1275_VALUE(IEEE1275_PHANDLE_INVALID);
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
- *result = args.result;
|
|
+ *result = args.result = IEEE1275_VALUE(args.result);
|
|
if (args.result == 0)
|
|
return -1;
|
|
return 0;
|
|
@@ -377,12 +396,12 @@ grub_ieee1275_parent (grub_ieee1275_phandle_t node,
|
|
args;
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "parent", 1, 1);
|
|
- args.node = node;
|
|
- args.result = IEEE1275_PHANDLE_INVALID;
|
|
+ args.node = IEEE1275_VALUE(node);
|
|
+ args.result = IEEE1275_VALUE(IEEE1275_PHANDLE_INVALID);
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
- *result = args.result;
|
|
+ *result = IEEE1275_VALUE(args.result);
|
|
return 0;
|
|
}
|
|
|
|
@@ -405,6 +424,7 @@ grub_ieee1275_interpret (const char *command, grub_ieee1275_cell_t *catch)
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
+ args.catch = IEEE1275_VALUE(args.catch);
|
|
if (catch)
|
|
*catch = args.catch;
|
|
return 0;
|
|
@@ -457,7 +477,7 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
- *result = args.result;
|
|
+ *result = args.result = IEEE1275_VALUE(args.result);
|
|
if (args.result == IEEE1275_IHANDLE_INVALID)
|
|
return -1;
|
|
return 0;
|
|
@@ -474,7 +494,7 @@ grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle)
|
|
args;
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "close", 1, 0);
|
|
- args.ihandle = ihandle;
|
|
+ args.ihandle = IEEE1275_VALUE(ihandle);
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
@@ -497,12 +517,14 @@ grub_ieee1275_claim (grub_addr_t addr, grub_size_t size, unsigned int align,
|
|
args;
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "claim", 3, 1);
|
|
- args.addr = (grub_ieee1275_cell_t) addr;
|
|
- args.size = (grub_ieee1275_cell_t) size;
|
|
- args.align = (grub_ieee1275_cell_t) align;
|
|
+ args.addr = IEEE1275_VALUE(addr);
|
|
+ args.size = IEEE1275_VALUE(size);
|
|
+ args.align = IEEE1275_VALUE(align);
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
+
|
|
+ args.base = IEEE1275_VALUE(args.base);
|
|
if (result)
|
|
*result = args.base;
|
|
if (args.base == IEEE1275_CELL_INVALID)
|
|
@@ -522,8 +544,8 @@ grub_ieee1275_release (grub_addr_t addr, grub_size_t size)
|
|
args;
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "release", 2, 0);
|
|
- args.addr = addr;
|
|
- args.size = size;
|
|
+ args.addr = IEEE1275_VALUE(addr);
|
|
+ args.size = IEEE1275_VALUE(size);
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
@@ -547,14 +569,14 @@ grub_ieee1275_set_property (grub_ieee1275_phandle_t phandle,
|
|
args;
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "setprop", 4, 1);
|
|
- args.size = (grub_ieee1275_cell_t) size;
|
|
+ args.size = IEEE1275_VALUE(size);
|
|
args.buf = IEEE1275_ADDR(buf);
|
|
args.propname = IEEE1275_ADDR(propname);
|
|
- args.phandle = (grub_ieee1275_cell_t) phandle;
|
|
+ args.phandle = IEEE1275_VALUE(phandle);
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
- *actual = args.actual;
|
|
+ *actual = args.actual = IEEE1275_VALUE(args.actual);
|
|
if ((args.actual == IEEE1275_CELL_INVALID) || (args.actual != args.size))
|
|
return -1;
|
|
return 0;
|
|
@@ -579,15 +601,15 @@ grub_ieee1275_set_color (grub_ieee1275_ihandle_t ihandle,
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1);
|
|
args.method = IEEE1275_ADDR("color!");
|
|
- args.ihandle = ihandle;
|
|
- args.index = index;
|
|
- args.r = r;
|
|
- args.g = g;
|
|
- args.b = b;
|
|
+ args.ihandle = IEEE1275_VALUE(ihandle);
|
|
+ args.index = IEEE1275_VALUE(index);
|
|
+ args.r = IEEE1275_VALUE(r);
|
|
+ args.g = IEEE1275_VALUE(g);
|
|
+ args.b = IEEE1275_VALUE(b);
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
- return args.catch_result;
|
|
+ return IEEE1275_VALUE(args.catch_result);
|
|
}
|
|
|
|
int
|
|
@@ -604,6 +626,6 @@ grub_ieee1275_milliseconds (grub_uint32_t *msecs)
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
- *msecs = args.msecs;
|
|
+ *msecs = IEEE1275_VALUE(args.msecs);
|
|
return 0;
|
|
}
|
|
diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c
|
|
index a8bbc71..ced8e3f 100644
|
|
--- a/grub-core/kern/ieee1275/openfw.c
|
|
+++ b/grub-core/kern/ieee1275/openfw.c
|
|
@@ -286,20 +286,20 @@ grub_ieee1275_map (grub_addr_t phys, grub_addr_t virt, grub_size_t size,
|
|
#endif
|
|
1);
|
|
args.method = IEEE1275_ADDR("map");
|
|
- args.ihandle = grub_ieee1275_mmu;
|
|
+ args.ihandle = IEEE1275_VALUE(grub_ieee1275_mmu);
|
|
#ifdef __sparc__
|
|
args.phys_high = 0;
|
|
#endif
|
|
- args.phys_low = phys;
|
|
- args.virt = virt;
|
|
- args.size = size;
|
|
- args.mode = mode; /* Format is WIMG0PP. */
|
|
- args.catch_result = (grub_ieee1275_cell_t) -1;
|
|
+ args.phys_low = IEEE1275_ADDR(phys);
|
|
+ args.virt = IEEE1275_ADDR(virt);
|
|
+ args.size = IEEE1275_VALUE(size);
|
|
+ args.mode = IEEE1275_VALUE(mode); /* Format is WIMG0PP. */
|
|
+ args.catch_result = IEEE1275_VALUE((grub_ieee1275_cell_t) -1);
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return -1;
|
|
|
|
- return args.catch_result;
|
|
+ return IEEE1275_VALUE(args.catch_result);
|
|
}
|
|
|
|
grub_err_t
|
|
@@ -545,10 +545,12 @@ grub_ieee1275_canonicalise_devname (const char *path)
|
|
INIT_IEEE1275_COMMON (&args.common, "canon", 3, 1);
|
|
args.path = IEEE1275_ADDR(path);
|
|
args.buf = IEEE1275_ADDR(buf);
|
|
- args.inlen = (grub_ieee1275_cell_t) (bufsize - 1);
|
|
+ args.inlen = IEEE1275_VALUE(bufsize - 1);
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
return 0;
|
|
+
|
|
+ args.outlen = IEEE1275_VALUE(args.outlen);
|
|
if (args.outlen > bufsize - 1)
|
|
{
|
|
bufsize = args.outlen + 2;
|
|
@@ -560,4 +562,3 @@ grub_ieee1275_canonicalise_devname (const char *path)
|
|
grub_free (buf);
|
|
return NULL;
|
|
}
|
|
-
|
|
diff --git a/grub-core/lib/ieee1275/datetime.c b/grub-core/lib/ieee1275/datetime.c
|
|
index fa0d3b6..7ee1ae2 100644
|
|
--- a/grub-core/lib/ieee1275/datetime.c
|
|
+++ b/grub-core/lib/ieee1275/datetime.c
|
|
@@ -83,22 +83,22 @@ grub_get_datetime (struct grub_datetime *datetime)
|
|
return grub_error (GRUB_ERR_IO, "couldn't open RTC");
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 7);
|
|
- args.device = (grub_ieee1275_cell_t) ihandle;
|
|
+ args.device = IEEE1275_VALUE((grub_ieee1275_cell_t) ihandle);
|
|
args.method = IEEE1275_ADDR("get-time");
|
|
|
|
status = IEEE1275_CALL_ENTRY_FN (&args);
|
|
|
|
grub_ieee1275_close (ihandle);
|
|
|
|
- if (status == -1 || args.catch_result)
|
|
+ if (status == -1 || IEEE1275_VALUE(args.catch_result))
|
|
return grub_error (GRUB_ERR_IO, "get-time failed");
|
|
|
|
- datetime->year = args.year;
|
|
- datetime->month = args.month;
|
|
- datetime->day = args.day;
|
|
- datetime->hour = args.hour;
|
|
- datetime->minute = args.minute;
|
|
- datetime->second = args.second;
|
|
+ datetime->year = IEEE1275_VALUE(args.year);
|
|
+ datetime->month = IEEE1275_VALUE(args.month);
|
|
+ datetime->day = IEEE1275_VALUE(args.day);
|
|
+ datetime->hour = IEEE1275_VALUE(args.hour);
|
|
+ datetime->minute = IEEE1275_VALUE(args.minute);
|
|
+ datetime->second = IEEE1275_VALUE(args.second);
|
|
|
|
return GRUB_ERR_NONE;
|
|
}
|
|
@@ -135,21 +135,21 @@ grub_set_datetime (struct grub_datetime *datetime)
|
|
return grub_error (GRUB_ERR_IO, "couldn't open RTC");
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "call-method", 8, 1);
|
|
- args.device = (grub_ieee1275_cell_t) ihandle;
|
|
+ args.device = IEEE1275_VALUE(ihandle);
|
|
args.method = IEEE1275_ADDR("set-time");
|
|
|
|
- args.year = datetime->year;
|
|
- args.month = datetime->month;
|
|
- args.day = datetime->day;
|
|
- args.hour = datetime->hour;
|
|
- args.minute = datetime->minute;
|
|
- args.second = datetime->second;
|
|
+ args.year = IEEE1275_VALUE(datetime->year);
|
|
+ args.month = IEEE1275_VALUE(datetime->month);
|
|
+ args.day = IEEE1275_VALUE(datetime->day);
|
|
+ args.hour = IEEE1275_VALUE(datetime->hour);
|
|
+ args.minute = IEEE1275_VALUE(datetime->minute);
|
|
+ args.second = IEEE1275_VALUE(datetime->second);
|
|
|
|
status = IEEE1275_CALL_ENTRY_FN (&args);
|
|
|
|
grub_ieee1275_close (ihandle);
|
|
|
|
- if (status == -1 || args.catch_result)
|
|
+ if (status == -1 || IEEE1275_VALUE(args.catch_result))
|
|
return grub_error (GRUB_ERR_IO, "set-time failed");
|
|
|
|
return GRUB_ERR_NONE;
|
|
diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c
|
|
index 07c8446..01dfe85 100644
|
|
--- a/grub-core/net/drivers/ieee1275/ofnet.c
|
|
+++ b/grub-core/net/drivers/ieee1275/ofnet.c
|
|
@@ -385,17 +385,17 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
|
|
}
|
|
args;
|
|
INIT_IEEE1275_COMMON (&args.common, "interpret", 2, 2);
|
|
- args.len = card->txbufsize;
|
|
+ args.len = IEEE1275_VALUE(card->txbufsize);
|
|
args.method = IEEE1275_ADDR("alloc-mem");
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1
|
|
- || args.catch)
|
|
+ || IEEE1275_VALUE(args.catch))
|
|
{
|
|
card->txbuf = 0;
|
|
grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
|
|
}
|
|
else
|
|
- card->txbuf = (void *) (grub_addr_t) args.result;
|
|
+ card->txbuf = (void *) (grub_addr_t) IEEE1275_VALUE(args.result);
|
|
}
|
|
else
|
|
card->txbuf = grub_zalloc (card->txbufsize);
|
|
diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h
|
|
index 2e5270c..be0c235 100644
|
|
--- a/include/grub/ieee1275/ieee1275.h
|
|
+++ b/include/grub/ieee1275/ieee1275.h
|
|
@@ -49,12 +49,12 @@ struct grub_ieee1275_common_hdr
|
|
grub_ieee1275_cell_t nr_outs;
|
|
};
|
|
|
|
-#define IEEE1275_ADDR(x) (grub_uint32_t)(grub_addr_t)(x)
|
|
-
|
|
+#define IEEE1275_ADDR(x) (grub_uint32_t)grub_cpu_to_be32((grub_addr_t)(x))
|
|
+#define IEEE1275_VALUE(x) (grub_uint32_t)grub_cpu_to_be32(x)
|
|
#define INIT_IEEE1275_COMMON(p, xname, xins, xouts) \
|
|
(p)->name = (grub_ieee1275_cell_t) IEEE1275_ADDR(xname); \
|
|
- (p)->nr_ins = (grub_ieee1275_cell_t) xins; \
|
|
- (p)->nr_outs = (grub_ieee1275_cell_t) xouts
|
|
+ (p)->nr_ins = (grub_ieee1275_cell_t) IEEE1275_VALUE(xins); \
|
|
+ (p)->nr_outs = (grub_ieee1275_cell_t) IEEE1275_VALUE(xouts)
|
|
|
|
typedef grub_uint32_t grub_ieee1275_ihandle_t;
|
|
typedef grub_uint32_t grub_ieee1275_phandle_t;
|
|
--
|
|
1.8.3.1
|