aboutsummaryrefslogtreecommitdiff
path: root/sys/boot/uboot/lib
diff options
context:
space:
mode:
Diffstat (limited to 'sys/boot/uboot/lib')
-rw-r--r--sys/boot/uboot/lib/Makefile31
-rw-r--r--sys/boot/uboot/lib/api_public.h160
-rw-r--r--sys/boot/uboot/lib/console.c89
-rw-r--r--sys/boot/uboot/lib/copy.c166
-rw-r--r--sys/boot/uboot/lib/devicename.c201
-rw-r--r--sys/boot/uboot/lib/disk.c320
-rw-r--r--sys/boot/uboot/lib/elf_freebsd.c100
-rw-r--r--sys/boot/uboot/lib/glue.c564
-rw-r--r--sys/boot/uboot/lib/glue.h107
-rw-r--r--sys/boot/uboot/lib/libuboot.h77
-rw-r--r--sys/boot/uboot/lib/module.c57
-rw-r--r--sys/boot/uboot/lib/net.c364
-rw-r--r--sys/boot/uboot/lib/reboot.c38
-rw-r--r--sys/boot/uboot/lib/time.c65
14 files changed, 0 insertions, 2339 deletions
diff --git a/sys/boot/uboot/lib/Makefile b/sys/boot/uboot/lib/Makefile
deleted file mode 100644
index d12d48cafaa1..000000000000
--- a/sys/boot/uboot/lib/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-# $FreeBSD$
-
-.include <bsd.init.mk>
-
-.PATH: ${LDRSRC}
-
-LIB= uboot
-INTERNALLIB=
-WARNS?= 2
-
-SRCS= console.c copy.c devicename.c elf_freebsd.c glue.c
-SRCS+= module.c net.c reboot.c time.c
-
-CFLAGS+= -ffreestanding -msoft-float
-
-.if ${LOADER_DISK_SUPPORT:Uyes} == "yes"
-SRCS+= disk.c
-.endif
-
-.include "${BOOTSRC}/fdt.mk"
-
-# 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.stand.mk>
-.include <bsd.lib.mk>
diff --git a/sys/boot/uboot/lib/api_public.h b/sys/boot/uboot/lib/api_public.h
deleted file mode 100644
index f393de88933b..000000000000
--- a/sys/boot/uboot/lib/api_public.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * (C) Copyright 2007-2008 Semihalf
- *
- * Written by: Rafal Jaworowski <raj@semihalf.com>
- *
- * This file is dual licensed; you can use it under the terms of
- * either the GPL, or the BSD license, at your option.
- *
- * I. GPL:
- *
- * This file is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This file is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
- * Alternatively,
- *
- * II. BSD license:
- *
- * 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.
- *
- * $FreeBSD$
- *
- * This file needs to be kept in sync with U-Boot reference:
- * http://www.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=blob;f=include/api_public.h
- */
-
-#ifndef _API_PUBLIC_H_
-#define _API_PUBLIC_H_
-
-#define API_EINVAL 1 /* invalid argument(s) */
-#define API_ENODEV 2 /* no device */
-#define API_ENOMEM 3 /* no memory */
-#define API_EBUSY 4 /* busy, occupied etc. */
-#define API_EIO 5 /* I/O error */
-#define API_ESYSC 6 /* syscall error */
-
-typedef int (*scp_t)(int, int *, ...);
-
-#define API_SIG_VERSION 1
-#define API_SIG_MAGIC "UBootAPI"
-#define API_SIG_MAGLEN 8
-
-struct api_signature {
- char magic[API_SIG_MAGLEN]; /* magic string */
- uint16_t version; /* API version */
- uint32_t checksum; /* checksum of this sig struct */
- scp_t syscall; /* entry point to the API */
-};
-
-enum {
- API_RSVD = 0,
- API_GETC,
- API_PUTC,
- API_TSTC,
- API_PUTS,
- API_RESET,
- API_GET_SYS_INFO,
- API_UDELAY,
- API_GET_TIMER,
- API_DEV_ENUM,
- API_DEV_OPEN,
- API_DEV_CLOSE,
- API_DEV_READ,
- API_DEV_WRITE,
- API_ENV_ENUM,
- API_ENV_GET,
- API_ENV_SET,
- API_MAXCALL
-};
-
-#define MR_ATTR_FLASH 0x0001
-#define MR_ATTR_DRAM 0x0002
-#define MR_ATTR_SRAM 0x0003
-
-struct mem_region {
- unsigned long start;
- unsigned long size;
- int flags;
-};
-
-struct sys_info {
- unsigned long clk_bus;
- unsigned long clk_cpu;
- unsigned long bar;
- struct mem_region *mr;
- int mr_no; /* number of memory regions */
-};
-
-#undef CFG_64BIT_LBA
-#ifdef CFG_64BIT_LBA
-typedef uint64_t lbasize_t;
-#else
-typedef unsigned long lbasize_t;
-#endif
-typedef unsigned long lbastart_t;
-
-#define DEV_TYP_NONE 0x0000
-#define DEV_TYP_NET 0x0001
-
-#define DEV_TYP_STOR 0x0002
-#define DT_STOR_IDE 0x0010
-#define DT_STOR_SCSI 0x0020
-#define DT_STOR_USB 0x0040
-#define DT_STOR_MMC 0x0080
-#define DT_STOR_SATA 0x0100
-
-#define DEV_STA_CLOSED 0x0000 /* invalid, closed */
-#define DEV_STA_OPEN 0x0001 /* open i.e. active */
-
-struct device_info {
- int type;
- void *cookie;
-
- union {
- struct {
- lbasize_t block_count; /* no of blocks */
- unsigned long block_size; /* size of one block */
- } storage;
-
- struct {
- unsigned char hwaddr[6];
- } net;
- } info;
-#define di_stor info.storage
-#define di_net info.net
-
- int state;
-};
-
-#endif /* _API_PUBLIC_H_ */
diff --git a/sys/boot/uboot/lib/console.c b/sys/boot/uboot/lib/console.c
deleted file mode 100644
index f49f455c7efa..000000000000
--- a/sys/boot/uboot/lib/console.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*-
- * Copyright (c) 2007 Semihalf, Rafal Jaworowski <raj@semihalf.com>
- * 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 "glue.h"
-
-int console;
-
-static void uboot_cons_probe(struct console *cp);
-static int uboot_cons_init(int);
-static void uboot_cons_putchar(int);
-static int uboot_cons_getchar(void);
-static int uboot_cons_poll(void);
-
-struct console uboot_console = {
- "uboot",
- "U-Boot console",
- 0,
- uboot_cons_probe,
- uboot_cons_init,
- uboot_cons_putchar,
- uboot_cons_getchar,
- uboot_cons_poll,
-};
-
-static void
-uboot_cons_probe(struct console *cp)
-{
-
- cp->c_flags |= (C_PRESENTIN | C_PRESENTOUT);
-}
-
-static int
-uboot_cons_init(int arg)
-{
-
- return (0);
-}
-
-static void
-uboot_cons_putchar(int c)
-{
-
- if (c == '\n')
- ub_putc('\r');
-
- ub_putc(c);
-}
-
-static int
-uboot_cons_getchar()
-{
-
- return (ub_getc());
-}
-
-static int
-uboot_cons_poll()
-{
-
- return (ub_tstc());
-}
diff --git a/sys/boot/uboot/lib/copy.c b/sys/boot/uboot/lib/copy.c
deleted file mode 100644
index 131b88d85861..000000000000
--- a/sys/boot/uboot/lib/copy.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/*-
- * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
- * Copyright (c) 2007 Semihalf, Rafal Jaworowski <raj@semihalf.com>
- * 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 <stand.h>
-#include <stdint.h>
-
-#include "api_public.h"
-#include "glue.h"
-#include "libuboot.h"
-
-/*
- * MD primitives supporting placement of module data
- */
-
-#ifdef __arm__
-#define KERN_ALIGN (2 * 1024 * 1024)
-#else
-#define KERN_ALIGN PAGE_SIZE
-#endif
-
-/*
- * Avoid low memory, u-boot puts things like args and dtb blobs there.
- */
-#define KERN_MINADDR max(KERN_ALIGN, (1024 * 1024))
-
-extern void _start(void); /* ubldr entry point address. */
-
-/*
- * This is called for every object loaded (kernel, module, dtb file, etc). The
- * expected return value is the next address at or after the given addr which is
- * appropriate for loading the given object described by type and data. On each
- * call the addr is the next address following the previously loaded object.
- *
- * The first call is for loading the kernel, and the addr argument will be zero,
- * and we search for a big block of ram to load the kernel and modules.
- *
- * On subsequent calls the addr will be non-zero, and we just round it up so
- * that each object begins on a page boundary.
- */
-uint64_t
-uboot_loadaddr(u_int type, void *data, uint64_t addr)
-{
- struct sys_info *si;
- uint64_t sblock, eblock, subldr, eubldr;
- uint64_t biggest_block, this_block;
- uint64_t biggest_size, this_size;
- int i;
- char *envstr;
-
- if (addr == 0) {
- /*
- * If the loader_kernaddr environment variable is set, blindly
- * honor it. It had better be right. We force interpretation
- * of the value in base-16 regardless of any leading 0x prefix,
- * because that's the U-Boot convention.
- */
- envstr = ub_env_get("loader_kernaddr");
- if (envstr != NULL)
- return (strtoul(envstr, NULL, 16));
-
- /*
- * Find addr/size of largest DRAM block. Carve our own address
- * range out of the block, because loading the kernel over the
- * top ourself is a poor memory-conservation strategy. Avoid
- * memory at beginning of the first block of physical ram,
- * since u-boot likes to pass args and data there. Assume that
- * u-boot has moved itself to the very top of ram and
- * optimistically assume that we won't run into it up there.
- */
- if ((si = ub_get_sys_info()) == NULL)
- panic("could not retrieve system info");
-
- biggest_block = 0;
- biggest_size = 0;
- subldr = rounddown2((uintptr_t)_start, KERN_ALIGN);
- eubldr = roundup2((uint64_t)uboot_heap_end, KERN_ALIGN);
- for (i = 0; i < si->mr_no; i++) {
- if (si->mr[i].flags != MR_ATTR_DRAM)
- continue;
- sblock = roundup2((uint64_t)si->mr[i].start,
- KERN_ALIGN);
- eblock = rounddown2((uint64_t)si->mr[i].start +
- si->mr[i].size, KERN_ALIGN);
- if (biggest_size == 0)
- sblock += KERN_MINADDR;
- if (subldr >= sblock && subldr < eblock) {
- if (subldr - sblock > eblock - eubldr) {
- this_block = sblock;
- this_size = subldr - sblock;
- } else {
- this_block = eubldr;
- this_size = eblock - eubldr;
- }
- } else if (subldr < sblock && eubldr < eblock) {
- /* Loader is below or engulfs the sblock */
- this_block = (eubldr < sblock) ? sblock : eubldr;
- this_size = eblock - this_block;
- } else {
- this_block = 0;
- this_size = 0;
- }
- if (biggest_size < this_size) {
- biggest_block = this_block;
- biggest_size = this_size;
- }
- }
- if (biggest_size == 0)
- panic("Not enough DRAM to load kernel\n");
-#if 0
- printf("Loading kernel into region 0x%08jx-0x%08jx (%ju MiB)\n",
- (uintmax_t)biggest_block,
- (uintmax_t)biggest_block + biggest_size - 1,
- (uintmax_t)biggest_size / 1024 / 1024);
-#endif
- return (biggest_block);
- }
- return roundup2(addr, PAGE_SIZE);
-}
-
-ssize_t
-uboot_copyin(const void *src, vm_offset_t dest, const size_t len)
-{
- bcopy(src, (void *)dest, len);
- return (len);
-}
-
-ssize_t
-uboot_copyout(const vm_offset_t src, void *dest, const size_t len)
-{
- bcopy((void *)src, dest, len);
- return (len);
-}
-
-ssize_t
-uboot_readin(const int fd, vm_offset_t dest, const size_t len)
-{
- return (read(fd, (void *)dest, len));
-}
diff --git a/sys/boot/uboot/lib/devicename.c b/sys/boot/uboot/lib/devicename.c
deleted file mode 100644
index 9e68f9df9eb8..000000000000
--- a/sys/boot/uboot/lib/devicename.c
+++ /dev/null
@@ -1,201 +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 <string.h>
-
-#include "bootstrap.h"
-#include "disk.h"
-#include "libuboot.h"
-
-static int uboot_parsedev(struct uboot_devdesc **dev, const char *devspec,
- const char **path);
-
-/*
- * 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
-uboot_getdev(void **vdev, const char *devspec, const char **path)
-{
- struct uboot_devdesc **dev = (struct uboot_devdesc **)vdev;
- int rv;
-
- /*
- * If it looks like this is just a path and no
- * device, go with the current device.
- */
- if ((devspec == NULL) || (devspec[0] == '/') ||
- (strchr(devspec, ':') == NULL)) {
-
- if (((rv = uboot_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 (uboot_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).
- *
- * In all cases, the beginning of (devspec) is compared to the names
- * of known devices in the device switch, and then any following text
- * is parsed according to the rules applied to the device type.
- *
- * For disk-type devices, the syntax is:
- *
- * disk<unit>[<partition>]:
- *
- */
-static int
-uboot_parsedev(struct uboot_devdesc **dev, const char *devspec,
- const char **path)
-{
- struct uboot_devdesc *idev;
- struct devsw *dv;
- char *cp;
- const char *np;
- int i, unit, err;
-
- /* minimum length check */
- if (strlen(devspec) < 2)
- return(EINVAL);
-
- /* look for a device that matches */
- for (i = 0, dv = NULL; devsw[i] != NULL; i++) {
- if (!strncmp(devspec, devsw[i]->dv_name,
- strlen(devsw[i]->dv_name))) {
- dv = devsw[i];
- break;
- }
- }
- if (dv == NULL)
- return(ENOENT);
- idev = malloc(sizeof(struct uboot_devdesc));
- err = 0;
- np = (devspec + strlen(dv->dv_name));
-
- switch(dv->dv_type) {
- case DEVT_NONE:
- break;
-
-#ifdef LOADER_DISK_SUPPORT
- case DEVT_DISK:
- err = disk_parsedev((struct disk_devdesc *)idev, np, path);
- if (err != 0)
- goto fail;
- break;
-#endif
-
- case DEVT_NET:
- unit = 0;
-
- if (*np && (*np != ':')) {
- /* get unit number if present */
- unit = strtol(np, &cp, 0);
- if (cp == np) {
- err = EUNIT;
- goto fail;
- }
- }
- if (*cp && (*cp != ':')) {
- err = EINVAL;
- goto fail;
- }
- idev->d_unit = unit;
-
- if (path != NULL)
- *path = (*cp == 0) ? cp : cp + 1;
- break;
-
- default:
- err = EINVAL;
- goto fail;
- }
- idev->d_dev = dv;
- idev->d_type = dv->dv_type;
- if (dev == NULL) {
- free(idev);
- } else {
- *dev = idev;
- }
- return (0);
-
-fail:
- free(idev);
- return (err);
-}
-
-
-char *
-uboot_fmtdev(void *vdev)
-{
- struct uboot_devdesc *dev = (struct uboot_devdesc *)vdev;
- static char buf[128];
-
- switch(dev->d_type) {
- case DEVT_NONE:
- strcpy(buf, "(no device)");
- break;
-
- case DEVT_DISK:
-#ifdef LOADER_DISK_SUPPORT
- return (disk_fmtdev(vdev));
-#endif
-
- case DEVT_NET:
- sprintf(buf, "%s%d:", dev->d_dev->dv_name, dev->d_unit);
- break;
- }
- return(buf);
-}
-
-/*
- * Set currdev to suit the value being supplied in (value).
- */
-int
-uboot_setcurrdev(struct env_var *ev, int flags, const void *value)
-{
- struct uboot_devdesc *ncurr;
- int rv;
-
- if ((rv = uboot_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/uboot/lib/disk.c b/sys/boot/uboot/lib/disk.c
deleted file mode 100644
index f5e44c749ba3..000000000000
--- a/sys/boot/uboot/lib/disk.c
+++ /dev/null
@@ -1,320 +0,0 @@
-/*-
- * Copyright (c) 2008 Semihalf, Rafal Jaworowski
- * Copyright (c) 2009 Semihalf, Piotr Ziecik
- * Copyright (c) 2012 Andrey V. Elsukov <ae@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.
- *
- */
-
-/*
- * Block storage I/O routines for U-Boot
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/disk.h>
-#include <machine/stdarg.h>
-#include <stand.h>
-
-#include "api_public.h"
-#include "bootstrap.h"
-#include "disk.h"
-#include "glue.h"
-#include "libuboot.h"
-
-#define stor_printf(fmt, args...) do { \
- printf("%s%d: ", dev->d_dev->dv_name, dev->d_unit); \
- printf(fmt, ##args); \
-} while (0)
-
-#ifdef DEBUG
-#define debugf(fmt, args...) do { printf("%s(): ", __func__); \
- printf(fmt,##args); } while (0)
-#else
-#define debugf(fmt, args...)
-#endif
-
-static struct {
- int opened; /* device is opened */
- int handle; /* storage device handle */
- int type; /* storage type */
- off_t blocks; /* block count */
- u_int bsize; /* block size */
-} stor_info[UB_MAX_DEV];
-
-#define SI(dev) (stor_info[(dev)->d_unit])
-
-static int stor_info_no = 0;
-static int stor_opendev(struct disk_devdesc *);
-static int stor_readdev(struct disk_devdesc *, daddr_t, size_t, char *);
-
-/* devsw I/F */
-static int stor_init(void);
-static int stor_strategy(void *, int, daddr_t, size_t, char *, size_t *);
-static int stor_open(struct open_file *, ...);
-static int stor_close(struct open_file *);
-static int stor_ioctl(struct open_file *f, u_long cmd, void *data);
-static int stor_print(int);
-static void stor_cleanup(void);
-
-struct devsw uboot_storage = {
- "disk",
- DEVT_DISK,
- stor_init,
- stor_strategy,
- stor_open,
- stor_close,
- stor_ioctl,
- stor_print,
- stor_cleanup
-};
-
-static int
-stor_init(void)
-{
- struct device_info *di;
- int i;
-
- if (devs_no == 0) {
- printf("No U-Boot devices! Really enumerated?\n");
- return (-1);
- }
-
- for (i = 0; i < devs_no; i++) {
- di = ub_dev_get(i);
- if ((di != NULL) && (di->type & DEV_TYP_STOR)) {
- if (stor_info_no >= UB_MAX_DEV) {
- printf("Too many storage devices: %d\n",
- stor_info_no);
- return (-1);
- }
- stor_info[stor_info_no].handle = i;
- stor_info[stor_info_no].opened = 0;
- stor_info[stor_info_no].type = di->type;
- stor_info[stor_info_no].blocks =
- di->di_stor.block_count;
- stor_info[stor_info_no].bsize =
- di->di_stor.block_size;
- stor_info_no++;
- }
- }
-
- if (!stor_info_no) {
- debugf("No storage devices\n");
- return (-1);
- }
-
- debugf("storage devices found: %d\n", stor_info_no);
- return (0);
-}
-
-static void
-stor_cleanup(void)
-{
- int i;
-
- for (i = 0; i < stor_info_no; i++)
- if (stor_info[i].opened > 0)
- ub_dev_close(stor_info[i].handle);
-}
-
-static int
-stor_strategy(void *devdata, int rw, daddr_t blk, size_t size,
- char *buf, size_t *rsize)
-{
- struct disk_devdesc *dev = (struct disk_devdesc *)devdata;
- daddr_t bcount;
- int err;
-
- rw &= F_MASK;
- if (rw != F_READ) {
- stor_printf("write attempt, operation not supported!\n");
- return (EROFS);
- }
-
- if (size % SI(dev).bsize) {
- stor_printf("size=%zu not multiple of device "
- "block size=%d\n",
- size, SI(dev).bsize);
- return (EIO);
- }
- bcount = size / SI(dev).bsize;
- if (rsize)
- *rsize = 0;
-
- err = stor_readdev(dev, blk + dev->d_offset, bcount, buf);
- if (!err && rsize)
- *rsize = size;
-
- return (err);
-}
-
-static int
-stor_open(struct open_file *f, ...)
-{
- va_list ap;
- struct disk_devdesc *dev;
-
- va_start(ap, f);
- dev = va_arg(ap, struct disk_devdesc *);
- va_end(ap);
-
- return (stor_opendev(dev));
-}
-
-static int
-stor_opendev(struct disk_devdesc *dev)
-{
- int err;
-
- if (dev->d_unit < 0 || dev->d_unit >= stor_info_no)
- return (EIO);
-
- if (SI(dev).opened == 0) {
- err = ub_dev_open(SI(dev).handle);
- if (err != 0) {
- stor_printf("device open failed with error=%d, "
- "handle=%d\n", err, SI(dev).handle);
- return (ENXIO);
- }
- SI(dev).opened++;
- }
- return (disk_open(dev, SI(dev).blocks * SI(dev).bsize,
- SI(dev).bsize));
-}
-
-static int
-stor_close(struct open_file *f)
-{
- struct disk_devdesc *dev;
-
- dev = (struct disk_devdesc *)(f->f_devdata);
- return (disk_close(dev));
-}
-
-static int
-stor_readdev(struct disk_devdesc *dev, daddr_t blk, size_t size, char *buf)
-{
- lbasize_t real_size;
- int err;
-
- debugf("reading blk=%d size=%d @ 0x%08x\n", (int)blk, size, (uint32_t)buf);
-
- err = ub_dev_read(SI(dev).handle, buf, size, blk, &real_size);
- if (err != 0) {
- stor_printf("read failed, error=%d\n", err);
- return (EIO);
- }
-
- if (real_size != size) {
- stor_printf("real size != size\n");
- err = EIO;
- }
-
- return (err);
-}
-
-static int
-stor_print(int verbose)
-{
- struct disk_devdesc dev;
- static char line[80];
- int i, ret = 0;
-
- if (stor_info_no == 0)
- return (ret);
-
- printf("%s devices:", uboot_storage.dv_name);
- if ((ret = pager_output("\n")) != 0)
- return (ret);
-
- for (i = 0; i < stor_info_no; i++) {
- dev.d_dev = &uboot_storage;
- dev.d_unit = i;
- dev.d_slice = -1;
- dev.d_partition = -1;
- snprintf(line, sizeof(line), "\tdisk%d (%s)\n", i,
- ub_stor_type(SI(&dev).type));
- if ((ret = pager_output(line)) != 0)
- break;
- if (stor_opendev(&dev) == 0) {
- sprintf(line, "\tdisk%d", i);
- ret = disk_print(&dev, line, verbose);
- disk_close(&dev);
- if (ret != 0)
- break;
- }
- }
- return (ret);
-}
-
-static int
-stor_ioctl(struct open_file *f, u_long cmd, void *data)
-{
- struct disk_devdesc *dev;
- int rc;
-
- dev = (struct disk_devdesc *)f->f_devdata;
- rc = disk_ioctl(dev, cmd, data);
- if (rc != ENOTTY)
- return (rc);
-
- switch (cmd) {
- case DIOCGSECTORSIZE:
- *(u_int *)data = SI(dev).bsize;
- break;
- case DIOCGMEDIASIZE:
- *(uint64_t *)data = SI(dev).bsize * SI(dev).blocks;
- break;
- default:
- return (ENOTTY);
- }
- return (0);
-}
-
-
-/*
- * Return the device unit number for the given type and type-relative unit
- * number.
- */
-int
-uboot_diskgetunit(int type, int type_unit)
-{
- int local_type_unit;
- int i;
-
- local_type_unit = 0;
- for (i = 0; i < stor_info_no; i++) {
- if ((stor_info[i].type & type) == type) {
- if (local_type_unit == type_unit) {
- return (i);
- }
- local_type_unit++;
- }
- }
-
- return (-1);
-}
diff --git a/sys/boot/uboot/lib/elf_freebsd.c b/sys/boot/uboot/lib/elf_freebsd.c
deleted file mode 100644
index a65fa26aa722..000000000000
--- a/sys/boot/uboot/lib/elf_freebsd.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*-
- * Copyright (c) 2001 Benno Rice <benno@FreeBSD.org>
- * Copyright (c) 2007 Semihalf, Rafal Jaworowski <raj@semihalf.com>
- * 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>
-
-#ifdef __mips__
-#include <sys/proc.h>
-#include <machine/frame.h>
-#endif
-#include <machine/md_var.h>
-#include <machine/metadata.h>
-#include <machine/elf.h>
-
-#include <stand.h>
-
-#include "bootstrap.h"
-#include "libuboot.h"
-
-extern vm_offset_t md_load(char *, vm_offset_t *);
-
-int
-__elfN(uboot_load)(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(uboot_exec)(struct preloaded_file *fp)
-{
- struct file_metadata *fmp;
- vm_offset_t mdp;
- Elf_Ehdr *e;
- int error;
- void (*entry)(void *);
-
- if ((fmp = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL)
- return (EFTYPE);
-
- e = (Elf_Ehdr *)&fmp->md_data;
-
- if ((error = md_load(fp->f_args, &mdp)) != 0)
- return (error);
-
- entry = (void *)e->e_entry;
- printf("Kernel entry at %p...\n", entry);
-
- dev_cleanup();
- printf("Kernel args: %s\n", fp->f_args);
-
- (*entry)((void *)mdp);
- panic("exec returned");
-}
-
-struct file_format uboot_elf = {
- __elfN(uboot_load),
- __elfN(uboot_exec)
-};
diff --git a/sys/boot/uboot/lib/glue.c b/sys/boot/uboot/lib/glue.c
deleted file mode 100644
index 312075ab9882..000000000000
--- a/sys/boot/uboot/lib/glue.c
+++ /dev/null
@@ -1,564 +0,0 @@
-/*-
- * Copyright (c) 2007-2008 Semihalf, Rafal Jaworowski <raj@semihalf.com>
- * 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/types.h>
-
-#include <crc32.h>
-#include <stand.h>
-#include "api_public.h"
-#include "glue.h"
-
-#ifdef DEBUG
-#define debugf(fmt, args...) do { printf("%s(): ", __func__); printf(fmt,##args); } while (0)
-#else
-#define debugf(fmt, args...)
-#endif
-
-/* Some random address used by U-Boot. */
-extern long uboot_address;
-
-static int
-valid_sig(struct api_signature *sig)
-{
- uint32_t checksum;
- struct api_signature s;
-
- if (sig == NULL)
- return (0);
- /*
- * Clear the checksum field (in the local copy) so as to calculate the
- * CRC with the same initial contents as at the time when the sig was
- * produced
- */
- s = *sig;
- s.checksum = 0;
-
- checksum = crc32((void *)&s, sizeof(struct api_signature));
-
- if (checksum != sig->checksum)
- return (0);
-
- return (1);
-}
-
-/*
- * Checks to see if API signature's address was given to us as a command line
- * argument by U-Boot.
- *
- * returns 1/0 depending on found/not found result
- */
-int
-api_parse_cmdline_sig(int argc, char **argv, struct api_signature **sig)
-{
- unsigned long api_address;
- int c;
-
- api_address = 0;
- opterr = 0;
- optreset = 1;
- optind = 1;
-
- while ((c = getopt (argc, argv, "a:")) != -1)
- switch (c) {
- case 'a':
- api_address = strtoul(optarg, NULL, 16);
- break;
- default:
- break;
- }
-
- if (api_address != 0) {
- *sig = (struct api_signature *)api_address;
- if (valid_sig(*sig))
- return (1);
- }
-
- return (0);
-}
-
-/*
- * Searches for the U-Boot API signature
- *
- * returns 1/0 depending on found/not found result
- */
-int
-api_search_sig(struct api_signature **sig)
-{
- unsigned char *sp, *spend;
-
- if (sig == NULL)
- return (0);
-
- if (uboot_address == 0)
- uboot_address = 255 * 1024 * 1024;
-
- sp = (void *)(uboot_address & API_SIG_SEARCH_MASK);
- spend = sp + API_SIG_SEARCH_LEN - API_SIG_MAGLEN;
-
- while (sp < spend) {
- if (!bcmp(sp, API_SIG_MAGIC, API_SIG_MAGLEN)) {
- *sig = (struct api_signature *)sp;
- if (valid_sig(*sig))
- return (1);
- }
- sp += API_SIG_MAGLEN;
- }
-
- *sig = NULL;
- return (0);
-}
-
-/****************************************
- *
- * console
- *
- ****************************************/
-
-int
-ub_getc(void)
-{
- int c;
-
- if (!syscall(API_GETC, NULL, &c))
- return (-1);
-
- return (c);
-}
-
-int
-ub_tstc(void)
-{
- int t;
-
- if (!syscall(API_TSTC, NULL, &t))
- return (-1);
-
- return (t);
-}
-
-void
-ub_putc(const char c)
-{
-
- syscall(API_PUTC, NULL, &c);
-}
-
-void
-ub_puts(const char *s)
-{
-
- syscall(API_PUTS, NULL, s);
-}
-
-/****************************************
- *
- * system
- *
- ****************************************/
-
-void
-ub_reset(void)
-{
-
- syscall(API_RESET, NULL);
-}
-
-static struct mem_region mr[UB_MAX_MR];
-static struct sys_info si;
-
-struct sys_info *
-ub_get_sys_info(void)
-{
- int err = 0;
-
- memset(&si, 0, sizeof(struct sys_info));
- si.mr = mr;
- si.mr_no = UB_MAX_MR;
- memset(&mr, 0, sizeof(mr));
-
- if (!syscall(API_GET_SYS_INFO, &err, &si))
- return (NULL);
-
- return ((err) ? NULL : &si);
-}
-
-/****************************************
- *
- * timing
- *
- ****************************************/
-
-void
-ub_udelay(unsigned long usec)
-{
-
- syscall(API_UDELAY, NULL, &usec);
-}
-
-unsigned long
-ub_get_timer(unsigned long base)
-{
- unsigned long cur;
-
- if (!syscall(API_GET_TIMER, NULL, &cur, &base))
- return (0);
-
- return (cur);
-}
-
-/****************************************************************************
- *
- * devices
- *
- * Devices are identified by handles: numbers 0, 1, 2, ..., UB_MAX_DEV-1
- *
- ***************************************************************************/
-
-static struct device_info devices[UB_MAX_DEV];
-
-struct device_info *
-ub_dev_get(int i)
-{
-
- return ((i < 0 || i >= UB_MAX_DEV) ? NULL : &devices[i]);
-}
-
-/*
- * Enumerates the devices: fills out device_info elements in the devices[]
- * array.
- *
- * returns: number of devices found
- */
-int
-ub_dev_enum(void)
-{
- struct device_info *di;
- int n = 0;
-
- memset(&devices, 0, sizeof(struct device_info) * UB_MAX_DEV);
- di = &devices[0];
-
- if (!syscall(API_DEV_ENUM, NULL, di))
- return (0);
-
- while (di->cookie != NULL) {
-
- if (++n >= UB_MAX_DEV)
- break;
-
- /* take another device_info */
- di++;
-
- /* pass on the previous cookie */
- di->cookie = devices[n - 1].cookie;
-
- if (!syscall(API_DEV_ENUM, NULL, di))
- return (0);
- }
-
- return (n);
-}
-
-/*
- * handle: 0-based id of the device
- *
- * returns: 0 when OK, err otherwise
- */
-int
-ub_dev_open(int handle)
-{
- struct device_info *di;
- int err = 0;
-
- if (handle < 0 || handle >= UB_MAX_DEV)
- return (API_EINVAL);
-
- di = &devices[handle];
- if (!syscall(API_DEV_OPEN, &err, di))
- return (-1);
-
- return (err);
-}
-
-int
-ub_dev_close(int handle)
-{
- struct device_info *di;
-
- if (handle < 0 || handle >= UB_MAX_DEV)
- return (API_EINVAL);
-
- di = &devices[handle];
- if (!syscall(API_DEV_CLOSE, NULL, di))
- return (-1);
-
- return (0);
-}
-
-/*
- * Validates device for read/write, it has to:
- *
- * - have sane handle
- * - be opened
- *
- * returns: 0/1 accordingly
- */
-static int
-dev_valid(int handle)
-{
-
- if (handle < 0 || handle >= UB_MAX_DEV)
- return (0);
-
- if (devices[handle].state != DEV_STA_OPEN)
- return (0);
-
- return (1);
-}
-
-static int
-dev_stor_valid(int handle)
-{
-
- if (!dev_valid(handle))
- return (0);
-
- if (!(devices[handle].type & DEV_TYP_STOR))
- return (0);
-
- return (1);
-}
-
-int
-ub_dev_read(int handle, void *buf, lbasize_t len, lbastart_t start,
- lbasize_t *rlen)
-{
- struct device_info *di;
- lbasize_t act_len;
- int err = 0;
-
- if (!dev_stor_valid(handle))
- return (API_ENODEV);
-
- di = &devices[handle];
- if (!syscall(API_DEV_READ, &err, di, buf, &len, &start, &act_len))
- return (API_ESYSC);
-
- if (!err && rlen)
- *rlen = act_len;
-
- return (err);
-}
-
-static int
-dev_net_valid(int handle)
-{
-
- if (!dev_valid(handle))
- return (0);
-
- if (devices[handle].type != DEV_TYP_NET)
- return (0);
-
- return (1);
-}
-
-int
-ub_dev_recv(int handle, void *buf, int len, int *rlen)
-{
- struct device_info *di;
- int err = 0, act_len;
-
- if (!dev_net_valid(handle))
- return (API_ENODEV);
-
- di = &devices[handle];
- if (!syscall(API_DEV_READ, &err, di, buf, &len, &act_len))
- return (API_ESYSC);
-
- if (!err)
- *rlen = act_len;
-
- return (err);
-}
-
-int
-ub_dev_send(int handle, void *buf, int len)
-{
- struct device_info *di;
- int err = 0;
-
- if (!dev_net_valid(handle))
- return (API_ENODEV);
-
- di = &devices[handle];
- if (!syscall(API_DEV_WRITE, &err, di, buf, &len))
- return (API_ESYSC);
-
- return (err);
-}
-
-char *
-ub_stor_type(int type)
-{
-
- if (type & DT_STOR_IDE)
- return ("IDE");
-
- if (type & DT_STOR_SCSI)
- return ("SCSI");
-
- if (type & DT_STOR_USB)
- return ("USB");
-
- if (type & DT_STOR_MMC)
- return ("MMC");
-
- if (type & DT_STOR_SATA)
- return ("SATA");
-
- return ("Unknown");
-}
-
-char *
-ub_mem_type(int flags)
-{
-
- switch (flags & 0x000F) {
- case MR_ATTR_FLASH:
- return ("FLASH");
- case MR_ATTR_DRAM:
- return ("DRAM");
- case MR_ATTR_SRAM:
- return ("SRAM");
- default:
- return ("Unknown");
- }
-}
-
-void
-ub_dump_di(int handle)
-{
- struct device_info *di = ub_dev_get(handle);
- int i;
-
- printf("device info (%d):\n", handle);
- printf(" cookie\t= %p\n", di->cookie);
- printf(" type\t\t= 0x%08x\n", di->type);
-
- if (di->type == DEV_TYP_NET) {
- printf(" hwaddr\t= ");
- for (i = 0; i < 6; i++)
- printf("%02x ", di->di_net.hwaddr[i]);
-
- printf("\n");
-
- } else if (di->type & DEV_TYP_STOR) {
- printf(" type\t\t= %s\n", ub_stor_type(di->type));
- printf(" blk size\t\t= %ld\n", di->di_stor.block_size);
- printf(" blk count\t\t= %ld\n", di->di_stor.block_count);
- }
-}
-
-void
-ub_dump_si(struct sys_info *si)
-{
- int i;
-
- printf("sys info:\n");
- printf(" clkbus\t= %ld MHz\n", si->clk_bus / 1000 / 1000);
- printf(" clkcpu\t= %ld MHz\n", si->clk_cpu / 1000 / 1000);
- printf(" bar\t\t= 0x%08lx\n", si->bar);
-
- printf("---\n");
- for (i = 0; i < si->mr_no; i++) {
- if (si->mr[i].flags == 0)
- break;
-
- printf(" start\t= 0x%08lx\n", si->mr[i].start);
- printf(" size\t= 0x%08lx\n", si->mr[i].size);
- printf(" type\t= %s\n", ub_mem_type(si->mr[i].flags));
- printf("---\n");
- }
-}
-
-/****************************************
- *
- * env vars
- *
- ****************************************/
-
-char *
-ub_env_get(const char *name)
-{
- char *value;
-
- if (!syscall(API_ENV_GET, NULL, name, &value))
- return (NULL);
-
- return (value);
-}
-
-void
-ub_env_set(const char *name, char *value)
-{
-
- syscall(API_ENV_SET, NULL, name, value);
-}
-
-static char env_name[256];
-
-const char *
-ub_env_enum(const char *last)
-{
- const char *env, *str;
- int i;
-
- /*
- * It's OK to pass only the name piece as last (and not the whole
- * 'name=val' string), since the API_ENUM_ENV call uses envmatch()
- * internally, which handles such case
- */
- env = NULL;
- if (!syscall(API_ENV_ENUM, NULL, last, &env))
- return (NULL);
-
- if (env == NULL || last == env)
- /* no more env. variables to enumerate */
- return (NULL);
-
- /* next enumerated env var */
- memset(env_name, 0, 256);
- for (i = 0, str = env; *str != '=' && *str != '\0';)
- env_name[i++] = *str++;
-
- env_name[i] = '\0';
-
- return (env_name);
-}
diff --git a/sys/boot/uboot/lib/glue.h b/sys/boot/uboot/lib/glue.h
deleted file mode 100644
index 4c2da66ccb27..000000000000
--- a/sys/boot/uboot/lib/glue.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * Copyright (c) 2008 Semihalf, Rafal Jaworowski <raj@semihalf.com>
- * 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.
- *
- * $FreeBSD$
- */
-
-/*
- * This is the header file for conveniency wrapper routines (API glue)
- */
-
-#ifndef _API_GLUE_H_
-#define _API_GLUE_H_
-
-#include "api_public.h"
-
-/*
- * Mask used to align the start address for API signature search to 1MiB
- */
-#define API_SIG_SEARCH_MASK ~0x000fffff
-
-#ifdef __mips__
-/*
- * On MIPS, U-Boot passes us a hint address, which is very close to the end of
- * RAM (less than 1MiB), so searching for the API signature within more than
- * that leads to exception.
- */
-#define API_SIG_SEARCH_LEN 0x00100000
-#else
-/*
- * Search for the API signature within 3MiB of the 1MiB-aligned address that
- * U-Boot has hinted us.
- */
-#define API_SIG_SEARCH_LEN 0x00300000
-#endif
-
-int syscall(int, int *, ...);
-void *syscall_ptr;
-
-int api_parse_cmdline_sig(int argc, char **argv, struct api_signature **sig);
-int api_search_sig(struct api_signature **sig);
-
-#define UB_MAX_MR 16 /* max mem regions number */
-#define UB_MAX_DEV 6 /* max devices number */
-
-/*
- * The ub_ library calls are part of the application, not U-Boot code! They
- * are front-end wrappers that are used by the consumer application: they
- * prepare arguments for particular syscall and jump to the low level
- * syscall()
- */
-
-/* console */
-int ub_getc(void);
-int ub_tstc(void);
-void ub_putc(char);
-void ub_puts(const char *);
-
-/* system */
-void ub_reset(void);
-struct sys_info *ub_get_sys_info(void);
-
-/* time */
-void ub_udelay(unsigned long);
-unsigned long ub_get_timer(unsigned long);
-
-/* env vars */
-char *ub_env_get(const char *);
-void ub_env_set(const char *, char *);
-const char *ub_env_enum(const char *);
-
-/* devices */
-int ub_dev_enum(void);
-int ub_dev_open(int);
-int ub_dev_close(int);
-int ub_dev_read(int, void *, lbasize_t, lbastart_t, lbasize_t *);
-int ub_dev_send(int, void *, int);
-int ub_dev_recv(int, void *, int, int *);
-struct device_info *ub_dev_get(int);
-
-void ub_dump_di(int);
-void ub_dump_si(struct sys_info *);
-char *ub_mem_type(int);
-char *ub_stor_type(int);
-
-#endif /* _API_GLUE_H_ */
diff --git a/sys/boot/uboot/lib/libuboot.h b/sys/boot/uboot/lib/libuboot.h
deleted file mode 100644
index e4201d8a1347..000000000000
--- a/sys/boot/uboot/lib/libuboot.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*-
- * Copyright (C) 2000 Benno Rice.
- * Copyright (C) 2007 Semihalf, Rafal Jaworowski <raj@semihalf.com>
- * 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.
- *
- * $FreeBSD$
- */
-
-struct uboot_devdesc
-{
- struct devsw *d_dev;
- int d_type;
- int d_unit;
- void *d_opendata;
- union {
- struct {
- int slice;
- int partition;
- off_t offset;
- } disk;
- } d_kind;
-};
-
-#define d_disk d_kind.disk
-
-/*
- * Default network packet alignment in memory
- */
-#define PKTALIGN 32
-
-int uboot_getdev(void **vdev, const char *devspec, const char **path);
-char *uboot_fmtdev(void *vdev);
-int uboot_setcurrdev(struct env_var *ev, int flags, const void *value);
-
-extern int devs_no;
-extern struct netif_driver uboot_net;
-extern struct devsw uboot_storage;
-
-extern uintptr_t uboot_heap_start;
-extern uintptr_t uboot_heap_end;
-
-uint64_t uboot_loadaddr(u_int type, void *data, uint64_t addr);
-ssize_t uboot_copyin(const void *src, vm_offset_t dest, const size_t len);
-ssize_t uboot_copyout(const vm_offset_t src, void *dest, const size_t len);
-ssize_t uboot_readin(const int fd, vm_offset_t dest, const size_t len);
-extern int uboot_autoload(void);
-
-struct preloaded_file;
-struct file_format;
-
-extern struct file_format uboot_elf;
-
-void reboot(void);
-
-int uboot_diskgetunit(int type, int type_unit);
-
diff --git a/sys/boot/uboot/lib/module.c b/sys/boot/uboot/lib/module.c
deleted file mode 100644
index 0951ed6618e4..000000000000
--- a/sys/boot/uboot/lib/module.c
+++ /dev/null
@@ -1,57 +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$");
-
-/*
- * U-Boot-specific module functionality.
- */
-
-#include <stand.h>
-#include <string.h>
-
-#if defined(LOADER_FDT_SUPPORT)
-#include <fdt_platform.h>
-#endif
-
-#include "bootstrap.h"
-#include "libuboot.h"
-
-int
-uboot_autoload(void)
-{
-#if defined(LOADER_FDT_SUPPORT)
- int err;
-
- if ((err = fdt_setup_fdtp()) != 0) {
- printf("No valid device tree blob found!\n");
- return (err);
- }
-#endif
-
- return(0);
-}
diff --git a/sys/boot/uboot/lib/net.c b/sys/boot/uboot/lib/net.c
deleted file mode 100644
index a0d1cb4f4583..000000000000
--- a/sys/boot/uboot/lib/net.c
+++ /dev/null
@@ -1,364 +0,0 @@
-/*-
- * Copyright (c) 2000-2001 Benno Rice
- * Copyright (c) 2007 Semihalf, Rafal Jaworowski <raj@semihalf.com>
- * 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/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 "api_public.h"
-#include "glue.h"
-#include "libuboot.h"
-#include "dev_net.h"
-
-static int net_probe(struct netif *, void *);
-static int net_match(struct netif *, void *);
-static void net_init(struct iodesc *, void *);
-static ssize_t net_get(struct iodesc *, void **, time_t);
-static ssize_t net_put(struct iodesc *, void *, size_t);
-static void net_end(struct netif *);
-
-extern struct netif_stats net_stats[];
-
-struct netif_dif net_ifs[] = {
- /* dif_unit dif_nsel dif_stats dif_private */
- { 0, 1, &net_stats[0], 0, },
-};
-
-struct netif_stats net_stats[nitems(net_ifs)];
-
-struct netif_driver uboot_net = {
- "uboot_eth", /* netif_bname */
- net_match, /* netif_match */
- net_probe, /* netif_probe */
- net_init, /* netif_init */
- net_get, /* netif_get */
- net_put, /* netif_put */
- net_end, /* netif_end */
- net_ifs, /* netif_ifs */
- nitems(net_ifs) /* netif_nifs */
-};
-
-struct uboot_softc {
- uint32_t sc_pad;
- uint8_t sc_rxbuf[ETHER_MAX_LEN];
- uint8_t sc_txbuf[ETHER_MAX_LEN + PKTALIGN];
- uint8_t *sc_txbufp;
- int sc_handle; /* device handle for ub_dev_xxx */
-};
-
-static struct uboot_softc uboot_softc;
-
-/*
- * get_env_net_params()
- *
- * Attempt to obtain all the parms we need for netbooting from the U-Boot
- * environment. If we fail to obtain the values it may still be possible to
- * netboot; the net_dev code will attempt to get the values from bootp, rarp,
- * and other such sources.
- *
- * If rootip.s_addr is non-zero net_dev assumes the required global variables
- * are set and skips the bootp inquiry. For that reason, we don't set rootip
- * until we've verified that we have at least the minimum required info.
- *
- * This is called from netif_init() which can result in it getting called
- * multiple times, by design. The network code at higher layers zeroes out
- * rootip when it closes a network interface, so if it gets opened again we have
- * to obtain all this info again.
- */
-static void
-get_env_net_params()
-{
- char *envstr;
- in_addr_t rootaddr, serveraddr;
-
- /*
- * Silently get out right away if we don't have rootpath, because none
- * of the other info we obtain below is sufficient to boot without it.
- *
- * If we do have rootpath, copy it into the global var and also set
- * dhcp.root-path in the env. If we don't get all the other info from
- * the u-boot env below, we will still try dhcp/bootp, but the server-
- * provided path will not replace the user-provided value we set here.
- */
- if ((envstr = ub_env_get("rootpath")) == NULL)
- return;
- strlcpy(rootpath, envstr, sizeof(rootpath));
- setenv("dhcp.root-path", rootpath, 0);
-
- /*
- * Our own IP address must be valid. Silently get out if it's not set,
- * but whine if it's there and we can't parse it.
- */
- if ((envstr = ub_env_get("ipaddr")) == NULL)
- return;
- if ((myip.s_addr = inet_addr(envstr)) == INADDR_NONE) {
- printf("Could not parse ipaddr '%s'\n", envstr);
- return;
- }
-
- /*
- * Netmask is optional, default to the "natural" netmask for our IP, but
- * whine if it was provided and we couldn't parse it.
- */
- if ((envstr = ub_env_get("netmask")) != NULL &&
- (netmask = inet_addr(envstr)) == INADDR_NONE) {
- printf("Could not parse netmask '%s'\n", envstr);
- }
- if (netmask == INADDR_NONE) {
- if (IN_CLASSA(myip.s_addr))
- netmask = IN_CLASSA_NET;
- else if (IN_CLASSB(myip.s_addr))
- netmask = IN_CLASSB_NET;
- else
- netmask = IN_CLASSC_NET;
- }
-
- /*
- * Get optional serverip before rootpath; the latter can override it.
- * Whine only if it's present but can't be parsed.
- */
- serveraddr = INADDR_NONE;
- if ((envstr = ub_env_get("serverip")) != NULL) {
- if ((serveraddr = inet_addr(envstr)) == INADDR_NONE)
- printf("Could not parse serverip '%s'\n", envstr);
- }
-
- /*
- * There must be a rootpath. It may be ip:/path or it may be just the
- * path in which case the ip needs to be in serverip.
- */
- rootaddr = net_parse_rootpath();
- if (rootaddr == INADDR_NONE)
- rootaddr = serveraddr;
- if (rootaddr == INADDR_NONE) {
- printf("No server address for rootpath '%s'\n", envstr);
- return;
- }
- rootip.s_addr = rootaddr;
-
- /*
- * Gateway IP is optional unless rootip is on a different net in which
- * case whine if it's missing or we can't parse it, and set rootip addr
- * to zero, which signals to other network code that network params
- * aren't set (so it will try dhcp, bootp, etc).
- */
- envstr = ub_env_get("gatewayip");
- if (!SAMENET(myip, rootip, netmask)) {
- if (envstr == NULL) {
- printf("Need gatewayip for a root server on a "
- "different network.\n");
- rootip.s_addr = 0;
- return;
- }
- if ((gateip.s_addr = inet_addr(envstr) == INADDR_NONE)) {
- printf("Could not parse gatewayip '%s'\n", envstr);
- rootip.s_addr = 0;
- return;
- }
- }
-}
-
-static int
-net_match(struct netif *nif, void *machdep_hint)
-{
- char **a = (char **)machdep_hint;
-
- if (memcmp("net", *a, 3) == 0)
- return (1);
-
- printf("net_match: could not match network device\n");
- return (0);
-}
-
-static int
-net_probe(struct netif *nif, void *machdep_hint)
-{
- struct device_info *di;
- int i;
-
- for (i = 0; i < devs_no; i++)
- if ((di = ub_dev_get(i)) != NULL)
- if (di->type == DEV_TYP_NET)
- break;
-
- if (i == devs_no) {
- printf("net_probe: no network devices found, maybe not"
- " enumerated yet..?\n");
- return (-1);
- }
-
-#if defined(NETIF_DEBUG)
- printf("net_probe: network device found: %d\n", i);
-#endif
- uboot_softc.sc_handle = i;
-
- return (0);
-}
-
-static ssize_t
-net_put(struct iodesc *desc, void *pkt, size_t len)
-{
- struct netif *nif = desc->io_netif;
- struct uboot_softc *sc = nif->nif_devdata;
- size_t sendlen;
- ssize_t rv;
-
-#if defined(NETIF_DEBUG)
- struct ether_header *eh;
-
- printf("net_put: desc %p, pkt %p, 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
-
- if (len < ETHER_MIN_LEN - ETHER_CRC_LEN) {
- sendlen = ETHER_MIN_LEN - ETHER_CRC_LEN;
- bzero(sc->sc_txbufp, sendlen);
- } else
- sendlen = len;
-
- memcpy(sc->sc_txbufp, pkt, len);
-
- rv = ub_dev_send(sc->sc_handle, sc->sc_txbufp, sendlen);
-
-#if defined(NETIF_DEBUG)
- printf("net_put: ub_send returned %d\n", rv);
-#endif
- if (rv == 0)
- rv = len;
- else
- rv = -1;
-
- return (rv);
-}
-
-static ssize_t
-net_get(struct iodesc *desc, void **pkt, time_t timeout)
-{
- struct netif *nif = desc->io_netif;
- struct uboot_softc *sc = nif->nif_devdata;
- time_t t;
- int err, rlen;
- size_t len;
- char *buf;
-
-#if defined(NETIF_DEBUG)
- printf("net_get: pkt %p, timeout %d\n", pkt, timeout);
-#endif
- t = getsecs();
- len = sizeof(sc->sc_rxbuf);
- do {
- err = ub_dev_recv(sc->sc_handle, sc->sc_rxbuf, len, &rlen);
-
- if (err != 0) {
- printf("net_get: ub_dev_recv() failed, error=%d\n",
- err);
- rlen = 0;
- break;
- }
- } while ((rlen == -1 || rlen == 0) && (getsecs() - t < timeout));
-
-#if defined(NETIF_DEBUG)
- printf("net_get: received len %d (%x)\n", rlen, rlen);
-#endif
-
- if (rlen > 0) {
- buf = malloc(rlen + ETHER_ALIGN);
- if (buf == NULL)
- return (-1);
- memcpy(buf + ETHER_ALIGN, sc->sc_rxbuf, rlen);
- *pkt = buf;
- return ((ssize_t)rlen);
- }
-
- return (-1);
-}
-
-static void
-net_init(struct iodesc *desc, void *machdep_hint)
-{
- struct netif *nif = desc->io_netif;
- struct uboot_softc *sc;
- struct device_info *di;
- int err;
-
- sc = nif->nif_devdata = &uboot_softc;
-
- if ((err = ub_dev_open(sc->sc_handle)) != 0)
- panic("%s%d: initialisation failed with error %d\n",
- nif->nif_driver->netif_bname, nif->nif_unit, err);
-
- /* Get MAC address */
- di = ub_dev_get(sc->sc_handle);
- memcpy(desc->myea, di->di_net.hwaddr, 6);
- if (memcmp (desc->myea, "\0\0\0\0\0\0", 6) == 0) {
- panic("%s%d: empty ethernet address!",
- nif->nif_driver->netif_bname, nif->nif_unit);
- }
-
- /* Attempt to get netboot params from the u-boot env. */
- get_env_net_params();
- if (myip.s_addr != 0)
- desc->myip = myip;
-
-#if defined(NETIF_DEBUG)
- printf("network: %s%d attached to %s\n", nif->nif_driver->netif_bname,
- nif->nif_unit, ether_sprintf(desc->myea));
-#endif
-
- /* Set correct alignment for TX packets */
- sc->sc_txbufp = sc->sc_txbuf;
- if ((unsigned long)sc->sc_txbufp % PKTALIGN)
- sc->sc_txbufp += PKTALIGN -
- (unsigned long)sc->sc_txbufp % PKTALIGN;
-}
-
-static void
-net_end(struct netif *nif)
-{
- struct uboot_softc *sc = nif->nif_devdata;
- int err;
-
- if ((err = ub_dev_close(sc->sc_handle)) != 0)
- panic("%s%d: net_end failed with error %d\n",
- nif->nif_driver->netif_bname, nif->nif_unit, err);
-}
diff --git a/sys/boot/uboot/lib/reboot.c b/sys/boot/uboot/lib/reboot.c
deleted file mode 100644
index 9f4d277eb6f9..000000000000
--- a/sys/boot/uboot/lib/reboot.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*-
- * Copyright (c) 2007 Semihalf, Rafal Jaworowski <raj@semihalf.com>
- * 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 "glue.h"
-
-void
-exit(int code)
-{
-
- ub_reset();
-}
diff --git a/sys/boot/uboot/lib/time.c b/sys/boot/uboot/lib/time.c
deleted file mode 100644
index a3c73f471a25..000000000000
--- a/sys/boot/uboot/lib/time.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * Copyright (c) 2000 Benno Rice
- * Copyright (c) 2007 Semihalf, Rafal Jaworowski <raj@semihalf.com>
- * 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 "glue.h"
-
-/*
- * Return the time in seconds since the beginning of the day.
- */
-time_t
-time(time_t *tloc)
-{
- int secs;
-
- secs = ub_get_timer(0) / 1000;
- if (tloc)
- *tloc = secs;
-
- return (secs);
-}
-
-time_t
-getsecs(void)
-{
-
- return (time(NULL));
-}
-
-/*
- * Use U-Boot udelay() function to wait for a given microseconds period
- */
-void
-delay(int usecs)
-{
-
- ub_udelay(usecs);
-}