2005-04-21 Hollis Blanchard <hollis@penguinppc.org>

* include/grub/powerpc/ieee1275/ieee1275.h
	(grub_ieee1275_encode_devname): New prototype.
	(grub_ieee1275_get_filename): Likewise.
	* kern/powerpc/ieee1275/init.c (grub_translate_ieee175_path): New
	function.
	(grub_set_prefix): Likewise.
	(grub_machine_init): Call grub_set_prefix.
	* kern/powerpc/ieee1275/openfw.c: Fix typos.
	(grub_parse_type): New enum.
	(grub_ieee1275_get_devargs): New function.
	(grub_ieee1275_get_devname): Likewise.
	(grub_ieee1275_parse_args): Likewise.
	(grub_ieee1275_get_filename): Likewise.
	(grub_ieee1275_encode_devname): Likewise.
This commit is contained in:
hollisb 2005-04-22 02:32:37 +00:00
parent be36992037
commit ed16607e13
4 changed files with 241 additions and 3 deletions

View file

@ -46,6 +46,69 @@ abort (void)
for (;;);
}
/* Translate an OF filesystem path (separated by backslashes), into a GRUB
path (separated by forward slashes). */
static void
grub_translate_ieee1275_path (char *filepath)
{
char *backslash;
backslash = grub_strchr (filepath, '\\');
while (backslash != 0)
{
*backslash = '/';
backslash = grub_strchr (filepath, '\\');
}
}
static void
grub_set_prefix (void)
{
char bootpath[64]; /* XXX check length */
char *filename;
char *prefix;
grub_ieee1275_phandle_t chosen;
grub_ieee1275_finddevice ("/chosen", &chosen);
if (grub_ieee1275_get_property (chosen, "bootpath", &bootpath,
sizeof (bootpath), 0))
{
/* Should never happen. */
grub_printf ("/chosen/bootpath property missing!\n");
grub_env_set ("prefix", "");
return;
}
/* Transform an OF device path to a GRUB path. */
prefix = grub_ieee1275_encode_devname (bootpath);
filename = grub_ieee1275_get_filename (bootpath);
if (filename)
{
char *newprefix;
char *lastslash = grub_strrchr (filename, '\\');
/* Truncate at last directory. */
if (lastslash)
{
*lastslash = '\0';
grub_translate_ieee1275_path (filename);
newprefix = grub_malloc (grub_strlen (prefix)
+ grub_strlen (filename));
grub_sprintf (newprefix, "%s%s", prefix, filename);
grub_free (prefix);
prefix = newprefix;
}
}
grub_env_set ("prefix", prefix);
grub_free (filename);
grub_free (prefix);
}
void
grub_machine_init (void)
{
@ -65,7 +128,7 @@ grub_machine_init (void)
}
grub_mm_init_region ((void *) grub_heap_start, grub_heap_len);
grub_env_set ("prefix", "");
grub_set_prefix ();
grub_ofdisk_init ();
}