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

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Eric Snowberg 2018-02-26 17:34:14 -08:00 committed by Vincent Batts
parent 21b89650ec
commit 856004c85b
2 changed files with 47 additions and 1 deletions

View file

@ -482,6 +482,47 @@ grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle)
return 0; return 0;
} }
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 int
grub_ieee1275_claim (grub_addr_t addr, grub_size_t size, unsigned int align, grub_ieee1275_claim (grub_addr_t addr, grub_size_t size, unsigned int align,
grub_addr_t *result) grub_addr_t *result)

View file

@ -210,7 +210,12 @@ int EXPORT_FUNC(grub_ieee1275_set_property) (grub_ieee1275_phandle_t phandle,
int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle, int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle,
int index, int r, int g, int b); int index, int r, int g, int b);
int EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uint32_t *msecs); 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); grub_err_t EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size);