netboot support
This commit is contained in:
parent
785984d9e4
commit
8f53455cfb
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.3 2003/07/26 18:33:51 mrg Exp $
|
||||
# $NetBSD: Makefile,v 1.4 2003/08/09 08:01:42 igy Exp $
|
||||
.include <bsd.own.mk>
|
||||
|
||||
ROMICE?= no
|
||||
@ -9,9 +9,11 @@ PROG= lcboot.out
|
||||
SREC= lcboot.srec
|
||||
MKMAN= no
|
||||
WARNS= 1
|
||||
SRCS= start.S main.c com.c conf.c dev_flash.c devopen.c i28f128.c
|
||||
SRCS= start.S main.c com.c conf.c dev_flash.c dev_net.c \
|
||||
devopen.c i28f128.c if_cs.c
|
||||
|
||||
CPPFLAGS+= -DDEBUG
|
||||
#CPPFLAGS+= -DDEBUG -DNET_DEBUG -DNETIF_DEBUG -DARP_DEBUG \
|
||||
# -DETHER_DEBUG -DBOOTP_DEBUG
|
||||
|
||||
STARTOBJS=
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/* $NetBSD: conf.c,v 1.1 2003/06/24 12:27:03 igy Exp $ */
|
||||
/* $NetBSD: conf.c,v 1.2 2003/08/09 08:01:43 igy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 2003 Naoto Shimazaki.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Naoto Shimazaki.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@ -15,30 +12,26 @@
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* THIS SOFTWARE IS PROVIDED BY NAOTO SHIMAZAKI 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 NAOTO 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.
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: conf.c,v 1.1 2003/06/24 12:27:03 igy Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: conf.c,v 1.2 2003/08/09 08:01:43 igy Exp $");
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <lib/libsa/stand.h>
|
||||
#include <lib/libsa/netif.h>
|
||||
#include <lib/libsa/tftp.h>
|
||||
|
||||
#include "extern.h"
|
||||
@ -51,8 +44,29 @@ struct devsw devsw[] = {
|
||||
.dv_close = flash_close,
|
||||
.dv_ioctl = flash_ioctl,
|
||||
},
|
||||
{
|
||||
.dv_name = "net",
|
||||
.dv_strategy = net_strategy,
|
||||
.dv_open = net_open,
|
||||
.dv_close = net_close,
|
||||
.dv_ioctl = net_ioctl,
|
||||
},
|
||||
};
|
||||
int ndevs = sizeof devsw / sizeof devsw[0];
|
||||
|
||||
struct fs_ops file_system[1];
|
||||
int nfsys = 0;
|
||||
struct fs_ops file_system[] = {
|
||||
{
|
||||
.open = tftp_open,
|
||||
.close = tftp_close,
|
||||
.read = tftp_read,
|
||||
.write = tftp_write,
|
||||
.seek = tftp_seek,
|
||||
.stat = tftp_stat,
|
||||
}
|
||||
};
|
||||
int nfsys = sizeof file_system / sizeof file_system[0];
|
||||
|
||||
struct netif_driver *netif_drivers[] = {
|
||||
&cs_driver,
|
||||
};
|
||||
int n_netif_drivers = sizeof netif_drivers / sizeof netif_drivers[0];
|
||||
|
@ -1,12 +1,9 @@
|
||||
/* $NetBSD: dev_flash.c,v 1.1 2003/06/24 12:27:03 igy Exp $ */
|
||||
/* $NetBSD: dev_flash.c,v 1.2 2003/08/09 08:01:43 igy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 2003 Naoto Shimazaki.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Naoto Shimazaki.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@ -15,31 +12,25 @@
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* THIS SOFTWARE IS PROVIDED BY NAOTO SHIMAZAKI 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 NAOTO 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.
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: dev_flash.c,v 1.1 2003/06/24 12:27:03 igy Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: dev_flash.c,v 1.2 2003/08/09 08:01:43 igy Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <lib/libsa/stand.h>
|
||||
#include <machine/stdarg.h>
|
||||
|
||||
#include "extern.h"
|
||||
|
||||
@ -65,6 +56,17 @@ flash_strategy(void *devdata, int rw, daddr_t blk,
|
||||
int
|
||||
flash_open(struct open_file *f, ...)
|
||||
{
|
||||
char *fname;
|
||||
char **file;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, f);
|
||||
fname = va_arg(ap, char *);
|
||||
file = va_arg(ap, char **);
|
||||
va_end(ap);
|
||||
|
||||
*file = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,141 +0,0 @@
|
||||
/* $NetBSD: dev_lc.c,v 1.1 2003/05/01 07:02:01 igy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Naoto Shimazaki of YOKOGAWA Electric Corporation.
|
||||
*
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pseudo device and filesystem operation for L-Card+ boot loader
|
||||
*/
|
||||
|
||||
#include <lib/libsa/stand.h>
|
||||
|
||||
#include "extern.h"
|
||||
|
||||
struct dev_lc {
|
||||
u_int8_t *lc_addr;
|
||||
} lc_ca;
|
||||
|
||||
int
|
||||
devopen(struct open_file *f, const char *fname, char **file)
|
||||
{
|
||||
*file = (char *) fname;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
lc_open (char *path, struct open_file *f)
|
||||
{
|
||||
static int cnt = 0;
|
||||
|
||||
if (cnt) {
|
||||
printf("lc_open called multitime\n");
|
||||
panic("nnnnnnnnnn");
|
||||
}
|
||||
cnt++;
|
||||
|
||||
f->f_devdata = (void *) KERN_ROMBASE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
lc_close(struct open_file *f)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
ssize_t
|
||||
lc_read (struct open_file *f, void *buf, size_t size, size_t *resid)
|
||||
{
|
||||
#define READ_CHUNK 0x10000
|
||||
u_int8_t *addr = f->f_devdata;
|
||||
|
||||
while (size >= READ_CHUNK) {
|
||||
twiddle();
|
||||
bcopy(addr, buf, READ_CHUNK);
|
||||
addr += READ_CHUNK;
|
||||
buf = READ_CHUNK + (u_int8_t *) buf;
|
||||
size -= READ_CHUNK;
|
||||
}
|
||||
twiddle();
|
||||
bcopy(addr, buf, size);
|
||||
f->f_devdata = addr + size;
|
||||
*resid = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
off_t
|
||||
lc_seek (struct open_file *f, off_t offset, int where)
|
||||
{
|
||||
switch (where) {
|
||||
case SEEK_SET:
|
||||
f->f_devdata = offset + (u_int8_t *) KERN_ROMBASE;
|
||||
return 0;
|
||||
|
||||
case SEEK_CUR:
|
||||
f->f_devdata = offset + (u_int8_t *) f->f_devdata;
|
||||
return 0;
|
||||
|
||||
case SEEK_END:
|
||||
default:
|
||||
}
|
||||
errno = EIO;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
lcdevstrategy(devdata, rw, blk, size, buf, rsize)
|
||||
void *devdata;
|
||||
int rw;
|
||||
daddr_t blk;
|
||||
size_t size;
|
||||
void *buf;
|
||||
size_t *rsize;
|
||||
{
|
||||
return EIO;
|
||||
}
|
||||
|
||||
int
|
||||
lcdevclose(struct open_file *f)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
_rtt(void)
|
||||
{
|
||||
for (;;)
|
||||
;
|
||||
}
|
105
sys/arch/hpcmips/stand/lcboot/dev_net.c
Normal file
105
sys/arch/hpcmips/stand/lcboot/dev_net.c
Normal file
@ -0,0 +1,105 @@
|
||||
/* $NetBSD: dev_net.c,v 1.1 2003/08/09 08:01:45 igy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 Naoto Shimazaki.
|
||||
* 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 NAOTO SHIMAZAKI 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 NAOTO 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>
|
||||
__KERNEL_RCSID(0, "$NetBSD: dev_net.c,v 1.1 2003/08/09 08:01:45 igy Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <lib/libsa/stand.h>
|
||||
#include <lib/libkern/libkern.h>
|
||||
#include <machine/stdarg.h>
|
||||
|
||||
#include "extern.h"
|
||||
|
||||
extern struct in_addr servip;
|
||||
|
||||
static int netdev_sock = -1;
|
||||
|
||||
int
|
||||
net_strategy(void *devdata, int rw, daddr_t blk,
|
||||
size_t size, void *buf , size_t *rsize)
|
||||
{
|
||||
return EIO;
|
||||
}
|
||||
|
||||
int
|
||||
net_open(struct open_file *f, ...)
|
||||
{
|
||||
char *fname;
|
||||
char **file;
|
||||
struct iodesc *s;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, f);
|
||||
fname = va_arg(ap, char *);
|
||||
file = va_arg(ap, char **);
|
||||
va_end(ap);
|
||||
|
||||
f->f_devdata = &netdev_sock;
|
||||
netdev_sock = netif_open(NULL);
|
||||
|
||||
bootfile[0] = '\0';
|
||||
if (bootopts.b_flags & B_F_USE_BOOTP) {
|
||||
printf("bootp is not yet supported\n");
|
||||
netif_close(netdev_sock);
|
||||
return EIO;
|
||||
} else {
|
||||
s = socktodesc(netdev_sock);
|
||||
|
||||
servip = s->destip = bootopts.b_remote_ip;
|
||||
myip = s->myip = bootopts.b_local_ip;
|
||||
netmask = bootopts.b_netmask;
|
||||
gateip = bootopts.b_gate_ip;
|
||||
|
||||
if (fname[0] == '\0') {
|
||||
printf("no boot filename\n");
|
||||
netif_close(netdev_sock);
|
||||
return EIO;
|
||||
}
|
||||
strlcpy(bootfile, fname, sizeof bootfile);
|
||||
*file = fname;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
net_close(struct open_file *f)
|
||||
{
|
||||
int sock;
|
||||
|
||||
sock = *((int *) f->f_devdata);
|
||||
netif_close(sock);
|
||||
f->f_devdata = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
net_ioctl(struct open_file *f, u_long cmd, void *data)
|
||||
{
|
||||
return EIO;
|
||||
}
|
@ -1,12 +1,9 @@
|
||||
/* $NetBSD: devopen.c,v 1.1 2003/06/24 12:27:03 igy Exp $ */
|
||||
/* $NetBSD: devopen.c,v 1.2 2003/08/09 08:01:46 igy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 2003 Naoto Shimazaki.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Naoto Shimazaki.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@ -15,38 +12,61 @@
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* THIS SOFTWARE IS PROVIDED BY NAOTO SHIMAZAKI 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 NAOTO 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.
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: devopen.c,v 1.1 2003/06/24 12:27:03 igy Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: devopen.c,v 1.2 2003/08/09 08:01:46 igy Exp $");
|
||||
|
||||
#include <lib/libsa/stand.h>
|
||||
#include <lib/libkern/libkern.h>
|
||||
|
||||
#include "extern.h"
|
||||
|
||||
int
|
||||
devopen(struct open_file *f, const char *fname, char **file)
|
||||
{
|
||||
*file = NULL;
|
||||
nfsys = 0;
|
||||
f->f_dev = &devsw[0];
|
||||
return 0;
|
||||
int i;
|
||||
char devname[IFNAME_SIZE];
|
||||
const char *basename;
|
||||
|
||||
for (i = 0; i < IFNAME_SIZE; i++) {
|
||||
if (fname[i] == '\0') {
|
||||
devname[i] = '\0';
|
||||
basename = &fname[i];
|
||||
break;
|
||||
}
|
||||
if (fname[i] == ':') {
|
||||
devname[i] = '\0';
|
||||
basename = &fname[i + 1];
|
||||
break;
|
||||
}
|
||||
devname[i] = fname[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < ndevs; i++) {
|
||||
if (strcmp(devname, devsw[i].dv_name) == 0) {
|
||||
f->f_dev = &devsw[i];
|
||||
return DEV_OPEN(f->f_dev)(f, basename, file);
|
||||
}
|
||||
}
|
||||
|
||||
printf("No such device - Configured devices are:\n");
|
||||
for (i = 0; i < ndevs; i++) {
|
||||
if (devsw[i].dv_name)
|
||||
printf(" %s", devsw[i].dv_name);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
return ENODEV;
|
||||
}
|
||||
|
@ -1,12 +1,9 @@
|
||||
/* $NetBSD: extern.h,v 1.2 2003/06/24 12:27:04 igy Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.3 2003/08/09 08:01:47 igy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 2003 Naoto Shimazaki.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Naoto Shimazaki of YOKOGAWA Electric Corporation.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@ -15,29 +12,29 @@
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* THIS SOFTWARE IS PROVIDED BY NAOTO SHIMAZAKI 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 NAOTO 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.
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _LOCORE
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
|
||||
#include <lib/libsa/net.h>
|
||||
#include <lib/libsa/netif.h>
|
||||
|
||||
#include <mips/cpuregs.h>
|
||||
|
||||
#include <dev/ic/comreg.h>
|
||||
@ -50,9 +47,28 @@ struct bootmenu_command {
|
||||
void (*c_fn)(char*);
|
||||
};
|
||||
|
||||
#define BOOTOPT_MAGIC 0x4c43424fU /* LCBO */
|
||||
#define B_F_USE_BOOTP 0x00000001
|
||||
|
||||
struct boot_option {
|
||||
u_int32_t b_magic;
|
||||
u_int32_t b_flags;
|
||||
struct in_addr b_remote_ip;
|
||||
struct in_addr b_local_ip;
|
||||
struct in_addr b_gate_ip;
|
||||
u_long b_netmask;
|
||||
char b_pathname[FNAME_SIZE];
|
||||
};
|
||||
|
||||
#define ROMCS0_BASE 0xbe000000U
|
||||
#define ROMCS3_BASE 0xbf800000U
|
||||
#define FLASH_BASE ROMCS0_BASE
|
||||
#define BOOTOPTS_BASE 0xbfd20000U
|
||||
|
||||
/* ElapsedTime registers */
|
||||
#define VRETIMEL 0x0b0000c0
|
||||
#define VRETIMEM 0x0b0000c2
|
||||
#define VRETIMEH 0x0b0000c4
|
||||
|
||||
#ifdef ROMICE
|
||||
#define KERN_ROMBASE 0x80800000U
|
||||
@ -95,6 +111,9 @@ typedef void *bus_space_tag_t;
|
||||
typedef u_int32_t bus_space_handle_t;
|
||||
typedef size_t bus_size_t;
|
||||
|
||||
extern struct netif_driver cs_driver;
|
||||
extern struct boot_option bootopts;
|
||||
|
||||
void comcninit(void);
|
||||
int iskey(void);
|
||||
void start_netbsd(void);
|
||||
@ -107,6 +126,12 @@ int flash_open(struct open_file *, ...);
|
||||
int flash_close(struct open_file *);
|
||||
int flash_ioctl(struct open_file *, u_long, void *);
|
||||
|
||||
/* dev_net */
|
||||
int net_strategy(void *, int, daddr_t, size_t, void *, size_t *);
|
||||
int net_open(struct open_file *, ...);
|
||||
int net_close(struct open_file *);
|
||||
int net_ioctl(struct open_file *, u_long, void *);
|
||||
|
||||
#endif /* !_LOCORE */
|
||||
|
||||
#define LCBOOT_STARTADDR 0x80001000
|
||||
|
@ -1,12 +1,9 @@
|
||||
/* $NetBSD: i28f128.c,v 1.2 2003/06/15 08:50:05 igy Exp $ */
|
||||
/* $NetBSD: i28f128.c,v 1.3 2003/08/09 08:01:47 igy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 2003 Naoto Shimazaki.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Naoto Shimazaki of YOKOGAWA Electric Corporation.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@ -15,30 +12,25 @@
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* THIS SOFTWARE IS PROVIDED BY NAOTO SHIMAZAKI 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 NAOTO 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.
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Flash Memory Writer
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: i28f128.c,v 1.3 2003/08/09 08:01:47 igy Exp $");
|
||||
|
||||
#include <lib/libsa/stand.h>
|
||||
|
||||
|
@ -1,12 +1,9 @@
|
||||
/* $NetBSD: i28f128reg.h,v 1.2 2003/06/15 08:50:06 igy Exp $ */
|
||||
/* $NetBSD: i28f128reg.h,v 1.3 2003/08/09 08:01:47 igy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 2003 Naoto Shimazaki.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Naoto Shimazaki of YOKOGAWA Electric Corporation.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@ -15,25 +12,18 @@
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* THIS SOFTWARE IS PROVIDED BY NAOTO SHIMAZAKI 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 NAOTO 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.
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
232
sys/arch/hpcmips/stand/lcboot/if_cs.c
Normal file
232
sys/arch/hpcmips/stand/lcboot/if_cs.c
Normal file
@ -0,0 +1,232 @@
|
||||
/* $NetBSD: if_cs.c,v 1.1 2003/08/09 08:01:48 igy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 Naoto Shimazaki.
|
||||
* 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 NAOTO SHIMAZAKI 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 NAOTO 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>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_cs.c,v 1.1 2003/08/09 08:01:48 igy Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <lib/libsa/stand.h>
|
||||
#include <lib/libsa/netif.h>
|
||||
|
||||
#include <dev/ic/cs89x0reg.h>
|
||||
|
||||
#include "extern.h"
|
||||
|
||||
static int cs_match(struct netif *, void *);
|
||||
static int cs_probe(struct netif *, void *);
|
||||
static void cs_init(struct iodesc *, void *);
|
||||
static int cs_get(struct iodesc *, void *, size_t, time_t);
|
||||
static int cs_put(struct iodesc *, void *, size_t);
|
||||
static void cs_end(struct netif *);
|
||||
|
||||
static struct netif_stats cs_stats;
|
||||
|
||||
static struct netif_dif cs_if = {
|
||||
.dif_unit = 0,
|
||||
.dif_nsel = 1,
|
||||
.dif_stats = &cs_stats,
|
||||
.dif_private = NULL,
|
||||
.dif_used = 0,
|
||||
};
|
||||
|
||||
struct netif_driver cs_driver = {
|
||||
.netif_bname = "cs",
|
||||
.netif_match = cs_match,
|
||||
.netif_probe = cs_probe,
|
||||
.netif_init = cs_init,
|
||||
.netif_get = cs_get,
|
||||
.netif_put = cs_put,
|
||||
.netif_end = cs_end,
|
||||
.netif_ifs = &cs_if,
|
||||
.netif_nifs = 1,
|
||||
};
|
||||
|
||||
#define CS_IO_BASE 0x14010300U
|
||||
|
||||
#define CS_READ_1(off) REGREAD_1(CS_IO_BASE, (off))
|
||||
#define CS_READ_2(off) REGREAD_2(CS_IO_BASE, (off))
|
||||
#define CS_WRITE_1(off, val) REGWRITE_1(CS_IO_BASE, (off), (val))
|
||||
#define CS_WRITE_2(off, val) REGWRITE_2(CS_IO_BASE, (off), (val))
|
||||
#define CS_READ_PACKET_PAGE(off) \
|
||||
(REGWRITE_2(CS_IO_BASE, PORT_PKTPG_PTR, (off)), \
|
||||
REGREAD_2(CS_IO_BASE, PORT_PKTPG_DATA))
|
||||
#define CS_WRITE_PACKET_PAGE(off, val) \
|
||||
(REGWRITE_2(CS_IO_BASE, PORT_PKTPG_PTR, (off)), \
|
||||
REGWRITE_2(CS_IO_BASE, PORT_PKTPG_DATA, (val)))
|
||||
|
||||
static inline void
|
||||
delay(int n)
|
||||
{
|
||||
int i = 33 * n;
|
||||
|
||||
while (--i > 0)
|
||||
;
|
||||
}
|
||||
|
||||
time_t
|
||||
getsecs(void)
|
||||
{
|
||||
return REGREAD_4(VRETIMEL, 0) >> 15;
|
||||
}
|
||||
|
||||
static int
|
||||
cs_match(struct netif *nif, void *machdep_hint)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
cs_probe(struct netif *nif, void *machdep_hint)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
cs_init(struct iodesc *desc, void *machdep_hint)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Issue a software reset command to the chip */
|
||||
CS_WRITE_PACKET_PAGE(PKTPG_SELF_CTL, SELF_CTL_RESET);
|
||||
|
||||
/* We cannot touch the chip until calibration is done */
|
||||
delay(10000);
|
||||
|
||||
/*
|
||||
* Transition -SBHE H->L L->H is needed between reset and
|
||||
* the first access to the chip's register.
|
||||
*/
|
||||
CS_READ_1(PORT_PKTPG_PTR + 0);
|
||||
CS_READ_1(PORT_PKTPG_PTR + 1);
|
||||
CS_READ_1(PORT_PKTPG_PTR + 0);
|
||||
CS_READ_1(PORT_PKTPG_PTR + 1);
|
||||
|
||||
/* wait for INIT_DONE */
|
||||
for (i = 10000; i > 0; i--) {
|
||||
u_int16_t s;
|
||||
|
||||
s = CS_READ_PACKET_PAGE(PKTPG_SELF_ST);
|
||||
if ((s & SELF_ST_INIT_DONE) && !(s & SELF_ST_SI_BUSY))
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
panic("cannot reset netif");
|
||||
|
||||
for (i = 0; i < 6; i += 2) {
|
||||
u_int16_t ea;
|
||||
|
||||
ea = CS_READ_PACKET_PAGE(PKTPG_IND_ADDR + i);
|
||||
|
||||
/* assuming little endian */
|
||||
desc->myea[i + 0] = (ea >> 0) & 0xff;
|
||||
desc->myea[i + 1] = (ea >> 8) & 0xff;
|
||||
}
|
||||
|
||||
/*
|
||||
* Accepting frames:
|
||||
* RX_CTL_RX_OK_A: correct crc, and valid length
|
||||
* RX_CTL_IND_A: dest addr maches individual address
|
||||
* RX_CTL_BCAST_A: dest addr maches broadcast address
|
||||
*/
|
||||
CS_WRITE_PACKET_PAGE(PKTPG_RX_CTL,
|
||||
RX_CTL_RX_OK_A | RX_CTL_IND_A | RX_CTL_BCAST_A);
|
||||
CS_WRITE_PACKET_PAGE(PKTPG_LINE_CTL, LINE_CTL_RX_ON | LINE_CTL_TX_ON);
|
||||
}
|
||||
|
||||
static int
|
||||
cs_get(struct iodesc *desc, void *pkt, size_t len, time_t timeout)
|
||||
{
|
||||
time_t t;
|
||||
int rlen;
|
||||
int i;
|
||||
u_int16_t *p;
|
||||
|
||||
t = getsecs();
|
||||
rlen = 0;
|
||||
while (getsecs() - t < timeout && rlen == 0) {
|
||||
if (!(CS_READ_PACKET_PAGE(PKTPG_RX_EVENT) & RX_EVENT_RX_OK))
|
||||
continue;
|
||||
|
||||
/* drop status */
|
||||
CS_READ_2(PORT_RXTX_DATA);
|
||||
|
||||
/* get frame length */
|
||||
rlen = CS_READ_2(PORT_RXTX_DATA);
|
||||
|
||||
if (rlen > len) {
|
||||
CS_WRITE_PACKET_PAGE(PKTPG_RX_CFG, RX_CFG_SKIP);
|
||||
rlen = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
p = pkt;
|
||||
for (i = rlen >> 1; i > 0; i--)
|
||||
*p++ = CS_READ_2(PORT_RXTX_DATA);
|
||||
if (rlen & 1)
|
||||
*((u_int8_t *) p + 1) = CS_READ_1(PORT_RXTX_DATA);
|
||||
|
||||
/* exit while loop */
|
||||
}
|
||||
|
||||
return rlen;
|
||||
}
|
||||
|
||||
static int
|
||||
cs_put(struct iodesc *desc, void *pkt, size_t len)
|
||||
{
|
||||
int timeo;
|
||||
int i;
|
||||
u_int16_t *p;
|
||||
|
||||
CS_WRITE_2(PORT_TX_CMD, TX_CMD_START_ALL);
|
||||
CS_WRITE_2(PORT_TX_LENGTH, len);
|
||||
|
||||
for (timeo = 1000000; timeo > 0; timeo--) {
|
||||
if (CS_READ_PACKET_PAGE(PKTPG_BUS_ST) & BUS_ST_RDY4TXNOW)
|
||||
break;
|
||||
}
|
||||
if (timeo == 0)
|
||||
panic("cs: cannot send frame");
|
||||
|
||||
p = pkt;
|
||||
i = (len + 1) >> 1;
|
||||
while (i > 0) {
|
||||
CS_WRITE_2(PORT_RXTX_DATA, *p++);
|
||||
i--;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static void
|
||||
cs_end(struct netif *nif)
|
||||
{
|
||||
CS_WRITE_PACKET_PAGE(PKTPG_LINE_CTL, 0);
|
||||
}
|
@ -1,12 +1,9 @@
|
||||
/* $NetBSD: main.c,v 1.3 2003/06/24 12:27:04 igy Exp $ */
|
||||
/* $NetBSD: main.c,v 1.4 2003/08/09 08:01:49 igy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 2003 Naoto Shimazaki.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Naoto Shimazaki of YOKOGAWA Electric Corporation.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@ -15,25 +12,18 @@
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* THIS SOFTWARE IS PROVIDED BY NAOTO SHIMAZAKI 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 NAOTO 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.
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -116,8 +106,11 @@
|
||||
*
|
||||
*
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: main.c,v 1.4 2003/08/09 08:01:49 igy Exp $");
|
||||
|
||||
#include <lib/libsa/stand.h>
|
||||
|
||||
#include <lib/libsa/loadfile.h>
|
||||
#include <lib/libkern/libkern.h>
|
||||
|
||||
@ -128,10 +121,6 @@
|
||||
#include "extern.h"
|
||||
#include "i28f128reg.h"
|
||||
|
||||
#define VRETIMEL 0x0b0000c0
|
||||
#define VRETIMEM 0x0b0000c2
|
||||
#define VRETIMEH 0x0b0000c4
|
||||
|
||||
/* XXX */
|
||||
#define ISABRGCTL 0x00
|
||||
#define ISABRGSTS 0x02
|
||||
@ -151,6 +140,16 @@ static void command_boot(char *opt);
|
||||
static void command_load(char *opt);
|
||||
static void command_fill(char *opt);
|
||||
static void command_write(char *opt);
|
||||
static void command_option(char *subcmd);
|
||||
static void opt_subcmd_print(char *opt);
|
||||
static void opt_subcmd_read(char *opt);
|
||||
static void opt_subcmd_write(char *opt);
|
||||
static void opt_subcmd_path(char *opt);
|
||||
static void opt_subcmd_bootp(char *opt);
|
||||
static void opt_subcmd_ip(char *opt);
|
||||
|
||||
|
||||
struct boot_option bootopts;
|
||||
|
||||
static struct bootmenu_command commands[] = {
|
||||
{ "?", command_help },
|
||||
@ -160,6 +159,17 @@ static struct bootmenu_command commands[] = {
|
||||
{ "l", command_load },
|
||||
{ "f", command_fill },
|
||||
{ "w", command_write },
|
||||
{ "o", command_option },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
static struct bootmenu_command opt_subcommands[] = {
|
||||
{ "p", opt_subcmd_print },
|
||||
{ "r", opt_subcmd_read },
|
||||
{ "w", opt_subcmd_write },
|
||||
{ "path", opt_subcmd_path },
|
||||
{ "bootp", opt_subcmd_bootp },
|
||||
{ "ip", opt_subcmd_ip },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
@ -174,23 +184,6 @@ print_banner(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 1
|
||||
void foo(void);
|
||||
void foo(void)
|
||||
{
|
||||
extern int start[];
|
||||
extern int edata[];
|
||||
|
||||
int *p = (int*)0xbfc01000;
|
||||
int *q = start;
|
||||
int *f = edata;
|
||||
|
||||
do {
|
||||
*q++ = *p++;
|
||||
} while (q < f);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
init_devices(void)
|
||||
{
|
||||
@ -414,12 +407,22 @@ static void
|
||||
command_help(char *opt)
|
||||
{
|
||||
printf("commands are:\n"
|
||||
"boot: b\n"
|
||||
"dump: d addr [addr]\n"
|
||||
"fill: f addr addr char\n"
|
||||
"load: l [offset] (with following S-Record)\n"
|
||||
"write: w dst src len\n"
|
||||
"help: h|?\n");
|
||||
"boot:\tb\n"
|
||||
"dump:\td addr [addr]\n"
|
||||
"fill:\tf addr addr char\n"
|
||||
"load:\tl [offset] (with following S-Record)\n"
|
||||
"write:\tw dst src len\n"
|
||||
"option:\to subcommand [params]\n"
|
||||
"help:\th|?\n"
|
||||
"\n"
|
||||
"option subcommands are:\n"
|
||||
"print:\to p\n"
|
||||
"read:\to r\n"
|
||||
"write:\to w\n"
|
||||
"path:\to path pathname\n"
|
||||
"bootp:\to bootp yes|no\n"
|
||||
"ip:\to ip remote local netmask gateway\n"
|
||||
);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -497,8 +500,10 @@ command_boot(char *opt)
|
||||
u_long marks[MARK_MAX];
|
||||
|
||||
marks[MARK_START] = 0;
|
||||
if (loadfile("n", marks, LOAD_KERNEL))
|
||||
panic("loadfile failed");
|
||||
if (loadfile(bootopts.b_pathname, marks, LOAD_KERNEL)) {
|
||||
printf("loadfile failed\n");
|
||||
return;
|
||||
}
|
||||
start_netbsd();
|
||||
/* no return */
|
||||
}
|
||||
@ -671,30 +676,11 @@ command_fill(char *opt)
|
||||
memset(p, c, limit - p);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
command_write(char *opt)
|
||||
check_write_verify_flash(u_int32_t src, u_int32_t dst, size_t len)
|
||||
{
|
||||
char *endptr;
|
||||
u_int32_t src;
|
||||
u_int32_t dst;
|
||||
size_t len;
|
||||
int status;
|
||||
|
||||
dst = strtoul(opt, &endptr, 16);
|
||||
if (opt == endptr)
|
||||
goto out;
|
||||
|
||||
opt = get_next_arg(opt);
|
||||
src = strtoul(opt, &endptr, 16);
|
||||
if (opt == endptr)
|
||||
goto out;
|
||||
|
||||
opt = get_next_arg(opt);
|
||||
len = strtoul(opt, &endptr, 16);
|
||||
if (opt == endptr)
|
||||
goto out;
|
||||
|
||||
if ((dst & I28F128_BLOCK_MASK) != 0) {
|
||||
printf("dst addr must be aligned to block boundary (0x%x)\n",
|
||||
I28F128_BLOCK_SIZE);
|
||||
@ -721,6 +707,31 @@ command_write(char *opt)
|
||||
printf("ok\n");
|
||||
|
||||
printf("writing memory to flash succeeded\n");
|
||||
}
|
||||
|
||||
static void
|
||||
command_write(char *opt)
|
||||
{
|
||||
char *endptr;
|
||||
u_int32_t src;
|
||||
u_int32_t dst;
|
||||
size_t len;
|
||||
|
||||
dst = strtoul(opt, &endptr, 16);
|
||||
if (opt == endptr)
|
||||
goto out;
|
||||
|
||||
opt = get_next_arg(opt);
|
||||
src = strtoul(opt, &endptr, 16);
|
||||
if (opt == endptr)
|
||||
goto out;
|
||||
|
||||
opt = get_next_arg(opt);
|
||||
len = strtoul(opt, &endptr, 16);
|
||||
if (opt == endptr)
|
||||
goto out;
|
||||
|
||||
check_write_verify_flash(src, dst, len);
|
||||
return;
|
||||
|
||||
out:
|
||||
@ -728,6 +739,90 @@ out:
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
command_option(char *subcmd)
|
||||
{
|
||||
char *opt;
|
||||
int i;
|
||||
|
||||
opt = get_next_arg(subcmd);
|
||||
|
||||
/* dispatch subcommand */
|
||||
for (i = 0; opt_subcommands[i].c_name != NULL; i++) {
|
||||
if (strcmp(subcmd, opt_subcommands[i].c_name) == 0) {
|
||||
opt_subcommands[i].c_fn(opt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (opt_subcommands[i].c_name == NULL) {
|
||||
printf("unknown option subcommand\n");
|
||||
command_help(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
opt_subcmd_print(char *opt)
|
||||
{
|
||||
printf("boot options:\n"
|
||||
"magic:\t\t%s\n"
|
||||
"pathname:\t`%s'\n"
|
||||
"bootp:\t\t%s\n",
|
||||
bootopts.b_magic == BOOTOPT_MAGIC ? "ok" : "bad",
|
||||
bootopts.b_pathname,
|
||||
bootopts.b_flags & B_F_USE_BOOTP ? "yes" : "no");
|
||||
printf("remote IP:\t%s\n", inet_ntoa(bootopts.b_remote_ip));
|
||||
printf("local IP:\t%s\n", inet_ntoa(bootopts.b_local_ip));
|
||||
printf("netmask:\t%s\n", intoa(bootopts.b_netmask));
|
||||
printf("gateway IP:\t%s\n", inet_ntoa(bootopts.b_gate_ip));
|
||||
}
|
||||
|
||||
static void
|
||||
opt_subcmd_read(char *opt)
|
||||
{
|
||||
bootopts = *((struct boot_option *) BOOTOPTS_BASE);
|
||||
if (bootopts.b_magic != BOOTOPT_MAGIC)
|
||||
bootopts.b_pathname[0] = '\0';
|
||||
}
|
||||
|
||||
static void
|
||||
opt_subcmd_write(char *opt)
|
||||
{
|
||||
bootopts.b_magic = BOOTOPT_MAGIC;
|
||||
|
||||
check_write_verify_flash((u_int32_t) &bootopts, BOOTOPTS_BASE,
|
||||
sizeof bootopts);
|
||||
}
|
||||
|
||||
static void
|
||||
opt_subcmd_path(char *opt)
|
||||
{
|
||||
strlcpy(bootopts.b_pathname, opt, sizeof bootopts.b_pathname);
|
||||
}
|
||||
|
||||
static void
|
||||
opt_subcmd_bootp(char *opt)
|
||||
{
|
||||
if (strcmp(opt, "yes") == 0) {
|
||||
bootopts.b_flags |= B_F_USE_BOOTP;
|
||||
} else if (strcmp(opt, "no") == 0) {
|
||||
bootopts.b_flags &= ~B_F_USE_BOOTP;
|
||||
} else {
|
||||
bad_param();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
opt_subcmd_ip(char *opt)
|
||||
{
|
||||
bootopts.b_remote_ip.s_addr = inet_addr(opt);
|
||||
opt = get_next_arg(opt);
|
||||
bootopts.b_local_ip.s_addr = inet_addr(opt);
|
||||
opt = get_next_arg(opt);
|
||||
bootopts.b_netmask = inet_addr(opt);
|
||||
opt = get_next_arg(opt);
|
||||
bootopts.b_gate_ip.s_addr = inet_addr(opt);
|
||||
}
|
||||
|
||||
static void
|
||||
bootmenu(void)
|
||||
{
|
||||
@ -811,6 +906,8 @@ main(void)
|
||||
|
||||
comcninit();
|
||||
|
||||
opt_subcmd_read(NULL);
|
||||
|
||||
print_banner();
|
||||
|
||||
c = awaitkey();
|
||||
@ -820,6 +917,11 @@ main(void)
|
||||
}
|
||||
|
||||
command_boot(NULL);
|
||||
/* never reach */
|
||||
/*
|
||||
* command_boot() returns only if it failed to boot.
|
||||
* we enter to boot menu in this case.
|
||||
*/
|
||||
bootmenu();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,12 +1,9 @@
|
||||
/* $NetBSD: start.S,v 1.1 2003/05/01 07:02:02 igy Exp $ */
|
||||
/* $NetBSD: start.S,v 1.2 2003/08/09 08:01:49 igy Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 2003 Naoto Shimazaki.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Naoto Shimazaki of YOKOGAWA Electric Corporation.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
@ -15,25 +12,18 @@
|
||||
* 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 the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* THIS SOFTWARE IS PROVIDED BY NAOTO SHIMAZAKI 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 NAOTO 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.
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user