2005-08-07 14:14:40 +00:00
|
|
|
|
/* of.c - Access the Open Firmware client interface. */
|
2004-03-28 21:52:02 +00:00
|
|
|
|
/*
|
2004-04-04 13:46:03 +00:00
|
|
|
|
* GRUB -- GRand Unified Bootloader
|
2007-07-21 23:32:33 +00:00
|
|
|
|
* Copyright (C) 2003,2004,2005,2007 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
|
|
|
|
*/
|
|
|
|
|
|
2005-08-03 22:53:51 +00:00
|
|
|
|
#include <grub/ieee1275/ieee1275.h>
|
2008-01-15 16:14:33 +00:00
|
|
|
|
#include <grub/types.h>
|
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
|
|
|
|
#define IEEE1275_PHANDLE_INVALID ((grub_ieee1275_phandle_t) -1)
|
2006-10-27 17:57:05 +00:00
|
|
|
|
#define IEEE1275_IHANDLE_INVALID ((grub_ieee1275_ihandle_t) 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
|
|
|
|
#define IEEE1275_CELL_INVALID ((grub_ieee1275_cell_t) -1)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
2005-08-03 22:53:51 +00:00
|
|
|
|
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
/* FIXME is this function needed? */
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_uint32_t
|
|
|
|
|
grub_ieee1275_decode_int_4 (unsigned char *p)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_uint32_t val = (*p++ << 8);
|
2004-03-28 21:52:02 +00:00
|
|
|
|
val = (val + *p++) << 8;
|
|
|
|
|
val = (val + *p++) << 8;
|
|
|
|
|
return (val + *p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_ieee1275_finddevice (char *name, grub_ieee1275_phandle_t *phandlep)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct find_device_args
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_ieee1275_cell_t device;
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_ieee1275_phandle_t phandle;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "finddevice", 1, 1);
|
2005-08-03 22:53:51 +00:00
|
|
|
|
args.device = (grub_ieee1275_cell_t) name;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
*phandlep = args.phandle;
|
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 (args.phandle == IEEE1275_PHANDLE_INVALID)
|
|
|
|
|
return -1;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2005-06-21 02:33:52 +00:00
|
|
|
|
grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle,
|
2004-09-14 08:56:51 +00:00
|
|
|
|
const char *property, void *buf,
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_size_t size, grub_ssize_t *actual)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct get_property_args
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
|
|
|
|
grub_ieee1275_phandle_t phandle;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_ieee1275_cell_t prop;
|
|
|
|
|
grub_ieee1275_cell_t buf;
|
|
|
|
|
grub_ieee1275_cell_t buflen;
|
|
|
|
|
grub_ieee1275_cell_t size;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "getprop", 4, 1);
|
2005-06-21 02:33:52 +00:00
|
|
|
|
args.phandle = phandle;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
args.prop = (grub_ieee1275_cell_t) property;
|
|
|
|
|
args.buf = (grub_ieee1275_cell_t) buf;
|
|
|
|
|
args.buflen = (grub_ieee1275_cell_t) size;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
if (actual)
|
2005-08-03 22:53:51 +00:00
|
|
|
|
*actual = (grub_ssize_t) args.size;
|
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 (args.size == IEEE1275_CELL_INVALID)
|
2004-10-13 23:43:44 +00:00
|
|
|
|
return -1;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-15 16:14:33 +00:00
|
|
|
|
int
|
|
|
|
|
grub_ieee1275_get_integer_property (grub_ieee1275_phandle_t phandle,
|
|
|
|
|
const char *property, grub_uint32_t *buf,
|
|
|
|
|
grub_size_t size, grub_ssize_t *actual)
|
|
|
|
|
{
|
|
|
|
|
int ret;
|
|
|
|
|
ret = grub_ieee1275_get_property (phandle, property, (void *) buf, size, actual);
|
|
|
|
|
#ifndef GRUB_CPU_WORDS_BIGENDIAN
|
|
|
|
|
/* Integer properties are always in big endian. */
|
|
|
|
|
if (ret == 0)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
size /= sizeof (grub_uint32_t);
|
|
|
|
|
for (i = 0; i < size; i++)
|
|
|
|
|
buf[i] = grub_be_to_cpu32 (buf[i]);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-28 21:52:02 +00:00
|
|
|
|
int
|
2005-06-21 02:33:52 +00:00
|
|
|
|
grub_ieee1275_next_property (grub_ieee1275_phandle_t phandle, char *prev_prop,
|
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
|
|
|
|
char *prop)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct get_property_args
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
|
|
|
|
grub_ieee1275_phandle_t phandle;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_ieee1275_cell_t prev_prop;
|
|
|
|
|
grub_ieee1275_cell_t next_prop;
|
|
|
|
|
grub_ieee1275_cell_t flags;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "nextprop", 3, 1);
|
2005-06-21 02:33:52 +00:00
|
|
|
|
args.phandle = phandle;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
args.prev_prop = (grub_ieee1275_cell_t) prev_prop;
|
|
|
|
|
args.next_prop = (grub_ieee1275_cell_t) prop;
|
|
|
|
|
args.flags = (grub_ieee1275_cell_t) -1;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
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
|
|
|
|
return (int) args.flags;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2005-06-21 02:33:52 +00:00
|
|
|
|
grub_ieee1275_get_property_length (grub_ieee1275_phandle_t phandle,
|
2005-08-03 22:53:51 +00:00
|
|
|
|
const char *prop, grub_ssize_t *length)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct get_property_args
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
|
|
|
|
grub_ieee1275_phandle_t phandle;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_ieee1275_cell_t prop;
|
|
|
|
|
grub_ieee1275_cell_t length;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "getproplen", 2, 1);
|
2005-06-21 02:33:52 +00:00
|
|
|
|
args.phandle = phandle;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
args.prop = (grub_ieee1275_cell_t) prop;
|
|
|
|
|
args.length = (grub_ieee1275_cell_t) -1;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
*length = args.length;
|
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 (args.length == IEEE1275_CELL_INVALID)
|
|
|
|
|
return -1;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_ieee1275_instance_to_package (grub_ieee1275_ihandle_t ihandle,
|
|
|
|
|
grub_ieee1275_phandle_t *phandlep)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct instance_to_package_args
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
|
|
|
|
grub_ieee1275_ihandle_t ihandle;
|
|
|
|
|
grub_ieee1275_phandle_t phandle;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "instance-to-package", 1, 1);
|
|
|
|
|
args.ihandle = ihandle;
|
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
*phandlep = args.phandle;
|
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 (args.phandle == IEEE1275_PHANDLE_INVALID)
|
|
|
|
|
return -1;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_ieee1275_package_to_path (grub_ieee1275_phandle_t phandle,
|
2005-08-07 14:14:40 +00:00
|
|
|
|
char *path, grub_size_t len,
|
|
|
|
|
grub_ssize_t *actual)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct instance_to_package_args
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
|
|
|
|
grub_ieee1275_phandle_t phandle;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_ieee1275_cell_t buf;
|
|
|
|
|
grub_ieee1275_cell_t buflen;
|
|
|
|
|
grub_ieee1275_cell_t actual;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "package-to-path", 3, 1);
|
|
|
|
|
args.phandle = phandle;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
args.buf = (grub_ieee1275_cell_t) path;
|
|
|
|
|
args.buflen = (grub_ieee1275_cell_t) len;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
if (actual)
|
|
|
|
|
*actual = args.actual;
|
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 (args.actual == IEEE1275_CELL_INVALID)
|
|
|
|
|
return -1;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle,
|
|
|
|
|
char *path, grub_size_t len,
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_ssize_t *actual)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
{
|
2006-10-01 06:45:53 +00:00
|
|
|
|
struct instance_to_path_args
|
2005-08-07 14:14:40 +00:00
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
|
|
|
|
grub_ieee1275_ihandle_t ihandle;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_ieee1275_cell_t buf;
|
|
|
|
|
grub_ieee1275_cell_t buflen;
|
|
|
|
|
grub_ieee1275_cell_t actual;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "instance-to-path", 3, 1);
|
|
|
|
|
args.ihandle = ihandle;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
args.buf = (grub_ieee1275_cell_t) path;
|
|
|
|
|
args.buflen = (grub_ieee1275_cell_t) len;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
if (actual)
|
|
|
|
|
*actual = args.actual;
|
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 (args.actual == IEEE1275_CELL_INVALID)
|
|
|
|
|
return -1;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, void *buffer,
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_size_t len, grub_ssize_t *actualp)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct write_args
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
|
|
|
|
grub_ieee1275_ihandle_t ihandle;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_ieee1275_cell_t buf;
|
|
|
|
|
grub_ieee1275_cell_t len;
|
|
|
|
|
grub_ieee1275_cell_t actual;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "write", 3, 1);
|
|
|
|
|
args.ihandle = ihandle;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
args.buf = (grub_ieee1275_cell_t) buffer;
|
|
|
|
|
args.len = (grub_ieee1275_cell_t) len;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
if (actualp)
|
|
|
|
|
*actualp = args.actual;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer,
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_size_t len, grub_ssize_t *actualp)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct write_args
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
|
|
|
|
grub_ieee1275_ihandle_t ihandle;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_ieee1275_cell_t buf;
|
|
|
|
|
grub_ieee1275_cell_t len;
|
|
|
|
|
grub_ieee1275_cell_t actual;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "read", 3, 1);
|
|
|
|
|
args.ihandle = ihandle;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
args.buf = (grub_ieee1275_cell_t) buffer;
|
|
|
|
|
args.len = (grub_ieee1275_cell_t) len;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
if (actualp)
|
|
|
|
|
*actualp = args.actual;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, int pos_hi,
|
2005-08-03 22:53:51 +00:00
|
|
|
|
int pos_lo, grub_ssize_t *result)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct write_args
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
|
|
|
|
grub_ieee1275_ihandle_t ihandle;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_ieee1275_cell_t pos_hi;
|
|
|
|
|
grub_ieee1275_cell_t pos_lo;
|
|
|
|
|
grub_ieee1275_cell_t result;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "seek", 3, 1);
|
|
|
|
|
args.ihandle = ihandle;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
args.pos_hi = (grub_ieee1275_cell_t) pos_hi;
|
|
|
|
|
args.pos_lo = (grub_ieee1275_cell_t) pos_lo;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
|
*result = args.result;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_ieee1275_peer (grub_ieee1275_phandle_t node,
|
|
|
|
|
grub_ieee1275_phandle_t *result)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct peer_args
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
|
|
|
|
grub_ieee1275_phandle_t node;
|
|
|
|
|
grub_ieee1275_phandle_t result;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "peer", 1, 1);
|
|
|
|
|
args.node = node;
|
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
*result = args.result;
|
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 (args.result == 0)
|
|
|
|
|
return -1;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_ieee1275_child (grub_ieee1275_phandle_t node,
|
|
|
|
|
grub_ieee1275_phandle_t *result)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct child_args
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
|
|
|
|
grub_ieee1275_phandle_t node;
|
|
|
|
|
grub_ieee1275_phandle_t result;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "child", 1, 1);
|
|
|
|
|
args.node = node;
|
|
|
|
|
args.result = IEEE1275_PHANDLE_INVALID;
|
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
*result = args.result;
|
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 (args.result == 0)
|
|
|
|
|
return -1;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_ieee1275_parent (grub_ieee1275_phandle_t node,
|
|
|
|
|
grub_ieee1275_phandle_t *result)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct parent_args
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
|
|
|
|
grub_ieee1275_phandle_t node;
|
|
|
|
|
grub_ieee1275_phandle_t result;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "parent", 1, 1);
|
|
|
|
|
args.node = node;
|
|
|
|
|
args.result = IEEE1275_PHANDLE_INVALID;
|
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
*result = args.result;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-31 21:28:34 +00:00
|
|
|
|
int
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_ieee1275_interpret (const char *command, grub_ieee1275_cell_t *catch)
|
2005-01-31 21:28:34 +00:00
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct enter_args
|
|
|
|
|
{
|
2005-01-31 21:28:34 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_ieee1275_cell_t command;
|
|
|
|
|
grub_ieee1275_cell_t catch;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2005-01-31 21:28:34 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "interpret", 1, 1);
|
2005-08-03 22:53:51 +00:00
|
|
|
|
args.command = (grub_ieee1275_cell_t) command;
|
2005-01-31 21:28:34 +00:00
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
if (catch)
|
|
|
|
|
*catch = args.catch;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-21 02:45:03 +00:00
|
|
|
|
int
|
|
|
|
|
grub_ieee1275_enter (void)
|
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct enter_args
|
|
|
|
|
{
|
2005-01-21 02:45:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2005-01-21 02:45:03 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "enter", 0, 0);
|
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2005-08-21 18:42:55 +00:00
|
|
|
|
void
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_ieee1275_exit (void)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct exit_args
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "exit", 0, 0);
|
|
|
|
|
|
2005-08-03 22:53:51 +00:00
|
|
|
|
IEEE1275_CALL_ENTRY_FN (&args);
|
|
|
|
|
for (;;) ;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct open_args
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_ieee1275_cell_t path;
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_ieee1275_ihandle_t result;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "open", 1, 1);
|
2005-08-03 22:53:51 +00:00
|
|
|
|
args.path = (grub_ieee1275_cell_t) path;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
*result = args.result;
|
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 (args.result == IEEE1275_IHANDLE_INVALID)
|
|
|
|
|
return -1;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct close_args
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
|
|
|
|
grub_ieee1275_ihandle_t ihandle;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "close", 1, 0);
|
|
|
|
|
args.ihandle = ihandle;
|
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2004-10-03 09:19:10 +00:00
|
|
|
|
grub_ieee1275_claim (grub_addr_t addr, grub_size_t size, unsigned int align,
|
|
|
|
|
grub_addr_t *result)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct claim_args
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_ieee1275_cell_t addr;
|
|
|
|
|
grub_ieee1275_cell_t size;
|
|
|
|
|
grub_ieee1275_cell_t align;
|
|
|
|
|
grub_ieee1275_cell_t base;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "claim", 3, 1);
|
2005-08-03 22:53:51 +00:00
|
|
|
|
args.addr = (grub_ieee1275_cell_t) addr;
|
|
|
|
|
args.size = (grub_ieee1275_cell_t) size;
|
|
|
|
|
args.align = (grub_ieee1275_cell_t) align;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
2004-10-03 09:19:10 +00:00
|
|
|
|
if (result)
|
|
|
|
|
*result = args.base;
|
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 (args.base == IEEE1275_CELL_INVALID)
|
2004-10-11 14:11:33 +00:00
|
|
|
|
return -1;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-27 17:47:37 +00:00
|
|
|
|
int
|
2004-10-03 09:19:10 +00:00
|
|
|
|
grub_ieee1275_release (grub_addr_t addr, grub_size_t size)
|
2004-07-27 17:47:37 +00:00
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct release_args
|
|
|
|
|
{
|
2004-07-27 17:47:37 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_ieee1275_cell_t addr;
|
|
|
|
|
grub_ieee1275_cell_t size;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-07-27 17:47:37 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "release", 2, 0);
|
2004-10-03 09:19:10 +00:00
|
|
|
|
args.addr = addr;
|
2004-07-27 17:47:37 +00:00
|
|
|
|
args.size = size;
|
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-28 21:52:02 +00:00
|
|
|
|
int
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_ieee1275_set_property (grub_ieee1275_phandle_t phandle,
|
2004-03-28 21:52:02 +00:00
|
|
|
|
const char *propname, void *buf,
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_size_t size, grub_ssize_t *actual)
|
2004-03-28 21:52:02 +00:00
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct set_property_args
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
|
|
|
|
grub_ieee1275_phandle_t phandle;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_ieee1275_cell_t propname;
|
|
|
|
|
grub_ieee1275_cell_t buf;
|
|
|
|
|
grub_ieee1275_cell_t size;
|
|
|
|
|
grub_ieee1275_cell_t actual;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "setprop", 4, 1);
|
2005-08-03 22:53:51 +00:00
|
|
|
|
args.size = (grub_ieee1275_cell_t) size;
|
|
|
|
|
args.buf = (grub_ieee1275_cell_t) buf;
|
|
|
|
|
args.propname = (grub_ieee1275_cell_t) propname;
|
|
|
|
|
args.phandle = (grub_ieee1275_cell_t) phandle;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
*actual = args.actual;
|
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 ((args.actual == IEEE1275_CELL_INVALID) || (args.actual != args.size))
|
|
|
|
|
return -1;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_ieee1275_set_color (grub_ieee1275_ihandle_t ihandle,
|
2004-03-28 21:52:02 +00:00
|
|
|
|
int index, int r, int g, int b)
|
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct set_color_args
|
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
char *method;
|
2004-04-04 13:46:03 +00:00
|
|
|
|
grub_ieee1275_ihandle_t ihandle;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_ieee1275_cell_t index;
|
|
|
|
|
grub_ieee1275_cell_t b;
|
|
|
|
|
grub_ieee1275_cell_t g;
|
|
|
|
|
grub_ieee1275_cell_t r;
|
2006-11-02 16:30:17 +00:00
|
|
|
|
grub_ieee1275_cell_t catch_result;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
|
2006-11-02 16:30:17 +00:00
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1);
|
2004-03-28 21:52:02 +00:00
|
|
|
|
args.method = "color!";
|
|
|
|
|
args.ihandle = ihandle;
|
|
|
|
|
args.index = index;
|
|
|
|
|
args.r = r;
|
|
|
|
|
args.g = g;
|
|
|
|
|
args.b = b;
|
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
2006-11-02 16:30:17 +00:00
|
|
|
|
return args.catch_result;
|
2004-03-28 21:52:02 +00:00
|
|
|
|
}
|
2005-01-03 21:48:45 +00:00
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
grub_ieee1275_milliseconds (grub_uint32_t *msecs)
|
|
|
|
|
{
|
2005-08-07 14:14:40 +00:00
|
|
|
|
struct milliseconds_args
|
|
|
|
|
{
|
2005-01-03 21:48:45 +00:00
|
|
|
|
struct grub_ieee1275_common_hdr common;
|
2005-08-03 22:53:51 +00:00
|
|
|
|
grub_ieee1275_cell_t msecs;
|
2005-08-07 14:14:40 +00:00
|
|
|
|
}
|
|
|
|
|
args;
|
2005-01-03 21:48:45 +00:00
|
|
|
|
|
|
|
|
|
INIT_IEEE1275_COMMON (&args.common, "milliseconds", 0, 1);
|
|
|
|
|
|
|
|
|
|
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
|
|
|
|
return -1;
|
|
|
|
|
*msecs = args.msecs;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|