All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Millan <rmh@aybabtu.com>
To: grub-devel@gnu.org
Subject: [PATCH] fix endianess in IEEE-1275 integer properties
Date: Sun, 13 Jan 2008 21:30:41 +0100	[thread overview]
Message-ID: <20080113203041.GA25702@thorin> (raw)

[-- Attachment #1: Type: text/plain, Size: 516 bytes --]


Integer properties are always in big endian.  This (incomplete) patch is my
suggested approach to deal with this.  I'd like to receive input about it
before I complete it (checking all calls to grub_ieee1275_get_property
through GRUB and replacing with grub_ieee1275_get_integer_property when
appropiate).

Again, some testing on Apple/IBM/Genesi hardware would be nice.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call, if you are unable to speak?
(as seen on /.)

[-- Attachment #2: ieee1275_endianess.diff --]
[-- Type: text/x-diff, Size: 2781 bytes --]

diff -urp endianess.old/include/grub/ieee1275/ieee1275.h endianess/include/grub/ieee1275/ieee1275.h
--- endianess.old/include/grub/ieee1275/ieee1275.h	2007-07-22 11:05:10.000000000 +0200
+++ endianess/include/grub/ieee1275/ieee1275.h	2008-01-13 21:27:19.000000000 +0100
@@ -97,6 +97,10 @@ int EXPORT_FUNC(grub_ieee1275_get_proper
 					     const char *property, void *buf,
 					     grub_size_t size,
 					     grub_ssize_t *actual);
+int EXPORT_FUNC(grub_ieee1275_get_integer_property) (grub_ieee1275_phandle_t phandle,
+						     const char *property, grub_uint32_t *buf,
+						     grub_size_t size,
+						     grub_ssize_t *actual);
 int EXPORT_FUNC(grub_ieee1275_next_property) (grub_ieee1275_phandle_t phandle,
 					      char *prev_prop, char *prop);
 int EXPORT_FUNC(grub_ieee1275_get_property_length) 
diff -urp endianess.old/kern/ieee1275/ieee1275.c endianess/kern/ieee1275/ieee1275.c
--- endianess.old/kern/ieee1275/ieee1275.c	2007-07-22 01:32:27.000000000 +0200
+++ endianess/kern/ieee1275/ieee1275.c	2008-01-13 21:27:19.000000000 +0100
@@ -18,6 +18,7 @@
  */
 
 #include <grub/ieee1275/ieee1275.h>
+#include <grub/types.h>
 
 #define IEEE1275_PHANDLE_INVALID  ((grub_ieee1275_phandle_t) -1)
 #define IEEE1275_IHANDLE_INVALID  ((grub_ieee1275_ihandle_t) 0)
@@ -89,6 +90,25 @@ grub_ieee1275_get_property (grub_ieee127
 }
 
 int
+grub_ieee1275_get_integer_property (grub_ieee1275_phandle_t phandle,
+				    const char *property, grub_uint32_t *buf,
+				    grub_size_t size, grub_ssize_t *actual)
+{
+  int ret;
+  ret = grub_ieee1275_get_property (phandle, property, (void *) buf, size, actual);
+#ifndef GRUB_CPU_WORDS_BIGENDIAN
+  /* Integer properties are always in big endian.  */
+  {
+    int i;
+    size /= sizeof (grub_uint32_t);
+    for (i = 0; i < size; i++)
+      buf[i] = grub_be_to_cpu32 (buf[i]);
+  }
+#endif
+  return ret;
+}
+
+int
 grub_ieee1275_next_property (grub_ieee1275_phandle_t phandle, char *prev_prop,
 			     char *prop)
 {
diff -urp endianess.old/kern/powerpc/ieee1275/openfw.c endianess/kern/powerpc/ieee1275/openfw.c
--- endianess.old/kern/powerpc/ieee1275/openfw.c	2008-01-13 21:27:09.000000000 +0100
+++ endianess/kern/powerpc/ieee1275/openfw.c	2008-01-13 21:27:19.000000000 +0100
@@ -157,8 +157,8 @@ grub_err_t grub_available_iterate (int (
   if (grub_ieee1275_finddevice ("/memory", &memory))
     return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
 		       "Couldn't find /memory node");
-  if (grub_ieee1275_get_property (memory, "available", available,
-				  sizeof available, &available_size))
+  if (grub_ieee1275_get_integer_property (memory, "available", available,
+					  sizeof available, &available_size))
     return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
 		       "Couldn't examine /memory/available property");
 

             reply	other threads:[~2008-01-13 20:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-13 20:30 Robert Millan [this message]
2008-01-14 14:20 ` [PATCH] fix endianess in IEEE-1275 integer properties Pavel Roskin
2008-01-14 14:27   ` Robert Millan
2008-01-15  4:49     ` Pavel Roskin
2008-01-15 12:12       ` Robert Millan
2008-01-15 12:22         ` Robert Millan
2008-01-15 14:41           ` Pavel Roskin
2008-01-15 16:13             ` Robert Millan
2008-01-15 12:30 ` Marco Gerards
2008-01-15 12:32   ` Robert Millan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080113203041.GA25702@thorin \
    --to=rmh@aybabtu.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.