aboutsummaryrefslogtreecommitdiff
path: root/stand/ofw
diff options
context:
space:
mode:
authorBrandon Bergren <bdragon@FreeBSD.org>2020-01-02 04:34:22 +0000
committerBrandon Bergren <bdragon@FreeBSD.org>2020-01-02 04:34:22 +0000
commit475008d6ca47ccb2b4baca59a37421d95916d2ba (patch)
treea6cfc19ccc21522b34a7d42d98f295760ef01e90 /stand/ofw
parentbad7e1e85c2e8e2bb3fdcdf736e099b7aa03d663 (diff)
downloadsrc-475008d6ca47ccb2b4baca59a37421d95916d2ba.tar.gz
src-475008d6ca47ccb2b4baca59a37421d95916d2ba.zip
Move stand/ofw/libofw to stand/libofw.
Since rS330365, there has been no particular reason for libofw to be in a subdirectory of ofw. Move libofw up a level to make it fit in better with the other top level libraries. Also add a LIBOFWSRC to stand/defs.mk to match what all the other libraries are doing. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D23000
Notes
Notes: svn path=/head/; revision=356266
Diffstat (limited to 'stand/ofw')
-rw-r--r--stand/ofw/Makefile5
-rw-r--r--stand/ofw/Makefile.inc3
-rw-r--r--stand/ofw/libofw/Makefile22
-rw-r--r--stand/ofw/libofw/devicename.c146
-rw-r--r--stand/ofw/libofw/libofw.h85
-rw-r--r--stand/ofw/libofw/ofw_console.c124
-rw-r--r--stand/ofw/libofw/ofw_copy.c173
-rw-r--r--stand/ofw/libofw/ofw_disk.c184
-rw-r--r--stand/ofw/libofw/ofw_memory.c114
-rw-r--r--stand/ofw/libofw/ofw_module.c49
-rw-r--r--stand/ofw/libofw/ofw_net.c275
-rw-r--r--stand/ofw/libofw/ofw_reboot.c37
-rw-r--r--stand/ofw/libofw/ofw_time.c61
-rw-r--r--stand/ofw/libofw/openfirm.c831
-rw-r--r--stand/ofw/libofw/openfirm.h124
15 files changed, 0 insertions, 2233 deletions
diff --git a/stand/ofw/Makefile b/stand/ofw/Makefile
deleted file mode 100644
index 3b881b780e87..000000000000
--- a/stand/ofw/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-# $FreeBSD$
-
-SUBDIR= libofw
-
-.include <bsd.subdir.mk>
diff --git a/stand/ofw/Makefile.inc b/stand/ofw/Makefile.inc
deleted file mode 100644
index 265f86d1ed55..000000000000
--- a/stand/ofw/Makefile.inc
+++ /dev/null
@@ -1,3 +0,0 @@
-# $FreeBSD$
-
-.include "../Makefile.inc"
diff --git a/stand/ofw/libofw/Makefile b/stand/ofw/libofw/Makefile
deleted file mode 100644
index 1017988705a6..000000000000
--- a/stand/ofw/libofw/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-# $FreeBSD$
-
-.include <bsd.init.mk>
-
-LIB= ofw
-
-SRCS= devicename.c ofw_console.c ofw_copy.c ofw_disk.c \
- ofw_memory.c ofw_module.c ofw_net.c ofw_reboot.c \
- ofw_time.c openfirm.c
-.PATH: ${ZFSSRC}
-SRCS+= devicename_stubs.c
-CFLAGS+= -I${ZFSSRC}
-
-# Pick up the bootstrap header for some interface items
-CFLAGS+= -I${LDRSRC}
-
-.ifdef(BOOT_DISK_DEBUG)
-# Make the disk code more talkative
-CFLAGS+= -DDISK_DEBUG
-.endif
-
-.include <bsd.lib.mk>
diff --git a/stand/ofw/libofw/devicename.c b/stand/ofw/libofw/devicename.c
deleted file mode 100644
index 786e5549c0fc..000000000000
--- a/stand/ofw/libofw/devicename.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*-
- * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
- * 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 AUTHOR 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <stand.h>
-
-#include "bootstrap.h"
-#include "libofw.h"
-#include "libzfs.h"
-
-static int ofw_parsedev(struct ofw_devdesc **, const char *, const char **);
-
-/*
- * Point (dev) at an allocated device specifier for the device matching the
- * path in (devspec). If it contains an explicit device specification,
- * use that. If not, use the default device.
- */
-int
-ofw_getdev(void **vdev, const char *devspec, const char **path)
-{
- struct ofw_devdesc **dev = (struct ofw_devdesc **)vdev;
- int rv;
-
- /*
- * If it looks like this is just a path and no
- * device, go with the current device.
- */
- if ((devspec == NULL) ||
- ((strchr(devspec, '@') == NULL) &&
- (strchr(devspec, ':') == NULL))) {
-
- if (((rv = ofw_parsedev(dev, getenv("currdev"), NULL)) == 0) &&
- (path != NULL))
- *path = devspec;
- return(rv);
- }
-
- /*
- * Try to parse the device name off the beginning of the devspec
- */
- return(ofw_parsedev(dev, devspec, path));
-}
-
-/*
- * Point (dev) at an allocated device specifier matching the string version
- * at the beginning of (devspec). Return a pointer to the remaining
- * text in (path).
- */
-static int
-ofw_parsedev(struct ofw_devdesc **dev, const char *devspec, const char **path)
-{
- struct ofw_devdesc *idev;
- struct devsw *dv;
- phandle_t handle;
- const char *p;
- const char *s;
- char *ep;
- char name[256];
- char type[64];
- int err;
- int len;
- int i;
-
- for (p = s = devspec; *s != '\0'; p = s) {
- if ((s = strchr(p + 1, '/')) == NULL)
- s = strchr(p, '\0');
- len = s - devspec;
- bcopy(devspec, name, len);
- name[len] = '\0';
- if ((handle = OF_finddevice(name)) == -1) {
- bcopy(name, type, len);
- type[len] = '\0';
- } else if (OF_getprop(handle, "device_type", type, sizeof(type)) == -1)
- continue;
- for (i = 0; (dv = devsw[i]) != NULL; i++) {
- if (strncmp(dv->dv_name, type, strlen(dv->dv_name)) == 0)
- goto found;
- }
- }
- return(ENOENT);
-
-found:
- if (path != NULL)
- *path = s;
- idev = malloc(sizeof(struct ofw_devdesc));
- if (idev == NULL) {
- printf("ofw_parsedev: malloc failed\n");
- return ENOMEM;
- }
- strcpy(idev->d_path, name);
- idev->dd.d_dev = dv;
- if (dv->dv_type == DEVT_ZFS) {
- p = devspec + strlen(dv->dv_name);
- err = zfs_parsedev((struct zfs_devdesc *)idev, p, path);
- if (err != 0) {
- free(idev);
- return (err);
- }
- }
-
- if (dev == NULL) {
- free(idev);
- } else {
- *dev = idev;
- }
- return(0);
-}
-
-int
-ofw_setcurrdev(struct env_var *ev, int flags, const void *value)
-{
- struct ofw_devdesc *ncurr;
- int rv;
-
- if ((rv = ofw_parsedev(&ncurr, value, NULL)) != 0)
- return rv;
-
- free(ncurr);
- env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL);
- return 0;
-}
diff --git a/stand/ofw/libofw/libofw.h b/stand/ofw/libofw/libofw.h
deleted file mode 100644
index 4a1e6a34bb2e..000000000000
--- a/stand/ofw/libofw/libofw.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * 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"
-
-struct ofw_devdesc {
- struct devdesc dd;
- union {
- struct {
- ihandle_t d_handle;
- char d_path[256];
- };
- struct {
- uint64_t pool_guid;
- uint64_t root_guid;
- };
- };
-};
-
-extern int ofw_getdev(void **vdev, const char *devspec, const char **path);
-extern ev_sethook_t ofw_setcurrdev;
-
-extern struct devsw ofwdisk;
-extern struct netif_driver ofwnet;
-
-int ofwn_getunit(const char *);
-
-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);
-
-void ofw_memmap(int);
-
-struct preloaded_file;
-struct file_format;
-
-/* MD code implementing MI interfaces */
-#if !defined(__sparc64__)
-vm_offset_t md_load(char *args, vm_offset_t *modulep, vm_offset_t *dtb);
-#endif
-vm_offset_t md_load64(char *args, vm_offset_t *modulep, vm_offset_t *dtb);
-
-extern void reboot(void);
-
-struct ofw_reg
-{
- cell_t base;
- cell_t size;
-};
-
-struct ofw_reg2
-{
- cell_t base_hi;
- cell_t base_lo;
- cell_t size;
-};
-
-extern int (*openfirmware)(void *);
diff --git a/stand/ofw/libofw/ofw_console.c b/stand/ofw/libofw/ofw_console.c
deleted file mode 100644
index a129997c5df2..000000000000
--- a/stand/ofw/libofw/ofw_console.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/* $NetBSD: prom.c,v 1.3 1997/09/06 14:03:58 drochner Exp $ */
-
-/*-
- * Mach Operating System
- * Copyright (c) 1992 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-
-#include "bootstrap.h"
-#include "openfirm.h"
-
-static void ofw_cons_probe(struct console *cp);
-static int ofw_cons_init(int);
-void ofw_cons_putchar(int);
-int ofw_cons_getchar(void);
-int ofw_cons_poll(void);
-
-static ihandle_t stdin;
-static ihandle_t stdout;
-
-struct console ofwconsole = {
- "ofw",
- "Open Firmware console",
- 0,
- ofw_cons_probe,
- ofw_cons_init,
- ofw_cons_putchar,
- ofw_cons_getchar,
- ofw_cons_poll,
-};
-
-static void
-ofw_cons_probe(struct console *cp)
-{
-
- OF_getprop(chosen, "stdin", &stdin, sizeof(stdin));
- OF_getprop(chosen, "stdout", &stdout, sizeof(stdout));
- cp->c_flags |= C_PRESENTIN|C_PRESENTOUT;
-}
-
-static int
-ofw_cons_init(int arg)
-{
- return 0;
-}
-
-void
-ofw_cons_putchar(int c)
-{
- char cbuf;
-
- if (c == '\n') {
- cbuf = '\r';
- OF_write(stdout, &cbuf, 1);
- }
-
- cbuf = c;
- OF_write(stdout, &cbuf, 1);
-}
-
-static int saved_char = -1;
-
-int
-ofw_cons_getchar()
-{
- unsigned char ch = '\0';
- int l;
-
- if (saved_char != -1) {
- l = saved_char;
- saved_char = -1;
- return l;
- }
-
- /* At least since version 4.0.0, QEMU became bug-compatible
- * with PowerVM's vty, by inserting a \0 after every \r.
- * As this confuses loader's interpreter and as a \0 coming
- * from the console doesn't seem reasonable, it's filtered here. */
- if (OF_read(stdin, &ch, 1) > 0 && ch != '\0')
- return (ch);
-
- return (-1);
-}
-
-int
-ofw_cons_poll()
-{
- unsigned char ch;
-
- if (saved_char != -1)
- return 1;
-
- if (OF_read(stdin, &ch, 1) > 0) {
- saved_char = ch;
- return 1;
- }
-
- return 0;
-}
diff --git a/stand/ofw/libofw/ofw_copy.c b/stand/ofw/libofw/ofw_copy.c
deleted file mode 100644
index d83dbeddb577..000000000000
--- a/stand/ofw/libofw/ofw_copy.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*-
- * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
- * 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 AUTHOR 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * MD primitives supporting placement of module data
- *
- * XXX should check load address/size against memory top.
- */
-#include <stand.h>
-
-#include "libofw.h"
-
-#define READIN_BUF (4 * 1024)
-#define PAGE_SIZE 0x1000
-#define PAGE_MASK 0x0fff
-#define MAPMEM_PAGE_INC 128 /* Half-MB at a time */
-
-
-#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
-
-static int
-ofw_mapmem(vm_offset_t dest, const size_t len)
-{
- void *destp, *addr;
- size_t dlen;
- size_t resid;
- size_t nlen;
- static vm_offset_t last_dest = 0;
- static size_t last_len = 0;
-
- nlen = len;
- /*
- * Check to see if this region fits in a prior mapping.
- * Allocations are generally sequential, so only check
- * the last one.
- */
- if (dest >= last_dest &&
- (dest + len) <= (last_dest + last_len)) {
- return (0);
- }
-
- /*
- * Trim area covered by existing mapping, if any
- */
- if (dest < (last_dest + last_len) && dest >= last_dest) {
- nlen -= (last_dest + last_len) - dest;
- dest = last_dest + last_len;
- }
-
- destp = (void *)(dest & ~PAGE_MASK);
- resid = dest & PAGE_MASK;
-
- /*
- * To avoid repeated mappings on small allocations,
- * never map anything less than MAPMEM_PAGE_INC pages at a time
- */
- if ((nlen + resid) < PAGE_SIZE*MAPMEM_PAGE_INC) {
- dlen = PAGE_SIZE*MAPMEM_PAGE_INC;
- } else
- dlen = roundup(nlen + resid, PAGE_SIZE);
-
- if (OF_call_method("claim", memory, 3, 1, destp, dlen, 0, &addr)
- == -1) {
- printf("ofw_mapmem: physical claim failed\n");
- return (ENOMEM);
- }
-
- /*
- * We only do virtual memory management when real_mode is false.
- */
- if (real_mode == 0) {
- if (OF_call_method("claim", mmu, 3, 1, destp, dlen, 0, &addr)
- == -1) {
- printf("ofw_mapmem: virtual claim failed\n");
- return (ENOMEM);
- }
-
- if (OF_call_method("map", mmu, 4, 0, destp, destp, dlen, 0)
- == -1) {
- printf("ofw_mapmem: map failed\n");
- return (ENOMEM);
- }
- }
- last_dest = (vm_offset_t) destp;
- last_len = dlen;
-
- return (0);
-}
-
-ssize_t
-ofw_copyin(const void *src, vm_offset_t dest, const size_t len)
-{
- if (ofw_mapmem(dest, len)) {
- printf("ofw_copyin: map error\n");
- return (0);
- }
-
- bcopy(src, (void *)dest, len);
- return(len);
-}
-
-ssize_t
-ofw_copyout(const vm_offset_t src, void *dest, const size_t len)
-{
- bcopy((void *)src, dest, len);
- return(len);
-}
-
-ssize_t
-ofw_readin(const int fd, vm_offset_t dest, const size_t len)
-{
- void *buf;
- size_t resid, chunk, get;
- ssize_t got;
- vm_offset_t p;
-
- p = dest;
-
- chunk = min(READIN_BUF, len);
- buf = malloc(chunk);
- if (buf == NULL) {
- printf("ofw_readin: buf malloc failed\n");
- return(0);
- }
-
- if (ofw_mapmem(dest, len)) {
- printf("ofw_readin: map error\n");
- free(buf);
- return (0);
- }
-
- for (resid = len; resid > 0; resid -= got, p += got) {
- get = min(chunk, resid);
- got = read(fd, buf, get);
-
- if (got <= 0) {
- if (got < 0)
- printf("ofw_readin: read failed\n");
- break;
- }
-
- bcopy(buf, (void *)p, got);
- }
-
- free(buf);
- return(len - resid);
-}
diff --git a/stand/ofw/libofw/ofw_disk.c b/stand/ofw/libofw/ofw_disk.c
deleted file mode 100644
index 2c3bd568a268..000000000000
--- a/stand/ofw/libofw/ofw_disk.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*-
- * 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * Disk I/O routines using Open Firmware
- */
-
-#include <sys/param.h>
-
-#include <netinet/in.h>
-
-#include <machine/stdarg.h>
-
-#include <stand.h>
-#include <sys/disk.h>
-
-#include "bootstrap.h"
-#include "libofw.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 int ofwd_ioctl(struct open_file *f, u_long cmd, void *data);
-static int ofwd_print(int verbose);
-
-struct devsw ofwdisk = {
- "block",
- DEVT_DISK,
- ofwd_init,
- ofwd_strategy,
- ofwd_open,
- ofwd_close,
- ofwd_ioctl,
- ofwd_print
-};
-
-/*
- * We're not guaranteed to be able to open a device more than once and there
- * is no OFW standard method to determine whether a device is already opened.
- * Opening a device multiple times simultaneously happens to work with most
- * OFW block device drivers but triggers a trap with at least the driver for
- * the on-board controllers of Sun Fire V100 and Ultra 1. Upper layers and MI
- * code expect to be able to open a device more than once however. Given that
- * different partitions of the same device might be opened at the same time as
- * done by ZFS, we can't generally just keep track of the opened devices and
- * reuse the instance handle when asked to open an already opened device. So
- * the best we can do is to cache the lastly used device path and close and
- * open devices in ofwd_strategy() as needed.
- */
-static struct ofw_devdesc *kdp;
-
-static int
-ofwd_init(void)
-{
-
- return (0);
-}
-
-static int
-ofwd_strategy(void *devdata, int flag __unused, daddr_t dblk, size_t size,
- char *buf, size_t *rsize)
-{
- struct ofw_devdesc *dp = (struct ofw_devdesc *)devdata;
- daddr_t pos;
- int n;
-
- if (dp != kdp) {
- if (kdp != NULL) {
-#if !defined(__powerpc__)
- OF_close(kdp->d_handle);
-#endif
- kdp = NULL;
- }
- if ((dp->d_handle = OF_open(dp->d_path)) == -1)
- return (ENOENT);
- kdp = dp;
- }
-
- pos = dblk * 512;
- do {
- if (OF_seek(dp->d_handle, pos) < 0)
- return (EIO);
- n = OF_read(dp->d_handle, buf, size);
- if (n < 0 && n != -2)
- return (EIO);
- } while (n == -2);
- *rsize = size;
- return (0);
-}
-
-static int
-ofwd_open(struct open_file *f, ...)
-{
- struct ofw_devdesc *dp;
- va_list vl;
-
- va_start(vl, f);
- dp = va_arg(vl, struct ofw_devdesc *);
- va_end(vl);
-
- if (dp != kdp) {
- if (kdp != NULL) {
- OF_close(kdp->d_handle);
- kdp = NULL;
- }
- if ((dp->d_handle = OF_open(dp->d_path)) == -1) {
- printf("%s: Could not open %s\n", __func__,
- dp->d_path);
- return (ENOENT);
- }
- kdp = dp;
- }
- return (0);
-}
-
-static int
-ofwd_close(struct open_file *f)
-{
- struct ofw_devdesc *dev = f->f_devdata;
-
- if (dev == kdp) {
-#if !defined(__powerpc__)
- OF_close(dev->d_handle);
-#endif
- kdp = NULL;
- }
- return (0);
-}
-
-static int
-ofwd_ioctl(struct open_file *f, u_long cmd, void *data)
-{
- struct ofw_devdesc *dev = f->f_devdata;
- int block_size;
- unsigned int n;
-
- switch (cmd) {
- case DIOCGSECTORSIZE:
- block_size = OF_block_size(dev->d_handle);
- *(u_int *)data = block_size;
- break;
- case DIOCGMEDIASIZE:
- block_size = OF_block_size(dev->d_handle);
- n = OF_blocks(dev->d_handle);
- *(uint64_t *)data = (uint64_t)(n * block_size);
- break;
- default:
- return (ENOTTY);
- }
- return (0);
-}
-
-static int
-ofwd_print(int verbose __unused)
-{
- return (0);
-}
diff --git a/stand/ofw/libofw/ofw_memory.c b/stand/ofw/libofw/ofw_memory.c
deleted file mode 100644
index f05881ee8a19..000000000000
--- a/stand/ofw/libofw/ofw_memory.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/*-
- * Copyright (c) 2001 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/types.h>
-
-#include <stand.h>
-
-#include "libofw.h"
-#include "openfirm.h"
-
-struct ofw_mapping {
- vm_offset_t va;
- int len;
- vm_offset_t pa;
- int mode;
-};
-
-struct ofw_mapping2 {
- vm_offset_t va;
- int len;
- vm_offset_t pa_hi;
- vm_offset_t pa_lo;
- int mode;
-};
-
-void
-ofw_memmap(int acells)
-{
- struct ofw_mapping *mapptr;
- struct ofw_mapping2 *mapptr2;
- phandle_t mmup;
- int nmapping, i;
- u_char mappings[256 * sizeof(struct ofw_mapping2)];
- char lbuf[80];
-
- mmup = OF_instance_to_package(mmu);
-
- bzero(mappings, sizeof(mappings));
-
- nmapping = OF_getprop(mmup, "translations", mappings, sizeof(mappings));
- if (nmapping == -1) {
- printf("Could not get memory map (%d)\n",
- nmapping);
- return;
- }
-
- pager_open();
- if (acells == 1) {
- nmapping /= sizeof(struct ofw_mapping);
- mapptr = (struct ofw_mapping *) mappings;
-
- printf("%17s\t%17s\t%8s\t%6s\n", "Virtual Range",
- "Physical Range", "#Pages", "Mode");
-
- for (i = 0; i < nmapping; i++) {
- sprintf(lbuf, "%08x-%08x\t%08x-%08x\t%8d\t%6x\n",
- mapptr[i].va,
- mapptr[i].va + mapptr[i].len,
- mapptr[i].pa,
- mapptr[i].pa + mapptr[i].len,
- mapptr[i].len / 0x1000,
- mapptr[i].mode);
- if (pager_output(lbuf))
- break;
- }
- } else {
- nmapping /= sizeof(struct ofw_mapping2);
- mapptr2 = (struct ofw_mapping2 *) mappings;
-
- printf("%17s\t%17s\t%8s\t%6s\n", "Virtual Range",
- "Physical Range", "#Pages", "Mode");
-
- for (i = 0; i < nmapping; i++) {
- sprintf(lbuf, "%08x-%08x\t%08x-%08x\t%8d\t%6x\n",
- mapptr2[i].va,
- mapptr2[i].va + mapptr2[i].len,
- mapptr2[i].pa_lo,
- mapptr2[i].pa_lo + mapptr2[i].len,
- mapptr2[i].len / 0x1000,
- mapptr2[i].mode);
- if (pager_output(lbuf))
- break;
- }
- }
- pager_close();
-}
-
diff --git a/stand/ofw/libofw/ofw_module.c b/stand/ofw/libofw/ofw_module.c
deleted file mode 100644
index d39a34344556..000000000000
--- a/stand/ofw/libofw/ofw_module.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
- * 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 AUTHOR 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * ofw-specific module functionality.
- *
- */
-
-#include <stand.h>
-#include <string.h>
-
-#include "bootstrap.h"
-#include "libofw.h"
-
-/*
- * Use voodoo to load modules required by current hardware.
- */
-int
-ofw_autoload(void)
-{
- /* XXX Call some machdep autoload routine? */
- return(0);
-}
diff --git a/stand/ofw/libofw/ofw_net.c b/stand/ofw/libofw/ofw_net.c
deleted file mode 100644
index 14494ecc2b2e..000000000000
--- a/stand/ofw/libofw/ofw_net.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/*-
- * Copyright (c) 2000-2001 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <net/if.h>
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/if_ether.h>
-#include <netinet/ip.h>
-
-#include <stand.h>
-#include <net.h>
-#include <netif.h>
-
-#include "openfirm.h"
-
-static int ofwn_probe(struct netif *, void *);
-static int ofwn_match(struct netif *, void *);
-static void ofwn_init(struct iodesc *, void *);
-static ssize_t ofwn_get(struct iodesc *, void **, time_t);
-static ssize_t ofwn_put(struct iodesc *, void *, size_t);
-static void ofwn_end(struct netif *);
-
-extern struct netif_stats ofwn_stats[];
-
-struct netif_dif ofwn_ifs[] = {
- /* dif_unit dif_nsel dif_stats dif_private */
- { 0, 1, &ofwn_stats[0], 0, },
-};
-
-struct netif_stats ofwn_stats[nitems(ofwn_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 */
- nitems(ofwn_ifs) /* netif_nifs */
-};
-
-static ihandle_t netinstance;
-
-static void *dmabuf;
-
-static int
-ofwn_match(struct netif *nif, void *machdep_hint)
-{
- return 1;
-}
-
-static int
-ofwn_probe(struct netif *nif, void *machdep_hint)
-{
- return 0;
-}
-
-static ssize_t
-ofwn_put(struct iodesc *desc, void *pkt, size_t len)
-{
- size_t sendlen;
- ssize_t rv;
-
-#if defined(NETIF_DEBUG)
- struct ether_header *eh;
- printf("netif_put: desc=0x%x pkt=0x%x len=%d\n", desc, pkt, len);
- eh = pkt;
- printf("dst: %s ", ether_sprintf(eh->ether_dhost));
- printf("src: %s ", ether_sprintf(eh->ether_shost));
- printf("type: 0x%x\n", eh->ether_type & 0xffff);
-#endif
-
- sendlen = len;
- if (sendlen < 60) {
- sendlen = 60;
-#if defined(NETIF_DEBUG)
- printf("netif_put: length padded to %d\n", sendlen);
-#endif
- }
-
- if (dmabuf) {
- bcopy(pkt, dmabuf, sendlen);
- pkt = dmabuf;
- }
-
- rv = OF_write(netinstance, pkt, len);
-
-#if defined(NETIF_DEBUG)
- printf("netif_put: OF_write returned %d\n", rv);
-#endif
-
- return rv;
-}
-
-static ssize_t
-ofwn_get(struct iodesc *desc, void **pkt, time_t timeout)
-{
- time_t t;
- ssize_t length;
- size_t len;
- char *buf, *ptr;
-
-#if defined(NETIF_DEBUG)
- printf("netif_get: pkt=%p, timeout=%d\n", pkt, timeout);
-#endif
-
- /*
- * We should read the "max-frame-size" int property instead,
- * but at this time the iodesc does not have mtu, so we will take
- * a small shortcut here.
- */
- len = ETHER_MAX_LEN;
- buf = malloc(len + ETHER_ALIGN);
- if (buf == NULL)
- return (-1);
- ptr = buf + ETHER_ALIGN;
-
- t = getsecs();
- do {
- length = OF_read(netinstance, ptr, len);
- } while ((length == -2 || length == 0) &&
- (getsecs() - t < timeout));
-
-#if defined(NETIF_DEBUG)
- printf("netif_get: received length=%d (%x)\n", length, length);
-#endif
-
- if (length < 12) {
- free(buf);
- return (-1);
- }
-
-#if defined(NETIF_VERBOSE_DEBUG)
- {
- char *ch = ptr;
- int i;
-
- for(i = 0; i < 96; i += 4) {
- printf("%02x%02x%02x%02x ", ch[i], ch[i+1],
- ch[i+2], ch[i+3]);
- }
- printf("\n");
- }
-#endif
-
-#if defined(NETIF_DEBUG)
- {
- struct ether_header *eh = ptr;
-
- printf("dst: %s ", ether_sprintf(eh->ether_dhost));
- printf("src: %s ", ether_sprintf(eh->ether_shost));
- printf("type: 0x%x\n", eh->ether_type & 0xffff);
- }
-#endif
-
- *pkt = buf;
- return (length);
-}
-
-extern char *strchr();
-
-static void
-ofwn_init(struct iodesc *desc, void *machdep_hint)
-{
- phandle_t netdev;
- char path[64];
- char *ch;
- int pathlen;
-
- pathlen = OF_getprop(chosen, "bootpath", path, 64);
- if ((ch = strchr(path, ':')) != NULL)
- *ch = '\0';
- netdev = OF_finddevice(path);
-#ifdef __sparc64__
- if (OF_getprop(netdev, "mac-address", desc->myea, 6) == -1)
-#else
- if (OF_getprop(netdev, "local-mac-address", desc->myea, 6) == -1)
-#endif
- goto punt;
-
- printf("boot: ethernet address: %s\n", ether_sprintf(desc->myea));
-
- if ((netinstance = OF_open(path)) == -1) {
- printf("Could not open network device.\n");
- goto punt;
- }
-
-#if defined(NETIF_DEBUG)
- printf("ofwn_init: Open Firmware instance handle: %08x\n", netinstance);
-#endif
-
-#ifndef __sparc64__
- dmabuf = NULL;
- if (OF_call_method("dma-alloc", netinstance, 1, 1, (64 * 1024), &dmabuf)
- < 0) {
- printf("Failed to allocate DMA buffer (got %p).\n", dmabuf);
- goto punt;
- }
-
-#if defined(NETIF_DEBUG)
- printf("ofwn_init: allocated DMA buffer: %p\n", dmabuf);
-#endif
-#endif
-
- return;
-
-punt:
- printf("\n");
- printf("Could not boot from %s.\n", path);
- OF_enter();
-}
-
-static void
-ofwn_end(struct netif *nif)
-{
-#ifdef BROKEN
- /* dma-free freezes at least some Apple ethernet controllers */
- OF_call_method("dma-free", netinstance, 2, 0, dmabuf, MAXPHYS);
-#endif
- OF_close(netinstance);
-}
-
-#if 0
-int
-ofwn_getunit(const char *path)
-{
- int i;
- char newpath[255];
-
- OF_canon(path, newpath, 254);
-
- for (i = 0; i < nofwninfo; i++) {
- printf(">>> test =\t%s\n", ofwninfo[i].ofwn_path);
- if (strcmp(path, ofwninfo[i].ofwn_path) == 0)
- return i;
-
- if (strcmp(newpath, ofwninfo[i].ofwn_path) == 0)
- return i;
- }
-
- return -1;
-}
-#endif
diff --git a/stand/ofw/libofw/ofw_reboot.c b/stand/ofw/libofw/ofw_reboot.c
deleted file mode 100644
index bbb420ac1767..000000000000
--- a/stand/ofw/libofw/ofw_reboot.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-
- * 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <stand.h>
-#include "openfirm.h"
-
-void
-exit(int code)
-{
- OF_exit();
-}
diff --git a/stand/ofw/libofw/ofw_time.c b/stand/ofw/libofw/ofw_time.c
deleted file mode 100644
index d5ca271564de..000000000000
--- a/stand/ofw/libofw/ofw_time.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*-
- * 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$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;
-}
-
-time_t
-getsecs(void)
-{
- time_t n = 0;
- time(&n);
- return n;
-}
-
-void
-delay(int usecs)
-{
- int msecs, start;
-
- msecs = usecs / 1000;
- start = OF_milliseconds();
-
- while (OF_milliseconds() - start < msecs);
-}
diff --git a/stand/ofw/libofw/openfirm.c b/stand/ofw/libofw/openfirm.c
deleted file mode 100644
index 0b4198d281fd..000000000000
--- a/stand/ofw/libofw/openfirm.c
+++ /dev/null
@@ -1,831 +0,0 @@
-/* $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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <machine/stdarg.h>
-
-#include <stand.h>
-
-#include "openfirm.h"
-
-int (*openfirmware)(void *);
-
-phandle_t chosen;
-ihandle_t mmu;
-ihandle_t memory;
-int real_mode = 0;
-
-/* Initialiser */
-
-void
-OF_init(int (*openfirm)(void *))
-{
- phandle_t options;
- char mode[sizeof("true")];
-
- openfirmware = openfirm;
-
- if ((chosen = OF_finddevice("/chosen")) == -1)
- OF_exit();
- if (OF_getprop(chosen, "memory", &memory, sizeof(memory)) == -1) {
- memory = OF_open("/memory");
- if (memory == -1)
- memory = OF_open("/memory@0");
- if (memory == -1)
- OF_exit();
- }
- if (OF_getprop(chosen, "mmu", &mmu, sizeof(mmu)) == -1)
- OF_exit();
-
- /*
- * Check if we run in real mode. If so, we do not need to map
- * memory later on.
- */
- options = OF_finddevice("/options");
- if (OF_getprop(options, "real-mode?", mode, sizeof(mode)) > 0 &&
- strcmp(mode, "true") == 0)
- real_mode = 1;
-}
-
-/*
- * Generic functions
- */
-
-/* Test to see if a service exists. */
-int
-OF_test(char *name)
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t service;
- cell_t missing;
- } args = {
- (cell_t)"test",
- 1,
- 1,
- };
-
- args.service = (cell_t)name;
- if (openfirmware(&args) == -1)
- return (-1);
- return (args.missing);
-}
-
-/* Return firmware millisecond count. */
-int
-OF_milliseconds()
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t ms;
- } args = {
- (cell_t)"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 {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t node;
- cell_t next;
- } args = {
- (cell_t)"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 {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t node;
- cell_t child;
- } args = {
- (cell_t)"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 {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t node;
- cell_t parent;
- } args = {
- (cell_t)"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 {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t instance;
- cell_t package;
- } args = {
- (cell_t)"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, const char *propname)
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t package;
- cell_t propname;
- cell_t proplen;
- } args = {
- (cell_t)"getproplen",
- 2,
- 1,
- };
-
- args.package = package;
- args.propname = (cell_t)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, const char *propname, void *buf, int buflen)
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t package;
- cell_t propname;
- cell_t buf;
- cell_t buflen;
- cell_t size;
- } args = {
- (cell_t)"getprop",
- 4,
- 1,
- };
-
- args.package = package;
- args.propname = (cell_t)propname;
- args.buf = (cell_t)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, const char *previous, char *buf)
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t package;
- cell_t previous;
- cell_t buf;
- cell_t flag;
- } args = {
- (cell_t)"nextprop",
- 3,
- 1,
- };
-
- args.package = package;
- args.previous = (cell_t)previous;
- args.buf = (cell_t)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, const char *propname, void *buf, int len)
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t package;
- cell_t propname;
- cell_t buf;
- cell_t len;
- cell_t size;
- } args = {
- (cell_t)"setprop",
- 4,
- 1,
- };
-
- args.package = package;
- args.propname = (cell_t)propname;
- args.buf = (cell_t)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(const char *device, char *buf, int len)
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t device;
- cell_t buf;
- cell_t len;
- cell_t size;
- } args = {
- (cell_t)"canon",
- 3,
- 1,
- };
-
- args.device = (cell_t)device;
- args.buf = (cell_t)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(const char *device)
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t device;
- cell_t package;
- } args = {
- (cell_t)"finddevice",
- 1,
- 1,
- };
-
- args.device = (cell_t)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 {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t instance;
- cell_t buf;
- cell_t len;
- cell_t size;
- } args = {
- (cell_t)"instance-to-path",
- 3,
- 1,
- };
-
- args.instance = instance;
- args.buf = (cell_t)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 {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t package;
- cell_t buf;
- cell_t len;
- cell_t size;
- } args = {
- (cell_t)"package-to-path",
- 3,
- 1,
- };
-
- args.package = package;
- args.buf = (cell_t)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 {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t method;
- cell_t instance;
- cell_t args_n_results[12];
- } args = {
- (cell_t)"call-method",
- 2,
- 1,
- };
- cell_t *cp;
- int n;
-
- if (nargs > 6)
- return (-1);
- args.nargs = nargs + 2;
- args.nreturns = nreturns + 1;
- args.method = (cell_t)method;
- args.instance = instance;
- va_start(ap, nreturns);
- for (cp = (cell_t *)(args.args_n_results + (n = nargs)); --n >= 0;)
- *--cp = va_arg(ap, cell_t);
- if (openfirmware(&args) == -1)
- return (-1);
- if (args.args_n_results[nargs])
- return (args.args_n_results[nargs]);
- for (cp = (cell_t *)(args.args_n_results + nargs + (n = args.nreturns));
- --n > 0;)
- *va_arg(ap, cell_t *) = *--cp;
- va_end(ap);
- return (0);
-}
-
-/*
- * Device I/O functions
- */
-
-/* Open an instance for a device. */
-ihandle_t
-OF_open(char *device)
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t device;
- cell_t instance;
- } args = {
- (cell_t)"open",
- 1,
- 1,
- };
-
- args.device = (cell_t)device;
- if (openfirmware(&args) == -1 || args.instance == 0) {
- return (-1);
- }
- return (args.instance);
-}
-
-/* Close an instance. */
-void
-OF_close(ihandle_t instance)
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t instance;
- } args = {
- (cell_t)"close",
- 1,
- };
-
- args.instance = instance;
- openfirmware(&args);
-}
-
-/* Read from an instance. */
-int
-OF_read(ihandle_t instance, void *addr, int len)
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t instance;
- cell_t addr;
- cell_t len;
- cell_t actual;
- } args = {
- (cell_t)"read",
- 3,
- 1,
- };
-
- args.instance = instance;
- args.addr = (cell_t)addr;
- args.len = len;
-
-#if defined(OPENFIRM_DEBUG)
- printf("OF_read: called with instance=%08x, addr=%p, len=%d\n",
- args.instance, args.addr, args.len);
-#endif
-
- if (openfirmware(&args) == -1)
- return (-1);
-
-#if defined(OPENFIRM_DEBUG)
- printf("OF_read: returning instance=%d, addr=%p, len=%d, actual=%d\n",
- args.instance, args.addr, args.len, args.actual);
-#endif
-
- return (args.actual);
-}
-
-/* Write to an instance. */
-int
-OF_write(ihandle_t instance, void *addr, int len)
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t instance;
- cell_t addr;
- cell_t len;
- cell_t actual;
- } args = {
- (cell_t)"write",
- 3,
- 1,
- };
-
- args.instance = instance;
- args.addr = (cell_t)addr;
- args.len = len;
- if (openfirmware(&args) == -1)
- return (-1);
- return (args.actual);
-}
-
-/* Seek to a position. */
-int
-OF_seek(ihandle_t instance, uint64_t pos)
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t instance;
- cell_t poshi;
- cell_t poslo;
- cell_t status;
- } args = {
- (cell_t)"seek",
- 3,
- 1,
- };
-
- args.instance = instance;
- args.poshi = pos >> 32;
- args.poslo = pos;
- if (openfirmware(&args) == -1)
- return (-1);
- return (args.status);
-}
-
-/* Blocks. */
-unsigned int
-OF_blocks(ihandle_t instance)
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t instance;
- cell_t result;
- cell_t blocks;
- } args = {
- (cell_t)"#blocks",
- 2,
- 1,
- };
-
- args.instance = instance;
- if (openfirmware(&args) == -1)
- return ((unsigned int)-1);
- return (args.blocks);
-}
-
-/* Block size. */
-int
-OF_block_size(ihandle_t instance)
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t instance;
- cell_t result;
- cell_t size;
- } args = {
- (cell_t)"block-size",
- 2,
- 1,
- };
-
- args.instance = instance;
- if (openfirmware(&args) == -1)
- return (512);
- return (args.size);
-}
-
-/*
- * Memory functions
- */
-
-/* Claim an area of memory. */
-void *
-OF_claim(void *virt, u_int size, u_int align)
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t virt;
- cell_t size;
- cell_t align;
- cell_t baseaddr;
- } args = {
- (cell_t)"claim",
- 3,
- 1,
- };
-
- args.virt = (cell_t)virt;
- args.size = size;
- args.align = align;
- if (openfirmware(&args) == -1)
- return ((void *)-1);
- return ((void *)args.baseaddr);
-}
-
-/* Release an area of memory. */
-void
-OF_release(void *virt, u_int size)
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t virt;
- cell_t size;
- } args = {
- (cell_t)"release",
- 2,
- };
-
- args.virt = (cell_t)virt;
- args.size = size;
- openfirmware(&args);
-}
-
-/*
- * Control transfer functions
- */
-
-/* Reset the system and call "boot <bootspec>". */
-void
-OF_boot(char *bootspec)
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t bootspec;
- } args = {
- (cell_t)"boot",
- 1,
- };
-
- args.bootspec = (cell_t)bootspec;
- openfirmware(&args);
- for (;;) /* just in case */
- ;
-}
-
-/* Suspend and drop back to the Open Firmware interface. */
-void
-OF_enter()
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- } args = {
- (cell_t)"enter",
- };
-
- openfirmware(&args);
- /* We may come back. */
-}
-
-/* Shut down and drop back to the Open Firmware interface. */
-void
-OF_exit()
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- } args = {
- (cell_t)"exit",
- };
-
- openfirmware(&args);
- for (;;) /* just in case */
- ;
-}
-
-void
-OF_quiesce()
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- } args = {
- (cell_t)"quiesce",
- };
-
- openfirmware(&args);
-}
-
-/* Free <size> bytes starting at <virt>, then call <entry> with <arg>. */
-#if 0
-void
-OF_chain(void *virt, u_int size, void (*entry)(), void *arg, u_int len)
-{
- static struct {
- cell_t name;
- cell_t nargs;
- cell_t nreturns;
- cell_t virt;
- cell_t size;
- cell_t entry;
- cell_t arg;
- cell_t len;
- } args = {
- (cell_t)"chain",
- 5,
- };
-
- args.virt = (cell_t)virt;
- args.size = size;
- args.entry = (cell_t)entry;
- args.arg = (cell_t)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
- if (size > 0)
- OF_release(virt, size);
-#endif
- entry(0, 0, openfirmware, arg, len);
-}
-#endif
diff --git a/stand/ofw/libofw/openfirm.h b/stand/ofw/libofw/openfirm.h
deleted file mode 100644
index b83cf4b0b27f..000000000000
--- a/stand/ofw/libofw/openfirm.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/* $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$
- */
-#ifndef _OPENFIRM_H_
-#define _OPENFIRM_H_
-/*
- * Prototypes for Open Firmware Interface Routines
- */
-
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-typedef unsigned int ihandle_t;
-typedef unsigned int phandle_t;
-typedef unsigned long int cell_t;
-
-extern int (*openfirmware)(void *);
-extern phandle_t chosen;
-extern ihandle_t memory, mmu;
-extern int real_mode;
-
-/*
- * This isn't actually an Open Firmware function, but it seemed like the right
- * place for it to go.
- */
-void OF_init(int (*openfirm)(void *));
-
-/* Generic functions */
-int OF_test(char *);
-void OF_quiesce(); /* Disable firmware */
-
-/* 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, const char *);
-int OF_getprop(phandle_t, const char *, void *, int);
-int OF_nextprop(phandle_t, const char *, char *);
-int OF_setprop(phandle_t, const char *, void *, int);
-int OF_canon(const char *, char *, int);
-phandle_t OF_finddevice(const 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);
-unsigned int OF_blocks(ihandle_t);
-int OF_block_size(ihandle_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);
-void OF_exit(void) __attribute__((noreturn));
-void OF_chain(void *, u_int, void (*)(), void *, u_int);
-
-/* Time function */
-int OF_milliseconds(void);
-
-#endif /* _OPENFIRM_H_ */