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
|
@ -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,38 +244,34 @@ add_device (grub_addr_t addr, int channel)
|
|||
grub_serial_register (port);
|
||||
}
|
||||
|
||||
static int
|
||||
find_macio (struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
if (grub_strcmp (alias->type, "mac-io") != 0)
|
||||
return 0;
|
||||
macio = grub_strdup (alias->path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (grub_strcmp (alias->type, "mac-io") != 0)
|
||||
return 0;
|
||||
macio = grub_strdup (alias->path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int find_escc (struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
if (grub_strcmp (alias->type, "escc") != 0)
|
||||
return 0;
|
||||
escc = grub_strdup (alias->path);
|
||||
return 1;
|
||||
}
|
||||
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,58 +180,53 @@ ofserial_hash_add (char *devpath, char *curcan)
|
|||
return p;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
grub_dprintf ("serial", "serial name = %s, path = %s\n", alias->name,
|
||||
alias->path);
|
||||
|
||||
op = ofserial_hash_find (alias->path);
|
||||
if (!op)
|
||||
{
|
||||
char *name = grub_strdup (use_name ? alias->name : alias->path);
|
||||
char *can = grub_strdup (alias->path);
|
||||
if (!name || !can)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
grub_free (name);
|
||||
grub_free (can);
|
||||
return;
|
||||
}
|
||||
op = ofserial_hash_add (name, can);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static int
|
||||
dev_iterate (struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
dev_iterate_real (alias, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
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,
|
||||
int use_name)
|
||||
{
|
||||
struct ofserial_hash_ent *op;
|
||||
|
||||
if (grub_strcmp (alias->type, "serial") != 0)
|
||||
return 0;
|
||||
|
||||
grub_dprintf ("serial", "serial name = %s, path = %s\n", alias->name,
|
||||
alias->path);
|
||||
|
||||
op = ofserial_hash_find (alias->path);
|
||||
if (!op)
|
||||
{
|
||||
char *name = grub_strdup (use_name ? alias->name : alias->path);
|
||||
char *can = grub_strdup (alias->path);
|
||||
if (!name || !can)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
grub_free (name);
|
||||
grub_free (can);
|
||||
return 0;
|
||||
}
|
||||
op = ofserial_hash_add (name, can);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto int dev_iterate_alias (struct grub_ieee1275_devalias *alias);
|
||||
int dev_iterate_alias (struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue