/*-
* 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
*
* 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.
*/
__FBSDID("$FreeBSD$");
#include <netinet/in_systm.h>
#include <netinet/if_ether.h>
#include <stand.h>
#include <net.h>
#include <netif.h>
#include "api_public.h"
#include "glue.h"
#include "libuboot.h"
#include "dev_net.h"
extern struct netif_stats net_stats[];
/* dif_unit dif_nsel dif_stats dif_private */
{ 0, 1, &net_stats[0], 0, },
};
"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 */
};
struct 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
{
char *envstr;
/*
* 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
* provided path will not replace the user-provided value we set here.
*/
return;
/*
* 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.
*/
return;
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 (netmask == INADDR_NONE) {
else
}
/*
* Get optional serverip before rootpath; the latter can override it.
* Whine only if it's present but can't be parsed.
*/
}
/*
* 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.
*/
if (rootaddr == INADDR_NONE)
if (rootaddr == INADDR_NONE) {
return;
}
/*
* 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).
*/
printf("Need gatewayip for a root server on a "
"different network.\n");
return;
}
return;
}
}
}
static int
{
char **a = (char **)machdep_hint;
return (1);
printf("net_match: could not match network device\n");
return (0);
}
static int
{
int i;
for (i = 0; i < devs_no; i++)
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 int
{
#if defined(NETIF_DEBUG)
#endif
} else
#if defined(NETIF_DEBUG)
#endif
if (rv == 0)
else
rv = -1;
return (rv);
}
static int
{
time_t t;
#if defined(NETIF_DEBUG)
#endif
t = getsecs();
do {
if (err != 0) {
printf("net_get: ub_dev_recv() failed, error=%d\n",
err);
rlen = 0;
break;
}
#if defined(NETIF_DEBUG)
#endif
if (rlen > 0) {
#if defined(NETIF_DEBUG)
#endif
}
return (rlen);
}
return (-1);
}
static void
{
int err;
panic("%s%d: initialisation failed with error %d\n",
/* Get MAC address */
panic("%s%d: empty ethernet address!",
}
/* Attempt to get netboot params from the u-boot env. */
#if defined(NETIF_DEBUG)
#endif
/* Set correct alignment for TX packets */
}
static void
{
int err;
panic("%s%d: net_end failed with error %d\n",
}