diff options
| author | Warner Losh <imp@FreeBSD.org> | 2017-11-14 23:02:19 +0000 |
|---|---|---|
| committer | Warner Losh <imp@FreeBSD.org> | 2017-11-14 23:02:19 +0000 |
| commit | ca987d4641cdcd7f27e153db17c5bf064934faf5 (patch) | |
| tree | 6c3860e3ba8949be9528d644fbb7fa88d8bbbb79 /sys/boot/ofw | |
| parent | 6eac7115560381ce5c9e2939ab3fce82bb9b6a95 (diff) | |
Notes
Diffstat (limited to 'sys/boot/ofw')
| -rw-r--r-- | sys/boot/ofw/Makefile | 5 | ||||
| -rw-r--r-- | sys/boot/ofw/Makefile.inc | 3 | ||||
| -rw-r--r-- | sys/boot/ofw/common/Makefile.inc | 3 | ||||
| -rw-r--r-- | sys/boot/ofw/common/main.c | 185 | ||||
| -rw-r--r-- | sys/boot/ofw/libofw/Makefile | 28 | ||||
| -rw-r--r-- | sys/boot/ofw/libofw/devicename.c | 147 | ||||
| -rw-r--r-- | sys/boot/ofw/libofw/elf_freebsd.c | 104 | ||||
| -rw-r--r-- | sys/boot/ofw/libofw/libofw.h | 90 | ||||
| -rw-r--r-- | sys/boot/ofw/libofw/ofw_console.c | 120 | ||||
| -rw-r--r-- | sys/boot/ofw/libofw/ofw_copy.c | 173 | ||||
| -rw-r--r-- | sys/boot/ofw/libofw/ofw_disk.c | 184 | ||||
| -rw-r--r-- | sys/boot/ofw/libofw/ofw_memory.c | 146 | ||||
| -rw-r--r-- | sys/boot/ofw/libofw/ofw_module.c | 49 | ||||
| -rw-r--r-- | sys/boot/ofw/libofw/ofw_net.c | 275 | ||||
| -rw-r--r-- | sys/boot/ofw/libofw/ofw_reboot.c | 37 | ||||
| -rw-r--r-- | sys/boot/ofw/libofw/ofw_time.c | 61 | ||||
| -rw-r--r-- | sys/boot/ofw/libofw/openfirm.c | 832 | ||||
| -rw-r--r-- | sys/boot/ofw/libofw/openfirm.h | 124 | ||||
| -rw-r--r-- | sys/boot/ofw/libofw/ppc64_elf_freebsd.c | 110 |
19 files changed, 0 insertions, 2676 deletions
diff --git a/sys/boot/ofw/Makefile b/sys/boot/ofw/Makefile deleted file mode 100644 index 3b881b780e87..000000000000 --- a/sys/boot/ofw/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# $FreeBSD$ - -SUBDIR= libofw - -.include <bsd.subdir.mk> diff --git a/sys/boot/ofw/Makefile.inc b/sys/boot/ofw/Makefile.inc deleted file mode 100644 index 265f86d1ed55..000000000000 --- a/sys/boot/ofw/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $FreeBSD$ - -.include "../Makefile.inc" diff --git a/sys/boot/ofw/common/Makefile.inc b/sys/boot/ofw/common/Makefile.inc deleted file mode 100644 index 5d20372631e6..000000000000 --- a/sys/boot/ofw/common/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $FreeBSD$ - -SRCS+= main.c diff --git a/sys/boot/ofw/common/main.c b/sys/boot/ofw/common/main.c deleted file mode 100644 index 3c0bbdf97a26..000000000000 --- a/sys/boot/ofw/common/main.c +++ /dev/null @@ -1,185 +0,0 @@ -/*- - * 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. - */ - -#include <sys/cdefs.h> -__FBSDID("$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_info[]; - -u_int32_t acells, scells; - -static char bootargs[128]; - -#define HEAP_SIZE 0x100000 - -#define OF_puts(fd, text) OF_write(fd, text, strlen(text)) - -void -init_heap(void) -{ - void *base; - ihandle_t stdout; - - if ((base = ofw_alloc_heap(HEAP_SIZE)) == (void *)0xffffffff) { - OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)); - OF_puts(stdout, "Heap memory claim failed!\n"); - OF_enter(); - } - - setheap(base, (void *)((int)base + HEAP_SIZE)); -} - -uint64_t -memsize(void) -{ - phandle_t memoryp; - cell_t reg[24]; - int i, sz; - u_int64_t memsz; - - memsz = 0; - memoryp = OF_instance_to_package(memory); - - sz = OF_getprop(memoryp, "reg", ®, sizeof(reg)); - sz /= sizeof(reg[0]); - - for (i = 0; i < sz; i += (acells + scells)) { - if (scells > 1) - memsz += (uint64_t)reg[i + acells] << 32; - memsz += reg[i + acells + scells - 1]; - } - - return (memsz); -} - -int -main(int (*openfirm)(void *)) -{ - phandle_t root; - int i; - char bootpath[64]; - char *ch; - int bargc; - char **bargv; - - /* - * Initialise the Open Firmware routines by giving them the entry point. - */ - OF_init(openfirm); - - root = OF_finddevice("/"); - - scells = acells = 1; - OF_getprop(root, "#address-cells", &acells, sizeof(acells)); - OF_getprop(root, "#size-cells", &scells, sizeof(scells)); - - /* - * 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(); - - /* - * Set up console. - */ - cons_probe(); - - /* - * 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%s", bootprog_info); - printf("Memory: %lldKB\n", memsize() / 1024); - - OF_getprop(chosen, "bootpath", bootpath, 64); - ch = strchr(bootpath, ':'); - *ch = '\0'; - printf("Booted from: %s\n", bootpath); - - printf("\n"); - - /* - * Only parse the first bootarg if present. It should - * be simple to handle extra arguments - */ - OF_getprop(chosen, "bootargs", bootargs, sizeof(bootargs)); - bargc = 0; - parse(&bargc, &bargv, bootargs); - if (bargc == 1) - env_setenv("currdev", EV_VOLATILE, bargv[0], ofw_setcurrdev, - env_nounset); - else - env_setenv("currdev", EV_VOLATILE, bootpath, - ofw_setcurrdev, env_nounset); - env_setenv("loaddev", EV_VOLATILE, bootpath, env_noset, - env_nounset); - setenv("LINES", "24", 1); /* optional */ - - archsw.arch_getdev = ofw_getdev; - archsw.arch_copyin = ofw_copyin; - archsw.arch_copyout = ofw_copyout; - archsw.arch_readin = ofw_readin; - archsw.arch_autoload = ofw_autoload; - - interact(NULL); /* 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); -} - -COMMAND_SET(memmap, "memmap", "print memory map", command_memmap); - -int -command_memmap(int argc, char **argv) -{ - - ofw_memmap(acells); - return (CMD_OK); -} diff --git a/sys/boot/ofw/libofw/Makefile b/sys/boot/ofw/libofw/Makefile deleted file mode 100644 index 8e9ac804c5fa..000000000000 --- a/sys/boot/ofw/libofw/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -# $FreeBSD$ - -.include <bsd.init.mk> - -LIB= ofw -INTERNALLIB= - -SRCS= devicename.c elf_freebsd.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 - -# Pick up the bootstrap header for some interface items -CFLAGS+= -I${LDRSRC} - -CFLAGS+= -ffreestanding -.if ${MACHINE_CPUARCH} == "powerpc" -CFLAGS+= -msoft-float -SRCS+= ppc64_elf_freebsd.c -.endif - -.ifdef(BOOT_DISK_DEBUG) -# Make the disk code more talkative -CFLAGS+= -DDISK_DEBUG -.endif - -.include <bsd.lib.mk> diff --git a/sys/boot/ofw/libofw/devicename.c b/sys/boot/ofw/libofw/devicename.c deleted file mode 100644 index c9814b76e97a..000000000000 --- a/sys/boot/ofw/libofw/devicename.c +++ /dev/null @@ -1,147 +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 "../zfs/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->d_dev = dv; - idev->d_type = dv->dv_type; - if (idev->d_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/sys/boot/ofw/libofw/elf_freebsd.c b/sys/boot/ofw/libofw/elf_freebsd.c deleted file mode 100644 index 80ece7eeba46..000000000000 --- a/sys/boot/ofw/libofw/elf_freebsd.c +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * Copyright (c) 2001 Benno Rice <benno@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 <sys/param.h> -#include <sys/linker.h> - -#include <machine/metadata.h> -#include <machine/elf.h> - -#include <stand.h> - -#include "bootstrap.h" -#include "libofw.h" -#include "openfirm.h" - -extern char end[]; -extern vm_offset_t reloc; /* From <arch>/conf.c */ - -int -__elfN(ofw_loadfile)(char *filename, u_int64_t dest, - struct preloaded_file **result) -{ - int r; - - r = __elfN(loadfile)(filename, dest, result); - if (r != 0) - return (r); - -#if defined(__powerpc__) - /* - * No need to sync the icache for modules: this will - * be done by the kernel after relocation. - */ - if (!strcmp((*result)->f_type, "elf kernel")) - __syncicache((void *) (*result)->f_addr, (*result)->f_size); -#endif - return (0); -} - -int -__elfN(ofw_exec)(struct preloaded_file *fp) -{ - struct file_metadata *fmp; - vm_offset_t mdp, dtbp; - Elf_Ehdr *e; - int error; - intptr_t entry; - - if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) { - return(EFTYPE); - } - e = (Elf_Ehdr *)&fmp->md_data; - entry = e->e_entry; - - if ((error = md_load(fp->f_args, &mdp, &dtbp)) != 0) - return (error); - - printf("Kernel entry at 0x%lx ...\n", e->e_entry); - - dev_cleanup(); - ofw_release_heap(); - if (dtbp != 0) { - OF_quiesce(); - ((int (*)(u_long, u_long, u_long, void *, u_long))entry)(dtbp, 0, 0, - mdp, sizeof(mdp)); - } else { - OF_chain((void *)reloc, end - (char *)reloc, (void *)entry, - (void *)mdp, sizeof(mdp)); - } - - panic("exec returned"); -} - -struct file_format ofw_elf = -{ - __elfN(ofw_loadfile), - __elfN(ofw_exec) -}; diff --git a/sys/boot/ofw/libofw/libofw.h b/sys/boot/ofw/libofw/libofw.h deleted file mode 100644 index 87e90959c9e6..000000000000 --- a/sys/boot/ofw/libofw/libofw.h +++ /dev/null @@ -1,90 +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" - -/* Note: Must match the 'struct devdesc' in bootstrap.h */ -struct ofw_devdesc { - struct devsw *d_dev; - int d_type; - int d_unit; - ihandle_t d_handle; - union { - 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); -void *ofw_alloc_heap(unsigned int); -void ofw_release_heap(void); - -struct preloaded_file; -struct file_format; - -int ofw_elf_loadfile(char *, vm_offset_t, struct preloaded_file **); -int ofw_elf_exec(struct preloaded_file *); - -extern struct file_format ofw_elf; -#ifdef __powerpc__ -extern struct file_format ofw_elf64; -#endif - -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/sys/boot/ofw/libofw/ofw_console.c b/sys/boot/ofw/libofw/ofw_console.c deleted file mode 100644 index 59ce9a5067d5..000000000000 --- a/sys/boot/ofw/libofw/ofw_console.c +++ /dev/null @@ -1,120 +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; - } - - if (OF_read(stdin, &ch, 1) > 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/sys/boot/ofw/libofw/ofw_copy.c b/sys/boot/ofw/libofw/ofw_copy.c deleted file mode 100644 index ffd698731503..000000000000 --- a/sys/boot/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 16 - - -#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/sys/boot/ofw/libofw/ofw_disk.c b/sys/boot/ofw/libofw/ofw_disk.c deleted file mode 100644 index 2c3bd568a268..000000000000 --- a/sys/boot/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/sys/boot/ofw/libofw/ofw_memory.c b/sys/boot/ofw/libofw/ofw_memory.c deleted file mode 100644 index 5616184e8080..000000000000 --- a/sys/boot/ofw/libofw/ofw_memory.c +++ /dev/null @@ -1,146 +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" - -static void *heap_base = NULL; -static unsigned int heap_size = 0; - -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(); -} - -void * -ofw_alloc_heap(unsigned int size) -{ - phandle_t memoryp, root; - cell_t available[4]; - cell_t acells; - - root = OF_finddevice("/"); - acells = 1; - OF_getprop(root, "#address-cells", &acells, sizeof(acells)); - - memoryp = OF_instance_to_package(memory); - OF_getprop(memoryp, "available", available, sizeof(available)); - - heap_base = OF_claim((void *)available[acells-1], size, - sizeof(register_t)); - - if (heap_base != (void *)-1) { - heap_size = size; - } - - return (heap_base); -} - -void -ofw_release_heap(void) -{ - OF_release(heap_base, heap_size); -} diff --git a/sys/boot/ofw/libofw/ofw_module.c b/sys/boot/ofw/libofw/ofw_module.c deleted file mode 100644 index d39a34344556..000000000000 --- a/sys/boot/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/sys/boot/ofw/libofw/ofw_net.c b/sys/boot/ofw/libofw/ofw_net.c deleted file mode 100644 index ea5e47e7ed0d..000000000000 --- a/sys/boot/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 %08x).\n", dmabuf); - goto punt; - } - -#if defined(NETIF_DEBUG) - printf("ofwn_init: allocated DMA buffer: %08x\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/sys/boot/ofw/libofw/ofw_reboot.c b/sys/boot/ofw/libofw/ofw_reboot.c deleted file mode 100644 index bbb420ac1767..000000000000 --- a/sys/boot/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/sys/boot/ofw/libofw/ofw_time.c b/sys/boot/ofw/libofw/ofw_time.c deleted file mode 100644 index d5ca271564de..000000000000 --- a/sys/boot/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/sys/boot/ofw/libofw/openfirm.c b/sys/boot/ofw/libofw/openfirm.c deleted file mode 100644 index 1ccae60d66d0..000000000000 --- a/sys/boot/ofw/libofw/openfirm.c +++ /dev/null @@ -1,832 +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, 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, 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, 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, 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, u_int64_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/sys/boot/ofw/libofw/openfirm.h b/sys/boot/ofw/libofw/openfirm.h deleted file mode 100644 index 9fe77c69a09f..000000000000 --- a/sys/boot/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, 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(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_ */ diff --git a/sys/boot/ofw/libofw/ppc64_elf_freebsd.c b/sys/boot/ofw/libofw/ppc64_elf_freebsd.c deleted file mode 100644 index b411da491222..000000000000 --- a/sys/boot/ofw/libofw/ppc64_elf_freebsd.c +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * Copyright (c) 2001 Benno Rice <benno@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$"); - -#define __ELF_WORD_SIZE 64 - -#include <sys/param.h> -#include <sys/linker.h> - -#include <machine/metadata.h> -#include <machine/elf.h> - -#include <stand.h> - -#include "bootstrap.h" -#include "libofw.h" -#include "openfirm.h" - -extern char end[]; -extern vm_offset_t reloc; /* From <arch>/conf.c */ - -int -ppc64_ofw_elf_loadfile(char *filename, u_int64_t dest, - struct preloaded_file **result) -{ - int r; - - r = __elfN(loadfile)(filename, dest, result); - if (r != 0) - return (r); - - /* - * No need to sync the icache for modules: this will - * be done by the kernel after relocation. - */ - if (!strcmp((*result)->f_type, "elf kernel")) - __syncicache((void *) (*result)->f_addr, (*result)->f_size); - return (0); -} - -int -ppc64_ofw_elf_exec(struct preloaded_file *fp) -{ - struct file_metadata *fmp; - vm_offset_t mdp, dtbp; - Elf_Ehdr *e; - int error; - intptr_t entry; - - if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) { - return(EFTYPE); - } - e = (Elf_Ehdr *)&fmp->md_data; - - /* Handle function descriptor for ELFv1 kernels */ - if ((e->e_flags & 3) == 2) - entry = e->e_entry; - else - entry = *(uint64_t *)e->e_entry; - - if ((error = md_load64(fp->f_args, &mdp, &dtbp)) != 0) - return (error); - - printf("Kernel entry at 0x%lx ...\n", entry); - - dev_cleanup(); - ofw_release_heap(); - - if (dtbp != 0) { - OF_quiesce(); - ((int (*)(u_long, u_long, u_long, void *, u_long))entry)(dtbp, 0, 0, - mdp, sizeof(mdp)); - } else { - OF_chain((void *)reloc, end - (char *)reloc, (void *)entry, - (void *)mdp, sizeof(mdp)); - } - - panic("exec returned"); -} - -struct file_format ofw_elf64 = -{ - ppc64_ofw_elf_loadfile, - ppc64_ofw_elf_exec -}; |
