/*
* 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (C) IBM Corp. 2005
*
* Authors: Jimi Xenidis <jimix@watson.ibm.com>
*/
#include <xen/config.h>
#include <xen/init.h>
#include <xen/lib.h>
#include <xen/multiboot.h>
#include <xen/compile.h>
#include <xen/spinlock.h>
#include <xen/serial.h>
#include <xen/time.h>
#include <asm/page.h>
#include <asm/io.h>
#include "exceptions.h"
#include "of-devtree.h"
static ulong of_vec;
static ulong of_msr;
static int of_out;
static ofdn_t boot_cpu;
static char bootargs[256];
extern struct ns16550_defaults ns16550;
#undef OF_DEBUG
#ifdef OF_DEBUG
#define DBG(args...) of_printf(args)
#else
#define DBG(args...)
#endif
#define of_panic(MSG...) \
do { of_printf(MSG); of_printf("\nHANG\n"); for (;;); } while (0)
struct of_service {
u32 ofs_service;
u32 ofs_nargs;
u32 ofs_nrets;
u32 ofs_args[10];
};
static int bof_chosen;
static struct of_service s;
extern s32 prom_call(void *arg, ulong rtas_base, ulong func, ulong msr);
static int __init of_call(
const char *service, u32 nargs, u32 nrets, s32 rets[], ...)
{
int rc;
if (of_vec != 0) {
va_list args;
int i;
memset(&s, 0, sizeof (s));
s.ofs_service = (ulong)service;
s.ofs_nargs = nargs;
s.ofs_nrets = nrets;
s.ofs_nargs = nargs;
/* copy all the params into the args array */
va_start(args, rets);
for (i = 0; i < nargs; i++) {
s.ofs_args[i] = va_arg(args, u32);
}
va_end(args);
rc = prom_call(&s, 0, of_vec, of_msr);
/* yes always to the copy, just in case */
for (i = 0; i < nrets; i++) {
rets[i] = s.ofs_args[i + nargs];
}
} else {
rc = OF_FAILURE;
}
return rc;
}
/* popular OF methods */
static int __init _of_write(int ih, const char *addr, u32 len)
{
int rets[1] = { OF_FAILURE };
if (of_call("write", 3, 1, rets, ih, addr, len) == OF_FAILURE) {
return OF_FAILURE;
}
return rets[0];