2005-08-03 Hollis Blanchard <hollis@penguinppc.org>
* include/grub/powerpc/ieee1275/ieee1275.h: Move ... * include/grub/ieee1275/ieee1275.h: ... to here. All users updated. Move `abort', `grub_reboot', and `grub_halt' prototypes ... * include/grub/powerpc/ieee1275/kernel.h: ... to here. * commands/ieee1275/halt.c: Include <grub/machine/kernel.h> instead of <grub/machine/ieee1275.h>. * commands/ieee1275/reboot.c: Likewise. * boot/powerpc/ieee1275/ieee1275.c: Move ... * kern/ieee1275.c: ... to here. All users updated. Change all parameter structs to use new type `grub_ieee1275_cell_t'. * term/powerpc/ieee1275/ofconsole.c: Move ... * term/ieee1275/ofconsole.c: ... to here. All users updated. * disk/powerpc/ieee1275/ofdisk.c: Move ... * disk/ieee1275/ofdisk.c: ... to here. All users updated. * boot/powerpc/ieee1275/cmain.c: Change `grub_ieee1275_entry_fn' type to return int. * include/grub/i386/pc/console.h: Move to include/grub/console.h. Remove unused prototypes. All users updated. * include/grub/powerpc/ieee1275/console.h: Removed. * include/grub/powerpc/ieee1275/ieee1275.h: Define `grub_ieee1275_cell_t'. * kern/powerpc/ieee1275/openfw.c: Include <grub/machine/kernel.h>. Cast comparisons with -1 to the correct type. * loader/powerpc/ieee1275/linux.c (kernel_entry_t): Change parameter type to match `grub_ieee1275_entry_fn'.
This commit is contained in:
parent
8b5f393852
commit
3be7266d92
21 changed files with 339 additions and 355 deletions
|
@ -20,12 +20,12 @@
|
|||
|
||||
#include <alloca.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <grub/machine/ieee1275.h>
|
||||
#include <grub/kernel.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/ieee1275/ieee1275.h>
|
||||
|
||||
/* OpenFirmware entry point passed to us from the real bootloader. */
|
||||
intptr_t (*grub_ieee1275_entry_fn) (void *);
|
||||
int (*grub_ieee1275_entry_fn) (void *);
|
||||
|
||||
grub_ieee1275_phandle_t grub_ieee1275_chosen;
|
||||
|
||||
|
@ -76,7 +76,7 @@ cmain (uint32_t r3, uint32_t r4 __attribute__((unused)), uint32_t r5)
|
|||
extern char _start;
|
||||
extern char _end;
|
||||
|
||||
grub_ieee1275_entry_fn = (intptr_t (*)(void *)) r3;
|
||||
grub_ieee1275_entry_fn = (int (*)(void *)) r3;
|
||||
|
||||
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0);
|
||||
|
||||
|
@ -91,7 +91,7 @@ cmain (uint32_t r3, uint32_t r4 __attribute__((unused)), uint32_t r5)
|
|||
else
|
||||
{
|
||||
/* Assume we were entered from Open Firmware. */
|
||||
grub_ieee1275_entry_fn = (intptr_t (*)(void *)) r5;
|
||||
grub_ieee1275_entry_fn = (int (*)(void *)) r5;
|
||||
}
|
||||
|
||||
grub_ieee1275_finddevice ("/chosen", &grub_ieee1275_chosen);
|
||||
|
|
|
@ -1,533 +0,0 @@
|
|||
/* ieee1275.c - Access the Open Firmware client interface. */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <grub/machine/ieee1275.h>
|
||||
|
||||
|
||||
#define IEEE1275_PHANDLE_ROOT ((grub_ieee1275_phandle_t) 0)
|
||||
#define IEEE1275_PHANDLE_INVALID ((grub_ieee1275_phandle_t) -1)
|
||||
|
||||
intptr_t (*grub_ieee1275_entry_fn) (void *);
|
||||
|
||||
/* FIXME is this function needed? */
|
||||
grub_uint32_t
|
||||
grub_ieee1275_decode_int_4 (unsigned char *p)
|
||||
{
|
||||
grub_uint32_t val = (*p++ << 8);
|
||||
val = (val + *p++) << 8;
|
||||
val = (val + *p++) << 8;
|
||||
return (val + *p);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
grub_ieee1275_finddevice (char *name, grub_ieee1275_phandle_t *phandlep)
|
||||
{
|
||||
struct find_device_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
char *device;
|
||||
grub_ieee1275_phandle_t phandle;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "finddevice", 1, 1);
|
||||
args.device = name;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
*phandlep = args.phandle;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle,
|
||||
const char *property, void *buf,
|
||||
grub_size_t size, grub_size_t *actual)
|
||||
{
|
||||
struct get_property_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_ieee1275_phandle_t phandle;
|
||||
const char *prop;
|
||||
void *buf;
|
||||
int buflen;
|
||||
int size;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "getprop", 4, 1);
|
||||
args.phandle = phandle;
|
||||
args.prop = property;
|
||||
args.buf = buf;
|
||||
args.buflen = size;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
if (actual)
|
||||
*actual = args.size;
|
||||
if (args.size == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_next_property (grub_ieee1275_phandle_t phandle, char *prev_prop,
|
||||
char *prop, int *flags)
|
||||
{
|
||||
struct get_property_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_ieee1275_phandle_t phandle;
|
||||
char *prev_prop;
|
||||
char *next_prop;
|
||||
int flags;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "nextprop", 3, 1);
|
||||
args.phandle = phandle;
|
||||
args.prev_prop = prev_prop;
|
||||
args.next_prop = prop;
|
||||
args.flags = -1;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
if (flags)
|
||||
*flags = args.flags;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_get_property_length (grub_ieee1275_phandle_t phandle,
|
||||
const char *prop, grub_size_t *length)
|
||||
{
|
||||
struct get_property_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_ieee1275_phandle_t phandle;
|
||||
const char *prop;
|
||||
grub_size_t length;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "getproplen", 2, 1);
|
||||
args.phandle = phandle;
|
||||
args.prop = prop;
|
||||
args.length = -1;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
*length = args.length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_instance_to_package (grub_ieee1275_ihandle_t ihandle,
|
||||
grub_ieee1275_phandle_t *phandlep)
|
||||
{
|
||||
struct instance_to_package_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_ieee1275_ihandle_t ihandle;
|
||||
grub_ieee1275_phandle_t phandle;
|
||||
} args;
|
||||
|
||||
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;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_package_to_path (grub_ieee1275_phandle_t phandle,
|
||||
char *path, grub_size_t len, grub_size_t *actual)
|
||||
{
|
||||
struct instance_to_package_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_ieee1275_phandle_t phandle;
|
||||
char *buf;
|
||||
int buflen;
|
||||
int actual;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "package-to-path", 3, 1);
|
||||
args.phandle = phandle;
|
||||
args.buf = path;
|
||||
args.buflen = len;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
if (actual)
|
||||
*actual = args.actual;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle,
|
||||
char *path, grub_size_t len,
|
||||
grub_size_t *actual)
|
||||
{
|
||||
struct instance_to_package_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_ieee1275_ihandle_t ihandle;
|
||||
char *buf;
|
||||
int buflen;
|
||||
int actual;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "instance-to-path", 3, 1);
|
||||
args.ihandle = ihandle;
|
||||
args.buf = path;
|
||||
args.buflen = len;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
if (actual)
|
||||
*actual = args.actual;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, void *buffer,
|
||||
grub_size_t len, grub_size_t *actualp)
|
||||
{
|
||||
struct write_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_ieee1275_ihandle_t ihandle;
|
||||
void *buf;
|
||||
grub_size_t len;
|
||||
grub_size_t actual;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "write", 3, 1);
|
||||
args.ihandle = ihandle;
|
||||
args.buf = buffer;
|
||||
args.len = len;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
if (actualp)
|
||||
*actualp = args.actual;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer,
|
||||
grub_size_t len, grub_size_t *actualp)
|
||||
{
|
||||
struct write_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_ieee1275_ihandle_t ihandle;
|
||||
void *buf;
|
||||
grub_size_t len;
|
||||
grub_size_t actual;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "read", 3, 1);
|
||||
args.ihandle = ihandle;
|
||||
args.buf = buffer;
|
||||
args.len = len;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
if (actualp)
|
||||
*actualp = args.actual;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, int pos_hi,
|
||||
int pos_lo, int *result)
|
||||
{
|
||||
struct write_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_ieee1275_ihandle_t ihandle;
|
||||
int pos_hi;
|
||||
int pos_lo;
|
||||
int result;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "seek", 3, 1);
|
||||
args.ihandle = ihandle;
|
||||
args.pos_hi = pos_hi;
|
||||
args.pos_lo = pos_lo;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
|
||||
if (result)
|
||||
*result = args.result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_peer (grub_ieee1275_phandle_t node,
|
||||
grub_ieee1275_phandle_t *result)
|
||||
{
|
||||
struct peer_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_ieee1275_phandle_t node;
|
||||
grub_ieee1275_phandle_t result;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "peer", 1, 1);
|
||||
args.node = node;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
*result = args.result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_child (grub_ieee1275_phandle_t node,
|
||||
grub_ieee1275_phandle_t *result)
|
||||
{
|
||||
struct child_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_ieee1275_phandle_t node;
|
||||
grub_ieee1275_phandle_t result;
|
||||
} args;
|
||||
|
||||
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;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_parent (grub_ieee1275_phandle_t node,
|
||||
grub_ieee1275_phandle_t *result)
|
||||
{
|
||||
struct parent_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_ieee1275_phandle_t node;
|
||||
grub_ieee1275_phandle_t result;
|
||||
} args;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_interpret (const char *command, int *catch)
|
||||
{
|
||||
struct enter_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
const char *command;
|
||||
int catch;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "interpret", 1, 1);
|
||||
args.command = command;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
if (catch)
|
||||
*catch = args.catch;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_enter (void)
|
||||
{
|
||||
struct enter_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "enter", 0, 0);
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_exit (void)
|
||||
{
|
||||
struct exit_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "exit", 0, 0);
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_open (char *node, grub_ieee1275_ihandle_t *result)
|
||||
{
|
||||
struct open_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
char *cstr;
|
||||
grub_ieee1275_ihandle_t result;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "open", 1, 1);
|
||||
args.cstr = node;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
*result = args.result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle)
|
||||
{
|
||||
struct close_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_ieee1275_ihandle_t ihandle;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "close", 1, 0);
|
||||
args.ihandle = ihandle;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_claim (grub_addr_t addr, grub_size_t size, unsigned int align,
|
||||
grub_addr_t *result)
|
||||
{
|
||||
struct claim_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_addr_t addr;
|
||||
grub_size_t size;
|
||||
unsigned int align;
|
||||
grub_addr_t base;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "claim", 3, 1);
|
||||
args.addr = addr;
|
||||
args.size = size;
|
||||
args.align = align;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
|
||||
if (result)
|
||||
*result = args.base;
|
||||
|
||||
if (args.base == (grub_addr_t)-1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_release (grub_addr_t addr, grub_size_t size)
|
||||
{
|
||||
struct release_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_addr_t addr;
|
||||
grub_size_t size;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "release", 2, 0);
|
||||
args.addr = addr;
|
||||
args.size = size;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_set_property (grub_ieee1275_phandle_t phandle,
|
||||
const char *propname, void *buf,
|
||||
grub_size_t size, grub_size_t *actual)
|
||||
{
|
||||
struct set_property_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_ieee1275_phandle_t phandle;
|
||||
const char *propname;
|
||||
void *buf;
|
||||
grub_size_t size;
|
||||
grub_size_t actual;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "setprop", 4, 1);
|
||||
args.size = size;
|
||||
args.buf = buf;
|
||||
args.propname = propname;
|
||||
args.phandle = phandle;
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
*actual = args.actual;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_set_color (grub_ieee1275_ihandle_t ihandle,
|
||||
int index, int r, int g, int b)
|
||||
{
|
||||
struct set_color_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
char *method;
|
||||
grub_ieee1275_ihandle_t ihandle;
|
||||
int index;
|
||||
int b;
|
||||
int g;
|
||||
int r;
|
||||
int result;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1);
|
||||
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;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_ieee1275_milliseconds (grub_uint32_t *msecs)
|
||||
{
|
||||
struct milliseconds_args {
|
||||
struct grub_ieee1275_common_hdr common;
|
||||
grub_uint32_t msecs;
|
||||
} args;
|
||||
|
||||
INIT_IEEE1275_COMMON (&args.common, "milliseconds", 0, 1);
|
||||
|
||||
if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
|
||||
return -1;
|
||||
*msecs = args.msecs;
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue