Allow IEEE1275 ports on path even if it wasn't detected automatically.
Needed on OpenBIOS due to incomplete device tree.
This commit is contained in:
parent
ac4fea7998
commit
aa1af9bbda
4 changed files with 76 additions and 26 deletions
|
@ -1,3 +1,8 @@
|
|||
2013-04-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Allow IEEE1275 ports on path even if it wasn't detected automatically.
|
||||
Needed on OpenBIOS due to incomplete device tree.
|
||||
|
||||
2013-04-14 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/disk/ieee1275/ofdisk.c: Iterate over bootpath even if it
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <grub/mm.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/i18n.h>
|
||||
#include <grub/ieee1275/console.h>
|
||||
|
||||
#define IEEE1275_IHANDLE_INVALID ((grub_ieee1275_cell_t) 0)
|
||||
|
||||
|
@ -216,11 +217,59 @@ dev_iterate (struct grub_ieee1275_devalias *alias)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static const char *
|
||||
add_port (struct ofserial_hash_ent *ent)
|
||||
{
|
||||
struct grub_serial_port *port;
|
||||
char *ptr;
|
||||
grub_err_t err;
|
||||
|
||||
if (!ent->shortest)
|
||||
return NULL;
|
||||
|
||||
port = grub_zalloc (sizeof (*port));
|
||||
if (!port)
|
||||
return NULL;
|
||||
port->name = grub_malloc (sizeof ("ieee1275/")
|
||||
+ grub_strlen (ent->shortest));
|
||||
port->elem = ent;
|
||||
if (!port->name)
|
||||
return NULL;
|
||||
ptr = grub_stpcpy (port->name, "ieee1275/");
|
||||
grub_strcpy (ptr, ent->shortest);
|
||||
|
||||
port->driver = &grub_ofserial_driver;
|
||||
err = grub_serial_config_defaults (port);
|
||||
if (err)
|
||||
grub_print_error ();
|
||||
|
||||
grub_serial_register (port);
|
||||
|
||||
return port->name;
|
||||
}
|
||||
|
||||
const char *
|
||||
grub_ofserial_add_port (const char *path)
|
||||
{
|
||||
struct ofserial_hash_ent *ent;
|
||||
char *name = grub_strdup (path);
|
||||
char *can = grub_strdup (path);
|
||||
|
||||
if (!name || ! can)
|
||||
{
|
||||
grub_free (name);
|
||||
grub_free (can);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ent = ofserial_hash_add (name, can);
|
||||
return add_port (ent);
|
||||
}
|
||||
|
||||
void
|
||||
grub_ofserial_init (void)
|
||||
{
|
||||
unsigned i;
|
||||
grub_err_t err;
|
||||
struct grub_ieee1275_devalias alias;
|
||||
|
||||
FOR_IEEE1275_DEVALIASES(alias)
|
||||
|
@ -230,32 +279,9 @@ grub_ofserial_init (void)
|
|||
|
||||
for (i = 0; i < ARRAY_SIZE (ofserial_hash); i++)
|
||||
{
|
||||
static struct ofserial_hash_ent *ent;
|
||||
struct ofserial_hash_ent *ent;
|
||||
for (ent = ofserial_hash[i]; ent; ent = ent->next)
|
||||
{
|
||||
struct grub_serial_port *port;
|
||||
char *ptr;
|
||||
if (!ent->shortest)
|
||||
continue;
|
||||
|
||||
port = grub_zalloc (sizeof (*port));
|
||||
if (!port)
|
||||
return;
|
||||
port->name = grub_malloc (sizeof ("ieee1275/")
|
||||
+ grub_strlen (ent->shortest));
|
||||
port->elem = ent;
|
||||
if (!port->name)
|
||||
return;
|
||||
ptr = grub_stpcpy (port->name, "ieee1275/");
|
||||
grub_strcpy (ptr, ent->shortest);
|
||||
|
||||
port->driver = &grub_ofserial_driver;
|
||||
err = grub_serial_config_defaults (port);
|
||||
if (err)
|
||||
grub_print_error ();
|
||||
|
||||
grub_serial_register (port);
|
||||
}
|
||||
add_port (ent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||
#include <grub/machine/kernel.h>
|
||||
#endif
|
||||
#ifdef GRUB_MACHINE_IEEE1275
|
||||
#include <grub/ieee1275/console.h>
|
||||
#endif
|
||||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
|
@ -149,6 +152,19 @@ grub_serial_find (const char *name)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef GRUB_MACHINE_IEEE1275
|
||||
if (!port && grub_memcmp (name, "ieee1275/", sizeof ("ieee1275/") - 1) == 0)
|
||||
{
|
||||
name = grub_ofserial_add_port (&name[sizeof ("ieee1275/") - 1]);
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
FOR_SERIAL_PORTS (port)
|
||||
if (grub_strcmp (port->name, name) == 0)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
return port;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,4 +28,7 @@ void grub_console_init_lately (void);
|
|||
/* Finish the console system. */
|
||||
void grub_console_fini (void);
|
||||
|
||||
const char *
|
||||
grub_ofserial_add_port (const char *name);
|
||||
|
||||
#endif /* ! GRUB_CONSOLE_MACHINE_HEADER */
|
||||
|
|
Loading…
Reference in a new issue