2007-12-30 08:52:06 +00:00
|
|
|
/* openfw.c -- Open firmware support functions. */
|
2004-03-28 21:52:02 +00:00
|
|
|
/*
|
2004-04-04 13:46:03 +00:00
|
|
|
* GRUB -- GRand Unified Bootloader
|
2009-12-05 01:43:17 +00:00
|
|
|
* Copyright (C) 2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
|
2004-03-28 21:52:02 +00:00
|
|
|
*
|
2007-07-21 23:32:33 +00:00
|
|
|
* GRUB is free software: you can redistribute it and/or modify
|
2004-03-28 21:52:02 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2007-07-21 23:32:33 +00:00
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
2004-03-28 21:52:02 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2007-07-21 23:32:33 +00:00
|
|
|
* GRUB is distributed in the hope that it will be useful,
|
2004-03-28 21:52:02 +00:00
|
|
|
* 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
|
2007-07-21 23:32:33 +00:00
|
|
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
2004-03-28 21:52:02 +00:00
|
|
|
*/
|
|
|
|
|
2007-02-13 03:20:16 +00:00
|
|
|
#include <grub/types.h>
|
2004-04-04 13:46:03 +00:00
|
|
|
#include <grub/err.h>
|
|
|
|
#include <grub/misc.h>
|
|
|
|
#include <grub/mm.h>
|
2005-08-03 22:53:51 +00:00
|
|
|
#include <grub/machine/kernel.h>
|
|
|
|
#include <grub/ieee1275/ieee1275.h>
|
2004-03-28 21:52:02 +00:00
|
|
|
|
2005-04-22 02:32:37 +00:00
|
|
|
enum grub_ieee1275_parse_type
|
|
|
|
{
|
|
|
|
GRUB_PARSE_FILENAME,
|
|
|
|
GRUB_PARSE_PARTITION,
|
|
|
|
};
|
|
|
|
|
2004-10-13 23:43:44 +00:00
|
|
|
/* Walk children of 'devpath', calling hook for each. */
|
2009-04-24 12:05:54 +00:00
|
|
|
int
|
2004-10-13 23:43:44 +00:00
|
|
|
grub_children_iterate (char *devpath,
|
2009-04-24 12:05:54 +00:00
|
|
|
int (*hook) (struct grub_ieee1275_devalias *alias))
|
2004-10-13 23:43:44 +00:00
|
|
|
{
|
|
|
|
grub_ieee1275_phandle_t dev;
|
|
|
|
grub_ieee1275_phandle_t child;
|
2009-04-22 09:46:54 +00:00
|
|
|
char *childtype, *childpath;
|
|
|
|
char *childname, *fullname;
|
2009-04-24 12:05:54 +00:00
|
|
|
int ret = 0;
|
2004-10-13 23:43:44 +00:00
|
|
|
|
2005-10-01 Hollis Blanchard <hollis@penguinppc.org>
* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Cast `size' to long.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_next_property):
Remove `flags' argument. All callers changed.
* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_ROOT): Removed.
(IEEE1275_IHANDLE_INVALID): New variable.
(IEEE1275_CELL_INVALID): New variable.
(grub_ieee1275_finddevice, grub_ieee1275_get_property,
grub_ieee1275_get_property_length, grub_ieee1275_instance_to_package,
grub_ieee1275_package_to_path, grub_ieee1275_instance_to_path,
grub_ieee1275_peer, grub_ieee1275_child, grub_ieee1275_open,
grub_ieee1275_claim, grub_ieee1275_set_property): Error-check return
codes from Open Firmware. All callers updated.
(grub_ieee1275_next_property): Directly return Open Firmware return
code.
* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options):
Standardize error checking from `grub_ieee1275_get_property'.
* kern/powerpc/ieee1275/openfw.c (grub_devalias_iterate): Rename
`devalias' to `aliases'. Correct comments. Consolidate error paths.
2006-10-01 08:30:09 +00:00
|
|
|
if (grub_ieee1275_finddevice (devpath, &dev))
|
2009-04-24 12:05:54 +00:00
|
|
|
return 0;
|
2004-10-13 23:43:44 +00:00
|
|
|
|
2005-10-01 Hollis Blanchard <hollis@penguinppc.org>
* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Cast `size' to long.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_next_property):
Remove `flags' argument. All callers changed.
* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_ROOT): Removed.
(IEEE1275_IHANDLE_INVALID): New variable.
(IEEE1275_CELL_INVALID): New variable.
(grub_ieee1275_finddevice, grub_ieee1275_get_property,
grub_ieee1275_get_property_length, grub_ieee1275_instance_to_package,
grub_ieee1275_package_to_path, grub_ieee1275_instance_to_path,
grub_ieee1275_peer, grub_ieee1275_child, grub_ieee1275_open,
grub_ieee1275_claim, grub_ieee1275_set_property): Error-check return
codes from Open Firmware. All callers updated.
(grub_ieee1275_next_property): Directly return Open Firmware return
code.
* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options):
Standardize error checking from `grub_ieee1275_get_property'.
* kern/powerpc/ieee1275/openfw.c (grub_devalias_iterate): Rename
`devalias' to `aliases'. Correct comments. Consolidate error paths.
2006-10-01 08:30:09 +00:00
|
|
|
if (grub_ieee1275_child (dev, &child))
|
2009-04-24 12:05:54 +00:00
|
|
|
return 0;
|
2004-10-13 23:43:44 +00:00
|
|
|
|
2009-04-22 09:46:54 +00:00
|
|
|
childtype = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
|
|
|
if (!childtype)
|
2009-04-24 12:05:54 +00:00
|
|
|
return 0;
|
2009-04-22 09:46:54 +00:00
|
|
|
childpath = grub_malloc (IEEE1275_MAX_PATH_LEN);
|
|
|
|
if (!childpath)
|
|
|
|
{
|
|
|
|
grub_free (childtype);
|
2009-04-24 12:05:54 +00:00
|
|
|
return 0;
|
2009-04-22 09:46:54 +00:00
|
|
|
}
|
|
|
|
childname = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
|
|
|
if (!childname)
|
|
|
|
{
|
|
|
|
grub_free (childpath);
|
|
|
|
grub_free (childtype);
|
2009-04-24 12:05:54 +00:00
|
|
|
return 0;
|
2009-04-22 09:46:54 +00:00
|
|
|
}
|
|
|
|
fullname = grub_malloc (IEEE1275_MAX_PATH_LEN);
|
|
|
|
if (!fullname)
|
|
|
|
{
|
|
|
|
grub_free (childname);
|
|
|
|
grub_free (childpath);
|
|
|
|
grub_free (childtype);
|
2009-04-24 12:05:54 +00:00
|
|
|
return 0;
|
2009-04-22 09:46:54 +00:00
|
|
|
}
|
|
|
|
|
2004-10-13 23:43:44 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
struct grub_ieee1275_devalias alias;
|
2009-04-11 03:09:17 +00:00
|
|
|
grub_ssize_t actual;
|
2004-10-13 23:43:44 +00:00
|
|
|
|
2009-05-04 22:46:55 +00:00
|
|
|
if (grub_ieee1275_get_property (child, "device_type", childtype,
|
2009-07-10 20:19:08 +00:00
|
|
|
IEEE1275_MAX_PROP_LEN, &actual))
|
2004-10-13 23:43:44 +00:00
|
|
|
continue;
|
|
|
|
|
2009-07-10 20:19:08 +00:00
|
|
|
if (grub_ieee1275_package_to_path (child, childpath,
|
|
|
|
IEEE1275_MAX_PATH_LEN, &actual))
|
2004-10-13 23:43:44 +00:00
|
|
|
continue;
|
|
|
|
|
2009-05-04 22:46:55 +00:00
|
|
|
if (grub_ieee1275_get_property (child, "name", childname,
|
2009-07-11 03:59:15 +00:00
|
|
|
IEEE1275_MAX_PROP_LEN, &actual))
|
2004-10-13 23:43:44 +00:00
|
|
|
continue;
|
|
|
|
|
2005-04-22 02:32:37 +00:00
|
|
|
grub_sprintf (fullname, "%s/%s", devpath, childname);
|
2004-10-13 23:43:44 +00:00
|
|
|
|
|
|
|
alias.type = childtype;
|
|
|
|
alias.path = childpath;
|
|
|
|
alias.name = fullname;
|
2009-04-24 12:05:54 +00:00
|
|
|
ret = hook (&alias);
|
|
|
|
if (ret)
|
|
|
|
break;
|
2004-10-13 23:43:44 +00:00
|
|
|
}
|
|
|
|
while (grub_ieee1275_peer (child, &child));
|
|
|
|
|
2009-04-22 09:46:54 +00:00
|
|
|
grub_free (fullname);
|
|
|
|
grub_free (childname);
|
|
|
|
grub_free (childpath);
|
|
|
|
grub_free (childtype);
|
|
|
|
|
2009-04-24 12:05:54 +00:00
|
|
|
return ret;
|
2004-10-13 23:43:44 +00:00
|
|
|
}
|
|
|
|
|
2005-04-22 02:32:37 +00:00
|
|
|
/* Iterate through all device aliases. This function can be used to
|
2004-03-28 21:52:02 +00:00
|
|
|
find a device of a specific type. */
|
2009-04-24 12:05:54 +00:00
|
|
|
int
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_devalias_iterate (int (*hook) (struct grub_ieee1275_devalias *alias))
|
2004-03-28 21:52:02 +00:00
|
|
|
{
|
2005-10-01 Hollis Blanchard <hollis@penguinppc.org>
* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Cast `size' to long.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_next_property):
Remove `flags' argument. All callers changed.
* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_ROOT): Removed.
(IEEE1275_IHANDLE_INVALID): New variable.
(IEEE1275_CELL_INVALID): New variable.
(grub_ieee1275_finddevice, grub_ieee1275_get_property,
grub_ieee1275_get_property_length, grub_ieee1275_instance_to_package,
grub_ieee1275_package_to_path, grub_ieee1275_instance_to_path,
grub_ieee1275_peer, grub_ieee1275_child, grub_ieee1275_open,
grub_ieee1275_claim, grub_ieee1275_set_property): Error-check return
codes from Open Firmware. All callers updated.
(grub_ieee1275_next_property): Directly return Open Firmware return
code.
* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options):
Standardize error checking from `grub_ieee1275_get_property'.
* kern/powerpc/ieee1275/openfw.c (grub_devalias_iterate): Rename
`devalias' to `aliases'. Correct comments. Consolidate error paths.
2006-10-01 08:30:09 +00:00
|
|
|
grub_ieee1275_phandle_t aliases;
|
2009-04-22 09:46:54 +00:00
|
|
|
char *aliasname, *devtype;
|
2009-04-11 03:09:17 +00:00
|
|
|
grub_ssize_t actual;
|
2004-04-04 13:46:03 +00:00
|
|
|
struct grub_ieee1275_devalias alias;
|
2009-04-24 12:05:54 +00:00
|
|
|
int ret = 0;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
2005-10-01 Hollis Blanchard <hollis@penguinppc.org>
* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Cast `size' to long.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_next_property):
Remove `flags' argument. All callers changed.
* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_ROOT): Removed.
(IEEE1275_IHANDLE_INVALID): New variable.
(IEEE1275_CELL_INVALID): New variable.
(grub_ieee1275_finddevice, grub_ieee1275_get_property,
grub_ieee1275_get_property_length, grub_ieee1275_instance_to_package,
grub_ieee1275_package_to_path, grub_ieee1275_instance_to_path,
grub_ieee1275_peer, grub_ieee1275_child, grub_ieee1275_open,
grub_ieee1275_claim, grub_ieee1275_set_property): Error-check return
codes from Open Firmware. All callers updated.
(grub_ieee1275_next_property): Directly return Open Firmware return
code.
* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options):
Standardize error checking from `grub_ieee1275_get_property'.
* kern/powerpc/ieee1275/openfw.c (grub_devalias_iterate): Rename
`devalias' to `aliases'. Correct comments. Consolidate error paths.
2006-10-01 08:30:09 +00:00
|
|
|
if (grub_ieee1275_finddevice ("/aliases", &aliases))
|
2009-04-24 12:05:54 +00:00
|
|
|
return 0;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
2009-04-22 09:46:54 +00:00
|
|
|
aliasname = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
|
|
|
if (!aliasname)
|
2009-04-24 12:05:54 +00:00
|
|
|
return 0;
|
2009-04-22 09:46:54 +00:00
|
|
|
devtype = grub_malloc (IEEE1275_MAX_PROP_LEN);
|
|
|
|
if (!devtype)
|
|
|
|
{
|
|
|
|
grub_free (aliasname);
|
2009-04-24 12:05:54 +00:00
|
|
|
return 0;
|
2009-04-22 09:46:54 +00:00
|
|
|
}
|
|
|
|
|
2005-10-01 Hollis Blanchard <hollis@penguinppc.org>
* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Cast `size' to long.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_next_property):
Remove `flags' argument. All callers changed.
* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_ROOT): Removed.
(IEEE1275_IHANDLE_INVALID): New variable.
(IEEE1275_CELL_INVALID): New variable.
(grub_ieee1275_finddevice, grub_ieee1275_get_property,
grub_ieee1275_get_property_length, grub_ieee1275_instance_to_package,
grub_ieee1275_package_to_path, grub_ieee1275_instance_to_path,
grub_ieee1275_peer, grub_ieee1275_child, grub_ieee1275_open,
grub_ieee1275_claim, grub_ieee1275_set_property): Error-check return
codes from Open Firmware. All callers updated.
(grub_ieee1275_next_property): Directly return Open Firmware return
code.
* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options):
Standardize error checking from `grub_ieee1275_get_property'.
* kern/powerpc/ieee1275/openfw.c (grub_devalias_iterate): Rename
`devalias' to `aliases'. Correct comments. Consolidate error paths.
2006-10-01 08:30:09 +00:00
|
|
|
/* Find the first property. */
|
2004-03-28 21:52:02 +00:00
|
|
|
aliasname[0] = '\0';
|
|
|
|
|
2005-10-01 Hollis Blanchard <hollis@penguinppc.org>
* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Cast `size' to long.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_next_property):
Remove `flags' argument. All callers changed.
* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_ROOT): Removed.
(IEEE1275_IHANDLE_INVALID): New variable.
(IEEE1275_CELL_INVALID): New variable.
(grub_ieee1275_finddevice, grub_ieee1275_get_property,
grub_ieee1275_get_property_length, grub_ieee1275_instance_to_package,
grub_ieee1275_package_to_path, grub_ieee1275_instance_to_path,
grub_ieee1275_peer, grub_ieee1275_child, grub_ieee1275_open,
grub_ieee1275_claim, grub_ieee1275_set_property): Error-check return
codes from Open Firmware. All callers updated.
(grub_ieee1275_next_property): Directly return Open Firmware return
code.
* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options):
Standardize error checking from `grub_ieee1275_get_property'.
* kern/powerpc/ieee1275/openfw.c (grub_devalias_iterate): Rename
`devalias' to `aliases'. Correct comments. Consolidate error paths.
2006-10-01 08:30:09 +00:00
|
|
|
while (grub_ieee1275_next_property (aliases, aliasname, aliasname))
|
2004-03-28 21:52:02 +00:00
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_ieee1275_phandle_t dev;
|
2006-09-26 03:49:41 +00:00
|
|
|
grub_ssize_t pathlen;
|
2004-03-28 21:52:02 +00:00
|
|
|
char *devpath;
|
2005-10-01 Hollis Blanchard <hollis@penguinppc.org>
* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Cast `size' to long.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_next_property):
Remove `flags' argument. All callers changed.
* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_ROOT): Removed.
(IEEE1275_IHANDLE_INVALID): New variable.
(IEEE1275_CELL_INVALID): New variable.
(grub_ieee1275_finddevice, grub_ieee1275_get_property,
grub_ieee1275_get_property_length, grub_ieee1275_instance_to_package,
grub_ieee1275_package_to_path, grub_ieee1275_instance_to_path,
grub_ieee1275_peer, grub_ieee1275_child, grub_ieee1275_open,
grub_ieee1275_claim, grub_ieee1275_set_property): Error-check return
codes from Open Firmware. All callers updated.
(grub_ieee1275_next_property): Directly return Open Firmware return
code.
* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options):
Standardize error checking from `grub_ieee1275_get_property'.
* kern/powerpc/ieee1275/openfw.c (grub_devalias_iterate): Rename
`devalias' to `aliases'. Correct comments. Consolidate error paths.
2006-10-01 08:30:09 +00:00
|
|
|
|
2008-01-20 17:20:48 +00:00
|
|
|
grub_dprintf ("devalias", "devalias name = %s\n", aliasname);
|
|
|
|
|
2005-10-01 Hollis Blanchard <hollis@penguinppc.org>
* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Cast `size' to long.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_next_property):
Remove `flags' argument. All callers changed.
* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_ROOT): Removed.
(IEEE1275_IHANDLE_INVALID): New variable.
(IEEE1275_CELL_INVALID): New variable.
(grub_ieee1275_finddevice, grub_ieee1275_get_property,
grub_ieee1275_get_property_length, grub_ieee1275_instance_to_package,
grub_ieee1275_package_to_path, grub_ieee1275_instance_to_path,
grub_ieee1275_peer, grub_ieee1275_child, grub_ieee1275_open,
grub_ieee1275_claim, grub_ieee1275_set_property): Error-check return
codes from Open Firmware. All callers updated.
(grub_ieee1275_next_property): Directly return Open Firmware return
code.
* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options):
Standardize error checking from `grub_ieee1275_get_property'.
* kern/powerpc/ieee1275/openfw.c (grub_devalias_iterate): Rename
`devalias' to `aliases'. Correct comments. Consolidate error paths.
2006-10-01 08:30:09 +00:00
|
|
|
grub_ieee1275_get_property_length (aliases, aliasname, &pathlen);
|
2004-11-16 21:59:11 +00:00
|
|
|
|
|
|
|
/* The property `name' is a special case we should skip. */
|
|
|
|
if (!grub_strcmp (aliasname, "name"))
|
2005-10-01 Hollis Blanchard <hollis@penguinppc.org>
* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Cast `size' to long.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_next_property):
Remove `flags' argument. All callers changed.
* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_ROOT): Removed.
(IEEE1275_IHANDLE_INVALID): New variable.
(IEEE1275_CELL_INVALID): New variable.
(grub_ieee1275_finddevice, grub_ieee1275_get_property,
grub_ieee1275_get_property_length, grub_ieee1275_instance_to_package,
grub_ieee1275_package_to_path, grub_ieee1275_instance_to_path,
grub_ieee1275_peer, grub_ieee1275_child, grub_ieee1275_open,
grub_ieee1275_claim, grub_ieee1275_set_property): Error-check return
codes from Open Firmware. All callers updated.
(grub_ieee1275_next_property): Directly return Open Firmware return
code.
* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options):
Standardize error checking from `grub_ieee1275_get_property'.
* kern/powerpc/ieee1275/openfw.c (grub_devalias_iterate): Rename
`devalias' to `aliases'. Correct comments. Consolidate error paths.
2006-10-01 08:30:09 +00:00
|
|
|
continue;
|
|
|
|
|
2009-04-22 09:46:54 +00:00
|
|
|
/* 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;
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
devpath = grub_malloc (pathlen);
|
2004-03-28 21:52:02 +00:00
|
|
|
if (! devpath)
|
2009-04-22 09:46:54 +00:00
|
|
|
{
|
|
|
|
grub_free (devtype);
|
|
|
|
grub_free (aliasname);
|
2009-04-24 12:05:54 +00:00
|
|
|
return 0;
|
2009-04-22 09:46:54 +00:00
|
|
|
}
|
2004-03-28 21:52:02 +00:00
|
|
|
|
2005-10-01 Hollis Blanchard <hollis@penguinppc.org>
* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Cast `size' to long.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_next_property):
Remove `flags' argument. All callers changed.
* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_ROOT): Removed.
(IEEE1275_IHANDLE_INVALID): New variable.
(IEEE1275_CELL_INVALID): New variable.
(grub_ieee1275_finddevice, grub_ieee1275_get_property,
grub_ieee1275_get_property_length, grub_ieee1275_instance_to_package,
grub_ieee1275_package_to_path, grub_ieee1275_instance_to_path,
grub_ieee1275_peer, grub_ieee1275_child, grub_ieee1275_open,
grub_ieee1275_claim, grub_ieee1275_set_property): Error-check return
codes from Open Firmware. All callers updated.
(grub_ieee1275_next_property): Directly return Open Firmware return
code.
* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options):
Standardize error checking from `grub_ieee1275_get_property'.
* kern/powerpc/ieee1275/openfw.c (grub_devalias_iterate): Rename
`devalias' to `aliases'. Correct comments. Consolidate error paths.
2006-10-01 08:30:09 +00:00
|
|
|
if (grub_ieee1275_get_property (aliases, aliasname, devpath, pathlen,
|
2004-03-28 21:52:02 +00:00
|
|
|
&actual))
|
2008-01-20 17:20:48 +00:00
|
|
|
{
|
|
|
|
grub_dprintf ("devalias", "get_property (%s) failed\n", aliasname);
|
|
|
|
goto nextprop;
|
|
|
|
}
|
2009-04-22 09:46:54 +00:00
|
|
|
devpath [actual] = '\0';
|
2005-10-01 Hollis Blanchard <hollis@penguinppc.org>
* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Cast `size' to long.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_next_property):
Remove `flags' argument. All callers changed.
* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_ROOT): Removed.
(IEEE1275_IHANDLE_INVALID): New variable.
(IEEE1275_CELL_INVALID): New variable.
(grub_ieee1275_finddevice, grub_ieee1275_get_property,
grub_ieee1275_get_property_length, grub_ieee1275_instance_to_package,
grub_ieee1275_package_to_path, grub_ieee1275_instance_to_path,
grub_ieee1275_peer, grub_ieee1275_child, grub_ieee1275_open,
grub_ieee1275_claim, grub_ieee1275_set_property): Error-check return
codes from Open Firmware. All callers updated.
(grub_ieee1275_next_property): Directly return Open Firmware return
code.
* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options):
Standardize error checking from `grub_ieee1275_get_property'.
* kern/powerpc/ieee1275/openfw.c (grub_devalias_iterate): Rename
`devalias' to `aliases'. Correct comments. Consolidate error paths.
2006-10-01 08:30:09 +00:00
|
|
|
|
|
|
|
if (grub_ieee1275_finddevice (devpath, &dev))
|
2008-01-20 17:20:48 +00:00
|
|
|
{
|
|
|
|
grub_dprintf ("devalias", "finddevice (%s) failed\n", devpath);
|
|
|
|
goto nextprop;
|
|
|
|
}
|
2005-10-01 Hollis Blanchard <hollis@penguinppc.org>
* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Cast `size' to long.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_next_property):
Remove `flags' argument. All callers changed.
* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_ROOT): Removed.
(IEEE1275_IHANDLE_INVALID): New variable.
(IEEE1275_CELL_INVALID): New variable.
(grub_ieee1275_finddevice, grub_ieee1275_get_property,
grub_ieee1275_get_property_length, grub_ieee1275_instance_to_package,
grub_ieee1275_package_to_path, grub_ieee1275_instance_to_path,
grub_ieee1275_peer, grub_ieee1275_child, grub_ieee1275_open,
grub_ieee1275_claim, grub_ieee1275_set_property): Error-check return
codes from Open Firmware. All callers updated.
(grub_ieee1275_next_property): Directly return Open Firmware return
code.
* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options):
Standardize error checking from `grub_ieee1275_get_property'.
* kern/powerpc/ieee1275/openfw.c (grub_devalias_iterate): Rename
`devalias' to `aliases'. Correct comments. Consolidate error paths.
2006-10-01 08:30:09 +00:00
|
|
|
|
|
|
|
if (grub_ieee1275_get_property (dev, "device_type", devtype,
|
2009-07-10 20:19:08 +00:00
|
|
|
IEEE1275_MAX_PROP_LEN, &actual))
|
2008-01-20 17:20:48 +00:00
|
|
|
{
|
2008-04-25 19:41:51 +00:00
|
|
|
/* NAND device don't have device_type property. */
|
|
|
|
devtype[0] = 0;
|
2008-01-20 17:20:48 +00:00
|
|
|
}
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
alias.name = aliasname;
|
2005-10-01 Hollis Blanchard <hollis@penguinppc.org>
* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Cast `size' to long.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_next_property):
Remove `flags' argument. All callers changed.
* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_ROOT): Removed.
(IEEE1275_IHANDLE_INVALID): New variable.
(IEEE1275_CELL_INVALID): New variable.
(grub_ieee1275_finddevice, grub_ieee1275_get_property,
grub_ieee1275_get_property_length, grub_ieee1275_instance_to_package,
grub_ieee1275_package_to_path, grub_ieee1275_instance_to_path,
grub_ieee1275_peer, grub_ieee1275_child, grub_ieee1275_open,
grub_ieee1275_claim, grub_ieee1275_set_property): Error-check return
codes from Open Firmware. All callers updated.
(grub_ieee1275_next_property): Directly return Open Firmware return
code.
* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options):
Standardize error checking from `grub_ieee1275_get_property'.
* kern/powerpc/ieee1275/openfw.c (grub_devalias_iterate): Rename
`devalias' to `aliases'. Correct comments. Consolidate error paths.
2006-10-01 08:30:09 +00:00
|
|
|
alias.path = devpath;
|
2004-03-28 21:52:02 +00:00
|
|
|
alias.type = devtype;
|
2009-04-24 12:05:54 +00:00
|
|
|
ret = hook (&alias);
|
2005-10-01 Hollis Blanchard <hollis@penguinppc.org>
* disk/ieee1275/ofdisk.c (grub_ofdisk_iterate): Cast `size' to long.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_next_property):
Remove `flags' argument. All callers changed.
* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_ROOT): Removed.
(IEEE1275_IHANDLE_INVALID): New variable.
(IEEE1275_CELL_INVALID): New variable.
(grub_ieee1275_finddevice, grub_ieee1275_get_property,
grub_ieee1275_get_property_length, grub_ieee1275_instance_to_package,
grub_ieee1275_package_to_path, grub_ieee1275_instance_to_path,
grub_ieee1275_peer, grub_ieee1275_child, grub_ieee1275_open,
grub_ieee1275_claim, grub_ieee1275_set_property): Error-check return
codes from Open Firmware. All callers updated.
(grub_ieee1275_next_property): Directly return Open Firmware return
code.
* kern/powerpc/ieee1275/cmain.c (grub_ieee1275_find_options):
Standardize error checking from `grub_ieee1275_get_property'.
* kern/powerpc/ieee1275/openfw.c (grub_devalias_iterate): Rename
`devalias' to `aliases'. Correct comments. Consolidate error paths.
2006-10-01 08:30:09 +00:00
|
|
|
|
|
|
|
nextprop:
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_free (devpath);
|
2009-04-24 12:05:54 +00:00
|
|
|
if (ret)
|
|
|
|
break;
|
2004-03-28 21:52:02 +00:00
|
|
|
}
|
|
|
|
|
2009-04-22 09:46:54 +00:00
|
|
|
grub_free (devtype);
|
|
|
|
grub_free (aliasname);
|
2009-04-24 12:05:54 +00:00
|
|
|
return ret;
|
2004-03-28 21:52:02 +00:00
|
|
|
}
|
2004-10-29 02:45:14 +00:00
|
|
|
|
|
|
|
/* Call the "map" method of /chosen/mmu. */
|
2004-12-27 Marco Gerards <metgerards@student.han.nl>
* genmk.rb: Handle the `Program' class in the main loop. Written
by Johan Rydberg <jrydberg@gnu.org>.
(Program): New class.
(programs): New variable.
* boot/powerpc/ieee1275/cmain.c: Include <grub/machine/ieee1275.h>
instead of "grub/machine/ieee1275.h". Include <grub/kernel.h>
instead of "grub/kernel.h". Include <grub/machine/init.h>.
(help_arch): Function removed.
* conf/powerpc-ieee1275.rmk (grubof_HEADERS): Add
`powerpc/libgcc.h' and `loader.h'.
(pkgdata_PROGRAMS): New variable.
(sbin_UTILITIES): Variable removed.
(grub_emu_SOURCES): Added kern/powerpc/cache.S.
(grubof_SOURCES): Variable re-defined so it only includes the
core functionality.
(grubof_CFLAGS): Remove `-DGRUBOF'.
(pkgdata_MODULES, fshelp_mod_SOURCES, fshelp_mod_CFLAGS,
(fat_mod_SOURCES, fat_mod_CFLAGS, ext2_mod_SOURCES)
(ext2_mod_CFLAGS, ufs_mod_SOURCES, ufs_mod_CFLAGS)
(minix_mod_SOURCES, minix_mod_CFLAGS, hfs_mod_SOURCES)
(hfs_mod_CFLAGS, jfs_mod_SOURCES, jfs_mod_CFLAGS)
(iso9660_mod_SOURCES, iso9660_mod_CFLAGS, _linux_mod_SOURCES)
(_linux_mod_CFLAGS, linux_mod_SOURCES, linux_mod_CFLAGS)
(normal_mod_SOURCES, normal_mod_CFLAGS, normal_mod_ASFLAGS)
(hello_mod_SOURCES, hello_mod_CFLAGS, boot_mod_SOURCES)
(boot_mod_CFLAGS, terminal_mod_SOURCES, terminal_mod_CFLAGS)
(ls_mod_SOURCES, ls_mod_CFLAGS, cmp_mod_SOURCES, cmp_mod_CFLAGS)
(cat_mod_SOURCES, cat_mod_CFLAGS, font_mod_SOURCES)
(font_mod_CFLAGS, amiga_mod_SOURCES, amiga_mod_CFLAGS)
(apple_mod_SOURCES, apple_mod_CFLAGS, pc_mod_SOURCES)
(pc_mod_CFLAGS): New variables.
* disk/powerpc/ieee1275/ofdisk.c: Include <grub/machine/init.h>.
(grub_ofdisk_iterate): Add a prototype for `dev_iterate'.
* include/grub/dl.h (grub_arch_dl_sync_caches): New prototype.
* include/grub/loader.h (grub_os_area_addr, grub_os_area_size):
Moved from here...
* include/grub/i386/pc/init.h (grub_os_area_addr)
(rub_os_area_size): ... to here.
* include/grub/powerpc/ieee1275/ieee1275.h
(grub_ieee1275_entry_fn): Export symbol.
* include/grub/powerpc/ieee1275/init.h: New file.
* include/grub/powerpc/libgcc.h: Likewise.
* include/grub/cache.h: Likewise.
* kern/powerpc/cache.S: Likewise. Written by Hollis Blanchard
<hollis@penguinppc.org>.
* kern/dl.c: Include <grub/cache.h>.
(grub_dl_flush_cache): New function.
(grub_dl_load_core): Call `grub_dl_flush_cache' to flush the cache
for this module.
* kern/powerpc/ieee1275/init.c (grub_ofdisk_init)
(grub_console_init): Removed prototypes.
(grub_machine_init): Don't initialize the modules anymore.
* kern/powerpc/ieee1275/openfw.c (grub_map): Make the function
static.
* include/grub/powerpc/types.h (GRUB_HOST_WORDS_LITTLEENDIAN):
Macro undef removed.
(GRUB_HOST_WORDS_BIGENDIAN): New macro.
* kern/powerpc/dl.c (grub_arch_dl_relocate_symbols): Add
relocation `R_PPC_REL32'. Return an error when the relocation is
unknown.
* Makefile.in (DATA): Add `$(pkgdata_PROGRAMS)'.
* kern/i386/pc/init.c (grub_arch_sync_caches): New function.
* util/misc.c (grub_arch_sync_caches): Likewise.
2004-12-27 13:46:20 +00:00
|
|
|
static int
|
2004-10-29 02:45:14 +00:00
|
|
|
grub_map (grub_addr_t phys, grub_addr_t virt, grub_uint32_t size,
|
|
|
|
grub_uint8_t mode)
|
|
|
|
{
|
|
|
|
struct map_args {
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
* disk/ieee1275/nand.c (grub_nand_open): All ieee1275 call arg
slots are of type grub_ieee1275_cell_t.
(grub_nand_read): Likewise.
* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_INVALID,
IEEE1275_IHANDLE_INVALID): Use grub_ieee1275_cell_t since these
macros are used to compare values in arg/ret block of the call.
(grub_ieee1275_finddevice, grub_ieee1275_get_property,
grub_ieee1275_next_property, grub_ieee1275_get_property_length,
grub_ieee1275_instance_to_package, grub_ieee1275_package_to_path,
grub_ieee1275_instance_to_path, grub_ieee1275_write,
grub_ieee1275_read, grub_ieee1275_seek, grub_ieee1275_peer,
grub_ieee1275_child, grub_ieee1275_parent, grub_ieee1275_open,
grub_ieee1275_close, grub_ieee1275_set_property,
grub_ieee1275_set_color): All ieee1275 call arg slots are of type
grub_ieee1275_cell_t.
* kern/ieee1275/openfw.c (grub_map): Likewise.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_ihandle_t,
grub_ieee1275_phandle_t): Define as grub_unit32_t type.
2009-04-11 03:07:58 +00:00
|
|
|
grub_ieee1275_cell_t method;
|
|
|
|
grub_ieee1275_cell_t ihandle;
|
|
|
|
grub_ieee1275_cell_t mode;
|
|
|
|
grub_ieee1275_cell_t size;
|
|
|
|
grub_ieee1275_cell_t virt;
|
|
|
|
grub_ieee1275_cell_t phys;
|
|
|
|
grub_ieee1275_cell_t catch_result;
|
2004-10-29 02:45:14 +00:00
|
|
|
} args;
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1);
|
* disk/ieee1275/nand.c (grub_nand_open): All ieee1275 call arg
slots are of type grub_ieee1275_cell_t.
(grub_nand_read): Likewise.
* kern/ieee1275/ieee1275.c (IEEE1275_PHANDLE_INVALID,
IEEE1275_IHANDLE_INVALID): Use grub_ieee1275_cell_t since these
macros are used to compare values in arg/ret block of the call.
(grub_ieee1275_finddevice, grub_ieee1275_get_property,
grub_ieee1275_next_property, grub_ieee1275_get_property_length,
grub_ieee1275_instance_to_package, grub_ieee1275_package_to_path,
grub_ieee1275_instance_to_path, grub_ieee1275_write,
grub_ieee1275_read, grub_ieee1275_seek, grub_ieee1275_peer,
grub_ieee1275_child, grub_ieee1275_parent, grub_ieee1275_open,
grub_ieee1275_close, grub_ieee1275_set_property,
grub_ieee1275_set_color): All ieee1275 call arg slots are of type
grub_ieee1275_cell_t.
* kern/ieee1275/openfw.c (grub_map): Likewise.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_ihandle_t,
grub_ieee1275_phandle_t): Define as grub_unit32_t type.
2009-04-11 03:07:58 +00:00
|
|
|
args.method = (grub_ieee1275_cell_t) "map";
|
2008-01-20 14:08:54 +00:00
|
|
|
args.ihandle = grub_ieee1275_mmu;
|
2004-10-29 02:45:14 +00:00
|
|
|
args.phys = phys;
|
|
|
|
args.virt = virt;
|
|
|
|
args.size = size;
|
|
|
|
args.mode = mode; /* Format is WIMG0PP. */
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return args.catch_result;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
grub_claimmap (grub_addr_t addr, grub_size_t size)
|
|
|
|
{
|
|
|
|
if (grub_ieee1275_claim (addr, size, 0, 0))
|
|
|
|
return -1;
|
2005-01-03 17:44:25 +00:00
|
|
|
|
2005-05-01 03:45:36 +00:00
|
|
|
if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_REAL_MODE)
|
|
|
|
&& grub_map (addr, addr, size, 0x00))
|
2004-10-29 02:45:14 +00:00
|
|
|
{
|
2009-04-30 01:18:43 +00:00
|
|
|
grub_printf ("map failed: address 0x%llx, size 0x%llx\n",
|
|
|
|
(long long) addr, (long long) size);
|
2004-10-29 02:45:14 +00:00
|
|
|
grub_ieee1275_release (addr, size);
|
|
|
|
return -1;
|
|
|
|
}
|
2005-01-03 17:44:25 +00:00
|
|
|
|
2004-10-29 02:45:14 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2005-03-26 17:34:50 +00:00
|
|
|
|
2005-04-22 02:32:37 +00:00
|
|
|
/* Get the device arguments of the Open Firmware node name `path'. */
|
|
|
|
static char *
|
|
|
|
grub_ieee1275_get_devargs (const char *path)
|
|
|
|
{
|
|
|
|
char *colon = grub_strchr (path, ':');
|
|
|
|
|
|
|
|
if (! colon)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return grub_strdup (colon + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the device path of the Open Firmware node name `path'. */
|
|
|
|
static char *
|
|
|
|
grub_ieee1275_get_devname (const char *path)
|
|
|
|
{
|
|
|
|
char *colon = grub_strchr (path, ':');
|
|
|
|
char *newpath = 0;
|
|
|
|
int pathlen = grub_strlen (path);
|
|
|
|
auto int match_alias (struct grub_ieee1275_devalias *alias);
|
|
|
|
|
|
|
|
int match_alias (struct grub_ieee1275_devalias *curalias)
|
|
|
|
{
|
|
|
|
/* briQ firmware can change capitalization in /chosen/bootpath. */
|
|
|
|
if (! grub_strncasecmp (curalias->path, path, pathlen))
|
|
|
|
{
|
2005-11-04 03:18:12 +00:00
|
|
|
newpath = grub_strdup (curalias->name);
|
2005-04-22 02:32:37 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (colon)
|
|
|
|
pathlen = (int)(colon - path);
|
|
|
|
|
|
|
|
/* Try to find an alias for this device. */
|
|
|
|
grub_devalias_iterate (match_alias);
|
|
|
|
|
|
|
|
if (! newpath)
|
2005-11-04 03:18:12 +00:00
|
|
|
newpath = grub_strndup (path, pathlen);
|
2005-04-22 02:32:37 +00:00
|
|
|
|
|
|
|
return newpath;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
grub_ieee1275_parse_args (const char *path, enum grub_ieee1275_parse_type ptype)
|
|
|
|
{
|
|
|
|
char type[64]; /* XXX check size. */
|
|
|
|
char *device = grub_ieee1275_get_devname (path);
|
|
|
|
char *args = grub_ieee1275_get_devargs (path);
|
|
|
|
char *ret = 0;
|
|
|
|
grub_ieee1275_phandle_t dev;
|
|
|
|
|
|
|
|
if (!args)
|
|
|
|
/* Shouldn't happen. */
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* We need to know what type of device it is in order to parse the full
|
|
|
|
file path properly. */
|
|
|
|
if (grub_ieee1275_finddevice (device, &dev))
|
|
|
|
{
|
|
|
|
grub_error (GRUB_ERR_UNKNOWN_DEVICE, "Device %s not found\n", device);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
if (grub_ieee1275_get_property (dev, "device_type", &type, sizeof type, 0))
|
|
|
|
{
|
|
|
|
grub_error (GRUB_ERR_UNKNOWN_DEVICE,
|
|
|
|
"Device %s lacks a device_type property\n", device);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!grub_strcmp ("block", type))
|
|
|
|
{
|
|
|
|
/* The syntax of the device arguments is defined in the CHRP and PReP
|
|
|
|
IEEE1275 bindings: "[partition][,[filename]]". */
|
|
|
|
char *comma = grub_strchr (args, ',');
|
|
|
|
|
|
|
|
if (ptype == GRUB_PARSE_FILENAME)
|
|
|
|
{
|
|
|
|
if (comma)
|
|
|
|
{
|
|
|
|
char *filepath = comma + 1;
|
|
|
|
|
|
|
|
ret = grub_malloc (grub_strlen (filepath) + 1);
|
|
|
|
/* Make sure filepath has leading backslash. */
|
|
|
|
if (filepath[0] != '\\')
|
|
|
|
grub_sprintf (ret, "\\%s", filepath);
|
|
|
|
else
|
|
|
|
grub_strcpy (ret, filepath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ptype == GRUB_PARSE_PARTITION)
|
|
|
|
{
|
|
|
|
if (!comma)
|
|
|
|
ret = grub_strdup (args);
|
|
|
|
else
|
|
|
|
ret = grub_strndup (args, (grub_size_t)(comma - args));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* XXX Handle net devices by configuring & registering a grub_net_dev
|
|
|
|
here, then return its name?
|
|
|
|
Example path: "net:<server ip>,<file name>,<client ip>,<gateway
|
|
|
|
ip>,<bootp retries>,<tftp retries>". */
|
|
|
|
grub_printf ("Unsupported type %s for device %s\n", type, device);
|
|
|
|
}
|
|
|
|
|
|
|
|
fail:
|
|
|
|
grub_free (device);
|
|
|
|
grub_free (args);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
grub_ieee1275_get_filename (const char *path)
|
|
|
|
{
|
|
|
|
return grub_ieee1275_parse_args (path, GRUB_PARSE_FILENAME);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert a device name from IEEE1275 syntax to GRUB syntax. */
|
|
|
|
char *
|
|
|
|
grub_ieee1275_encode_devname (const char *path)
|
|
|
|
{
|
|
|
|
char *device = grub_ieee1275_get_devname (path);
|
|
|
|
char *partition = grub_ieee1275_parse_args (path, GRUB_PARSE_PARTITION);
|
|
|
|
char *encoding;
|
|
|
|
|
|
|
|
if (partition)
|
|
|
|
{
|
|
|
|
unsigned int partno = grub_strtoul (partition, 0, 0);
|
2005-05-01 03:45:36 +00:00
|
|
|
|
2006-10-26 23:11:22 +00:00
|
|
|
if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS))
|
|
|
|
/* GRUB partition 1 is OF partition 0. */
|
2007-07-22 09:05:11 +00:00
|
|
|
partno++;
|
2005-04-22 02:32:37 +00:00
|
|
|
|
|
|
|
/* Assume partno will require less than five bytes to encode. */
|
|
|
|
encoding = grub_malloc (grub_strlen (device) + 3 + 5);
|
|
|
|
grub_sprintf (encoding, "(%s,%d)", device, partno);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
encoding = grub_malloc (grub_strlen (device) + 2);
|
|
|
|
grub_sprintf (encoding, "(%s)", device);
|
|
|
|
}
|
|
|
|
|
|
|
|
grub_free (partition);
|
|
|
|
grub_free (device);
|
|
|
|
|
|
|
|
return encoding;
|
|
|
|
}
|
|
|
|
|
2009-12-05 01:43:17 +00:00
|
|
|
/* On i386, a firmware-independant grub_reboot() is provided by realmode.S. */
|
|
|
|
#ifndef __i386__
|
2005-03-26 17:34:50 +00:00
|
|
|
void
|
|
|
|
grub_reboot (void)
|
|
|
|
{
|
|
|
|
grub_ieee1275_interpret ("reset-all", 0);
|
|
|
|
}
|
2009-12-05 01:43:17 +00:00
|
|
|
#endif
|
2005-03-26 17:34:50 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
grub_halt (void)
|
|
|
|
{
|
2009-05-04 20:06:05 +00:00
|
|
|
/* Not standardized. We try both known commands. */
|
2008-01-19 22:19:20 +00:00
|
|
|
|
2005-03-26 17:34:50 +00:00
|
|
|
grub_ieee1275_interpret ("shut-down", 0);
|
2008-01-19 22:19:20 +00:00
|
|
|
grub_ieee1275_interpret ("power-off", 0);
|
2005-03-26 17:34:50 +00:00
|
|
|
}
|