2005-10-01 Hollis Blanchard <hollis@penguinppc.org>
* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Cast `size' to long. * include/grub/ieee1275/ieee1275.h (grub_ieee1275_next_property): Remove `flags' argument. All callers changed. * kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_ROOT): Removed. (IEEE1275_IHANDLE_INVALID): New variable. (IEEE1275_CELL_INVALID): New variable. (grub_ieee1275_finddevice, grub_ieee1275_get_property, grub_ieee1275_get_property_length, grub_ieee1275_instance_to_package, grub_ieee1275_package_to_path, grub_ieee1275_instance_to_path, grub_ieee1275_peer, grub_ieee1275_child, grub_ieee1275_open, grub_ieee1275_claim, grub_ieee1275_set_property): Error-check return codes from Open Firmware. All callers updated. (grub_ieee1275_next_property): Directly return Open Firmware return code. * kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options): Standardize error checking from `grub_ieee1275_get_property'. * kern/powerpc/ieee1275/openfw.c (grub_devalias_iterate): Rename `devalias' to `aliases'. Correct comments. Consolidate error paths.
This commit is contained in:
parent
cc6d3df39e
commit
fba51f4801
6 changed files with 84 additions and 67 deletions
22
ChangeLog
22
ChangeLog
|
@ -1,3 +1,25 @@
|
|||
2005-10-01 Hollis Blanchard <hollis@penguinppc.org>
|
||||
|
||||
* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Cast `size' to long.
|
||||
|
||||
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_next_property):
|
||||
Remove `flags' argument. All callers changed.
|
||||
* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_ROOT): Removed.
|
||||
(IEEE1275_IHANDLE_INVALID): New variable.
|
||||
(IEEE1275_CELL_INVALID): New variable.
|
||||
(grub_ieee1275_finddevice, grub_ieee1275_get_property,
|
||||
grub_ieee1275_get_property_length, grub_ieee1275_instance_to_package,
|
||||
grub_ieee1275_package_to_path, grub_ieee1275_instance_to_path,
|
||||
grub_ieee1275_peer, grub_ieee1275_child, grub_ieee1275_open,
|
||||
grub_ieee1275_claim, grub_ieee1275_set_property): Error-check return
|
||||
codes from Open Firmware. All callers updated.
|
||||
(grub_ieee1275_next_property): Directly return Open Firmware return
|
||||
code.
|
||||
* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options):
|
||||
Standardize error checking from `grub_ieee1275_get_property'.
|
||||
* kern/powerpc/ieee1275/openfw.c (grub_devalias_iterate): Rename
|
||||
`devalias' to `aliases'. Correct comments. Consolidate error paths.
|
||||
|
||||
2005-10-01 Hollis Blanchard <hollis@penguinppc.org>
|
||||
|
||||
* kern/ieee1275/ieee1275.c (grub_ieee1275_instance_to_path): Rename
|
||||
|
|
|
@ -130,7 +130,7 @@ grub_ofdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
|
|||
|
||||
grub_dprintf ("disk",
|
||||
"Reading handle %p: sector 0x%llx, size 0x%lx, buf %p.\n",
|
||||
(void *) disk->data, sector, size, buf);
|
||||
(void *) disk->data, sector, (long) size, buf);
|
||||
|
||||
pos = sector * 512UL;
|
||||
|
||||
|
|
|
@ -96,8 +96,7 @@ int EXPORT_FUNC(grub_ieee1275_get_property) (grub_ieee1275_phandle_t phandle,
|
|||
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,
|
||||
grub_ieee1275_cell_t *flags);
|
||||
char *prev_prop, char *prop);
|
||||
int EXPORT_FUNC(grub_ieee1275_get_property_length)
|
||||
(grub_ieee1275_phandle_t phandle, const char *prop, grub_ssize_t *length);
|
||||
int EXPORT_FUNC(grub_ieee1275_instance_to_package)
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
|
||||
#include <grub/ieee1275/ieee1275.h>
|
||||
|
||||
#define IEEE1275_PHANDLE_ROOT ((grub_ieee1275_phandle_t) 0)
|
||||
#define IEEE1275_PHANDLE_INVALID ((grub_ieee1275_phandle_t) -1)
|
||||
#define IEEE1275_IHANDLE_INVALID ((grub_ieee1275_ihandle_t) -1)
|
||||
#define IEEE1275_CELL_INVALID ((grub_ieee1275_cell_t) -1)
|
||||
|
||||
|
||||
|
||||
|
@ -52,6 +53,8 @@ grub_ieee1275_finddevice (char *name, grub_ieee1275_phandle_t *phandlep)
|
|||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
*phandlep = args.phandle;
|
||||
if (args.phandle == IEEE1275_PHANDLE_INVALID)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -81,14 +84,14 @@ grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle,
|
|||
return -1;
|
||||
if (actual)
|
||||
*actual = (grub_ssize_t) args.size;
|
||||
if (args.size == (grub_ieee1275_cell_t) -1)
|
||||
if (args.size == IEEE1275_CELL_INVALID)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_next_property (grub_ieee1275_phandle_t phandle, char *prev_prop,
|
||||
char *prop, grub_ieee1275_cell_t *flags)
|
||||
char *prop)
|
||||
{
|
||||
struct get_property_args
|
||||
{
|
||||
|
@ -108,9 +111,7 @@ grub_ieee1275_next_property (grub_ieee1275_phandle_t phandle, char *prev_prop,
|
|||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
if (flags)
|
||||
*flags = args.flags;
|
||||
return 0;
|
||||
return (int) args.flags;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -134,6 +135,8 @@ grub_ieee1275_get_property_length (grub_ieee1275_phandle_t phandle,
|
|||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
*length = args.length;
|
||||
if (args.length == IEEE1275_CELL_INVALID)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -155,6 +158,8 @@ grub_ieee1275_instance_to_package (grub_ieee1275_ihandle_t ihandle,
|
|||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
*phandlep = args.phandle;
|
||||
if (args.phandle == IEEE1275_PHANDLE_INVALID)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -182,6 +187,8 @@ grub_ieee1275_package_to_path (grub_ieee1275_phandle_t phandle,
|
|||
return -1;
|
||||
if (actual)
|
||||
*actual = args.actual;
|
||||
if (args.actual == IEEE1275_CELL_INVALID)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -209,6 +216,8 @@ grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle,
|
|||
return -1;
|
||||
if (actual)
|
||||
*actual = args.actual;
|
||||
if (args.actual == IEEE1275_CELL_INVALID)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -309,6 +318,8 @@ grub_ieee1275_peer (grub_ieee1275_phandle_t node,
|
|||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
*result = args.result;
|
||||
if (args.result == 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -331,6 +342,8 @@ grub_ieee1275_child (grub_ieee1275_phandle_t node,
|
|||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
*result = args.result;
|
||||
if (args.result == 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -425,6 +438,8 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
|
|||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
*result = args.result;
|
||||
if (args.result == IEEE1275_IHANDLE_INVALID)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -468,13 +483,10 @@ grub_ieee1275_claim (grub_addr_t addr, grub_size_t size, unsigned int align,
|
|||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
|
||||
if (result)
|
||||
*result = args.base;
|
||||
|
||||
if (args.base == (grub_ieee1275_cell_t)-1)
|
||||
if (args.base == IEEE1275_CELL_INVALID)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -495,7 +507,6 @@ grub_ieee1275_release (grub_addr_t addr, grub_size_t size)
|
|||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -524,6 +535,8 @@ grub_ieee1275_set_property (grub_ieee1275_phandle_t phandle,
|
|||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
*actual = args.actual;
|
||||
if ((args.actual == IEEE1275_CELL_INVALID) || (args.actual != args.size))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -553,7 +566,6 @@ grub_ieee1275_set_color (grub_ieee1275_ihandle_t ihandle,
|
|||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,19 +51,18 @@ grub_ieee1275_find_options (void)
|
|||
{
|
||||
grub_ieee1275_phandle_t options;
|
||||
grub_ieee1275_phandle_t openprom;
|
||||
int realmode;
|
||||
int smartfw;
|
||||
int rc;
|
||||
int realmode = 0;
|
||||
|
||||
grub_ieee1275_finddevice ("/options", &options);
|
||||
grub_ieee1275_get_property (options, "real-mode?", &realmode,
|
||||
sizeof (realmode), 0);
|
||||
if (realmode)
|
||||
rc = grub_ieee1275_get_property (options, "real-mode?", &realmode,
|
||||
sizeof realmode, 0);
|
||||
if ((rc >= 0) && realmode)
|
||||
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_REAL_MODE);
|
||||
|
||||
grub_ieee1275_finddevice ("/openprom", &openprom);
|
||||
smartfw = grub_ieee1275_get_property (openprom, "SmartFirmware-version",
|
||||
0, 0, 0);
|
||||
if (smartfw != -1)
|
||||
rc = grub_ieee1275_get_property (openprom, "SmartFirmware-version", 0, 0, 0);
|
||||
if (rc >= 0)
|
||||
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,12 +38,10 @@ grub_children_iterate (char *devpath,
|
|||
grub_ieee1275_phandle_t dev;
|
||||
grub_ieee1275_phandle_t child;
|
||||
|
||||
grub_ieee1275_finddevice (devpath, &dev);
|
||||
if (dev == (grub_ieee1275_phandle_t) -1)
|
||||
if (grub_ieee1275_finddevice (devpath, &dev))
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Unknown device");
|
||||
|
||||
grub_ieee1275_child (dev, &child);
|
||||
if (child == (grub_ieee1275_phandle_t) -1)
|
||||
if (grub_ieee1275_child (dev, &child))
|
||||
return grub_error (GRUB_ERR_BAD_DEVICE, "Device has no children");
|
||||
|
||||
do
|
||||
|
@ -56,19 +54,16 @@ grub_children_iterate (char *devpath,
|
|||
struct grub_ieee1275_devalias alias;
|
||||
int actual;
|
||||
|
||||
grub_ieee1275_get_property (child, "device_type", &childtype,
|
||||
sizeof childtype, &actual);
|
||||
if (actual == -1)
|
||||
if (grub_ieee1275_get_property (child, "device_type", &childtype,
|
||||
sizeof childtype, &actual))
|
||||
continue;
|
||||
|
||||
grub_ieee1275_package_to_path (child, childpath, sizeof childpath,
|
||||
&actual);
|
||||
if (actual == -1)
|
||||
if (grub_ieee1275_package_to_path (child, childpath, sizeof childpath,
|
||||
&actual))
|
||||
continue;
|
||||
|
||||
grub_ieee1275_get_property (child, "name", &childname,
|
||||
sizeof childname, &actual);
|
||||
if (actual == -1)
|
||||
if (grub_ieee1275_get_property (child, "name", &childname,
|
||||
sizeof childname, &actual))
|
||||
continue;
|
||||
|
||||
grub_sprintf (fullname, "%s/%s", devpath, childname);
|
||||
|
@ -88,19 +83,18 @@ grub_children_iterate (char *devpath,
|
|||
grub_err_t
|
||||
grub_devalias_iterate (int (*hook) (struct grub_ieee1275_devalias *alias))
|
||||
{
|
||||
grub_ieee1275_phandle_t devalias;
|
||||
grub_ieee1275_phandle_t aliases;
|
||||
char aliasname[32];
|
||||
int actual;
|
||||
struct grub_ieee1275_devalias alias;
|
||||
|
||||
if (grub_ieee1275_finddevice ("/aliases", &devalias))
|
||||
if (grub_ieee1275_finddevice ("/aliases", &aliases))
|
||||
return -1;
|
||||
|
||||
/* XXX: Is this the right way to find the first property? */
|
||||
/* Find the first property. */
|
||||
aliasname[0] = '\0';
|
||||
|
||||
/* XXX: Are the while conditions correct? */
|
||||
while (grub_ieee1275_next_property (devalias, aliasname, aliasname, 0))
|
||||
while (grub_ieee1275_next_property (aliases, aliasname, aliasname))
|
||||
{
|
||||
grub_ieee1275_phandle_t dev;
|
||||
grub_ssize_t pathlen;
|
||||
|
@ -108,7 +102,7 @@ grub_devalias_iterate (int (*hook) (struct grub_ieee1275_devalias *alias))
|
|||
/* XXX: This should be large enough for any possible case. */
|
||||
char devtype[64];
|
||||
|
||||
grub_ieee1275_get_property_length (devalias, aliasname, &pathlen);
|
||||
grub_ieee1275_get_property_length (aliases, aliasname, &pathlen);
|
||||
|
||||
/* The property `name' is a special case we should skip. */
|
||||
if (!grub_strcmp (aliasname, "name"))
|
||||
|
@ -118,32 +112,23 @@ grub_devalias_iterate (int (*hook) (struct grub_ieee1275_devalias *alias))
|
|||
if (! devpath)
|
||||
return grub_errno;
|
||||
|
||||
if (grub_ieee1275_get_property (devalias, aliasname, devpath, pathlen,
|
||||
if (grub_ieee1275_get_property (aliases, aliasname, devpath, pathlen,
|
||||
&actual))
|
||||
{
|
||||
grub_free (devpath);
|
||||
continue;
|
||||
}
|
||||
goto nextprop;
|
||||
|
||||
if (grub_ieee1275_finddevice (devpath, &dev)
|
||||
|| dev == (grub_ieee1275_phandle_t) -1)
|
||||
{
|
||||
grub_free (devpath);
|
||||
continue;
|
||||
}
|
||||
if (grub_ieee1275_finddevice (devpath, &dev))
|
||||
goto nextprop;
|
||||
|
||||
if (grub_ieee1275_get_property (dev, "device_type", devtype, sizeof devtype,
|
||||
&actual))
|
||||
{
|
||||
grub_free (devpath);
|
||||
continue;
|
||||
}
|
||||
if (grub_ieee1275_get_property (dev, "device_type", devtype,
|
||||
sizeof devtype, &actual))
|
||||
goto nextprop;
|
||||
|
||||
alias.name = aliasname;
|
||||
alias.path= devpath;
|
||||
alias.path = devpath;
|
||||
alias.type = devtype;
|
||||
hook (&alias);
|
||||
|
||||
nextprop:
|
||||
grub_free (devpath);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue