Move to more hookless approach in IEEE1275 devices handling.
This commit is contained in:
parent
99fcda8a7b
commit
6e4146c41e
9 changed files with 390 additions and 353 deletions
|
@ -1,3 +1,7 @@
|
|||
2013-03-02 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Move to more hookless approach in IEEE1275 devices handling.
|
||||
|
||||
2013-03-02 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/kern/term.c (grub_term_normal_color),
|
||||
|
|
|
@ -36,22 +36,29 @@ static int
|
|||
grub_nand_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
|
||||
grub_disk_pull_t pull)
|
||||
{
|
||||
auto int dev_iterate (struct grub_ieee1275_devalias *alias);
|
||||
int dev_iterate (struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
if (grub_strcmp (alias->name, "nand") == 0)
|
||||
{
|
||||
hook (alias->name, hook_data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
static int have_nand = -1;
|
||||
|
||||
if (pull != GRUB_DISK_PULL_NONE)
|
||||
return 0;
|
||||
|
||||
return grub_devalias_iterate (dev_iterate);
|
||||
if (have_nand == -1)
|
||||
{
|
||||
struct grub_ieee1275_devalias alias;
|
||||
|
||||
have_nand = 0;
|
||||
FOR_IEEE1275_DEVALIASES(alias)
|
||||
if (grub_strcmp (alias->name, "nand") == 0)
|
||||
{
|
||||
have_nand = 1;
|
||||
break;
|
||||
}
|
||||
grub_ieee1275_devalias_free (&alias);
|
||||
}
|
||||
|
||||
if (have_nand)
|
||||
return hook ("nand", hook_data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
|
|
|
@ -114,11 +114,7 @@ ofdisk_hash_add (char *devpath, char *curcan)
|
|||
}
|
||||
|
||||
static void
|
||||
scan (void)
|
||||
{
|
||||
auto int dev_iterate_real (const char *name, const char *path);
|
||||
|
||||
int dev_iterate_real (const char *name, const char *path)
|
||||
dev_iterate_real (const char *name, const char *path)
|
||||
{
|
||||
struct ofdisk_hash_ent *op;
|
||||
|
||||
|
@ -135,23 +131,15 @@ scan (void)
|
|||
grub_errno = GRUB_ERR_NONE;
|
||||
grub_free (name_dup);
|
||||
grub_free (can);
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
op = ofdisk_hash_add (name_dup, can);
|
||||
}
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
auto int dev_iterate_alias (struct grub_ieee1275_devalias *alias);
|
||||
int dev_iterate_alias (struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
if (grub_strcmp (alias->type, "block") != 0)
|
||||
return 0;
|
||||
return dev_iterate_real (alias->name, alias->path);
|
||||
}
|
||||
|
||||
auto int dev_iterate (struct grub_ieee1275_devalias *alias);
|
||||
int dev_iterate (struct grub_ieee1275_devalias *alias)
|
||||
static void
|
||||
dev_iterate (const struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
if (grub_strcmp (alias->type, "vscsi") == 0)
|
||||
{
|
||||
|
@ -170,7 +158,7 @@ scan (void)
|
|||
unsigned i;
|
||||
|
||||
if (grub_ieee1275_open (alias->path, &ihandle))
|
||||
return 0;
|
||||
return;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3);
|
||||
args.method = (grub_ieee1275_cell_t) "vscsi-report-luns";
|
||||
|
@ -181,12 +169,12 @@ scan (void)
|
|||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1 || args.catch_result)
|
||||
{
|
||||
grub_ieee1275_close (ihandle);
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
buf = grub_malloc (grub_strlen (alias->path) + 32);
|
||||
if (!buf)
|
||||
return 0;
|
||||
return;
|
||||
bufptr = grub_stpcpy (buf, alias->path);
|
||||
|
||||
for (i = 0; i < args.nentries; i++)
|
||||
|
@ -197,24 +185,42 @@ scan (void)
|
|||
while (*ptr)
|
||||
{
|
||||
grub_snprintf (bufptr, 32, "/disk@%" PRIxGRUB_UINT64_T, *ptr++);
|
||||
if (dev_iterate_real (buf, buf))
|
||||
return 1;
|
||||
dev_iterate_real (buf, buf);
|
||||
}
|
||||
}
|
||||
grub_ieee1275_close (ihandle);
|
||||
grub_free (buf);
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS)
|
||||
&& grub_strcmp (alias->type, "block") == 0)
|
||||
return dev_iterate_real (alias->path, alias->path);
|
||||
|
||||
return grub_children_iterate (alias->path, dev_iterate);
|
||||
{
|
||||
dev_iterate_real (alias->path, alias->path);
|
||||
return;
|
||||
}
|
||||
|
||||
grub_devalias_iterate (dev_iterate_alias);
|
||||
grub_children_iterate ("/", dev_iterate);
|
||||
{
|
||||
struct grub_ieee1275_devalias child;
|
||||
|
||||
FOR_IEEE1275_DEVCHILDREN(alias->path, child)
|
||||
dev_iterate (&child);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
scan (void)
|
||||
{
|
||||
struct grub_ieee1275_devalias alias;
|
||||
FOR_IEEE1275_DEVALIASES(alias)
|
||||
{
|
||||
if (grub_strcmp (alias.type, "block") != 0)
|
||||
continue;
|
||||
dev_iterate_real (alias.name, alias.path);
|
||||
}
|
||||
|
||||
FOR_IEEE1275_DEVCHILDREN("/", alias)
|
||||
dev_iterate (&alias);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -32,184 +32,227 @@ enum grub_ieee1275_parse_type
|
|||
GRUB_PARSE_DEVICE_TYPE
|
||||
};
|
||||
|
||||
/* Walk children of 'devpath', calling hook for each. */
|
||||
int
|
||||
grub_children_iterate (const char *devpath,
|
||||
int (*hook) (struct grub_ieee1275_devalias *alias))
|
||||
static int
|
||||
fill_alias (struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
grub_ieee1275_phandle_t dev;
|
||||
grub_ieee1275_phandle_t child;
|
||||
char *childtype, *childpath;
|
||||
char *childname;
|
||||
int ret = 0;
|
||||
|
||||
if (grub_ieee1275_finddevice (devpath, &dev))
|
||||
return 0;
|
||||
|
||||
if (grub_ieee1275_child (dev, &child))
|
||||
return 0;
|
||||
|
||||
childtype = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
||||
if (!childtype)
|
||||
return 0;
|
||||
childpath = grub_malloc (IEEE1275_MAX_PATH_LEN);
|
||||
if (!childpath)
|
||||
{
|
||||
grub_free (childtype);
|
||||
return 0;
|
||||
}
|
||||
childname = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
||||
if (!childname)
|
||||
{
|
||||
grub_free (childpath);
|
||||
grub_free (childtype);
|
||||
return 0;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
struct grub_ieee1275_devalias alias;
|
||||
grub_ssize_t actual;
|
||||
|
||||
if (grub_ieee1275_get_property (child, "device_type", childtype,
|
||||
if (grub_ieee1275_get_property (alias->phandle, "device_type", alias->type,
|
||||
IEEE1275_MAX_PROP_LEN, &actual))
|
||||
childtype[0] = 0;
|
||||
alias->type[0] = 0;
|
||||
|
||||
if (dev == child)
|
||||
continue;
|
||||
if (alias->parent_dev == alias->phandle)
|
||||
return 0;
|
||||
|
||||
if (grub_ieee1275_package_to_path (child, childpath,
|
||||
if (grub_ieee1275_package_to_path (alias->phandle, alias->path,
|
||||
IEEE1275_MAX_PATH_LEN, &actual))
|
||||
continue;
|
||||
return 0;
|
||||
|
||||
if (grub_strcmp (devpath, childpath) == 0)
|
||||
continue;
|
||||
if (grub_strcmp (alias->parent_path, alias->path) == 0)
|
||||
return 0;
|
||||
|
||||
if (grub_ieee1275_get_property (child, "name", childname,
|
||||
if (grub_ieee1275_get_property (alias->phandle, "name", alias->name,
|
||||
IEEE1275_MAX_PROP_LEN, &actual))
|
||||
continue;
|
||||
return 0;
|
||||
grub_dprintf ("devalias", "device path=%s\n", alias->path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
alias.type = childtype;
|
||||
alias.path = childpath;
|
||||
alias.name = childname;
|
||||
void
|
||||
grub_ieee1275_devalias_free (struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
grub_free (alias->name);
|
||||
grub_free (alias->type);
|
||||
grub_free (alias->path);
|
||||
grub_free (alias->parent_path);
|
||||
alias->name = 0;
|
||||
alias->type = 0;
|
||||
alias->path = 0;
|
||||
alias->parent_path = 0;
|
||||
alias->phandle = GRUB_IEEE1275_PHANDLE_INVALID;
|
||||
}
|
||||
|
||||
void
|
||||
grub_ieee1275_children_peer (struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
while (grub_ieee1275_peer (alias->phandle, &alias->phandle) != -1)
|
||||
if (fill_alias (alias))
|
||||
return;
|
||||
grub_ieee1275_devalias_free (alias);
|
||||
}
|
||||
|
||||
void
|
||||
grub_ieee1275_children_first (const char *devpath,
|
||||
struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
grub_ieee1275_phandle_t dev;
|
||||
|
||||
grub_dprintf ("devalias", "iterating children of %s\n",
|
||||
devpath);
|
||||
|
||||
alias->name = 0;
|
||||
alias->path = 0;
|
||||
alias->parent_path = 0;
|
||||
alias->type = 0;
|
||||
|
||||
if (grub_ieee1275_finddevice (devpath, &dev))
|
||||
return;
|
||||
|
||||
if (grub_ieee1275_child (dev, &alias->phandle))
|
||||
return;
|
||||
|
||||
alias->type = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
||||
if (!alias->type)
|
||||
return;
|
||||
alias->path = grub_malloc (IEEE1275_MAX_PATH_LEN);
|
||||
if (!alias->path)
|
||||
{
|
||||
grub_free (alias->type);
|
||||
return;
|
||||
}
|
||||
alias->parent_path = grub_strdup (devpath);
|
||||
if (!alias->parent_path)
|
||||
{
|
||||
grub_free (alias->path);
|
||||
grub_free (alias->type);
|
||||
return;
|
||||
}
|
||||
|
||||
alias->name = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
||||
if (!alias->name)
|
||||
{
|
||||
grub_free (alias->path);
|
||||
grub_free (alias->type);
|
||||
grub_free (alias->parent_path);
|
||||
return;
|
||||
}
|
||||
if (!fill_alias (alias))
|
||||
grub_ieee1275_children_peer (alias);
|
||||
}
|
||||
|
||||
static int
|
||||
iterate_recursively (const char *path,
|
||||
int (*hook) (struct grub_ieee1275_devalias *alias))
|
||||
{
|
||||
struct grub_ieee1275_devalias alias;
|
||||
int ret = 0;
|
||||
|
||||
FOR_IEEE1275_DEVCHILDREN(path, alias)
|
||||
{
|
||||
ret = hook (&alias);
|
||||
if (ret)
|
||||
break;
|
||||
ret = iterate_recursively (alias.path, hook);
|
||||
if (ret)
|
||||
break;
|
||||
}
|
||||
while (grub_ieee1275_peer (child, &child) != -1);
|
||||
|
||||
grub_free (childname);
|
||||
grub_free (childpath);
|
||||
grub_free (childtype);
|
||||
|
||||
grub_ieee1275_devalias_free (&alias);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_devices_iterate (int (*hook) (struct grub_ieee1275_devalias *alias))
|
||||
{
|
||||
auto int it_through (struct grub_ieee1275_devalias *alias);
|
||||
int it_through (struct grub_ieee1275_devalias *alias)
|
||||
return iterate_recursively ("/", hook);
|
||||
}
|
||||
|
||||
void
|
||||
grub_ieee1275_devalias_init_iterator (struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
if (hook (alias))
|
||||
return 1;
|
||||
return grub_children_iterate (alias->path, it_through);
|
||||
alias->name = 0;
|
||||
alias->path = 0;
|
||||
alias->parent_path = 0;
|
||||
alias->type = 0;
|
||||
|
||||
grub_dprintf ("devalias", "iterating aliases\n");
|
||||
|
||||
if (grub_ieee1275_finddevice ("/aliases", &alias->parent_dev))
|
||||
return;
|
||||
|
||||
alias->name = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
||||
if (!alias->name)
|
||||
return;
|
||||
|
||||
alias->type = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
||||
if (!alias->type)
|
||||
{
|
||||
grub_free (alias->name);
|
||||
alias->name = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
return grub_children_iterate ("/", it_through);
|
||||
alias->name[0] = '\0';
|
||||
}
|
||||
|
||||
/* Iterate through all device aliases. This function can be used to
|
||||
find a device of a specific type. */
|
||||
int
|
||||
grub_devalias_iterate (int (*hook) (struct grub_ieee1275_devalias *alias))
|
||||
grub_ieee1275_devalias_next (struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
grub_ieee1275_phandle_t aliases;
|
||||
char *aliasname, *devtype;
|
||||
if (!alias->name)
|
||||
return 0;
|
||||
while (1)
|
||||
{
|
||||
grub_ssize_t pathlen;
|
||||
grub_ssize_t actual;
|
||||
struct grub_ieee1275_devalias alias;
|
||||
int ret = 0;
|
||||
|
||||
if (grub_ieee1275_finddevice ("/aliases", &aliases))
|
||||
return 0;
|
||||
|
||||
aliasname = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
||||
if (!aliasname)
|
||||
return 0;
|
||||
devtype = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
||||
if (!devtype)
|
||||
if (alias->path)
|
||||
{
|
||||
grub_free (aliasname);
|
||||
grub_free (alias->path);
|
||||
alias->path = 0;
|
||||
}
|
||||
if (grub_ieee1275_next_property (alias->parent_dev, alias->name,
|
||||
alias->name) <= 0)
|
||||
{
|
||||
grub_ieee1275_devalias_free (alias);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Find the first property. */
|
||||
aliasname[0] = '\0';
|
||||
grub_dprintf ("devalias", "devalias name = %s\n", alias->name);
|
||||
|
||||
while (grub_ieee1275_next_property (aliases, aliasname, aliasname) > 0)
|
||||
{
|
||||
grub_ieee1275_phandle_t dev;
|
||||
grub_ssize_t pathlen;
|
||||
char *devpath;
|
||||
|
||||
grub_dprintf ("devalias", "devalias name = %s\n", aliasname);
|
||||
|
||||
grub_ieee1275_get_property_length (aliases, aliasname, &pathlen);
|
||||
grub_ieee1275_get_property_length (alias->parent_dev, alias->name, &pathlen);
|
||||
|
||||
/* The property `name' is a special case we should skip. */
|
||||
if (!grub_strcmp (aliasname, "name"))
|
||||
if (grub_strcmp (alias->name, "name") == 0)
|
||||
continue;
|
||||
|
||||
/* Sun's OpenBoot often doesn't zero terminate the device alias
|
||||
strings, so we will add a NULL byte at the end explicitly. */
|
||||
pathlen += 1;
|
||||
|
||||
devpath = grub_malloc (pathlen + 1);
|
||||
if (! devpath)
|
||||
alias->path = grub_malloc (pathlen + 1);
|
||||
if (! alias->path)
|
||||
{
|
||||
grub_free (devtype);
|
||||
grub_free (aliasname);
|
||||
grub_ieee1275_devalias_free (alias);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (grub_ieee1275_get_property (aliases, aliasname, devpath, pathlen,
|
||||
&actual) || actual < 0)
|
||||
if (grub_ieee1275_get_property (alias->parent_dev, alias->name, alias->path,
|
||||
pathlen, &actual) || actual < 0)
|
||||
{
|
||||
grub_dprintf ("devalias", "get_property (%s) failed\n", aliasname);
|
||||
goto nextprop;
|
||||
grub_dprintf ("devalias", "get_property (%s) failed\n", alias->name);
|
||||
grub_free (alias->path);
|
||||
continue;
|
||||
}
|
||||
if (actual > pathlen)
|
||||
actual = pathlen;
|
||||
devpath[actual] = '\0';
|
||||
devpath[pathlen] = '\0';
|
||||
alias->path[actual] = '\0';
|
||||
alias->path[pathlen] = '\0';
|
||||
|
||||
if (grub_ieee1275_finddevice (devpath, &dev))
|
||||
if (grub_ieee1275_finddevice (alias->path, &alias->phandle))
|
||||
{
|
||||
grub_dprintf ("devalias", "finddevice (%s) failed\n", devpath);
|
||||
goto nextprop;
|
||||
grub_dprintf ("devalias", "finddevice (%s) failed\n", alias->path);
|
||||
grub_free (alias->path);
|
||||
alias->path = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (grub_ieee1275_get_property (dev, "device_type", devtype,
|
||||
if (grub_ieee1275_get_property (alias->phandle, "device_type", alias->type,
|
||||
IEEE1275_MAX_PROP_LEN, &actual))
|
||||
{
|
||||
/* NAND device don't have device_type property. */
|
||||
devtype[0] = 0;
|
||||
alias->type[0] = 0;
|
||||
}
|
||||
|
||||
alias.name = aliasname;
|
||||
alias.path = devpath;
|
||||
alias.type = devtype;
|
||||
ret = hook (&alias);
|
||||
|
||||
nextprop:
|
||||
grub_free (devpath);
|
||||
if (ret)
|
||||
break;
|
||||
return 1;
|
||||
}
|
||||
|
||||
grub_free (devtype);
|
||||
grub_free (aliasname);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Call the "map" method of /chosen/mmu. */
|
||||
|
@ -286,39 +329,30 @@ grub_ieee1275_get_devargs (const char *path)
|
|||
}
|
||||
|
||||
/* Get the device path of the Open Firmware node name `path'. */
|
||||
static char *
|
||||
char *
|
||||
grub_ieee1275_get_devname (const char *path)
|
||||
{
|
||||
char *colon = grub_strchr (path, ':');
|
||||
char *newpath = 0;
|
||||
int pathlen = grub_strlen (path);
|
||||
auto int match_alias (struct grub_ieee1275_devalias *alias);
|
||||
|
||||
int match_alias (struct grub_ieee1275_devalias *curalias)
|
||||
{
|
||||
/* briQ firmware can change capitalization in /chosen/bootpath. */
|
||||
if (grub_strncasecmp (curalias->path, path, pathlen) == 0
|
||||
&& curalias->path[pathlen] == 0)
|
||||
{
|
||||
newpath = grub_strdup (curalias->name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct grub_ieee1275_devalias curalias;
|
||||
if (colon)
|
||||
pathlen = (int)(colon - path);
|
||||
|
||||
/* Try to find an alias for this device. */
|
||||
grub_devalias_iterate (match_alias);
|
||||
|
||||
if (! newpath)
|
||||
newpath = grub_strndup (path, pathlen);
|
||||
|
||||
FOR_IEEE1275_DEVALIASES (curalias)
|
||||
/* briQ firmware can change capitalization in /chosen/bootpath. */
|
||||
if (grub_strncasecmp (curalias.path, path, pathlen) == 0
|
||||
&& curalias.path[pathlen] == 0)
|
||||
{
|
||||
char *newpath;
|
||||
newpath = grub_strdup (curalias.name);
|
||||
grub_ieee1275_devalias_free (&curalias);
|
||||
return newpath;
|
||||
}
|
||||
|
||||
return grub_strndup (path, pathlen);
|
||||
}
|
||||
|
||||
static char *
|
||||
grub_ieee1275_parse_args (const char *path, enum grub_ieee1275_parse_type ptype)
|
||||
{
|
||||
|
|
|
@ -198,27 +198,6 @@ grub_ieee1275_net_config_real (const char *devpath, char **device, char **path)
|
|||
}
|
||||
}
|
||||
|
||||
static char *
|
||||
find_alias (const char *fullname)
|
||||
{
|
||||
char *ret = NULL;
|
||||
auto int find_alias_hook (struct grub_ieee1275_devalias *alias);
|
||||
|
||||
int find_alias_hook (struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
if (grub_strcmp (alias->path, fullname) == 0)
|
||||
{
|
||||
ret = grub_strdup (alias->name);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_devalias_iterate (find_alias_hook);
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
search_net_devices (struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
|
@ -308,7 +287,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
|
|||
card->driver = NULL;
|
||||
card->data = ofdata;
|
||||
card->flags = 0;
|
||||
shortname = find_alias (alias->path);
|
||||
shortname = grub_ieee1275_get_devname (alias->path);
|
||||
card->name = grub_xasprintf ("ofnet_%s", shortname ? : alias->path);
|
||||
card->idle_poll_delay_ms = 10;
|
||||
grub_free (shortname);
|
||||
|
|
|
@ -200,6 +200,7 @@ struct grub_serial_driver grub_escc_driver =
|
|||
};
|
||||
|
||||
static struct grub_escc_descriptor escc_descs[2];
|
||||
static char *macio = 0;
|
||||
|
||||
static void
|
||||
add_device (grub_addr_t addr, int channel)
|
||||
|
@ -243,18 +244,8 @@ add_device (grub_addr_t addr, int channel)
|
|||
grub_serial_register (port);
|
||||
}
|
||||
|
||||
GRUB_MOD_INIT (escc)
|
||||
{
|
||||
char *macio = 0;
|
||||
char *escc = 0;
|
||||
grub_uint32_t macio_addr[4];
|
||||
grub_uint32_t escc_addr[2];
|
||||
grub_ieee1275_phandle_t dev;
|
||||
|
||||
auto int find_macio (struct grub_ieee1275_devalias *alias);
|
||||
auto int find_escc (struct grub_ieee1275_devalias *alias);
|
||||
|
||||
int find_macio (struct grub_ieee1275_devalias *alias)
|
||||
static int
|
||||
find_macio (struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
if (grub_strcmp (alias->type, "mac-io") != 0)
|
||||
return 0;
|
||||
|
@ -262,19 +253,25 @@ GRUB_MOD_INIT (escc)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int find_escc (struct grub_ieee1275_devalias *alias)
|
||||
GRUB_MOD_INIT (escc)
|
||||
{
|
||||
if (grub_strcmp (alias->type, "escc") != 0)
|
||||
return 0;
|
||||
escc = grub_strdup (alias->path);
|
||||
return 1;
|
||||
}
|
||||
grub_uint32_t macio_addr[4];
|
||||
grub_uint32_t escc_addr[2];
|
||||
grub_ieee1275_phandle_t dev;
|
||||
struct grub_ieee1275_devalias alias;
|
||||
char *escc = 0;
|
||||
|
||||
grub_ieee1275_devices_iterate (find_macio);
|
||||
if (!macio)
|
||||
return;
|
||||
|
||||
grub_children_iterate (macio, find_escc);
|
||||
FOR_IEEE1275_DEVCHILDREN(macio, alias)
|
||||
if (grub_strcmp (alias.type, "escc") == 0)
|
||||
{
|
||||
escc = grub_strdup (alias.path);
|
||||
break;
|
||||
}
|
||||
grub_ieee1275_devalias_free (&alias);
|
||||
if (!escc)
|
||||
{
|
||||
grub_free (macio);
|
||||
|
|
|
@ -180,19 +180,14 @@ ofserial_hash_add (char *devpath, char *curcan)
|
|||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
grub_ofserial_init (void)
|
||||
{
|
||||
auto int dev_iterate_real (struct grub_ieee1275_devalias *alias,
|
||||
int use_name);
|
||||
|
||||
int dev_iterate_real (struct grub_ieee1275_devalias *alias,
|
||||
static void
|
||||
dev_iterate_real (struct grub_ieee1275_devalias *alias,
|
||||
int use_name)
|
||||
{
|
||||
struct ofserial_hash_ent *op;
|
||||
|
||||
if (grub_strcmp (alias->type, "serial") != 0)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
grub_dprintf ("serial", "serial name = %s, path = %s\n", alias->name,
|
||||
alias->path);
|
||||
|
@ -207,32 +202,32 @@ grub_ofserial_init (void)
|
|||
grub_errno = GRUB_ERR_NONE;
|
||||
grub_free (name);
|
||||
grub_free (can);
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
op = ofserial_hash_add (name, can);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static int
|
||||
dev_iterate (struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
dev_iterate_real (alias, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto int dev_iterate_alias (struct grub_ieee1275_devalias *alias);
|
||||
int dev_iterate_alias (struct grub_ieee1275_devalias *alias)
|
||||
void
|
||||
grub_ofserial_init (void)
|
||||
{
|
||||
return dev_iterate_real (alias, 1);
|
||||
}
|
||||
|
||||
auto int dev_iterate (struct grub_ieee1275_devalias *alias);
|
||||
int dev_iterate (struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
return dev_iterate_real (alias, 0);
|
||||
}
|
||||
|
||||
unsigned i;
|
||||
grub_err_t err;
|
||||
struct grub_ieee1275_devalias alias;
|
||||
|
||||
FOR_IEEE1275_DEVALIASES(alias)
|
||||
dev_iterate_real (&alias, 1);
|
||||
|
||||
grub_devalias_iterate (dev_iterate_alias);
|
||||
grub_ieee1275_devices_iterate (dev_iterate);
|
||||
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE (ofserial_hash); i++)
|
||||
{
|
||||
static struct ofserial_hash_ent *ent;
|
||||
|
|
|
@ -54,11 +54,8 @@ set_video_mode (unsigned width __attribute__ ((unused)),
|
|||
/* TODO */
|
||||
}
|
||||
|
||||
static void
|
||||
find_display (void)
|
||||
{
|
||||
auto int hook (struct grub_ieee1275_devalias *alias);
|
||||
int hook (struct grub_ieee1275_devalias *alias)
|
||||
static int
|
||||
find_display_hook (struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
if (grub_strcmp (alias->type, "display") == 0)
|
||||
{
|
||||
|
@ -69,7 +66,10 @@ find_display (void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
grub_ieee1275_devices_iterate (hook);
|
||||
static void
|
||||
find_display (void)
|
||||
{
|
||||
grub_ieee1275_devices_iterate (find_display_hook);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
|
|
|
@ -24,13 +24,6 @@
|
|||
#include <grub/types.h>
|
||||
#include <grub/machine/ieee1275.h>
|
||||
|
||||
struct grub_ieee1275_devalias
|
||||
{
|
||||
char *name;
|
||||
char *path;
|
||||
char *type;
|
||||
};
|
||||
|
||||
struct grub_ieee1275_mem_region
|
||||
{
|
||||
unsigned int start;
|
||||
|
@ -64,6 +57,18 @@ struct grub_ieee1275_common_hdr
|
|||
typedef grub_uint32_t grub_ieee1275_ihandle_t;
|
||||
typedef grub_uint32_t grub_ieee1275_phandle_t;
|
||||
|
||||
#define GRUB_IEEE1275_PHANDLE_INVALID ((grub_ieee1275_phandle_t) -1)
|
||||
|
||||
struct grub_ieee1275_devalias
|
||||
{
|
||||
char *name;
|
||||
char *path;
|
||||
char *type;
|
||||
char *parent_path;
|
||||
grub_ieee1275_phandle_t phandle;
|
||||
grub_ieee1275_phandle_t parent_dev;
|
||||
};
|
||||
|
||||
extern void (*EXPORT_VAR(grub_ieee1275_net_config)) (const char *dev,
|
||||
char **device,
|
||||
char **path);
|
||||
|
@ -192,10 +197,6 @@ int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle,
|
|||
int EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uint32_t *msecs);
|
||||
|
||||
|
||||
int EXPORT_FUNC(grub_devalias_iterate)
|
||||
(int (*hook) (struct grub_ieee1275_devalias *alias));
|
||||
int EXPORT_FUNC(grub_children_iterate) (const char *devpath,
|
||||
int (*hook) (struct grub_ieee1275_devalias *alias));
|
||||
grub_err_t EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size);
|
||||
|
||||
int
|
||||
|
@ -210,5 +211,19 @@ int EXPORT_FUNC(grub_ieee1275_devices_iterate) (int (*hook)
|
|||
char *EXPORT_FUNC(grub_ieee1275_get_aliasdevname) (const char *path);
|
||||
char *EXPORT_FUNC(grub_ieee1275_canonicalise_devname) (const char *path);
|
||||
char *EXPORT_FUNC(grub_ieee1275_get_device_type) (const char *path);
|
||||
char *EXPORT_FUNC(grub_ieee1275_get_devname) (const char *path);
|
||||
|
||||
void EXPORT_FUNC(grub_ieee1275_devalias_init_iterator) (struct grub_ieee1275_devalias *alias);
|
||||
void EXPORT_FUNC(grub_ieee1275_devalias_free) (struct grub_ieee1275_devalias *alias);
|
||||
int EXPORT_FUNC(grub_ieee1275_devalias_next) (struct grub_ieee1275_devalias *alias);
|
||||
void EXPORT_FUNC(grub_ieee1275_children_peer) (struct grub_ieee1275_devalias *alias);
|
||||
void EXPORT_FUNC(grub_ieee1275_children_first) (const char *devpath,
|
||||
struct grub_ieee1275_devalias *alias);
|
||||
|
||||
#define FOR_IEEE1275_DEVALIASES(alias) for (grub_ieee1275_devalias_init_iterator (&(alias)); grub_ieee1275_devalias_next (&(alias));)
|
||||
|
||||
#define FOR_IEEE1275_DEVCHILDREN(devpath, alias) for (grub_ieee1275_children_first ((devpath), &(alias)); \
|
||||
(alias).name; \
|
||||
grub_ieee1275_children_peer (&(alias)))
|
||||
|
||||
#endif /* ! GRUB_IEEE1275_HEADER */
|
||||
|
|
Loading…
Reference in a new issue