Skip to contentSkip to conversation

: grub: Fix ieee1275 call block typing.

PATCH In review David Miller 2 participants 4 messages Apr 8, 2009 – Apr 9, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : grub: Fix ieee1275 call block typing.

This fixes the use of various fundamental types involved in ieee1275 calls.

In ieee1275, the array of arguments and return values passed to the ieee1275 call handler is defined as an array of "cells". No ifs, ands, or buts. They are all cells and must be of the size of a cell for a given platform.

On powerpc the cell is currently 32-bits. Since this matches the type of phandles and ihandles, the type usage ends up being arbitrary and things just work.

But on sparc64 a cell is 64-bits, whereas the phandles and ihandles are still 32-bits. So it becomes important to get the types right.

This patch does two things:

1) Make all ieee1275 calls use grub_ieee1275_cell_t consistently in all arg declarations.

2) Makes grub_ieee1275_ihandle_t and grub_ieee1275_phandle_t defined as 32-bit integers.

With this the ieee1275 calls will work on both powerpc and sparc64.

2009-04-07 David S. Miller <[email protected]>

	* disk/ieee1275/nand.c (grub_nand_open): All ieee1275 call arg
	slots are of type grub_ieee1275_cell_t.
	(grub_nand_read): Likewise.
	* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_INVALID,
	IEEE1275_IHANDLE_INVALID): Use grub_ieee1275_cell_t since these
	macros are used to compare values in arg/ret block of the call.
	(grub_ieee1275_finddevice, grub_ieee1275_get_property,
	grub_ieee1275_next_property, grub_ieee1275_get_property_length,
	grub_ieee1275_instance_to_package, grub_ieee1275_package_to_path,
	grub_ieee1275_instance_to_path, grub_ieee1275_write,
	grub_ieee1275_read, grub_ieee1275_seek, grub_ieee1275_peer,
	grub_ieee1275_child, grub_ieee1275_parent, grub_ieee1275_open,
	grub_ieee1275_close, grub_ieee1275_set_property,
	grub_ieee1275_set_color): All ieee1275 call arg slots are of type
	grub_ieee1275_cell_t.
	* kern/ieee1275/openfw.c (grub_map): Likewise.
	* include/grub/ieee1275/ieee1275.h (grub_ieee1275_ihandle_t,
	grub_ieee1275_phandle_t): Define as grub_unit32_t type.
---
 disk/ieee1275/nand.c             |   14 +++++-----
 include/grub/ieee1275/ieee1275.h |    4 +-
 kern/ieee1275/ieee1275.c         |   50 +++++++++++++++++++-------------------
 kern/ieee1275/openfw.c           |   16 ++++++------
 4 files changed, 42 insertions(+), 42 deletions(-)
disk/ieee1275/nand.c +7 -7
index ba79faa..ed50768 100644
@@ -60,8 +60,8 @@ grub_nand_open (const char *name, grub_disk_t disk)
   struct size_args
     {
       struct grub_ieee1275_common_hdr common;
-      char *method;
-      grub_ieee1275_ihandle_t ihandle;
+      grub_ieee1275_cell_t method;
+      grub_ieee1275_cell_t ihandle;
       grub_ieee1275_cell_t result;
       grub_ieee1275_cell_t size1;
       grub_ieee1275_cell_t size2;
@@ -84,7 +84,7 @@ 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 = "block-size";
+  args.method = (grub_ieee1275_cell_t) "block-size";
   args.ihandle = dev_ihandle;
   args.result = 1;
 
@@ -97,7 +97,7 @@ grub_nand_open (const char *name, grub_disk_t disk)
   data->block_size = (args.size1 >> GRUB_DISK_SECTOR_BITS);
 
   INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3);
-  args.method = "size";
+  args.method = (grub_ieee1275_cell_t) "size";
   args.ihandle = dev_ihandle;
   args.result = 1;
 
@@ -143,8 +143,8 @@ grub_nand_read (grub_disk_t disk, grub_disk_addr_t sector,
   struct read_args
     {
       struct grub_ieee1275_common_hdr common;
-      char *method;
-      grub_ieee1275_ihandle_t ihandle;
+      grub_ieee1275_cell_t method;
+      grub_ieee1275_cell_t ihandle;
       grub_ieee1275_cell_t ofs;
       grub_ieee1275_cell_t page;
       grub_ieee1275_cell_t len;
@@ -153,7 +153,7 @@ grub_nand_read (grub_disk_t disk, grub_disk_addr_t sector,
     } args;
 
   INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1);
-  args.method = "pio-read";
+  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);
include/grub/ieee1275/ieee1275.h +2 -2
index 628d888..3b5139e 100644
@@ -60,8 +60,8 @@ struct grub_ieee1275_common_hdr
   (p)->nr_ins = (grub_ieee1275_cell_t) xins; \
   (p)->nr_outs = (grub_ieee1275_cell_t) xouts
 
-typedef grub_ieee1275_cell_t grub_ieee1275_ihandle_t;
-typedef grub_ieee1275_cell_t grub_ieee1275_phandle_t;
+typedef grub_uint32_t grub_ieee1275_ihandle_t;
+typedef grub_uint32_t grub_ieee1275_phandle_t;
 
 extern grub_ieee1275_phandle_t EXPORT_VAR(grub_ieee1275_chosen);
 extern grub_ieee1275_ihandle_t EXPORT_VAR(grub_ieee1275_mmu);
kern/ieee1275/ieee1275.c +25 -25

164 lines not on this page · raw message

kern/ieee1275/openfw.c +8 -8
index e88f3b3..4c8cc6a 100644
@@ -154,17 +154,17 @@ grub_map (grub_addr_t phys, grub_addr_t virt, grub_uint32_t size,
 {
   struct map_args {
     struct grub_ieee1275_common_hdr common;
-    char *method;
-    grub_ieee1275_ihandle_t ihandle;
-    grub_uint32_t mode;
-    grub_uint32_t size;
-    grub_uint32_t virt;
-    grub_uint32_t phys;
-    int catch_result;
+    grub_ieee1275_cell_t method;
+    grub_ieee1275_cell_t ihandle;
+    grub_ieee1275_cell_t mode;
+    grub_ieee1275_cell_t size;
+    grub_ieee1275_cell_t virt;
+    grub_ieee1275_cell_t phys;
+    grub_ieee1275_cell_t catch_result;
   } args;
 
   INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1);
-  args.method = "map";
+  args.method = (grub_ieee1275_cell_t) "map";
   args.ihandle = grub_ieee1275_mmu;
   args.phys = phys;
   args.virt = virt;
Signature · 1 line
1.6.2.2
#1 lore raw

From: David Miller <[email protected]>
Date: Tue, 07 Apr 2009 17:03:26 -0700 (PDT)

Quoted 12 lines

2009-04-07 David S. Miller <[email protected]>

	* disk/ieee1275/nand.c (grub_nand_open): All ieee1275 call arg
	slots are of type grub_ieee1275_cell_t.
	(grub_nand_read): Likewise.
	* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_INVALID,
	IEEE1275_IHANDLE_INVALID): Use grub_ieee1275_cell_t since these
	macros are used to compare values in arg/ret block of the call.
	(grub_ieee1275_finddevice, grub_ieee1275_get_property,
	grub_ieee1275_next_property, grub_ieee1275_get_property_length,
	grub_ieee1275_instance_to_package, grub_ieee1275_package_to_path,
	grub_ieee1275_instance_to_path, grub_ieee1275_write,
Quoted 8 lines
	grub_ieee1275_read, grub_ieee1275_seek, grub_ieee1275_peer,
	grub_ieee1275_child, grub_ieee1275_parent, grub_ieee1275_open,
	grub_ieee1275_close, grub_ieee1275_set_property,
	grub_ieee1275_set_color): All ieee1275 call arg slots are of type
	grub_ieee1275_cell_t.
	* kern/ieee1275/openfw.c (grub_map): Likewise.
	* include/grub/ieee1275/ieee1275.h (grub_ieee1275_ihandle_t,
	grub_ieee1275_phandle_t): Define as grub_unit32_t type.

Ping? I'm touching non-sparc code so at least one review would be appreciated before I check this in.

#2 lore raw

At first it seems ok. I'll test it in the weekend ok?

Quoted 32 lines · David Miller

From: David Miller <[email protected]>
Date: Tue, 07 Apr 2009 17:03:26 -0700 (PDT)

Quoted 12 lines

2009-04-07 David S. Miller <[email protected]>

	* disk/ieee1275/nand.c (grub_nand_open): All ieee1275 call arg
	slots are of type grub_ieee1275_cell_t.
	(grub_nand_read): Likewise.
	* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_INVALID,
	IEEE1275_IHANDLE_INVALID): Use grub_ieee1275_cell_t since these
	macros are used to compare values in arg/ret block of the call.
	(grub_ieee1275_finddevice, grub_ieee1275_get_property,
	grub_ieee1275_next_property, grub_ieee1275_get_property_length,
	grub_ieee1275_instance_to_package, grub_ieee1275_package_to_path,
	grub_ieee1275_instance_to_path, grub_ieee1275_write,
Quoted 8 lines
	grub_ieee1275_read, grub_ieee1275_seek, grub_ieee1275_peer,
	grub_ieee1275_child, grub_ieee1275_parent, grub_ieee1275_open,
	grub_ieee1275_close, grub_ieee1275_set_property,
	grub_ieee1275_set_color): All ieee1275 call arg slots are of type
	grub_ieee1275_cell_t.
	* kern/ieee1275/openfw.c (grub_map): Likewise.
	* include/grub/ieee1275/ieee1275.h (grub_ieee1275_ihandle_t,
	grub_ieee1275_phandle_t): Define as grub_unit32_t type.

Ping? I'm touching non-sparc code so at least one review would be appreciated before I check this in.

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 4 lines
Best Regards,

Manoel Rebelo Abranches 
IBM Linux Technology Center Brazil
#3 lore raw

From: Manoel Rebelo Abranches <[email protected]>
Date: Thu, 09 Apr 2009 18:42:08 -0300

Quoted 1 line

At first it seems ok. I'll test it in the weekend ok?

Thanks! Let me know how it goes.