"Ok, my loader's now up to putting up a prompt. It probes disks partially

but can't boot from them yet."

Thanks to Stephane Potvin for the some of the code in this set.

Submitted by:	Benno Rice <benno@jeamland.net>
This commit is contained in:
David E. O'Brien 2000-10-16 10:46:22 +00:00
parent cb22e4fad5
commit 146a7d5318
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=67204
20 changed files with 2718 additions and 0 deletions

5
sys/boot/ofw/Makefile Normal file
View File

@ -0,0 +1,5 @@
# $FreeBSD$
SUBDIR= libofw
.include <bsd.subdir.mk>

View File

@ -0,0 +1,23 @@
# $FreeBSD$
LIB= ofw
NOPIC= true
NOPROFILE= true
INTERNALLIB= true
INTERNALSTATICLIB= true
SRCS= devicename.c main.c ofw_copy.c ofw_module.c ofw_disk.c ofw_console.c \
ofw_time.c ofw_devsearch.c ofw_reboot.c openfirm.c
CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
# Pick up the bootstrap header for some interface items
CFLAGS+= -I${.CURDIR}/../../common -msoft-float \
-I${.CURDIR}/../../.. -I.
.ifdef(BOOT_BIOSDISK_DEBUG)
# Make the disk code more talkative
CFLAGS+= -DDISK_DEBUG
.endif
.include <bsd.lib.mk>

View File

@ -0,0 +1,79 @@
/*
* Copyright (C) 2000 Benno Rice.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
/* Note: Must match the 'struct devdesc' in bootstrap.h */
struct ofw_devdesc {
struct devsw *d_dev;
int d_type;
union {
struct {
int unit;
int partition;
int slice;
int bsize;
void *dmabuf;
} ofwdisk;
struct {
int unit;
void *dmabuf;
} netif;
} d_kind;
/*
* Keeping this around so I know what came from the NetBSD stuff.
* I've made a wild guess as to what goes where, but I have no idea if it's
* right.
*
* u_long partoff;
* int bsize;
* void *dmabuf;
*/
};
#define MAXDEV 31 /* Maximum number of devices. */
/* Known types. Use the same as alpha for consistancy. */
#define DEVT_NONE 0
#define DEVT_DISK 1
#define DEVT_NET 2
extern int ofw_getdev(void **vdev, const char *devspec, const char **path);
extern char *ofw_fmtdev(void *vdev);
extern int ofw_setcurrdev(struct env_var *ev, int flags, void *value);
extern struct devsw ofwdisk;
extern struct devsw ofwnet;
ssize_t ofw_copyin(const void *src, vm_offset_t dest, const size_t len);
ssize_t ofw_copyout(const vm_offset_t src, void *dest, const size_t len);
ssize_t ofw_readin(const int fd, vm_offset_t dest, const size_t len);
extern int ofw_boot(void);
extern int ofw_autoload(void);
extern void reboot(void);
extern int main(int (*openfirm)(void *));

153
sys/boot/ofw/libofw/main.c Normal file
View File

@ -0,0 +1,153 @@
/*-
* Copyright (c) 2000 Benno Rice <benno@jeamland.net>
* Copyright (c) 2000 Stephane Potvin <sepotvin@videotron.ca>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <stand.h>
#include "openfirm.h"
#include "libofw.h"
#include "bootstrap.h"
struct arch_switch archsw; /* MI/MD interface boundary */
extern char end[];
extern char bootprog_name[];
extern char bootprog_rev[];
extern char bootprog_date[];
extern char bootprog_maker[];
struct ofw_reg
{
uint32_t base;
uint32_t size;
};
void
init_heap(void)
{
phandle_t chosen, memory;
ihandle_t meminstance;
struct ofw_reg available;
void * aligned_end;
chosen = OF_finddevice("/chosen");
OF_getprop(chosen, "memory", &meminstance, sizeof(meminstance));
memory = OF_instance_to_package(meminstance);
OF_getprop(memory, "available", &available, sizeof(available));
printf("available.base = 0x%08x\n", available.base);
printf("available.size = 0x%08x\n", available.size);
if (OF_claim((void *)available.base, 0x00040000, 0) ==
(void *) 0xffffffff) {
printf("Heap memory claim failed!\n");
OF_enter();
}
aligned_end = (void *)(((int)end + sizeof(int) - 1) &
~(sizeof(int) - 1));
printf("end = 0x%08x, aligned_end = 0x%08x\n", (uint32_t)end,
(uint32_t)aligned_end);
setheap((void *)aligned_end, (void *)(available.base + available.size));
}
uint32_t
memsize(void)
{
phandle_t chosen, memory;
ihandle_t meminstance;
struct ofw_reg reg;
chosen = OF_finddevice("/chosen");
OF_getprop(chosen, "memory", &meminstance, sizeof(meminstance));
memory = OF_instance_to_package(meminstance);
OF_getprop(memory, "reg", &reg, sizeof(reg));
return(reg.size);
}
int
main(int (*openfirm)(void *))
{
#if 0
void * test;
#endif
int i;
/*
* Initalise the OpenFirmware routines by giving them the entry point.
*/
OF_init(openfirm);
/*
* Set up console.
*/
cons_probe();
printf(">>> hello?\n");
/*
* Initialise the heap as early as possible. Once this is done,
* alloc() is usable. The stack is buried inside us, so this is
* safe.
*/
init_heap();
/*
* Initialise the block cache
*/
bcache_init(32, 512); /* 16k XXX tune this */
/*
* March through the device switch probing for things.
*/
for(i = 0; devsw[i] != NULL; i++)
if(devsw[i]->dv_init != NULL)
(devsw[i]->dv_init)();
printf("\n");
printf("%s, Revision %s\n", bootprog_name, bootprog_rev);
printf("(%s, %s)\n", bootprog_maker, bootprog_date);
printf("Memory: %dKB\n", memsize() / 1024);
archsw.arch_getdev = ofw_getdev;
interact(); /* doesn't return */
OF_exit();
return 0;
}
COMMAND_SET(halt, "halt", "halt the system", command_halt);
static int
command_halt(int argc, char *argv[])
{
OF_exit();
return(CMD_OK);
}

View File

@ -0,0 +1,109 @@
/*
* Copyright (C) 2000 Benno Rice
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#include "openfirm.h"
static phandle_t curnode;
/*
* Initialise a device tree search. We do this by setting curpackage to point
* to the root node.
*/
void
ofw_devsearch_init(void)
{
curnode = OF_peer(0);
}
static phandle_t
nextnode(phandle_t current)
{
phandle_t node;
node = OF_child(current);
if (node == -1)
return(-1);
if (node == 0) {
node = OF_peer(current);
if (node == -1)
return(-1);
if (node == 0) {
phandle_t newnode;
newnode = current;
node = 0;
while (node == 0) {
node = OF_parent(newnode);
if (node == -1 || node == 0)
return ((int)node);
newnode = node;
node = OF_peer(newnode);
}
}
}
return(node);
}
/*
* Search for devices in the device tree with a certain device_type.
* Return their paths.
*/
int
ofw_devsearch(const char *type, char *path)
{
phandle_t new;
char str[32];
int i;
for (;;) {
new = nextnode(curnode);
if (new == 0 || new == -1) {
return((int)new);
}
curnode = new;
if ((i = OF_getprop(curnode, "device_type", str, 31)) != -1) {
if (strncmp(str, type, 32) == 0) {
if ((i = OF_package_to_path(curnode, path, 254)) == -1)
return(-1);
path[i] = '\0';
return(1);
}
}
}
}

View File

@ -0,0 +1,122 @@
f/*
* Copyright (C) 2000 Benno Rice.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
/*
* Disk I/O routines using Open Firmware
*/
#include <sys/param.h>
#include <sys/disklabel.h>
#include <sys/disklabel_mbr.h>
#include <netinet/in.h>
#include <stand.h>
#include "bootstrap.h"
#include "libofw.h"
#include "openfirm.h"
static int ofwd_init(void);
static int ofwd_strategy(void *devdata, int flag, daddr_t dblk,
size_t size, char *buf, size_t *rsize);
static int ofwd_open(struct open_file *f, ...);
static int ofwd_close(struct open_file *f);
static void ofwd_print(int verbose);
struct devsw ofwdisk = {
"disk",
DEVT_DISK,
ofwd_init,
ofwd_strategy,
ofwd_open,
ofwd_close,
noioctl,
ofwd_print
};
static struct ofwdinfo {
int ofwd_unit;
char ofwd_path[255];
} ofwdinfo[MAXDEV];
static int nofwdinfo = 0;
static int
ofwd_init(void)
{
int ret;
char devpath[255];
ihandle_t instance;
ofw_devsearch_init();
while((ret = ofw_devsearch("block", devpath)) != 0) {
if (ret == -1)
return (1);
instance = OF_open(devpath);
if (instance != -1) {
ofwdinfo[nofwdinfo].ofwd_unit = nofwdinfo;
strncpy(ofwdinfo[nofwdinfo].ofwd_path, devpath, 255);
printf("disk%d is %s\n", nofwdinfo, devpath);
nofwdinfo++;
OF_close(instance);
}
if (nofwdinfo > MAXDEV) {
printf("Hit MAXDEV probing disks.\n");
return (1);
}
}
return (0);
}
static int
ofwd_strategy(void *devdata, int flag, daddr_t dblk, size_t size, char *buf,
size_t *rsize)
{
return (0);
}
static int
ofwd_open(struct open_file *f, ...)
{
return (0);
}
static int
ofwd_close(struct open_file *f)
{
return (0);
}
static void
ofwd_print(int verbose)
{
printf("ofwd_print called.\n");
return;
}

View File

@ -0,0 +1,195 @@
/*
* Copyright (c) 2000 Benno Rice
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <sys/param.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <stand.h>
#include <net.h>
#include <netif.h>
int ofwn_probe();
int ofwn_match();
void ofwn_init();
int ofwn_get();
int ofwn_put();
void ofwn_end();
extern struct netif_stats prom_stats[];
struct netif_dif prom_ifs[] = {
/* dif_unit dif_nsel dif_stats dif_private */
{ 0, 1, &prom_stats[0], 0, },
};
struct netif_stats prom_stats[NENTS(prom_ifs)];
struct netif_driver ofwnet = {
"net", /* netif_bname */
ofwn_match, /* netif_match */
ofwn_probe, /* netif_probe */
ofwn_init, /* netif_init */
ofwn_get, /* netif_get */
ofwn_put, /* netif_put */
ofwn_end, /* netif_end */
ofwn_ifs, /* netif_ifs */
NENTS(ofwn_ifs) /* netif_nifs */
};
int netfd = 0, broken_firmware;
int
ofwn_match(struct netif *nif, void *machdep_hint)
{
return (1);
}
int
ofwn_probe(struct netif *nif, void *machdep_hint)
{
return 0;
}
int
ofwn_put(struct iodesc *desc, void *pkt, int len)
{
#if 0
prom_write(netfd, len, pkt, 0);
return len;
#endif
return 0;
}
int
ofwn_get(struct iodesc *desc, void *pkt, int len, time_t timeout)
{
return 0;
}
extern char *strchr();
void
ofw_init(struct iodesc *desc, void *machdep_hint)
{
char devname[64];
int devlen, i;
int netbbinfovalid;
char *enet_addr;
prom_return_t ret;
u_int64_t *qp, csum;
broken_firmware = 0;
csum = 0;
for (i = 0, qp = (u_int64_t *)&netbbinfo;
i < (sizeof netbbinfo / sizeof (u_int64_t)); i++, qp++)
csum += *qp;
netbbinfovalid = (csum == 0);
if (netbbinfovalid)
netbbinfovalid = netbbinfo.set;
ret.bits = prom_getenv(PROM_E_BOOTED_DEV, devname, sizeof(devname));
devlen = ret.u.retval;
/* Ethernet address is the 9th component of the booted_dev string. */
enet_addr = devname;
for (i = 0; i < 8; i++) {
enet_addr = strchr(enet_addr, ' ');
if (enet_addr == NULL) {
printf(
"boot: boot device name does not contain ethernet address.\n");
goto punt;
}
enet_addr++;
}
if (enet_addr != NULL) {
int hv, lv;
#define dval(c) (((c) >= '0' && (c) <= '9') ? ((c) - '0') : \
(((c) >= 'A' && (c) <= 'F') ? (10 + (c) - 'A') : \
(((c) >= 'a' && (c) <= 'f') ? (10 + (c) - 'a') : -1)))
for (i = 0; i < 6; i++) {
hv = dval(*enet_addr); enet_addr++;
lv = dval(*enet_addr); enet_addr++;
enet_addr++;
if (hv == -1 || lv == -1) {
printf(
"boot: boot device name contains bogus ethernet address.\n");
goto punt;
}
desc->myea[i] = (hv << 4) | lv;
}
#undef dval
}
if (netbbinfovalid && netbbinfo.force) {
printf("boot: using hard-coded ethernet address (forced).\n");
bcopy(netbbinfo.ether_addr, desc->myea, sizeof desc->myea);
}
gotit:
printf("boot: ethernet address: %s\n", ether_sprintf(desc->myea));
ret.bits = prom_open(devname, devlen + 1);
if (ret.u.status) {
printf("prom_init: open failed: %d\n", ret.u.status);
goto reallypunt;
}
netfd = ret.u.retval;
return;
punt:
broken_firmware = 1;
if (netbbinfovalid) {
printf("boot: using hard-coded ethernet address.\n");
bcopy(netbbinfo.ether_addr, desc->myea, sizeof desc->myea);
goto gotit;
}
reallypunt:
printf("\n");
printf("Boot device name was: \"%s\"\n", devname);
printf("\n");
printf("Your firmware may be too old to network-boot FreeBSD/alpha,\n");
printf("or you might have to hard-code an ethernet address into\n");
printf("your network boot block with setnetbootinfo(8).\n");
halt();
}
void
ofwn_end(struct netif *nif)
{
prom_close(netfd);
}

View File

@ -0,0 +1,36 @@
/*
* Copyright (c) 2000 Benno Rice
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <stand.h>
#include "openfirm.h"
void
exit(int code)
{
OF_exit();
}

View File

@ -0,0 +1,41 @@
/*
* Copyright (c) 2000 Benno Rice
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <stand.h>
#include "openfirm.h"
time_t
time(time_t *tloc)
{
int secs;
secs = OF_milliseconds() / 1000;
if (tloc)
*tloc = secs;
return secs;
}

View File

@ -0,0 +1,733 @@
/* $NetBSD: Locore.c,v 1.7 2000/08/20 07:04:59 tsubai Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
* Copyright (C) 1995, 1996 TooLs GmbH.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by TooLs GmbH.
* 4. The name of TooLs GmbH may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (C) 2000 Benno Rice.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <machine/stdarg.h>
#include "openfirm.h"
static int (*openfirmware)(void *);
static ihandle_t stdin;
static ihandle_t stdout;
/* Initialiaser */
void
OF_init(int (*openfirm)(void *))
{
openfirmware = openfirm;
}
/*
* Generic functions
*/
/* Test to see if a service exists. */
int
OF_test(char *name)
{
static struct {
char *name;
int nargs;
int nreturns;
char *service;
int missing;
} args = {
"test",
1,
1,
};
args.service = name;
if (openfirmware(&args) == -1)
return -1;
return args.missing;
}
/* Return firmware millisecond count. */
int
OF_milliseconds()
{
static struct {
char *name;
int nargs;
int nreturns;
int ms;
} args = {
"milliseconds",
0,
1,
};
openfirmware(&args);
return args.ms;
}
/*
* Device tree functions
*/
/* Return the next sibling of this node or 0. */
phandle_t
OF_peer(phandle_t node)
{
static struct {
char *name;
int nargs;
int nreturns;
phandle_t node;
phandle_t next;
} args = {
"peer",
1,
1,
};
args.node = node;
if (openfirmware(&args) == -1)
return -1;
return args.next;
}
/* Return the first child of this node or 0. */
phandle_t
OF_child(phandle_t node)
{
static struct {
char *name;
int nargs;
int nreturns;
phandle_t node;
phandle_t child;
} args = {
"child",
1,
1,
};
args.node = node;
if (openfirmware(&args) == -1)
return -1;
return args.child;
}
/* Return the parent of this node or 0. */
phandle_t
OF_parent(phandle_t node)
{
static struct {
char *name;
int nargs;
int nreturns;
phandle_t node;
phandle_t parent;
} args = {
"parent",
1,
1,
};
args.node = node;
if (openfirmware(&args) == -1)
return -1;
return args.parent;
}
/* Return the package handle that corresponds to an instance handle. */
phandle_t
OF_instance_to_package(ihandle_t instance)
{
static struct {
char *name;
int nargs;
int nreturns;
ihandle_t instance;
phandle_t package;
} args = {
"instance-to-package",
1,
1,
};
args.instance = instance;
if (openfirmware(&args) == -1)
return -1;
return args.package;
}
/* Get the length of a property of a package. */
int
OF_getproplen(phandle_t package, char *propname)
{
static struct {
char *name;
int nargs;
int nreturns;
phandle_t package;
char *propname;
int proplen;
} args = {
"getproplen",
2,
1,
};
args.package = package;
args.propname = propname;
if (openfirmware(&args) == -1)
return -1;
return args.proplen;
}
/* Get the value of a property of a package. */
int
OF_getprop(phandle_t package, char *propname, void *buf, int buflen)
{
static struct {
char *name;
int nargs;
int nreturns;
phandle_t package;
char *propname;
void *buf;
int buflen;
int size;
} args = {
"getprop",
4,
1,
};
args.package = package;
args.propname = propname;
args.buf = buf;
args.buflen = buflen;
if (openfirmware(&args) == -1)
return -1;
return args.size;
}
/* Get the next property of a package. */
int
OF_nextprop(phandle_t package, char *previous, char *buf)
{
static struct {
char *name;
int nargs;
int nreturns;
phandle_t package;
char *previous;
char *buf;
int flag;
} args = {
"nextprop",
3,
1,
};
args.package = package;
args.previous = previous;
args.buf = buf;
if (openfirmware(&args) == -1)
return -1;
return args.flag;
}
/* Set the value of a property of a package. */
/* XXX Has a bug on FirePower */
int
OF_setprop(phandle_t package, char *propname, void *buf, int len)
{
static struct {
char *name;
int nargs;
int nreturns;
phandle_t package;
char *propname;
void *buf;
int len;
int size;
} args = {
"setprop",
4,
1,
};
args.package = package;
args.propname = propname;
args.buf = buf;
args.len = len;
if (openfirmware(&args) == -1)
return -1;
return args.size;
}
/* Convert a device specifier to a fully qualified pathname. */
int
OF_canon(char *device, char *buf, int len)
{
static struct {
char *name;
int nargs;
int nreturns;
char *device;
char *buf;
int len;
int size;
} args = {
"canon",
3,
1,
};
args.device = device;
args.buf = buf;
args.len = len;
if (openfirmware(&args) == -1)
return -1;
return args.size;
}
/* Return a package handle for the specified device. */
phandle_t
OF_finddevice(char *device)
{
static struct {
char *name;
int nargs;
int nreturns;
char *device;
phandle_t package;
} args = {
"finddevice",
1,
1,
};
args.device = device;
if (openfirmware(&args) == -1)
return -1;
return args.package;
}
/* Return the fully qualified pathname corresponding to an instance. */
int
OF_instance_to_path(ihandle_t instance, char *buf, int len)
{
static struct {
char *name;
int nargs;
int nreturns;
ihandle_t instance;
char *buf;
int len;
int size;
} args = {
"instance-to-path",
3,
1,
};
args.instance = instance;
args.buf = buf;
args.len = len;
if (openfirmware(&args) == -1)
return -1;
return(args.size);
}
/* Return the fully qualified pathname corresponding to a package. */
int
OF_package_to_path(phandle_t package, char *buf, int len)
{
static struct {
char *name;
int nargs;
int nreturns;
phandle_t package;
char *buf;
int len;
int size;
} args = {
"package-to-path",
3,
1,
};
args.package = package;
args.buf = buf;
args.len = len;
if (openfirmware(&args) == -1)
return -1;
return(args.size);
}
/* Call the method in the scope of a given instance. */
int
OF_call_method(char *method, ihandle_t instance, int nargs, int nreturns, ...)
{
va_list ap;
static struct {
char *name;
int nargs;
int nreturns;
char *method;
ihandle_t instance;
int args_n_results[12];
} args = {
"call-method",
2,
1,
};
int *ip, n;
if (nargs > 6)
return -1;
args.nargs = nargs + 2;
args.nreturns = nreturns + 1;
args.method = method;
args.instance = instance;
va_start(ap, nreturns);
for (ip = args.args_n_results + (n = nargs); --n >= 0;)
*--ip = va_arg(ap, int);
if (openfirmware(&args) == -1)
return -1;
if (args.args_n_results[nargs])
return args.args_n_results[nargs];
for (ip = args.args_n_results + nargs + (n = args.nreturns); --n > 0;)
*va_arg(ap, int *) = *--ip;
va_end(ap);
return 0;
}
/*
* Device I/O functions.
*/
/* Open an instance for a device. */
ihandle_t
OF_open(char *device)
{
static struct {
char *name;
int nargs;
int nreturns;
char *device;
ihandle_t instance;
} args = {
"open",
1,
1,
};
args.device = device;
if (openfirmware(&args) == -1 || args.instance == 0) {
return -1;
}
return args.instance;
}
/* Close an instance. */
void
OF_close(ihandle_t instance)
{
static struct {
char *name;
int nargs;
int nreturns;
ihandle_t instance;
} args = {
"close",
1,
0,
};
args.instance = instance;
openfirmware(&args);
}
/* Read from an instance. */
int
OF_read(ihandle_t instance, void *addr, int len)
{
static struct {
char *name;
int nargs;
int nreturns;
ihandle_t instance;
void *addr;
int len;
int actual;
} args = {
"read",
3,
1,
};
args.instance = instance;
args.addr = addr;
args.len = len;
if (openfirmware(&args) == -1)
return -1;
return args.actual;
}
/* Write to an instance. */
int
OF_write(ihandle_t instance, void *addr, int len)
{
static struct {
char *name;
int nargs;
int nreturns;
ihandle_t instance;
void *addr;
int len;
int actual;
} args = {
"write",
3,
1,
};
args.instance = instance;
args.addr = addr;
args.len = len;
if (openfirmware(&args) == -1)
return -1;
return args.actual;
}
/* Seek to a position. */
int
OF_seek(ihandle_t instance, u_quad_t pos)
{
static struct {
char *name;
int nargs;
int nreturns;
ihandle_t instance;
int poshi;
int poslo;
int status;
} args = {
"seek",
3,
1,
};
args.instance = instance;
args.poshi = (int)(pos >> 32);
args.poslo = (int)pos;
if (openfirmware(&args) == -1)
return -1;
return args.status;
}
/*
* Memory functions.
*/
/* Claim an area of memory. */
void *
OF_claim(void *virt, u_int size, u_int align)
{
static struct {
char *name;
int nargs;
int nreturns;
void *virt;
u_int size;
u_int align;
void *baseaddr;
} args = {
"claim",
3,
1,
};
args.virt = virt;
args.size = size;
args.align = align;
if (openfirmware(&args) == -1)
return (void *)-1;
return args.baseaddr;
}
/* Release an area of memory. */
void
OF_release(void *virt, u_int size)
{
static struct {
char *name;
int nargs;
int nreturns;
void *virt;
u_int size;
} args = {
"release",
2,
0,
};
args.virt = virt;
args.size = size;
openfirmware(&args);
}
/*
* Control transfer functions.
*/
/* Reset the system and call "boot <bootspec>". */
void
OF_boot(char *bootspec)
{
static struct {
char *name;
int nargs;
int nreturns;
char *bootspec;
} args = {
"boot",
1,
0,
};
args.bootspec = bootspec;
openfirmware(&args);
for (;;); /* just in case */
}
/* Suspend and drop back to the OpenFirmware interface. */
void
OF_enter()
{
static struct {
char *name;
int nargs;
int nreturns;
} args = {
"enter",
0,
0
};
openfirmware(&args);
return; /* We may come back. */
}
/* Shut down and drop back to the OpenFirmware interface. */
__dead void
OF_exit()
{
static struct {
char *name;
int nargs;
int nreturns;
} args = {
"exit",
0,
0
};
openfirmware(&args);
for (;;); /* just in case */
}
/* Free <size> bytes starting at <virt>, then call <entry> with <arg>. */
#ifdef __notyet__
void
OF_chain(void *virt, u_int size, void (*entry)(), void *arg, u_int len)
{
static struct {
char *name;
int nargs;
int nreturns;
void *virt;
u_int size;
void (*entry)();
void *arg;
u_int len;
} args = {
"chain",
5,
0,
};
args.virt = virt;
args.size = size;
args.entry = entry;
args.arg = arg;
args.len = len;
openfirmware(&args);
}
#else
void
OF_chain(void *virt, u_int size, void (*entry)(), void *arg, u_int len)
{
/*
* This is a REALLY dirty hack till the firmware gets this going
*/
#if 0
OF_release(virt, size);
#endif
entry(0, 0, openfirmware, arg, len);
}
#endif

View File

@ -0,0 +1,119 @@
/* $NetBSD: openfirm.h,v 1.1 1998/05/15 10:16:00 tsubai Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
* Copyright (C) 1995, 1996 TooLs GmbH.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by TooLs GmbH.
* 4. The name of TooLs GmbH may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (C) 2000 Benno Rice.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
/*
* Prototypes for Openfirmware Interface Routines
*/
#include <sys/cdefs.h>
#include <sys/types.h>
typedef int ihandle_t;
typedef int phandle_t;
/*
* This isn't actually an OpenFirmware function, but it seemed like the right
* place for it to go.
*/
void OF_init(int (*openfirm)(void *));
/* Generic functions */
int OF_test(char *);
/* Device tree functions */
phandle_t OF_peer(phandle_t);
phandle_t OF_child(phandle_t);
phandle_t OF_parent(phandle_t);
phandle_t OF_instance_to_package(ihandle_t);
int OF_getproplen(phandle_t, char *);
int OF_getprop(phandle_t, char *, void *, int);
int OF_nextprop(phandle_t, char *, char *);
int OF_setprop(phandle_t, char *, void *, int);
int OF_canon(char *, char *, int);
phandle_t OF_finddevice(char *);
int OF_instance_to_path(ihandle_t, char *, int);
int OF_package_to_path(phandle_t, char *, int);
int OF_call_method(char *, ihandle_t, int, int, ...);
/* Device I/O functions */
ihandle_t OF_open(char *);
void OF_close(ihandle_t);
int OF_read(ihandle_t, void *, int);
int OF_write(ihandle_t, void *, int);
int OF_seek(ihandle_t, u_quad_t);
/* Memory functions */
void *OF_claim(void *, u_int, u_int);
void OF_release(void *, u_int);
/* Control transfer functions */
void OF_boot(char *);
void OF_enter(void);
__dead void OF_exit(void) __attribute__((noreturn));
void OF_chain(void *, u_int, void (*)(), void *, u_int);
#if 0
/* User interface functions */
/* OF_interpret */
void *OF_set_callback(void *);
void OF_set_symbol_lookup(void *, void *);
#endif
/* Time function */
int OF_milliseconds(void);

View File

@ -0,0 +1,5 @@
# $FreeBSD$
SUBDIR= loader
.include <bsd.subdir.mk>

View File

@ -0,0 +1,116 @@
# $FreeBSD$
BASE= loader
PROG= ${BASE}
NOMAN=
MAN1=
NEWVERSWHAT= "bootstrap loader" OpenFirmware/PowerPC
BINDIR?= /boot
NOGCCERROR= YES
# architecture-specific loader code
SRCS= conf.c
CFLAGS+= -DLOADER_DISK_SUPPORT
.if !defined(NOFORTH)
# Enable BootForth
BOOT_FORTH= yes
CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/powerpc
.if exists(${.OBJDIR}/../../ficl/libficl.a)
LIBFICL= ${.OBJDIR}/../../ficl/libficl.a
.else
LIBFICL= ${.CURDIR}/../../ficl/libficl.a
.endif
.endif
# Always add MI sources
.PATH: ${.CURDIR}/../../common
.include <${.CURDIR}/../../common/Makefile.inc>
CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I.
CLEANFILES+= vers.c vers.o ${BASE}.list ${BASE}.bin ${BASE}.sym ${BASE}.help
CFLAGS+= -Wall
LDFLAGS= -nostdlib -static -Ttext 6c0000
# OpenFirmware standalone support library
LIBOFW= ${.OBJDIR}/../../ofw/libofw/libofw.a
CFLAGS+= -I${.CURDIR}/../../ofw/libofw
# where to get libstand from
#XXX need a better way to do this
LIBSTAND= ${.CURDIR}/../../../../lib/libstand/libstand.a
#.if !exists(${LIBSTAND})
#LIBSTAND= ${.OBJDIR}/../../../../lib/libstand/libstand.a
#.if !exists(${LIBSTAND})
#LIBSTAND= -lstand
#.endif
#.endif
CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
# OpenFirmware is expecting ELF components
CFLAGS+= -elf
# New linker set code
#CFLAGS+= -DNEW_LINKER_SET
vers.o: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
${CC} -c vers.c
${BASE}.help: help.common help.ofw
cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk \
> ${.TARGET}
beforeinstall:
.if exists(${DESTDIR}/boot/loader)
mv ${DESTDIR}/boot/loader ${DESTDIR}/boot/loader.old
.endif
.if exists(${.OBJDIR}/loader.help)
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
${.OBJDIR}/${BASE}.help ${DESTDIR}/boot
.else
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
${.CURDIR}/${BASE}.help ${DESTDIR}/boot
.endif
.if !exists(${DESTDIR}/boot/loader.rc)
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
${.CURDIR}/../../forth/loader.rc ${DESTDIR}/boot
.endif
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
${.CURDIR}/../../forth/loader.4th ${DESTDIR}/boot
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
${.CURDIR}/../../forth/support.4th ${DESTDIR}/boot
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
${.CURDIR}/../../forth/loader.conf ${DESTDIR}/boot/defaults
${PROG}: ${OBJS} ${LIBOFW} ${LIBSTAND} ${LIBFICL} powerpc.o vers.o setdef0.o \
setdef1.o
${LD} ${LDFLAGS} -o ${.TARGET} setdef0.o powerpc.o ${OBJS} setdef1.o \
vers.o ${LIBFICL} ${LIBOFW} ${LIBSTAND}
setdef0.o: setdefs.h
setdef1.o: setdefs.h
# Cannot use ${OBJS} above this line
.include <bsd.prog.mk>
# If it's not there, don't consider it a target
.if exists(${.CURDIR}/../../../ofw/include)
beforedepend ${OBJS}: machine
machine:
ln -sf ${.CURDIR}/../../../ofw/include machine
.endif
CLEANFILES+= machine setdefs.h setdef0.c setdef1.c setdef0.o setdef1.o \
powerpc.o
.ORDER: setdefs.h setdef0.c setdef1.c
setdefs.h setdef0.c setdef1.c: ${OBJS}
@echo Generating linker sets
@gensetdefs ${OBJS}

View File

@ -0,0 +1 @@
$FreeBSD$

View File

@ -0,0 +1,6 @@
$FreeBSD$
NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
file is important. Make sure the current version number is on line 6.
0.1: Initial OFW/PowerPC version.

View File

@ -0,0 +1,116 @@
# $FreeBSD$
BASE= loader
PROG= ${BASE}
NOMAN=
MAN1=
NEWVERSWHAT= "bootstrap loader" OpenFirmware/PowerPC
BINDIR?= /boot
NOGCCERROR= YES
# architecture-specific loader code
SRCS= conf.c
CFLAGS+= -DLOADER_DISK_SUPPORT
.if !defined(NOFORTH)
# Enable BootForth
BOOT_FORTH= yes
CFLAGS+= -DBOOT_FORTH -I${.CURDIR}/../../ficl -I${.CURDIR}/../../ficl/powerpc
.if exists(${.OBJDIR}/../../ficl/libficl.a)
LIBFICL= ${.OBJDIR}/../../ficl/libficl.a
.else
LIBFICL= ${.CURDIR}/../../ficl/libficl.a
.endif
.endif
# Always add MI sources
.PATH: ${.CURDIR}/../../common
.include <${.CURDIR}/../../common/Makefile.inc>
CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I.
CLEANFILES+= vers.c vers.o ${BASE}.list ${BASE}.bin ${BASE}.sym ${BASE}.help
CFLAGS+= -Wall
LDFLAGS= -nostdlib -static -Ttext 6c0000
# OpenFirmware standalone support library
LIBOFW= ${.OBJDIR}/../../ofw/libofw/libofw.a
CFLAGS+= -I${.CURDIR}/../../ofw/libofw
# where to get libstand from
#XXX need a better way to do this
LIBSTAND= ${.CURDIR}/../../../../lib/libstand/libstand.a
#.if !exists(${LIBSTAND})
#LIBSTAND= ${.OBJDIR}/../../../../lib/libstand/libstand.a
#.if !exists(${LIBSTAND})
#LIBSTAND= -lstand
#.endif
#.endif
CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
# OpenFirmware is expecting ELF components
CFLAGS+= -elf
# New linker set code
#CFLAGS+= -DNEW_LINKER_SET
vers.o: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
${CC} -c vers.c
${BASE}.help: help.common help.ofw
cat ${.ALLSRC} | awk -f ${.CURDIR}/../../common/merge_help.awk \
> ${.TARGET}
beforeinstall:
.if exists(${DESTDIR}/boot/loader)
mv ${DESTDIR}/boot/loader ${DESTDIR}/boot/loader.old
.endif
.if exists(${.OBJDIR}/loader.help)
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
${.OBJDIR}/${BASE}.help ${DESTDIR}/boot
.else
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
${.CURDIR}/${BASE}.help ${DESTDIR}/boot
.endif
.if !exists(${DESTDIR}/boot/loader.rc)
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
${.CURDIR}/../../forth/loader.rc ${DESTDIR}/boot
.endif
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
${.CURDIR}/../../forth/loader.4th ${DESTDIR}/boot
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
${.CURDIR}/../../forth/support.4th ${DESTDIR}/boot
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 \
${.CURDIR}/../../forth/loader.conf ${DESTDIR}/boot/defaults
${PROG}: ${OBJS} ${LIBOFW} ${LIBSTAND} ${LIBFICL} powerpc.o vers.o setdef0.o \
setdef1.o
${LD} ${LDFLAGS} -o ${.TARGET} setdef0.o powerpc.o ${OBJS} setdef1.o \
vers.o ${LIBFICL} ${LIBOFW} ${LIBSTAND}
setdef0.o: setdefs.h
setdef1.o: setdefs.h
# Cannot use ${OBJS} above this line
.include <bsd.prog.mk>
# If it's not there, don't consider it a target
.if exists(${.CURDIR}/../../../ofw/include)
beforedepend ${OBJS}: machine
machine:
ln -sf ${.CURDIR}/../../../ofw/include machine
.endif
CLEANFILES+= machine setdefs.h setdef0.c setdef1.c setdef0.o setdef1.o \
powerpc.o
.ORDER: setdefs.h setdef0.c setdef1.c
setdefs.h setdef0.c setdef1.c: ${OBJS}
@echo Generating linker sets
@gensetdefs ${OBJS}

View File

@ -0,0 +1 @@
$FreeBSD$

View File

@ -0,0 +1,6 @@
$FreeBSD$
NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
file is important. Make sure the current version number is on line 6.
0.1: Initial OFW/PowerPC version.

733
sys/dev/ofw/openfirm.c Normal file
View File

@ -0,0 +1,733 @@
/* $NetBSD: Locore.c,v 1.7 2000/08/20 07:04:59 tsubai Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
* Copyright (C) 1995, 1996 TooLs GmbH.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by TooLs GmbH.
* 4. The name of TooLs GmbH may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (C) 2000 Benno Rice.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <machine/stdarg.h>
#include "openfirm.h"
static int (*openfirmware)(void *);
static ihandle_t stdin;
static ihandle_t stdout;
/* Initialiaser */
void
OF_init(int (*openfirm)(void *))
{
openfirmware = openfirm;
}
/*
* Generic functions
*/
/* Test to see if a service exists. */
int
OF_test(char *name)
{
static struct {
char *name;
int nargs;
int nreturns;
char *service;
int missing;
} args = {
"test",
1,
1,
};
args.service = name;
if (openfirmware(&args) == -1)
return -1;
return args.missing;
}
/* Return firmware millisecond count. */
int
OF_milliseconds()
{
static struct {
char *name;
int nargs;
int nreturns;
int ms;
} args = {
"milliseconds",
0,
1,
};
openfirmware(&args);
return args.ms;
}
/*
* Device tree functions
*/
/* Return the next sibling of this node or 0. */
phandle_t
OF_peer(phandle_t node)
{
static struct {
char *name;
int nargs;
int nreturns;
phandle_t node;
phandle_t next;
} args = {
"peer",
1,
1,
};
args.node = node;
if (openfirmware(&args) == -1)
return -1;
return args.next;
}
/* Return the first child of this node or 0. */
phandle_t
OF_child(phandle_t node)
{
static struct {
char *name;
int nargs;
int nreturns;
phandle_t node;
phandle_t child;
} args = {
"child",
1,
1,
};
args.node = node;
if (openfirmware(&args) == -1)
return -1;
return args.child;
}
/* Return the parent of this node or 0. */
phandle_t
OF_parent(phandle_t node)
{
static struct {
char *name;
int nargs;
int nreturns;
phandle_t node;
phandle_t parent;
} args = {
"parent",
1,
1,
};
args.node = node;
if (openfirmware(&args) == -1)
return -1;
return args.parent;
}
/* Return the package handle that corresponds to an instance handle. */
phandle_t
OF_instance_to_package(ihandle_t instance)
{
static struct {
char *name;
int nargs;
int nreturns;
ihandle_t instance;
phandle_t package;
} args = {
"instance-to-package",
1,
1,
};
args.instance = instance;
if (openfirmware(&args) == -1)
return -1;
return args.package;
}
/* Get the length of a property of a package. */
int
OF_getproplen(phandle_t package, char *propname)
{
static struct {
char *name;
int nargs;
int nreturns;
phandle_t package;
char *propname;
int proplen;
} args = {
"getproplen",
2,
1,
};
args.package = package;
args.propname = propname;
if (openfirmware(&args) == -1)
return -1;
return args.proplen;
}
/* Get the value of a property of a package. */
int
OF_getprop(phandle_t package, char *propname, void *buf, int buflen)
{
static struct {
char *name;
int nargs;
int nreturns;
phandle_t package;
char *propname;
void *buf;
int buflen;
int size;
} args = {
"getprop",
4,
1,
};
args.package = package;
args.propname = propname;
args.buf = buf;
args.buflen = buflen;
if (openfirmware(&args) == -1)
return -1;
return args.size;
}
/* Get the next property of a package. */
int
OF_nextprop(phandle_t package, char *previous, char *buf)
{
static struct {
char *name;
int nargs;
int nreturns;
phandle_t package;
char *previous;
char *buf;
int flag;
} args = {
"nextprop",
3,
1,
};
args.package = package;
args.previous = previous;
args.buf = buf;
if (openfirmware(&args) == -1)
return -1;
return args.flag;
}
/* Set the value of a property of a package. */
/* XXX Has a bug on FirePower */
int
OF_setprop(phandle_t package, char *propname, void *buf, int len)
{
static struct {
char *name;
int nargs;
int nreturns;
phandle_t package;
char *propname;
void *buf;
int len;
int size;
} args = {
"setprop",
4,
1,
};
args.package = package;
args.propname = propname;
args.buf = buf;
args.len = len;
if (openfirmware(&args) == -1)
return -1;
return args.size;
}
/* Convert a device specifier to a fully qualified pathname. */
int
OF_canon(char *device, char *buf, int len)
{
static struct {
char *name;
int nargs;
int nreturns;
char *device;
char *buf;
int len;
int size;
} args = {
"canon",
3,
1,
};
args.device = device;
args.buf = buf;
args.len = len;
if (openfirmware(&args) == -1)
return -1;
return args.size;
}
/* Return a package handle for the specified device. */
phandle_t
OF_finddevice(char *device)
{
static struct {
char *name;
int nargs;
int nreturns;
char *device;
phandle_t package;
} args = {
"finddevice",
1,
1,
};
args.device = device;
if (openfirmware(&args) == -1)
return -1;
return args.package;
}
/* Return the fully qualified pathname corresponding to an instance. */
int
OF_instance_to_path(ihandle_t instance, char *buf, int len)
{
static struct {
char *name;
int nargs;
int nreturns;
ihandle_t instance;
char *buf;
int len;
int size;
} args = {
"instance-to-path",
3,
1,
};
args.instance = instance;
args.buf = buf;
args.len = len;
if (openfirmware(&args) == -1)
return -1;
return(args.size);
}
/* Return the fully qualified pathname corresponding to a package. */
int
OF_package_to_path(phandle_t package, char *buf, int len)
{
static struct {
char *name;
int nargs;
int nreturns;
phandle_t package;
char *buf;
int len;
int size;
} args = {
"package-to-path",
3,
1,
};
args.package = package;
args.buf = buf;
args.len = len;
if (openfirmware(&args) == -1)
return -1;
return(args.size);
}
/* Call the method in the scope of a given instance. */
int
OF_call_method(char *method, ihandle_t instance, int nargs, int nreturns, ...)
{
va_list ap;
static struct {
char *name;
int nargs;
int nreturns;
char *method;
ihandle_t instance;
int args_n_results[12];
} args = {
"call-method",
2,
1,
};
int *ip, n;
if (nargs > 6)
return -1;
args.nargs = nargs + 2;
args.nreturns = nreturns + 1;
args.method = method;
args.instance = instance;
va_start(ap, nreturns);
for (ip = args.args_n_results + (n = nargs); --n >= 0;)
*--ip = va_arg(ap, int);
if (openfirmware(&args) == -1)
return -1;
if (args.args_n_results[nargs])
return args.args_n_results[nargs];
for (ip = args.args_n_results + nargs + (n = args.nreturns); --n > 0;)
*va_arg(ap, int *) = *--ip;
va_end(ap);
return 0;
}
/*
* Device I/O functions.
*/
/* Open an instance for a device. */
ihandle_t
OF_open(char *device)
{
static struct {
char *name;
int nargs;
int nreturns;
char *device;
ihandle_t instance;
} args = {
"open",
1,
1,
};
args.device = device;
if (openfirmware(&args) == -1 || args.instance == 0) {
return -1;
}
return args.instance;
}
/* Close an instance. */
void
OF_close(ihandle_t instance)
{
static struct {
char *name;
int nargs;
int nreturns;
ihandle_t instance;
} args = {
"close",
1,
0,
};
args.instance = instance;
openfirmware(&args);
}
/* Read from an instance. */
int
OF_read(ihandle_t instance, void *addr, int len)
{
static struct {
char *name;
int nargs;
int nreturns;
ihandle_t instance;
void *addr;
int len;
int actual;
} args = {
"read",
3,
1,
};
args.instance = instance;
args.addr = addr;
args.len = len;
if (openfirmware(&args) == -1)
return -1;
return args.actual;
}
/* Write to an instance. */
int
OF_write(ihandle_t instance, void *addr, int len)
{
static struct {
char *name;
int nargs;
int nreturns;
ihandle_t instance;
void *addr;
int len;
int actual;
} args = {
"write",
3,
1,
};
args.instance = instance;
args.addr = addr;
args.len = len;
if (openfirmware(&args) == -1)
return -1;
return args.actual;
}
/* Seek to a position. */
int
OF_seek(ihandle_t instance, u_quad_t pos)
{
static struct {
char *name;
int nargs;
int nreturns;
ihandle_t instance;
int poshi;
int poslo;
int status;
} args = {
"seek",
3,
1,
};
args.instance = instance;
args.poshi = (int)(pos >> 32);
args.poslo = (int)pos;
if (openfirmware(&args) == -1)
return -1;
return args.status;
}
/*
* Memory functions.
*/
/* Claim an area of memory. */
void *
OF_claim(void *virt, u_int size, u_int align)
{
static struct {
char *name;
int nargs;
int nreturns;
void *virt;
u_int size;
u_int align;
void *baseaddr;
} args = {
"claim",
3,
1,
};
args.virt = virt;
args.size = size;
args.align = align;
if (openfirmware(&args) == -1)
return (void *)-1;
return args.baseaddr;
}
/* Release an area of memory. */
void
OF_release(void *virt, u_int size)
{
static struct {
char *name;
int nargs;
int nreturns;
void *virt;
u_int size;
} args = {
"release",
2,
0,
};
args.virt = virt;
args.size = size;
openfirmware(&args);
}
/*
* Control transfer functions.
*/
/* Reset the system and call "boot <bootspec>". */
void
OF_boot(char *bootspec)
{
static struct {
char *name;
int nargs;
int nreturns;
char *bootspec;
} args = {
"boot",
1,
0,
};
args.bootspec = bootspec;
openfirmware(&args);
for (;;); /* just in case */
}
/* Suspend and drop back to the OpenFirmware interface. */
void
OF_enter()
{
static struct {
char *name;
int nargs;
int nreturns;
} args = {
"enter",
0,
0
};
openfirmware(&args);
return; /* We may come back. */
}
/* Shut down and drop back to the OpenFirmware interface. */
__dead void
OF_exit()
{
static struct {
char *name;
int nargs;
int nreturns;
} args = {
"exit",
0,
0
};
openfirmware(&args);
for (;;); /* just in case */
}
/* Free <size> bytes starting at <virt>, then call <entry> with <arg>. */
#ifdef __notyet__
void
OF_chain(void *virt, u_int size, void (*entry)(), void *arg, u_int len)
{
static struct {
char *name;
int nargs;
int nreturns;
void *virt;
u_int size;
void (*entry)();
void *arg;
u_int len;
} args = {
"chain",
5,
0,
};
args.virt = virt;
args.size = size;
args.entry = entry;
args.arg = arg;
args.len = len;
openfirmware(&args);
}
#else
void
OF_chain(void *virt, u_int size, void (*entry)(), void *arg, u_int len)
{
/*
* This is a REALLY dirty hack till the firmware gets this going
*/
#if 0
OF_release(virt, size);
#endif
entry(0, 0, openfirmware, arg, len);
}
#endif

119
sys/dev/ofw/openfirm.h Normal file
View File

@ -0,0 +1,119 @@
/* $NetBSD: openfirm.h,v 1.1 1998/05/15 10:16:00 tsubai Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
* Copyright (C) 1995, 1996 TooLs GmbH.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by TooLs GmbH.
* 4. The name of TooLs GmbH may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (C) 2000 Benno Rice.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
/*
* Prototypes for Openfirmware Interface Routines
*/
#include <sys/cdefs.h>
#include <sys/types.h>
typedef int ihandle_t;
typedef int phandle_t;
/*
* This isn't actually an OpenFirmware function, but it seemed like the right
* place for it to go.
*/
void OF_init(int (*openfirm)(void *));
/* Generic functions */
int OF_test(char *);
/* Device tree functions */
phandle_t OF_peer(phandle_t);
phandle_t OF_child(phandle_t);
phandle_t OF_parent(phandle_t);
phandle_t OF_instance_to_package(ihandle_t);
int OF_getproplen(phandle_t, char *);
int OF_getprop(phandle_t, char *, void *, int);
int OF_nextprop(phandle_t, char *, char *);
int OF_setprop(phandle_t, char *, void *, int);
int OF_canon(char *, char *, int);
phandle_t OF_finddevice(char *);
int OF_instance_to_path(ihandle_t, char *, int);
int OF_package_to_path(phandle_t, char *, int);
int OF_call_method(char *, ihandle_t, int, int, ...);
/* Device I/O functions */
ihandle_t OF_open(char *);
void OF_close(ihandle_t);
int OF_read(ihandle_t, void *, int);
int OF_write(ihandle_t, void *, int);
int OF_seek(ihandle_t, u_quad_t);
/* Memory functions */
void *OF_claim(void *, u_int, u_int);
void OF_release(void *, u_int);
/* Control transfer functions */
void OF_boot(char *);
void OF_enter(void);
__dead void OF_exit(void) __attribute__((noreturn));
void OF_chain(void *, u_int, void (*)(), void *, u_int);
#if 0
/* User interface functions */
/* OF_interpret */
void *OF_set_callback(void *);
void OF_set_symbol_lookup(void *, void *);
#endif
/* Time function */
int OF_milliseconds(void);