Skip to contentSkip to conversation

Add additional IEEE1275 methods

PATCH In review Eric Snowberg 2 participants 10 messages Feb 27, 2018 – Mar 1, 2018

lore
Share & tools
lore
#0 lore raw

cover Add additional IEEE1275 methods

Add additional IEEE1275 methods. This is in preparation for a follow on patch that will make use of all of them.

Eric Snowberg (7):
ieee1275: decode-unit command for 4 addr cell devs
ieee1275: encode-unit command for 4 addr cell devs
ieee1275: set-address bus specific method
ieee1275: no-data-command bus specific method
ieee1275: block-size deblocker support method
sparc64: #blocks disk node method
sparc64: #blocks64 disk node method

 grub-core/kern/ieee1275/ieee1275.c         |  198 ++++++++++++++++++++++++++++
 grub-core/kern/sparc64/ieee1275/ieee1275.c |   53 ++++++++
 include/grub/ieee1275/ieee1275.h           |   24 ++++
 include/grub/sparc64/ieee1275/ieee1275.h   |    2 +
 4 files changed, 277 insertions(+), 0 deletions(-)
#1 lore raw

PATCH 1/7 ieee1275: decode-unit command for 4 addr cell devs

decode-unit ( addr len -- phys.lo ... phys.hi )

Convert text unit-string to physical address.

Convert unit-string, the text string representation, to phys.lo ... phys.hi, the numerical representation of a physical address within the address space defined by this device node. The number of cells in the list phys.lo ... phys.hi is determined by the value of the #address-cells property of this node.

This function is for devices with #address-cells == 4

---
 grub-core/kern/ieee1275/ieee1275.c |   42 ++++++++++++++++++++++++++++++++++++
 include/grub/ieee1275/ieee1275.h   |    8 ++++++
 2 files changed, 50 insertions(+), 0 deletions(-)
grub-core/kern/ieee1275/ieee1275.c +42 -0
index 9821702..4617b36 100644
@@ -483,6 +483,48 @@ grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle)
 }
 
 int
+grub_ieee1275_decode_unit4 (grub_ieee1275_ihandle_t ihandle,
+                            void *addr, grub_size_t size,
+                            grub_uint32_t *phy_lo, grub_uint32_t *phy_hi,
+                            grub_uint32_t *lun_lo, grub_uint32_t *lun_hi)
+{
+  struct decode_args
+  {
+    struct grub_ieee1275_common_hdr common;
+    grub_ieee1275_cell_t method;
+    grub_ieee1275_cell_t ihandle;
+    grub_ieee1275_cell_t size;
+    grub_ieee1275_cell_t addr;
+    grub_ieee1275_cell_t catch_result;
+    grub_ieee1275_cell_t tgt_h;
+    grub_ieee1275_cell_t tgt_l;
+    grub_ieee1275_cell_t lun_h;
+    grub_ieee1275_cell_t lun_l;
+  }
+  args;
+
+  INIT_IEEE1275_COMMON (&args.common, "call-method", 4, 5);
+  args.method = (grub_ieee1275_cell_t) "decode-unit";
+  args.ihandle = ihandle;
+  args.size = size;
+  args.addr = (grub_ieee1275_cell_t) addr;
+  args.catch_result = 1;
+
+  if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.catch_result))
+    {
+      grub_error (GRUB_ERR_OUT_OF_RANGE, "decode-unit failed\n");
+      return -1;
+    }
+
+  *phy_lo = args.tgt_l;
+  *phy_hi = args.tgt_h;
+  *lun_lo = args.lun_l;
+  *lun_hi = args.lun_h;
+  return 0;
+}
+
+
+int
 grub_ieee1275_claim (grub_addr_t addr, grub_size_t size, unsigned int align,
 		     grub_addr_t *result)
 {
include/grub/ieee1275/ieee1275.h +8 -0
index 8e42513..b1940c2 100644
@@ -211,6 +211,14 @@ int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle,
 					  int index, int r, int g, int b);
 int EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uint32_t *msecs);
 
+int EXPORT_FUNC(grub_ieee1275_decode_unit4) (grub_ieee1275_ihandle_t ihandle,
+                                             void *addr, grub_size_t size,
+                                             grub_uint32_t *phy_lo,
+                                             grub_uint32_t *phy_hi,
+                                             grub_uint32_t *lun_lo,
+                                             grub_uint32_t *lun_hi);
+
+
 
 grub_err_t EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size);
 
Signature · 1 line
1.7.1
#3 lore raw

PATCH 2/7 ieee1275: encode-unit command for 4 addr cell devs

In reply to Eric Snowberg

Convert physical address to text unit-string.

Convert phys.lo ... phys-high, the numerical representation, to unit-string, the text string representation of a physical address within the address space defined by this device node. The number of cells in the list phys.lo ... phys.hi is determined by the value of the #address-cells property of this node.

This function is for devices with #address-cells == 4

---
 grub-core/kern/ieee1275/ieee1275.c |   46 ++++++++++++++++++++++++++++++++++++
 include/grub/ieee1275/ieee1275.h   |    7 +++++
 2 files changed, 53 insertions(+), 0 deletions(-)
grub-core/kern/ieee1275/ieee1275.c +46 -0
index 4617b36..7aef624 100644
@@ -19,6 +19,7 @@
 
 #include <grub/ieee1275/ieee1275.h>
 #include <grub/types.h>
+#include <grub/misc.h>
 
 #define IEEE1275_PHANDLE_INVALID  ((grub_ieee1275_cell_t) -1)
 #define IEEE1275_IHANDLE_INVALID  ((grub_ieee1275_cell_t) 0)
@@ -523,6 +524,51 @@ grub_ieee1275_decode_unit4 (grub_ieee1275_ihandle_t ihandle,
   return 0;
 }
 
+char *
+grub_ieee1275_encode_uint4 (grub_ieee1275_ihandle_t ihandle,
+                            grub_uint32_t phy_lo, grub_uint32_t phy_hi,
+                            grub_uint32_t lun_lo, grub_uint32_t lun_hi,
+                            grub_size_t *size)
+{
+  char *addr;
+  struct encode_args
+  {
+    struct grub_ieee1275_common_hdr common;
+    grub_ieee1275_cell_t method;
+    grub_ieee1275_cell_t ihandle;
+    grub_ieee1275_cell_t tgt_h;
+    grub_ieee1275_cell_t tgt_l;
+    grub_ieee1275_cell_t lun_h;
+    grub_ieee1275_cell_t lun_l;
+    grub_ieee1275_cell_t catch_result;
+    grub_ieee1275_cell_t size;
+    grub_ieee1275_cell_t addr;
+  }
+  args;
+
+  INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 3);
+  args.method = (grub_ieee1275_cell_t) "encode-unit";
+  args.ihandle = ihandle;
+
+  args.tgt_l = phy_lo;
+  args.tgt_h = phy_hi;
+  args.lun_l = lun_lo;
+  args.lun_h = lun_hi;
+  args.catch_result = 1;
+
+  if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.catch_result))
+    {
+      grub_error (GRUB_ERR_OUT_OF_RANGE, "encode-unit failed\n");
+      return 0;
+    }
+
+  addr = (void *)args.addr;
+  *size = args.size;
+  addr = grub_strdup ((char *)args.addr);
+  return addr;
+}
+
+
 
 int
 grub_ieee1275_claim (grub_addr_t addr, grub_size_t size, unsigned int align,
include/grub/ieee1275/ieee1275.h +7 -0
index b1940c2..5404ed6 100644
@@ -218,6 +218,13 @@ int EXPORT_FUNC(grub_ieee1275_decode_unit4) (grub_ieee1275_ihandle_t ihandle,
                                              grub_uint32_t *lun_lo,
                                              grub_uint32_t *lun_hi);
 
+char *EXPORT_FUNC(grub_ieee1275_encode_uint4) (grub_ieee1275_ihandle_t ihandle,
+                                             grub_uint32_t phy_lo,
+                                             grub_uint32_t phy_hi,
+                                             grub_uint32_t lun_lo,
+                                             grub_uint32_t lun_hi,
+                                             grub_size_t *size);
+
 
 
 grub_err_t EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size);
Signature · 1 line
1.7.1
#4 lore raw

PATCH 3/7 ieee1275: set-address bus specific method

In reply to Eric Snowberg

IEEE 1275-1994 Standard for Boot (Initialization Configuration)
Firmware: Core Requirements and Practices
E.3.2.2 Bus-specific methods for bus nodes

A package implementing the scsi-2 device type shall implement the following bus-specific method:

set-address ( unit# target# -- )
Sets the SCSI target number (0x0..0xf) and unit number (0..7) to which subsequent commands apply.

This function is for devices with #address-cells == 2

---
 grub-core/kern/ieee1275/ieee1275.c |   38 ++++++++++++++++++++++++++++++++++++
 include/grub/ieee1275/ieee1275.h   |    4 +++
 2 files changed, 42 insertions(+), 0 deletions(-)
grub-core/kern/ieee1275/ieee1275.c +38 -0
index 7aef624..7de87ac 100644
@@ -695,3 +695,41 @@ grub_ieee1275_milliseconds (grub_uint32_t *msecs)
   *msecs = args.msecs;
   return 0;
 }
+
+int
+grub_ieee1275_set_address (grub_ieee1275_ihandle_t ihandle,
+                           grub_uint32_t target, grub_uint32_t lun)
+{
+  struct set_address
+  {
+    struct grub_ieee1275_common_hdr common;
+    grub_ieee1275_cell_t method;
+    grub_ieee1275_cell_t ihandle;
+    grub_ieee1275_cell_t tgt;
+    grub_ieee1275_cell_t lun;
+    grub_ieee1275_cell_t catch_result;
+  }
+  args;
+
+  INIT_IEEE1275_COMMON (&args.common, "call-method", 4, 1);
+
+  /* IEEE 1275-1994 Standard for Boot (Initialization Configuration)
+     Firmware: Core Requirements and Practices
+     E.3.2.2 Bus-specific methods for bus nodes
+
+     A package implementing the scsi-2 device type shall implement the
+     following bus-specific method:
+
+     set-address ( unit# target# -- )
+     Sets the SCSI target number (0x0..0xf) and unit number (0..7) to which
+     subsequent commands apply. */
+  args.method = (grub_ieee1275_cell_t) "set-address";
+  args.ihandle = ihandle;
+  args.tgt = target;
+  args.lun = lun;
+
+  if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+    return -1;
+
+  return args.catch_result;
+}
include/grub/ieee1275/ieee1275.h +4 -0
index 5404ed6..1ba9f27 100644
@@ -211,6 +211,10 @@ int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle,
 					  int index, int r, int g, int b);
 int EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uint32_t *msecs);
 
+int EXPORT_FUNC(grub_ieee1275_set_address) (grub_ieee1275_ihandle_t ihandle,
+                                            grub_uint32_t target,
+                                            grub_uint32_t lun);
+
 int EXPORT_FUNC(grub_ieee1275_decode_unit4) (grub_ieee1275_ihandle_t ihandle,
                                              void *addr, grub_size_t size,
                                              grub_uint32_t *phy_lo,
Signature · 1 line
1.7.1
#5 lore raw

PATCH 4/7 ieee1275: no-data-command bus specific method

In reply to Eric Snowberg

IEEE 1275-1994 Standard for Boot (Initialization Configuration)
Firmware: Core Requirements and Practices

E.3.2.2 Bus-specific methods for bus nodes

A package implementing the scsi-2 device type shall implement the following bus-specific method:

no-data-command ( cmd-addr -- error? )
Executes a simple SCSI command, automatically retrying under certain conditions. cmd-addr is the address of a 6-byte command buffer containing an SCSI command that does not have a data transfer phase. Executes the command, retrying indefinitely with the same retry criteria as retry-command.

error? is nonzero if an error occurred, zero otherwise. NOTE no-data-command is a convenience function. It provides no capabilities that are not present in retry-command, but for those commands that meet its restrictions, it is easier to use.

---
 grub-core/kern/ieee1275/ieee1275.c |   49 ++++++++++++++++++++++++++++++++++++
 include/grub/ieee1275/ieee1275.h   |    4 +++
 2 files changed, 53 insertions(+), 0 deletions(-)
grub-core/kern/ieee1275/ieee1275.c +49 -0
index 7de87ac..89e4f7d 100644
@@ -733,3 +733,52 @@ grub_ieee1275_set_address (grub_ieee1275_ihandle_t ihandle,
 
   return args.catch_result;
 }
+
+int
+grub_ieee1275_no_data_command (grub_ieee1275_ihandle_t ihandle,
+                               const void *cmd_addr, grub_ssize_t *result)
+{
+  struct set_address
+  {
+    struct grub_ieee1275_common_hdr common;
+    grub_ieee1275_cell_t method;
+    grub_ieee1275_cell_t ihandle;
+    grub_ieee1275_cell_t cmd_addr;
+    grub_ieee1275_cell_t error;
+    grub_ieee1275_cell_t catch_result;
+  }
+  args;
+
+  INIT_IEEE1275_COMMON (&args.common, "call-method", 3, 2);
+
+  /* IEEE 1275-1994 Standard for Boot (Initialization Configuration)
+     Firmware: Core Requirements and Practices
+
+     E.3.2.2 Bus-specific methods for bus nodes
+
+     A package implementing the scsi-2 device type shall implement the
+     following bus-specific method:
+
+     no-data-command ( cmd-addr -- error? )
+     Executes a simple SCSI command, automatically retrying under
+     certain conditions.  cmd-addr is the address of a 6-byte command buffer
+     containing an SCSI command that does not have a data transfer phase.
+     Executes the command, retrying indefinitely with the same retry criteria
+     as retry-command.
+
+     error? is nonzero if an error occurred, zero otherwise.
+     NOTE no-data-command is a convenience function. It provides
+     no capabilities that are not present in retry-command, but for
+     those commands that meet its restrictions, it is easier to use.  */
+  args.method = (grub_ieee1275_cell_t) "no-data-command";
+  args.ihandle = ihandle;
+  args.cmd_addr = (grub_ieee1275_cell_t) cmd_addr;
+
+  if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
+    return -1;
+
+  if (result)
+    *result = args.error;
+
+  return args.catch_result;
+}
include/grub/ieee1275/ieee1275.h +4 -0
index 1ba9f27..7ef326a 100644
@@ -215,6 +215,10 @@ int EXPORT_FUNC(grub_ieee1275_set_address) (grub_ieee1275_ihandle_t ihandle,
                                             grub_uint32_t target,
                                             grub_uint32_t lun);
 
+int EXPORT_FUNC(grub_ieee1275_no_data_command) (grub_ieee1275_ihandle_t ihandle,
+                                                const void *cmd_addr,
+                                                grub_ssize_t *result);
+
 int EXPORT_FUNC(grub_ieee1275_decode_unit4) (grub_ieee1275_ihandle_t ihandle,
                                              void *addr, grub_size_t size,
                                              grub_uint32_t *phy_lo,
Signature · 1 line
1.7.1
#6 lore raw

PATCH 5/7 ieee1275: block-size deblocker support method

In reply to Eric Snowberg

IEEE Std 1275-1994 Standard for Boot (Initialization Configuration)
Firmware: Core Requirements and Practices

3.8.3 deblocker support package

Any package that uses the "deblocker" support package must define the following method, which the deblocker uses as a low-level interface to the device

block-size ( -- block-len ) Return "granularity" for accesses to this device.

---
 grub-core/kern/ieee1275/ieee1275.c |   23 +++++++++++++++++++++++
 include/grub/ieee1275/ieee1275.h   |    1 +
 2 files changed, 24 insertions(+), 0 deletions(-)
grub-core/kern/ieee1275/ieee1275.c +23 -0
index 89e4f7d..96eb78d 100644
@@ -782,3 +782,26 @@ grub_ieee1275_no_data_command (grub_ieee1275_ihandle_t ihandle,
 
   return args.catch_result;
 }
+
+int
+grub_ieee1275_get_block_size (grub_ieee1275_ihandle_t ihandle)
+{
+  struct size_args_ieee1275
+    {
+      struct grub_ieee1275_common_hdr common;
+      grub_ieee1275_cell_t method;
+      grub_ieee1275_cell_t ihandle;
+      grub_ieee1275_cell_t result;
+      grub_ieee1275_cell_t size;
+    } args;
+
+  INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 2);
+  args.method = (grub_ieee1275_cell_t) "block-size";
+  args.ihandle = ihandle;
+  args.result = 1;
+
+  if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
+    return 0;
+
+  return args.size;
+}
include/grub/ieee1275/ieee1275.h +1 -0
index 7ef326a..c457212 100644
@@ -233,6 +233,7 @@ char *EXPORT_FUNC(grub_ieee1275_encode_uint4) (grub_ieee1275_ihandle_t ihandle,
                                              grub_uint32_t lun_hi,
                                              grub_size_t *size);
 
+int EXPORT_FUNC(grub_ieee1275_get_block_size) (grub_ieee1275_ihandle_t ihandle);
 
 
 grub_err_t EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size);
Signature · 1 line
1.7.1
#7 lore raw

PATCH 6/7 sparc64: #blocks disk node method

In reply to Eric Snowberg

Return the number of blocks of storage associated with the device or instance. Where a "block" is a unit of storage consisting of the number of bytes returned by the package's "block-size" method. If the size cannot be determined, the #blocks method returns the maximum unsigned integer (which, because of Open Firmware's assumption of two's complement arithmetic, is equivalent to the signed number -1). If the number of blocks exceeds the range of an unsigned number, return 0 to alert the caller to try the #blocks64 command.

---
 grub-core/kern/sparc64/ieee1275/ieee1275.c |   29 ++++++++++++++++++++++++++++
 include/grub/sparc64/ieee1275/ieee1275.h   |    1 +
 2 files changed, 30 insertions(+), 0 deletions(-)
grub-core/kern/sparc64/ieee1275/ieee1275.c +29 -0
index 53be692..ed68d61 100644
@@ -89,3 +89,32 @@ grub_ieee1275_alloc_physmem (grub_addr_t *paddr, grub_size_t size,
 
   return args.catch_result;
 }
+
+grub_uint64_t
+grub_ieee1275_num_blocks (grub_ieee1275_ihandle_t ihandle)
+{
+  struct nblocks_args_ieee1275
+  {
+    struct grub_ieee1275_common_hdr common;
+    grub_ieee1275_cell_t method;
+    grub_ieee1275_cell_t ihandle;
+    grub_ieee1275_cell_t catch_result;
+    grub_ieee1275_cell_t blocks;
+  }
+  args;
+
+  INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 2);
+  args.method = (grub_ieee1275_cell_t) "#blocks";
+  args.ihandle = ihandle;
+  args.catch_result = 1;
+
+  if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.catch_result != 0))
+    return -1;
+
+  /* If the number of blocks exceeds the range of an unsigned number,
+     return 0 to alert the caller to try the #blocks64 command. */
+  if (args.blocks >= 0xffffffffULL)
+    return 0;
+
+  return args.blocks;
+}
include/grub/sparc64/ieee1275/ieee1275.h +1 -0
index 32c77f8..2ddf44d 100644
@@ -42,6 +42,7 @@ extern int EXPORT_FUNC(grub_ieee1275_claim_vaddr) (grub_addr_t vaddr,
 extern int EXPORT_FUNC(grub_ieee1275_alloc_physmem) (grub_addr_t *paddr,
 						     grub_size_t size,
 						     grub_uint32_t align);
+extern grub_uint64_t EXPORT_FUNC(grub_ieee1275_num_blocks) (grub_uint32_t ihandle);
 
 extern grub_addr_t EXPORT_VAR (grub_ieee1275_original_stack);
 
Signature · 1 line
1.7.1
#8 lore raw

PATCH 7/7 sparc64: #blocks64 disk node method

In reply to Eric Snowberg

Return the 64bit number of blocks of storage associated with the device or instance. Where a "block" is a unit of storage consisting of the number of bytes returned by the package's "block-size" method. If the size cannot be determined, or if the number of blocks exceeds the range return -1.

---
 grub-core/kern/sparc64/ieee1275/ieee1275.c |   24 ++++++++++++++++++++++++
 include/grub/sparc64/ieee1275/ieee1275.h   |    1 +
 2 files changed, 25 insertions(+), 0 deletions(-)
grub-core/kern/sparc64/ieee1275/ieee1275.c +24 -0
index ed68d61..6e5b90a 100644
@@ -118,3 +118,27 @@ grub_ieee1275_num_blocks (grub_ieee1275_ihandle_t ihandle)
 
   return args.blocks;
 }
+grub_uint64_t
+grub_ieee1275_num_blocks64 (grub_ieee1275_ihandle_t ihandle)
+{
+  struct nblocks_args_ieee1275
+  {
+    struct grub_ieee1275_common_hdr common;
+    grub_ieee1275_cell_t method;
+    grub_ieee1275_cell_t ihandle;
+    grub_ieee1275_cell_t catch_result;
+    grub_ieee1275_cell_t hi_blocks;
+    grub_ieee1275_cell_t lo_blocks;
+  }
+  args;
+
+  INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3);
+  args.method = (grub_ieee1275_cell_t) "#blocks64";
+  args.ihandle = ihandle;
+  args.catch_result = 1;
+
+  if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.catch_result != 0))
+    return -1;
+
+  return ((args.hi_blocks << 32) | (args.lo_blocks));
+}
include/grub/sparc64/ieee1275/ieee1275.h +1 -0
index 2ddf44d..4b18468 100644
@@ -43,6 +43,7 @@ extern int EXPORT_FUNC(grub_ieee1275_alloc_physmem) (grub_addr_t *paddr,
 						     grub_size_t size,
 						     grub_uint32_t align);
 extern grub_uint64_t EXPORT_FUNC(grub_ieee1275_num_blocks) (grub_uint32_t ihandle);
+extern grub_uint64_t EXPORT_FUNC(grub_ieee1275_num_blocks64) (grub_uint32_t ihandle);
 
 extern grub_addr_t EXPORT_VAR (grub_ieee1275_original_stack);
 
Signature · 1 line
1.7.1
Reviewed-by on v1 1/7
#2 lore raw

Re: [PATCH 1/7] ieee1275: decode-unit command for 4 addr cell devs

In reply to Eric Snowberg
Quoted 10 lines · Eric Snowberg

decode-unit ( addr len -- phys.lo ... phys.hi )

Convert text unit-string to physical address.

Convert unit-string, the text string representation, to phys.lo ... phys.hi, the numerical representation of a physical address within the address space defined by this device node. The number of cells in the list phys.lo ... phys.hi is determined by the value of the #address-cells property of this node.

Quoted 3 lines

This function is for devices with #address-cells == 4

Just one nit pick below...

Quoted 64 lines
---
 grub-core/kern/ieee1275/ieee1275.c |   42 ++++++++++++++++++++++++++++++++++++
 include/grub/ieee1275/ieee1275.h   |    8 ++++++
 2 files changed, 50 insertions(+), 0 deletions(-)
grub-core/kern/ieee1275/ieee1275.c +42 -0
index 9821702..4617b36 100644
@@ -483,6 +483,48 @@ grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle)
 }
 
 int
+grub_ieee1275_decode_unit4 (grub_ieee1275_ihandle_t ihandle,
+                            void *addr, grub_size_t size,
+                            grub_uint32_t *phy_lo, grub_uint32_t *phy_hi,
+                            grub_uint32_t *lun_lo, grub_uint32_t *lun_hi)
+{
+  struct decode_args
+  {
+    struct grub_ieee1275_common_hdr common;
+    grub_ieee1275_cell_t method;
+    grub_ieee1275_cell_t ihandle;
+    grub_ieee1275_cell_t size;
+    grub_ieee1275_cell_t addr;
+    grub_ieee1275_cell_t catch_result;
+    grub_ieee1275_cell_t tgt_h;
+    grub_ieee1275_cell_t tgt_l;
+    grub_ieee1275_cell_t lun_h;
+    grub_ieee1275_cell_t lun_l;
+  }
+  args;
+
+  INIT_IEEE1275_COMMON (&args.common, "call-method", 4, 5);
+  args.method = (grub_ieee1275_cell_t) "decode-unit";
+  args.ihandle = ihandle;
+  args.size = size;
+  args.addr = (grub_ieee1275_cell_t) addr;
+  args.catch_result = 1;
+
+  if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.catch_result))
+    {
+      grub_error (GRUB_ERR_OUT_OF_RANGE, "decode-unit failed\n");
+      return -1;
+    }
+
+  *phy_lo = args.tgt_l;
+  *phy_hi = args.tgt_h;
+  *lun_lo = args.lun_l;
+  *lun_hi = args.lun_h;
+  return 0;
+}
+
+
+int
 grub_ieee1275_claim (grub_addr_t addr, grub_size_t size, unsigned int align,
 		     grub_addr_t *result)
 {
include/grub/ieee1275/ieee1275.h +0 -0
index 8e42513..b1940c2 100644
@@ -211,6 +211,14 @@ int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle,
 					  int index, int r, int g, int b);

include/grub/ieee1275/ieee1275.h int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle, · line 221

Quoted 10 lines
include/grub/ieee1275/ieee1275.h +8 -0
 int EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uint32_t *msecs);
 
+int EXPORT_FUNC(grub_ieee1275_decode_unit4) (grub_ieee1275_ihandle_t ihandle,
+                                             void *addr, grub_size_t size,
+                                             grub_uint32_t *phy_lo,
+                                             grub_uint32_t *phy_hi,
+                                             grub_uint32_t *lun_lo,
+                                             grub_uint32_t *lun_hi);
+
+

Too many empty lines. I will fix this during commit.

Daniel

#9 lore raw
In reply to Eric Snowberg
Quoted 2 lines · Eric Snowberg

Add additional IEEE1275 methods. This is in preparation for a follow on patch that will make use of all of them.

In general Reviewed-by: Daniel Kiper <[email protected]> +/- some nit picks which I fix during commit. I will do that in a week or so if there are no objections.

Daniel