From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JE9VS-0004mG-P1 for mharc-grub-devel@gnu.org; Sun, 13 Jan 2008 15:32:34 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JE9VQ-0004kG-5a for grub-devel@gnu.org; Sun, 13 Jan 2008 15:32:32 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JE9VO-0004jx-Oz for grub-devel@gnu.org; Sun, 13 Jan 2008 15:32:30 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JE9VO-0004ju-JB for grub-devel@gnu.org; Sun, 13 Jan 2008 15:32:30 -0500 Received: from aybabtu.com ([69.60.117.155]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JE9VO-0005nO-5b for grub-devel@gnu.org; Sun, 13 Jan 2008 15:32:30 -0500 Received: from [192.168.10.6] (helo=thorin) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1JE9VK-0006uQ-Dk for grub-devel@gnu.org; Sun, 13 Jan 2008 21:32:29 +0100 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1JE9Td-0006he-4a for grub-devel@gnu.org; Sun, 13 Jan 2008 21:30:41 +0100 Date: Sun, 13 Jan 2008 21:30:41 +0100 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20080113203041.GA25702@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Nq2Wo0NMKNjxTN9z" Content-Disposition: inline Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.13 (2006-08-11) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [PATCH] fix endianess in IEEE-1275 integer properties X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Jan 2008 20:32:32 -0000 --Nq2Wo0NMKNjxTN9z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 I know my rights; I want my phone call! What use is a phone call, if you are unable to speak? (as seen on /.) --Nq2Wo0NMKNjxTN9z Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="ieee1275_endianess.diff" 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 +#include #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"); --Nq2Wo0NMKNjxTN9z--