/* openfw.c -- Open firmware support functions. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
{
};
/* Walk children of 'devpath', calling hook for each. */
int
{
char *childname;
int ret = 0;
return 0;
return 0;
if (!childtype)
return 0;
if (!childpath)
{
return 0;
}
if (!childname)
{
return 0;
}
do
{
childtype[0] = 0;
continue;
continue;
continue;
continue;
if (ret)
break;
}
return ret;
}
int
{
{
return 1;
}
}
/* Iterate through all device aliases. This function can be used to
find a device of a specific type. */
int
{
int ret = 0;
return 0;
if (!aliasname)
return 0;
if (!devtype)
{
return 0;
}
/* Find the first property. */
aliasname[0] = '\0';
{
char *devpath;
/* The property `name' is a special case we should skip. */
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;
if (! devpath)
{
return 0;
}
{
goto nextprop;
}
{
goto nextprop;
}
{
/* NAND device don't have device_type property. */
devtype[0] = 0;
}
if (ret)
break;
}
return ret;
}
int
{
struct map_args {
#ifdef GRUB_MACHINE_SPARC64
#endif
} args;
#ifdef GRUB_MACHINE_SPARC64
7,
#else
6,
#endif
1);
#ifdef GRUB_MACHINE_SPARC64
#endif
return -1;
return args.catch_result;
}
int
{
return -1;
{
grub_printf ("map failed: address 0x%llx, size 0x%llx\n",
return -1;
}
return 0;
}
/* Get the device arguments of the Open Firmware node name `path'. */
static char *
{
if (! colon)
return 0;
}
/* Get the device path of the Open Firmware node name `path'. */
static char *
{
char *newpath = 0;
{
{
return 1;
}
return 0;
}
if (colon)
/* Try to find an alias for this device. */
if (! newpath)
return newpath;
}
static char *
{
char *ret = 0;
/* We need to know what type of device it is in order to parse the full
file path properly. */
{
goto fail;
}
{
"device %s lacks a device_type property", device);
goto fail;
}
switch (ptype)
{
case GRUB_PARSE_DEVICE:
break;
case GRUB_PARSE_DEVICE_TYPE:
break;
case GRUB_PARSE_FILENAME:
{
char *comma;
char *args;
goto unknown;
if (!args)
/* Shouldn't happen. */
return 0;
/* The syntax of the device arguments is defined in the CHRP and PReP
IEEE1275 bindings: "[partition][,[filename]]". */
if (comma)
{
/* Make sure filepath has leading backslash. */
if (filepath[0] != '\\')
else
}
}
break;
case GRUB_PARSE_PARTITION:
{
char *comma;
char *args;
goto unknown;
if (!args)
/* Shouldn't happen. */
return 0;
if (!comma)
else
/* Consistently provide numbered partitions to GRUB.
OpenBOOT traditionally uses alphabetical partition
specifiers. */
}
break;
default:
}
fail:
return ret;
}
char *
{
}
char *
{
}
char *
{
}
/* Convert a device name from IEEE1275 syntax to GRUB syntax. */
char *
{
char *encoding;
{
/* GRUB partition 1 is OF partition 0. */
partno++;
}
else
return encoding;
}
/* Resolve aliases. */
char *
{
struct canon_args
{
}
args;
int i;
for (i = 0; i < 2; i++)
{
if (!buf)
return NULL;
return 0;
{
continue;
}
return buf;
}
/* Shouldn't reach here. */
return NULL;
}