All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] Add additional IEEE1275 methods
@ 2018-02-27  1:34 Eric Snowberg
  2018-02-27  1:34 ` [PATCH 1/7] ieee1275: decode-unit command for 4 addr cell devs Eric Snowberg
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Eric Snowberg @ 2018-02-27  1:34 UTC (permalink / raw)
  To: grub-devel; +Cc: daniel.kiper, glaubitz, Eric Snowberg

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



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

* [PATCH 1/7] ieee1275: decode-unit command for 4 addr cell devs
  2018-02-27  1:34 [PATCH 0/7] Add additional IEEE1275 methods Eric Snowberg
@ 2018-02-27  1:34 ` Eric Snowberg
  2018-03-01 14:10   ` Daniel Kiper
  2018-02-27  1:34 ` [PATCH 2/7] ieee1275: encode-unit " Eric Snowberg
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 10+ messages in thread
From: Eric Snowberg @ 2018-02-27  1:34 UTC (permalink / raw)
  To: grub-devel; +Cc: daniel.kiper, glaubitz, 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.

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

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
 grub-core/kern/ieee1275/ieee1275.c |   42 ++++++++++++++++++++++++++++++++++++
 include/grub/ieee1275/ieee1275.h   |    8 ++++++
 2 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c
index 9821702..4617b36 100644
--- a/grub-core/kern/ieee1275/ieee1275.c
+++ b/grub-core/kern/ieee1275/ieee1275.c
@@ -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)
 {
diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h
index 8e42513..b1940c2 100644
--- a/include/grub/ieee1275/ieee1275.h
+++ b/include/grub/ieee1275/ieee1275.h
@@ -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);
 
-- 
1.7.1



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

* [PATCH 2/7] ieee1275: encode-unit command for 4 addr cell devs
  2018-02-27  1:34 [PATCH 0/7] Add additional IEEE1275 methods Eric Snowberg
  2018-02-27  1:34 ` [PATCH 1/7] ieee1275: decode-unit command for 4 addr cell devs Eric Snowberg
@ 2018-02-27  1:34 ` Eric Snowberg
  2018-02-27  1:34 ` [PATCH 3/7] ieee1275: set-address bus specific method Eric Snowberg
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Eric Snowberg @ 2018-02-27  1:34 UTC (permalink / raw)
  To: grub-devel; +Cc: daniel.kiper, glaubitz, 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

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
 grub-core/kern/ieee1275/ieee1275.c |   46 ++++++++++++++++++++++++++++++++++++
 include/grub/ieee1275/ieee1275.h   |    7 +++++
 2 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c
index 4617b36..7aef624 100644
--- a/grub-core/kern/ieee1275/ieee1275.c
+++ b/grub-core/kern/ieee1275/ieee1275.c
@@ -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,
diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h
index b1940c2..5404ed6 100644
--- a/include/grub/ieee1275/ieee1275.h
+++ b/include/grub/ieee1275/ieee1275.h
@@ -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);
-- 
1.7.1



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

* [PATCH 3/7] ieee1275: set-address bus specific method
  2018-02-27  1:34 [PATCH 0/7] Add additional IEEE1275 methods Eric Snowberg
  2018-02-27  1:34 ` [PATCH 1/7] ieee1275: decode-unit command for 4 addr cell devs Eric Snowberg
  2018-02-27  1:34 ` [PATCH 2/7] ieee1275: encode-unit " Eric Snowberg
@ 2018-02-27  1:34 ` Eric Snowberg
  2018-02-27  1:34 ` [PATCH 4/7] ieee1275: no-data-command " Eric Snowberg
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Eric Snowberg @ 2018-02-27  1:34 UTC (permalink / raw)
  To: grub-devel; +Cc: daniel.kiper, glaubitz, 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

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
 grub-core/kern/ieee1275/ieee1275.c |   38 ++++++++++++++++++++++++++++++++++++
 include/grub/ieee1275/ieee1275.h   |    4 +++
 2 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c
index 7aef624..7de87ac 100644
--- a/grub-core/kern/ieee1275/ieee1275.c
+++ b/grub-core/kern/ieee1275/ieee1275.c
@@ -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;
+}
diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h
index 5404ed6..1ba9f27 100644
--- a/include/grub/ieee1275/ieee1275.h
+++ b/include/grub/ieee1275/ieee1275.h
@@ -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,
-- 
1.7.1



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

* [PATCH 4/7] ieee1275: no-data-command bus specific method
  2018-02-27  1:34 [PATCH 0/7] Add additional IEEE1275 methods Eric Snowberg
                   ` (2 preceding siblings ...)
  2018-02-27  1:34 ` [PATCH 3/7] ieee1275: set-address bus specific method Eric Snowberg
@ 2018-02-27  1:34 ` Eric Snowberg
  2018-02-27  1:34 ` [PATCH 5/7] ieee1275: block-size deblocker support method Eric Snowberg
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Eric Snowberg @ 2018-02-27  1:34 UTC (permalink / raw)
  To: grub-devel; +Cc: daniel.kiper, glaubitz, 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.

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
 grub-core/kern/ieee1275/ieee1275.c |   49 ++++++++++++++++++++++++++++++++++++
 include/grub/ieee1275/ieee1275.h   |    4 +++
 2 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c
index 7de87ac..89e4f7d 100644
--- a/grub-core/kern/ieee1275/ieee1275.c
+++ b/grub-core/kern/ieee1275/ieee1275.c
@@ -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;
+}
diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h
index 1ba9f27..7ef326a 100644
--- a/include/grub/ieee1275/ieee1275.h
+++ b/include/grub/ieee1275/ieee1275.h
@@ -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,
-- 
1.7.1



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

* [PATCH 5/7] ieee1275: block-size deblocker support method
  2018-02-27  1:34 [PATCH 0/7] Add additional IEEE1275 methods Eric Snowberg
                   ` (3 preceding siblings ...)
  2018-02-27  1:34 ` [PATCH 4/7] ieee1275: no-data-command " Eric Snowberg
@ 2018-02-27  1:34 ` Eric Snowberg
  2018-02-27  1:34 ` [PATCH 6/7] sparc64: #blocks disk node method Eric Snowberg
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Eric Snowberg @ 2018-02-27  1:34 UTC (permalink / raw)
  To: grub-devel; +Cc: daniel.kiper, glaubitz, 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.

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
 grub-core/kern/ieee1275/ieee1275.c |   23 +++++++++++++++++++++++
 include/grub/ieee1275/ieee1275.h   |    1 +
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c
index 89e4f7d..96eb78d 100644
--- a/grub-core/kern/ieee1275/ieee1275.c
+++ b/grub-core/kern/ieee1275/ieee1275.c
@@ -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;
+}
diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h
index 7ef326a..c457212 100644
--- a/include/grub/ieee1275/ieee1275.h
+++ b/include/grub/ieee1275/ieee1275.h
@@ -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);
-- 
1.7.1



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

* [PATCH 6/7] sparc64: #blocks disk node method
  2018-02-27  1:34 [PATCH 0/7] Add additional IEEE1275 methods Eric Snowberg
                   ` (4 preceding siblings ...)
  2018-02-27  1:34 ` [PATCH 5/7] ieee1275: block-size deblocker support method Eric Snowberg
@ 2018-02-27  1:34 ` Eric Snowberg
  2018-02-27  1:34 ` [PATCH 7/7] sparc64: #blocks64 " Eric Snowberg
  2018-03-01 14:16 ` [PATCH 0/7] Add additional IEEE1275 methods Daniel Kiper
  7 siblings, 0 replies; 10+ messages in thread
From: Eric Snowberg @ 2018-02-27  1:34 UTC (permalink / raw)
  To: grub-devel; +Cc: daniel.kiper, glaubitz, 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.

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
 grub-core/kern/sparc64/ieee1275/ieee1275.c |   29 ++++++++++++++++++++++++++++
 include/grub/sparc64/ieee1275/ieee1275.h   |    1 +
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/grub-core/kern/sparc64/ieee1275/ieee1275.c b/grub-core/kern/sparc64/ieee1275/ieee1275.c
index 53be692..ed68d61 100644
--- a/grub-core/kern/sparc64/ieee1275/ieee1275.c
+++ b/grub-core/kern/sparc64/ieee1275/ieee1275.c
@@ -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;
+}
diff --git a/include/grub/sparc64/ieee1275/ieee1275.h b/include/grub/sparc64/ieee1275/ieee1275.h
index 32c77f8..2ddf44d 100644
--- a/include/grub/sparc64/ieee1275/ieee1275.h
+++ b/include/grub/sparc64/ieee1275/ieee1275.h
@@ -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);
 
-- 
1.7.1



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

* [PATCH 7/7] sparc64: #blocks64 disk node method
  2018-02-27  1:34 [PATCH 0/7] Add additional IEEE1275 methods Eric Snowberg
                   ` (5 preceding siblings ...)
  2018-02-27  1:34 ` [PATCH 6/7] sparc64: #blocks disk node method Eric Snowberg
@ 2018-02-27  1:34 ` Eric Snowberg
  2018-03-01 14:16 ` [PATCH 0/7] Add additional IEEE1275 methods Daniel Kiper
  7 siblings, 0 replies; 10+ messages in thread
From: Eric Snowberg @ 2018-02-27  1:34 UTC (permalink / raw)
  To: grub-devel; +Cc: daniel.kiper, glaubitz, 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.

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
---
 grub-core/kern/sparc64/ieee1275/ieee1275.c |   24 ++++++++++++++++++++++++
 include/grub/sparc64/ieee1275/ieee1275.h   |    1 +
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/grub-core/kern/sparc64/ieee1275/ieee1275.c b/grub-core/kern/sparc64/ieee1275/ieee1275.c
index ed68d61..6e5b90a 100644
--- a/grub-core/kern/sparc64/ieee1275/ieee1275.c
+++ b/grub-core/kern/sparc64/ieee1275/ieee1275.c
@@ -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));
+}
diff --git a/include/grub/sparc64/ieee1275/ieee1275.h b/include/grub/sparc64/ieee1275/ieee1275.h
index 2ddf44d..4b18468 100644
--- a/include/grub/sparc64/ieee1275/ieee1275.h
+++ b/include/grub/sparc64/ieee1275/ieee1275.h
@@ -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);
 
-- 
1.7.1



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

* Re: [PATCH 1/7] ieee1275: decode-unit command for 4 addr cell devs
  2018-02-27  1:34 ` [PATCH 1/7] ieee1275: decode-unit command for 4 addr cell devs Eric Snowberg
@ 2018-03-01 14:10   ` Daniel Kiper
  0 siblings, 0 replies; 10+ messages in thread
From: Daniel Kiper @ 2018-03-01 14:10 UTC (permalink / raw)
  To: Eric Snowberg; +Cc: grub-devel, glaubitz

On Mon, Feb 26, 2018 at 05:34:14PM -0800, Eric Snowberg wrote:
> 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
>
> Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Just one nit pick below...

> ---
>  grub-core/kern/ieee1275/ieee1275.c |   42 ++++++++++++++++++++++++++++++++++++
>  include/grub/ieee1275/ieee1275.h   |    8 ++++++
>  2 files changed, 50 insertions(+), 0 deletions(-)
>
> diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c
> index 9821702..4617b36 100644
> --- a/grub-core/kern/ieee1275/ieee1275.c
> +++ b/grub-core/kern/ieee1275/ieee1275.c
> @@ -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)
>  {
> diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h
> index 8e42513..b1940c2 100644
> --- a/include/grub/ieee1275/ieee1275.h
> +++ b/include/grub/ieee1275/ieee1275.h
> @@ -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);
> +
> +

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

Daniel


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

* Re: [PATCH 0/7] Add additional IEEE1275 methods
  2018-02-27  1:34 [PATCH 0/7] Add additional IEEE1275 methods Eric Snowberg
                   ` (6 preceding siblings ...)
  2018-02-27  1:34 ` [PATCH 7/7] sparc64: #blocks64 " Eric Snowberg
@ 2018-03-01 14:16 ` Daniel Kiper
  7 siblings, 0 replies; 10+ messages in thread
From: Daniel Kiper @ 2018-03-01 14:16 UTC (permalink / raw)
  To: Eric Snowberg; +Cc: grub-devel, glaubitz

On Mon, Feb 26, 2018 at 05:34:13PM -0800, Eric Snowberg wrote:
> 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 <daniel.kiper@oracle.com> +/- some
nit picks which I fix during commit. I will do that in a week or so if
there are no objections.

Daniel


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

end of thread, other threads:[~2018-03-01 14:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-27  1:34 [PATCH 0/7] Add additional IEEE1275 methods Eric Snowberg
2018-02-27  1:34 ` [PATCH 1/7] ieee1275: decode-unit command for 4 addr cell devs Eric Snowberg
2018-03-01 14:10   ` Daniel Kiper
2018-02-27  1:34 ` [PATCH 2/7] ieee1275: encode-unit " Eric Snowberg
2018-02-27  1:34 ` [PATCH 3/7] ieee1275: set-address bus specific method Eric Snowberg
2018-02-27  1:34 ` [PATCH 4/7] ieee1275: no-data-command " Eric Snowberg
2018-02-27  1:34 ` [PATCH 5/7] ieee1275: block-size deblocker support method Eric Snowberg
2018-02-27  1:34 ` [PATCH 6/7] sparc64: #blocks disk node method Eric Snowberg
2018-02-27  1:34 ` [PATCH 7/7] sparc64: #blocks64 " Eric Snowberg
2018-03-01 14:16 ` [PATCH 0/7] Add additional IEEE1275 methods Daniel Kiper

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.