diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2004-01-26 19:48:35 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2004-01-26 19:48:35 +0000 |
commit | be164f9138e45f14d40de3c6906c9b6ff8b82da2 (patch) | |
tree | da95224965a7b40775776d08a440970248a6160e /sys/arch/mvme88k/stand | |
parent | b03fe615fd708a39a5cef60d1a03e0b0918544b7 (diff) |
tftp-only netboot code, inspired from mvmeppc, and stripped down; it will
become necessary to boot from unsupported (as far as mvme88k/stand/ is
concerned) network cards, such as the MVME374 and the MVME376.
Not enabled in the build yet, because there are a few issues left, but
it is nonetheless usable...
Diffstat (limited to 'sys/arch/mvme88k/stand')
-rw-r--r-- | sys/arch/mvme88k/stand/Makefile | 7 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/libbug/Makefile | 6 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/libsa/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/tftpboot/Makefile | 41 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/tftpboot/boot.c | 80 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/tftpboot/conf.c | 22 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/tftpboot/netdev.c | 137 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/tftpboot/netdev.h | 6 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/tftpboot/tftpfs.c | 291 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/tftpboot/tftpfs.h | 43 | ||||
-rw-r--r-- | sys/arch/mvme88k/stand/tftpboot/version.c | 8 |
11 files changed, 638 insertions, 7 deletions
diff --git a/sys/arch/mvme88k/stand/Makefile b/sys/arch/mvme88k/stand/Makefile index 404fda74972..fd200b56b19 100644 --- a/sys/arch/mvme88k/stand/Makefile +++ b/sys/arch/mvme88k/stand/Makefile @@ -1,8 +1,11 @@ -# $OpenBSD: Makefile,v 1.5 2000/12/28 21:21:25 smurph Exp $ +# $OpenBSD: Makefile,v 1.6 2004/01/26 19:48:31 miod Exp $ .if ${MACHINE} == "mvme88k" SUBDIR= bugcrt libbug libsa libz wrtvid bootsd bootxx bootst netboot -#sboot XXX future +# not ready yet +# SUBDIR+= tftpboot +# not really written yet... +# SUBDIR+= sboot .endif SUBDIR+=installboot diff --git a/sys/arch/mvme88k/stand/libbug/Makefile b/sys/arch/mvme88k/stand/libbug/Makefile index a8860aecd6c..80cdefcb9e6 100644 --- a/sys/arch/mvme88k/stand/libbug/Makefile +++ b/sys/arch/mvme88k/stand/libbug/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.6 2003/10/01 20:39:41 miod Exp $ +# $OpenBSD: Makefile,v 1.7 2004/01/26 19:48:33 miod Exp $ LIB=bug @@ -10,8 +10,8 @@ DIR_SA=$S/lib/libsa CFLAGS+=-I${.CURDIR}/../../include -I${DIR_SA} -SRCS= delay.c diskrd.c diskwr.c getbrdid.c inchr.c instat.c outln.c \ - outstr.c putchar.c return.c rtc_rd.c +SRCS= delay.c diskrd.c diskwr.c getbrdid.c inchr.c instat.c \ + netfopen.c netfread.c outln.c outstr.c putchar.c return.c rtc_rd.c install: diff --git a/sys/arch/mvme88k/stand/libsa/Makefile b/sys/arch/mvme88k/stand/libsa/Makefile index 51976db41c9..80e996d6860 100644 --- a/sys/arch/mvme88k/stand/libsa/Makefile +++ b/sys/arch/mvme88k/stand/libsa/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.5 2003/10/01 20:39:41 miod Exp $ +# $OpenBSD: Makefile,v 1.6 2004/01/26 19:48:34 miod Exp $ LIB=sa @@ -17,7 +17,7 @@ SRC_net= arp.c ether.c in_cksum.c net.c netif.c rpc.c nfs.c \ SRC_sa= alloc.c memcpy.c exit.c getfile.c gets.c globals.c \ printf.c strerror.c memset.c memcmp.c strncpy.c strcmp.c strlen.c \ - snprintf.c \ + strlcpy.c strlcat.c snprintf.c \ close.c closeall.c dev.c dkcksum.c \ lseek.c open.c nullfs.c read.c fstat.c \ ufs.c cread.c diff --git a/sys/arch/mvme88k/stand/tftpboot/Makefile b/sys/arch/mvme88k/stand/tftpboot/Makefile new file mode 100644 index 00000000000..5ee68e2aed2 --- /dev/null +++ b/sys/arch/mvme88k/stand/tftpboot/Makefile @@ -0,0 +1,41 @@ +# $OpenBSD: Makefile,v 1.1 2004/01/26 19:48:34 miod Exp $ + +SIZE?= size +STRIP?= strip + +S= ${.CURDIR}/../../../.. +DEFS= -DSUN_BOOTPARAMS +#-DNETIF_DEBUG +INCPATH=-I${.CURDIR} -I${.CURDIR}/../libsa -I${.CURDIR}/../libbug \ + -I${S} -I${S}/lib/libsa +CFLAGS+=${DEFS} ${INCPATH} ${COPTS} +CLEANFILES+=tftpboot tftpboot.bin + +.include "${S}/arch/mvme88k/stand/bugcrt/Makefile.inc" +.include "${S}/arch/mvme88k/stand/libbug/Makefile.inc" +.include "${S}/arch/mvme88k/stand/libsa/Makefile.inc" +.include "${S}/arch/mvme88k/stand/libz/Makefile.inc" + +SRCS= boot.c conf.c version.c tftpfs.c netdev.c +OBJS= ${SRCS:S/.c/.o/g} +LIBS= ${LIBSA} ${LIBBUG} ${LIBZ} +LDFLAGS+= -s -N -T ${STAGE2_RELOC} +#LDFLAGS+= -nostdlib -s -N -Ttext ${RELOC} + +all: tftpboot.bin + +tftpboot: ${OBJS} ${SINGLE} ${LIBS} + ${LD} ${LDFLAGS} -o $@ \ + ${SINGLE} ${OBJS} ${LIBS} +# @${SIZE} $@ + +tftpboot.bin: tftpboot + ${STRIP} tftpboot + dd ibs=32 skip=1 if=tftpboot of=$@ +# dd ibs=38 skip=1 if=tftpboot of=$@ + +install: + ${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + tftpboot.bin ${DESTDIR}${MDEC_DIR}/tftpboot + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/tftpboot/boot.c b/sys/arch/mvme88k/stand/tftpboot/boot.c new file mode 100644 index 00000000000..c7445ed95c8 --- /dev/null +++ b/sys/arch/mvme88k/stand/tftpboot/boot.c @@ -0,0 +1,80 @@ +/* $OpenBSD: boot.c,v 1.1 2004/01/26 19:48:34 miod Exp $ */ +/* $NetBSD: boot.c,v 1.2 1995/09/23 03:42:52 gwr Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University 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 REGENTS 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 REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)boot.c 8.1 (Berkeley) 6/10/93 + */ + +#include <sys/param.h> +#include <sys/reboot.h> + +#include <machine/prom.h> + +#include "stand.h" +#include "libsa.h" + +int debug; +int errno; +extern char *version; +char line[80]; + +int +main() +{ + char *cp, *file; + int io, flag, ret; + int ask = 0; + + printf("\n>> OpenBSD/mvme88k tftpboot [%s]\n", version); + + ret = parse_args(&file, &flag); + for (;;) { + if (ask) { + printf("boot: "); + gets(line); + if (line[0]) { + bugargs.arg_start = line; + cp = line; + while (cp < (line + sizeof(line) -1) && *cp) + cp++; + bugargs.arg_end = cp; + ret = parse_args(&file, &flag); + } + } + if (ret) { + printf("boot: -q returning to MVME-Bug\n"); + break; + } + exec_mvme(file, flag); + printf("boot: %s: %s\n", file, strerror(errno)); + ask = 1; + } + return (0); +} diff --git a/sys/arch/mvme88k/stand/tftpboot/conf.c b/sys/arch/mvme88k/stand/tftpboot/conf.c new file mode 100644 index 00000000000..e1b26c65e08 --- /dev/null +++ b/sys/arch/mvme88k/stand/tftpboot/conf.c @@ -0,0 +1,22 @@ +/* $OpenBSD: conf.c,v 1.1 2004/01/26 19:48:34 miod Exp $ */ + +#include <sys/types.h> +#include <machine/prom.h> + +#include <stand.h> +#include "tftpfs.h" +#include "netdev.h" +#include "libsa.h" + +struct fs_ops file_system[] = { + { tftpfs_open, tftpfs_close, tftpfs_read, tftpfs_write, tftpfs_seek, tftpfs_stat }, +}; + +int nfsys = sizeof(file_system) / sizeof(file_system[0]); + +struct devsw devsw[] = { + { "net", net_strategy, net_open, net_close, net_ioctl }, +}; + +int ndevs = (sizeof(devsw)/sizeof(devsw[0])); + diff --git a/sys/arch/mvme88k/stand/tftpboot/netdev.c b/sys/arch/mvme88k/stand/tftpboot/netdev.c new file mode 100644 index 00000000000..39ed9146b17 --- /dev/null +++ b/sys/arch/mvme88k/stand/tftpboot/netdev.c @@ -0,0 +1,137 @@ +/* $OpenBSD: netdev.c,v 1.1 2004/01/26 19:48:34 miod Exp $ */ + +/* + * Copyright (c) 1993 Paul Kranenburg + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Paul Kranenburg. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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/param.h> +#include <machine/prom.h> + +#include "stand.h" +#include "tftpfs.h" + +#include "libsa.h" + +struct bugdev_softc { + short clun; + short dlun; +} bugdev_softc[1]; + +int +devopen(f, fname, file) + struct open_file *f; + const char *fname; + char **file; +{ + struct bugdev_softc *pp = &bugdev_softc[0]; + + pp->clun = (short)bugargs.ctrl_lun; + pp->dlun = (short)bugargs.dev_lun; + + f->f_devdata = (void *)pp; + f->f_dev = &devsw[0]; + *file = (char *)fname; + return (0); +} + +#define NFR_TIMEOUT 5 + +int +net_strategy(devdata, func, nblk, size, buf, rsize) + void *devdata; + int func; + daddr_t nblk; + size_t size; + void *buf; + size_t *rsize; +{ + struct bugdev_softc *pp = (struct bugdev_softc *)devdata; + struct mvmeprom_netfread nfr; + int attempts; + + for (attempts = 0; attempts < 10; attempts++) { + nfr.ctrl = pp->clun; + nfr.dev = pp->dlun; + nfr.status = 0; + nfr.addr = (u_long)buf; + nfr.bytes = 0; + nfr.blk = nblk; + nfr.timeout = NFR_TIMEOUT; + mvmeprom_netfread(&nfr); + + if (rsize) { + *rsize = nfr.bytes; + } + + if (nfr.status == 0) + return (0); + } + + return (EIO); +} + +int +net_open(struct open_file *f, ...) +{ + va_list ap; + struct mvmeprom_netfopen nfo; + struct bugdev_softc *pp = (struct bugdev_softc *)f->f_devdata; + char *filename; + + va_start(ap, f); + filename = va_arg(ap, char *); + va_end(ap); + + nfo.ctrl = pp->clun; + nfo.dev = pp->dlun; + nfo.status = 0; + strlcpy(nfo.filename, filename, sizeof nfo.filename); + mvmeprom_netfopen(&nfo); + +#ifdef DEBUG + printf("tftp open(%s): error %x\n", filename, nfo.status); +#endif + return (nfo.status); +} + +int +net_close(f) + struct open_file *f; +{ + return (0); +} + +int +net_ioctl(f, cmd, data) + struct open_file *f; + u_long cmd; + void *data; +{ + return (EIO); +} diff --git a/sys/arch/mvme88k/stand/tftpboot/netdev.h b/sys/arch/mvme88k/stand/tftpboot/netdev.h new file mode 100644 index 00000000000..4d9b1abc797 --- /dev/null +++ b/sys/arch/mvme88k/stand/tftpboot/netdev.h @@ -0,0 +1,6 @@ +/* $OpenBSD: netdev.h,v 1.1 2004/01/26 19:48:34 miod Exp $ */ + +int net_open(struct open_file *, ...); +int net_close(struct open_file *); +int net_ioctl(struct open_file *, u_long, void *); +int net_strategy(void *, int, daddr_t, size_t, void *, size_t *); diff --git a/sys/arch/mvme88k/stand/tftpboot/tftpfs.c b/sys/arch/mvme88k/stand/tftpboot/tftpfs.c new file mode 100644 index 00000000000..42cef91e583 --- /dev/null +++ b/sys/arch/mvme88k/stand/tftpboot/tftpfs.c @@ -0,0 +1,291 @@ +/* $OpenBSD: tftpfs.c,v 1.1 2004/01/26 19:48:34 miod Exp $ */ + +/*- + * Copyright (c) 2001 Steve Murphree, Jr. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * TFTP file system. + */ + +#include <sys/param.h> +#include <sys/time.h> +#include <sys/stat.h> +#include <ufs/ffs/fs.h> +#include <lib/libkern/libkern.h> + +#include "stand.h" + +/* + * In-core open file. + */ +struct tftp_file { + char filename[128]; + off_t f_seekp; /* seek pointer */ + char *f_buf; /* buffer for data block */ + off_t f_off; /* index into buffer for data block */ + daddr_t f_buf_blkno; /* block number of data block */ + size_t f_buf_size; +}; + +#define TFTP_BLOCK_SHIFT 9 +#define TFTP_BLOCK_SIZE (1<<TFTP_BLOCK_SHIFT) /* 512 by tftp convention */ +#define TFTP_BLOCK_NO(x) ((x >> TFTP_BLOCK_SHIFT) + 1) +#define TFTP_BLOCK_OFF(x) (x % TFTP_BLOCK_SIZE) + +static int read_inode(ino_t, struct open_file *); +static int block_map(struct open_file *, daddr_t, daddr_t *); +static int tftp_read_file(struct open_file *, char **, size_t *); +#ifdef COMPAT_UFS +static void ffs_oldfscompat(struct fs *); +#endif + +/* + * Read a portion of a file into an internal buffer. Return + * the location in the buffer and the amount in the buffer. + */ + +char tftp_buf[TFTP_BLOCK_SIZE]; /* static */ +struct tftp_file tftp_ctrl; + +static int +tftp_read_file(f, buf_p, size_p) + struct open_file *f; + char **buf_p; /* out */ + size_t *size_p; /* out */ +{ + register struct tftp_file *fp = (struct tftp_file *)f->f_fsdata; + long off; + register daddr_t file_block; + size_t block_size; + int i, rc; + + off = TFTP_BLOCK_OFF(fp->f_seekp); + file_block = TFTP_BLOCK_NO(fp->f_seekp); + block_size = TFTP_BLOCK_SIZE; + + if (file_block == fp->f_buf_blkno + 1) { + /* + * Normal, incremental block transfer. + */ + rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ, + file_block, block_size, fp->f_buf, &fp->f_buf_size); + if (rc) + return (rc); + if (!(file_block % 4)) /* twiddle every 4 blocks */ + twiddle(); + fp->f_buf_blkno = file_block; + } else if (file_block > fp->f_buf_blkno + 1) { + /* + * Read ahead to the requested block; If we need + * those we skipped, see below. + */ + for (i = (fp->f_buf_blkno + 1); i <= file_block; i++) { + rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ, + i, block_size, fp->f_buf, &fp->f_buf_size); + if (rc) + return (rc); + } + fp->f_buf_blkno = file_block; + } else if (file_block < fp->f_buf_blkno) { + /* + * Uh oh... We can't rewind. Reopen the file + * and start again. + */ + char filename[64]; + strlcpy(filename, fp->filename, sizeof filename); + tftpfs_close(f); + tftpfs_open(filename, f); + for (i = 1; i <= file_block; i++) { + rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ, + i, block_size, fp->f_buf, &fp->f_buf_size); + if (rc) + return (rc); + } + fp->f_buf_blkno = file_block; + } + + /* + * Return address of byte in buffer corresponding to + * offset, and size of remainder of buffer after that + * byte. + */ + *buf_p = fp->f_buf + off; + *size_p = fp->f_buf_size - off; + + /* + * But truncate buffer at end of file. + */ + if (fp->f_buf_size > block_size){ + twiddle(); + return(EIO); + } + + + return (0); +} + +/* + * Open a file. + */ +int +tftpfs_open(path, f) + char *path; + struct open_file *f; +{ + struct tftp_file *fp; + int rc = 0; + + /* locate file system specific data structure and zero it.*/ + fp = &tftp_ctrl; + bzero(fp, sizeof(struct tftp_file)); + f->f_fsdata = (void *)fp; + fp->f_seekp = 0; + fp->f_buf = tftp_buf; + bzero(fp->f_buf, TFTP_BLOCK_SIZE); + fp->f_buf_size = 0; + + strlcpy(fp->filename, path, sizeof fp->filename); + + if (f->f_dev->dv_open == NULL) { + panic("No device open()!"); + } + twiddle(); + rc = (f->f_dev->dv_open)(f, path); + return (rc); +} + +int +tftpfs_close(f) + struct open_file *f; +{ + register struct tftp_file *fp = (struct tftp_file *)f->f_fsdata; + + fp->f_buf = (void *)0; + f->f_fsdata = (void *)0; + (f->f_dev->dv_close)(f); + return (0); +} + +/* + * Copy a portion of a file into kernel memory. + * Cross block boundaries when necessary. + */ +int +tftpfs_read(f, start, size, resid) + struct open_file *f; + void *start; + size_t size; + size_t *resid; /* out */ +{ + register struct tftp_file *fp = (struct tftp_file *)f->f_fsdata; + register size_t csize; + char *buf; + size_t buf_size; + int rc = 0; + register char *addr = start; + + while (size != 0) { + rc = tftp_read_file(f, &buf, &buf_size); + if (rc) + break; + + csize = size; + if (csize > buf_size) + csize = buf_size; + + bcopy(buf, addr, csize); + + fp->f_seekp += csize; + addr += csize; + size -= csize; + } + if (resid) + *resid = size; + return (rc); +} + +/* + * Not implemented. + */ +int +tftpfs_write(f, start, size, resid) + struct open_file *f; + void *start; + size_t size; + size_t *resid; /* out */ +{ + + return (EROFS); +} + +/* + * We only see forward. We can't rewind. + */ +off_t +tftpfs_seek(f, offset, where) + struct open_file *f; + off_t offset; + int where; +{ + register struct tftp_file *fp = (struct tftp_file *)f->f_fsdata; + + switch (where) { + case SEEK_SET: + fp->f_seekp = offset; + break; + case SEEK_CUR: + fp->f_seekp += offset; + break; + case SEEK_END: + errno = EIO; + return (-1); + break; + default: + return (-1); + } + return (fp->f_seekp); +} + +int +tftpfs_stat(f, sb) + struct open_file *f; + struct stat *sb; +{ + return EIO; +} + +#ifndef NO_READDIR +int +tftpfs_readdir (struct open_file *f, char *name) +{ + return EIO; +} +#endif + diff --git a/sys/arch/mvme88k/stand/tftpboot/tftpfs.h b/sys/arch/mvme88k/stand/tftpboot/tftpfs.h new file mode 100644 index 00000000000..956a3c379ed --- /dev/null +++ b/sys/arch/mvme88k/stand/tftpboot/tftpfs.h @@ -0,0 +1,43 @@ +/* $OpenBSD: tftpfs.h,v 1.1 2004/01/26 19:48:34 miod Exp $ */ + +/*- + * Copyright (c) 2001 Steve Murphree, Jr. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by TooLs GmbH. + * 4. The name of TooLs GmbH may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +int tftpfs_open(char *path, struct open_file *f); +int tftpfs_close(struct open_file *f); +int tftpfs_read(struct open_file *f, void *buf, + size_t size, size_t *resid); +int tftpfs_write(struct open_file *f, void *buf, + size_t size, size_t *resid); +off_t tftpfs_seek(struct open_file *f, off_t offset, int where); +int tftpfs_stat(struct open_file *f, struct stat *sb); +#ifndef NO_READDIR +int tftpfs_readdir(struct open_file *f, char *name); +#endif diff --git a/sys/arch/mvme88k/stand/tftpboot/version.c b/sys/arch/mvme88k/stand/tftpboot/version.c new file mode 100644 index 00000000000..aeec0400f86 --- /dev/null +++ b/sys/arch/mvme88k/stand/tftpboot/version.c @@ -0,0 +1,8 @@ +/* $OpenBSD: version.c,v 1.1 2004/01/26 19:48:34 miod Exp $ */ + +/* + * make a random change to this file when you want the bootblock + * revision to increase. like change this q to an x, or something. + */ + +char *version = "$Revision: 1.1 $"; |