All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix endianess in IEEE-1275 integer properties
@ 2008-01-13 20:30 Robert Millan
  2008-01-14 14:20 ` Pavel Roskin
  2008-01-15 12:30 ` Marco Gerards
  0 siblings, 2 replies; 10+ messages in thread
From: Robert Millan @ 2008-01-13 20:30 UTC (permalink / raw)
  To: grub-devel

[-- 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");
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] fix endianess in IEEE-1275 integer properties
  2008-01-13 20:30 [PATCH] fix endianess in IEEE-1275 integer properties Robert Millan
@ 2008-01-14 14:20 ` Pavel Roskin
  2008-01-14 14:27   ` Robert Millan
  2008-01-15 12:30 ` Marco Gerards
  1 sibling, 1 reply; 10+ messages in thread
From: Pavel Roskin @ 2008-01-14 14:20 UTC (permalink / raw)
  To: The development of GRUB 2

On Sun, 2008-01-13 at 21:30 +0100, Robert Millan wrote:
> 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.

It doesn't apply cleanly, and I don't see how the result of
grub_ieee1275_get_integer_property() is used.  I suggest that you go
ahead with the changes as long as you get them right for your platform.

-- 
Regards,
Pavel Roskin



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] fix endianess in IEEE-1275 integer properties
  2008-01-14 14:20 ` Pavel Roskin
@ 2008-01-14 14:27   ` Robert Millan
  2008-01-15  4:49     ` Pavel Roskin
  0 siblings, 1 reply; 10+ messages in thread
From: Robert Millan @ 2008-01-14 14:27 UTC (permalink / raw)
  To: The development of GRUB 2

On Mon, Jan 14, 2008 at 09:20:39AM -0500, Pavel Roskin wrote:
> On Sun, 2008-01-13 at 21:30 +0100, Robert Millan wrote:
> > 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.
> 
> It doesn't apply cleanly,

It depends on my previous patch, "restrict parsing of `available'".

> and I don't see how the result of
> grub_ieee1275_get_integer_property() is used.

If something went wrong, you'd most likely see those claim-related errors
you're familiar with ;-)

-- 
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 /.)



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] fix endianess in IEEE-1275 integer properties
  2008-01-14 14:27   ` Robert Millan
@ 2008-01-15  4:49     ` Pavel Roskin
  2008-01-15 12:12       ` Robert Millan
  0 siblings, 1 reply; 10+ messages in thread
From: Pavel Roskin @ 2008-01-15  4:49 UTC (permalink / raw)
  To: The development of GRUB 2, Robert Millan

Quoting Robert Millan <rmh@aybabtu.com>:

>> > Again, some testing on Apple/IBM/Genesi hardware would be nice.
>>
>> It doesn't apply cleanly,
>
> It depends on my previous patch, "restrict parsing of `available'".

Applied both, everything is fine on PowerMac G3.

-- 
Regards,
Pavel Roskin



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] fix endianess in IEEE-1275 integer properties
  2008-01-15  4:49     ` Pavel Roskin
@ 2008-01-15 12:12       ` Robert Millan
  2008-01-15 12:22         ` Robert Millan
  0 siblings, 1 reply; 10+ messages in thread
From: Robert Millan @ 2008-01-15 12:12 UTC (permalink / raw)
  To: The development of GRUB 2

On Mon, Jan 14, 2008 at 11:49:30PM -0500, Pavel Roskin wrote:
> Quoting Robert Millan <rmh@aybabtu.com>:
> 
> >>> Again, some testing on Apple/IBM/Genesi hardware would be nice.
> >>
> >>It doesn't apply cleanly,
> >
> >It depends on my previous patch, "restrict parsing of `available'".
> 
> Applied both, everything is fine on PowerMac G3.

Ok.  Checked in the first one.  I'll complete the second now.

-- 
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 /.)



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] fix endianess in IEEE-1275 integer properties
  2008-01-15 12:12       ` Robert Millan
@ 2008-01-15 12:22         ` Robert Millan
  2008-01-15 14:41           ` Pavel Roskin
  0 siblings, 1 reply; 10+ messages in thread
From: Robert Millan @ 2008-01-15 12:22 UTC (permalink / raw)
  To: The development of GRUB 2

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

On Tue, Jan 15, 2008 at 01:12:57PM +0100, Robert Millan wrote:
> 
> Ok.  Checked in the first one.  I'll complete the second now.

Here.  Please can you test?

-- 
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: integer.diff --]
[-- Type: text/x-diff, Size: 5510 bytes --]


	* include/grub/ieee1275/ieee1275.h
	(grub_ieee1275_get_integer_property): New function prototype.

	* kern/ieee1275/ieee1275.c: Include `<grub/types.h>'.
	(grub_ieee1275_get_integer_property): New function.  Wraps around
	grub_ieee1275_get_property() to handle endianess.

	* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options): Replace
	grub_ieee1275_get_property() with grub_ieee1275_get_integer_property()
	where appropiate.
	* kern/powerpc/ieee1275/openfw.c (grub_available_iterate): Likewise.
	(grub_map): Likewise.
	* kern/sparc64/ieee1275/openfw.c (grub_map): Likewise.

diff -urp grub2/include/grub/ieee1275/ieee1275.h integer/include/grub/ieee1275/ieee1275.h
--- grub2/include/grub/ieee1275/ieee1275.h	2007-07-22 11:05:10.000000000 +0200
+++ integer/include/grub/ieee1275/ieee1275.h	2008-01-15 13:17:27.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 grub2/kern/ieee1275/ieee1275.c integer/kern/ieee1275/ieee1275.c
--- grub2/kern/ieee1275/ieee1275.c	2007-07-22 01:32:27.000000000 +0200
+++ integer/kern/ieee1275/ieee1275.c	2008-01-15 13:17:27.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,26 @@ 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.  */
+  if (ret == 0)
+    {
+      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 grub2/kern/powerpc/ieee1275/cmain.c integer/kern/powerpc/ieee1275/cmain.c
--- grub2/kern/powerpc/ieee1275/cmain.c	2007-12-30 09:52:05.000000000 +0100
+++ integer/kern/powerpc/ieee1275/cmain.c	2008-01-15 13:17:27.000000000 +0100
@@ -56,8 +56,8 @@ grub_ieee1275_find_options (void)
   int is_smartfirmware = 0;
 
   grub_ieee1275_finddevice ("/options", &options);
-  rc = grub_ieee1275_get_property (options, "real-mode?", &realmode,
-				   sizeof realmode, 0);
+  rc = grub_ieee1275_get_integer_property (options, "real-mode?", &realmode,
+					   sizeof realmode, 0);
   if ((rc >= 0) && realmode)
     grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_REAL_MODE);
 
diff -urp grub2/kern/powerpc/ieee1275/openfw.c integer/kern/powerpc/ieee1275/openfw.c
--- grub2/kern/powerpc/ieee1275/openfw.c	2008-01-15 13:13:58.000000000 +0100
+++ integer/kern/powerpc/ieee1275/openfw.c	2008-01-15 13:17:27.000000000 +0100
@@ -148,17 +148,17 @@ grub_err_t grub_available_iterate (int (
 
   /* Determine the format of each entry in `available'.  */
   grub_ieee1275_finddevice ("/", &root);
-  grub_ieee1275_get_property (root, "#address-cells", &address_cells,
-	sizeof address_cells, 0);
-  grub_ieee1275_get_property (root, "#size-cells", &size_cells,
-	sizeof size_cells, 0);
+  grub_ieee1275_get_integer_property (root, "#address-cells", &address_cells,
+				      sizeof address_cells, 0);
+  grub_ieee1275_get_integer_property (root, "#size-cells", &size_cells,
+				      sizeof size_cells, 0);
 
   /* Load `/memory/available'.  */
   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");
 
@@ -203,8 +203,8 @@ grub_map (grub_addr_t phys, grub_addr_t 
   grub_ieee1275_ihandle_t mmu;
   int len;
 
-  grub_ieee1275_get_property (grub_ieee1275_chosen, "mmu", &mmu, sizeof mmu,
-			      &len);
+  grub_ieee1275_get_integer_property (grub_ieee1275_chosen, "mmu", &mmu, sizeof mmu,
+				      &len);
   if (len != sizeof mmu)
     return -1;
 
diff -urp grub2/kern/sparc64/ieee1275/openfw.c integer/kern/sparc64/ieee1275/openfw.c
--- grub2/kern/sparc64/ieee1275/openfw.c	2007-12-30 09:52:05.000000000 +0100
+++ integer/kern/sparc64/ieee1275/openfw.c	2008-01-15 13:17:27.000000000 +0100
@@ -183,8 +183,8 @@ grub_map (grub_addr_t phys, grub_addr_t 
   grub_ieee1275_ihandle_t mmu;
   grub_ssize_t len;
 
-  grub_ieee1275_get_property (grub_ieee1275_chosen, "mmu", &mmu, sizeof mmu,
-			      &len);
+  grub_ieee1275_get_integer_property (grub_ieee1275_chosen, "mmu", &mmu, sizeof mmu,
+				      &len);
   if (len != sizeof mmu)
     return -1;
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] fix endianess in IEEE-1275 integer properties
  2008-01-13 20:30 [PATCH] fix endianess in IEEE-1275 integer properties Robert Millan
  2008-01-14 14:20 ` Pavel Roskin
@ 2008-01-15 12:30 ` Marco Gerards
  2008-01-15 12:32   ` Robert Millan
  1 sibling, 1 reply; 10+ messages in thread
From: Marco Gerards @ 2008-01-15 12:30 UTC (permalink / raw)
  To: The development of GRUB 2

Robert Millan <rmh@aybabtu.com> writes:

> 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).

It looks fine to me.  The Changelog entry is still missing.

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

All my PPC boxes do not like themselves.  One died and the other also
has some problems... :-/

--
Marco




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] fix endianess in IEEE-1275 integer properties
  2008-01-15 12:30 ` Marco Gerards
@ 2008-01-15 12:32   ` Robert Millan
  0 siblings, 0 replies; 10+ messages in thread
From: Robert Millan @ 2008-01-15 12:32 UTC (permalink / raw)
  To: The development of GRUB 2

On Tue, Jan 15, 2008 at 01:30:48PM +0100, Marco Gerards wrote:
> Robert Millan <rmh@aybabtu.com> writes:
> 
> > 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).
> 
> It looks fine to me.  The Changelog entry is still missing.

Check my last mail!

-- 
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 /.)



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] fix endianess in IEEE-1275 integer properties
  2008-01-15 12:22         ` Robert Millan
@ 2008-01-15 14:41           ` Pavel Roskin
  2008-01-15 16:13             ` Robert Millan
  0 siblings, 1 reply; 10+ messages in thread
From: Pavel Roskin @ 2008-01-15 14:41 UTC (permalink / raw)
  To: The development of GRUB 2, Robert Millan

Quoting Robert Millan <rmh@aybabtu.com>:

> On Tue, Jan 15, 2008 at 01:12:57PM +0100, Robert Millan wrote:
>>
>> Ok.  Checked in the first one.  I'll complete the second now.
>
> Here.  Please can you test?

It's working fine for me.  I don't see any difference.

-- 
Regards,
Pavel Roskin



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] fix endianess in IEEE-1275 integer properties
  2008-01-15 14:41           ` Pavel Roskin
@ 2008-01-15 16:13             ` Robert Millan
  0 siblings, 0 replies; 10+ messages in thread
From: Robert Millan @ 2008-01-15 16:13 UTC (permalink / raw)
  To: The development of GRUB 2

On Tue, Jan 15, 2008 at 09:41:19AM -0500, Pavel Roskin wrote:
> Quoting Robert Millan <rmh@aybabtu.com>:
> 
> >On Tue, Jan 15, 2008 at 01:12:57PM +0100, Robert Millan wrote:
> >>
> >>Ok.  Checked in the first one.  I'll complete the second now.
> >
> >Here.  Please can you test?
> 
> It's working fine for me.  I don't see any difference.

Thank you.   Committed now.

-- 
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 /.)



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-01-15 16:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-13 20:30 [PATCH] fix endianess in IEEE-1275 integer properties Robert Millan
2008-01-14 14:20 ` 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

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.