|
|
f96e0b |
From 4f258868283bf563138c854d65df1e5f34eea2af Mon Sep 17 00:00:00 2001
|
|
|
f96e0b |
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
Date: Sat, 2 Mar 2013 23:51:19 +0100
|
|
|
f96e0b |
Subject: [PATCH 187/482] Move to more hookless approach in IEEE1275
|
|
|
f96e0b |
devices handling.
|
|
|
f96e0b |
|
|
|
f96e0b |
---
|
|
|
f96e0b |
ChangeLog | 4 +
|
|
|
f96e0b |
grub-core/disk/ieee1275/nand.c | 31 ++--
|
|
|
f96e0b |
grub-core/disk/ieee1275/ofdisk.c | 172 +++++++++---------
|
|
|
f96e0b |
grub-core/kern/ieee1275/openfw.c | 308 ++++++++++++++++++---------------
|
|
|
f96e0b |
grub-core/net/drivers/ieee1275/ofnet.c | 23 +--
|
|
|
f96e0b |
grub-core/term/ieee1275/escc.c | 41 ++---
|
|
|
f96e0b |
grub-core/term/ieee1275/serial.c | 73 ++++----
|
|
|
f96e0b |
grub-core/video/ieee1275.c | 26 +--
|
|
|
f96e0b |
include/grub/ieee1275/ieee1275.h | 37 ++--
|
|
|
f96e0b |
9 files changed, 376 insertions(+), 339 deletions(-)
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/ChangeLog b/ChangeLog
|
|
|
f96e0b |
index 3231b4b..f107544 100644
|
|
|
f96e0b |
--- a/ChangeLog
|
|
|
f96e0b |
+++ b/ChangeLog
|
|
|
f96e0b |
@@ -1,5 +1,9 @@
|
|
|
f96e0b |
2013-03-02 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
|
|
|
f96e0b |
+ Move to more hookless approach in IEEE1275 devices handling.
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+2013-03-02 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
f96e0b |
+
|
|
|
f96e0b |
* grub-core/kern/term.c (grub_term_normal_color),
|
|
|
f96e0b |
(grub_term_highlight_color): Add back lost defaults.
|
|
|
f96e0b |
|
|
|
f96e0b |
diff --git a/grub-core/disk/ieee1275/nand.c b/grub-core/disk/ieee1275/nand.c
|
|
|
f96e0b |
index b2844b1..30ea0f2 100644
|
|
|
f96e0b |
--- a/grub-core/disk/ieee1275/nand.c
|
|
|
f96e0b |
+++ b/grub-core/disk/ieee1275/nand.c
|
|
|
f96e0b |
@@ -36,22 +36,29 @@ static int
|
|
|
f96e0b |
grub_nand_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data,
|
|
|
f96e0b |
grub_disk_pull_t pull)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- auto int dev_iterate (struct grub_ieee1275_devalias *alias);
|
|
|
f96e0b |
- int dev_iterate (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- if (grub_strcmp (alias->name, "nand") == 0)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- hook (alias->name, hook_data);
|
|
|
f96e0b |
- return 1;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
+ static int have_nand = -1;
|
|
|
f96e0b |
|
|
|
f96e0b |
if (pull != GRUB_DISK_PULL_NONE)
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
- return grub_devalias_iterate (dev_iterate);
|
|
|
f96e0b |
+ if (have_nand == -1)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ struct grub_ieee1275_devalias alias;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ have_nand = 0;
|
|
|
f96e0b |
+ FOR_IEEE1275_DEVALIASES(alias)
|
|
|
f96e0b |
+ if (grub_strcmp (alias->name, "nand") == 0)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ have_nand = 1;
|
|
|
f96e0b |
+ break;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+ grub_ieee1275_devalias_free (&alias);
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (have_nand)
|
|
|
f96e0b |
+ return hook ("nand", hook_data);
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ return 0;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
static grub_err_t
|
|
|
f96e0b |
diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c
|
|
|
f96e0b |
index 2130cb1..1d4de90 100644
|
|
|
f96e0b |
--- a/grub-core/disk/ieee1275/ofdisk.c
|
|
|
f96e0b |
+++ b/grub-core/disk/ieee1275/ofdisk.c
|
|
|
f96e0b |
@@ -114,107 +114,113 @@ ofdisk_hash_add (char *devpath, char *curcan)
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
static void
|
|
|
f96e0b |
-scan (void)
|
|
|
f96e0b |
+dev_iterate_real (const char *name, const char *path)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- auto int dev_iterate_real (const char *name, const char *path);
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- int dev_iterate_real (const char *name, const char *path)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- struct ofdisk_hash_ent *op;
|
|
|
f96e0b |
+ struct ofdisk_hash_ent *op;
|
|
|
f96e0b |
|
|
|
f96e0b |
- grub_dprintf ("disk", "disk name = %s, path = %s\n", name,
|
|
|
f96e0b |
- path);
|
|
|
f96e0b |
+ grub_dprintf ("disk", "disk name = %s, path = %s\n", name,
|
|
|
f96e0b |
+ path);
|
|
|
f96e0b |
|
|
|
f96e0b |
- op = ofdisk_hash_find (path);
|
|
|
f96e0b |
- if (!op)
|
|
|
f96e0b |
+ op = ofdisk_hash_find (path);
|
|
|
f96e0b |
+ if (!op)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ char *name_dup = grub_strdup (name);
|
|
|
f96e0b |
+ char *can = grub_strdup (path);
|
|
|
f96e0b |
+ if (!name_dup || !can)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- char *name_dup = grub_strdup (name);
|
|
|
f96e0b |
- char *can = grub_strdup (path);
|
|
|
f96e0b |
- if (!name_dup || !can)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- grub_errno = GRUB_ERR_NONE;
|
|
|
f96e0b |
- grub_free (name_dup);
|
|
|
f96e0b |
- grub_free (can);
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
- op = ofdisk_hash_add (name_dup, can);
|
|
|
f96e0b |
+ grub_errno = GRUB_ERR_NONE;
|
|
|
f96e0b |
+ grub_free (name_dup);
|
|
|
f96e0b |
+ grub_free (can);
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
+ op = ofdisk_hash_add (name_dup, can);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
|
|
|
f96e0b |
- auto int dev_iterate_alias (struct grub_ieee1275_devalias *alias);
|
|
|
f96e0b |
- int dev_iterate_alias (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- if (grub_strcmp (alias->type, "block") != 0)
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
- return dev_iterate_real (alias->name, alias->path);
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- auto int dev_iterate (struct grub_ieee1275_devalias *alias);
|
|
|
f96e0b |
- int dev_iterate (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- if (grub_strcmp (alias->type, "vscsi") == 0)
|
|
|
f96e0b |
+static void
|
|
|
f96e0b |
+dev_iterate (const struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ if (grub_strcmp (alias->type, "vscsi") == 0)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ static grub_ieee1275_ihandle_t ihandle;
|
|
|
f96e0b |
+ struct set_color_args
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- static grub_ieee1275_ihandle_t ihandle;
|
|
|
f96e0b |
- struct set_color_args
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- struct grub_ieee1275_common_hdr common;
|
|
|
f96e0b |
- grub_ieee1275_cell_t method;
|
|
|
f96e0b |
- grub_ieee1275_cell_t ihandle;
|
|
|
f96e0b |
- grub_ieee1275_cell_t catch_result;
|
|
|
f96e0b |
- grub_ieee1275_cell_t nentries;
|
|
|
f96e0b |
- grub_ieee1275_cell_t table;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
- args;
|
|
|
f96e0b |
- char *buf, *bufptr;
|
|
|
f96e0b |
- unsigned i;
|
|
|
f96e0b |
+ struct grub_ieee1275_common_hdr common;
|
|
|
f96e0b |
+ grub_ieee1275_cell_t method;
|
|
|
f96e0b |
+ grub_ieee1275_cell_t ihandle;
|
|
|
f96e0b |
+ grub_ieee1275_cell_t catch_result;
|
|
|
f96e0b |
+ grub_ieee1275_cell_t nentries;
|
|
|
f96e0b |
+ grub_ieee1275_cell_t table;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+ args;
|
|
|
f96e0b |
+ char *buf, *bufptr;
|
|
|
f96e0b |
+ unsigned i;
|
|
|
f96e0b |
|
|
|
f96e0b |
- if (grub_ieee1275_open (alias->path, &ihandle))
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
+ if (grub_ieee1275_open (alias->path, &ihandle))
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
|
|
|
f96e0b |
- INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3);
|
|
|
f96e0b |
- args.method = (grub_ieee1275_cell_t) "vscsi-report-luns";
|
|
|
f96e0b |
- args.ihandle = ihandle;
|
|
|
f96e0b |
- args.table = 0;
|
|
|
f96e0b |
- args.nentries = 0;
|
|
|
f96e0b |
+ INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3);
|
|
|
f96e0b |
+ args.method = (grub_ieee1275_cell_t) "vscsi-report-luns";
|
|
|
f96e0b |
+ args.ihandle = ihandle;
|
|
|
f96e0b |
+ args.table = 0;
|
|
|
f96e0b |
+ args.nentries = 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
- if (IEEE1275_CALL_ENTRY_FN (&args) == -1 || args.catch_result)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- grub_ieee1275_close (ihandle);
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
+ if (IEEE1275_CALL_ENTRY_FN (&args) == -1 || args.catch_result)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_ieee1275_close (ihandle);
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
|
|
|
f96e0b |
- buf = grub_malloc (grub_strlen (alias->path) + 32);
|
|
|
f96e0b |
- if (!buf)
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
- bufptr = grub_stpcpy (buf, alias->path);
|
|
|
f96e0b |
+ buf = grub_malloc (grub_strlen (alias->path) + 32);
|
|
|
f96e0b |
+ if (!buf)
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+ bufptr = grub_stpcpy (buf, alias->path);
|
|
|
f96e0b |
|
|
|
f96e0b |
- for (i = 0; i < args.nentries; i++)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- grub_uint64_t *ptr;
|
|
|
f96e0b |
+ for (i = 0; i < args.nentries; i++)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_uint64_t *ptr;
|
|
|
f96e0b |
|
|
|
f96e0b |
- ptr = *(grub_uint64_t **) (args.table + 4 + 8 * i);
|
|
|
f96e0b |
- while (*ptr)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- grub_snprintf (bufptr, 32, "/disk@%" PRIxGRUB_UINT64_T, *ptr++);
|
|
|
f96e0b |
- if (dev_iterate_real (buf, buf))
|
|
|
f96e0b |
- return 1;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
- grub_ieee1275_close (ihandle);
|
|
|
f96e0b |
- grub_free (buf);
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
+ ptr = *(grub_uint64_t **) (args.table + 4 + 8 * i);
|
|
|
f96e0b |
+ while (*ptr)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_snprintf (bufptr, 32, "/disk@%" PRIxGRUB_UINT64_T, *ptr++);
|
|
|
f96e0b |
+ dev_iterate_real (buf, buf);
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+ grub_ieee1275_close (ihandle);
|
|
|
f96e0b |
+ grub_free (buf);
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
|
|
|
f96e0b |
- if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS)
|
|
|
f96e0b |
- && grub_strcmp (alias->type, "block") == 0)
|
|
|
f96e0b |
- return dev_iterate_real (alias->path, alias->path);
|
|
|
f96e0b |
+ if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS)
|
|
|
f96e0b |
+ && grub_strcmp (alias->type, "block") == 0)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ dev_iterate_real (alias->path, alias->path);
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ struct grub_ieee1275_devalias child;
|
|
|
f96e0b |
|
|
|
f96e0b |
- return grub_children_iterate (alias->path, dev_iterate);
|
|
|
f96e0b |
+ FOR_IEEE1275_DEVCHILDREN(alias->path, child)
|
|
|
f96e0b |
+ dev_iterate (&child);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+static void
|
|
|
f96e0b |
+scan (void)
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ struct grub_ieee1275_devalias alias;
|
|
|
f96e0b |
+ FOR_IEEE1275_DEVALIASES(alias)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ if (grub_strcmp (alias.type, "block") != 0)
|
|
|
f96e0b |
+ continue;
|
|
|
f96e0b |
+ dev_iterate_real (alias.name, alias.path);
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
|
|
|
f96e0b |
- grub_devalias_iterate (dev_iterate_alias);
|
|
|
f96e0b |
- grub_children_iterate ("/", dev_iterate);
|
|
|
f96e0b |
+ FOR_IEEE1275_DEVCHILDREN("/", alias)
|
|
|
f96e0b |
+ dev_iterate (&alias);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
static int
|
|
|
f96e0b |
diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c
|
|
|
f96e0b |
index 40abaa3..90c092c 100644
|
|
|
f96e0b |
--- a/grub-core/kern/ieee1275/openfw.c
|
|
|
f96e0b |
+++ b/grub-core/kern/ieee1275/openfw.c
|
|
|
f96e0b |
@@ -32,184 +32,227 @@ enum grub_ieee1275_parse_type
|
|
|
f96e0b |
GRUB_PARSE_DEVICE_TYPE
|
|
|
f96e0b |
};
|
|
|
f96e0b |
|
|
|
f96e0b |
-/* Walk children of 'devpath', calling hook for each. */
|
|
|
f96e0b |
-int
|
|
|
f96e0b |
-grub_children_iterate (const char *devpath,
|
|
|
f96e0b |
- int (*hook) (struct grub_ieee1275_devalias *alias))
|
|
|
f96e0b |
+static int
|
|
|
f96e0b |
+fill_alias (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- grub_ieee1275_phandle_t dev;
|
|
|
f96e0b |
- grub_ieee1275_phandle_t child;
|
|
|
f96e0b |
- char *childtype, *childpath;
|
|
|
f96e0b |
- char *childname;
|
|
|
f96e0b |
- int ret = 0;
|
|
|
f96e0b |
+ grub_ssize_t actual;
|
|
|
f96e0b |
|
|
|
f96e0b |
- if (grub_ieee1275_finddevice (devpath, &dev))
|
|
|
f96e0b |
+ if (grub_ieee1275_get_property (alias->phandle, "device_type", alias->type,
|
|
|
f96e0b |
+ IEEE1275_MAX_PROP_LEN, &actual))
|
|
|
f96e0b |
+ alias->type[0] = 0;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (alias->parent_dev == alias->phandle)
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
- if (grub_ieee1275_child (dev, &child))
|
|
|
f96e0b |
+ if (grub_ieee1275_package_to_path (alias->phandle, alias->path,
|
|
|
f96e0b |
+ IEEE1275_MAX_PATH_LEN, &actual))
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
- childtype = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
|
|
f96e0b |
- if (!childtype)
|
|
|
f96e0b |
+ if (grub_strcmp (alias->parent_path, alias->path) == 0)
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
- childpath = grub_malloc (IEEE1275_MAX_PATH_LEN);
|
|
|
f96e0b |
- if (!childpath)
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (grub_ieee1275_get_property (alias->phandle, "name", alias->name,
|
|
|
f96e0b |
+ IEEE1275_MAX_PROP_LEN, &actual))
|
|
|
f96e0b |
+ return 0;
|
|
|
f96e0b |
+ grub_dprintf ("devalias", "device path=%s\n", alias->path);
|
|
|
f96e0b |
+ return 1;
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+void
|
|
|
f96e0b |
+grub_ieee1275_devalias_free (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ grub_free (alias->name);
|
|
|
f96e0b |
+ grub_free (alias->type);
|
|
|
f96e0b |
+ grub_free (alias->path);
|
|
|
f96e0b |
+ grub_free (alias->parent_path);
|
|
|
f96e0b |
+ alias->name = 0;
|
|
|
f96e0b |
+ alias->type = 0;
|
|
|
f96e0b |
+ alias->path = 0;
|
|
|
f96e0b |
+ alias->parent_path = 0;
|
|
|
f96e0b |
+ alias->phandle = GRUB_IEEE1275_PHANDLE_INVALID;
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+void
|
|
|
f96e0b |
+grub_ieee1275_children_peer (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ while (grub_ieee1275_peer (alias->phandle, &alias->phandle) != -1)
|
|
|
f96e0b |
+ if (fill_alias (alias))
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+ grub_ieee1275_devalias_free (alias);
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+void
|
|
|
f96e0b |
+grub_ieee1275_children_first (const char *devpath,
|
|
|
f96e0b |
+ struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ grub_ieee1275_phandle_t dev;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ grub_dprintf ("devalias", "iterating children of %s\n",
|
|
|
f96e0b |
+ devpath);
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ alias->name = 0;
|
|
|
f96e0b |
+ alias->path = 0;
|
|
|
f96e0b |
+ alias->parent_path = 0;
|
|
|
f96e0b |
+ alias->type = 0;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (grub_ieee1275_finddevice (devpath, &dev))
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (grub_ieee1275_child (dev, &alias->phandle))
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ alias->type = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
|
|
f96e0b |
+ if (!alias->type)
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+ alias->path = grub_malloc (IEEE1275_MAX_PATH_LEN);
|
|
|
f96e0b |
+ if (!alias->path)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- grub_free (childtype);
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
+ grub_free (alias->type);
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
- childname = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
|
|
f96e0b |
- if (!childname)
|
|
|
f96e0b |
+ alias->parent_path = grub_strdup (devpath);
|
|
|
f96e0b |
+ if (!alias->parent_path)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- grub_free (childpath);
|
|
|
f96e0b |
- grub_free (childtype);
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
+ grub_free (alias->path);
|
|
|
f96e0b |
+ grub_free (alias->type);
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
- do
|
|
|
f96e0b |
+ alias->name = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
|
|
f96e0b |
+ if (!alias->name)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- struct grub_ieee1275_devalias alias;
|
|
|
f96e0b |
- grub_ssize_t actual;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- if (grub_ieee1275_get_property (child, "device_type", childtype,
|
|
|
f96e0b |
- IEEE1275_MAX_PROP_LEN, &actual))
|
|
|
f96e0b |
- childtype[0] = 0;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- if (dev == child)
|
|
|
f96e0b |
- continue;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- if (grub_ieee1275_package_to_path (child, childpath,
|
|
|
f96e0b |
- IEEE1275_MAX_PATH_LEN, &actual))
|
|
|
f96e0b |
- continue;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- if (grub_strcmp (devpath, childpath) == 0)
|
|
|
f96e0b |
- continue;
|
|
|
f96e0b |
+ grub_free (alias->path);
|
|
|
f96e0b |
+ grub_free (alias->type);
|
|
|
f96e0b |
+ grub_free (alias->parent_path);
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+ if (!fill_alias (alias))
|
|
|
f96e0b |
+ grub_ieee1275_children_peer (alias);
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
|
|
|
f96e0b |
- if (grub_ieee1275_get_property (child, "name", childname,
|
|
|
f96e0b |
- IEEE1275_MAX_PROP_LEN, &actual))
|
|
|
f96e0b |
- continue;
|
|
|
f96e0b |
+static int
|
|
|
f96e0b |
+iterate_recursively (const char *path,
|
|
|
f96e0b |
+ int (*hook) (struct grub_ieee1275_devalias *alias))
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ struct grub_ieee1275_devalias alias;
|
|
|
f96e0b |
+ int ret = 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
- alias.type = childtype;
|
|
|
f96e0b |
- alias.path = childpath;
|
|
|
f96e0b |
- alias.name = childname;
|
|
|
f96e0b |
+ FOR_IEEE1275_DEVCHILDREN(path, alias)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
ret = hook (&alias);
|
|
|
f96e0b |
if (ret)
|
|
|
f96e0b |
break;
|
|
|
f96e0b |
+ ret = iterate_recursively (alias.path, hook);
|
|
|
f96e0b |
+ if (ret)
|
|
|
f96e0b |
+ break;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
- while (grub_ieee1275_peer (child, &child) != -1);
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- grub_free (childname);
|
|
|
f96e0b |
- grub_free (childpath);
|
|
|
f96e0b |
- grub_free (childtype);
|
|
|
f96e0b |
-
|
|
|
f96e0b |
+ grub_ieee1275_devalias_free (&alias);
|
|
|
f96e0b |
return ret;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
int
|
|
|
f96e0b |
grub_ieee1275_devices_iterate (int (*hook) (struct grub_ieee1275_devalias *alias))
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- auto int it_through (struct grub_ieee1275_devalias *alias);
|
|
|
f96e0b |
- int it_through (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- if (hook (alias))
|
|
|
f96e0b |
- return 1;
|
|
|
f96e0b |
- return grub_children_iterate (alias->path, it_through);
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- return grub_children_iterate ("/", it_through);
|
|
|
f96e0b |
+ return iterate_recursively ("/", hook);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
-/* Iterate through all device aliases. This function can be used to
|
|
|
f96e0b |
- find a device of a specific type. */
|
|
|
f96e0b |
-int
|
|
|
f96e0b |
-grub_devalias_iterate (int (*hook) (struct grub_ieee1275_devalias *alias))
|
|
|
f96e0b |
+void
|
|
|
f96e0b |
+grub_ieee1275_devalias_init_iterator (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- grub_ieee1275_phandle_t aliases;
|
|
|
f96e0b |
- char *aliasname, *devtype;
|
|
|
f96e0b |
- grub_ssize_t actual;
|
|
|
f96e0b |
- struct grub_ieee1275_devalias alias;
|
|
|
f96e0b |
- int ret = 0;
|
|
|
f96e0b |
+ alias->name = 0;
|
|
|
f96e0b |
+ alias->path = 0;
|
|
|
f96e0b |
+ alias->parent_path = 0;
|
|
|
f96e0b |
+ alias->type = 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
- if (grub_ieee1275_finddevice ("/aliases", &aliases))
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
+ grub_dprintf ("devalias", "iterating aliases\n");
|
|
|
f96e0b |
|
|
|
f96e0b |
- aliasname = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
|
|
f96e0b |
- if (!aliasname)
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
- devtype = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
|
|
f96e0b |
- if (!devtype)
|
|
|
f96e0b |
+ if (grub_ieee1275_finddevice ("/aliases", &alias->parent_dev))
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ alias->name = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
|
|
f96e0b |
+ if (!alias->name)
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ alias->type = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
|
|
f96e0b |
+ if (!alias->type)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- grub_free (aliasname);
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
+ grub_free (alias->name);
|
|
|
f96e0b |
+ alias->name = 0;
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
- /* Find the first property. */
|
|
|
f96e0b |
- aliasname[0] = '\0';
|
|
|
f96e0b |
+ alias->name[0] = '\0';
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
|
|
|
f96e0b |
- while (grub_ieee1275_next_property (aliases, aliasname, aliasname) > 0)
|
|
|
f96e0b |
+int
|
|
|
f96e0b |
+grub_ieee1275_devalias_next (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ if (!alias->name)
|
|
|
f96e0b |
+ return 0;
|
|
|
f96e0b |
+ while (1)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- grub_ieee1275_phandle_t dev;
|
|
|
f96e0b |
grub_ssize_t pathlen;
|
|
|
f96e0b |
- char *devpath;
|
|
|
f96e0b |
+ grub_ssize_t actual;
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+ if (alias->path)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_free (alias->path);
|
|
|
f96e0b |
+ alias->path = 0;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+ if (grub_ieee1275_next_property (alias->parent_dev, alias->name,
|
|
|
f96e0b |
+ alias->name) <= 0)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_ieee1275_devalias_free (alias);
|
|
|
f96e0b |
+ return 0;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
|
|
|
f96e0b |
- grub_dprintf ("devalias", "devalias name = %s\n", aliasname);
|
|
|
f96e0b |
+ grub_dprintf ("devalias", "devalias name = %s\n", alias->name);
|
|
|
f96e0b |
|
|
|
f96e0b |
- grub_ieee1275_get_property_length (aliases, aliasname, &pathlen);
|
|
|
f96e0b |
+ grub_ieee1275_get_property_length (alias->parent_dev, alias->name, &pathlen);
|
|
|
f96e0b |
|
|
|
f96e0b |
/* The property `name' is a special case we should skip. */
|
|
|
f96e0b |
- if (!grub_strcmp (aliasname, "name"))
|
|
|
f96e0b |
+ if (grub_strcmp (alias->name, "name") == 0)
|
|
|
f96e0b |
continue;
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Sun's OpenBoot often doesn't zero terminate the device alias
|
|
|
f96e0b |
strings, so we will add a NULL byte at the end explicitly. */
|
|
|
f96e0b |
pathlen += 1;
|
|
|
f96e0b |
|
|
|
f96e0b |
- devpath = grub_malloc (pathlen + 1);
|
|
|
f96e0b |
- if (! devpath)
|
|
|
f96e0b |
+ alias->path = grub_malloc (pathlen + 1);
|
|
|
f96e0b |
+ if (! alias->path)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- grub_free (devtype);
|
|
|
f96e0b |
- grub_free (aliasname);
|
|
|
f96e0b |
+ grub_ieee1275_devalias_free (alias);
|
|
|
f96e0b |
return 0;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
- if (grub_ieee1275_get_property (aliases, aliasname, devpath, pathlen,
|
|
|
f96e0b |
- &actual) || actual < 0)
|
|
|
f96e0b |
+ if (grub_ieee1275_get_property (alias->parent_dev, alias->name, alias->path,
|
|
|
f96e0b |
+ pathlen, &actual) || actual < 0)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- grub_dprintf ("devalias", "get_property (%s) failed\n", aliasname);
|
|
|
f96e0b |
- goto nextprop;
|
|
|
f96e0b |
+ grub_dprintf ("devalias", "get_property (%s) failed\n", alias->name);
|
|
|
f96e0b |
+ grub_free (alias->path);
|
|
|
f96e0b |
+ continue;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
if (actual > pathlen)
|
|
|
f96e0b |
actual = pathlen;
|
|
|
f96e0b |
- devpath[actual] = '\0';
|
|
|
f96e0b |
- devpath[pathlen] = '\0';
|
|
|
f96e0b |
+ alias->path[actual] = '\0';
|
|
|
f96e0b |
+ alias->path[pathlen] = '\0';
|
|
|
f96e0b |
|
|
|
f96e0b |
- if (grub_ieee1275_finddevice (devpath, &dev))
|
|
|
f96e0b |
+ if (grub_ieee1275_finddevice (alias->path, &alias->phandle))
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- grub_dprintf ("devalias", "finddevice (%s) failed\n", devpath);
|
|
|
f96e0b |
- goto nextprop;
|
|
|
f96e0b |
+ grub_dprintf ("devalias", "finddevice (%s) failed\n", alias->path);
|
|
|
f96e0b |
+ grub_free (alias->path);
|
|
|
f96e0b |
+ alias->path = 0;
|
|
|
f96e0b |
+ continue;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
- if (grub_ieee1275_get_property (dev, "device_type", devtype,
|
|
|
f96e0b |
+ if (grub_ieee1275_get_property (alias->phandle, "device_type", alias->type,
|
|
|
f96e0b |
IEEE1275_MAX_PROP_LEN, &actual))
|
|
|
f96e0b |
{
|
|
|
f96e0b |
/* NAND device don't have device_type property. */
|
|
|
f96e0b |
- devtype[0] = 0;
|
|
|
f96e0b |
+ alias->type[0] = 0;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- alias.name = aliasname;
|
|
|
f96e0b |
- alias.path = devpath;
|
|
|
f96e0b |
- alias.type = devtype;
|
|
|
f96e0b |
- ret = hook (&alias);
|
|
|
f96e0b |
-
|
|
|
f96e0b |
-nextprop:
|
|
|
f96e0b |
- grub_free (devpath);
|
|
|
f96e0b |
- if (ret)
|
|
|
f96e0b |
- break;
|
|
|
f96e0b |
+ return 1;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- grub_free (devtype);
|
|
|
f96e0b |
- grub_free (aliasname);
|
|
|
f96e0b |
- return ret;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Call the "map" method of /chosen/mmu. */
|
|
|
f96e0b |
@@ -286,37 +329,28 @@ grub_ieee1275_get_devargs (const char *path)
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Get the device path of the Open Firmware node name `path'. */
|
|
|
f96e0b |
-static char *
|
|
|
f96e0b |
+char *
|
|
|
f96e0b |
grub_ieee1275_get_devname (const char *path)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
char *colon = grub_strchr (path, ':');
|
|
|
f96e0b |
- char *newpath = 0;
|
|
|
f96e0b |
int pathlen = grub_strlen (path);
|
|
|
f96e0b |
- auto int match_alias (struct grub_ieee1275_devalias *alias);
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- int match_alias (struct grub_ieee1275_devalias *curalias)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- /* briQ firmware can change capitalization in /chosen/bootpath. */
|
|
|
f96e0b |
- if (grub_strncasecmp (curalias->path, path, pathlen) == 0
|
|
|
f96e0b |
- && curalias->path[pathlen] == 0)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- newpath = grub_strdup (curalias->name);
|
|
|
f96e0b |
- return 1;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
-
|
|
|
f96e0b |
+ struct grub_ieee1275_devalias curalias;
|
|
|
f96e0b |
if (colon)
|
|
|
f96e0b |
pathlen = (int)(colon - path);
|
|
|
f96e0b |
|
|
|
f96e0b |
/* Try to find an alias for this device. */
|
|
|
f96e0b |
- grub_devalias_iterate (match_alias);
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- if (! newpath)
|
|
|
f96e0b |
- newpath = grub_strndup (path, pathlen);
|
|
|
f96e0b |
+ FOR_IEEE1275_DEVALIASES (curalias)
|
|
|
f96e0b |
+ /* briQ firmware can change capitalization in /chosen/bootpath. */
|
|
|
f96e0b |
+ if (grub_strncasecmp (curalias.path, path, pathlen) == 0
|
|
|
f96e0b |
+ && curalias.path[pathlen] == 0)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ char *newpath;
|
|
|
f96e0b |
+ newpath = grub_strdup (curalias.name);
|
|
|
f96e0b |
+ grub_ieee1275_devalias_free (&curalias);
|
|
|
f96e0b |
+ return newpath;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
|
|
|
f96e0b |
- return newpath;
|
|
|
f96e0b |
+ return grub_strndup (path, pathlen);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
static char *
|
|
|
f96e0b |
diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c
|
|
|
f96e0b |
index 7e8e2a7..1acfb73 100644
|
|
|
f96e0b |
--- a/grub-core/net/drivers/ieee1275/ofnet.c
|
|
|
f96e0b |
+++ b/grub-core/net/drivers/ieee1275/ofnet.c
|
|
|
f96e0b |
@@ -198,27 +198,6 @@ grub_ieee1275_net_config_real (const char *devpath, char **device, char **path)
|
|
|
f96e0b |
}
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
-static char *
|
|
|
f96e0b |
-find_alias (const char *fullname)
|
|
|
f96e0b |
-{
|
|
|
f96e0b |
- char *ret = NULL;
|
|
|
f96e0b |
- auto int find_alias_hook (struct grub_ieee1275_devalias *alias);
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- int find_alias_hook (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- if (grub_strcmp (alias->path, fullname) == 0)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- ret = grub_strdup (alias->name);
|
|
|
f96e0b |
- return 1;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- grub_devalias_iterate (find_alias_hook);
|
|
|
f96e0b |
- grub_errno = GRUB_ERR_NONE;
|
|
|
f96e0b |
- return ret;
|
|
|
f96e0b |
-}
|
|
|
f96e0b |
-
|
|
|
f96e0b |
static int
|
|
|
f96e0b |
search_net_devices (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
@@ -308,7 +287,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
card->driver = NULL;
|
|
|
f96e0b |
card->data = ofdata;
|
|
|
f96e0b |
card->flags = 0;
|
|
|
f96e0b |
- shortname = find_alias (alias->path);
|
|
|
f96e0b |
+ shortname = grub_ieee1275_get_devname (alias->path);
|
|
|
f96e0b |
card->name = grub_xasprintf ("ofnet_%s", shortname ? : alias->path);
|
|
|
f96e0b |
card->idle_poll_delay_ms = 10;
|
|
|
f96e0b |
grub_free (shortname);
|
|
|
f96e0b |
diff --git a/grub-core/term/ieee1275/escc.c b/grub-core/term/ieee1275/escc.c
|
|
|
f96e0b |
index 6d7b636..40de3f7 100644
|
|
|
f96e0b |
--- a/grub-core/term/ieee1275/escc.c
|
|
|
f96e0b |
+++ b/grub-core/term/ieee1275/escc.c
|
|
|
f96e0b |
@@ -200,6 +200,7 @@ struct grub_serial_driver grub_escc_driver =
|
|
|
f96e0b |
};
|
|
|
f96e0b |
|
|
|
f96e0b |
static struct grub_escc_descriptor escc_descs[2];
|
|
|
f96e0b |
+static char *macio = 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
static void
|
|
|
f96e0b |
add_device (grub_addr_t addr, int channel)
|
|
|
f96e0b |
@@ -243,38 +244,34 @@ add_device (grub_addr_t addr, int channel)
|
|
|
f96e0b |
grub_serial_register (port);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
+static int
|
|
|
f96e0b |
+find_macio (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ if (grub_strcmp (alias->type, "mac-io") != 0)
|
|
|
f96e0b |
+ return 0;
|
|
|
f96e0b |
+ macio = grub_strdup (alias->path);
|
|
|
f96e0b |
+ return 1;
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
+
|
|
|
f96e0b |
GRUB_MOD_INIT (escc)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- char *macio = 0;
|
|
|
f96e0b |
- char *escc = 0;
|
|
|
f96e0b |
grub_uint32_t macio_addr[4];
|
|
|
f96e0b |
grub_uint32_t escc_addr[2];
|
|
|
f96e0b |
grub_ieee1275_phandle_t dev;
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- auto int find_macio (struct grub_ieee1275_devalias *alias);
|
|
|
f96e0b |
- auto int find_escc (struct grub_ieee1275_devalias *alias);
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- int find_macio (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- if (grub_strcmp (alias->type, "mac-io") != 0)
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
- macio = grub_strdup (alias->path);
|
|
|
f96e0b |
- return 1;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- int find_escc (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- if (grub_strcmp (alias->type, "escc") != 0)
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
- escc = grub_strdup (alias->path);
|
|
|
f96e0b |
- return 1;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
+ struct grub_ieee1275_devalias alias;
|
|
|
f96e0b |
+ char *escc = 0;
|
|
|
f96e0b |
|
|
|
f96e0b |
grub_ieee1275_devices_iterate (find_macio);
|
|
|
f96e0b |
if (!macio)
|
|
|
f96e0b |
return;
|
|
|
f96e0b |
|
|
|
f96e0b |
- grub_children_iterate (macio, find_escc);
|
|
|
f96e0b |
+ FOR_IEEE1275_DEVCHILDREN(macio, alias)
|
|
|
f96e0b |
+ if (grub_strcmp (alias.type, "escc") == 0)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ escc = grub_strdup (alias.path);
|
|
|
f96e0b |
+ break;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+ grub_ieee1275_devalias_free (&alias);
|
|
|
f96e0b |
if (!escc)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
grub_free (macio);
|
|
|
f96e0b |
diff --git a/grub-core/term/ieee1275/serial.c b/grub-core/term/ieee1275/serial.c
|
|
|
f96e0b |
index 09a5a03..cda97d0 100644
|
|
|
f96e0b |
--- a/grub-core/term/ieee1275/serial.c
|
|
|
f96e0b |
+++ b/grub-core/term/ieee1275/serial.c
|
|
|
f96e0b |
@@ -180,58 +180,53 @@ ofserial_hash_add (char *devpath, char *curcan)
|
|
|
f96e0b |
return p;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
-void
|
|
|
f96e0b |
-grub_ofserial_init (void)
|
|
|
f96e0b |
+static void
|
|
|
f96e0b |
+dev_iterate_real (struct grub_ieee1275_devalias *alias,
|
|
|
f96e0b |
+ int use_name)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- auto int dev_iterate_real (struct grub_ieee1275_devalias *alias,
|
|
|
f96e0b |
- int use_name);
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- int dev_iterate_real (struct grub_ieee1275_devalias *alias,
|
|
|
f96e0b |
- int use_name)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- struct ofserial_hash_ent *op;
|
|
|
f96e0b |
+ struct ofserial_hash_ent *op;
|
|
|
f96e0b |
|
|
|
f96e0b |
- if (grub_strcmp (alias->type, "serial") != 0)
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
+ if (grub_strcmp (alias->type, "serial") != 0)
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
|
|
|
f96e0b |
- grub_dprintf ("serial", "serial name = %s, path = %s\n", alias->name,
|
|
|
f96e0b |
- alias->path);
|
|
|
f96e0b |
+ grub_dprintf ("serial", "serial name = %s, path = %s\n", alias->name,
|
|
|
f96e0b |
+ alias->path);
|
|
|
f96e0b |
|
|
|
f96e0b |
- op = ofserial_hash_find (alias->path);
|
|
|
f96e0b |
- if (!op)
|
|
|
f96e0b |
+ op = ofserial_hash_find (alias->path);
|
|
|
f96e0b |
+ if (!op)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ char *name = grub_strdup (use_name ? alias->name : alias->path);
|
|
|
f96e0b |
+ char *can = grub_strdup (alias->path);
|
|
|
f96e0b |
+ if (!name || !can)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- char *name = grub_strdup (use_name ? alias->name : alias->path);
|
|
|
f96e0b |
- char *can = grub_strdup (alias->path);
|
|
|
f96e0b |
- if (!name || !can)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- grub_errno = GRUB_ERR_NONE;
|
|
|
f96e0b |
- grub_free (name);
|
|
|
f96e0b |
- grub_free (can);
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
- op = ofserial_hash_add (name, can);
|
|
|
f96e0b |
+ grub_errno = GRUB_ERR_NONE;
|
|
|
f96e0b |
+ grub_free (name);
|
|
|
f96e0b |
+ grub_free (can);
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
}
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
+ op = ofserial_hash_add (name, can);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
+ return;
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
|
|
|
f96e0b |
- auto int dev_iterate_alias (struct grub_ieee1275_devalias *alias);
|
|
|
f96e0b |
- int dev_iterate_alias (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- return dev_iterate_real (alias, 1);
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- auto int dev_iterate (struct grub_ieee1275_devalias *alias);
|
|
|
f96e0b |
- int dev_iterate (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- return dev_iterate_real (alias, 0);
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
+static int
|
|
|
f96e0b |
+dev_iterate (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ dev_iterate_real (alias, 0);
|
|
|
f96e0b |
+ return 0;
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
|
|
|
f96e0b |
+void
|
|
|
f96e0b |
+grub_ofserial_init (void)
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
unsigned i;
|
|
|
f96e0b |
grub_err_t err;
|
|
|
f96e0b |
+ struct grub_ieee1275_devalias alias;
|
|
|
f96e0b |
|
|
|
f96e0b |
- grub_devalias_iterate (dev_iterate_alias);
|
|
|
f96e0b |
- grub_ieee1275_devices_iterate (dev_iterate);
|
|
|
f96e0b |
+ FOR_IEEE1275_DEVALIASES(alias)
|
|
|
f96e0b |
+ dev_iterate_real (&alias, 1);
|
|
|
f96e0b |
|
|
|
f96e0b |
+ grub_ieee1275_devices_iterate (dev_iterate);
|
|
|
f96e0b |
|
|
|
f96e0b |
for (i = 0; i < ARRAY_SIZE (ofserial_hash); i++)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
diff --git a/grub-core/video/ieee1275.c b/grub-core/video/ieee1275.c
|
|
|
f96e0b |
index 84f9b89..93feeb5 100644
|
|
|
f96e0b |
--- a/grub-core/video/ieee1275.c
|
|
|
f96e0b |
+++ b/grub-core/video/ieee1275.c
|
|
|
f96e0b |
@@ -54,22 +54,22 @@ set_video_mode (unsigned width __attribute__ ((unused)),
|
|
|
f96e0b |
/* TODO */
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
+static int
|
|
|
f96e0b |
+find_display_hook (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ if (grub_strcmp (alias->type, "display") == 0)
|
|
|
f96e0b |
+ {
|
|
|
f96e0b |
+ grub_dprintf ("video", "Found display %s\n", alias->path);
|
|
|
f96e0b |
+ display = grub_strdup (alias->path);
|
|
|
f96e0b |
+ return 1;
|
|
|
f96e0b |
+ }
|
|
|
f96e0b |
+ return 0;
|
|
|
f96e0b |
+}
|
|
|
f96e0b |
+
|
|
|
f96e0b |
static void
|
|
|
f96e0b |
find_display (void)
|
|
|
f96e0b |
{
|
|
|
f96e0b |
- auto int hook (struct grub_ieee1275_devalias *alias);
|
|
|
f96e0b |
- int hook (struct grub_ieee1275_devalias *alias)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- if (grub_strcmp (alias->type, "display") == 0)
|
|
|
f96e0b |
- {
|
|
|
f96e0b |
- grub_dprintf ("video", "Found display %s\n", alias->path);
|
|
|
f96e0b |
- display = grub_strdup (alias->path);
|
|
|
f96e0b |
- return 1;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
- return 0;
|
|
|
f96e0b |
- }
|
|
|
f96e0b |
-
|
|
|
f96e0b |
- grub_ieee1275_devices_iterate (hook);
|
|
|
f96e0b |
+ grub_ieee1275_devices_iterate (find_display_hook);
|
|
|
f96e0b |
}
|
|
|
f96e0b |
|
|
|
f96e0b |
static grub_err_t
|
|
|
f96e0b |
diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h
|
|
|
f96e0b |
index ee9b707..1e8ba6f 100644
|
|
|
f96e0b |
--- a/include/grub/ieee1275/ieee1275.h
|
|
|
f96e0b |
+++ b/include/grub/ieee1275/ieee1275.h
|
|
|
f96e0b |
@@ -24,13 +24,6 @@
|
|
|
f96e0b |
#include <grub/types.h>
|
|
|
f96e0b |
#include <grub/machine/ieee1275.h>
|
|
|
f96e0b |
|
|
|
f96e0b |
-struct grub_ieee1275_devalias
|
|
|
f96e0b |
-{
|
|
|
f96e0b |
- char *name;
|
|
|
f96e0b |
- char *path;
|
|
|
f96e0b |
- char *type;
|
|
|
f96e0b |
-};
|
|
|
f96e0b |
-
|
|
|
f96e0b |
struct grub_ieee1275_mem_region
|
|
|
f96e0b |
{
|
|
|
f96e0b |
unsigned int start;
|
|
|
f96e0b |
@@ -64,6 +57,18 @@ struct grub_ieee1275_common_hdr
|
|
|
f96e0b |
typedef grub_uint32_t grub_ieee1275_ihandle_t;
|
|
|
f96e0b |
typedef grub_uint32_t grub_ieee1275_phandle_t;
|
|
|
f96e0b |
|
|
|
f96e0b |
+#define GRUB_IEEE1275_PHANDLE_INVALID ((grub_ieee1275_phandle_t) -1)
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+struct grub_ieee1275_devalias
|
|
|
f96e0b |
+{
|
|
|
f96e0b |
+ char *name;
|
|
|
f96e0b |
+ char *path;
|
|
|
f96e0b |
+ char *type;
|
|
|
f96e0b |
+ char *parent_path;
|
|
|
f96e0b |
+ grub_ieee1275_phandle_t phandle;
|
|
|
f96e0b |
+ grub_ieee1275_phandle_t parent_dev;
|
|
|
f96e0b |
+};
|
|
|
f96e0b |
+
|
|
|
f96e0b |
extern void (*EXPORT_VAR(grub_ieee1275_net_config)) (const char *dev,
|
|
|
f96e0b |
char **device,
|
|
|
f96e0b |
char **path);
|
|
|
f96e0b |
@@ -192,10 +197,6 @@ int EXPORT_FUNC(grub_ieee1275_set_color) (grub_ieee1275_ihandle_t ihandle,
|
|
|
f96e0b |
int EXPORT_FUNC(grub_ieee1275_milliseconds) (grub_uint32_t *msecs);
|
|
|
f96e0b |
|
|
|
f96e0b |
|
|
|
f96e0b |
-int EXPORT_FUNC(grub_devalias_iterate)
|
|
|
f96e0b |
- (int (*hook) (struct grub_ieee1275_devalias *alias));
|
|
|
f96e0b |
-int EXPORT_FUNC(grub_children_iterate) (const char *devpath,
|
|
|
f96e0b |
- int (*hook) (struct grub_ieee1275_devalias *alias));
|
|
|
f96e0b |
grub_err_t EXPORT_FUNC(grub_claimmap) (grub_addr_t addr, grub_size_t size);
|
|
|
f96e0b |
|
|
|
f96e0b |
int
|
|
|
f96e0b |
@@ -210,5 +211,19 @@ int EXPORT_FUNC(grub_ieee1275_devices_iterate) (int (*hook)
|
|
|
f96e0b |
char *EXPORT_FUNC(grub_ieee1275_get_aliasdevname) (const char *path);
|
|
|
f96e0b |
char *EXPORT_FUNC(grub_ieee1275_canonicalise_devname) (const char *path);
|
|
|
f96e0b |
char *EXPORT_FUNC(grub_ieee1275_get_device_type) (const char *path);
|
|
|
f96e0b |
+char *EXPORT_FUNC(grub_ieee1275_get_devname) (const char *path);
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+void EXPORT_FUNC(grub_ieee1275_devalias_init_iterator) (struct grub_ieee1275_devalias *alias);
|
|
|
f96e0b |
+void EXPORT_FUNC(grub_ieee1275_devalias_free) (struct grub_ieee1275_devalias *alias);
|
|
|
f96e0b |
+int EXPORT_FUNC(grub_ieee1275_devalias_next) (struct grub_ieee1275_devalias *alias);
|
|
|
f96e0b |
+void EXPORT_FUNC(grub_ieee1275_children_peer) (struct grub_ieee1275_devalias *alias);
|
|
|
f96e0b |
+void EXPORT_FUNC(grub_ieee1275_children_first) (const char *devpath,
|
|
|
f96e0b |
+ struct grub_ieee1275_devalias *alias);
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+#define FOR_IEEE1275_DEVALIASES(alias) for (grub_ieee1275_devalias_init_iterator (&(alias)); grub_ieee1275_devalias_next (&(alias));)
|
|
|
f96e0b |
+
|
|
|
f96e0b |
+#define FOR_IEEE1275_DEVCHILDREN(devpath, alias) for (grub_ieee1275_children_first ((devpath), &(alias)); \
|
|
|
f96e0b |
+ (alias).name; \
|
|
|
f96e0b |
+ grub_ieee1275_children_peer (&(alias)))
|
|
|
f96e0b |
|
|
|
f96e0b |
#endif /* ! GRUB_IEEE1275_HEADER */
|
|
|
f96e0b |
--
|
|
|
f96e0b |
1.8.2.1
|
|
|
f96e0b |
|