diff options
author | Dale S. Rahn <rahnds@cvs.openbsd.org> | 1997-03-03 19:32:35 +0000 |
---|---|---|
committer | Dale S. Rahn <rahnds@cvs.openbsd.org> | 1997-03-03 19:32:35 +0000 |
commit | 90ff5a441368313fa226376473fea6908c2c3539 (patch) | |
tree | 38e1de6dcfb2805194734736d7209f51e06fa9e1 /sys/arch/mvme88k/stand | |
parent | 7848f1c3b3e234584c90f67e60c6164590478f49 (diff) |
Third try at importing the mvme88k port. This is a working kernel
from nivas.
Userland and compiler still need to be worked on.
Make certain what directory the import is done from.
Diffstat (limited to 'sys/arch/mvme88k/stand')
232 files changed, 18480 insertions, 0 deletions
diff --git a/sys/arch/mvme88k/stand/Makefile.inc b/sys/arch/mvme88k/stand/Makefile.inc new file mode 100644 index 00000000000..cd56d8c2c72 --- /dev/null +++ b/sys/arch/mvme88k/stand/Makefile.inc @@ -0,0 +1,3 @@ +# $Id: Makefile.inc,v 1.1 1997/03/03 19:30:28 rahnds Exp $ + +MDEC_DIR?=/usr/mdec diff --git a/sys/arch/mvme88k/stand/boot/obj.m88k/boot b/sys/arch/mvme88k/stand/boot/obj.m88k/boot Binary files differnew file mode 100644 index 00000000000..789b981caf1 --- /dev/null +++ b/sys/arch/mvme88k/stand/boot/obj.m88k/boot diff --git a/sys/arch/mvme88k/stand/bootsd/Makefile b/sys/arch/mvme88k/stand/bootsd/Makefile new file mode 100644 index 00000000000..ebf141fb0e8 --- /dev/null +++ b/sys/arch/mvme88k/stand/bootsd/Makefile @@ -0,0 +1,50 @@ +# from: @(#)Makefile 8.1 (Berkeley) 6/10/93 +# $Id: Makefile,v 1.1 1997/03/03 19:30:29 rahnds Exp $ + +RELOC=0x3F0000 + +S= ${.CURDIR}/../../../.. +DEFS= -DSTANDALONE -DCOMPAT_NOLABEL # -DROMPRF +INCPATH=-I${.CURDIR} -I${.CURDIR}/../../include -I${S} -I${S}/lib/libsa +CFLAGS= ${INCPATH} ${DEFS} ${COPTS} +CLEANFILES+=sdboot bootsd bootsd.bug + +#.PATH: ${S}/arch/${MACHINE_ARCH}/${MACHINE_ARCH} +#.PATH: ${S}/lib/libsa + +.include "${S}/arch/${MACHINE}/stand/libsa/Makefile.inc" +.include "${S}/arch/${MACHINE}/stand/libbug/Makefile.inc" +.include "${S}/arch/${MACHINE}/stand/bugcrt/Makefile.inc" +.include "${S}/arch/${MACHINE}/stand/wrtvid/Makefile.inc" + +SRCS= boot.c filesystem.c bugdev.c version.c + +LIBS= ${LIBSA} ${LIBBUG} libgcc.a + +OBJS= ${SRCS:N*.h:R:S/$/.o/g} + +BOOTS= bootsd sdboot +ALL= ${BOOTS} + +all: ${ALL} + +devopen.o machdep.o: Makefile + +bootsd.bug: ${OBJS} ${BUGCRT} ${LIBS} + ${LD} -N -T ${RELOC} ${BUGCRT} ${OBJS} ${LIBS} -o $@ + @size bootsd.bug + +bootsd sdboot: bootsd.bug ${WRTVID} + cp bootsd.bug bootsd.bin + strip bootsd.bin + @if [ `size bootsd.bin | awk 'BEGIN {getline} {print $$1+$$2;}'` -gt 7168 ];\ + then\ + echo BOOTBLOCKS ARE TOO BIG;\ + fail;\ + fi + ${WRTVID} bootsd.bin + +install: + install -c -m 555 -g bin -o bin ${BOOTS} ${DESTDIR}${MDEC_DIR} + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/bootsd/README b/sys/arch/mvme88k/stand/bootsd/README new file mode 100644 index 00000000000..f3a503eb63e --- /dev/null +++ b/sys/arch/mvme88k/stand/bootsd/README @@ -0,0 +1,3 @@ +In short: stick the the bootblocks into a partition with +something like: + cat sdboot bootsd > /dev/rsd0c diff --git a/sys/arch/mvme88k/stand/bootsd/boot.c b/sys/arch/mvme88k/stand/bootsd/boot.c new file mode 100644 index 00000000000..70385ffde5f --- /dev/null +++ b/sys/arch/mvme88k/stand/bootsd/boot.c @@ -0,0 +1,302 @@ +/* $Id: boot.c,v 1.1 1997/03/03 19:30:29 rahnds Exp $ */ + +/*- + * Copyright (c) 1995 Theo de Raadt + * + * 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 under OpenBSD by + * Theo de Raadt for Willowglen Singapore. + * 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. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * from: @(#)boot.c 8.1 (Berkeley) 6/10/93 + */ + +#include <sys/param.h> +#include <sys/types.h> +#include <sys/reboot.h> +#include <a.out.h> +#include <machine/prom.h> +#include "stand.h" + +void copyunix __P((int io, char *addr)); +void parse_args __P((void)); + +int debug; +int netif_debug; +#define RB_NOSYM 0x400 + +/* + * Boot device is derived from ROM provided information. + */ +extern char *version; +u_long esym; +char *strtab; +int strtablen; +#if 0 +struct nlist *nlp, *enlp; +#endif + +struct kernel { + void *entry; + void *symtab; + void *esym; + int bflags; + int bdev; + char *kname; + void *smini; + void *emini; + u_int end_loaded; +} kernel; + +extern struct mvmeprom_args bugargs; + +int +main() +{ + struct exec x; + char *file; + void *addr; + int io, i; + + printf(">> OpenBSD sdboot [%s]\n", version); + + parse_args(); + file = kernel.kname; + + io = open(file, 0); + if (io < 0) { + printf("Can't open %s: %s\n", file, strerror(errno)); + mvmeprom_return(); + } + i = read(io, (char *)&x, sizeof(x)); + if (i != sizeof(x) || N_BADMAG(x)) { + printf("Bad format\n"); + return (0); + } + /* Make load address start of page which containes "start" */ + addr = (void *)(x.a_entry & ~0x0FFF); + lseek(io, 0, SEEK_SET); + + printf("load %s to 0x%x\n", file, addr); + copyunix(io, addr); + return (0); +} + +/*ARGSUSED*/ +void +copyunix(io, addr) + int io; + char *addr; +{ + void (*entry)() = (void (*)())addr; + struct exec x; + int i, cnt; + + i = read(io, (char *)&x, sizeof(x)); + if (i != sizeof(x) || N_BADMAG(x)) { + printf("Bad format\n"); + return; + } + + printf("%x", x.a_text); + if (N_GETMAGIC(x) == ZMAGIC) { + kernel.entry = entry = (void *)x.a_entry; + lseek(io, 0, SEEK_SET); + } + if (read(io, (char *)addr, x.a_text) != x.a_text) + goto shread; + addr += x.a_text; + if (N_GETMAGIC(x) == NMAGIC) + while ((int)addr & CLOFSET) + *addr++ = 0; + printf("+%x", x.a_data); + if (read(io, addr, x.a_data) != x.a_data) + goto shread; + addr += x.a_data; + printf("+%x", x.a_bss); + for (i = 0; i < x.a_bss; i++) + *addr++ = 0; + if (x.a_syms != 0 && !(kernel.bflags & RB_NOSYM)) { + bcopy(&x.a_syms, addr, sizeof(x.a_syms)); + addr += sizeof(x.a_syms); +#if 0 + nlp = (struct nlist *)addr; +#endif + printf("+[%x+", x.a_syms); + if (read(io, addr, x.a_syms) != x.a_syms) + goto shread; + addr += x.a_syms; +#if 0 + enlp = (struct nlist *)(strtab = addr); +#endif + + if (read(io, &strtablen, sizeof(int)) != sizeof(int)) + goto shread; + + bcopy(&strtablen, addr, sizeof(int)); + if (i = strtablen) { + i -= sizeof(int); + addr += sizeof(int); + cnt = read(io, addr, i); + if (cnt != i) + printf("symwarn"); /* goto shread; */ + addr += i; + } + printf("%x]", i); + esym = KERNBASE + + (((int)addr + sizeof(int) - 1) & ~(sizeof(int) - 1)); + kernel.symtab = (void *) x.a_syms; + kernel.esym = addr; + } else { + kernel.symtab = 0; + kernel.esym = 0; + } + +#if 0 + while (nlp < enlp) { + register int strx = nlp->n_un.n_strx; + if (strx > strtablen) + continue; + if (strcmp(strtab+strx, "_esym") == 0) { + *(int*)(nlp->n_value - KERNBASE) = esym; + break; + } + nlp++; + } +#endif + + kernel.bdev = 0; + kernel.end_loaded = (u_int)addr; + kernel.smini = 0; + kernel.emini = 0; + kernel.kname = 0; + + printf("=%x\n", (u_int)addr - (u_int)entry); /* XXX wrong? */ + +#if 0 +printf("entry %x\n",kernel.entry); +printf("symtab %x\n",kernel.symtab); +printf("esym %x\n",kernel.esym); +printf("bflags %x\n",kernel.bflags); +printf("bdev %x\n",kernel.bdev); +printf("kname %x\n",kernel.kname); +printf("smini %x\n",kernel.smini); +printf("emini %x\n",kernel.emini); +printf("end_loaded %x\n",kernel.end_loaded); +#endif + + printf("start at 0x%x\n", (int)entry); + if (((u_long)entry &0xf) == 0x2) { + (entry)(&bugargs, &kernel); + } else { + /* is type fixing anything like price fixing? */ + typedef (* kernel_start) __P((int, int, void *,void *, void *)); + kernel_start addr; + addr = (void *)entry; + (addr)(kernel.bflags, 0, kernel.esym, kernel.smini, kernel.emini); + } + return; + +shread: + printf("short read\n"); +} + +struct flags { + char c; + short bit; +} bf[] = { + { 'a', RB_ASKNAME }, + { 'b', RB_HALT }, + { 'y', RB_NOSYM }, + { 'd', RB_KDB }, + { 'm', RB_MINIROOT }, + { 'r', RB_DFLTROOT }, + { 's', RB_SINGLE }, +}; + +void +parse_args() +{ + char *name = "/netbsd", *ptr; + int i, howto = 0; + char c; + + if (bugargs.arg_start != bugargs.arg_end) { + ptr = bugargs.arg_start; + while (c = *ptr) { + while (c == ' ') + c = *++ptr; + if (c == '\0') + return; + if (c != '-') { + name = ptr; + while ((c = *++ptr) && c != ' ') + ; + if (c) + *ptr++ = 0; + continue; + } + while ((c = *++ptr) && c != ' ') { + for (i = 0; i < sizeof(bf)/sizeof(bf[0]); i++) + if (bf[i].c == c) { + howto |= bf[i].bit; + } + } + } + } + kernel.bflags = howto; + kernel.kname = name; +} diff --git a/sys/arch/mvme88k/stand/bootsd/bootsd b/sys/arch/mvme88k/stand/bootsd/bootsd Binary files differnew file mode 100644 index 00000000000..5289b6e0087 --- /dev/null +++ b/sys/arch/mvme88k/stand/bootsd/bootsd diff --git a/sys/arch/mvme88k/stand/bootsd/bootsd.bin b/sys/arch/mvme88k/stand/bootsd/bootsd.bin Binary files differnew file mode 100644 index 00000000000..4ea194d6a22 --- /dev/null +++ b/sys/arch/mvme88k/stand/bootsd/bootsd.bin diff --git a/sys/arch/mvme88k/stand/bootsd/bootsd.bug b/sys/arch/mvme88k/stand/bootsd/bootsd.bug Binary files differnew file mode 100644 index 00000000000..52ba1e9769b --- /dev/null +++ b/sys/arch/mvme88k/stand/bootsd/bootsd.bug diff --git a/sys/arch/mvme88k/stand/bootsd/bugdev.c b/sys/arch/mvme88k/stand/bootsd/bugdev.c new file mode 100644 index 00000000000..def0241f77b --- /dev/null +++ b/sys/arch/mvme88k/stand/bootsd/bugdev.c @@ -0,0 +1,244 @@ +/* $Id: bugdev.c,v 1.1 1997/03/03 19:30:29 rahnds 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 <sys/disklabel.h> +#include <machine/prom.h> +#include "stand.h" + +int bugscopen __P((struct open_file *, ...)); +int bugscclose __P((struct open_file *)); +int bugscioctl __P((struct open_file *, u_long, void *)); +int bugscstrategy __P((void *, int, daddr_t, size_t, void *, size_t *)); + +void cputobsdlabel __P((struct disklabel *lp, struct cpu_disklabel *clp)); + +struct devsw devsw[] = { + { "bugsc", bugscstrategy, bugscopen, bugscclose, bugscioctl }, +}; +int ndevs = (sizeof(devsw)/sizeof(devsw[0])); + +extern struct mvmeprom_args bugargs; +int errno; + +struct bugsc_softc { + int fd; /* Prom file descriptor */ + int poff; /* Partition offset */ + int psize; /* Partition size */ + short ctrl; + short dev; +} bugsc_softc[1]; + +int +devopen(f, fname, file) + struct open_file *f; + const char *fname; + char **file; +{ + register struct bugsc_softc *pp = &bugsc_softc[0]; + int error, i, dn = 0, pn = 0; + char *dev, *cp; + static char iobuf[MAXBSIZE]; + struct disklabel sdlabel; + + dev = bugargs.arg_start; + + /* + * Extract partition # from boot device string. + */ + for (cp = dev; *cp; cp++) /* void */; + while (*cp != '/' && cp > dev) { + if (*cp == ':') + pn = *(cp+1) - 'a'; + --cp; + } + + pp->fd = bugscopen(f); + + if (pp->fd < 0) { + printf("Can't open device `%s'\n", dev); + return (ENXIO); + } + error = bugscstrategy(pp, F_READ, LABELSECTOR, DEV_BSIZE, iobuf, &i); + if (error) + return (error); + if (i != DEV_BSIZE) + return (EINVAL); + + cputobsdlabel(&sdlabel, (struct cpu_disklabel *)iobuf); + pp->poff = sdlabel.d_partitions[pn].p_offset; + pp->psize = sdlabel.d_partitions[pn].p_size; + + f->f_dev = devsw; + f->f_devdata = (void *)pp; + *file = (char *)fname; + return (0); +} + +/* silly block scale factor */ +#define BUG_BLOCK_SIZE 256 +#define BUG_SCALE (512/BUG_BLOCK_SIZE) +int +bugscstrategy(devdata, func, dblk, size, buf, rsize) + void *devdata; + int func; + daddr_t dblk; + size_t size; + void *buf; + size_t *rsize; +{ + struct mvmeprom_dskio dio; + register struct bugsc_softc *pp = (struct bugsc_softc *)devdata; + daddr_t blk = dblk + pp->poff; + + twiddle(); + + dio.ctrl_lun = pp->ctrl; + dio.dev_lun = pp->dev; + dio.status = 0; + dio.pbuffer = buf; + dio.blk_num = blk * BUG_SCALE; + dio.blk_cnt = size / BUG_BLOCK_SIZE; /* assumed size in bytes */ + dio.flag = 0; + dio.addr_mod = 0; +#ifdef 0 + printf("bugscstrategy: size=%d blk=%d buf=%x\n", size, blk, buf); + printf("ctrl %d dev %d\n", dio.ctrl_lun, dio.dev_lun); +#endif + mvmeprom_diskrd(&dio); + + *rsize = dio.blk_cnt * BUG_BLOCK_SIZE; +#ifdef 0 +printf("rsize %d status %x\n", *rsize, dio.status); +#endif + + if (dio.status) + return (EIO); + return (0); +} + +int +bugscopen(f) + struct open_file *f; +{ +#ifdef DEBUG + printf("bugscopen:\n"); +#endif + + f->f_devdata = (void *)bugsc_softc; + bugsc_softc[0].ctrl = (short)bugargs.ctrl_lun; + bugsc_softc[0].dev = (short)bugargs.dev_lun; + printf("using mvmebug ctrl %d dev %d\n", + bugsc_softc[0].ctrl, bugsc_softc[0].dev); + return (0); +} + +int +bugscclose(f) + struct open_file *f; +{ + return (EIO); +} + +int +bugscioctl(f, cmd, data) + struct open_file *f; + u_long cmd; + void *data; +{ + return (EIO); +} + +void +cputobsdlabel(lp, clp) + struct disklabel *lp; + struct cpu_disklabel *clp; +{ + int i; + + lp->d_magic = clp->magic1; + lp->d_type = clp->type; + lp->d_subtype = clp->subtype; + bcopy(clp->vid_vd, lp->d_typename, 16); + bcopy(clp->packname, lp->d_packname, 16); + lp->d_secsize = clp->cfg_psm; + lp->d_nsectors = clp->cfg_spt; + lp->d_ncylinders = clp->cfg_trk; /* trk is really num of cyl! */ + lp->d_ntracks = clp->cfg_hds; + + lp->d_secpercyl = clp->secpercyl; + lp->d_secperunit = clp->secperunit; + lp->d_secpercyl = clp->secpercyl; + lp->d_secperunit = clp->secperunit; + lp->d_sparespertrack = clp->sparespertrack; + lp->d_sparespercyl = clp->sparespercyl; + lp->d_acylinders = clp->acylinders; + lp->d_rpm = clp->rpm; + lp->d_interleave = clp->cfg_ilv; + lp->d_trackskew = clp->cfg_sof; + lp->d_cylskew = clp->cylskew; + lp->d_headswitch = clp->headswitch; + + /* this silly table is for winchester drives */ + switch (clp->cfg_ssr) { + case 0: + lp->d_trkseek = 0; + break; + case 1: + lp->d_trkseek = 6; + break; + case 2: + lp->d_trkseek = 10; + break; + case 3: + lp->d_trkseek = 15; + break; + case 4: + lp->d_trkseek = 20; + break; + default: + lp->d_trkseek = 0; + break; + } + lp->d_flags = clp->flags; + for (i = 0; i < NDDATA; i++) + lp->d_drivedata[i] = clp->drivedata[i]; + for (i = 0; i < NSPARE; i++) + lp->d_spare[i] = clp->spare[i]; + lp->d_magic2 = clp->magic2; + lp->d_checksum = clp->checksum; + lp->d_npartitions = clp->partitions; + lp->d_bbsize = clp->bbsize; + lp->d_sbsize = clp->sbsize; + bcopy(clp->vid_4, &(lp->d_partitions[0]), sizeof (struct partition) * 4); + bcopy(clp->cfg_4, &(lp->d_partitions[4]), sizeof (struct partition) * 12); +} diff --git a/sys/arch/mvme88k/stand/bootsd/filesystem.c b/sys/arch/mvme88k/stand/bootsd/filesystem.c new file mode 100644 index 00000000000..1f1574a93f2 --- /dev/null +++ b/sys/arch/mvme88k/stand/bootsd/filesystem.c @@ -0,0 +1,42 @@ +/* $Id: filesystem.c,v 1.1 1997/03/03 19:30:29 rahnds Exp $ */ + +/* + * Copyright (c) 1993 Philip A. Nelson. + * 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 Philip A. Nelson. + * 4. The name of Philip A. Nelson may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY PHILIP NELSON ``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 PHILIP NELSON 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 <stand.h> +#include <ufs.h> + +struct fs_ops file_system[] = { + { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat }, +}; + +int nfsys = sizeof(file_system)/sizeof(struct fs_ops); + diff --git a/sys/arch/mvme88k/stand/bootsd/sdboot b/sys/arch/mvme88k/stand/bootsd/sdboot Binary files differnew file mode 100644 index 00000000000..a79942fc568 --- /dev/null +++ b/sys/arch/mvme88k/stand/bootsd/sdboot diff --git a/sys/arch/mvme88k/stand/bootsd/version.c b/sys/arch/mvme88k/stand/bootsd/version.c new file mode 100644 index 00000000000..2332e37eb22 --- /dev/null +++ b/sys/arch/mvme88k/stand/bootsd/version.c @@ -0,0 +1,8 @@ +/* $Id: version.c,v 1.1 1997/03/03 19:30:29 rahnds Exp $ */ + +/* + * make a random change to this file when you want the bootblock + * revision to increase. like change this x to a y, or something. + */ + +char *version = "$Revision: 1.1 $"; diff --git a/sys/arch/mvme88k/stand/bootst/Makefile b/sys/arch/mvme88k/stand/bootst/Makefile new file mode 100644 index 00000000000..59b7f980be9 --- /dev/null +++ b/sys/arch/mvme88k/stand/bootst/Makefile @@ -0,0 +1,41 @@ +# from: @(#)Makefile 8.1 (Berkeley) 6/10/93 +# $Id: Makefile,v 1.1 1997/03/03 19:30:30 rahnds Exp $ + +RELOC=0x3F0000 + +S= ${.CURDIR}/../../../.. +DEFS= -DSTANDALONE -DCOMPAT_NOLABEL # -DROMPRF +INCPATH=-I${.CURDIR} -I${.CURDIR}/../../include -I${S} -I${S}/lib/libsa +CFLAGS= -O2 ${INCPATH} ${DEFS} ${COPTS} +CLEANFILES+=sdboot bootst bootst.bug + +#.PATH: ${S}/arch/${MACHINE_ARCH}/${MACHINE_ARCH} +#.PATH: ${S}/lib/libsa + +.include "${S}/arch/${MACHINE}/stand/libsa/Makefile.inc" +.include "${S}/arch/${MACHINE}/stand/libbug/Makefile.inc" +.include "${S}/arch/${MACHINE}/stand/bugcrt/Makefile.inc" +.include "${S}/arch/${MACHINE}/stand/wrtvid/Makefile.inc" + +SRCS= bootst.c + +LIBS= ${LIBSA} ${LIBBUG} + +OBJS= ${SRCS:N*.h:R:S/$/.o/g} + +BOOTS= bootst stboot +ALL= ${BOOTS} + +all: ${ALL} + +bootst.bug: ${OBJS} ${BUGCRT} ${LIBS} + ${LD} -s -N -T ${RELOC} ${BUGCRT} ${OBJS} ${LIBS} -o $@ + @size bootst.bug + +bootst stboot: bootst.bug ${WRTVID} + ${WRTVID} bootst.bug + +install: + install -c -m 555 -g bin -o bin ${BOOTS} ${DESTDIR}${MDEC_DIR} + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/bootst/bak.c b/sys/arch/mvme88k/stand/bootst/bak.c new file mode 100644 index 00000000000..a93d9bc5d49 --- /dev/null +++ b/sys/arch/mvme88k/stand/bootst/bak.c @@ -0,0 +1,382 @@ +#include "bug.h" +#include <sys/types.h> +#include <sys/param.h> +#include <sys/reboot.h> +#include <sys/exec.h> +/* +#include <sys/exec_aout.h> +*/ + +#define KERNEL_LOAD_ADDRESS ((void *)0x4000) +#define BUG_BLOCK_SIZE 512 +#define VERSION 0x0000 + +#define RB_NOSYM 0x400 + + + +void memset(void *,char,size_t); +void printf(char *,...); +void parse_args(struct bugargs *pbugargs); +int read_tape_block(short ctrl, short dev, short *status, void *addr, + int *cnt, int blk_num, unsigned char *flags,int verbose); +int load_kern(); + +struct kernel { + void *entry; + void *symtab; + void *esym; + int bflags; + int bdev; + char *kname; + void *smini; + void *emini; + u_int end_loaded; +} kernel; + +typedef (* kernel_entry)(struct bugargs *,struct kernel *); + +void main(struct bugargs *pbugargs) +{ + kernel_entry addr; + + /* + print_bugargs(pbugargs); + print_time(); + print_brdid(); + print_memory(); + */ + parse_args(pbugargs); + if (1 == load_kern(pbugargs)) { + printf("unsuccessful in loading kernel\n\r"); + } else { + addr = kernel.entry; + printf("kernel loaded at %x\n\r",addr); + printf("kernel.entry %x\n\r",kernel.entry); + printf("kernel.symtab %x\n\r",kernel.symtab); + printf("kernel.esym %x\n\r",kernel.esym); + printf("kernel.bflags %x\n\r",kernel.bflags); + printf("kernel.bdev %x\n\r",kernel.bdev); + if (kernel.kname) { + printf("kernel.kname <%s>\n\r",kernel.kname); + } else { + printf("kernel.kname <null>\n\r"); + } + printf("kernel.end_loaded %x\n\r",kernel.end_loaded); + + if (kernel.bflags & RB_MINIROOT) { + loadmini(kernel.end_loaded,pbugargs); + } + + printf("kernel.smini %x\n\r",kernel.smini); + printf("kernel.emini %x\n\r",kernel.emini); + printf("kernel.end_loaded %x\n\r",kernel.end_loaded); + if (kernel.bflags & RB_HALT) + bug_return(); + (addr)(pbugargs,&kernel); + } + + return; +} +#define BUG_SCALE (512/BUG_BLOCK_SIZE) +int +read_tape_block(short ctrl, short dev, short *status, void *addr, + int *cnt, int blk_num, unsigned char *flags,int verbose) +{ + struct bug_dskio dio; + int ret; + int len, len1; + + len = *cnt; + do { + if (len > 16 * 1024) { + len1 = 16 * 1024; + }else{ + len1 = len; + } + dio.ctrl_lun = ctrl; + dio.dev_lun = dev; + dio.status = *status; + dio.pbuffer = addr; + dio.blk_num = blk_num; + dio.blk_cnt = len1 /(512/BUG_SCALE); + dio.flag = *flags; + dio.addr_mod = 0; + + if (verbose){ + printf("saddr %x eaddr %x", dio.pbuffer, + (int)dio.pbuffer + (dio.blk_cnt * BUG_BLOCK_SIZE)); + } + + ret = bug_diskrd(&dio); + + *status = dio.status; + *cnt += (dio.blk_cnt/BUG_SCALE)*512; + if (verbose) { + printf("status %x ret %d ",*status, ret); + printf("flags %x\n\r",*flags); + } + len -= len1; + addr += len1; + blk_num += len1 /(512/BUG_SCALE); + } while (len > 0); + return ret; +} +int verbose = 1; +int +load_kern(struct bugargs *pbugargs) +{ + int ret; + char *addr; + unsigned char flags; + short status = 0; + int blk_num; + struct exec *pexec; + int magic; + int *esym; + int *symtab; + int cnt, len; + char buf[512]; + + blk_num = 2; + /* flags = IGNORE_FILENUM ; */ + flags = 0; + cnt = 512 ; + ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, &status, buf, + &cnt, blk_num, &flags, verbose); + if (ret != 0) { + printf("unable to load kernel 1\n\r"); + return 1; + } + pexec = (struct exec *) buf; + if ((N_GETMID(*pexec) != MID_M68K) && + ( N_GETMID(*pexec) != MID_M68K4K )) + { + printf("invalid mid on kernel\n\r"); + return 1; + } + { + short *pversion = (void *)(KERNEL_LOAD_ADDRESS+0x20); + if (VERSION != *pversion) { + printf("invalid version of kernel/loader\n\r"); + bug_return(); + } + } + magic = N_GETMAGIC(*pexec); + switch (magic) { + case ZMAGIC: + break; + case NMAGIC: + printf ("NMAGIC not yet supported"); + case OMAGIC: + case QMAGIC: + default: + printf("Unknown or unsupported magic type <%x>\n\r", + magic); + return 1; + break; + } + if ( magic == ZMAGIC ) { + + status = 0; + addr = pexec->a_entry & ~0x0FFF; + bcopy(&buf, addr, 512); + /* 2nd block of exe */ + addr += 512; + + if ((int)pexec->a_entry != (int)KERNEL_LOAD_ADDRESS + 0x22) { + printf ("warning kernel start address not %x, %x\n\r", + (int)KERNEL_LOAD_ADDRESS + 0x22,pexec->a_entry); + printf ("kernel loaded at %x\n\r",KERNEL_LOAD_ADDRESS); + + } + printf ("text 0x%x data 0x%x bss 0x%x\n\r", + pexec->a_text, pexec->a_data, pexec->a_bss); + + len = (pexec->a_text - 512) ; /* XXX */ + len += (pexec->a_data ); + + printf ("loading [ %x + %x ",pexec->a_text,pexec->a_data); + + cnt = len; + flags = IGNORE_FILENUM ; + ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, + &status, addr, &cnt, blk_num, &flags, verbose); + if (ret != 0 || cnt != len) { + printf("unable to load kernel 2\n\r"); + return 1; + } + addr += len; + + /* Skip over text and data and zero bss. */ + len = pexec->a_bss; + printf ("+ %x",len); + memset (KERNEL_LOAD_ADDRESS + (pexec->a_text + pexec->a_data), + 0, pexec->a_bss); + addr +=len; + + if (pexec->a_syms != 0 && !(kernel.bflags & RB_NOSYM)) { + printf (" + [ %x",pexec->a_syms); + addr += 4; /* skip over _end symbol */ + symtab = (void *)pexec->a_syms; + len = pexec->a_syms; + cnt = len; + flags = IGNORE_FILENUM ; + ret = read_tape_block(pbugargs->ctrl_lun, + pbugargs->dev_lun, &status, addr, + &cnt, blk_num, &flags, verbose); + if (ret != 0 || cnt != len) + { + printf("unable to load kernel 3\n\r"); + return 1; + } + + /* this value should have already been loaded XXX */ + esym = (void *) ((u_int)addr + pexec->a_syms); + if ((int)addr +cnt <= (int) esym) { + printf("missed loading count of symbols\n\r"); + return 1; + } + addr +=cnt ; + + + len = *esym; +#if 0 + printf("start load %x end load %x %x\n\r", addr, + len, addr +len); + printf("esym %x *esym %x\n\r",esym, len); +#endif + /* dont load tail of already loaded */ + len -= (u_int)addr - (u_int)esym; + + if (len > 0) { + printf(" + %x",*esym); + esym = (void *)(addr + len); + cnt = len; + flags = IGNORE_FILENUM ; + ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, &status, addr, + &cnt, blk_num, &flags, verbose); + if (ret != 0 || cnt != len) + { + printf("unable to load kernel 4\n\r"); + return 1; + } + addr += len; + printf(" ]"); + } else { + printf("+ %x ]",*esym); + } + esym = (int *)(((int)esym) + *esym); + + kernel.symtab = symtab; + kernel.esym = esym; + } else { + kernel.symtab = 0; + kernel.esym = 0; + } + kernel.end_loaded = (int)addr; + flags = IGNORE_FILENUM | END_OF_FILE; + cnt = 8192; + printf ("removing pad ["); + ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, &status, addr, + &cnt, blk_num, &flags, verbose); + if (ret != 0) { + printf("unable to load kernel 5\n\r"); + return 1; + } + printf (" %d ]",cnt); + + printf("]\n\r"); + } + + + kernel.entry = (void *)pexec->a_entry; + return 0; +} +loadmini(u_int addr,struct bugargs *pbugargs) +{ + int ret; + unsigned char flags; + short status = 0; + int verbose = 0; + int blk_num; + int cnt; + blk_num = 3; + /* align addr to some boundary */ +#define ALIGN_F 0x4 + addr = (u_int)((((int)addr + ALIGN_F -1)/ALIGN_F) * ALIGN_F); +#undef ALIGN_F + flags = END_OF_FILE; + cnt = 6144 * 512 ; /* some abserdly large value. (3meg) */ + printf("loading miniroot[ "); + ret = read_tape_block(4, pbugargs->dev_lun, &status, (void*)addr, + &cnt, blk_num, &flags, verbose); + if (ret != 0) { + printf("unable to load miniroot\n\r"); + return 1; + } + kernel.smini = (void *)addr; + printf("%d ]\n\r",(BUG_BLOCK_SIZE * cnt)); + kernel.emini = (void*)((u_int)addr + (BUG_BLOCK_SIZE * cnt)); + kernel.end_loaded = (u_int)kernel.emini; +} +void +parse_args(struct bugargs *pargs) +{ + char * ptr = pargs->arg_start; + char c, *name; + int howto; + howto = ( 0 | RB_DFLTROOT ); + name = NULL; + + if (pargs->arg_start != pargs->arg_end) { + while (c = *ptr) { + while (c == ' ') + c = *++ptr; + if (!c) + return; + if (c == '-') + while ((c = *++ptr) && c != ' ') { + if (c == 'a') + howto |= RB_ASKNAME; + else if (c == 'b') + howto |= RB_HALT; + else if (c == 'y') + howto |= RB_NOSYM; +#ifdef CHECKSUM + else if (c == 'c') + cflag = 1; +#endif + else if (c == 'd') + howto |= RB_KDB; + else if (c == 'm') + howto |= RB_MINIROOT; + else if (c == 'r') +/* change logic to have force root to config device UNLESS arg given */ + howto &= ~RB_DFLTROOT; + else if (c == 's') + howto |= RB_SINGLE; + } + else { + name = ptr; + while ((c = *++ptr) && c != ' '); + if (c) + *ptr++ = 0; + } + } + if (RB_NOSYM & howto) printf("RB_NOSYM\n\r"); + if (RB_AUTOBOOT & howto) printf("RB_AUTOBOOT\n\r"); + if (RB_SINGLE & howto) printf("RB_SINGLE\n\r"); + if (RB_NOSYNC & howto) printf("RB_NOSYNC\n\r"); + if (RB_HALT & howto) printf("RB_HALT\n\r"); + if (RB_DFLTROOT & howto) printf("RB_DFLTROOT\n\r"); + if (RB_KDB & howto) printf("RB_KDB\n\r"); + if (RB_RDONLY & howto) printf("RB_RDONLY\n\r"); + if (RB_DUMP & howto) printf("RB_DUMP\n\r"); + if (RB_MINIROOT & howto) printf("RB_MINIROOT\n\r"); + + } + kernel.bflags = howto; + kernel.kname = name; +} + diff --git a/sys/arch/mvme88k/stand/bootst/bootst b/sys/arch/mvme88k/stand/bootst/bootst Binary files differnew file mode 100644 index 00000000000..53c7665552c --- /dev/null +++ b/sys/arch/mvme88k/stand/bootst/bootst diff --git a/sys/arch/mvme88k/stand/bootst/bootst.bug b/sys/arch/mvme88k/stand/bootst/bootst.bug Binary files differnew file mode 100644 index 00000000000..34dbd2763ba --- /dev/null +++ b/sys/arch/mvme88k/stand/bootst/bootst.bug diff --git a/sys/arch/mvme88k/stand/bootst/bootst.c b/sys/arch/mvme88k/stand/bootst/bootst.c new file mode 100644 index 00000000000..d0dd5586a57 --- /dev/null +++ b/sys/arch/mvme88k/stand/bootst/bootst.c @@ -0,0 +1,357 @@ +#include <sys/types.h> +#include <sys/param.h> +#include <sys/reboot.h> +#include <sys/exec.h> +#include <machine/prom.h> + +#define RB_NOSYM 0x400 + +void parse_args __P((struct mvmeprom_args *pbugargs)); +int load_kern(); +int read_tape_block __P((short ctrl, short dev, short *status, + void *addr, int *cnt, int blk_num, u_char *flags, int verbose)); + +struct kernel { + void *entry; + void *symtab; + void *esym; + int bflags; + int bdev; + char *kname; + void *smini; + void *emini; + u_int end_loaded; +} kernel; + +typedef(*kernel_entry) __P((struct mvmeprom_args *, struct kernel *)); + +int +main(pbugargs) + struct mvmeprom_args *pbugargs; +{ + kernel_entry addr; + + /* + print_bugargs(pbugargs); + print_time(); + print_brdid(); + print_memory(); + */ + parse_args(pbugargs); + if (load_kern(pbugargs) == 1) { + printf("unsuccessful in loading kernel\n"); + } else { + addr = kernel.entry; + + printf("kernel loaded at %x\n", addr); + printf("kernel.entry %x\n", kernel.entry); + printf("kernel.symtab %x\n", kernel.symtab); + printf("kernel.esym %x\n", kernel.esym); + printf("kernel.bflags %x\n", kernel.bflags); + printf("kernel.bdev %x\n", kernel.bdev); + if (kernel.kname) + printf("kernel.kname <%s>\n", kernel.kname); + else + printf("kernel.kname <null>\n"); + printf("kernel.end_loaded %x\n", kernel.end_loaded); + + if (kernel.bflags & RB_MINIROOT) + loadmini(kernel.end_loaded, pbugargs); + + printf("kernel.smini %x\n", kernel.smini); + printf("kernel.emini %x\n", kernel.emini); + printf("kernel.end_loaded %x\n", kernel.end_loaded); + if (kernel.bflags & RB_HALT) + mvmeprom_return(); + if (((u_long)addr &0xf) == 0x2) { + (addr)(pbugargs, &kernel); + } else { + /* is type fixing anything like price fixing? */ + typedef (* kernel_start) __P((int, int, void *,void *, void *)); + kernel_start addr1; + addr1 = (void *)addr; + (addr1)(kernel.bflags, 0, kernel.esym, kernel.smini, kernel.emini + ); + } + + } + return (0); +} + +#define MVMEPROM_SCALE (512/MVMEPROM_BLOCK_SIZE) + +int +read_tape_block(ctrl, dev, status, addr, cnt, blk_num, flags, verbose) + short ctrl; + short dev; + short *status; + void *addr; + int *cnt; + int blk_num; + u_char *flags; + int verbose; +{ + struct mvmeprom_dskio dio; + int ret; + + dio.ctrl_lun = ctrl; + dio.dev_lun = dev; + dio.status = *status; + dio.pbuffer = addr; + dio.blk_num = blk_num; + dio.blk_cnt = *cnt / (512 / MVMEPROM_SCALE); + dio.flag = *flags; + dio.addr_mod = 0; + + if (verbose) + printf("saddr %x eaddr %x", dio.pbuffer, + (int) dio.pbuffer + (dio.blk_cnt * MVMEPROM_BLOCK_SIZE)); + ret = mvmeprom_diskrd(&dio); + + *status = dio.status; + *cnt = (dio.blk_cnt / MVMEPROM_SCALE) * 512; + if (verbose) { + printf("status %x ret %d ", *status, ret); + printf("flags %x blocks read %x cnt %x\n", + *flags, dio.blk_cnt, *cnt); + } + return (ret); +} +#ifdef DEBUG +int verbose = 1; +#else +int verbose = 0; +#endif + +int +load_kern(pbugargs) + struct mvmeprom_args *pbugargs; +{ + int ret; + char *addr; + u_char flags; + short status = 0; + int blk_num; + struct exec *pexec; + int magic; + int *esym; + int *symtab; + int cnt, len; + char buf[512]; + + blk_num = 2; + /* flags = IGNORE_FILENUM; */ + flags = 0; + cnt = 512; +printf("ctrl %x dev %x\n",pbugargs->ctrl_lun, pbugargs->dev_lun); + ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, &status, + buf, &cnt, blk_num, &flags, verbose); + if (ret != 0) { + printf("unable to load kernel 1 status %x\n", status); + return (1); + } + pexec = (struct exec *) buf; + if (N_GETMID(*pexec) != MID_M68K && + N_GETMID(*pexec) != MID_M68K4K) { + printf("invalid mid on kernel\n"); + return (1); + } + + magic = N_GETMAGIC(*pexec); + switch (magic) { + case ZMAGIC: + break; + case NMAGIC: + printf("NMAGIC not yet supported"); + case OMAGIC: + case QMAGIC: + default: + printf("Unknown or unsupported magic type <%x>\n", magic); + return (1); + } + if (magic == ZMAGIC) { + status = 0; + addr = (char *) (pexec->a_entry & ~0x0FFF); + + if ((int) pexec->a_entry != (int) addr + 0x22) { + printf("warning kernel start address not %x, %x\n", + (int) addr + 0x22, pexec->a_entry); + printf("kernel loaded at %x\n", addr); + } + bcopy(&buf, addr, 512); + /* 2nd block of exe */ + addr += 512; + + printf("text 0x%x data 0x%x bss 0x%x\n", + pexec->a_text, pexec->a_data, pexec->a_bss); + + len = (pexec->a_text - 512); /* XXX */ + len += (pexec->a_data); + + printf("loading [ %x + %x ", pexec->a_text, pexec->a_data); + + cnt = len; + flags = IGNORE_FILENUM; + ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, + &status, addr, &cnt, blk_num, &flags, verbose); + if (ret != 0 || cnt != len) { + printf("unable to load kernel 2 status %x\n", status); + return 1; + } + addr += len; + + /* Skip over text and data and zero bss. */ + len = pexec->a_bss; + printf("+ %x", len); +#ifdef DEBUG + printf("bss %x - %x\n", addr, addr + pexec->a_bss); +#endif + bzero(addr, pexec->a_bss); + addr += len; + + if (pexec->a_syms != 0 && !(kernel.bflags & RB_NOSYM)) { + printf(" + [ %x", pexec->a_syms); + addr += 4; /* skip over _end symbol */ + symtab = (void *) pexec->a_syms; + len = pexec->a_syms; + cnt = ((len + (512 - 1)) / 512) * 512; + flags = IGNORE_FILENUM; + ret = read_tape_block(pbugargs->ctrl_lun, + pbugargs->dev_lun, &status, addr, + &cnt, blk_num, &flags, verbose); + if (ret != 0 || cnt != ((len + (512 - 1)) / 512) * 512) { + printf("unable to load kernel 3\n"); + return 1; + } + /* this value should have already been loaded XXX */ + esym = (void *) ((u_int) addr + pexec->a_syms); + if ((int) addr + cnt <= (int) esym) { + printf("missed loading count of symbols\n"); + return 1; + } + addr += cnt; + + + len = *esym; +#if 0 + printf("start load %x end load %x %x\n", addr, + len, addr + len); + printf("esym %x *esym %x\n", esym, len); +#endif + /* dont load tail of already loaded */ + len -= (u_int) addr - (u_int) esym; + + if (len > 0) { + printf(" + %x", *esym); + esym = (void *) (addr + len); + cnt = ((len + (512 - 1)) / 512) * 512; + flags = IGNORE_FILENUM; + ret = read_tape_block(pbugargs->ctrl_lun, + pbugargs->dev_lun, &status, addr, + &cnt, blk_num, &flags, verbose); + if (ret != 0 || cnt != ((len + (512-1)) / 512)*512) { + printf("unable to load kernel 4\n"); + return (1); + } + addr += len; + printf(" ]"); + } else { + printf("+ %x ]", *esym); + } + esym = (int *) (((int) esym) + *esym); + + kernel.symtab = symtab; + kernel.esym = esym; + } else { + kernel.symtab = 0; + kernel.esym = 0; + } + kernel.end_loaded = (int) addr; + flags = IGNORE_FILENUM | END_OF_FILE; + cnt = 8192; + printf("removing pad ["); + ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, + &status, addr, &cnt, blk_num, &flags, verbose); + if (ret != 0) { + printf("unable to load kernel 5\n"); + return (1); + } + printf(" %d ]", cnt); + + printf("]\n"); + } + kernel.entry = (void *) pexec->a_entry; + return (0); +} + +int +loadmini(addr, pbugargs) + u_int addr; + struct mvmeprom_args *pbugargs; +{ + int cnt, ret, blk_num = 3; + short status = 0; + u_char flags; + + /* align addr to some boundary */ +#define ALIGN_F 0x4 + addr = (u_int) ((((int) addr + ALIGN_F - 1) / ALIGN_F) * ALIGN_F); +#undef ALIGN_F + flags = END_OF_FILE; + cnt = 6144 * 512; /* some abserdly large value. (3meg) */ + printf("loading miniroot[ "); + ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, + &status, (void *) addr, &cnt, blk_num, &flags, verbose); + if (ret != 0) { + printf("unable to load miniroot\n"); + return (1); + } + kernel.smini = (void *)addr; + printf("%d ]\n", cnt); + kernel.emini = (void *) ((u_int) addr + cnt); + kernel.end_loaded = (u_int) kernel.emini; + return (0); +} + +void +parse_args(pargs) + struct mvmeprom_args *pargs; +{ + char *ptr = pargs->arg_start; + char c, *name = NULL; + int howto = 0; + + if (pargs->arg_start != pargs->arg_end) { + while (c = *ptr) { + while (c == ' ') + c = *++ptr; + if (!c) + return; + if (c != '-') { + name = ptr; + while ((c = *++ptr) && c != ' '); + if (c) + *ptr++ = 0; + continue; + } + while ((c = *++ptr) && c != ' ') { + if (c == 'a') + howto |= RB_ASKNAME; + else if (c == 'b') + howto |= RB_HALT; + else if (c == 'y') + howto |= RB_NOSYM; + else if (c == 'd') + howto |= RB_KDB; + else if (c == 'm') + howto |= RB_MINIROOT; + else if (c == 'r') + howto |= RB_DFLTROOT; + else if (c == 's') + howto |= RB_SINGLE; + } + } + } + kernel.bflags = howto; + kernel.kname = name; +} diff --git a/sys/arch/mvme88k/stand/bootst/stboot b/sys/arch/mvme88k/stand/bootst/stboot Binary files differnew file mode 100644 index 00000000000..a6b19b34db4 --- /dev/null +++ b/sys/arch/mvme88k/stand/bootst/stboot diff --git a/sys/arch/mvme88k/stand/bugcrt/Makefile.inc b/sys/arch/mvme88k/stand/bugcrt/Makefile.inc new file mode 100644 index 00000000000..f2bae6c888c --- /dev/null +++ b/sys/arch/mvme88k/stand/bugcrt/Makefile.inc @@ -0,0 +1,12 @@ +BUG_CRT_DIR=${S}/arch/${MACHINE}/stand/bugcrt + +BUGCRT_DIR!= cd ${BUG_CRT_DIR}; \ + printf "xxx:\n\techo \$${.OBJDIR}\n" | ${MAKE} -r -s -f - xxx + +BUGCRT=${BUGCRT_DIR}/bugcrt.o + +$(BUGCRT): .NOTMAIN __always_make_bugcrt + @echo making sure the bugcrt is up to date... + @(cd ${BUG_CRT_DIR}; ${MAKE}) + +__always_make_bugcrt: .NOTMAIN diff --git a/sys/arch/mvme88k/stand/bugcrt/m88k/Makefile.inc b/sys/arch/mvme88k/stand/bugcrt/m88k/Makefile.inc new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/arch/mvme88k/stand/bugcrt/m88k/Makefile.inc diff --git a/sys/arch/mvme88k/stand/bugcrt/m88k/bugcrt.c b/sys/arch/mvme88k/stand/bugcrt/m88k/bugcrt.c new file mode 100644 index 00000000000..2eca49c663d --- /dev/null +++ b/sys/arch/mvme88k/stand/bugcrt/m88k/bugcrt.c @@ -0,0 +1,44 @@ +#include <sys/types.h> +#include <machine/prom.h> + +struct mvmeprom_args bugargs = { 1 }; /* not BSS */ + + asm (".text"); + asm (".long 0x003ffff8"); + asm (".long _start"); +start() +{ + register int dev_lun asm ("r2"); + register int ctrl_lun asm ("r3"); + register int flags asm ("r4"); + register int ctrl_addr asm ("r5"); + register int entry asm ("r6"); + register int conf_blk asm ("r7"); + register char *arg_start asm ("r8"); + register char *arg_end asm ("r9"); + extern int edata, end; + +asm ("# enable SFU1"); +asm (" ldcr r10,cr1"); +asm (" xor r10,r10,0x8"); +asm (" stcr r10,cr1"); + + bugargs.dev_lun = dev_lun; + bugargs.ctrl_lun = ctrl_lun; + bugargs.flags = flags; + bugargs.ctrl_addr = ctrl_addr; + bugargs.entry = entry; + bugargs.conf_blk = conf_blk; + bugargs.arg_start = arg_start; + bugargs.arg_end = arg_end; + *arg_end = 0; + + bzero(&edata, (int)&end - (int)&edata); + main(); + mvmeprom_return(); + /* NOTREACHED */ +} + +__main() +{ +} diff --git a/sys/arch/mvme88k/stand/libbug/Makefile.inc b/sys/arch/mvme88k/stand/libbug/Makefile.inc new file mode 100644 index 00000000000..dc1ad6b04c8 --- /dev/null +++ b/sys/arch/mvme88k/stand/libbug/Makefile.inc @@ -0,0 +1,12 @@ +LIB_BUG_DIR=${S}/arch/${MACHINE}/stand/libbug + +LIBBUG_DIR!= cd ${LIB_BUG_DIR}; \ + printf "xxx:\n\techo \$${.OBJDIR}\n" | ${MAKE} -r -s -f - xxx + +LIBBUG=${LIBBUG_DIR}/libbug.a + +$(LIBBUG): .NOTMAIN __always_make_libbug + @echo making sure the libbug is up to date... + @(cd ${LIB_BUG_DIR}; ${MAKE}) + +__always_make_libbug: .NOTMAIN diff --git a/sys/arch/mvme88k/stand/libbug/log1 b/sys/arch/mvme88k/stand/libbug/log1 new file mode 100644 index 00000000000..448b6b71f94 --- /dev/null +++ b/sys/arch/mvme88k/stand/libbug/log1 @@ -0,0 +1,9 @@ +delay.o delay.o +diskrd.o diskrd.o +diskwr.o diskwr.o +getbrdid.o getbrdid.o +instat.o instat.o +outln.o outln.o +outstr.o outstr.o +return.o return.o +rtc_rd.o rtc_rd.o diff --git a/sys/arch/mvme88k/stand/libbug/log2 b/sys/arch/mvme88k/stand/libbug/log2 new file mode 100644 index 00000000000..7a8950e635f --- /dev/null +++ b/sys/arch/mvme88k/stand/libbug/log2 @@ -0,0 +1,9 @@ +rtc_rd.o +return.o +outstr.o +outln.o +instat.o +getbrdid.o +diskwr.o +diskrd.o +delay.o diff --git a/sys/arch/mvme88k/stand/libbug/m88k/delay.c b/sys/arch/mvme88k/stand/libbug/m88k/delay.c new file mode 100644 index 00000000000..68b1db12106 --- /dev/null +++ b/sys/arch/mvme88k/stand/libbug/m88k/delay.c @@ -0,0 +1,15 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +/* BUG - timing routine */ +void +mvmeprom_delay(msec) + int msec; +{ + asm volatile ("or r2,r0,%0": : "r" (msec)); + MVMEPROM_CALL(MVMEPROM_DELAY); +} diff --git a/sys/arch/mvme88k/stand/libbug/m88k/diskrd.c b/sys/arch/mvme88k/stand/libbug/m88k/diskrd.c new file mode 100644 index 00000000000..bc69b365501 --- /dev/null +++ b/sys/arch/mvme88k/stand/libbug/m88k/diskrd.c @@ -0,0 +1,19 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +/* returns 0: success, nonzero: error */ +int +mvmeprom_diskrd(arg) + struct mvmeprom_dskio *arg; +{ + int ret; + + asm volatile ("or r2,r0,%0": : "r" (arg)); + MVMEPROM_CALL(MVMEPROM_DSKRD); + asm volatile ("or %0,r0,r2" : "=r" (ret)); + return (!(ret & 0x4)); +} diff --git a/sys/arch/mvme88k/stand/libbug/m88k/diskwr.c b/sys/arch/mvme88k/stand/libbug/m88k/diskwr.c new file mode 100644 index 00000000000..681f521b5b0 --- /dev/null +++ b/sys/arch/mvme88k/stand/libbug/m88k/diskwr.c @@ -0,0 +1,19 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +/* returns 0: success, nonzero: error */ +int +mvmeprom_diskwr(arg) + struct mvmeprom_dskio *arg; +{ + int ret; + + asm volatile ("or r2,r0,%0": : "r" (arg) ); + MVMEPROM_CALL(MVMEPROM_DSKWR); + asm volatile ("or %0,r0,r2" : "=r" (ret)); + return (!(ret & 0x4)); +} diff --git a/sys/arch/mvme88k/stand/libbug/m88k/getbrdid.c b/sys/arch/mvme88k/stand/libbug/m88k/getbrdid.c new file mode 100644 index 00000000000..eeda9468ab7 --- /dev/null +++ b/sys/arch/mvme88k/stand/libbug/m88k/getbrdid.c @@ -0,0 +1,17 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +/* BUG - query board routines */ +struct mvmeprom_brdid * +mvmeprom_brdid() +{ + struct mvmeprom_brdid *id; + + MVMEPROM_CALL(MVMEPROM_GETBRDID); + asm volatile ("or %0,r0,r2": "=r" (id):); + return (id); +} diff --git a/sys/arch/mvme88k/stand/libbug/m88k/instat.c b/sys/arch/mvme88k/stand/libbug/m88k/instat.c new file mode 100644 index 00000000000..0ac97fe7676 --- /dev/null +++ b/sys/arch/mvme88k/stand/libbug/m88k/instat.c @@ -0,0 +1,17 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +/* returns 0 if no characters ready to read */ +int +mvmeprom_instat() +{ + short ret; + + MVMEPROM_CALL(MVMEPROM_INSTAT); + asm volatile ("or %0,r0,r2" : "=r" (ret)); + return (!(ret & 0x4)); +} diff --git a/sys/arch/mvme88k/stand/libbug/m88k/outch.c b/sys/arch/mvme88k/stand/libbug/m88k/outch.c new file mode 100644 index 00000000000..78110e0299f --- /dev/null +++ b/sys/arch/mvme88k/stand/libbug/m88k/outch.c @@ -0,0 +1,15 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +void +mvmeprom_outchr(a) + char a; +{ + asm volatile ("or r2, r0, %0" : :"r" (a)); + BUG_CALL(_OUTCHR); +} + diff --git a/sys/arch/mvme88k/stand/libbug/m88k/outln.c b/sys/arch/mvme88k/stand/libbug/m88k/outln.c new file mode 100644 index 00000000000..ed0067e42d9 --- /dev/null +++ b/sys/arch/mvme88k/stand/libbug/m88k/outln.c @@ -0,0 +1,15 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +void +mvmeprom_outln(start, end) + char *start, *end; +{ + asm volatile ("or r2,r0,%0": : "r" (start)); + asm volatile ("or r3,r0,%0": : "r" (end)); + MVMEPROM_CALL(MVMEPROM_OUTSTRCRLF); +} diff --git a/sys/arch/mvme88k/stand/libbug/m88k/outstr.c b/sys/arch/mvme88k/stand/libbug/m88k/outstr.c new file mode 100644 index 00000000000..c9e3c355736 --- /dev/null +++ b/sys/arch/mvme88k/stand/libbug/m88k/outstr.c @@ -0,0 +1,15 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +void +mvmeprom_outstr(start, end) + char *start, *end; +{ + asm volatile ("or r2,r0,%0": : "r" (start)); + asm volatile ("or r3,r0,%0": : "r" (end)); + MVMEPROM_CALL(MVMEPROM_OUTSTR); +} diff --git a/sys/arch/mvme88k/stand/libbug/m88k/prom.h b/sys/arch/mvme88k/stand/libbug/m88k/prom.h new file mode 100644 index 00000000000..4048e86eaff --- /dev/null +++ b/sys/arch/mvme88k/stand/libbug/m88k/prom.h @@ -0,0 +1,3 @@ +#define MVMEPROM_CALL(x) \ + asm volatile ( __CONCAT("or r9,r0," __STRING(x)) ); \ + asm volatile ("tb0 0,r0,496"); diff --git a/sys/arch/mvme88k/stand/libbug/m88k/return.c b/sys/arch/mvme88k/stand/libbug/m88k/return.c new file mode 100644 index 00000000000..00206a16c48 --- /dev/null +++ b/sys/arch/mvme88k/stand/libbug/m88k/return.c @@ -0,0 +1,14 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +/* BUG - return to bug routine */ +void +mvmeprom_return() +{ + MVMEPROM_CALL(MVMEPROM_EXIT); + /*NOTREACHED*/ +} diff --git a/sys/arch/mvme88k/stand/libbug/m88k/rtc_rd.c b/sys/arch/mvme88k/stand/libbug/m88k/rtc_rd.c new file mode 100644 index 00000000000..9b32f960ea3 --- /dev/null +++ b/sys/arch/mvme88k/stand/libbug/m88k/rtc_rd.c @@ -0,0 +1,14 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +void +mvmeprom_rtc_rd(ptime) + struct mvmeprom_time *ptime; +{ + asm volatile ("or r2,r0,%0": : "r" (ptime)); + MVMEPROM_CALL(MVMEPROM_RTC_RD); +} diff --git a/sys/arch/mvme88k/stand/libsa/Makefile b/sys/arch/mvme88k/stand/libsa/Makefile new file mode 100644 index 00000000000..8aa02095e63 --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/Makefile @@ -0,0 +1,49 @@ +# $Id: Makefile,v 1.1 1997/03/03 19:30:35 rahnds Exp $ + +LIB=sa + +CLEANFILES+=SRT0.o SRT1.o + +NOPIC=nopic +NOPROFILE=noprofile + +# Logically src/sys +S=${.CURDIR}/../../../.. +DIR_SA=$S/lib/libsa +DIR_KERN=$S/lib/libkern + +SRC_net= nfs.c rpc.c net.c ether.c arp.c in_cksum.c netif.c \ + bootparam.c rarp.c + + +#SRC_sa = alloc.c bcopy.c memcpy.c close.c getfile.c open.c \ +# printf.c read.c strerror.c ufs.c globals.c lseek.c \ +# closeall.c dev.c dkcksum.c nullfs.c fstat.c + +SRC_sa = alloc.c bcopy.c close.c getfile.c open.c \ + printf.c read.c strerror.c ufs.c globals.c lseek.c \ + dev.c + +SRC_kern= ashrdi3.c bcmp.c bzero.c strcmp.c strlen.c + +SRC_here= clock.c devopen.c dvma.c \ + gets.c panic.c \ + promboot.c promcons.c + +SRCS= ${SRC_net} ${SRC_sa} ${SRC_kern} ${SRC_here} + +# DBG= -DDEBUG -DNETIF_DEBUG -DNFS_DEBUG -DRPC_DEBUG \ +# -DNET_DEBUG -DRARP_DEBUG -DETHER_DEBUG + +#DEFS= -DCOMPAT_UFS +INCL= -I. -I${S}/lib/libsa -I${S} +COPTS= #-fno-defer-pop +CFLAGS= ${COPTS} ${DEFS} ${DBG} ${INCL} + +.PATH: ${DIR_SA} ${DIR_KERN} ../../sun3 + +all: libsa.a SRT0.o SRT1.o + +install: + +.include <bsd.lib.mk> diff --git a/sys/arch/mvme88k/stand/libsa/Makefile,v b/sys/arch/mvme88k/stand/libsa/Makefile,v new file mode 100644 index 00000000000..00ad6d0e157 --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/Makefile,v @@ -0,0 +1,72 @@ +head 1.1; +access; +symbols; +locks + build:1.1; strict; +comment @# @; + + +1.1 +date 96.02.03.01.43.48; author build; state Exp; +branches; +next ; + + +desc +@back up +@ + + +1.1 +log +@Initial revision +@ +text +@# $Id: Makefile,v,v 1.1 1997/03/03 19:30:37 rahnds Exp $ + +LIB=sa + +CLEANFILES+=SRT0.o SRT1.o + +NOPIC=nopic +NOPROFILE=noprofile + +# Logically src/sys +S=${.CURDIR}/../../../.. +DIR_SA=$S/lib/libsa +DIR_KERN=$S/lib/libkern + +SRC_net= nfs.c rpc.c net.c ether.c arp.c in_cksum.c netif.c \ + bootparam.c rarp.c + + +SRC_sa = alloc.c bcopy.c memcpy.c close.c getfile.c open.c \ + printf.c read.c strerror.c ufs.c globals.c lseek.c \ + closeall.c dev.c dkcksum.c nullfs.c fstat.c + +SRC_kern= ashrdi3.c bcmp.c bzero.c strcmp.c strlen.c + +SRC_sun3= exec_sun.c + +SRC_here= clock.c devopen.c dvma.c \ + gets.c panic.c \ + promboot.c promcons.c + +SRCS= ${SRC_net} ${SRC_sa} ${SRC_kern} ${SRC_sun3} ${SRC_here} + +# DBG= -DDEBUG -DNETIF_DEBUG -DNFS_DEBUG -DRPC_DEBUG \ +# -DNET_DEBUG -DRARP_DEBUG -DETHER_DEBUG + +#DEFS= -DCOMPAT_UFS +INCL= -I. -I${S}/lib/libsa -I${S} +COPTS= #-fno-defer-pop +CFLAGS= -O2 ${COPTS} ${DEFS} ${DBG} ${INCL} + +.PATH: ${DIR_SA} ${DIR_KERN} ../../sun3 + +all: libsa.a SRT0.o SRT1.o + +install: + +.include <bsd.lib.mk> +@ diff --git a/sys/arch/mvme88k/stand/libsa/Makefile.inc b/sys/arch/mvme88k/stand/libsa/Makefile.inc new file mode 100644 index 00000000000..c402951fa76 --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/Makefile.inc @@ -0,0 +1,12 @@ +LIB_SA_DIR=${S}/arch/${MACHINE}/stand/libsa + +LIBSA_DIR!= cd ${LIB_SA_DIR}; \ + printf "xxx:\n\techo \$${.OBJDIR}\n" | ${MAKE} -r -s -f - xxx + +LIBSA=${LIBSA_DIR}/libsa.a + +$(LIBSA): .NOTMAIN __always_make_libsa + @echo making sure the libsa is up to date... + @(cd ${LIB_SA_DIR}; ${MAKE}) + +__always_make_libsa: .NOTMAIN diff --git a/sys/arch/mvme88k/stand/libsa/SRT0.S b/sys/arch/mvme88k/stand/libsa/SRT0.S new file mode 100644 index 00000000000..7156aa32830 --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/SRT0.S @@ -0,0 +1,90 @@ +| $Id: SRT0.S,v 1.1 1997/03/03 19:30:35 rahnds Exp $ + +| Copyright (c) 1996 Nivas Madhur +| Copyright (c) 1995 Theo de Raadt +| +| 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 under OpenBSD by +| Theo de Raadt for Willowglen Singapore. +| 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. +| +| Copyright (c) 1995 Gordon W. Ross +| 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. The name of the author may not be used to endorse or promote products +| derived from this software without specific prior written permission. +| 4. All advertising materials mentioning features or use of this software +| must display the following acknowledgement: +| This product includes software developed by Gordon Ross +| +| 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. + +; SRT0.S - Stand-alone Run-Time startup code, part 0 + .file "SRT0.S" + .text + .globl _stack +_stack: + .globl _start +_start: + .word __estack + .word _start + + align 8 + or.u r10, r0, hi16(_devlun) + st r2, r0, lo16(_devlun) + or.u r10, r0, hi16(_ctrlun) + st r3, r0, lo16(_ctrlun) + or.u r10, r0, hi16(_oparg) + st r8, r0, lo16(_oparg) + or.u r10, r0, hi16(_opargend) + st r9, r0, lo16(_opargend) +; enable SFU1 - 88k disables SFU1 on a reset + ldcr r10, cr1 + xor r10, r10, 0x8 + stcr r10, cr1 + +; Call the run-time startup C code, which will: +; call main & call exit - exit passes control back to +; to the Bug. + bsr __start + +; The end. diff --git a/sys/arch/mvme88k/stand/libsa/SRT1.c b/sys/arch/mvme88k/stand/libsa/SRT1.c new file mode 100644 index 00000000000..312751c6974 --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/SRT1.c @@ -0,0 +1,123 @@ +/* $Id: SRT1.c,v 1.1 1997/03/03 19:30:35 rahnds Exp $ */ + +/* + * Copyright (c) 1996 Nivas Madhur + * Copyright (c) 1995 Theo de Raadt + * + * 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 under OpenBSD by + * Theo de Raadt for Willowglen Singapore. + * 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. + * + * Copyright (c) 1995 Gordon W. Ross + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * 4. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Gordon Ross + * + * 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. + */ + +/* SRT1.c - Stand-alone Run-time startup code, part 1 */ + +#include <stdarg.h> +#include <sys/types.h> + +#include "config.h" + +extern char *edata, *end; + +int devlun = 0; +int ctrlun = 0; +int oparg = 0; +int opargend = 0; + +getvbr() +{ + asm volatile ("ldcr r2, cr7"); +} + +void +exit() +{ + /* + * Return to the Bug + */ + + asm volatile ("or r9, r0, 0x63; tb0 0, r0, 496"); + /* NOTREACHED */ +} + +struct brdid brdid; +int cputyp; + +/* + * This is called by SRT0.S + * to do final prep for main + */ +_start() +{ + struct brdid *p; + + /* Clear BSS */ + + bzero(edata, end - edata); + + asm volatile("or r9, r0, 0x70\n + tb0 0, r0, 496\n + st r2, %0" : "=m" (p)); + + bcopy(p, &brdid, sizeof brdid); + cputyp = brdid.model; + + main(0); + exit(); +} + +/* + * Boot programs in C++ ? Not likely! + */ +__main() +{} diff --git a/sys/arch/mvme88k/stand/libsa/bug.c b/sys/arch/mvme88k/stand/libsa/bug.c new file mode 100644 index 00000000000..e0ac46017bf --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/bug.c @@ -0,0 +1,136 @@ +/* + * Copyright (c) 1995 Theo de Raadt + * 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 Theo de Raadt + * 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. + * + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +#define MVMEPROM_CALL(x) \ + asm volatile (__CONCAT("trap #15; .short ", __STRING(x)) ) + +/* returns 0 if no characters ready to read */ +int +mvmeprom_instat() +{ + u_short ret; + + MVMEPROM_CALL(MVMEPROM_INSTAT); + asm volatile ("movew ccr,%0": "=d" (ret)); + return (!(ret & 0x4)); +} + +void +mvmeprom_outstr(start, end) + char *start, *end; +{ + asm volatile ("movl %0, sp@-" : "=a" (start)); + asm volatile ("movl %0, sp@-" : "=a" (end)); + MVMEPROM_CALL(MVMEPROM_OUTSTR); +} + +void +mvmeprom_outln(start, end) + char *start, *end; +{ + asm volatile ("movl %0, sp@-" : "=a" (start)); + asm volatile ("movl %0, sp@-" : "=a" (end)); + MVMEPROM_CALL(MVMEPROM_OUTSTRCRLF); +} + +/* returns 0: success, nonzero: error */ +int +mvmeprom_diskrd(arg) + struct mvmeprom_dskio *arg; +{ + int ret; + + asm volatile ("movel %0, sp@-"::"d" (arg)); + MVMEPROM_CALL(MVMEPROM_DSKRD); + asm volatile ("movew ccr,%0": "=d" (ret)); + return (!(ret & 0x4)); +} + +/* returns 0: success, nonzero: error */ +int +mvmeprom_diskwr(arg) + struct mvmeprom_dskio *arg; +{ + int ret; + + asm volatile ("movel %0, sp@-"::"d" (arg)); + MVMEPROM_CALL(MVMEPROM_DSKWR); + asm volatile ("movew ccr,%0": "=d" (ret)); + return (!(ret & 0x4)); +} + +#ifdef NOTYET +mvmeprom_diskcfig() {} +mvmeprom_diskfmt(){} +mvmeprom_diskctrl(){} +#endif + +/* BUG - timing routine */ +void +mvmeprom_delay(msec) + int msec; +{ + asm volatile ("movel %0,sp@-" : :"d" (msec)); + MVMEPROM_CALL(MVMEPROM_DELAY); +} + +/* BUG - return to bug routine */ +void +mvmeprom_return() +{ + MVMEPROM_CALL(MVMEPROM_EXIT); + /*NOTREACHED*/ +} + +/* BUG - query board routines */ +struct mvmeprom_brdid * +mvmeprom_getbrdid() +{ + struct mvmeprom_brdid *id; + + asm volatile ("clrl sp@-"); + MVMEPROM_CALL(MVMEPROM_GETBRDID); + asm volatile ("movel sp@+,%0": "=d" (id):); + return (id); +} + +void +mvmeprom_rtc_rd(ptime) + struct mvmeprom_time *ptime; +{ + asm volatile ("movel %0,sp@-" : :"a" (ptime)); + MVMEPROM_CALL(MVMEPROM_RTC_RD); +} diff --git a/sys/arch/mvme88k/stand/libsa/clock.c b/sys/arch/mvme88k/stand/libsa/clock.c new file mode 100644 index 00000000000..683bd48f849 --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/clock.c @@ -0,0 +1,79 @@ +#include <sys/types.h> + +#include "clockreg.h" +#include "config.h" +#include "clock.h" + +/* + * BCD to decimal and decimal to BCD. + */ +#define FROMBCD(x) (((x) >> 4) * 10 + ((x) & 0xf)) +#define TOBCD(x) (((x) / 10 * 16) + ((x) % 10)) + +#define SECDAY (24 * 60 * 60) +#define SECYR (SECDAY * 365) +#define LEAPYEAR(y) (((y) & 3) == 0) + +/* + * This code is defunct after 2068. + * Will Unix still be here then?? + */ +const short dayyr[12] = +{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; + +static u_long +chiptotime(sec, min, hour, day, mon, year) + register int sec, min, hour, day, mon, year; +{ + register int days, yr; + + sec = FROMBCD(sec); + min = FROMBCD(min); + hour = FROMBCD(hour); + day = FROMBCD(day); + mon = FROMBCD(mon); + year = FROMBCD(year) + YEAR0; + if (year < 70) + year = 70; + + /* simple sanity checks */ + if (year < 70 || mon < 1 || mon > 12 || day < 1 || day > 31) + return (0); + days = 0; + for (yr = 70; yr < year; yr++) + days += LEAPYEAR(yr) ? 366 : 365; + days += dayyr[mon - 1] + day - 1; + if (LEAPYEAR(yr) && mon > 2) + days++; + /* now have days since Jan 1, 1970; the rest is easy... */ + return (days * SECDAY + hour * 3600 + min * 60 + sec); +} + +time_t +getsecs() +{ + extern int cputyp; + register struct clockreg *cl; + int sec, min, hour, day, mon, year; + + if (cputyp == CPU_147) + cl = (struct clockreg *) CLOCK_ADDR_147; + else + cl = (struct clockreg *) CLOCK_ADDR_16x; + + cl->cl_csr |= CLK_READ; /* enable read (stop time) */ + sec = cl->cl_sec; + min = cl->cl_min; + hour = cl->cl_hour; + day = cl->cl_mday; + mon = cl->cl_month; + year = cl->cl_year; + cl->cl_csr &= ~CLK_READ;/* time wears on */ + return (chiptotime(sec, min, hour, day, mon, year)); +} + +int +getticks() +{ + return getsecs() * 100; +} diff --git a/sys/arch/mvme88k/stand/libsa/clock.h b/sys/arch/mvme88k/stand/libsa/clock.h new file mode 100644 index 00000000000..d61bc9b03b8 --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/clock.h @@ -0,0 +1,6 @@ + +extern int hz; + +time_t getsecs(); +int getticks(); + diff --git a/sys/arch/mvme88k/stand/libsa/clockreg.h b/sys/arch/mvme88k/stand/libsa/clockreg.h new file mode 100644 index 00000000000..7eb7eba2b81 --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/clockreg.h @@ -0,0 +1,71 @@ +/* $Id: clockreg.h,v 1.1 1997/03/03 19:30:37 rahnds Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Lawrence Berkeley Laboratory. + * + * 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 University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)clockreg.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * Mostek MK48T02 clock. + */ +struct clockreg { + volatile u_char cl_csr; /* control register */ + volatile u_char cl_sec; /* seconds (0..59; BCD) */ + volatile u_char cl_min; /* minutes (0..59; BCD) */ + volatile u_char cl_hour;/* hour (0..23; BCD) */ + volatile u_char cl_wday;/* weekday (1..7) */ + volatile u_char cl_mday;/* day in month (1..31; BCD) */ + volatile u_char cl_month; /* month (1..12; BCD) */ + volatile u_char cl_year;/* year (0..99; BCD) */ +}; +/* bits in cl_csr */ +#define CLK_WRITE 0x80 /* want to write */ +#define CLK_READ 0x40 /* want to read (freeze clock) */ + +/* + * Sun chose the year `68' as their base count, so that + * cl_year==0 means 1968. + */ +#define YEAR0 68 + +#define CLOCK_ADDR_147 (0xfffe07f8) /* PA of clock */ +#define CLOCK_ADDR_16x (0xfffc1ff8) /* PA of clock */ diff --git a/sys/arch/mvme88k/stand/libsa/config.h b/sys/arch/mvme88k/stand/libsa/config.h new file mode 100644 index 00000000000..0aad19e505f --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/config.h @@ -0,0 +1,66 @@ +/* $Id: config.h,v 1.1 1997/03/03 19:30:37 rahnds Exp $ */ + +/* + * Copyright (c) 1995 Theo de Raadt + * 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 Theo de Raadt + * 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. + */ + +/* configuration information for base-line code */ + +#define ETHER_ADDR_147 (0xfffe0778) +#define ETHER_ADDR_16X (0xfffc0000+7980) +#define ERAM_ADDR (0xfffe0774) +#define LANCE_REG_ADDR (0xfffe1800) +#define INTEL_REG_ADDR (0xfff46000) + +#define CPU_147 0x147 +#define CPU_162 0x162 +#define CPU_167 0x167 +#define CPU_172 0x172 +#define CPU_177 0x177 + +struct brdid { + u_long eye_catcher; + u_char rev; + u_char month; + u_char day; + u_char year; + u_short size; + u_short rsv1; + u_short model; + u_short suffix; + u_short options; + u_char family; + u_char cpu; + u_short ctrlun; + u_short devlun; + u_short devtype; + u_short devnum; + u_long bug; +}; diff --git a/sys/arch/mvme88k/stand/libsa/dev_disk.c b/sys/arch/mvme88k/stand/libsa/dev_disk.c new file mode 100644 index 00000000000..65c1db4ac64 --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/dev_disk.c @@ -0,0 +1,132 @@ +/* $Id: dev_disk.c,v 1.1 1997/03/03 19:30:36 rahnds 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. + */ + +/* + * This module implements a "raw device" interface suitable for + * use by the stand-alone I/O library UFS file-system code, and + * possibly for direct access (i.e. boot from tape). + * + * The implementation is deceptively simple because it uses the + * drivers provided by the Sun PROM monitor. Note that only the + * PROM driver used to load the boot program is available here. + */ + +#include <sys/types.h> +#include <machine/mon.h> +#include <machine/saio.h> + +#include "stand.h" + +#include "dvma.h" +#include "promdev.h" + +int +disk_open(f, devname) + struct open_file *f; + char *devname; /* Device part of file name (or NULL). */ +{ + struct saioreq *sip; + int error; + +#ifdef DEBUG_PROM + printf("disk_open: %s\n", devname); +#endif + + if ((error = prom_iopen(&sip)) != 0) + return (error); + + f->f_devdata = sip; + return 0; +} + +int +disk_close(f) + struct open_file *f; +{ + struct saioreq *sip; + + sip = f->f_devdata; + prom_iclose(sip); + f->f_devdata = NULL; + return 0; +} + +int +disk_strategy(devdata, flag, dblk, size, buf, rsize) + void *devdata; + int flag; + daddr_t dblk; + u_int size; + char *buf; + u_int *rsize; +{ + struct saioreq *si; + struct boottab *ops; + char *dmabuf; + int si_flag, xcnt; + + si = devdata; + ops = si->si_boottab; + +#ifdef DEBUG_PROM + printf("disk_strategy: size=%d dblk=%d\n", size, dblk); +#else + twiddle(); +#endif + + dmabuf = dvma_mapin(buf, size); + + si->si_bn = dblk; + si->si_ma = dmabuf; + si->si_cc = size; + + si_flag = (flag == F_READ) ? SAIO_F_READ : SAIO_F_WRITE; + xcnt = (*ops->b_strategy)(si, si_flag); + dvma_mapout(dmabuf, size); + +#ifdef DEBUG_PROM + printf("disk_strategy: xcnt = %x\n", xcnt); +#endif + + if (xcnt <= 0) + return (EIO); + + *rsize = xcnt; + return (0); +} + +int +disk_ioctl() +{ + return EIO; +} + diff --git a/sys/arch/mvme88k/stand/libsa/dev_disk.h b/sys/arch/mvme88k/stand/libsa/dev_disk.h new file mode 100644 index 00000000000..9f05f74bd82 --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/dev_disk.h @@ -0,0 +1,6 @@ + +int disk_open __P((struct open_file *, ...)); +int disk_close __P((struct open_file *)); +int disk_strategy __P((void *, int, daddr_t, u_int, char *, u_int *)); +int disk_ioctl(); + diff --git a/sys/arch/mvme88k/stand/libsa/devopen.c b/sys/arch/mvme88k/stand/libsa/devopen.c new file mode 100644 index 00000000000..92c083983cb --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/devopen.c @@ -0,0 +1,32 @@ + +#include <sys/param.h> +#include <stand.h> +#include "promboot.h" + +/* + * Open the device named by the combined device/file name + * given as the "fname" arg, something like: "sd()bsd" + * + * However, Sun PROMs don't really let you choose which + * device you will talk to. You can only open the device + * that was used to load the boot program. Therefore, we + * do not accept a "device" part in the "fname" string. + * Pass the PROM device name to open in case it needs it. + */ +int +devopen(f, fname, file) + struct open_file *f; + const char *fname; + char **file; +{ + struct devsw *dp; + char *cp, *path, *devname; + int error; + + *file = (char*)fname; + dp = &devsw[0]; + f->f_dev = dp; + error = (*dp->dv_open)(f, prom_bootdev); + + return (error); +} diff --git a/sys/arch/mvme88k/stand/libsa/dvma.c b/sys/arch/mvme88k/stand/libsa/dvma.c new file mode 100644 index 00000000000..11526106c2a --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/dvma.c @@ -0,0 +1,68 @@ + +/* + * The easiest way to deal with the need for DVMA mappings is + * to just map the first four megabytes of RAM into DVMA space. + * That way, dvma_mapin can just compute the DVMA alias address, + * and dvma_mapout does nothing. + */ + +#include <sys/param.h> + +#define DVMA_BASE 0x00000000 +#define DVMA_MASK 0x00ffFFff +#define DVMA_MAPLEN 0x400000 /* 4 MB */ + +void +dvma_init() +{ +#if 0 + int segva, sme; + + for (segva = 0; segva < DVMA_MAPLEN; segva += NBSG) { + sme = get_segmap(segva); + set_segmap((DVMA_BASE | segva), sme); + } +#endif +} + +/* Convert a local address to a DVMA address. */ +char * +dvma_mapin(char *addr, int len) +{ + int va = (int)addr; + + va |= DVMA_BASE; + return ((char *) va); +} + +/* Convert a DVMA address to a local address. */ +char * +dvma_mapout(char *dmabuf, int len) +{ + if (dmabuf < (char*)DVMA_BASE) + panic("dvma_mapout"); + return (dmabuf - DVMA_BASE); +} + +extern char *alloc(int len); +char * +dvma_alloc(int len) +{ + char *mem; + + mem = alloc(len); + if (!mem) + return(mem); + return(dvma_mapin(mem, len)); +} + +extern void free(void *ptr, int len); +void +dvma_free(char *dvma, int len) +{ + char *mem; + + mem = dvma_mapout(dvma, len); + if (mem) + free(mem, len); +} diff --git a/sys/arch/mvme88k/stand/libsa/dvma.h b/sys/arch/mvme88k/stand/libsa/dvma.h new file mode 100644 index 00000000000..2b8be37cbe0 --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/dvma.h @@ -0,0 +1,6 @@ + +char * dvma_mapin(char *pkt, int len); +void dvma_mapout(char *dmabuf, int len); + +char * dvma_alloc(int len); + diff --git a/sys/arch/mvme88k/stand/libsa/exec_sun.c b/sys/arch/mvme88k/stand/libsa/exec_sun.c new file mode 100644 index 00000000000..5708b413541 --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/exec_sun.c @@ -0,0 +1,212 @@ +/* $Id: exec_sun.c,v 1.1 1997/03/03 19:30:36 rahnds Exp $ */ + +/*- + * Copyright (c) 1995 Theo de Raadt + * 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 Theo de Raadt + * 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. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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 <a.out.h> + +#include "stand.h" + +extern int debug; + +extern u_int bootdev; + +/*ARGSUSED*/ +exec_sun(file, loadaddr, howto) + char *file; + char *loadaddr; + int howto; +{ + register int io; + struct exec x; + int cc, magic; + void (*entry)(); + register char *cp; + register int *ip; + int textlen; + +#ifdef DEBUG + printf("exec_sun: file=%s loadaddr=0x%x\n", file, loadaddr); +#endif + + io = open(file, 0); + if (io < 0) + return(-1); + + /* + * Read in the exec header, and validate it. + */ + if (read(io, (char *)&x, sizeof(x)) != sizeof(x)) + goto shread; + if (N_BADMAG(x)) { + errno = EFTYPE; + goto closeout; + } + + cp = loadaddr; + textlen = x.a_text; + magic = N_GETMAGIC(x); + if (magic == ZMAGIC) { + cp += sizeof(x); + textlen -= sizeof(x); + } + entry = (void (*)())cp; + + /* + * Leave a copy of the exec header before the text. + * The sun3 kernel uses this to verify that the + * symbols were loaded by this boot program. + */ + bcopy(&x, cp - sizeof(x), sizeof(x)); + + /* + * Read in the text segment. + */ + printf("%x", x.a_text); + if (read(io, cp, textlen) != textlen) + goto shread; + cp += textlen; + + /* + * NMAGIC may have a gap between text and data. + */ + if (magic == NMAGIC) { + register int mask = N_PAGSIZ(x) - 1; + while ((int)cp & mask) + *cp++ = 0; + } + + /* + * Read in the data segment. + */ + printf("+%x", x.a_data); + if (read(io, cp, x.a_data) != x.a_data) + goto shread; + cp += x.a_data; + + /* + * Zero out the BSS section. + * (Kernel does not do it itself) + */ + printf("+%x", x.a_bss); + cc = x.a_bss; + while ((int)cp & 3) { + *cp++ = 0; + --cc; + } + ip = (int *)cp; + cp += cc; + while ((char *)ip < cp) + *ip++ = 0; + + /* + * Read in the symbol table and strings. + * (Always set the symtab size word.) + */ + *ip++ = x.a_syms; + cp = (char *)ip; + + if (x.a_syms > 0) { + + /* Symbol table and string table length word. */ + cc = x.a_syms; + printf("+[%x", cc); + cc += sizeof(int); /* strtab length too */ + if (read(io, cp, cc) != cc) + goto shread; + cp += x.a_syms; + ip = (int *)cp; /* points to strtab length */ + cp += sizeof(int); + + /* String table. Length word includes itself. */ + cc = *ip; + printf("+%x]", cc); + cc -= sizeof(int); + if (cc <= 0) + goto shread; + if (read(io, cp, cc) != cc) + goto shread; + cp += cc; + } + printf("=%x\n", cp - loadaddr); + close(io); + + if (debug) { + printf("Debug mode - enter c to continue\n"); + asm(" trap #0"); + } + + printf("Starting program at 0x%x\n", (int)entry); + (*entry)(howto, bootdev, cp, 0, 0); + panic("exec returned"); + +shread: + printf("exec: short read\n"); + errno = EIO; +closeout: + close(io); + return(-1); +} diff --git a/sys/arch/mvme88k/stand/libsa/gets.c b/sys/arch/mvme88k/stand/libsa/gets.c new file mode 100644 index 00000000000..071acc0d9fa --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/gets.c @@ -0,0 +1,141 @@ +/* $Id: gets.c,v 1.1 1997/03/03 19:30:35 rahnds Exp $ */ + +/*- + * Copyright (c) 1995 Theo de Raadt + * 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 Theo de Raadt + * 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. + * + * Copyright (c) 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)gets.c 8.1 (Berkeley) 6/11/93 + */ + +#include "stand.h" + +/* + * This implementation assumes that getchar() does echo, because + * on some machines, it is hard to keep echo from being done. + * Those that need it can do echo in their getchar() function. + * + * Yes, the code below will echo CR, DEL, and other control chars, + * but sending CR or DEL here is harmless. All the other editing + * characters will be followed by a newline, so it doesn't matter. + * (Most terminals will not show them anyway.) + */ + +void +gets(buf) + char *buf; +{ + register int c; + register char *lp; + +top: + lp = buf; + + for (;;) { + c = getchar() & 0177; + + putchar(c); + + switch (c) { + + default: + *lp++ = c; + continue; + + case '\177': + putchar('\b'); + /* fall through */ + case '\b': + putchar(' '); + putchar('\b'); + /* fall through */ + case '#': + if (lp > buf) + lp--; + continue; + + /* + * This is not very useful in a boot program. + * (It costs you 52 bytes on m68k, gcc -O3). + */ + case 'r'&037: { + register char *p; + putchar('\n'); + for (p = buf; p < lp; ++p) + putchar(*p); + continue; + } + + case '@': + case 'u'&037: + case 'w'&037: + putchar('\n'); + goto top; + + case '\r': + putchar('\n'); + /* fall through */ + case '\n': + *lp = '\0'; + return; + + } /* switch */ + } + /*NOTREACHED*/ +} diff --git a/sys/arch/mvme88k/stand/libsa/log1 b/sys/arch/mvme88k/stand/libsa/log1 new file mode 100644 index 00000000000..17047779eef --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/log1 @@ -0,0 +1,130 @@ +nfs.o nfs.o +rpc.o rpc.o +net.o net.o +ether.o ether.o +arp.o arp.o +in_cksum.o in_cksum.o +netif.o netif.o +bootparam.o bootparam.o +rarp.o rarp.o +alloc.o alloc.o +bcopy.o bcopy.o +memcpy.o memcpy.o +close.o close.o +getfile.o getfile.o +open.o open.o +printf.o printf.o +read.o read.o +strerror.o strerror.o +ufs.o ufs.o +globals.o globals.o +lseek.o lseek.o +closeall.o closeall.o +dev.o dev.o +dkcksum.o dkcksum.o +nullfs.o nullfs.o +fstat.o fstat.o +ashrdi3.o ashrdi3.o +bcmp.o bcmp.o +bzero.o bzero.o +strcmp.o strcmp.o +strlen.o strlen.o +exec_sun.o exec_sun.o +clock.o clock.o +devopen.o devopen.o +dvma.o dvma.o +gets.o gets.o +panic.o panic.o +promboot.o promboot.o +promcons.o promcons.o +ufs.o ashrdi3.o +dvma.o alloc.o +nfs.o alloc.o +ufs.o alloc.o +net.o arp.o +net.o arp.o +arp.o globals.o +ether.o globals.o +rarp.o globals.o +arp.o bcmp.o +ether.o bcmp.o +rarp.o bcmp.o +arp.o bcopy.o +bootparam.o bcopy.o +ether.o bcopy.o +exec_sun.o bcopy.o +memcpy.o bcopy.o +net.o bcopy.o +nfs.o bcopy.o +rarp.o bcopy.o +ufs.o bcopy.o +arp.o bzero.o +net.o bzero.o +netif.o bzero.o +nfs.o bzero.o +rarp.o bzero.o +rpc.o bzero.o +ufs.o bzero.o +closeall.o close.o +exec_sun.o close.o +open.o devopen.o +dvma.o alloc.o +nfs.o alloc.o +ufs.o alloc.o +gets.o promcons.o +getfile.o gets.o +net.o clock.o +net.o in_cksum.o +arp.o net.o +ether.o netif.o +ether.o netif.o +net.o globals.o +rarp.o globals.o +exec_sun.o open.o +getfile.o open.o +arp.o panic.o +exec_sun.o panic.o +net.o panic.o +netif.o panic.o +arp.o printf.o +bootparam.o printf.o +exec_sun.o printf.o +getfile.o printf.o +net.o printf.o +netif.o printf.o +nfs.o printf.o +panic.o printf.o +rarp.o printf.o +rpc.o printf.o +gets.o promcons.o +printf.o promcons.o +exec_sun.o read.o +arp.o ether.o +net.o ether.o +rarp.o ether.o +rpc.o net.o +bootparam.o rpc.o +nfs.o rpc.o +bootparam.o rpc.o +bootparam.o rpc.o +bootparam.o rpc.o +nfs.o rpc.o +arp.o ether.o +net.o ether.o +rarp.o ether.o +arp.o net.o +rarp.o net.o +rpc.o net.o +rpc.o net.o +bootparam.o netif.o +nfs.o netif.o +rarp.o netif.o +strerror.o printf.o +ufs.o strcmp.o +rpc.o strerror.o +bootparam.o strlen.o +nfs.o strlen.o +ufs.o strlen.o +nfs.o printf.o +read.o printf.o +ufs.o printf.o diff --git a/sys/arch/mvme88k/stand/libsa/log2 b/sys/arch/mvme88k/stand/libsa/log2 new file mode 100644 index 00000000000..31ecde33da0 --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/log2 @@ -0,0 +1,39 @@ +promboot.o +dvma.o +exec_sun.o +fstat.o +nullfs.o +dkcksum.o +dev.o +closeall.o +lseek.o +ufs.o +read.o +getfile.o +close.o +memcpy.o +rarp.o +bootparam.o +nfs.o +gets.o +strlen.o +strcmp.o +ashrdi3.o +open.o +alloc.o +rpc.o +devopen.o +strerror.o +arp.o +net.o +clock.o +in_cksum.o +ether.o +bcmp.o +globals.o +bcopy.o +netif.o +panic.o +bzero.o +printf.o +promcons.o diff --git a/sys/arch/mvme88k/stand/libsa/netif_sun.c b/sys/arch/mvme88k/stand/libsa/netif_sun.c new file mode 100644 index 00000000000..5201318a14a --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/netif_sun.c @@ -0,0 +1,284 @@ +/* $Id: netif_sun.c,v 1.1 1997/03/03 19:30:36 rahnds Exp $ */ + +/* + * Copyright (c) 1995 Gordon W. Ross + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * 4. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Gordon W. Ross + * + * 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. + */ + +/* + * The Sun PROM has a fairly general set of network drivers, + * so it is easiest to just replace the netif module with + * this adaptation to the PROM network interface. + */ + +#include <sys/param.h> +#include <sys/socket.h> +#include <string.h> +#include <time.h> + +#include <net/if.h> + +#include <netinet/in.h> +#include <netinet/if_ether.h> +#include <netinet/in_systm.h> + +#include <machine/control.h> +#include <machine/idprom.h> +#include <machine/mon.h> +#include <machine/saio.h> + +#include "stand.h" +#include "net.h" +#include "netif.h" + +#include "clock.h" +#include "dvma.h" +#include "promdev.h" + +static struct netif netif_prom; + +#ifdef NETIF_DEBUG +int netif_debug; +#endif + +struct iodesc sockets[SOPEN_MAX]; + +struct iodesc * +socktodesc(sock) + int sock; +{ + if (sock != 0) { + return(NULL); + } + return (sockets); +} + +int +netif_open(machdep_hint) + void *machdep_hint; +{ + struct saioreq *si; + struct iodesc *io; + int fd, error; + + /* find a free socket */ + io = sockets; + if (io->io_netif) { +#ifdef DEBUG + printf("netif_open: device busy\n"); +#endif + return (-1); + } + bzero(io, sizeof(*io)); + + /* + * Note: Sun PROMs will do RARP on open, but does not tell + * you the IP address it gets, so it is just noise to us... + */ + if ((error = prom_iopen(&si)) != 0) { +#ifdef DEBUG + printf("netif_open: prom_iopen, error=%d\n", error); +#endif + return (-1); + } + if (si->si_sif == NULL) { +#ifdef DEBUG + printf("netif_open: not a network device\n"); +#endif + prom_iclose(si); + return (-1); + } + + netif_prom.devdata = si; + io->io_netif = &netif_prom; + + /* Put our ethernet address in io->myea */ + sun3_getether(io->myea); + + return(0); +} + +int +netif_close(fd) + int fd; +{ + struct iodesc *io; + struct netif *ni; + + if (fd != 0) { + errno = EBADF; + return(-1); + } + + io = sockets; + ni = io->io_netif; + if (ni != NULL) { + prom_iclose(ni->devdata); + ni->devdata = NULL; + io->io_netif = NULL; + } + return(0); +} + +/* + * Send a packet. The ether header is already there. + * Return the length sent (or -1 on error). + */ +int +netif_put(desc, pkt, len) + struct iodesc *desc; + void *pkt; + int len; +{ + struct saioreq *si; + struct saif *sif; + char *dmabuf; + int rv, sendlen; + +#ifdef NETIF_DEBUG + if (netif_debug) { + struct ether_header *eh; + + printf("netif_put: desc=0x%x pkt=0x%x len=%d\n", + desc, pkt, len); + eh = pkt; + printf("dst: %s ", ether_sprintf(eh->ether_dhost)); + printf("src: %s ", ether_sprintf(eh->ether_shost)); + printf("type: 0x%x\n", eh->ether_type & 0xFFFF); + } +#endif + + si = desc->io_netif->devdata; + sif = si->si_sif; + sendlen = len; + if (sendlen < 60) { + sendlen = 60; +#ifdef NETIF_DEBUG + printf("netif_put: length padded to %d\n", sendlen); +#endif + } + +#ifdef PARANOID + if (sif == NULL) + panic("netif_put: no saif ptr\n"); +#endif + + dmabuf = dvma_mapin(pkt, sendlen); + rv = sif->sif_xmit(si->si_devdata, dmabuf, sendlen); + dvma_mapout(dmabuf, sendlen); + +#ifdef NETIF_DEBUG + if (netif_debug) + printf("netif_put: xmit returned %d\n", rv); +#endif + if (rv == 0) rv = len; + else rv = -1; + + return rv; +} + +/* + * Receive a packet, including the ether header. + * Return the total length received (or -1 on error). + */ +int +netif_get(desc, pkt, maxlen, timo) + struct iodesc *desc; + void *pkt; + int maxlen; + time_t timo; +{ + struct saioreq *si; + struct saif *sif; + char *dmabuf; + int tick0, tmo_ticks; + int len; + +#ifdef NETIF_DEBUG + if (netif_debug) + printf("netif_get: pkt=0x%x, maxlen=%d, tmo=%d\n", + pkt, maxlen, timo); +#endif + + si = desc->io_netif->devdata; + sif = si->si_sif; + +#ifdef PARANOID + if (sif == NULL) + panic("netif_get: no saif ptr\n"); +#endif + + tmo_ticks = timo * hz; + tick0 = getticks(); + + dmabuf = dvma_mapin(pkt, maxlen); + do len = sif->sif_poll(si->si_devdata, dmabuf); + while ((len == 0) && ((getticks() - tick0) < tmo_ticks)); + dvma_mapout(dmabuf, maxlen); + +#ifdef NETIF_DEBUG + if (netif_debug) + printf("netif_get: received len=%d\n", len); +#endif + + if (len < 12) + return -1; + +#ifdef NETIF_DEBUG + if (netif_debug) { + struct ether_header *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 + + return len; +} + +static struct idprom sun3_idprom; + +sun3_getether(ea) + u_char *ea; +{ + u_char *src, *dst; + int len, x; + + if (sun3_idprom.idp_format == 0) { + dst = (char*)&sun3_idprom; + src = (char*)IDPROM_BASE; + len = IDPROM_SIZE; + do { + x = get_control_byte(src++); + *dst++ = x; + } while (--len > 0); + } + MACPY(sun3_idprom.idp_etheraddr, ea); +} + diff --git a/sys/arch/mvme88k/stand/libsa/panic.c b/sys/arch/mvme88k/stand/libsa/panic.c new file mode 100644 index 00000000000..f7c83a6d8e7 --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/panic.c @@ -0,0 +1,31 @@ + +#include <stdarg.h> +#include "stand.h" + +extern volatile void abort(); +extern int _estack[]; + +__dead void +panic(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + printf(fmt, ap); + printf("\n"); + va_end(ap); + stackdump(0); + abort(); +} + +stackdump(dummy) + int dummy; +{ + int *ip; + + printf("stackdump:\n"); + for (ip = &dummy; ip < _estack; ip += 4) { + printf("%x: %x %x %x %x\n", + (int)ip, ip[0], ip[1], ip[2], ip[3]); + } +} diff --git a/sys/arch/mvme88k/stand/libsa/promboot.c b/sys/arch/mvme88k/stand/libsa/promboot.c new file mode 100644 index 00000000000..fc4aea53e82 --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/promboot.c @@ -0,0 +1,93 @@ +/* $Id: promboot.c,v 1.1 1997/03/03 19:30:36 rahnds Exp $ */ + +/* + * Copyright (c) 1995 Theo de Raadt + * 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 Theo de Raadt + * 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 <sys/reboot.h> +#include "stand.h" +#include "promboot.h" + +char prom_bootdev[32]; +char prom_bootfile[32]; +int prom_boothow; +int debug; + +void +prom_get_boot_info() +{ + char c, *src, *dst; + extern int devlun, ctrlun; + extern char *oparg, *opargend; + +#ifdef DEBUG + printf("prom_get_boot_info\n"); +#endif + + /* Get kernel filename */ + src = oparg; + while (src && (*src == ' ' || *src == '\t')) + src++; + + dst = prom_bootfile; + if (src && *src != '-') { + while (src && *src) { + if (*src == ' ' || *src == '\t') + break; + *dst++ = *src++; + } + } + *dst = '\0'; + + /* Get boothowto flags */ + while (src && (*src == ' ' || *src == '\t')) + src++; + if (src && (*src == '-')) { + while (*src) { + switch (*src++) { + case 'a': + prom_boothow |= RB_ASKNAME; + break; + case 's': + prom_boothow |= RB_SINGLE; + break; + case 'd': + prom_boothow |= RB_KDB; + debug = 1; + break; + } + } + } +#ifdef DEBUG + printf("promboot: device=\"%s\" file=\"%s\" how=0x%x\n", + prom_bootdev, prom_bootfile, prom_boothow); +#endif +} diff --git a/sys/arch/mvme88k/stand/libsa/promboot.h b/sys/arch/mvme88k/stand/libsa/promboot.h new file mode 100644 index 00000000000..86b5aace21c --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/promboot.h @@ -0,0 +1,5 @@ + +extern char prom_bootdev[]; +extern char prom_bootfile[]; +extern int prom_boothow; + diff --git a/sys/arch/mvme88k/stand/libsa/promcons.c b/sys/arch/mvme88k/stand/libsa/promcons.c new file mode 100644 index 00000000000..77ece569969 --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/promcons.c @@ -0,0 +1,71 @@ +/* $Id: promcons.c,v 1.1 1997/03/03 19:30:36 rahnds Exp $ */ + +/* + * Copyright (c) 1996 Nivas Madhur + * Copyright (c) 1995 Theo de Raadt + * 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 Theo de Raadt + * 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 <stdarg.h> +#include <sys/types.h> + +int +getchar() +{ + char c; + + __asm volatile("or r9, r0, 0\n + tb0 0, r0, 496\n + st.b r2, %0" : "=m" (c)); + return (c); +} + +peekchar() +{ + int have = 0; + + __asm volatile("or r9, r0, 1\n + tb0 0, r0, 496\n + bb1 2, r2, 1f\n + or r2,r0, 1\n + st r2, %0\n1:" : "=m" (have) :); + return (have); +} + +void +putchar(c) + int c; +{ + if (c == '\n') + putchar('\r'); + __asm volatile("or r9, r0, 0x20\n + or r2, r0, %0\n + tb0 0, r0, 496\n" : : "r" (c)); +} + diff --git a/sys/arch/mvme88k/stand/libsa/promdev.c b/sys/arch/mvme88k/stand/libsa/promdev.c new file mode 100644 index 00000000000..7ba01390c31 --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/promdev.c @@ -0,0 +1,193 @@ +/* $Id: promdev.c,v 1.1 1997/03/03 19:30:36 rahnds Exp $ */ + +/* + * Copyright (c) 1995 Gordon W. Ross + * 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/mon.h> +#include <machine/pte.h> +#include <machine/saio.h> + +#include <dvma.h> +#include <stand.h> + +struct saioreq prom_si; +static int promdev_inuse; + +static char * +prom_mapin(u_long physaddr, int length, int maptype); + +int +prom_iopen(void **devdatap) +{ + struct bootparam *bp; + struct boottab *ops; + struct devinfo *dip; + struct saioreq *si; + char *p; + int error; + + if (promdev_inuse) + return(EMFILE); + + bp = *romp->bootParam; + ops = bp->bootDevice; + dip = ops->b_devinfo; + +#ifdef DEBUG_PROM + printf("Boot device type: %s\n", ops->b_desc); +#endif + + dvma_init(); + + si = &prom_si; + bzero((caddr_t)si, sizeof(*si)); + si->si_boottab = ops; + si->si_ctlr = bp->ctlrNum; + si->si_unit = bp->unitNum; + si->si_boff = bp->partNum; + + if (si->si_ctlr > dip->d_stdcount) { + printf("Invalid controller number\n"); + return(ENXIO); + } + + if (dip->d_devbytes) { + si->si_devaddr = prom_mapin(dip->d_stdaddrs[si->si_ctlr], + dip->d_devbytes, dip->d_devtype); +#ifdef DEBUG_PROM + printf("prom_iopen: devaddr=0x%x pte=0x%x\n", + si->si_devaddr, get_pte(si->si_devaddr)); +#endif + } + + if (dip->d_dmabytes) { + si->si_dmaaddr = dvma_alloc(dip->d_dmabytes); +#ifdef DEBUG_PROM + printf("prom_iopen: dmaaddr=0x%x\n", si->si_dmaaddr); +#endif + } + + /* OK, call the PROM device open routine. */ + error = (*ops->b_open)(si); + if (error != 0) { + printf("prom_iopen: \"%s\" error=%d\n", + ops->b_desc, error); + return (ENXIO); + } +#ifdef DEBUG_PROM + printf("prom_iopen: succeeded, error=%d\n", error); +#endif + + *devdatap = si; + promdev_inuse++; + return (0); +} + +void +prom_iclose(void *devdata) +{ + struct boottab *ops; + struct devinfo *dip; + struct saioreq *si; + + if (promdev_inuse == 0) + return; + + si = devdata; + ops = si->si_boottab; + dip = ops->b_devinfo; + + (*ops->b_close)(si); + + if (si->si_dmaaddr) { + dvma_free(si->si_dmaaddr, dip->d_dmabytes); + si->si_dmaaddr = NULL; + } + + promdev_inuse = 0; +} + +struct mapinfo { + int maptype; + int pgtype; + int base; +}; + +static struct mapinfo +prom_mapinfo[] = { + { MAP_MAINMEM, PGT_OBMEM, 0 }, + { MAP_OBIO, PGT_OBIO, 0 }, + { MAP_MBMEM, PGT_OBMEM, 0 }, /* XXX - Sun2 Multibus? */ + { MAP_MBIO, PGT_OBIO, 0 }, /* XXX - Sun2 Multibus? */ + { MAP_VME16A16D, PGT_VME_D16, 0xFFFF0000 }, + { MAP_VME16A32D, PGT_VME_D32, 0xFFFF0000 }, + { MAP_VME24A16D, PGT_VME_D16, 0xFF000000 }, + { MAP_VME24A32D, PGT_VME_D32, 0xFF000000 }, + { MAP_VME32A16D, PGT_VME_D16, 0 }, + { MAP_VME32A32D, PGT_VME_D32, 0 }, +}; +static prom_mapinfo_cnt = sizeof(prom_mapinfo) / sizeof(prom_mapinfo[0]); + +/* The virtual address we will use for PROM device mappings. */ +static int prom_devmap = MONSHORTSEG; + +static char * +prom_mapin(physaddr, length, maptype) + u_long physaddr; + int length, maptype; +{ + int i, pa, pte, va; + + if (length > (4*NBPG)) + panic("prom_mapin: length=%d\n", length); + + for (i = 0; i < prom_mapinfo_cnt; i++) + if (prom_mapinfo[i].maptype == maptype) + goto found; + panic("prom_mapin: invalid maptype %d\n", maptype); +found: + + pte = prom_mapinfo[i].pgtype; + pte |= PG_PERM; + pa = prom_mapinfo[i].base; + pa += physaddr; + pte |= PA_PGNUM(pa); + + va = prom_devmap; + do { + set_pte(va, pte); + va += NBPG; + pte += 1; + length -= NBPG; + } while (length > 0); + return ((char*)prom_devmap); +} diff --git a/sys/arch/mvme88k/stand/libsa/promdev.h b/sys/arch/mvme88k/stand/libsa/promdev.h new file mode 100644 index 00000000000..e3ae5ba2d7c --- /dev/null +++ b/sys/arch/mvme88k/stand/libsa/promdev.h @@ -0,0 +1,4 @@ + +int prom_iopen(struct saioreq **sipp); +void prom_iclose(struct saioreq *sip); + diff --git a/sys/arch/mvme88k/stand/netboot/Makefile b/sys/arch/mvme88k/stand/netboot/Makefile new file mode 100644 index 00000000000..2036c5d5c11 --- /dev/null +++ b/sys/arch/mvme88k/stand/netboot/Makefile @@ -0,0 +1,31 @@ +# $Id: Makefile,v 1.1 1997/03/03 19:30:39 rahnds Exp $ + +RELOC=0x3F0000 + +S= ${.CURDIR}/../../../.. +DEFS= -DSTANDALONE -DSUN_BOOTPARAMS +INCPATH=-I${.CURDIR} -I${.CURDIR}/../libsa -I${S} -I${S}/lib/libsa +CFLAGS= -O2 ${INCPATH} ${DEFS} ${COPTS} + +.include "${S}/arch/${MACHINE}/stand/libsa/Makefile.inc" +.PATH: ${S}/arch/${MACHINE}/stand/libsa +SRTOBJ= SRT0.o SRT1.o + +SRCS= boot.c conf.c version.c dev_net.c +SRCS+= if_ie.c if_le.c +OBJS= ${SRTOBJ} ${SRCS:S/.c/.o/g} + +all: netboot.bin + +netboot: ${OBJS} ${LIBSA} + ${LD} -s -N -T ${RELOC} -e start -o $@ ${OBJS} ${LIBSA} + @size $@ + +netboot.bin: netboot + dd ibs=32 skip=1 if=netboot of=$@ + +install: + install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + netboot.bin ${DESTDIR}${MDEC_DIR}/netboot + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/netboot/boot.c b/sys/arch/mvme88k/stand/netboot/boot.c new file mode 100644 index 00000000000..e7330a080af --- /dev/null +++ b/sys/arch/mvme88k/stand/netboot/boot.c @@ -0,0 +1,119 @@ +/* $Id: boot.c,v 1.1 1997/03/03 19:30:38 rahnds Exp $ */ + +/*- + * Copyright (c) 1995 Theo de Raadt + * 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 Theo de Raadt + * 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. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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 "stand.h" +#include "promboot.h" + +/* + * Boot device is derived from ROM provided information. + */ +#define LOADADDR 0x10000 + +extern char *version; +char defname[32] = "bsd"; +char line[80]; + +#if 0 +u_int bootdev = MAKEBOOTDEV(0, sdmajor, 0, 0, 0); /* disk boot */ +#endif +u_int bootdev = MAKEBOOTDEV(1, 0, 0, 0, 0); /* network boot */ + +main() +{ + char *cp, *file; + int io; + extern int cputyp; + extern char *oparg, *opargend; + int ask = 0; + + printf(">> OpenBSD netboot [%s]\n", version); + printf("model MVME%x\n", cputyp); + + *opargend = '\0'; + prom_get_boot_info(); + file = defname; + + cp = prom_bootfile; + if (cp && *cp) + file = cp; + + for (;;) { + if (ask) { + printf("boot: "); + gets(line); + if (line[0]) { + oparg = line; + prom_get_boot_info(); + } + } + exec_sun(file, (char *)LOADADDR, prom_boothow); + printf("boot: %s\n", strerror(errno)); + ask = 1; + } +} diff --git a/sys/arch/mvme88k/stand/netboot/conf.c b/sys/arch/mvme88k/stand/netboot/conf.c new file mode 100644 index 00000000000..2f41cb21c84 --- /dev/null +++ b/sys/arch/mvme88k/stand/netboot/conf.c @@ -0,0 +1,34 @@ +/* $Id: conf.c,v 1.1 1997/03/03 19:30:38 rahnds Exp $ */ + +#include <sys/types.h> +#include <netinet/in.h> +#include <netinet/in_systm.h> + +#include <stand.h> +#include <nfs.h> +#include <dev_net.h> + +struct fs_ops file_system[] = { + { nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_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]); + +extern struct netif_driver le_driver; +extern struct netif_driver ie_driver; + +struct netif_driver *netif_drivers[] = { + &le_driver, + &ie_driver, +}; +int n_netif_drivers = sizeof(netif_drivers) / sizeof(netif_drivers[0]); + + +/* XXX */ +int netif_debug; +int debug; +int errno; diff --git a/sys/arch/mvme88k/stand/netboot/dev_net.c b/sys/arch/mvme88k/stand/netboot/dev_net.c new file mode 100644 index 00000000000..ffba93b71aa --- /dev/null +++ b/sys/arch/mvme88k/stand/netboot/dev_net.c @@ -0,0 +1,211 @@ +/* $Id: dev_net.c,v 1.1 1997/03/03 19:30:38 rahnds Exp $ */ + +/* + * Copyright (c) 1995 Gordon W. Ross + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * 4. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Gordon W. Ross + * + * 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. + */ + +/* + * This module implements a "raw device" interface suitable for + * use by the stand-alone I/O library NFS code. This interface + * does not support any "block" access, and exists only for the + * purpose of initializing the network interface, getting boot + * parameters, and performing the NFS mount. + * + * At open time, this does: + * + * find interface - netif_open() + * RARP for IP address - rarp_getipaddress() + * RPC/bootparams - callrpc(d, RPC_BOOTPARAMS, ...) + * RPC/mountd - nfs_mount(sock, ip, path) + * + * the root file handle from mountd is saved in a global + * for use by the NFS open code (NFS/lookup). + */ + +#include <sys/param.h> +#include <sys/socket.h> +#include <net/if.h> +#include <netinet/in.h> +#include <netinet/if_ether.h> +#include <netinet/in_systm.h> + +#include "stand.h" +#include "net.h" +#include "netif.h" +#include "config.h" +#include "bootparam.h" + +extern int nfs_root_node[]; /* XXX - get from nfs_mount() */ + +struct in_addr myip, rootip, gateip, mask; +char rootpath[FNAME_SIZE]; + +int netdev_sock = -1; +static int open_count; + +/* + * Called by devopen after it sets f->f_dev to our devsw entry. + * This opens the low-level device and sets f->f_devdata. + */ +int +net_open(f, devname) + struct open_file *f; + char *devname; /* Device part of file name (or NULL). */ +{ + int error = 0; + + /* On first open, do netif open, mount, etc. */ + if (open_count == 0) { + /* Find network interface. */ + if ((netdev_sock = netif_open(devname)) < 0) + return (error=ENXIO); + if ((error = net_mountroot(f, devname)) != 0) + return (error); + } + open_count++; + f->f_devdata = nfs_root_node; + return (error); +} + +int +net_close(f) + struct open_file *f; +{ + /* On last close, do netif close, etc. */ + if (open_count > 0) + if (--open_count == 0) + netif_close(netdev_sock); + f->f_devdata = NULL; +} + +int +net_ioctl() +{ + return EIO; +} + +int +net_strategy() +{ + return EIO; +} + +int +net_mountroot(f, devname) + struct open_file *f; + char *devname; /* Device part of file name (or NULL). */ +{ + int error; + +#ifdef DEBUG + printf("net_mountroot: %s\n", devname); +#endif + + /* + * Get info for NFS boot: our IP address, our hostname, + * server IP address, and our root path on the server. + * There are two ways to do this: The old, Sun way, + * and the more modern, BOOTP way. (RFC951, RFC1048) + */ + +#ifdef SUN_BOOTPARAMS + /* Get boot info using RARP and Sun bootparams. */ + + /* Get our IP address. (rarp.c) */ + if (rarp_getipaddress(netdev_sock) == -1) + return (EIO); + printf("boot: client IP address: %s\n", intoa(myip.s_addr)); + + /* Get our hostname, server IP address. */ + if (bp_whoami(netdev_sock)) + return (EIO); + printf("boot: client name: %s\n", hostname); + + /* Get the root pathname. */ + if (bp_getfile(netdev_sock, "root", &rootip, rootpath)) + return (EIO); + +#else + + /* Get boot info using BOOTP way. (RFC951, RFC1048) */ + bootp(netdev_sock); + + printf("Using IP address: %s\n", intoa(myip.s_addr)); + + printf("myip: %s (%s)", hostname, intoa(myip)); + if (gateip) + printf(", gateip: %s", intoa(gateip)); + if (mask) + printf(", mask: %s", intoa(mask)); + printf("\n"); + +#endif + + printf("root addr=%s path=%s\n", intoa(rootip.s_addr), rootpath); + + /* Get the NFS file handle (mount). */ + error = nfs_mount(netdev_sock, rootip, rootpath); + + return (error); +} + +/* + * machdep_common_ether: get ethernet address + */ +void +machdep_common_ether(ether) + u_char *ether; +{ + u_char *ea; + extern int cputyp; + + if (cputyp == CPU_147) { + ea = (u_char *) ETHER_ADDR_147; + + if ((*(int *) ea & 0x2fffff00) == 0x2fffff00) + panic("ERROR: ethernet address not set!\r\n"); + ether[0] = 0x08; + ether[1] = 0x00; + ether[2] = 0x3e; + ether[3] = ea[0]; + ether[4] = ea[1]; + ether[5] = ea[2]; + } else { + ea = (u_char *) ETHER_ADDR_16X; + + if (ea[0] + ea[1] + ea[2] + ea[3] + ea[4] + ea[5] == 0) + panic("ERROR: ethernet address not set!\r\n"); + ether[0] = ea[0]; + ether[1] = ea[1]; + ether[2] = ea[2]; + ether[3] = ea[3]; + ether[4] = ea[4]; + ether[5] = ea[5]; + } +} diff --git a/sys/arch/mvme88k/stand/netboot/dev_net.h b/sys/arch/mvme88k/stand/netboot/dev_net.h new file mode 100644 index 00000000000..093ba193bfd --- /dev/null +++ b/sys/arch/mvme88k/stand/netboot/dev_net.h @@ -0,0 +1,6 @@ + +int net_open __P((struct open_file *, ...)); +int net_close __P((struct open_file *)); +int net_ioctl(); +int net_strategy(); + diff --git a/sys/arch/mvme88k/stand/netboot/i82586.h b/sys/arch/mvme88k/stand/netboot/i82586.h new file mode 100644 index 00000000000..471cadfde19 --- /dev/null +++ b/sys/arch/mvme88k/stand/netboot/i82586.h @@ -0,0 +1,306 @@ +/* $Id: i82586.h,v 1.1 1997/03/03 19:30:38 rahnds Exp $ */ + +/*- + * Copyright (c) 1995 Theo de Raadt + * Copyright (c) 1992, University of Vermont and State Agricultural College. + * Copyright (c) 1992, Garrett A. Wollman. + * 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 the University of + * Vermont and State Agricultural College and Garrett A. Wollman. + * 4. Neither the name of the University nor the name of the author + * 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 UNIVERSITY OR 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. + */ + +/* + * Intel 82586 Ethernet chip + * Register, bit, and structure definitions. + * + * Written by GAW with reference to the Clarkson Packet Driver code for this + * chip written by Russ Nelson and others. + */ + +struct ie_en_addr { + u_char data[6]; +}; +/* + * the only actual IE registers. + */ +struct iereg { + u_short ie_porthigh; + u_short ie_portlow; + u_long ie_attention; +}; +#define IE_PORT_NEWSCP 0x00000002 +#define IE_PORT_RESET 0x00000000 + +/* + * This is the master configuration block. It tells the hardware where + * all the rest of the stuff is. + */ +struct ie_scp { + u_char mbz1[3]; /* must be zero */ + u_char scp_sysbus; /* true if 8-bit only */ + u_char mbz2[4]; /* must be zero */ + u_short scp_iscp_low; /* 24-bit physaddr of ISCP */ + u_char mbz3[1]; + u_char scp_iscp_high; /* the rest of the physaddr.. */ +}; +/* + * The tells the hardware where all the rest of the stuff is, too. + * FIXME: some of these should be re-commented after we figure out their + * REAL function. + */ +struct ie_iscp { + u_char mbz1[1]; + u_char iscp_busy; /* zeroed after init */ + u_short iscp_scboffset; /* 16-bit physaddr of next struct */ + u_short iscp_base_low; /* 24-bit physaddr for all 16-bit vars */ + u_char mbz2[1]; + u_char iscp_base_high; /* rest of physaddr ... */ +}; +/* + * This FINALLY tells the hardware what to do and where to put it. + */ +struct ie_scb { + u_short ie_status; /* status word */ + u_short ie_command; /* command word */ + u_short ie_command_list;/* 16-pointer to command block list */ + u_short ie_recv_list; /* 16-pointer to receive frame list */ + u_short ie_err_crc; /* CRC errors */ + u_short ie_err_align; /* Alignment errors */ + u_short ie_err_resource;/* Resource errors */ + u_short ie_err_overrun; /* Overrun errors */ +}; +/* Command values */ +#define IE_RU_COMMAND 0x0070 /* mask for RU command */ +#define IE_RU_NOP 0 /* for completeness */ +#define IE_RU_START 0x0010 /* start receive unit command */ +#define IE_RU_ENABLE 0x0020 /* enable receiver command */ +#define IE_RU_DISABLE 0x0030 /* disable receiver command */ +#define IE_RU_ABORT 0x0040 /* abort current receive operation */ + +#define IE_CU_COMMAND 0x0700 /* mask for CU command */ +#define IE_CU_NOP 0 /* included for completeness */ +#define IE_CU_START 0x0100 /* do-command command */ +#define IE_CU_RESUME 0x0200 /* resume a suspended cmd list */ +#define IE_CU_STOP 0x0300 /* SUSPEND was already taken */ +#define IE_CU_ABORT 0x0400 /* abort current command */ + +#define IE_ACK_COMMAND 0xf000 /* mask for ACK command */ +#define IE_ACK_CX 0x8000 /* ack IE_ST_DONE */ +#define IE_ACK_FR 0x4000 /* ack IE_ST_RECV */ +#define IE_ACK_CNA 0x2000 /* ack IE_ST_ALLDONE */ +#define IE_ACK_RNR 0x1000 /* ack IE_ST_RNR */ + +#define IE_ACTION_COMMAND(x) (((x) & IE_CU_COMMAND) == IE_CU_START) + /* is this command an action command? */ + +/* Status values */ +#define IE_ST_WHENCE 0xf000 /* mask for cause of interrupt */ +#define IE_ST_DONE 0x8000 /* command with I bit completed */ +#define IE_ST_RECV 0x4000 /* frame received */ +#define IE_ST_ALLDONE 0x2000 /* all commands completed */ +#define IE_ST_RNR 0x1000 /* receive not ready */ + +#define IE_CU_STATUS 0x700 /* mask for command unit status */ +#define IE_CU_ACTIVE 0x200 /* command unit is active */ +#define IE_CU_SUSPEND 0x100 /* command unit is suspended */ + +#define IE_RU_STATUS 0x70 /* mask for receiver unit status */ +#define IE_RU_SUSPEND 0x10 /* receiver is suspended */ +#define IE_RU_NOSPACE 0x20 /* receiver has no resources */ +#define IE_RU_READY 0x40 /* receiver is ready */ + +/* + * This is filled in partially by the chip, partially by us. + */ +struct ie_recv_frame_desc { + u_short ie_fd_status; /* status for this frame */ + u_short ie_fd_last; /* end of frame list flag */ + u_short ie_fd_next; /* 16-pointer to next RFD */ + u_short ie_fd_buf_desc; /* 16-pointer to list of buffer desc's */ + struct ie_en_addr dest; /* destination ether */ + struct ie_en_addr src; /* source ether */ + u_short ie_length; /* 802 length/Ether type */ + u_short mbz; /* must be zero */ +}; +#define IE_FD_LAST 0x8000 /* last rfd in list */ +#define IE_FD_SUSP 0x4000 /* suspend RU after receipt */ + +#define IE_FD_COMPLETE 0x8000 /* frame is complete */ +#define IE_FD_BUSY 0x4000 /* frame is busy */ +#define IE_FD_OK 0x2000 /* frame is bad */ +#define IE_FD_RNR 0x0200 /* receiver out of resources here */ + +/* + * linked list of buffers... + */ +struct ie_recv_buf_desc { + u_short ie_rbd_actual; /* status for this buffer */ + u_short ie_rbd_next; /* 16-pointer to next RBD */ + u_short ie_rbd_buffer_low; /* 24-pointer to buffer for this RBD */ + u_short ie_rbd_buffer_high; /* 24-pointer to buffer for this RBD */ + u_short ie_rbd_length; /* length of the buffer */ + u_short mbz; /* must be zero */ +}; +#define IE_RBD_LAST 0x8000 /* last buffer */ +#define IE_RBD_USED 0x4000 /* this buffer has data */ +/* + * All commands share this in common. + */ +struct ie_cmd_common { + u_short ie_cmd_status; /* status of this command */ + u_short ie_cmd_cmd; /* command word */ + u_short ie_cmd_link; /* link to next command */ +}; +#define IE_STAT_COMPL 0x8000 /* command is completed */ +#define IE_STAT_BUSY 0x4000 /* command is running now */ +#define IE_STAT_OK 0x2000 /* command completed successfully */ +#define IE_STAT_ABORT 0x1000 /* command was aborted */ + + +#define IE_CMD_NOP 0x0000 /* NOP */ +#define IE_CMD_IASETUP 0x0001 /* initial address setup */ +#define IE_CMD_CONFIG 0x0002 /* configure command */ +#define IE_CMD_MCAST 0x0003 /* multicast setup command */ +#define IE_CMD_XMIT 0x0004 /* transmit command */ +#define IE_CMD_TDR 0x0005 /* time-domain reflectometer command */ +#define IE_CMD_DUMP 0x0006 /* dump command */ +#define IE_CMD_DIAGNOSE 0x0007 /* diagnostics command */ + +#define IE_CMD_LAST 0x8000 /* this is the last command in the list */ +#define IE_CMD_SUSPEND 0x4000 /* suspend CU after this command */ +#define IE_CMD_INTR 0x2000 /* post an interrupt after completion */ + +/* + * This is the command to transmit a frame. + */ +struct ie_xmit_cmd { + struct ie_cmd_common com; /* common part */ +#define ie_xmit_status com.ie_cmd_status + + u_short ie_xmit_desc; /* 16-pointer to buffer descriptor */ + struct ie_en_addr ie_xmit_addr; /* destination address */ + + u_short ie_xmit_length; /* 802.3 length/Ether type field */ +}; +#define IE_XS_MAXCOLL 0x000f /* number of collisions during transmit */ +#define IE_XS_EXCMAX 0x0020 /* exceeded maximum number of collisions */ +#define IE_XS_SQE 0x0040 /* SQE positive */ +#define IE_XS_DEFERRED 0x0080 /* transmission deferred */ +#define IE_XS_UNDERRUN 0x0100 /* DMA underrun */ +#define IE_XS_LOSTCTS 0x0200 /* Lost CTS */ +#define IE_XS_NOCARRIER 0x0400 /* No Carrier */ + +/* + * This is a buffer descriptor for a frame to be transmitted. + */ + +struct ie_xmit_buf { + u_short ie_xmit_flags; /* see below */ + u_short ie_xmit_next; /* 16-pointer to next desc. */ + u_short ie_xmit_buf_low;/* 24-pointer to the actual buffer */ + u_short ie_xmit_buf_high; /* 24-pointer to the actual buffer */ +}; +#define IE_XMIT_LAST 0x8000 /* this TBD is the last one */ +/* The rest of the `flags' word is actually the length. */ + +/* + * Multicast setup command. + */ + +#define MAXMCAST 250 /* must fit in transmit buffer */ + +struct ie_mcast_cmd { + struct ie_cmd_common com; /* common part */ +#define ie_mcast_status com.ie_cmd_status + + u_short ie_mcast_bytes; /* size (in bytes) of multicast addresses */ + struct ie_en_addr ie_mcast_addrs[MAXMCAST + 1]; /* space for them */ +}; +/* + * Time Domain Reflectometer command. + */ + +struct ie_tdr_cmd { + struct ie_cmd_common com; /* common part */ +#define ie_tdr_status com.ie_cmd_status + + u_short ie_tdr_time; /* error bits and time */ +}; +#define IE_TDR_SUCCESS 0x8000 /* TDR succeeded without error */ +#define IE_TDR_XCVR 0x4000 /* detected a transceiver problem */ +#define IE_TDR_OPEN 0x2000 /* detected an open */ +#define IE_TDR_SHORT 0x1000 /* TDR detected a short */ +#define IE_TDR_TIME 0x07ff /* mask for reflection time */ + +/* + * Initial Address Setup command + */ +struct ie_iasetup_cmd { + struct ie_cmd_common com; +#define ie_iasetup_status com.ie_cmd_status + + struct ie_en_addr ie_address; +}; +/* + * Configuration command + */ +struct ie_config_cmd { + struct ie_cmd_common com; /* common part */ +#define ie_config_status com.ie_cmd_status + + u_char ie_config_count;/* byte count (0x0c) */ + u_char ie_fifo; /* fifo (8) */ + u_char ie_save_bad; /* save bad frames (0x40) */ + u_char ie_addr_len; /* address length (0x2e) (AL-LOC == 1) */ + u_char ie_priority; /* priority and backoff (0x0) */ + u_char ie_ifs; /* inter-frame spacing (0x60) */ + u_char ie_slot_low; /* slot time, LSB (0x0) */ + u_char ie_slot_high; /* slot time, MSN, and retries (0xf2) */ + u_char ie_promisc; /* 1 if promiscuous, else 0 */ + u_char ie_crs_cdt; /* CSMA/CD parameters (0x0) */ + u_char ie_min_len; /* min frame length (0x40) */ + u_char ie_junk; /* stuff for 82596 (0xff) */ +}; + +struct iemem { + volatile struct ie_scp im_scp; + u_char xx1[4]; + volatile struct ie_iscp im_iscp; + + volatile struct ie_scb im_scb; + volatile struct ie_config_cmd im_cc; + volatile struct ie_iasetup_cmd im_ic; + volatile struct ie_recv_frame_desc im_rfd[NRXBUF]; + volatile struct ie_recv_buf_desc im_rbd[NRXBUF]; + volatile struct ie_xmit_cmd im_xc[NTXBUF]; + volatile struct ie_xmit_buf im_xd[NTXBUF]; + volatile u_char im_rxbuf[NRXBUF * IE_RBUF_SIZE]; + volatile u_char im_txbuf[NTXBUF * ETHER_MAX_LEN]; + +}; diff --git a/sys/arch/mvme88k/stand/netboot/if_ie.c b/sys/arch/mvme88k/stand/netboot/if_ie.c new file mode 100644 index 00000000000..7b3237af9a5 --- /dev/null +++ b/sys/arch/mvme88k/stand/netboot/if_ie.c @@ -0,0 +1,496 @@ +/* $Id: if_ie.c,v 1.1 1997/03/03 19:30:38 rahnds Exp $ */ + +/* + * Copyright (c) 1995 Theo de Raadt + * + * 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 under OpenBSD by + * Theo de Raadt for Willowglen Singapore. + * 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 <sys/types.h> + +#include <netinet/in.h> +#include <netinet/in_systm.h> + +#define ETHER_MIN_LEN 64 +#define ETHER_MAX_LEN 1518 + +#define NTXBUF 1 +#define NRXBUF 16 +#define IE_RBUF_SIZE ETHER_MAX_LEN + +#include "stand.h" +#include "netif.h" +#include "config.h" + +#include "i82586.h" +#include "if_iereg.h" + +int ie_debug = 0; + +void ie_stop __P((struct netif *)); +void ie_end __P((struct netif *)); +void ie_error __P((struct netif *, char *, volatile struct iereg *)); +int ie_get __P((struct iodesc *, void *, size_t, time_t)); +void ie_init __P((struct iodesc *, void *)); +int ie_match __P((struct netif *, void *)); +int ie_poll __P((struct iodesc *, void *, int)); +int ie_probe __P((struct netif *, void *)); +int ie_put __P((struct iodesc *, void *, size_t)); +void ie_reset __P((struct netif *, u_char *)); + +struct netif_stats ie_stats; + +struct netif_dif ie0_dif = { + 0, /* unit */ + 1, /* nsel */ + &ie_stats, + 0, + 0, +}; + +struct netif_driver ie_driver = { + "ie", /* netif_bname */ + ie_match, /* match */ + ie_probe, /* probe */ + ie_init, /* init */ + ie_get, /* get */ + ie_put, /* put */ + ie_end, /* end */ + &ie0_dif, /* netif_ifs */ + 1, /* netif_nifs */ +}; + +struct ie_configuration { + u_int phys_addr; + int used; +} ie_config[] = { + { INTEL_REG_ADDR, 0 } +}; + +int nie_config = sizeof(ie_config) / (sizeof(ie_config[0])); + +struct { + struct iereg *sc_reg; /* IE registers */ + struct iemem *sc_mem; /* RAM */ +} ie_softc; + +int +ie_match(nif, machdep_hint) + struct netif *nif; + void *machdep_hint; +{ + char *name; + int i, val = 0; + extern int cputyp; + + if (cputyp == CPU_147) + return (0); + name = machdep_hint; + if (name && !bcmp(ie_driver.netif_bname, name, 2)) + val += 10; + for (i = 0; i < nie_config; i++) { + if (ie_config[i].used) + continue; + if (ie_debug) + printf("ie%d: ie_match --> %d\n", i, val + 1); + ie_config[i].used++; + return (val + 1); + } + if (ie_debug) + printf("ie%d: ie_match --> 0\n", i); + return (0); +} + +int +ie_probe(nif, machdep_hint) + struct netif *nif; + void *machdep_hint; +{ + extern int cputyp; + + /* the set unit is the current unit */ + if (ie_debug) + printf("ie%d: ie_probe called\n", nif->nif_unit); + + if (cputyp != CPU_147) + return (0); + return (1); +} + +void +ie_error(nif, str, ier) + struct netif *nif; + char *str; + volatile struct iereg *ier; +{ + panic("ie%d: unknown error\n", nif->nif_unit); +} + +ieack(ier, iem) + volatile struct iereg *ier; + struct iemem *iem; +{ + /* ack the `interrupt' */ + iem->im_scb.ie_command = iem->im_scb.ie_status & IE_ST_WHENCE; + ier->ie_attention = 1; /* chan attention! */ + while (iem->im_scb.ie_command) + ; +} + +void +ie_reset(nif, myea) + struct netif *nif; + u_char *myea; +{ + volatile struct iereg *ier = ie_softc.sc_reg; + struct iemem *iem = ie_softc.sc_mem; + int timo = 10000, stat, i; + volatile int t; + u_int a; + + if (ie_debug) + printf("ie%d: ie_reset called\n", nif->nif_unit); + + /*printf("ier %x iem %x\n", ier, iem);*/ + + *(u_char *)0xfff4202a = 0x40; + + bzero(iem, sizeof(*iem)); + iem->im_scp.scp_sysbus = 0; + iem->im_scp.scp_iscp_low = (int) &iem->im_iscp & 0xffff; + iem->im_scp.scp_iscp_high = (int) &iem->im_iscp >> 16; + + iem->im_iscp.iscp_scboffset = (int) &iem->im_scb - (int) iem; + iem->im_iscp.iscp_busy = 1; + iem->im_iscp.iscp_base_low = (int) iem & 0xffff; + iem->im_iscp.iscp_base_high = (int) iem >> 16; + + /* + * completely and utterly unlike what i expected, the + * "write" order is: + * 1st: d15-d0 -> high address + * 2nd: d31-d16 -> low address + */ + + /* reset chip */ + a = IE_PORT_RESET; + ier->ie_porthigh = a & 0xffff; + t = 0; + t = 1; + ier->ie_portlow = a >> 16; + for (t = timo; t--;) + ; + + /* set new SCP pointer */ + a = (int) &iem->im_scp | IE_PORT_NEWSCP; + ier->ie_porthigh = a & 0xffff; + t = 0; + t = 1; + ier->ie_portlow = a >> 16; + for (t = timo; t--;) + ; + + ier->ie_attention = 1; /* chan attention! */ + for (t = timo * 10; t--;) + ; + + /* send CONFIGURE command */ + iem->im_scb.ie_command = IE_CU_START; + iem->im_scb.ie_command_list = (int) &iem->im_cc - (int) iem; + iem->im_cc.com.ie_cmd_status = 0; + iem->im_cc.com.ie_cmd_cmd = IE_CMD_CONFIG | IE_CMD_LAST; + iem->im_cc.com.ie_cmd_link = 0xffff; + iem->im_cc.ie_config_count = 0x0c; + iem->im_cc.ie_fifo = 8; + iem->im_cc.ie_save_bad = 0x40; + iem->im_cc.ie_addr_len = 0x2e; + iem->im_cc.ie_priority = 0; + iem->im_cc.ie_ifs = 0x60; + iem->im_cc.ie_slot_low = 0; + iem->im_cc.ie_slot_high = 0xf2; + iem->im_cc.ie_promisc = 0; + iem->im_cc.ie_crs_cdt = 0; + iem->im_cc.ie_min_len = 64; + iem->im_cc.ie_junk = 0xff; + + ier->ie_attention = 1; /* chan attention! */ + for (t = timo * 10; t--;) + ; + + ieack(ier, iem); + + /*printf("ic %x\n", &iem->im_ic);*/ + /* send IASETUP command */ + iem->im_scb.ie_command = IE_CU_START; + iem->im_scb.ie_command_list = (int) &iem->im_ic - (int) iem; + iem->im_ic.com.ie_cmd_status = 0; + iem->im_ic.com.ie_cmd_cmd = IE_CMD_IASETUP | IE_CMD_LAST; + iem->im_ic.com.ie_cmd_link = 0xffff; + bcopy(myea, (void *)&iem->im_ic.ie_address, sizeof iem->im_ic.ie_address); + + ier->ie_attention = 1; /* chan attention! */ + for (t = timo * 10; t--;) + ; + + ieack(ier, iem); + + /* setup buffers */ + + for (i = 0; i < NRXBUF; i++) { + iem->im_rfd[i].ie_fd_next = (int) &iem->im_rfd[(i+1) % NRXBUF] - + (int) iem; + iem->im_rbd[i].ie_rbd_next = (int) &iem->im_rbd[(i+1) % NRXBUF] - + (int) iem; + a = (int) &iem->im_rxbuf[i * IE_RBUF_SIZE]; + iem->im_rbd[i].ie_rbd_buffer_low = a & 0xffff; + iem->im_rbd[i].ie_rbd_buffer_high = a >> 16; + iem->im_rbd[i].ie_rbd_length = IE_RBUF_SIZE; + } + iem->im_rfd[NRXBUF-1].ie_fd_last |= IE_FD_LAST; + iem->im_rbd[NRXBUF-1].ie_rbd_length |= IE_RBD_LAST; + iem->im_rfd[0].ie_fd_buf_desc = (int) &iem->im_rbd[0] - (int) iem; + + /*printf("rfd[0] %x rbd[0] %x buf[0] %x\n", &iem->im_rfd, &iem->im_rbd, + &iem->im_rxbuf);*/ + + /* send receiver start command */ + iem->im_scb.ie_command = IE_RU_START; + iem->im_scb.ie_command_list = 0; + iem->im_scb.ie_recv_list = (int) &iem->im_rfd[0] - (int) iem; + ier->ie_attention = 1; /* chan attention! */ + while (iem->im_scb.ie_command) + ; + + ieack(ier, iem); +} + +int +ie_poll(desc, pkt, len) + struct iodesc *desc; + void *pkt; + int len; +{ + volatile struct iereg *ier = ie_softc.sc_reg; + struct iemem *iem = ie_softc.sc_mem; + u_char *p = pkt; + static int slot; + int length = 0; + u_int a; + u_short status; + + asm(".word 0xf518\n"); + status = iem->im_rfd[slot].ie_fd_status; + if (status & IE_FD_BUSY) + return (0); + + /* printf("slot %d: %x\n", slot, status); */ + if ((status & (IE_FD_COMPLETE | IE_FD_OK)) == (IE_FD_COMPLETE | IE_FD_OK)) { + if (status & IE_FD_OK) { + length = iem->im_rbd[slot].ie_rbd_actual & 0x3fff; + if (length > len) + length = len; + bcopy((void *)&iem->im_rxbuf[slot * IE_RBUF_SIZE], + pkt, length); + + iem->im_rfd[slot].ie_fd_status = 0; + iem->im_rfd[slot].ie_fd_last |= IE_FD_LAST; + iem->im_rfd[(slot+NRXBUF-1)%NRXBUF].ie_fd_last &= + ~IE_FD_LAST; + iem->im_rbd[slot].ie_rbd_actual = 0; + iem->im_rbd[slot].ie_rbd_length |= IE_RBD_LAST; + iem->im_rbd[(slot+NRXBUF-1)%NRXBUF].ie_rbd_length &= + ~IE_RBD_LAST; + /*printf("S%d\n", slot);*/ + + } else { + printf("shit\n"); + } + slot++; + /* should move descriptor onto end of queue... */ + } + if ((iem->im_scb.ie_status & IE_RU_READY) == 0) { + printf("RR\n"); + + for (slot = 0; slot < NRXBUF; slot++) { + iem->im_rbd[slot].ie_rbd_length &= ~IE_RBD_LAST; + iem->im_rfd[slot].ie_fd_last &= ~IE_FD_LAST; + } + iem->im_rbd[NRXBUF-1].ie_rbd_length |= IE_RBD_LAST; + iem->im_rfd[NRXBUF-1].ie_fd_last |= IE_FD_LAST; + + iem->im_rfd[0].ie_fd_buf_desc = (int)&iem->im_rbd[0] - (int)iem; + + iem->im_scb.ie_command = IE_RU_START; + iem->im_scb.ie_command_list = 0; + iem->im_scb.ie_recv_list = (int)&iem->im_rfd[0] - (int)iem; + ier->ie_attention = 1; /* chan attention! */ + while (iem->im_scb.ie_command) + ; + slot = 0; + } + slot = slot % NRXBUF; + return (length); +} + +int +ie_put(desc, pkt, len) + struct iodesc *desc; + void *pkt; + size_t len; +{ + volatile struct iereg *ier = ie_softc.sc_reg; + struct iemem *iem = ie_softc.sc_mem; + u_char *p = pkt; + int timo = 10000, stat, i; + volatile int t; + u_int a; + int xx = 0; + + /* send transmit command */ + + while (iem->im_scb.ie_command) + ; + + /* copy data */ + bcopy(p, (void *)&iem->im_txbuf[xx], len); + + len = MAX(len, ETHER_MIN_LEN); + + /* build transmit descriptor */ + iem->im_xd[xx].ie_xmit_flags = len | IE_XMIT_LAST; + iem->im_xd[xx].ie_xmit_next = 0xffff; + a = (int) &iem->im_txbuf[xx]; + iem->im_xd[xx].ie_xmit_buf_low = a & 0xffff; + iem->im_xd[xx].ie_xmit_buf_high = a >> 16; + + /* transmit command */ + iem->im_xc[xx].com.ie_cmd_status = 0; + iem->im_xc[xx].com.ie_cmd_cmd = IE_CMD_XMIT | IE_CMD_LAST; + iem->im_xc[xx].com.ie_cmd_link = 0xffff; + iem->im_xc[xx].ie_xmit_desc = (int) &iem->im_xd[xx] - (int) iem; + iem->im_xc[xx].ie_xmit_length = len; + bcopy(p, (void *)&iem->im_xc[xx].ie_xmit_addr, + sizeof iem->im_xc[xx].ie_xmit_addr); + + iem->im_scb.ie_command = IE_CU_START; + iem->im_scb.ie_command_list = (int) &iem->im_xc[xx] - (int) iem; + + ier->ie_attention = 1; /* chan attention! */ + + if (ie_debug) { + printf("ie%d: send %d to %x:%x:%x:%x:%x:%x\n", + desc->io_netif->nif_unit, len, + p[0], p[1], p[2], p[3], p[4], p[5]); + } + return (len); +} + +int +ie_get(desc, pkt, len, timeout) + struct iodesc *desc; + void *pkt; + size_t len; + time_t timeout; +{ + time_t t; + int cc; + + t = getsecs(); + cc = 0; + while (((getsecs() - t) < timeout) && !cc) { + cc = ie_poll(desc, pkt, len); + } + return (cc); +} +/* + * init ie device. return 0 on failure, 1 if ok. + */ +void +ie_init(desc, machdep_hint) + struct iodesc *desc; + void *machdep_hint; +{ + struct netif *nif = desc->io_netif; + + if (ie_debug) + printf("ie%d: ie_init called\n", desc->io_netif->nif_unit); + machdep_common_ether(desc->myea); + bzero(&ie_softc, sizeof(ie_softc)); + ie_softc.sc_reg = + (struct iereg *) ie_config[desc->io_netif->nif_unit].phys_addr; + ie_softc.sc_mem = (struct iemem *) 0x1e0000; + ie_reset(desc->io_netif, desc->myea); + printf("device: %s%d attached to %s\n", nif->nif_driver->netif_bname, + nif->nif_unit, ether_sprintf(desc->myea)); +} + +void +ie_stop(nif) + struct netif *nif; +{ + volatile struct iereg *ier = ie_softc.sc_reg; + struct iemem *iem = ie_softc.sc_mem; + int timo = 10000; + volatile int t; + u_int a; + + iem->im_iscp.iscp_busy = 1; + /* reset chip */ + a = IE_PORT_RESET; + ier->ie_porthigh = a & 0xffff; + t = 0; + t = 1; + ier->ie_portlow = a >> 16; + for (t = timo; t--;) + ; + + /* reset chip again */ + a = IE_PORT_RESET; + ier->ie_porthigh = a & 0xffff; + t = 0; + t = 1; + ier->ie_portlow = a >> 16; + for (t = timo; t--;) + ; + + /*printf("status %x busy %x\n", iem->im_scb.ie_status, + iem->im_iscp.iscp_busy);*/ +} + +void +ie_end(nif) + struct netif *nif; +{ + if (ie_debug) + printf("ie%d: ie_end called\n", nif->nif_unit); + + ie_stop(nif); + + /* *(u_char *) 0xfff42002 = 0; */ +} diff --git a/sys/arch/mvme88k/stand/netboot/if_iereg.h b/sys/arch/mvme88k/stand/netboot/if_iereg.h new file mode 100644 index 00000000000..d3a16e2ceaf --- /dev/null +++ b/sys/arch/mvme88k/stand/netboot/if_iereg.h @@ -0,0 +1,163 @@ +/* $Id: if_iereg.h,v 1.1 1997/03/03 19:30:38 rahnds Exp $ */ + +/* + * if_sunie.h + * + * sun's ie interface + */ + +/* + * programming notes: + * + * the ie chip operates in a 24 bit address space. + * + * most ie interfaces appear to be divided into two parts: + * - generic 586 stuff + * - board specific + * + * generic: + * the generic stuff of the ie chip is all done with data structures + * that live in the chip's memory address space. the chip expects + * its main data structure (the sys conf ptr -- SCP) to be at a fixed + * address in its 24 bit space: 0xfffff4 + * + * the SCP points to another structure called the ISCP. + * the ISCP points to another structure called the SCB. + * the SCB has a status field, a linked list of "commands", and + * a linked list of "receive buffers". these are data structures that + * live in memory, not registers. + * + * board: + * to get the chip to do anything, you first put a command in the + * command data structure list. then you have to signal "attention" + * to the chip to get it to look at the command. how you + * signal attention depends on what board you have... on PC's + * there is an i/o port number to do this, on sun's there is a + * register bit you toggle. + * + * to get data from the chip you program it to interrupt... + * + * + * sun issues: + * + * there are 3 kinds of sun "ie" interfaces: + * 1 - a VME/multibus card + * 2 - an on-board interface (sun3's, sun-4/100's, and sun-4/200's) + * 3 - another VME board called the 3E + * + * the VME boards lives in vme16 space. only 16 and 8 bit accesses + * are allowed, so functions that copy data must be aware of this. + * + * the chip is an intel chip. this means that the byte order + * on all the "short"s in the chip's data structures is wrong. + * so, constants described in the intel docs are swapped for the sun. + * that means that any buffer pointers you give the chip must be + * swapped to intel format. yuck. + * + * VME/multibus interface: + * for the multibus interface the board ignores the top 4 bits + * of the chip address. the multibus interface seems to have its + * own MMU like page map (without protections or valid bits, etc). + * there are 256 pages of physical memory on the board (each page + * is 1024 bytes). there are 1024 slots in the page map. so, + * a 1024 byte page takes up 10 bits of address for the offset, + * and if there are 1024 slots in the page that is another 10 bits + * of the address. that makes a 20 bit address, and as stated + * earlier the board ignores the top 4 bits, so that accounts + * for all 24 bits of address. + * + * note that the last entry of the page map maps the top of the + * 24 bit address space and that the SCP is supposed to be at + * 0xfffff4 (taking into account allignment). so, + * for multibus, that entry in the page map has to be used for the SCP. + * + * the page map effects BOTH how the ie chip sees the + * memory, and how the host sees it. + * + * the page map is part of the "register" area of the board + * + * on-board interface: + * + * <fill in useful info later> + * + * + * VME3E interface: + * + * <fill in useful info later> + * + */ + +/* + * PART 1: VME/multibus defs + */ +#define IEVME_PAGESIZE 1024 /* bytes */ +#define IEVME_PAGSHIFT 10 /* bits */ +#define IEVME_NPAGES 256 /* number of pages on chip */ +#define IEVME_MAPSZ 1024 /* number of entries in the map */ + +/* + * PTE for the page map + */ +#define IEVME_SBORDR 0x8000 /* sun byte order */ +#define IEVME_IBORDR 0x0000 /* intel byte ordr */ + +#define IEVME_P2MEM 0x2000 /* memory is on P2 */ +#define IEVME_OBMEM 0x0000 /* memory is on board */ + +#define IEVME_PGMASK 0x0fff /* gives the physical page frame number */ + +struct ievme { + u_short pgmap[IEVME_MAPSZ]; + u_short xxx[32]; /* prom */ + u_short status; /* see below for bits */ + u_short xxx2; /* filler */ + u_short pectrl; /* parity control (see below) */ + u_short peaddr; /* low 16 bits of address */ +}; +/* + * status bits + */ +#define IEVME_RESET 0x8000 /* reset board */ +#define IEVME_ONAIR 0x4000 /* go out of loopback 'on-air' */ +#define IEVME_ATTEN 0x2000 /* attention */ +#define IEVME_IENAB 0x1000 /* interrupt enable */ +#define IEVME_PEINT 0x0800 /* parity error interrupt enable */ +#define IEVME_PERR 0x0200 /* parity error flag */ +#define IEVME_INT 0x0100 /* interrupt flag */ +#define IEVME_P2EN 0x0020 /* enable p2 bus */ +#define IEVME_256K 0x0010 /* 256kb rams */ +#define IEVME_HADDR 0x000f /* mask for bits 17-20 of address */ + +/* + * parity control + */ +#define IEVME_PARACK 0x0100 /* parity error ack */ +#define IEVME_PARSRC 0x0080 /* parity error source */ +#define IEVME_PAREND 0x0040 /* which end of the data got the error */ +#define IEVME_PARADR 0x000f /* mask to get bits 17-20 of parity address */ + + +/* + * PART 2: the on-board interface + */ +struct ieob { + u_char obctrl; +}; +#define IEOB_NORSET 0x80 /* don't reset the board */ +#define IEOB_ONAIR 0x40 /* put us on the air */ +#define IEOB_ATTEN 0x20 /* attention! */ +#define IEOB_IENAB 0x10 /* interrupt enable */ +#define IEOB_XXXXX 0x08 /* free bit */ +#define IEOB_XCVRL2 0x04 /* level 2 transceiver? */ +#define IEOB_BUSERR 0x02 /* bus error */ +#define IEOB_INT 0x01 /* interrupt */ + +#define IEOB_ADBASE 0xff000000 /* KVA base addr of 24 bit address space */ + +/* + * PART 3: the 3E board + */ + +/* + * not supported (yet?) + */ diff --git a/sys/arch/mvme88k/stand/netboot/if_le.c b/sys/arch/mvme88k/stand/netboot/if_le.c new file mode 100644 index 00000000000..0d08efc1077 --- /dev/null +++ b/sys/arch/mvme88k/stand/netboot/if_le.c @@ -0,0 +1,460 @@ +/* $Id: if_le.c,v 1.1 1997/03/03 19:30:37 rahnds Exp $ */ + +/* + * Copyright (c) 1995 Theo de Raadt + * + * 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 under OpenBSD by + * Theo de Raadt for Willowglen Singapore. + * 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. + * + * Copyright (c) 1993 Adam Glass + * 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 Adam Glass. + * 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 Adam Glass ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/types.h> + +#include <netinet/in.h> +#include <netinet/in_systm.h> + +#include "stand.h" +#include "netif.h" +#include "config.h" + +#include "if_lereg.h" + +int le_debug = 0; + +void le_end __P((struct netif *)); +void le_error __P((struct netif *, char *, volatile struct lereg1 *)); +int le_get __P((struct iodesc *, void *, size_t, time_t)); +void le_init __P((struct iodesc *, void *)); +int le_match __P((struct netif *, void *)); +int le_poll __P((struct iodesc *, void *, int)); +int le_probe __P((struct netif *, void *)); +int le_put __P((struct iodesc *, void *, size_t)); +void le_reset __P((struct netif *, u_char *)); + +struct netif_stats le_stats; + +struct netif_dif le0_dif = { + 0, /* unit */ + 1, /* nsel */ + &le_stats, + 0, + 0, +}; + +struct netif_driver le_driver = { + "le", /* netif_bname */ + le_match, /* match */ + le_probe, /* probe */ + le_init, /* init */ + le_get, /* get */ + le_put, /* put */ + le_end, /* end */ + &le0_dif, /* netif_ifs */ + 1, /* netif_nifs */ +}; + +struct le_configuration { + unsigned int phys_addr; + int used; +} le_config[] = { + { LANCE_REG_ADDR, 0 } +}; + +int nle_config = sizeof(le_config) / (sizeof(le_config[0])); + +struct { + struct lereg1 *sc_r1; /* LANCE registers */ + struct lereg2 *sc_r2; /* RAM */ + int next_rmd; + int next_tmd; +} le_softc; + +int +le_match(nif, machdep_hint) + struct netif *nif; + void *machdep_hint; +{ + char *name; + int i, val = 0; + extern int cputyp; + + if (cputyp != CPU_147) + return (0); + name = machdep_hint; + if (name && !bcmp(le_driver.netif_bname, name, 2)) + val += 10; + for (i = 0; i < nle_config; i++) { + if (le_config[i].used) + continue; + if (le_debug) + printf("le%d: le_match --> %d\n", i, val + 1); + le_config[i].used++; + return val + 1; + } + if (le_debug) + printf("le%d: le_match --> 0\n", i); + return 0; +} + +int +le_probe(nif, machdep_hint) + struct netif *nif; + void *machdep_hint; +{ + extern int cputyp; + + /* the set unit is the current unit */ + if (le_debug) + printf("le%d: le_probe called\n", nif->nif_unit); + + if (cputyp == CPU_147) + return 0; + return 1; +} + +void +le_error(nif, str, ler1) + struct netif *nif; + char *str; + volatile struct lereg1 *ler1; +{ + /* ler1->ler1_rap = LE_CSRO done in caller */ + if (ler1->ler1_rdp & LE_C0_BABL) + panic("le%d: been babbling, found by '%s'\n", nif->nif_unit, str); + if (ler1->ler1_rdp & LE_C0_CERR) { + le_stats.collision_error++; + ler1->ler1_rdp = LE_C0_CERR; + } + if (ler1->ler1_rdp & LE_C0_MISS) { + le_stats.missed++; + ler1->ler1_rdp = LE_C0_MISS; + } + if (ler1->ler1_rdp & LE_C0_MERR) { + printf("le%d: memory error in '%s'\n", nif->nif_unit, str); + panic("memory error"); + } +} + +void +le_reset(nif, myea) + struct netif *nif; + u_char *myea; +{ + struct lereg1 *ler1 = le_softc.sc_r1; + struct lereg2 *ler2 = le_softc.sc_r2; + unsigned int a; + int timo = 100000, stat, i; + + if (le_debug) + printf("le%d: le_reset called\n", nif->nif_unit); + ler1->ler1_rap = LE_CSR0; + ler1->ler1_rdp = LE_C0_STOP; /* do nothing until we are finished */ + + bzero(ler2, sizeof(*ler2)); + + ler2->ler2_mode = LE_MODE_NORMAL; + ler2->ler2_padr[0] = myea[1]; + ler2->ler2_padr[1] = myea[0]; + ler2->ler2_padr[2] = myea[3]; + ler2->ler2_padr[3] = myea[2]; + ler2->ler2_padr[4] = myea[5]; + ler2->ler2_padr[5] = myea[4]; + + + ler2->ler2_ladrf0 = 0; + ler2->ler2_ladrf1 = 0; + + a = (u_int) ler2->ler2_rmd; + ler2->ler2_rlen = LE_RLEN | (a >> 16); + ler2->ler2_rdra = a & LE_ADDR_LOW_MASK; + + a = (u_int) ler2->ler2_tmd; + ler2->ler2_tlen = LE_TLEN | (a >> 16); + ler2->ler2_tdra = a & LE_ADDR_LOW_MASK; + + ler1->ler1_rap = LE_CSR1; + a = (u_int) ler2; + ler1->ler1_rdp = a & LE_ADDR_LOW_MASK; + ler1->ler1_rap = LE_CSR2; + ler1->ler1_rdp = a >> 16; + + for (i = 0; i < LERBUF; i++) { + a = (u_int) & ler2->ler2_rbuf[i]; + ler2->ler2_rmd[i].rmd0 = a & LE_ADDR_LOW_MASK; + ler2->ler2_rmd[i].rmd1_bits = LE_R1_OWN; + ler2->ler2_rmd[i].rmd1_hadr = a >> 16; + ler2->ler2_rmd[i].rmd2 = -LEMTU; + ler2->ler2_rmd[i].rmd3 = 0; + } + for (i = 0; i < LETBUF; i++) { + a = (u_int) & ler2->ler2_tbuf[i]; + ler2->ler2_tmd[i].tmd0 = a & LE_ADDR_LOW_MASK; + ler2->ler2_tmd[i].tmd1_bits = 0; + ler2->ler2_tmd[i].tmd1_hadr = a >> 16; + ler2->ler2_tmd[i].tmd2 = 0; + ler2->ler2_tmd[i].tmd3 = 0; + } + + ler1->ler1_rap = LE_CSR3; + ler1->ler1_rdp = LE_C3_BSWP; + + ler1->ler1_rap = LE_CSR0; + ler1->ler1_rdp = LE_C0_INIT; + do { + if (--timo == 0) { + printf("le%d: init timeout, stat = 0x%x\n", + nif->nif_unit, stat); + break; + } + stat = ler1->ler1_rdp; + } while ((stat & LE_C0_IDON) == 0); + + ler1->ler1_rdp = LE_C0_IDON; + le_softc.next_rmd = 0; + le_softc.next_tmd = 0; + ler1->ler1_rap = LE_CSR0; + ler1->ler1_rdp = LE_C0_STRT; +} + +int +le_poll(desc, pkt, len) + struct iodesc *desc; + void *pkt; + int len; +{ + struct lereg1 *ler1 = le_softc.sc_r1; + struct lereg2 *ler2 = le_softc.sc_r2; + unsigned int a; + int length; + struct lermd *rmd; + + + ler1->ler1_rap = LE_CSR0; + if ((ler1->ler1_rdp & LE_C0_RINT) != 0) + ler1->ler1_rdp = LE_C0_RINT; + rmd = &ler2->ler2_rmd[le_softc.next_rmd]; + if (rmd->rmd1_bits & LE_R1_OWN) { + return (0); + } + if (ler1->ler1_rdp & LE_C0_ERR) + le_error(desc->io_netif, "le_poll", ler1); + if (rmd->rmd1_bits & LE_R1_ERR) { + printf("le%d_poll: rmd status 0x%x\n", desc->io_netif->nif_unit, + rmd->rmd1_bits); + length = 0; + goto cleanup; + } + if ((rmd->rmd1_bits & (LE_R1_STP | LE_R1_ENP)) != (LE_R1_STP | LE_R1_ENP)) + panic("le_poll: chained packet\n"); + + length = rmd->rmd3; + if (length >= LEMTU) { + length = 0; + panic("csr0 when bad things happen: %x\n", ler1->ler1_rdp); + goto cleanup; + } + if (!length) + goto cleanup; + length -= 4; + if (length > 0) { + + /* + * if buffer is smaller than the packet truncate it. + * (is this wise?) + */ + if (length > len) + length = len; + + bcopy((void *)&ler2->ler2_rbuf[le_softc.next_rmd], pkt, length); + } +cleanup: + a = (u_int) & ler2->ler2_rbuf[le_softc.next_rmd]; + rmd->rmd0 = a & LE_ADDR_LOW_MASK; + rmd->rmd1_hadr = a >> 16; + rmd->rmd2 = -LEMTU; + le_softc.next_rmd = + (le_softc.next_rmd == (LERBUF - 1)) ? 0 : (le_softc.next_rmd + 1); + rmd->rmd1_bits = LE_R1_OWN; + return length; +} + +int +le_put(desc, pkt, len) + struct iodesc *desc; + void *pkt; + size_t len; +{ + volatile struct lereg1 *ler1 = le_softc.sc_r1; + volatile struct lereg2 *ler2 = le_softc.sc_r2; + volatile struct letmd *tmd; + int timo = 100000, stat, i; + unsigned int a; + + ler1->ler1_rap = LE_CSR0; + if (ler1->ler1_rdp & LE_C0_ERR) + le_error(desc->io_netif, "le_put(way before xmit)", ler1); + tmd = &ler2->ler2_tmd[le_softc.next_tmd]; + while (tmd->tmd1_bits & LE_T1_OWN) { + printf("le%d: output buffer busy\n", desc->io_netif->nif_unit); + } + bcopy(pkt, (void *)ler2->ler2_tbuf[le_softc.next_tmd], len); + if (len < 64) + tmd->tmd2 = -64; + else + tmd->tmd2 = -len; + tmd->tmd3 = 0; + if (ler1->ler1_rdp & LE_C0_ERR) + le_error(desc->io_netif, "le_put(before xmit)", ler1); + tmd->tmd1_bits = LE_T1_STP | LE_T1_ENP | LE_T1_OWN; + a = (u_int) & ler2->ler2_tbuf[le_softc.next_tmd]; + tmd->tmd0 = a & LE_ADDR_LOW_MASK; + tmd->tmd1_hadr = a >> 16; + ler1->ler1_rdp = LE_C0_TDMD; + if (ler1->ler1_rdp & LE_C0_ERR) + le_error(desc->io_netif, "le_put(after xmit)", ler1); + do { + if (--timo == 0) { + printf("le%d: transmit timeout, stat = 0x%x\n", + desc->io_netif->nif_unit, stat); + if (ler1->ler1_rdp & LE_C0_ERR) + le_error(desc->io_netif, "le_put(timeout)", ler1); + break; + } + stat = ler1->ler1_rdp; + } while ((stat & LE_C0_TINT) == 0); + ler1->ler1_rdp = LE_C0_TINT; + if (ler1->ler1_rdp & LE_C0_ERR) { + if ((ler1->ler1_rdp & (LE_C0_BABL | LE_C0_CERR | LE_C0_MISS | + LE_C0_MERR)) != + LE_C0_CERR) + printf("le_put: xmit error, buf %d\n", le_softc.next_tmd); + le_error(desc->io_netif, "le_put(xmit error)", ler1); + } + le_softc.next_tmd = 0; +/* (le_softc.next_tmd == (LETBUF - 1)) ? 0 : le_softc.next_tmd + 1;*/ + if (tmd->tmd1_bits & LE_T1_DEF) + le_stats.deferred++; + if (tmd->tmd1_bits & LE_T1_ONE) + le_stats.collisions++; + if (tmd->tmd1_bits & LE_T1_MORE) + le_stats.collisions += 2; + if (tmd->tmd1_bits & LE_T1_ERR) { + printf("le%d: transmit error, error = 0x%x\n", desc->io_netif->nif_unit, + tmd->tmd3); + return -1; + } + if (le_debug) { + printf("le%d: le_put() successful: sent %d\n", + desc->io_netif->nif_unit, len); + printf("le%d: le_put(): tmd1_bits: %x tmd3: %x\n", + desc->io_netif->nif_unit, + (unsigned int) tmd->tmd1_bits, + (unsigned int) tmd->tmd3); + } + return len; +} + +int +le_get(desc, pkt, len, timeout) + struct iodesc *desc; + void *pkt; + size_t len; + time_t timeout; +{ + time_t t; + int cc; + + t = getsecs(); + cc = 0; + while (((getsecs() - t) < timeout) && !cc) { + cc = le_poll(desc, pkt, len); + } + return cc; +} +/* + * init le device. return 0 on failure, 1 if ok. + */ +void +le_init(desc, machdep_hint) + struct iodesc *desc; + void *machdep_hint; +{ + u_long eram = 4*1024*1024; + struct netif *nif = desc->io_netif; + + if (le_debug) + printf("le%d: le_init called\n", desc->io_netif->nif_unit); + machdep_common_ether(desc->myea); + bzero(&le_softc, sizeof(le_softc)); + le_softc.sc_r1 = + (struct lereg1 *) le_config[desc->io_netif->nif_unit].phys_addr; + le_softc.sc_r2 = (struct lereg2 *) (eram - (1024 * 1024)); + le_reset(desc->io_netif, desc->myea); + printf("device: %s%d attached to %s\n", nif->nif_driver->netif_bname, + nif->nif_unit, ether_sprintf(desc->myea)); +} + +void +le_end(nif) + struct netif *nif; +{ + struct lereg1 *ler1 = le_softc.sc_r1; + + if (le_debug) + printf("le%d: le_end called\n", nif->nif_unit); + ler1->ler1_rap = LE_CSR0; + ler1->ler1_rdp = LE_C0_STOP; +} diff --git a/sys/arch/mvme88k/stand/netboot/if_lereg.h b/sys/arch/mvme88k/stand/netboot/if_lereg.h new file mode 100644 index 00000000000..92b8a5fb773 --- /dev/null +++ b/sys/arch/mvme88k/stand/netboot/if_lereg.h @@ -0,0 +1,173 @@ +/* $Id: if_lereg.h,v 1.1 1997/03/03 19:30:38 rahnds Exp $ */ + +/*- + * Copyright (c) 1982, 1992, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)if_lereg.h 8.2 (Berkeley) 10/30/93 + */ + +#define LEMTU 1518 +#define LEMINSIZE 60 /* should be 64 if mode DTCR is set */ +#define LERBUF 8 +#define LERBUFLOG2 3 +#define LE_RLEN (LERBUFLOG2 << 13) +#define LETBUF 1 +#define LETBUFLOG2 0 +#define LE_TLEN (LETBUFLOG2 << 13) + +/* Local Area Network Controller for Ethernet (LANCE) registers */ +struct lereg1 { + volatile u_short ler1_rdp; /* register data port */ + volatile u_short ler1_rap; /* register address port */ +}; +/* register addresses */ +#define LE_CSR0 0 /* Control and status register */ +#define LE_CSR1 1 /* low address of init block */ +#define LE_CSR2 2 /* high address of init block */ +#define LE_CSR3 3 /* Bus master and control */ + +/* Control and status register 0 (csr0) */ +#define LE_C0_ERR 0x8000 /* error summary */ +#define LE_C0_BABL 0x4000 /* transmitter timeout error */ +#define LE_C0_CERR 0x2000 /* collision */ +#define LE_C0_MISS 0x1000 /* missed a packet */ +#define LE_C0_MERR 0x0800 /* memory error */ +#define LE_C0_RINT 0x0400 /* receiver interrupt */ +#define LE_C0_TINT 0x0200 /* transmitter interrupt */ +#define LE_C0_IDON 0x0100 /* initalization done */ +#define LE_C0_INTR 0x0080 /* interrupt condition */ +#define LE_C0_INEA 0x0040 /* interrupt enable */ +#define LE_C0_RXON 0x0020 /* receiver on */ +#define LE_C0_TXON 0x0010 /* transmitter on */ +#define LE_C0_TDMD 0x0008 /* transmit demand */ +#define LE_C0_STOP 0x0004 /* disable all external activity */ +#define LE_C0_STRT 0x0002 /* enable external activity */ +#define LE_C0_INIT 0x0001 /* begin initalization */ + +#define LE_C0_BITS \ + "\20\20ERR\17BABL\16CERR\15MISS\14MERR\13RINT\ +\12TINT\11IDON\10INTR\07INEA\06RXON\05TXON\04TDMD\03STOP\02STRT\01INIT" + +/* Control and status register 3 (csr3) */ +#define LE_C3_BSWP 0x4 /* byte swap */ +#define LE_C3_ACON 0x2 /* ALE control, eh? */ +#define LE_C3_BCON 0x1 /* byte control */ +/* + * Current size is 13,758 bytes with 8 x 1518 receive buffers and + * 1 x 1518 transmit buffer. + */ +struct lereg2 { + /* initialization block */ + volatile u_short ler2_mode; /* mode */ + volatile u_char ler2_padr[6]; /* physical address */ +#ifdef new_code + volatile u_short ler2_ladrf[4]; /* logical address filter */ +#else + volatile u_long ler2_ladrf0; /* logical address filter */ + volatile u_long ler2_ladrf1; /* logical address filter */ +#endif + volatile u_short ler2_rdra; /* receive descriptor addr */ + volatile u_short ler2_rlen; /* rda high and ring size */ + volatile u_short ler2_tdra; /* transmit descriptor addr */ + volatile u_short ler2_tlen; /* tda high and ring size */ + /* receive message descriptors. bits/hadr are byte order dependent. */ + struct lermd { + volatile u_short rmd0; /* low address of packet */ + volatile u_char rmd1_bits; /* descriptor bits */ + volatile u_char rmd1_hadr; /* high address of packet */ + volatile short rmd2; /* buffer byte count */ + volatile u_short rmd3; /* message byte count */ + } ler2_rmd[LERBUF]; + /* transmit message descriptors */ + struct letmd { + volatile u_short tmd0; /* low address of packet */ + volatile u_char tmd1_bits; /* descriptor bits */ + volatile u_char tmd1_hadr; /* high address of packet */ + volatile short tmd2; /* buffer byte count */ + volatile u_short tmd3; /* transmit error bits */ + } ler2_tmd[LETBUF]; + volatile char ler2_rbuf[LERBUF][LEMTU]; + volatile char ler2_tbuf[LETBUF][LEMTU]; +}; +/* Initialzation block (mode) */ +#define LE_MODE_PROM 0x8000 /* promiscuous mode */ +/* 0x7f80 reserved, must be zero */ +#define LE_MODE_INTL 0x0040 /* internal loopback */ +#define LE_MODE_DRTY 0x0020 /* disable retry */ +#define LE_MODE_COLL 0x0010 /* force a collision */ +#define LE_MODE_DTCR 0x0008 /* disable transmit CRC */ +#define LE_MODE_LOOP 0x0004 /* loopback mode */ +#define LE_MODE_DTX 0x0002 /* disable transmitter */ +#define LE_MODE_DRX 0x0001 /* disable receiver */ +#define LE_MODE_NORMAL 0 /* none of the above */ + + +/* Receive message descriptor 1 (rmd1_bits) */ +#define LE_R1_OWN 0x80 /* LANCE owns the packet */ +#define LE_R1_ERR 0x40 /* error summary */ +#define LE_R1_FRAM 0x20 /* framing error */ +#define LE_R1_OFLO 0x10 /* overflow error */ +#define LE_R1_CRC 0x08 /* CRC error */ +#define LE_R1_BUFF 0x04 /* buffer error */ +#define LE_R1_STP 0x02 /* start of packet */ +#define LE_R1_ENP 0x01 /* end of packet */ + +#define LE_R1_BITS \ + "\20\10OWN\7ERR\6FRAM\5OFLO\4CRC\3BUFF\2STP\1ENP" + +/* Transmit message descriptor 1 (tmd1_bits) */ +#define LE_T1_OWN 0x80 /* LANCE owns the packet */ +#define LE_T1_ERR 0x40 /* error summary */ +#define LE_T1_MORE 0x10 /* multiple collisions */ +#define LE_T1_ONE 0x08 /* single collision */ +#define LE_T1_DEF 0x04 /* defferred transmit */ +#define LE_T1_STP 0x02 /* start of packet */ +#define LE_T1_ENP 0x01 /* end of packet */ + +#define LE_T1_BITS \ + "\20\10OWN\7ERR\6RES\5MORE\4ONE\3DEF\2STP\1ENP" + +/* Transmit message descriptor 3 (tmd3) */ +#define LE_T3_BUFF 0x8000 /* buffer error */ +#define LE_T3_UFLO 0x4000 /* underflow error */ +#define LE_T3_LCOL 0x1000 /* late collision */ +#define LE_T3_LCAR 0x0800 /* loss of carrier */ +#define LE_T3_RTRY 0x0400 /* retry error */ +#define LE_T3_TDR_MASK 0x03ff /* time domain reflectometry counter */ + +#define LE_XMD2_ONES 0xf000 + +#define LE_T3_BITS \ + "\20\20BUFF\17UFLO\16RES\15LCOL\14LCAR\13RTRY" + + +#define LE_ADDR_LOW_MASK (0xffff) diff --git a/sys/arch/mvme88k/stand/netboot/netboot b/sys/arch/mvme88k/stand/netboot/netboot Binary files differnew file mode 100644 index 00000000000..a2fe675457c --- /dev/null +++ b/sys/arch/mvme88k/stand/netboot/netboot diff --git a/sys/arch/mvme88k/stand/netboot/netboot.bin b/sys/arch/mvme88k/stand/netboot/netboot.bin Binary files differnew file mode 100644 index 00000000000..2c1b35d8fa7 --- /dev/null +++ b/sys/arch/mvme88k/stand/netboot/netboot.bin diff --git a/sys/arch/mvme88k/stand/netboot/nfs.s b/sys/arch/mvme88k/stand/netboot/nfs.s new file mode 100644 index 00000000000..067b5084976 --- /dev/null +++ b/sys/arch/mvme88k/stand/netboot/nfs.s @@ -0,0 +1,542 @@ +#NO_APP +gcc2_compiled.: +___gnu_compiled_c: +.text + .even +.globl _nfs_getrootfh + .type _nfs_getrootfh,@function +_nfs_getrootfh: + link a6,#-392 + moveml #0x3038,sp@- + movel a6@(12),d3 + lea a6@(-132),a2 + lea a6@(-280),a3 + pea 132:w + movel a2,sp@- + jbsr _bzero + movel d3,sp@- + jbsr _strlen + movel d0,d2 + addqw #8,sp + addqw #4,sp + moveq #120,d0 + addqw #8,d0 + cmpl d2,d0 + jcc L2 + movel d0,d2 +L2: + movel d2,a2@ + movel d2,sp@- + pea a6@(-128) + movel d3,sp@- + lea _bcopy,a4 + jbsr a4@ + movel d2,d0 + addql #3,d0 + jpl L3 + movel d2,d0 + addql #6,d0 +L3: + moveq #-4,d1 + andl d1,d0 + pea 36:w + movel a3,sp@- + movel d0,a0 + pea a0@(4) + movel a2,sp@- + pea 1:w + pea 1:w + movel #100005,sp@- + movel a6@(8),sp@- + jbsr _rpc_call + addw #44,sp + moveq #-1,d1 + cmpl d0,d1 + jeq L7 + moveq #3,d1 + cmpl d0,d1 + jcs L5 + moveq #72,d1 + movel d1,_errno + jra L8 +L5: + tstl a3@ + jne L6 + pea 32:w + movel a6@(16),sp@- + pea a3@(4) + jbsr a4@ + clrl d0 + jra L7 +L6: + movel a3@,_errno +L8: + moveq #-1,d0 +L7: + moveml a6@(-412),#0x1c0c + unlk a6 + rts +Lfe1: + .size _nfs_getrootfh,Lfe1-_nfs_getrootfh + .even +.globl _nfs_lookupfh + .type _nfs_lookupfh,@function +_nfs_lookupfh: + link a6,#-492 + moveml #0x303c,sp@- + movel a6@(8),a5 + movel a6@(12),d3 + lea a6@(-164),a2 + lea a6@(-380),a3 + pea 164:w + movel a2,sp@- + jbsr _bzero + pea 32:w + movel a2,sp@- + pea a5@(12) + lea _bcopy,a4 + jbsr a4@ + movel d3,sp@- + jbsr _strlen + movel d0,d2 + addw #24,sp + moveq #120,d0 + addqw #8,d0 + cmpl d2,d0 + jcc L10 + movel d0,d2 +L10: + movel d2,sp@- + pea a6@(-128) + movel d3,sp@- + jbsr a4@ + movel d2,a6@(-132) + movel d2,d0 + addql #3,d0 + jpl L11 + movel d2,d0 + addql #6,d0 +L11: + moveq #-4,d1 + andl d1,d0 + pea 104:w + movel a3,sp@- + movel d0,a0 + pea a0@(36) + movel a2,sp@- + pea 4:w + pea 2:w + movel #100003,sp@- + movel a5@,sp@- + jbsr _rpc_call + addw #44,sp + moveq #-1,d1 + cmpl d0,d1 + jne L12 + movel _errno,d0 + jra L15 +L12: + moveq #3,d1 + cmpl d0,d1 + jlt L13 + moveq #5,d0 + jra L15 +L13: + tstl a3@ + jne L14 + pea 32:w + movel a6@(16),a0 + pea a0@(12) + pea a3@(4) + jbsr a4@ + pea 68:w + movel a6@(16),a0 + pea a0@(44) + pea a3@(36) + jbsr a4@ + clrl d0 + jra L15 +L14: + movel a3@,d0 +L15: + moveml a6@(-516),#0x3c0c + unlk a6 + rts +Lfe2: + .size _nfs_lookupfh,Lfe2-_nfs_lookupfh +LC0: + .ascii "nfsread: short packet, %d < %d\12\0" + .even +.globl _nfs_readdata + .type _nfs_readdata,@function +_nfs_readdata: + link a6,#-1368 + moveml #0x383c,sp@- + movel a6@(8),a4 + movel a6@(12),d2 + movel a6@(16),d3 + movel a6@(24),d4 + lea a6@(-44),a3 + lea a6@(-1256),a2 + pea 32:w + movel a3,sp@- + pea a4@(12) + lea _bcopy,a5 + jbsr a5@ + movel d3,a6@(-12) + addqw #8,sp + addqw #4,sp + movel #1024,d0 + cmpl d4,d0 + jcc L17 + movel d0,d4 +L17: + movel d4,a6@(-8) + clrl a6@(-4) + pea 1100:w + movel a2,sp@- + pea 44:w + movel a3,sp@- + pea 6:w + pea 2:w + movel #100003,sp@- + movel a4@,sp@- + jbsr _rpc_call + movel d0,a0 + addw #32,sp + moveq #-1,d1 + cmpl a0,d1 + jeq L22 + moveq #76,d1 + cmpl a0,d1 + jhi L23 + tstl a2@ + jeq L20 + movel a2@,_errno + jra L24 +L20: + addw #-76,a0 + movel a6@(-1184),d2 + cmpl a0,d2 + jgt L21 + movel d2,sp@- + movel a6@(20),sp@- + pea a2@(76) + jbsr a5@ + movel d2,d0 + jra L22 +L21: + movel d2,sp@- + movel a0,sp@- + pea LC0 + jbsr _printf +L23: + moveq #72,d1 + movel d1,_errno +L24: + moveq #-1,d0 +L22: + moveml a6@(-1396),#0x3c1c + unlk a6 + rts +Lfe3: + .size _nfs_readdata,Lfe3-_nfs_readdata + .even +.globl _nfs_mount + .type _nfs_mount,@function +_nfs_mount: + link a6,#0 + movel a2,sp@- + movel a6@(8),sp@- + jbsr _socktodesc + movel d0,a2 + addqw #4,sp + tstl a2 + jeq L26 + movel _rpc_port,d0 + subql #1,d0 + movel d0,_rpc_port + movew d0,a2@(10) + movel a6@(12),a2@ + pea _nfs_root_node+12 + movel a6@(16),sp@- + movel a2,sp@- + jbsr _nfs_getrootfh + tstl d0 + jne L27 + movel a2,_nfs_root_node + moveq #2,d1 + movel d1,_nfs_root_node+44 + movel #493,_nfs_root_node+48 + movel d1,_nfs_root_node+52 + clrl d0 + jra L28 +L26: + moveq #22,d1 + movel d1,_errno +L27: + moveq #-1,d0 +L28: + movel a6@(-4),a2 + unlk a6 + rts +Lfe4: + .size _nfs_mount,Lfe4-_nfs_mount +LC1: + .ascii "nfs_open: must mount first.\12\0" + .even +.globl _nfs_open + .type _nfs_open,@function +_nfs_open: + link a6,#0 + moveml #0x2038,sp@- + movel a6@(12),a4 + lea _nfs_root_node,a3 + tstl a3@ + jne L30 + pea LC1 + jbsr _printf + moveq #6,d0 + jra L32 +L30: + pea 112:w + jbsr _alloc + movel d0,a2 + movel a3@,a2@ + clrl a2@(4) + clrl a2@(8) + movel a2,sp@- + movel a6@(8),sp@- + movel a3,sp@- + jbsr _nfs_lookupfh + movel d0,d2 + addqw #8,sp + addqw #8,sp + jeq L31 + pea 112:w + movel a2,sp@- + jbsr _free + movel d2,d0 + jra L32 +L31: + movel a2,a4@(16) + clrl d0 +L32: + moveml a6@(-16),#0x1c04 + unlk a6 + rts +Lfe5: + .size _nfs_open,Lfe5-_nfs_open + .even +.globl _nfs_close + .type _nfs_close,@function +_nfs_close: + link a6,#0 + movel a2,sp@- + movel a6@(8),a2 + movel a2@(16),d0 + jeq L34 + pea 112:w + movel d0,sp@- + jbsr _free +L34: + clrl a2@(16) + clrl d0 + movel a6@(-4),a2 + unlk a6 + rts +Lfe6: + .size _nfs_close,Lfe6-_nfs_close +LC2: + .ascii "nfs_read: hit EOF unexpectantly\0" + .even +.globl _nfs_read + .type _nfs_read,@function +_nfs_read: + link a6,#0 + moveml #0x3f3c,sp@- + movel a6@(8),a0 + movel a6@(16),a3 + movel a6@(20),a5 + movel a0@(16),a2 + movel a6@(12),a4 + tstl a3 + jle L41 +L42: + jbsr _twiddle + movel a3,sp@- + movel a4,sp@- + movel a2@(8),sp@- + movel a2@(4),sp@- + movel a2,sp@- + jbsr _nfs_readdata + movel d0,d7 + addw #20,sp + moveq #-1,d5 + cmpl d7,d5 + jne L38 + movel _errno,d0 + jra L44 +L38: + tstl d7 + jne L39 + tstl _debug + jeq L41 + pea LC2 + jbsr _printf + jra L41 +L39: + movel d7,d4 + movel d7,d3 + moveq #31,d5 + asrl d5,d3 + movel d4,d2 + addl a2@(8),d2 + cmpl d2,d4 + shi d0 + extbl d0 + movel d3,d1 + addl a2@(4),d1 + subl d0,d1 + movel d1,a2@(4) + movel d2,a2@(8) + addl d7,a4 + subl d7,a3 + tstl a3 + jgt L42 +L41: + tstl a5 + jeq L43 + movel a3,a5@ +L43: + clrl d0 +L44: + moveml a6@(-40),#0x3cfc + unlk a6 + rts +Lfe7: + .size _nfs_read,Lfe7-_nfs_read + .even +.globl _nfs_write + .type _nfs_write,@function +_nfs_write: + link a6,#0 + moveq #30,d0 + unlk a6 + rts +Lfe8: + .size _nfs_write,Lfe8-_nfs_write + .even +.globl _nfs_seek + .type _nfs_seek,@function +_nfs_seek: + link a6,#0 + moveml #0x3f00,sp@- + movel a6@(8),a0 + movel a6@(12),d5 + movel a6@(16),d6 + movel a6@(20),d0 + movel a0@(16),a0 + movel a0@(64),d1 + moveq #1,d7 + cmpl d0,d7 + jeq L49 + jlt L53 + tstl d0 + jeq L48 + jra L51 +L53: + moveq #2,d7 + cmpl d0,d7 + jeq L50 + jra L51 +L48: + movel d5,a0@(4) + movel d6,a0@(8) + jra L47 +L49: + movel a0@(4),d3 + movel a0@(8),d4 + movel d6,d2 + addl d4,d2 + cmpl d2,d6 + shi d0 + extbl d0 + movel d5,d1 + addl d3,d1 + subl d0,d1 + movel d1,a0@(4) + movel d2,a0@(8) + jra L47 +L50: + movel d1,d4 + clrl d3 + movel d4,d2 + subl d6,d2 + cmpl d2,d4 + scs d0 + extbl d0 + movel d3,d1 + subl d5,d1 + addl d0,d1 + movel d1,a0@(4) + movel d2,a0@(8) + jra L47 +L51: + moveq #-1,d0 + moveq #-1,d1 + jra L54 +L47: + movel a0@(4),d0 + movel a0@(8),d1 +L54: + moveml a6@(-24),#0xfc + unlk a6 + rts +Lfe9: + .size _nfs_seek,Lfe9-_nfs_seek +.globl _nfs_stat_types +.data + .even + .type _nfs_stat_types,@object + .size _nfs_stat_types,32 +_nfs_stat_types: + .long 0 + .long 32768 + .long 16384 + .long 24576 + .long 8192 + .long 40960 + .long 0 + .skip 4 +.text + .even +.globl _nfs_stat + .type _nfs_stat,@function +_nfs_stat: + link a6,#0 + movel a2,sp@- + movel d2,sp@- + movel a6@(8),a0 + movel a6@(12),a2 + movel a0@(16),a1 + moveq #7,d0 + andl a1@(44),d0 + lea _nfs_stat_types,a0 + movew a1@(50),d2 + orw a0@(2,d0:l:4),d2 + movew d2,a2@(8) + movew a1@(54),a2@(10) + movel a1@(56),a2@(12) + movel a1@(60),a2@(16) + movel a1@(64),d1 + clrl d0 + movel d0,a2@(48) + movel d1,a2@(52) + movel a6@(-8),d2 + movel a6@(-4),a2 + unlk a6 + rts +Lfe10: + .size _nfs_stat,Lfe10-_nfs_stat +.comm _nfs_root_node,112 diff --git a/sys/arch/mvme88k/stand/netboot/version.c b/sys/arch/mvme88k/stand/netboot/version.c new file mode 100644 index 00000000000..279f398c44d --- /dev/null +++ b/sys/arch/mvme88k/stand/netboot/version.c @@ -0,0 +1,9 @@ +/* $Id: version.c,v 1.1 1997/03/03 19:30:38 rahnds Exp $ */ + +/* + * NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. + * + * 1.1 + */ + +char *version = "$Revision: 1.1 $"; diff --git a/sys/arch/mvme88k/stand/obj.m88k/boot b/sys/arch/mvme88k/stand/obj.m88k/boot Binary files differnew file mode 100644 index 00000000000..30d5f26c387 --- /dev/null +++ b/sys/arch/mvme88k/stand/obj.m88k/boot diff --git a/sys/arch/mvme88k/stand/obj.m88k/boot.1 b/sys/arch/mvme88k/stand/obj.m88k/boot.1 Binary files differnew file mode 100644 index 00000000000..112b445d07d --- /dev/null +++ b/sys/arch/mvme88k/stand/obj.m88k/boot.1 diff --git a/sys/arch/mvme88k/stand/obj.m88k/boot.2 b/sys/arch/mvme88k/stand/obj.m88k/boot.2 Binary files differnew file mode 100644 index 00000000000..6248ab12051 --- /dev/null +++ b/sys/arch/mvme88k/stand/obj.m88k/boot.2 diff --git a/sys/arch/mvme88k/stand/old/Makefile b/sys/arch/mvme88k/stand/old/Makefile new file mode 100644 index 00000000000..39788d542fb --- /dev/null +++ b/sys/arch/mvme88k/stand/old/Makefile @@ -0,0 +1,4 @@ +SUBDIRS = libbug kerncrt boot bugexec +SUBDIR = libbug kerncrt boot bugexec + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/old/boot/Makefile b/sys/arch/mvme88k/stand/old/boot/Makefile new file mode 100644 index 00000000000..df343d81f70 --- /dev/null +++ b/sys/arch/mvme88k/stand/old/boot/Makefile @@ -0,0 +1,30 @@ +all: boot boot.out +CFLAGS+=-fwritable-strings -I${.CURDIR}/../include +CFLAGS+=-I${.CURDIR}/../.. -I${.CURDIR}/../../machine +CFLAGS+=-I/usr/src/sys +LDFLAGS+= -L ${.CURDIR}/../libbug -L/usr/local/lib +BOOT=FC0000 +#BOOT=1000000 + +LIBBUG!= cd $(.CURDIR)/../libbug; \ + printf "xxx:\n\techo \$${.OBJDIR}/libbug.a\n" | ${MAKE} -r -s -f - xxx + +LDADD+=${LIBBUG} #/usr/local/lib/libgcc.a +SRCS+=bugcrt.c bugio.c main.c + +.PATH: ${.CURDIR}/../bugcrt ${.CURDIR}/../libbug ${.CURDIR}/../../../../lib/libc_sa ${.CURDIR}/${MACHINE_ARCH} + +boot: bugcrt.o main.o bcopy.o memset.o printf.o ${LIBBUG} +# ld -o {.TARGET} -x -n -Ttext ${BOOT} bugcrt.o bugio.o main.o bcopy.o memset.o printf.o /usr/local/lib/libgcc.a + ld -o ${.TARGET} -x -N -Ttext ${BOOT} ${.ALLSRC} ${LDADD} + +boot.out: + ${.CURDIR}/wrtvid ${.OBJDIR}/boot && mv ${.OBJDIR}/boot.? ${.CURDIR} + +#main.o: main.c +# ${CC} ${CFLAGS} -c -O ${.ALLSRC} +# ${LD} -x -r ${.TARGET} +# ${LD} -x ${.TARGET} +# mv a.out ${.TARGET} + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/old/boot/boot.1 b/sys/arch/mvme88k/stand/old/boot/boot.1 Binary files differnew file mode 100644 index 00000000000..03aa7928309 --- /dev/null +++ b/sys/arch/mvme88k/stand/old/boot/boot.1 diff --git a/sys/arch/mvme88k/stand/old/boot/boot.2 b/sys/arch/mvme88k/stand/old/boot/boot.2 Binary files differnew file mode 100644 index 00000000000..f1ebc35b445 --- /dev/null +++ b/sys/arch/mvme88k/stand/old/boot/boot.2 diff --git a/sys/arch/mvme88k/stand/old/boot/foo b/sys/arch/mvme88k/stand/old/boot/foo Binary files differnew file mode 100644 index 00000000000..53aac89a35e --- /dev/null +++ b/sys/arch/mvme88k/stand/old/boot/foo diff --git a/sys/arch/mvme88k/stand/old/boot/foo.1 b/sys/arch/mvme88k/stand/old/boot/foo.1 Binary files differnew file mode 100644 index 00000000000..53aac89a35e --- /dev/null +++ b/sys/arch/mvme88k/stand/old/boot/foo.1 diff --git a/sys/arch/mvme88k/stand/old/boot/foo.2 b/sys/arch/mvme88k/stand/old/boot/foo.2 Binary files differnew file mode 100644 index 00000000000..dcef04fabfb --- /dev/null +++ b/sys/arch/mvme88k/stand/old/boot/foo.2 diff --git a/sys/arch/mvme88k/stand/old/boot/main.c b/sys/arch/mvme88k/stand/old/boot/main.c new file mode 100644 index 00000000000..0759c9f2644 --- /dev/null +++ b/sys/arch/mvme88k/stand/old/boot/main.c @@ -0,0 +1,264 @@ +#include <sys/param.h> +#include <sys/reboot.h> +#include "bug.h" +#include "bugio.h" +#include "machine/exec.h" + +int readblk __P((int, char *)); +int loados __P((void)); +void putchar __P((char)); +void _main __P((void)); +void tapefileseek __P((int)); + +char Clun, Dlun; + +#define DEV_BSIZE 512 +#define KERNEL_LOAD_ADDR 0x10000 +#if !defined(BUG_BLKSIZE) +#define BUG_BLKSIZE 256 +#endif /* BUG_BLKSIZE */ +#define sec2blk(x) ((x) * (DEV_BSIZE/BUG_BLKSIZE)) + +struct kernel { + void *entry; + void *symtab; + void *esym; + int bflags; + int bdev; + char *kname; + void *smini; + void *emini; + unsigned int end_loaded; +} kernel; + +int howto = 0; +int bootdev = 0; +int *miniroot; + +void +putchar(char c) +{ + bugoutchr(c); +} + +main(struct bugenv *env) +{ + printf("Clun %x Dlun %x\n", env->clun, env->dlun); + Clun = (char)env->clun; + Dlun = (char)env->dlun; + loados(); + return; +} + + +loados(void) +{ + int i, size; + register char *loadaddr = (char *)KERNEL_LOAD_ADDR; /* load addr 64k*/ + struct exec *hdr; + int (*fptr)(); + int *esym; + int cnt, strtablen, ret; + char *addr; + + howto |= RB_SINGLE|RB_KDB; + + tapefileseek(2); /* seek to file 2 - the OS */ + if (readblk(1, loadaddr) == -1) { + printf("Unable to read blk 0\n"); + return 1; + } + hdr = (struct exec *)loadaddr; + + /* We only deal with ZMAGIC files */ + if ((int)hdr->a_entry != (int)(loadaddr + sizeof(struct exec))) { + printf("a_entry != loadaddr + exec size\n"); + } + size = hdr->a_text + hdr->a_data; + size -= DEV_BSIZE; /* account for the block already read */ + + printf("Loading [%x+%x", hdr->a_text, hdr->a_data); + if (readblk(size / DEV_BSIZE, loadaddr + DEV_BSIZE) == -1) { + printf("Error reading the OS\n"); + return 1; + } + + /* zero out BSS */ + + printf("+%x]", hdr->a_bss); +#if DEBUG + printf("zero'd out %x (%x)\n", loadaddr + hdr->a_text + hdr->a_data, + hdr->a_bss); +#endif + memset(loadaddr + hdr->a_text + hdr->a_data, 0, hdr->a_bss); + + addr = loadaddr + hdr->a_text + hdr->a_data + hdr->a_bss; + + if (hdr->a_syms != 0 /* && !(kernel.bflags & RB_NOSYM)*/) { + /* + * DDB expects the following layout: + * no. of syms + * symbols + * size of strtab + * entries of strtab + * esym->... + * Where as size of strtab is part of strtab, we need + * to prepend the size of symtab to satisfy ddb. + * esym is expected to point past the last byte of + * string table, rouded up to an int. + */ + bcopy(&hdr->a_syms, addr, sizeof(hdr->a_syms)); + addr += 4; /* account for a_syms copied above */ + printf (" + [ %x",hdr->a_syms); + + cnt = (hdr->a_syms + DEV_BSIZE - 1) & ~(DEV_BSIZE - 1); + + ret = readblk(cnt / DEV_BSIZE, addr); + if (ret != 0) { + printf("unable to load kernel\n"); + return 1; + } + + esym = (void *) ((int)addr + hdr->a_syms); + + if ((int)addr + cnt <= (int)esym) { + printf("missed loading count of symbols\n\r"); + return 1; + } + + addr += cnt; + + strtablen = *esym; +#if 0 + printf("start load %x end load %x %x\n", addr, + len, addr +len); + printf("esym %x *esym %x\n",esym, len); +#endif + /* + * If symbol table size is not a sector multiple, we + * already read part of the string table. Look at the + * part already read, and figure out the string table + * size. Also, adjust the size yet to read. + */ + if (hdr->a_syms != cnt) { + /* already read part of the string table */ + strtablen -= (cnt - hdr->a_syms); + } + + if (strtablen > 0) { + printf(" + %x",*esym); + + cnt = (strtablen + DEV_BSIZE -1) & ~(DEV_BSIZE - 1); + + ret = readblk(cnt / DEV_BSIZE, addr); + if (ret != 0) { + printf("unable to load kernel\n"); + return 1; + } + addr += strtablen; + printf(" ]\n"); + } else { + printf("+ %x ]\n", *esym); + } + esym = (int *)(((int)esym) + *esym); + esym = (int *)(((int)esym + 4 - 1) & ~3); + + kernel.symtab = (void *)hdr->a_syms; + kernel.esym = esym; + } else { + kernel.symtab = 0; + kernel.esym = 0; + } + + kernel.end_loaded = (unsigned int)addr; + miniroot = (int *)esym; + miniroot = (int *)(((int)miniroot + 0x1000 - 1) & ~0xFFF); + tapefileseek(3); /* seek to file 3 - minroot */ + if (readblk(1000, miniroot) != 0) { + printf("miniroot not loaded\n"); + addr = (char *)miniroot; + } else { + addr = (char *)((int)miniroot + 1000 * DEV_BSIZE); + } + printf("esym %x miniroot @ %x (ends @ %x)\n", esym, miniroot, addr); +#if 0 + { + char *symaddr = (char *)0x01F00000; + int i; + + tapefileseek(4); /* seek to file 4 - syms */ + readblk(1, symaddr); + i = *symaddr; + i = (i * 0x1C + 4 + DEV_BSIZE) & ~(DEV_BSIZE - 1); + printf("loading %d symbols (%d sectors)\n", + *symaddr, (i + 1) * DEV_BSIZE); + readblk(i / DEV_BSIZE, symaddr + DEV_BSIZE); + readblk(100, 0x01F00000); + } +#endif + + fptr = (int (*)())hdr->a_entry; + /* + * Args are passed as + * r2 howto + * r3 end addr + * r4 (Clun << 8) | Dlun & FF + * r5 esym + * r6 miniroot + */ + bootdev = ((Clun << 8) & 0xFF00 | Dlun & 0xFF) & 0xFFFF; +#if 0 + asm volatile ("or r2, r0, %0\n\tor r3, r0, %1\n\tor r4, r0, %2\n\tor r5, r0, %3\n\tor r6, r0, %4\n\tor r7, r0, %5" + : /* no outputs */ + : "r" (howto), "r" (addr), "r" (Clun), "r" (Dlun), "r" (esym), "r" (miniroot) + : "r2", "r3", "r4", "r5", "r6", "r7"); +#endif /* 0 */ + (*fptr)(howto, addr, bootdev, esym, miniroot); + return 0; +} + +int +readblk(int n, char *addr) +{ + struct bugdisk_io io; + + io.clun = Clun; + io.dlun = Dlun; + io.status = 0; + io.addr = (void *)addr; + io.fileno = 0; /* for tape reads, start io at current pos */ + io.nblks = sec2blk(n); + io.flag = IGNOREFILENO; + io.am = 0; + bugdskrd(&io); + if (io.status) + return -1; + return 0; +} + +void +_main(void) +{ + return; +} + +void +tapefileseek(int i) +{ + struct bugdisk_io io; + void *addr = (void *)KERNEL_LOAD_ADDR; /* some number - don't care */ + + io.clun = Clun; + io.dlun = Dlun; + io.status = 0; + io.addr = addr; + io.fileno = i; /* for tape reads, this is the file no. */ + io.nblks = 0; + io.flag = 0; /* we want to turn off IFN and EOF bits */ + io.am = 0; + bugdskrd(&io); +} + +__main() +{ +} diff --git a/sys/arch/mvme88k/stand/old/boot/wrtvid b/sys/arch/mvme88k/stand/old/boot/wrtvid Binary files differnew file mode 100644 index 00000000000..647a59d253f --- /dev/null +++ b/sys/arch/mvme88k/stand/old/boot/wrtvid diff --git a/sys/arch/mvme88k/stand/old/boot/wrtvid.c b/sys/arch/mvme88k/stand/old/boot/wrtvid.c new file mode 100644 index 00000000000..6161ccaa85a --- /dev/null +++ b/sys/arch/mvme88k/stand/old/boot/wrtvid.c @@ -0,0 +1,108 @@ +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <stdio.h> +#include "vid.h" + +#define sec2blk(x) ((x) * 2) + +main(int argc, char **argv) +{ + struct vid *pvid; + struct cfg *pcfg; + struct stat stat; + int exe_file; + int tape_vid; + int tape_exe; + unsigned int exe_addr; + unsigned short exe_addr_u; + unsigned short exe_addr_l; + char *filename; + char fileext[256]; + + if (argc == 0){ + filename = "a.out"; + } else { + filename = argv[1]; + } + exe_file = open(filename, O_RDONLY,0444); + if (exe_file == -1) + { + printf("file %s does not exist\n",filename); + exit(2); + } + sprintf (fileext,"%s%s",filename,".1"); + tape_vid = open(fileext, O_WRONLY|O_CREAT|O_TRUNC,0644); + sprintf (fileext,"%s%s",filename,".2"); + tape_exe = open(fileext, O_WRONLY|O_CREAT|O_TRUNC,0644); + + pvid = (struct vid *) malloc(sizeof (struct vid)); + + memset(pvid,0,sizeof(struct vid)); + + strcpy(pvid->vid_id, "NBSD"); + + fstat (exe_file,&stat); + /* size in 512 byte blocks round up after a.out header removed */ + /* Actually, blocks == 256 bytes */ + + pvid->vid_oss = 1; + pvid->vid_osl = (short)sec2blk((stat.st_size - 0x20 + 511) / 512); + + lseek(exe_file,0x14,SEEK_SET); + read(exe_file,&exe_addr,4); + { + union { + struct { + short osa_u; + short osa_l; + } osa_u_l; + int osa; + } u; + u.osa = exe_addr; + pvid->vid_osa_u = u.osa_u_l.osa_u; + pvid->vid_osa_l = u.osa_u_l.osa_l; + } + pvid->vid_cas = 1; + pvid->vid_cal = 1; + /* do not want to write past end of structure, not null terminated */ + strcpy(pvid->vid_mot,"MOTOROL"); + pvid->vid_mot[7] = 'A'; + + write(tape_vid,pvid,sizeof(struct vid)); + + free(pvid); + + pcfg = (struct cfg *) malloc (sizeof(struct cfg)); + + memset(pcfg,0,sizeof(struct cfg)); + + pcfg->cfg_rec = 0x100; + pcfg->cfg_psm = 0x200; + + write(tape_vid,pcfg,sizeof(struct cfg)); + + free(pcfg); + + copy_exe(exe_file,tape_exe); + close (exe_file); + close (tape_vid); + close (tape_exe); +} + +#define BUF_SIZ 512 +copy_exe(exe_file,tape_exe) +{ + char *buf; + int cnt = 0; + + buf = (char *)malloc (BUF_SIZ); + + lseek (exe_file,0x20,SEEK_SET); + while (BUF_SIZ == (cnt = read(exe_file, buf , BUF_SIZ))) { + write (tape_exe,buf,cnt); + } + memset (&buf[cnt],0,BUF_SIZ-cnt); + write (tape_exe,buf,BUF_SIZ); +} diff --git a/sys/arch/mvme88k/stand/old/bootst/Makefile b/sys/arch/mvme88k/stand/old/bootst/Makefile new file mode 100644 index 00000000000..7e8fba43288 --- /dev/null +++ b/sys/arch/mvme88k/stand/old/bootst/Makefile @@ -0,0 +1,28 @@ +STRIP_AOUT_HDR=rmaouthdr +all: bootst.bug +STRIP=-s +SRCS=bootst.c +S=${.CURDIR}/../../../.. + +CFLAGS+=-I${.CURDIR}/../../include -I${.CURDIR}/${MACHINE_ARCH} + +.include "${S}/arch/${MACHINE}/stand/libbug/Makefile.inc" +.include "${S}/arch/${MACHINE}/stand/bugcrt/Makefile.inc" +.include "${S}/lib/libsa/Makefile.inc" +.include "${S}/lib/libc_sa/Makefile.inc" +.include "${S}/lib/libkern/Makefile.inc" + +LDADD+=${LIBBUG} ${SA_LIB} ${C_SA_LIB} ${KERNLIB} + +bootst.bug: bootst.o ${LDADD} ${BUGCRT} + ${LD} ${STRIP} -N -T 0x3F0000 ${BUGCRT} bootst.o ${LDADD} -o bootst.bug + ${.CURDIR}/../wrtvid/wrtvid bootst.bug + +clean: + rm -f a.out *.core + rm -f bootst.o bootst.bug stboot bootst + +install: + install -c -m 555 -g bin -o bin bootst stboot /usr/mdec/ + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/old/bootst/bootst.c b/sys/arch/mvme88k/stand/old/bootst/bootst.c new file mode 100644 index 00000000000..fc3336b2643 --- /dev/null +++ b/sys/arch/mvme88k/stand/old/bootst/bootst.c @@ -0,0 +1,371 @@ +#include "bug.h" +#include <sys/types.h> +#include <sys/param.h> +#include <sys/reboot.h> +#include <sys/exec.h> +/* +#include <sys/exec_aout.h> +*/ + +#define KERNEL_LOAD_ADDRESS ((void *)0x4000) +#define BUG_BLOCK_SIZE 512 +#define VERSION 0x0000 + +#define RB_NOSYM 0x400 + + + +void memset(void *,char,size_t); +void printf(char *,...); +void parse_args(struct bugargs *pbugargs); +int read_tape_block(short ctrl, short dev, short *status, void *addr, + int *cnt, int blk_num, unsigned char *flags,int verbose); +int load_kern(); + +struct kernel { + void *entry; + void *symtab; + void *esym; + int bflags; + int bdev; + char *kname; + void *smini; + void *emini; + u_int end_loaded; +} kernel; + +typedef (* kernel_entry)(struct bugargs *,struct kernel *); + +void main(struct bugargs *pbugargs) +{ + kernel_entry addr; + + /* + print_bugargs(pbugargs); + print_time(); + print_brdid(); + print_memory(); + */ + parse_args(pbugargs); + if (1 == load_kern(pbugargs)) { + printf("unsuccessful in loading kernel\n\r"); + } else { + addr = kernel.entry; + printf("kernel loaded at %x\n\r",addr); + printf("kernel.entry %x\n\r",kernel.entry); + printf("kernel.symtab %x\n\r",kernel.symtab); + printf("kernel.esym %x\n\r",kernel.esym); + printf("kernel.bflags %x\n\r",kernel.bflags); + printf("kernel.bdev %x\n\r",kernel.bdev); + if (kernel.kname) { + printf("kernel.kname <%s>\n\r",kernel.kname); + } else { + printf("kernel.kname <null>\n\r"); + } + printf("kernel.end_loaded %x\n\r",kernel.end_loaded); + if (kernel.bflags & RB_MINIROOT) { + loadmini(kernel.end_loaded,pbugargs); + } + printf("kernel.smini %x\n\r",kernel.smini); + printf("kernel.emini %x\n\r",kernel.emini); + printf("kernel.end_loaded %x\n\r",kernel.end_loaded); + if (*pbugargs->arg_start == 'e') + bug_return(); + (addr)(pbugargs,&kernel); + } + + return; +} +int +read_tape_block(short ctrl, short dev, short *status, void *addr, + int *cnt, int blk_num, unsigned char *flags,int verbose) +{ + struct bug_dskio dio; + int ret; + + dio.ctrl_lun = ctrl; + dio.dev_lun = dev; + dio.status = *status; + dio.pbuffer = addr; + dio.blk_num = blk_num; + dio.blk_cnt = *cnt * 2; + dio.flag = *flags; + dio.addr_mod = 0; + + if (verbose){ + printf("saddr %x eaddr %x", dio.pbuffer, + (int)dio.pbuffer + (dio.blk_cnt * BUG_BLOCK_SIZE/2 )); + } + + ret = bug_diskrd(&dio); + + *status = dio.status; + *cnt = dio.blk_cnt/2; + if (verbose) { + printf("status %x ret %d ",*status, ret); + printf("flags %x\n\r",*flags); + } + return ret; +} +int load_kern(struct bugargs *pbugargs) +{ + int ret; + char *addr; + unsigned char flags; + short status = 0; + int verbose = 0; + int blk_num; + struct exec *pexec; + int magic; + int *esym; + int *symtab; + int cnt, len; + + blk_num = 0; + flags = IGNORE_FILENUM ; + cnt = 512 / BUG_BLOCK_SIZE; + addr = KERNEL_LOAD_ADDRESS; + ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, &status, addr, + &cnt, blk_num, &flags, verbose); + if (ret != 0) { + printf("unable to load kernel\n\r"); + return 1; + } + pexec = (struct exec *) addr; + if ((N_GETMID(*pexec) != MID_M68K) && + ( N_GETMID(*pexec) != MID_M68K4K )) + { + printf("invalid mid on kernel\n\r"); + return 1; + } + { + short *pversion = (void *)0x4020; + if (VERSION != *pversion) { + printf("invalid version of kernel/loader\n\r"); + bug_return(); + } + } + magic = N_GETMAGIC(*pexec); + switch (magic) { + case ZMAGIC: + break; + case NMAGIC: + printf ("NMAGIC not yet supported"); + case OMAGIC: + case QMAGIC: + default: + printf("Unknown or unsupported magic type <%x>\n\r", + magic); + return 1; + break; + } + if ( magic == ZMAGIC ) { + + status = 0; + /* 2nd block of exe */ + addr += 512; + + if ((int)pexec->a_entry != (int)KERNEL_LOAD_ADDRESS + 0x22) { + printf ("warning kernel start address not %x, %x\n\r", + (int)KERNEL_LOAD_ADDRESS + 0x22,pexec->a_entry); + printf ("kernel loaded at %x\n\r",KERNEL_LOAD_ADDRESS); + + } + printf ("text 0x%x data 0x%x bss 0x%x\n\r", + pexec->a_text, pexec->a_data, pexec->a_bss); + + len = (pexec->a_text - 512) ; /* XXX */ + len += (pexec->a_data ); + + printf ("loading [ %x + %x ",pexec->a_text,pexec->a_data); + + cnt = (len + BUG_BLOCK_SIZE -1)/ BUG_BLOCK_SIZE; + flags = IGNORE_FILENUM ; + ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, &status, addr, + &cnt, blk_num, &flags, verbose); + if (ret != 0 || cnt != (len + BUG_BLOCK_SIZE -1)/ BUG_BLOCK_SIZE) { + printf("unable to load kernel\n\r"); + return 1; + } + addr += len; + + /* Skip over text and data and zero bss. */ + len = pexec->a_bss; + printf ("+ %x",len); + memset (KERNEL_LOAD_ADDRESS + (pexec->a_text + pexec->a_data), + 0, pexec->a_bss); + addr +=len; + + if (pexec->a_syms != 0 && !(kernel.bflags & RB_NOSYM)) { + printf (" + [ %x",pexec->a_syms); + /* align addr */ +#if 0 +#define ALIGN_F 0x200 + addr = (void *)((((int)addr + ALIGN_F -1)/ALIGN_F) * ALIGN_F); +#endif + addr += 4; /* skip over _end symbol */ + symtab = (void *)pexec->a_syms; + len = pexec->a_syms; + cnt = (len+(BUG_BLOCK_SIZE-1)) / BUG_BLOCK_SIZE; + flags = IGNORE_FILENUM ; + ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, &status, addr, + &cnt, blk_num, &flags, verbose); + if (ret != 0 || cnt != (len+(BUG_BLOCK_SIZE-1)) / BUG_BLOCK_SIZE) + { + printf("unable to load kernel\n\r"); + return 1; + } + + /* this value should have already been loaded XXX */ + esym = (void *) ((u_int)addr + pexec->a_syms); + if ((int)addr +(cnt * BUG_BLOCK_SIZE) <= (int) esym) { + printf("missed loading count of symbols\n\r"); + return 1; + } + addr +=cnt * BUG_BLOCK_SIZE; + + + len = *esym; +#if 0 + printf("start load %x end load %x %x\n\r", addr, + len, addr +len); + printf("esym %x *esym %x\n\r",esym, len); +#endif + /* dont load tail of already loaded */ + len -= (u_int)addr - (u_int)esym; + + if (len > 0) { + printf(" + %x",*esym); + esym = (void *)(addr + len); + cnt = (len+(BUG_BLOCK_SIZE-1)) / BUG_BLOCK_SIZE; + flags = IGNORE_FILENUM ; + ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, &status, addr, + &cnt, blk_num, &flags, verbose); + if (ret != 0 || + cnt != (len+(BUG_BLOCK_SIZE-1)) / BUG_BLOCK_SIZE) + { + printf("unable to load kernel\n\r"); + return 1; + } + addr += len; + printf(" ]"); + } else { + printf("+ %x ]",*esym); + } + esym = (int *)(((int)esym) + *esym); + + kernel.symtab = symtab; + kernel.esym = esym; + } else { + kernel.symtab = 0; + kernel.esym = 0; + } + kernel.end_loaded = (int)addr; + flags = IGNORE_FILENUM | END_OF_FILE; + cnt = 1000; + printf ("removing pad ["); + ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, &status, addr, + &cnt, blk_num, &flags, verbose); + if (ret != 0) { + printf("unable to load kernel\n\r"); + return 1; + } + printf (" %d ]",cnt * BUG_BLOCK_SIZE); + + printf("]\n\r"); + } + + + kernel.entry = (void *)pexec->a_entry; + return 0; +} +loadmini(u_int addr,struct bugargs *pbugargs) +{ + int ret; + unsigned char flags; + short status = 0; + int verbose = 0; + int blk_num; + int cnt; + blk_num = 3; + /* + flags = IGNORE_FILENUM | END_OF_FILE; + */ + /* align addr to some boundary */ +#define ALIGN_F 0x4 + addr = (u_int)((((int)addr + ALIGN_F -1)/ALIGN_F) * ALIGN_F); +#undef ALIGN_F + flags = END_OF_FILE; + cnt = 6144; /* some abserdly large value. (3meg / 512) */ + printf("loading miniroot[ "); + ret = read_tape_block(4, pbugargs->dev_lun, &status, (void*)addr, + &cnt, blk_num, &flags, verbose); + if (ret != 0) { + printf("unable to load miniroot\n\r"); + return 1; + } + kernel.smini = (void *)addr; + printf("%d ]\n\r",(BUG_BLOCK_SIZE * cnt)); + kernel.emini = (void*)((u_int)addr + (BUG_BLOCK_SIZE * cnt)); + kernel.end_loaded = (u_int)kernel.emini; +} +void +parse_args(struct bugargs *pargs) +{ + char * ptr = pargs->arg_start; + char c, *name; + int howto; + howto = ( 0 | RB_DFLTROOT ); + name = NULL; + + if (pargs->arg_start != pargs->arg_end) { + while (c = *ptr) { + while (c == ' ') + c = *++ptr; + if (!c) + return; + if (c == '-') + while ((c = *++ptr) && c != ' ') { + if (c == 'a') + howto |= RB_ASKNAME; + else if (c == 'b') + howto |= RB_HALT; + else if (c == 'y') + howto |= RB_NOSYM; +#ifdef CHECKSUM + else if (c == 'c') + cflag = 1; +#endif + else if (c == 'd') + howto |= RB_KDB; + else if (c == 'm') + howto |= RB_MINIROOT; + else if (c == 'r') +/* change logic to have force root to config device UNLESS arg given */ + howto &= ~RB_DFLTROOT; + else if (c == 's') + howto |= RB_SINGLE; + } + else { + name = ptr; + while ((c = *++ptr) && c != ' '); + if (c) + *ptr++ = 0; + } + } + if (RB_NOSYM & howto) printf("RB_NOSYM\n\r"); + if (RB_AUTOBOOT & howto) printf("RB_AUTOBOOT\n\r"); + if (RB_SINGLE & howto) printf("RB_SINGLE\n\r"); + if (RB_NOSYNC & howto) printf("RB_NOSYNC\n\r"); + if (RB_HALT & howto) printf("RB_HALT\n\r"); + if (RB_DFLTROOT & howto) printf("RB_DFLTROOT\n\r"); + if (RB_KDB & howto) printf("RB_KDB\n\r"); + if (RB_RDONLY & howto) printf("RB_RDONLY\n\r"); + if (RB_DUMP & howto) printf("RB_DUMP\n\r"); + if (RB_MINIROOT & howto) printf("RB_MINIROOT\n\r"); + + } + kernel.bflags = howto; + kernel.kname = name; +} + diff --git a/sys/arch/mvme88k/stand/old/bugcrt/Makefile b/sys/arch/mvme88k/stand/old/bugcrt/Makefile new file mode 100644 index 00000000000..821ec7508d4 --- /dev/null +++ b/sys/arch/mvme88k/stand/old/bugcrt/Makefile @@ -0,0 +1,10 @@ +OBJ=bugcrt.o +CFLAGS+=-I${.CURDIR}/../include +CFLAGS+=-I${.CURDIR}/../.. +CFLAGS+=-I/usr/src/sys +CFLAGS+=-fwritable-strings + +SRCS=bugcrt.c +all: bugcrt.o + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/old/bugcrt/bugcrt.c b/sys/arch/mvme88k/stand/old/bugcrt/bugcrt.c new file mode 100644 index 00000000000..d01c20b6e2d --- /dev/null +++ b/sys/arch/mvme88k/stand/old/bugcrt/bugcrt.c @@ -0,0 +1,42 @@ +#include "bug.h" + +asm (" text"); +/*asm ("_stack: word _stack0xFC0000; stack");*/ +asm ("stack: word stack"); +asm (" word _start"); +asm (" align 8"); + +struct bugenv bugenv; +extern char *end, *edata; + +start() +{ + register int dlun asm("r2"); + register int clun asm("r3"); + register int ipl asm("r4"); + register int (*entryptr)() asm("r6"); + register int *cfg asm("r7"); + register char *strstr asm("r8"); + register char *endstr asm("r9"); + int i; + char *str; + +asm ("; enable SFU1"); +asm (" ldcr r10,cr1"); +asm (" xor r10,r10,0x8"); +asm (" stcr r10,cr1"); + + bugenv.clun = clun; + bugenv.dlun = dlun; + bugenv.ipl = ipl; + bugenv.entry= entryptr; + + bzero(&edata,((char *)&end - (char *)&edata)); + for (str = strstr, i = 0; str <= strstr; str++, i++) { + bugenv.bootargs[i] = *str; + } + bugenv.bootargs[i] = 0; + + main(&bugenv); + bugreturn(); +} diff --git a/sys/arch/mvme88k/stand/old/bugexec/Makefile b/sys/arch/mvme88k/stand/old/bugexec/Makefile new file mode 100644 index 00000000000..3ed0ff02de6 --- /dev/null +++ b/sys/arch/mvme88k/stand/old/bugexec/Makefile @@ -0,0 +1,26 @@ +all: hello +SRCS= hello.c +OBJS= hello.o + +CFLAGS+=-I${.CURDIR}/include -I${.CURDIR}/${MACHINE_ARCH} +CFLAGS+=-I${.CURDIR}/../include -I${.CURDIR}/../.. -I/usr/src/sys +CFLAGS+=-fwritable-strings + +LIBBUG!= cd $(.CURDIR)/../libbug; \ + printf "xxx:\n\techo \$${.OBJDIR}/libbug.a\n" | ${MAKE} -r -s -f - xxx + +BUGCRT!= cd $(.CURDIR)/../bugcrt; \ + printf "xxx:\n\techo \$${.OBJDIR}/bugcrt.o\n" | ${MAKE} -r -s -f - xxx + +KERNCRT!= cd $(.CURDIR)/../kerncrt; \ + printf "xxx:\n\techo \$${.OBJDIR}/kerncrt.o\n" | ${MAKE} -r -s -f - xxx + +LDADD+=${LIBBUG} /usr/local/lib/libgcc.a + +hello: $(OBJS) ${LIBBUG} + ${LD} -x -Ttext 10020 ${KERNCRT} $(OBJS) ${LDADD} -o ${.TARGET} +clean: + rm -f a.out *.core + rm -f hello.o hello.bug hello.bug.1 hello.bug.2 + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/old/bugexec/hello b/sys/arch/mvme88k/stand/old/bugexec/hello Binary files differnew file mode 100644 index 00000000000..8670fd2b147 --- /dev/null +++ b/sys/arch/mvme88k/stand/old/bugexec/hello diff --git a/sys/arch/mvme88k/stand/old/bugexec/hello.c b/sys/arch/mvme88k/stand/old/bugexec/hello.c new file mode 100644 index 00000000000..08ab75d2a27 --- /dev/null +++ b/sys/arch/mvme88k/stand/old/bugexec/hello.c @@ -0,0 +1,54 @@ +#include "bug.h" +#include "bugio.h" + +void putchar __P((char)); +int bcd2int __P((unsigned int)); + +void +putchar(char c) +{ + bugoutchr(c); +} + +main(struct bugenv *env) +{ + struct bugrtc rtc; + struct bugbrdid brdid; + + bugrtcrd(&rtc); + printf("From RTC:\n"); + printf("Year %d\tMonth %d\tDay %d\tDay of Week %d\n", + bcd2int(rtc.Y), bcd2int(rtc.M), bcd2int(rtc.D), bcd2int(rtc.d)); + printf("Hour %d\tMin %d\tSec %d\tCal %d\n", + bcd2int(rtc.H), bcd2int(rtc.m), bcd2int(rtc.s), bcd2int(rtc.c)); + printf("From BRDID:\n"); + bugbrdid(&brdid); +/* printf("Eye catcher %c%c%c%c\n", brdid.eye[0], brdid.eye[1], + brdid.eye[2], brdid.eye[3]); */ + printf("Board no %d (%d) \tsuffix %c%c\n", bcd2int(brdid.brdno), + brdid.brdno, brdid.brdsuf[0], brdid.brdsuf[1]); +/* printf("Clun %x\tdlun %x\n", brdid.clun, brdid.dlun); */ + return 0; +} + +ipow(int base, int i) +{ + int cnt = 1; + while (i--) { + cnt *= base; + } + return cnt; +} + +int +bcd2int(unsigned int i) +{ + unsigned val = 0; + int cnt = 0; + while (i) { + val += (i&0xf) * ipow(10,cnt); + cnt++; + i >>= 4; + } + return val; +} diff --git a/sys/arch/mvme88k/stand/old/bugexec/wrtos.c b/sys/arch/mvme88k/stand/old/bugexec/wrtos.c new file mode 100644 index 00000000000..1e01b697399 --- /dev/null +++ b/sys/arch/mvme88k/stand/old/bugexec/wrtos.c @@ -0,0 +1,64 @@ +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <stdio.h> +#include "vid.h" + +#define sec2blk(x) ((x) * 2) +#define BUF_SIZ 512 + +main(int argc, char **argv) +{ + struct vid *pvid; + struct cfg *pcfg; + struct stat stat; + int exe_file; + int tape_vid; + int tape_exe; + char *filename; + char fileext[256]; + char hdrbuf[BUF_SIZ]; + + if (argc == 0){ + filename = "a.out"; + } else { + filename = argv[1]; + } + exe_file = open(filename, O_RDONLY,0444); + if (exe_file == -1) + { + printf("file %s does not exist\n",filename); + exit(2); + } + sprintf (fileext,"%s%s",filename,".1"); + tape_vid = open(fileext, O_WRONLY|O_CREAT|O_TRUNC,0644); + sprintf (fileext,"%s%s",filename,".2"); + tape_exe = open(fileext, O_WRONLY|O_CREAT|O_TRUNC,0644); + + lseek(exe_file,0,SEEK_SET); + memset (hdrbuf,0,BUF_SIZ); + read(exe_file,hdrbuf, 0x20); /* read the header */ + + write(tape_vid,hdrbuf,BUF_SIZ); + + copy_exe(exe_file,tape_exe); + close (exe_file); + close (tape_vid); + close (tape_exe); +} + +copy_exe(exe_file,tape_exe) +{ + char *buf; + int cnt = 0; + + buf = (char *)malloc (BUF_SIZ); + + lseek (exe_file,0x20,SEEK_SET); + while (BUF_SIZ == (cnt = read(exe_file, buf , BUF_SIZ))) { + write (tape_exe,buf,cnt); + } + memset (&buf[cnt],0,BUF_SIZ-cnt); + write (tape_exe,buf,BUF_SIZ); +} diff --git a/sys/arch/mvme88k/stand/old/bugexec/xyz b/sys/arch/mvme88k/stand/old/bugexec/xyz Binary files differnew file mode 100644 index 00000000000..dbdee90a4e1 --- /dev/null +++ b/sys/arch/mvme88k/stand/old/bugexec/xyz diff --git a/sys/arch/mvme88k/stand/old/include/bug.h b/sys/arch/mvme88k/stand/old/include/bug.h new file mode 100644 index 00000000000..93fe1e6ccd5 --- /dev/null +++ b/sys/arch/mvme88k/stand/old/include/bug.h @@ -0,0 +1,8 @@ +struct bugenv { + int clun; + int dlun; + int ipl; + int (*entry)(); + char bootargs[256]; +}; + diff --git a/sys/arch/mvme88k/stand/old/include/bugio.h b/sys/arch/mvme88k/stand/old/include/bugio.h new file mode 100644 index 00000000000..74bb77bd336 --- /dev/null +++ b/sys/arch/mvme88k/stand/old/include/bugio.h @@ -0,0 +1,62 @@ +#include "sys/cdefs.h" + +struct bugdisk_io { + char clun; + char dlun; + short status; + void *addr; + int blkno; +#define fileno blkno + short nblks; + char flag; +#define FILEMARKFLAG 0x80 +#define IGNOREFILENO 0x02 +#define ENDOFFILE 0x01 + char am; +}; + +/* values are in BCD {upper nibble+lower nibble} */ + +struct bugrtc { + unsigned char Y; + unsigned char M; + unsigned char D; + unsigned char d; + unsigned char H; + unsigned char m; + unsigned char s; + unsigned char c; +}; + +/* Board ID - lots of info */ + +struct bugbrdid { + unsigned char eye[4]; + char rev; + char month; + char day; + char year; + short packetsize; + short dummy; + short brdno; + unsigned char brdsuf[2]; + char options[3]; + char family:4; + char cpu:4; + short clun; + short dlun; + short type; + short dev; + int option; +}; + +char buginchr __P((void)); +int buginstat __P((void)); +int bugoutchr __P((unsigned char)); +int bugoutstr __P((char *, char *)); +int bugpcrlf __P((void)); +int bugdskrd __P((struct bugdisk_io *)); +int bugdskwr __P((struct bugdisk_io *)); +int bugrtcrd __P((struct bugrtc *)); +int bugreturn __P((void)); +int bugbrdid __P((struct bugbrdid *)); diff --git a/sys/arch/mvme88k/stand/old/kerncrt/Makefile b/sys/arch/mvme88k/stand/old/kerncrt/Makefile new file mode 100644 index 00000000000..b41b0dec57d --- /dev/null +++ b/sys/arch/mvme88k/stand/old/kerncrt/Makefile @@ -0,0 +1,22 @@ +# $Id: Makefile,v 1.1 1997/03/03 19:30:46 rahnds Exp $ + +CFLAGS+=-I${.CURDIR}/../include -I${.CURDIR}/${MACHINE_ARCH} + +.PATH: ${.CURDIR}/${MACHINE_ARCH} + +SRCS= kerncrt.c + +OBJS=${SRCS:.c=.o} + +all: ${OBJS} + +kerncrt.o: ${SRCS} + ${CC} ${CFLAGS} -c -O ${.ALLSRC} + ${LD} -x -r ${.TARGET} + mv a.out ${.TARGET} + +install: + +lint tags: + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/old/kerncrt/kerncrt.c b/sys/arch/mvme88k/stand/old/kerncrt/kerncrt.c new file mode 100644 index 00000000000..a5f04d2398a --- /dev/null +++ b/sys/arch/mvme88k/stand/old/kerncrt/kerncrt.c @@ -0,0 +1,11 @@ +#include "bug.h" +start(struct bugenv *bugarea) +{ + main(bugarea); + bugreturn(); +} + +__main() +{ + return; +} diff --git a/sys/arch/mvme88k/stand/old/kerncrt/m88k/kerncrt.c b/sys/arch/mvme88k/stand/old/kerncrt/m88k/kerncrt.c new file mode 100644 index 00000000000..809750bdbfc --- /dev/null +++ b/sys/arch/mvme88k/stand/old/kerncrt/m88k/kerncrt.c @@ -0,0 +1,9 @@ +#include "bugargs.h" +#define volatile +int _DYNAMIC; +start(struct bugargs *bugarea) +{ + main(bugarea); + bug_return(); + /* NOTREACHED */ +} diff --git a/sys/arch/mvme88k/stand/old/libbug/Makefile b/sys/arch/mvme88k/stand/old/libbug/Makefile new file mode 100644 index 00000000000..5359fb435bd --- /dev/null +++ b/sys/arch/mvme88k/stand/old/libbug/Makefile @@ -0,0 +1,30 @@ +LIB=bug + +CFLAGS+=-I${.CURDIR}/../include +CFLAGS+=-I${.CURDIR}/../../include +CFLAGS+=-I${.CURDIR}/../.. +CFLAGS+=-I/usr/src/sys +CFLAGS+=-fwritable-strings + +NOPIC= + +SRCS+=bug.c +#SRCS+=bugcrt.c bugio.c main.c + +.if (${MACHINE_ARCH} == "m68k") +SRCS+=mvme147.c bcopy.c bzero.c +.endif +.if (${MACHINE_ARCH} == "m88k") +SRCS+=bcopy.c bzero.c printf.c bugsupp.c +.endif + +.PATH: ${.CURDIR}/../../../../lib/libkern ${.CURDIR}/../../../../lib/libsa ${.CURDIR}/${MACHINE_ARCH} + +all: bugio.o + +#bugio.o: bugio.c +# ${CC} ${CFLAGS} -c -O ${.ALLSRC} +# ${LD} -x -r ${.TARGET} +# mv a.out ${.TARGET} + +.include <bsd.lib.mk> diff --git a/sys/arch/mvme88k/stand/old/libbug/bug.c b/sys/arch/mvme88k/stand/old/libbug/bug.c new file mode 100644 index 00000000000..0595dbd2879 --- /dev/null +++ b/sys/arch/mvme88k/stand/old/libbug/bug.c @@ -0,0 +1,133 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include "bug.h" + +#define _INCHR "00" +#define _INSTAT "01" +#define _INLN "02" +#define _READSTR "03" +#define _READLN "04" +#define _DSKRD "16" +#define _DSKWR "17" +#define _DSKCFIG "18" +#define _DSKFMT "20" +#define _DSKCTRL "12" +#define _OUTCHR "32" +#define _OUTSTR "33" +#define _OUTLN "34" +#define _WRITE "35" +#define _WRITELN "36" +#define _DELAY "67" +#define _RTC_RD "83" +#define _RETURN "99" +#define _BRD_ID "112" + +/* BUG - tty routines */ + +#define BUG_CALL(x) \ + asm volatile ("or r9,r0," x); \ + asm volatile ("tb0 0,r0,496"); + +char bug_inchr() +{ + register char a; + asm volatile ("sub r31,r31,4"); + BUG_CALL(_INCHR); + asm volatile ("or %0,r0,r2" : "=r" (a)); + return a; +} + +/* returns 0 if no characters ready to read */ +int bug_instat() +{ + short ret; + BUG_CALL(_INSTAT); + asm volatile ("or %0,r0,r2" : "=r" (ret)); + return (!(ret & 0x4)); + +} + +void bug_outchr(char a) +{ + asm volatile ("or r2, r0, %0" : :"r" (a)); + BUG_CALL(_OUTCHR); + return; +} + +void bug_outstr(char *pstrb, char *pstre) +{ + asm volatile ("or r2,r0,%0": : "r" (pstrb) ); + asm volatile ("or r3,r0,%0": : "r" (pstre) ); + BUG_CALL(_OUTSTR); + return; +} + +void bug_outln(char *pstrb, char *pstre) +{ + asm volatile ("or r2,r0,%0": : "r" (pstrb) ); + asm volatile ("or r3,r0,%0": : "r" (pstre) ); + BUG_CALL(_OUTLN); + return; +} + +/* BUG - disk routines */ + +/* returns 0: success, nonzero: error */ +int bug_diskrd(bug_dskio *arg) +{ + int ret; + asm volatile ("or r2,r0,%0": : "r" (arg) ); + BUG_CALL(_DSKRD); + return (!(ret & 0x4)); +} +/* returns 0: success, nonzero: error */ +int bug_diskwr(bug_dskio *arg) +{ + int ret; + asm volatile ("or r2,r0,%0": : "r" (arg) ); + BUG_CALL(_DSKWR); + return (!(ret & 0x4)); +} +#ifdef NOTYET +bug_diskcfig() +{ + +} +bug_diskfmt(){} +bug_diskctrl(){} +#endif + +/* BUG - timing routine */ + +void bug_delay(int delay_msec) +{ + asm volatile ("or r2,r0,%0": : "r" (delay_msec) ); + BUG_CALL(_DELAY); + return ; +} + +/* BUG - return to bug routine */ + +void bug_return() +{ + BUG_CALL(_RETURN); + /*NOTREACHED*/ +} + +/* BUG - query board routines */ + +struct bug_brdid *bug_brdid() +{ + struct bug_brdid *pbrd_id; + BUG_CALL(_BRD_ID); + asm volatile ("or %0,r0,r2": "=r" (pbrd_id):); + return pbrd_id; +} +void bug_rtc_rd(struct bug_time *ptime) +{ + asm volatile ("or r2,r0,%0": : "r" (ptime)); + BUG_CALL(_RTC_RD); + return; +} diff --git a/sys/arch/mvme88k/stand/old/libbug/bugio.c b/sys/arch/mvme88k/stand/old/libbug/bugio.c new file mode 100644 index 00000000000..6406dac3e13 --- /dev/null +++ b/sys/arch/mvme88k/stand/old/libbug/bugio.c @@ -0,0 +1,101 @@ +#include "bugio.h" + +#define INCHR "0x0000" +#define INSTAT "0x0001" +#define INLN "0x0002" +#define READSTR "0x0003" +#define READLN "0x0004" +#define DSKRD "0x0010" +#define DSKWR "0x0011" +#define DSKCFIG "0x0012" +#define OUTCHR "0x0020" +#define PCRLF "0x0026" +#define TMDISP "0x0042" +#define DELAY "0x0043" +#define RTC_DSP "0x0052" +#define RTC_RD "0x0053" +#define RETURN "0x0063" +#define BRD_ID "0x0070" +#define BUGTRAP "0x01F0" + +char +buginchr(void) +{ + register int cc asm("r2"); + asm("or r9,r0," INCHR); + asm("tb0 0,r0,0x1F0"); + /*asm("or %0,r0,r2" : "=r" (cc) : );*/ + return ((char)cc & 0xFF); +} + +/* return 1 if not empty else 0 */ + +buginstat(void) +{ + int ret; + asm("or r9,r0," INSTAT); + asm("tb0 0,r0,0x1F0"); + asm("or %0,r0,r2" : "=r" (ret) : ); + return (ret & 0x40 ? 1 : 0); +} + +bugoutchr(unsigned char c) +{ + unsigned char cc; + + if ((cc = c) == '\n') { + bugpcrlf(); + return; + } + asm("or r2,r0,%0" : : "r" (cc)); + asm("or r9,r0," OUTCHR); + asm("tb0 0,r0,0x1F0"); +} + +bugpcrlf(void) +{ + asm("or r9,r0," PCRLF); + asm("tb0 0,r0,0x1F0"); +} +/* return 0 on success */ + +bugdskrd(struct bugdisk_io *arg) +{ + int ret; + asm("or r9,r0, " DSKRD); + asm("tb0 0,r0,0x1F0"); + asm("or %0,r0,r2" : "=r" (ret) : ); + return ((ret&0x4) == 0x4 ? 1 : 0); +} + +/* return 0 on success */ + +bugdskwr(struct bugdisk_io *arg) +{ + int ret; + asm("or r9,r0, " DSKWR); + asm("tb0 0,r0,0x1F0"); + asm("or %0,r0,r2" : "=r" (ret) : ); + return ((ret&0x4) == 0x4 ? 1 : 0); +} + +bugrtcrd(struct bugrtc *rtc) +{ + asm("or r9,r0, " RTC_RD); + asm("tb0 0,r0,0x1F0"); +} + +bugreturn(void) +{ + asm("or r9,r0, " RETURN); + asm("tb0 0,r0,0x1F0"); +} + +bugbrdid(struct bugbrdid *id) +{ + struct bugbrdid *ptr; + asm("or r9,r0, " BRD_ID); + asm("tb0 0,r0,0x1F0"); + asm("or %0,r0,r2" : "=r" (ptr) : ); + bcopy(ptr, id, sizeof(struct bugbrdid)); +} diff --git a/sys/arch/mvme88k/stand/old/libbug/bugsupp.c b/sys/arch/mvme88k/stand/old/libbug/bugsupp.c new file mode 100644 index 00000000000..51f0fb49bc4 --- /dev/null +++ b/sys/arch/mvme88k/stand/old/libbug/bugsupp.c @@ -0,0 +1,7 @@ +#include "bug.h" + +int putchar(char a) +{ + bug_outchr(a); +} +__main(){} diff --git a/sys/arch/mvme88k/stand/openbsd/Makefile b/sys/arch/mvme88k/stand/openbsd/Makefile new file mode 100644 index 00000000000..95be7960a00 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/Makefile @@ -0,0 +1,5 @@ +# $Id: Makefile,v 1.1 1997/03/03 19:31:01 rahnds Exp $ + +SUBDIR= netboot sboot bootsd bootst libsa bugcrt libbug wrtvid + +.include <bsd.subdir.mk> diff --git a/sys/arch/mvme88k/stand/openbsd/Makefile.inc b/sys/arch/mvme88k/stand/openbsd/Makefile.inc new file mode 100644 index 00000000000..d9e7ff83b1b --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/Makefile.inc @@ -0,0 +1,3 @@ +# $Id: Makefile.inc,v 1.1 1997/03/03 19:31:01 rahnds Exp $ + +MDEC_DIR?=/usr/mdec diff --git a/sys/arch/mvme88k/stand/openbsd/bootsd/Makefile b/sys/arch/mvme88k/stand/openbsd/bootsd/Makefile new file mode 100644 index 00000000000..24000991874 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/bootsd/Makefile @@ -0,0 +1,50 @@ +# from: @(#)Makefile 8.1 (Berkeley) 6/10/93 +# $Id: Makefile,v 1.1 1997/03/03 19:31:02 rahnds Exp $ + +RELOC=0x3F0000 + +S= ${.CURDIR}/../../../.. +DEFS= -DSTANDALONE -DCOMPAT_NOLABEL # -DROMPRF +INCPATH=-I${.CURDIR} -I${.CURDIR}/../../include -I${S} -I${S}/lib/libsa +CFLAGS= -O2 ${INCPATH} ${DEFS} ${COPTS} +CLEANFILES+=sdboot bootsd bootsd.bug + +#.PATH: ${S}/arch/${MACHINE_ARCH}/${MACHINE_ARCH} +#.PATH: ${S}/lib/libsa + +.include "${S}/arch/${MACHINE}/stand/libsa/Makefile.inc" +.include "${S}/arch/${MACHINE}/stand/libbug/Makefile.inc" +.include "${S}/arch/${MACHINE}/stand/bugcrt/Makefile.inc" +.include "${S}/arch/${MACHINE}/stand/wrtvid/Makefile.inc" + +SRCS= boot.c filesystem.c bugdev.c version.c + +LIBS= ${LIBSA} ${LIBBUG} + +OBJS= ${SRCS:N*.h:R:S/$/.o/g} + +BOOTS= bootsd sdboot +ALL= ${BOOTS} + +all: ${ALL} + +devopen.o machdep.o: Makefile + +bootsd.bug: ${OBJS} ${BUGCRT} ${LIBS} + ${LD} -N -T ${RELOC} ${BUGCRT} ${OBJS} ${LIBS} -o $@ + @size bootsd.bug + +bootsd sdboot: bootsd.bug ${WRTVID} + cp bootsd.bug bootsd.bin + strip bootsd.bin + @if [ `size bootsd.bin | awk 'BEGIN {getline} {print $$1+$$2;}'` -gt 7168 ];\ + then\ + echo BOOTBLOCKS ARE TOO BIG;\ + fail;\ + fi + ${WRTVID} bootsd.bin + +install: + install -c -m 555 -g bin -o bin ${BOOTS} ${DESTDIR}${MDEC_DIR} + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/openbsd/bootsd/README b/sys/arch/mvme88k/stand/openbsd/bootsd/README new file mode 100644 index 00000000000..f3a503eb63e --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/bootsd/README @@ -0,0 +1,3 @@ +In short: stick the the bootblocks into a partition with +something like: + cat sdboot bootsd > /dev/rsd0c diff --git a/sys/arch/mvme88k/stand/openbsd/bootsd/boot.c b/sys/arch/mvme88k/stand/openbsd/bootsd/boot.c new file mode 100644 index 00000000000..f6534699929 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/bootsd/boot.c @@ -0,0 +1,302 @@ +/* $Id: boot.c,v 1.1 1997/03/03 19:31:02 rahnds Exp $ */ + +/*- + * Copyright (c) 1995 Theo de Raadt + * + * 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 under OpenBSD by + * Theo de Raadt for Willowglen Singapore. + * 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. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * from: @(#)boot.c 8.1 (Berkeley) 6/10/93 + */ + +#include <sys/param.h> +#include <sys/types.h> +#include <sys/reboot.h> +#include <a.out.h> +#include <machine/prom.h> +#include "stand.h" + +void copyunix __P((int io, char *addr)); +void parse_args __P((void)); + +int debug; +int netif_debug; +#define RB_NOSYM 0x400 + +/* + * Boot device is derived from ROM provided information. + */ +extern char *version; +u_long esym; +char *strtab; +int strtablen; +#if 0 +struct nlist *nlp, *enlp; +#endif + +struct kernel { + void *entry; + void *symtab; + void *esym; + int bflags; + int bdev; + char *kname; + void *smini; + void *emini; + u_int end_loaded; +} kernel; + +extern struct mvmeprom_args bugargs; + +int +main() +{ + struct exec x; + char *file; + void *addr; + int io, i; + + printf(">> OpenBSD sdboot [%s]\n", version); + + parse_args(); + file = kernel.kname; + + io = open(file, 0); + if (io < 0) { + printf("Can't open %s: %s\n", file, strerror(errno)); + mvmeprom_return(); + } + i = read(io, (char *)&x, sizeof(x)); + if (i != sizeof(x) || N_BADMAG(x)) { + printf("Bad format\n"); + return (0); + } + /* Make load address start of page which containes "start" */ + addr = (void *)(x.a_entry & ~0x0FFF); + lseek(io, 0, SEEK_SET); + + printf("load %s to 0x%x\n", file, addr); + copyunix(io, addr); + return (0); +} + +/*ARGSUSED*/ +void +copyunix(io, addr) + int io; + char *addr; +{ + void (*entry)() = (void (*)())addr; + struct exec x; + int i, cnt; + + i = read(io, (char *)&x, sizeof(x)); + if (i != sizeof(x) || N_BADMAG(x)) { + printf("Bad format\n"); + return; + } + + printf("%x", x.a_text); + if (N_GETMAGIC(x) == ZMAGIC) { + kernel.entry = entry = (void *)x.a_entry; + lseek(io, 0, SEEK_SET); + } + if (read(io, (char *)addr, x.a_text) != x.a_text) + goto shread; + addr += x.a_text; + if (N_GETMAGIC(x) == NMAGIC) + while ((int)addr & CLOFSET) + *addr++ = 0; + printf("+%x", x.a_data); + if (read(io, addr, x.a_data) != x.a_data) + goto shread; + addr += x.a_data; + printf("+%x", x.a_bss); + for (i = 0; i < x.a_bss; i++) + *addr++ = 0; + if (x.a_syms != 0 && !(kernel.bflags & RB_NOSYM)) { + bcopy(&x.a_syms, addr, sizeof(x.a_syms)); + addr += sizeof(x.a_syms); +#if 0 + nlp = (struct nlist *)addr; +#endif + printf("+[%x+", x.a_syms); + if (read(io, addr, x.a_syms) != x.a_syms) + goto shread; + addr += x.a_syms; +#if 0 + enlp = (struct nlist *)(strtab = addr); +#endif + + if (read(io, &strtablen, sizeof(int)) != sizeof(int)) + goto shread; + + bcopy(&strtablen, addr, sizeof(int)); + if (i = strtablen) { + i -= sizeof(int); + addr += sizeof(int); + cnt = read(io, addr, i); + if (cnt != i) + printf("symwarn"); /* goto shread; */ + addr += i; + } + printf("%x]", i); + esym = KERNBASE + + (((int)addr + sizeof(int) - 1) & ~(sizeof(int) - 1)); + kernel.symtab = (void *) x.a_syms; + kernel.esym = addr; + } else { + kernel.symtab = 0; + kernel.esym = 0; + } + +#if 0 + while (nlp < enlp) { + register int strx = nlp->n_un.n_strx; + if (strx > strtablen) + continue; + if (strcmp(strtab+strx, "_esym") == 0) { + *(int*)(nlp->n_value - KERNBASE) = esym; + break; + } + nlp++; + } +#endif + + kernel.bdev = 0; + kernel.end_loaded = (u_int)addr; + kernel.smini = 0; + kernel.emini = 0; + kernel.kname = 0; + + printf("=%x\n", (u_int)addr - (u_int)entry); /* XXX wrong? */ + +#if 0 +printf("entry %x\n",kernel.entry); +printf("symtab %x\n",kernel.symtab); +printf("esym %x\n",kernel.esym); +printf("bflags %x\n",kernel.bflags); +printf("bdev %x\n",kernel.bdev); +printf("kname %x\n",kernel.kname); +printf("smini %x\n",kernel.smini); +printf("emini %x\n",kernel.emini); +printf("end_loaded %x\n",kernel.end_loaded); +#endif + + printf("start at 0x%x\n", (int)entry); + if (((u_long)entry &0xf) == 0x2) { + (entry)(&bugargs, &kernel); + } else { + /* is type fixing anything like price fixing? */ + typedef (* kernel_start) __P((int, int, void *,void *, void *)); + kernel_start addr; + addr = (void *)entry; + (addr)(kernel.bflags, 0, kernel.esym, kernel.smini, kernel.emini); + } + return; + +shread: + printf("short read\n"); +} + +struct flags { + char c; + short bit; +} bf[] = { + { 'a', RB_ASKNAME }, + { 'b', RB_HALT }, + { 'y', RB_NOSYM }, + { 'd', RB_KDB }, + { 'm', RB_MINIROOT }, + { 'r', RB_DFLTROOT }, + { 's', RB_SINGLE }, +}; + +void +parse_args() +{ + char *name = "/netbsd", *ptr; + int i, howto = 0; + char c; + + if (bugargs.arg_start != bugargs.arg_end) { + ptr = bugargs.arg_start; + while (c = *ptr) { + while (c == ' ') + c = *++ptr; + if (c == '\0') + return; + if (c != '-') { + name = ptr; + while ((c = *++ptr) && c != ' ') + ; + if (c) + *ptr++ = 0; + continue; + } + while ((c = *++ptr) && c != ' ') { + for (i = 0; i < sizeof(bf)/sizeof(bf[0]); i++) + if (bf[i].c == c) { + howto |= bf[i].bit; + } + } + } + } + kernel.bflags = howto; + kernel.kname = name; +} diff --git a/sys/arch/mvme88k/stand/openbsd/bootsd/bootsd b/sys/arch/mvme88k/stand/openbsd/bootsd/bootsd Binary files differnew file mode 100644 index 00000000000..cee266d758c --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/bootsd/bootsd diff --git a/sys/arch/mvme88k/stand/openbsd/bootsd/bootsd.bin b/sys/arch/mvme88k/stand/openbsd/bootsd/bootsd.bin Binary files differnew file mode 100644 index 00000000000..7f1662f5309 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/bootsd/bootsd.bin diff --git a/sys/arch/mvme88k/stand/openbsd/bootsd/bootsd.bug b/sys/arch/mvme88k/stand/openbsd/bootsd/bootsd.bug Binary files differnew file mode 100644 index 00000000000..ec762438c25 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/bootsd/bootsd.bug diff --git a/sys/arch/mvme88k/stand/openbsd/bootsd/bugdev.c b/sys/arch/mvme88k/stand/openbsd/bootsd/bugdev.c new file mode 100644 index 00000000000..ce0935f9512 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/bootsd/bugdev.c @@ -0,0 +1,244 @@ +/* $Id: bugdev.c,v 1.1 1997/03/03 19:31:02 rahnds 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 <sys/disklabel.h> +#include <machine/prom.h> +#include "stand.h" + +int bugscopen __P((struct open_file *, ...)); +int bugscclose __P((struct open_file *)); +int bugscioctl __P((struct open_file *, u_long, void *)); +int bugscstrategy __P((void *, int, daddr_t, size_t, void *, size_t *)); + +void cputobsdlabel __P((struct disklabel *lp, struct cpu_disklabel *clp)); + +struct devsw devsw[] = { + { "bugsc", bugscstrategy, bugscopen, bugscclose, bugscioctl }, +}; +int ndevs = (sizeof(devsw)/sizeof(devsw[0])); + +extern struct mvmeprom_args bugargs; +int errno; + +struct bugsc_softc { + int fd; /* Prom file descriptor */ + int poff; /* Partition offset */ + int psize; /* Partition size */ + short ctrl; + short dev; +} bugsc_softc[1]; + +int +devopen(f, fname, file) + struct open_file *f; + const char *fname; + char **file; +{ + register struct bugsc_softc *pp = &bugsc_softc[0]; + int error, i, dn = 0, pn = 0; + char *dev, *cp; + static char iobuf[MAXBSIZE]; + struct disklabel sdlabel; + + dev = bugargs.arg_start; + + /* + * Extract partition # from boot device string. + */ + for (cp = dev; *cp; cp++) /* void */; + while (*cp != '/' && cp > dev) { + if (*cp == ':') + pn = *(cp+1) - 'a'; + --cp; + } + + pp->fd = bugscopen(f); + + if (pp->fd < 0) { + printf("Can't open device `%s'\n", dev); + return (ENXIO); + } + error = bugscstrategy(pp, F_READ, LABELSECTOR, DEV_BSIZE, iobuf, &i); + if (error) + return (error); + if (i != DEV_BSIZE) + return (EINVAL); + + cputobsdlabel(&sdlabel, (struct cpu_disklabel *)iobuf); + pp->poff = sdlabel.d_partitions[pn].p_offset; + pp->psize = sdlabel.d_partitions[pn].p_size; + + f->f_dev = devsw; + f->f_devdata = (void *)pp; + *file = (char *)fname; + return (0); +} + +/* silly block scale factor */ +#define BUG_BLOCK_SIZE 256 +#define BUG_SCALE (512/BUG_BLOCK_SIZE) +int +bugscstrategy(devdata, func, dblk, size, buf, rsize) + void *devdata; + int func; + daddr_t dblk; + size_t size; + void *buf; + size_t *rsize; +{ + struct mvmeprom_dskio dio; + register struct bugsc_softc *pp = (struct bugsc_softc *)devdata; + daddr_t blk = dblk + pp->poff; + + twiddle(); + + dio.ctrl_lun = pp->ctrl; + dio.dev_lun = pp->dev; + dio.status = 0; + dio.pbuffer = buf; + dio.blk_num = blk * BUG_SCALE; + dio.blk_cnt = size / BUG_BLOCK_SIZE; /* assumed size in bytes */ + dio.flag = 0; + dio.addr_mod = 0; +#ifdef 0 + printf("bugscstrategy: size=%d blk=%d buf=%x\n", size, blk, buf); + printf("ctrl %d dev %d\n", dio.ctrl_lun, dio.dev_lun); +#endif + mvmeprom_diskrd(&dio); + + *rsize = dio.blk_cnt * BUG_BLOCK_SIZE; +#ifdef 0 +printf("rsize %d status %x\n", *rsize, dio.status); +#endif + + if (dio.status) + return (EIO); + return (0); +} + +int +bugscopen(f) + struct open_file *f; +{ +#ifdef DEBUG + printf("bugscopen:\n"); +#endif + + f->f_devdata = (void *)bugsc_softc; + bugsc_softc[0].ctrl = (short)bugargs.ctrl_lun; + bugsc_softc[0].dev = (short)bugargs.dev_lun; + printf("using mvmebug ctrl %d dev %d\n", + bugsc_softc[0].ctrl, bugsc_softc[0].dev); + return (0); +} + +int +bugscclose(f) + struct open_file *f; +{ + return (EIO); +} + +int +bugscioctl(f, cmd, data) + struct open_file *f; + u_long cmd; + void *data; +{ + return (EIO); +} + +void +cputobsdlabel(lp, clp) + struct disklabel *lp; + struct cpu_disklabel *clp; +{ + int i; + + lp->d_magic = clp->magic1; + lp->d_type = clp->type; + lp->d_subtype = clp->subtype; + bcopy(clp->vid_vd, lp->d_typename, 16); + bcopy(clp->packname, lp->d_packname, 16); + lp->d_secsize = clp->cfg_psm; + lp->d_nsectors = clp->cfg_spt; + lp->d_ncylinders = clp->cfg_trk; /* trk is really num of cyl! */ + lp->d_ntracks = clp->cfg_hds; + + lp->d_secpercyl = clp->secpercyl; + lp->d_secperunit = clp->secperunit; + lp->d_secpercyl = clp->secpercyl; + lp->d_secperunit = clp->secperunit; + lp->d_sparespertrack = clp->sparespertrack; + lp->d_sparespercyl = clp->sparespercyl; + lp->d_acylinders = clp->acylinders; + lp->d_rpm = clp->rpm; + lp->d_interleave = clp->cfg_ilv; + lp->d_trackskew = clp->cfg_sof; + lp->d_cylskew = clp->cylskew; + lp->d_headswitch = clp->headswitch; + + /* this silly table is for winchester drives */ + switch (clp->cfg_ssr) { + case 0: + lp->d_trkseek = 0; + break; + case 1: + lp->d_trkseek = 6; + break; + case 2: + lp->d_trkseek = 10; + break; + case 3: + lp->d_trkseek = 15; + break; + case 4: + lp->d_trkseek = 20; + break; + default: + lp->d_trkseek = 0; + break; + } + lp->d_flags = clp->flags; + for (i = 0; i < NDDATA; i++) + lp->d_drivedata[i] = clp->drivedata[i]; + for (i = 0; i < NSPARE; i++) + lp->d_spare[i] = clp->spare[i]; + lp->d_magic2 = clp->magic2; + lp->d_checksum = clp->checksum; + lp->d_npartitions = clp->partitions; + lp->d_bbsize = clp->bbsize; + lp->d_sbsize = clp->sbsize; + bcopy(clp->vid_4, &(lp->d_partitions[0]), sizeof (struct partition) * 4); + bcopy(clp->cfg_4, &(lp->d_partitions[4]), sizeof (struct partition) * 12); +} diff --git a/sys/arch/mvme88k/stand/openbsd/bootsd/filesystem.c b/sys/arch/mvme88k/stand/openbsd/bootsd/filesystem.c new file mode 100644 index 00000000000..9761fda621e --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/bootsd/filesystem.c @@ -0,0 +1,42 @@ +/* $Id: filesystem.c,v 1.1 1997/03/03 19:31:02 rahnds Exp $ */ + +/* + * Copyright (c) 1993 Philip A. Nelson. + * 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 Philip A. Nelson. + * 4. The name of Philip A. Nelson may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY PHILIP NELSON ``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 PHILIP NELSON 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 <stand.h> +#include <ufs.h> + +struct fs_ops file_system[] = { + { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat }, +}; + +int nfsys = sizeof(file_system)/sizeof(struct fs_ops); + diff --git a/sys/arch/mvme88k/stand/openbsd/bootsd/sdboot b/sys/arch/mvme88k/stand/openbsd/bootsd/sdboot Binary files differnew file mode 100644 index 00000000000..baf73ee5fdf --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/bootsd/sdboot diff --git a/sys/arch/mvme88k/stand/openbsd/bootsd/version.c b/sys/arch/mvme88k/stand/openbsd/bootsd/version.c new file mode 100644 index 00000000000..8d5d0c1fd0f --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/bootsd/version.c @@ -0,0 +1,8 @@ +/* $Id: version.c,v 1.1 1997/03/03 19:31:02 rahnds Exp $ */ + +/* + * make a random change to this file when you want the bootblock + * revision to increase. like change this x to a y, or something. + */ + +char *version = "$Revision: 1.1 $"; diff --git a/sys/arch/mvme88k/stand/openbsd/bootst/Makefile b/sys/arch/mvme88k/stand/openbsd/bootst/Makefile new file mode 100644 index 00000000000..2730b06af9b --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/bootst/Makefile @@ -0,0 +1,41 @@ +# from: @(#)Makefile 8.1 (Berkeley) 6/10/93 +# $Id: Makefile,v 1.1 1997/03/03 19:31:03 rahnds Exp $ + +RELOC=0x3F0000 + +S= ${.CURDIR}/../../../.. +DEFS= -DSTANDALONE -DCOMPAT_NOLABEL # -DROMPRF +INCPATH=-I${.CURDIR} -I${.CURDIR}/../../include -I${S} -I${S}/lib/libsa +CFLAGS= -O2 ${INCPATH} ${DEFS} ${COPTS} +CLEANFILES+=sdboot bootst bootst.bug + +#.PATH: ${S}/arch/${MACHINE_ARCH}/${MACHINE_ARCH} +#.PATH: ${S}/lib/libsa + +.include "${S}/arch/${MACHINE}/stand/libsa/Makefile.inc" +.include "${S}/arch/${MACHINE}/stand/libbug/Makefile.inc" +.include "${S}/arch/${MACHINE}/stand/bugcrt/Makefile.inc" +.include "${S}/arch/${MACHINE}/stand/wrtvid/Makefile.inc" + +SRCS= bootst.c + +LIBS= ${LIBSA} ${LIBBUG} + +OBJS= ${SRCS:N*.h:R:S/$/.o/g} + +BOOTS= bootst stboot +ALL= ${BOOTS} + +all: ${ALL} + +bootst.bug: ${OBJS} ${BUGCRT} ${LIBS} + ${LD} -s -N -T ${RELOC} ${BUGCRT} ${OBJS} ${LIBS} -o $@ + @size bootst.bug + +bootst stboot: bootst.bug ${WRTVID} + ${WRTVID} bootst.bug + +install: + install -c -m 555 -g bin -o bin ${BOOTS} ${DESTDIR}${MDEC_DIR} + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/openbsd/bootst/bootst b/sys/arch/mvme88k/stand/openbsd/bootst/bootst Binary files differnew file mode 100644 index 00000000000..53c7665552c --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/bootst/bootst diff --git a/sys/arch/mvme88k/stand/openbsd/bootst/bootst.bug b/sys/arch/mvme88k/stand/openbsd/bootst/bootst.bug Binary files differnew file mode 100644 index 00000000000..34dbd2763ba --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/bootst/bootst.bug diff --git a/sys/arch/mvme88k/stand/openbsd/bootst/bootst.c b/sys/arch/mvme88k/stand/openbsd/bootst/bootst.c new file mode 100644 index 00000000000..d0dd5586a57 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/bootst/bootst.c @@ -0,0 +1,357 @@ +#include <sys/types.h> +#include <sys/param.h> +#include <sys/reboot.h> +#include <sys/exec.h> +#include <machine/prom.h> + +#define RB_NOSYM 0x400 + +void parse_args __P((struct mvmeprom_args *pbugargs)); +int load_kern(); +int read_tape_block __P((short ctrl, short dev, short *status, + void *addr, int *cnt, int blk_num, u_char *flags, int verbose)); + +struct kernel { + void *entry; + void *symtab; + void *esym; + int bflags; + int bdev; + char *kname; + void *smini; + void *emini; + u_int end_loaded; +} kernel; + +typedef(*kernel_entry) __P((struct mvmeprom_args *, struct kernel *)); + +int +main(pbugargs) + struct mvmeprom_args *pbugargs; +{ + kernel_entry addr; + + /* + print_bugargs(pbugargs); + print_time(); + print_brdid(); + print_memory(); + */ + parse_args(pbugargs); + if (load_kern(pbugargs) == 1) { + printf("unsuccessful in loading kernel\n"); + } else { + addr = kernel.entry; + + printf("kernel loaded at %x\n", addr); + printf("kernel.entry %x\n", kernel.entry); + printf("kernel.symtab %x\n", kernel.symtab); + printf("kernel.esym %x\n", kernel.esym); + printf("kernel.bflags %x\n", kernel.bflags); + printf("kernel.bdev %x\n", kernel.bdev); + if (kernel.kname) + printf("kernel.kname <%s>\n", kernel.kname); + else + printf("kernel.kname <null>\n"); + printf("kernel.end_loaded %x\n", kernel.end_loaded); + + if (kernel.bflags & RB_MINIROOT) + loadmini(kernel.end_loaded, pbugargs); + + printf("kernel.smini %x\n", kernel.smini); + printf("kernel.emini %x\n", kernel.emini); + printf("kernel.end_loaded %x\n", kernel.end_loaded); + if (kernel.bflags & RB_HALT) + mvmeprom_return(); + if (((u_long)addr &0xf) == 0x2) { + (addr)(pbugargs, &kernel); + } else { + /* is type fixing anything like price fixing? */ + typedef (* kernel_start) __P((int, int, void *,void *, void *)); + kernel_start addr1; + addr1 = (void *)addr; + (addr1)(kernel.bflags, 0, kernel.esym, kernel.smini, kernel.emini + ); + } + + } + return (0); +} + +#define MVMEPROM_SCALE (512/MVMEPROM_BLOCK_SIZE) + +int +read_tape_block(ctrl, dev, status, addr, cnt, blk_num, flags, verbose) + short ctrl; + short dev; + short *status; + void *addr; + int *cnt; + int blk_num; + u_char *flags; + int verbose; +{ + struct mvmeprom_dskio dio; + int ret; + + dio.ctrl_lun = ctrl; + dio.dev_lun = dev; + dio.status = *status; + dio.pbuffer = addr; + dio.blk_num = blk_num; + dio.blk_cnt = *cnt / (512 / MVMEPROM_SCALE); + dio.flag = *flags; + dio.addr_mod = 0; + + if (verbose) + printf("saddr %x eaddr %x", dio.pbuffer, + (int) dio.pbuffer + (dio.blk_cnt * MVMEPROM_BLOCK_SIZE)); + ret = mvmeprom_diskrd(&dio); + + *status = dio.status; + *cnt = (dio.blk_cnt / MVMEPROM_SCALE) * 512; + if (verbose) { + printf("status %x ret %d ", *status, ret); + printf("flags %x blocks read %x cnt %x\n", + *flags, dio.blk_cnt, *cnt); + } + return (ret); +} +#ifdef DEBUG +int verbose = 1; +#else +int verbose = 0; +#endif + +int +load_kern(pbugargs) + struct mvmeprom_args *pbugargs; +{ + int ret; + char *addr; + u_char flags; + short status = 0; + int blk_num; + struct exec *pexec; + int magic; + int *esym; + int *symtab; + int cnt, len; + char buf[512]; + + blk_num = 2; + /* flags = IGNORE_FILENUM; */ + flags = 0; + cnt = 512; +printf("ctrl %x dev %x\n",pbugargs->ctrl_lun, pbugargs->dev_lun); + ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, &status, + buf, &cnt, blk_num, &flags, verbose); + if (ret != 0) { + printf("unable to load kernel 1 status %x\n", status); + return (1); + } + pexec = (struct exec *) buf; + if (N_GETMID(*pexec) != MID_M68K && + N_GETMID(*pexec) != MID_M68K4K) { + printf("invalid mid on kernel\n"); + return (1); + } + + magic = N_GETMAGIC(*pexec); + switch (magic) { + case ZMAGIC: + break; + case NMAGIC: + printf("NMAGIC not yet supported"); + case OMAGIC: + case QMAGIC: + default: + printf("Unknown or unsupported magic type <%x>\n", magic); + return (1); + } + if (magic == ZMAGIC) { + status = 0; + addr = (char *) (pexec->a_entry & ~0x0FFF); + + if ((int) pexec->a_entry != (int) addr + 0x22) { + printf("warning kernel start address not %x, %x\n", + (int) addr + 0x22, pexec->a_entry); + printf("kernel loaded at %x\n", addr); + } + bcopy(&buf, addr, 512); + /* 2nd block of exe */ + addr += 512; + + printf("text 0x%x data 0x%x bss 0x%x\n", + pexec->a_text, pexec->a_data, pexec->a_bss); + + len = (pexec->a_text - 512); /* XXX */ + len += (pexec->a_data); + + printf("loading [ %x + %x ", pexec->a_text, pexec->a_data); + + cnt = len; + flags = IGNORE_FILENUM; + ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, + &status, addr, &cnt, blk_num, &flags, verbose); + if (ret != 0 || cnt != len) { + printf("unable to load kernel 2 status %x\n", status); + return 1; + } + addr += len; + + /* Skip over text and data and zero bss. */ + len = pexec->a_bss; + printf("+ %x", len); +#ifdef DEBUG + printf("bss %x - %x\n", addr, addr + pexec->a_bss); +#endif + bzero(addr, pexec->a_bss); + addr += len; + + if (pexec->a_syms != 0 && !(kernel.bflags & RB_NOSYM)) { + printf(" + [ %x", pexec->a_syms); + addr += 4; /* skip over _end symbol */ + symtab = (void *) pexec->a_syms; + len = pexec->a_syms; + cnt = ((len + (512 - 1)) / 512) * 512; + flags = IGNORE_FILENUM; + ret = read_tape_block(pbugargs->ctrl_lun, + pbugargs->dev_lun, &status, addr, + &cnt, blk_num, &flags, verbose); + if (ret != 0 || cnt != ((len + (512 - 1)) / 512) * 512) { + printf("unable to load kernel 3\n"); + return 1; + } + /* this value should have already been loaded XXX */ + esym = (void *) ((u_int) addr + pexec->a_syms); + if ((int) addr + cnt <= (int) esym) { + printf("missed loading count of symbols\n"); + return 1; + } + addr += cnt; + + + len = *esym; +#if 0 + printf("start load %x end load %x %x\n", addr, + len, addr + len); + printf("esym %x *esym %x\n", esym, len); +#endif + /* dont load tail of already loaded */ + len -= (u_int) addr - (u_int) esym; + + if (len > 0) { + printf(" + %x", *esym); + esym = (void *) (addr + len); + cnt = ((len + (512 - 1)) / 512) * 512; + flags = IGNORE_FILENUM; + ret = read_tape_block(pbugargs->ctrl_lun, + pbugargs->dev_lun, &status, addr, + &cnt, blk_num, &flags, verbose); + if (ret != 0 || cnt != ((len + (512-1)) / 512)*512) { + printf("unable to load kernel 4\n"); + return (1); + } + addr += len; + printf(" ]"); + } else { + printf("+ %x ]", *esym); + } + esym = (int *) (((int) esym) + *esym); + + kernel.symtab = symtab; + kernel.esym = esym; + } else { + kernel.symtab = 0; + kernel.esym = 0; + } + kernel.end_loaded = (int) addr; + flags = IGNORE_FILENUM | END_OF_FILE; + cnt = 8192; + printf("removing pad ["); + ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, + &status, addr, &cnt, blk_num, &flags, verbose); + if (ret != 0) { + printf("unable to load kernel 5\n"); + return (1); + } + printf(" %d ]", cnt); + + printf("]\n"); + } + kernel.entry = (void *) pexec->a_entry; + return (0); +} + +int +loadmini(addr, pbugargs) + u_int addr; + struct mvmeprom_args *pbugargs; +{ + int cnt, ret, blk_num = 3; + short status = 0; + u_char flags; + + /* align addr to some boundary */ +#define ALIGN_F 0x4 + addr = (u_int) ((((int) addr + ALIGN_F - 1) / ALIGN_F) * ALIGN_F); +#undef ALIGN_F + flags = END_OF_FILE; + cnt = 6144 * 512; /* some abserdly large value. (3meg) */ + printf("loading miniroot[ "); + ret = read_tape_block(pbugargs->ctrl_lun, pbugargs->dev_lun, + &status, (void *) addr, &cnt, blk_num, &flags, verbose); + if (ret != 0) { + printf("unable to load miniroot\n"); + return (1); + } + kernel.smini = (void *)addr; + printf("%d ]\n", cnt); + kernel.emini = (void *) ((u_int) addr + cnt); + kernel.end_loaded = (u_int) kernel.emini; + return (0); +} + +void +parse_args(pargs) + struct mvmeprom_args *pargs; +{ + char *ptr = pargs->arg_start; + char c, *name = NULL; + int howto = 0; + + if (pargs->arg_start != pargs->arg_end) { + while (c = *ptr) { + while (c == ' ') + c = *++ptr; + if (!c) + return; + if (c != '-') { + name = ptr; + while ((c = *++ptr) && c != ' '); + if (c) + *ptr++ = 0; + continue; + } + while ((c = *++ptr) && c != ' ') { + if (c == 'a') + howto |= RB_ASKNAME; + else if (c == 'b') + howto |= RB_HALT; + else if (c == 'y') + howto |= RB_NOSYM; + else if (c == 'd') + howto |= RB_KDB; + else if (c == 'm') + howto |= RB_MINIROOT; + else if (c == 'r') + howto |= RB_DFLTROOT; + else if (c == 's') + howto |= RB_SINGLE; + } + } + } + kernel.bflags = howto; + kernel.kname = name; +} diff --git a/sys/arch/mvme88k/stand/openbsd/bootst/stboot b/sys/arch/mvme88k/stand/openbsd/bootst/stboot Binary files differnew file mode 100644 index 00000000000..a6b19b34db4 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/bootst/stboot diff --git a/sys/arch/mvme88k/stand/openbsd/bugcrt/Makefile b/sys/arch/mvme88k/stand/openbsd/bugcrt/Makefile new file mode 100644 index 00000000000..04c7936ff58 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/bugcrt/Makefile @@ -0,0 +1,24 @@ +# $Id: Makefile,v 1.1 1997/03/03 19:31:03 rahnds Exp $ + +CFLAGS+=-I${.CURDIR}/../../include -O2 + +.include "${MACHINE_ARCH}/Makefile.inc" + +.PATH: ${.CURDIR}/${MACHINE_ARCH} + +OBJS=bugcrt.o + +CLEANFILES+=a.out + +all: ${OBJS} + +bugcrt.o: bugcrt.c + ${CC} ${CFLAGS} -c ${.ALLSRC} + ${LD} -x -r ${.TARGET} + mv a.out ${.TARGET} + +install: + +lint tags: + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/openbsd/bugcrt/Makefile.inc b/sys/arch/mvme88k/stand/openbsd/bugcrt/Makefile.inc new file mode 100644 index 00000000000..f2bae6c888c --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/bugcrt/Makefile.inc @@ -0,0 +1,12 @@ +BUG_CRT_DIR=${S}/arch/${MACHINE}/stand/bugcrt + +BUGCRT_DIR!= cd ${BUG_CRT_DIR}; \ + printf "xxx:\n\techo \$${.OBJDIR}\n" | ${MAKE} -r -s -f - xxx + +BUGCRT=${BUGCRT_DIR}/bugcrt.o + +$(BUGCRT): .NOTMAIN __always_make_bugcrt + @echo making sure the bugcrt is up to date... + @(cd ${BUG_CRT_DIR}; ${MAKE}) + +__always_make_bugcrt: .NOTMAIN diff --git a/sys/arch/mvme88k/stand/openbsd/bugcrt/m88k/Makefile.inc b/sys/arch/mvme88k/stand/openbsd/bugcrt/m88k/Makefile.inc new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/bugcrt/m88k/Makefile.inc diff --git a/sys/arch/mvme88k/stand/openbsd/bugcrt/m88k/bugcrt.c b/sys/arch/mvme88k/stand/openbsd/bugcrt/m88k/bugcrt.c new file mode 100644 index 00000000000..711b4fe2035 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/bugcrt/m88k/bugcrt.c @@ -0,0 +1,39 @@ +#include <sys/types.h> +#include <machine/prom.h> + +struct mvmeprom_args bugargs = { 1 }; /* not BSS */ + + asm (".text"); + asm (".long 0x003ffff8"); + asm (".long _start"); +start() +{ + register int dev_lun asm ("r2"); + register int ctrl_lun asm ("r3"); + register int flags asm ("r4"); + register int ctrl_addr asm ("r5"); + register int entry asm ("r6"); + register int conf_blk asm ("r7"); + register char *arg_start asm ("r8"); + register char *arg_end asm ("r9"); + extern int edata, end; + + bugargs.dev_lun = dev_lun; + bugargs.ctrl_lun = ctrl_lun; + bugargs.flags = flags; + bugargs.ctrl_addr = ctrl_addr; + bugargs.entry = entry; + bugargs.conf_blk = conf_blk; + bugargs.arg_start = arg_start; + bugargs.arg_end = arg_end; + *arg_end = 0; + + bzero(&edata, (int)&edata - (int)&end); + main(); + mvmeprom_return(); + /* NOTREACHED */ +} + +__main() +{ +} diff --git a/sys/arch/mvme88k/stand/openbsd/libbug/Makefile b/sys/arch/mvme88k/stand/openbsd/libbug/Makefile new file mode 100644 index 00000000000..ba775e5693d --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libbug/Makefile @@ -0,0 +1,14 @@ +LIB=bug + +NOPIC= +NOPROFILE= + +CFLAGS+=-I${.CURDIR}/../../include + +SRCS=delay.c diskrd.c diskwr.c getbrdid.c instat.c outln.c outstr.c \ + return.c rtc_rd.c +.PATH: ${.CURDIR}/../../../../lib/libc_sa ${.CURDIR}/${MACHINE_ARCH} + +install: + +.include <bsd.lib.mk> diff --git a/sys/arch/mvme88k/stand/openbsd/libbug/Makefile.inc b/sys/arch/mvme88k/stand/openbsd/libbug/Makefile.inc new file mode 100644 index 00000000000..dc1ad6b04c8 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libbug/Makefile.inc @@ -0,0 +1,12 @@ +LIB_BUG_DIR=${S}/arch/${MACHINE}/stand/libbug + +LIBBUG_DIR!= cd ${LIB_BUG_DIR}; \ + printf "xxx:\n\techo \$${.OBJDIR}\n" | ${MAKE} -r -s -f - xxx + +LIBBUG=${LIBBUG_DIR}/libbug.a + +$(LIBBUG): .NOTMAIN __always_make_libbug + @echo making sure the libbug is up to date... + @(cd ${LIB_BUG_DIR}; ${MAKE}) + +__always_make_libbug: .NOTMAIN diff --git a/sys/arch/mvme88k/stand/openbsd/libbug/log1 b/sys/arch/mvme88k/stand/openbsd/libbug/log1 new file mode 100644 index 00000000000..448b6b71f94 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libbug/log1 @@ -0,0 +1,9 @@ +delay.o delay.o +diskrd.o diskrd.o +diskwr.o diskwr.o +getbrdid.o getbrdid.o +instat.o instat.o +outln.o outln.o +outstr.o outstr.o +return.o return.o +rtc_rd.o rtc_rd.o diff --git a/sys/arch/mvme88k/stand/openbsd/libbug/log2 b/sys/arch/mvme88k/stand/openbsd/libbug/log2 new file mode 100644 index 00000000000..7a8950e635f --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libbug/log2 @@ -0,0 +1,9 @@ +rtc_rd.o +return.o +outstr.o +outln.o +instat.o +getbrdid.o +diskwr.o +diskrd.o +delay.o diff --git a/sys/arch/mvme88k/stand/openbsd/libbug/m88k/delay.c b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/delay.c new file mode 100644 index 00000000000..68b1db12106 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/delay.c @@ -0,0 +1,15 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +/* BUG - timing routine */ +void +mvmeprom_delay(msec) + int msec; +{ + asm volatile ("or r2,r0,%0": : "r" (msec)); + MVMEPROM_CALL(MVMEPROM_DELAY); +} diff --git a/sys/arch/mvme88k/stand/openbsd/libbug/m88k/diskrd.c b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/diskrd.c new file mode 100644 index 00000000000..bc69b365501 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/diskrd.c @@ -0,0 +1,19 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +/* returns 0: success, nonzero: error */ +int +mvmeprom_diskrd(arg) + struct mvmeprom_dskio *arg; +{ + int ret; + + asm volatile ("or r2,r0,%0": : "r" (arg)); + MVMEPROM_CALL(MVMEPROM_DSKRD); + asm volatile ("or %0,r0,r2" : "=r" (ret)); + return (!(ret & 0x4)); +} diff --git a/sys/arch/mvme88k/stand/openbsd/libbug/m88k/diskwr.c b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/diskwr.c new file mode 100644 index 00000000000..681f521b5b0 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/diskwr.c @@ -0,0 +1,19 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +/* returns 0: success, nonzero: error */ +int +mvmeprom_diskwr(arg) + struct mvmeprom_dskio *arg; +{ + int ret; + + asm volatile ("or r2,r0,%0": : "r" (arg) ); + MVMEPROM_CALL(MVMEPROM_DSKWR); + asm volatile ("or %0,r0,r2" : "=r" (ret)); + return (!(ret & 0x4)); +} diff --git a/sys/arch/mvme88k/stand/openbsd/libbug/m88k/getbrdid.c b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/getbrdid.c new file mode 100644 index 00000000000..eeda9468ab7 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/getbrdid.c @@ -0,0 +1,17 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +/* BUG - query board routines */ +struct mvmeprom_brdid * +mvmeprom_brdid() +{ + struct mvmeprom_brdid *id; + + MVMEPROM_CALL(MVMEPROM_GETBRDID); + asm volatile ("or %0,r0,r2": "=r" (id):); + return (id); +} diff --git a/sys/arch/mvme88k/stand/openbsd/libbug/m88k/instat.c b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/instat.c new file mode 100644 index 00000000000..0ac97fe7676 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/instat.c @@ -0,0 +1,17 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +/* returns 0 if no characters ready to read */ +int +mvmeprom_instat() +{ + short ret; + + MVMEPROM_CALL(MVMEPROM_INSTAT); + asm volatile ("or %0,r0,r2" : "=r" (ret)); + return (!(ret & 0x4)); +} diff --git a/sys/arch/mvme88k/stand/openbsd/libbug/m88k/outch.c b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/outch.c new file mode 100644 index 00000000000..78110e0299f --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/outch.c @@ -0,0 +1,15 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +void +mvmeprom_outchr(a) + char a; +{ + asm volatile ("or r2, r0, %0" : :"r" (a)); + BUG_CALL(_OUTCHR); +} + diff --git a/sys/arch/mvme88k/stand/openbsd/libbug/m88k/outln.c b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/outln.c new file mode 100644 index 00000000000..ed0067e42d9 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/outln.c @@ -0,0 +1,15 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +void +mvmeprom_outln(start, end) + char *start, *end; +{ + asm volatile ("or r2,r0,%0": : "r" (start)); + asm volatile ("or r3,r0,%0": : "r" (end)); + MVMEPROM_CALL(MVMEPROM_OUTSTRCRLF); +} diff --git a/sys/arch/mvme88k/stand/openbsd/libbug/m88k/outstr.c b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/outstr.c new file mode 100644 index 00000000000..c9e3c355736 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/outstr.c @@ -0,0 +1,15 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +void +mvmeprom_outstr(start, end) + char *start, *end; +{ + asm volatile ("or r2,r0,%0": : "r" (start)); + asm volatile ("or r3,r0,%0": : "r" (end)); + MVMEPROM_CALL(MVMEPROM_OUTSTR); +} diff --git a/sys/arch/mvme88k/stand/openbsd/libbug/m88k/prom.h b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/prom.h new file mode 100644 index 00000000000..4048e86eaff --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/prom.h @@ -0,0 +1,3 @@ +#define MVMEPROM_CALL(x) \ + asm volatile ( __CONCAT("or r9,r0," __STRING(x)) ); \ + asm volatile ("tb0 0,r0,496"); diff --git a/sys/arch/mvme88k/stand/openbsd/libbug/m88k/return.c b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/return.c new file mode 100644 index 00000000000..00206a16c48 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/return.c @@ -0,0 +1,14 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +/* BUG - return to bug routine */ +void +mvmeprom_return() +{ + MVMEPROM_CALL(MVMEPROM_EXIT); + /*NOTREACHED*/ +} diff --git a/sys/arch/mvme88k/stand/openbsd/libbug/m88k/rtc_rd.c b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/rtc_rd.c new file mode 100644 index 00000000000..7cff3227678 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libbug/m88k/rtc_rd.c @@ -0,0 +1,14 @@ +/* + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +void +mvmeprom_rtc_rd(ptime) + struct mvmeprom_time *ptime) +{ + asm volatile ("or r2,r0,%0": : "r" (ptime)); + MVMEPROM_CALL(MVMEPROM_RTC_RD); +} diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/Makefile b/sys/arch/mvme88k/stand/openbsd/libsa/Makefile new file mode 100644 index 00000000000..45a1240ed7b --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/Makefile @@ -0,0 +1,47 @@ +# $Id: Makefile,v 1.1 1997/03/03 19:31:06 rahnds Exp $ + +LIB=sa + +CLEANFILES+=SRT0.o SRT1.o + +NOPIC=nopic +NOPROFILE=noprofile + +# Logically src/sys +S=${.CURDIR}/../../../.. +DIR_SA=$S/lib/libsa +DIR_KERN=$S/lib/libkern + +SRC_net= nfs.c rpc.c net.c ether.c arp.c in_cksum.c netif.c \ + bootparam.c rarp.c + + +SRC_sa = alloc.c bcopy.c memcpy.c close.c getfile.c open.c \ + printf.c read.c strerror.c ufs.c globals.c lseek.c \ + closeall.c dev.c dkcksum.c nullfs.c fstat.c + +SRC_kern= ashrdi3.c bcmp.c bzero.c strcmp.c strlen.c + +SRC_sun3= exec_sun.c + +SRC_here= clock.c devopen.c dvma.c \ + gets.c panic.c \ + promboot.c promcons.c + +SRCS= ${SRC_net} ${SRC_sa} ${SRC_kern} ${SRC_sun3} ${SRC_here} + +# DBG= -DDEBUG -DNETIF_DEBUG -DNFS_DEBUG -DRPC_DEBUG \ +# -DNET_DEBUG -DRARP_DEBUG -DETHER_DEBUG + +#DEFS= -DCOMPAT_UFS +INCL= -I. -I${S}/lib/libsa -I${S} +COPTS= #-fno-defer-pop +CFLAGS= -O2 ${COPTS} ${DEFS} ${DBG} ${INCL} + +.PATH: ${DIR_SA} ${DIR_KERN} ../../sun3 + +all: libsa.a SRT0.o SRT1.o + +install: + +.include <bsd.lib.mk> diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/Makefile.inc b/sys/arch/mvme88k/stand/openbsd/libsa/Makefile.inc new file mode 100644 index 00000000000..c402951fa76 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/Makefile.inc @@ -0,0 +1,12 @@ +LIB_SA_DIR=${S}/arch/${MACHINE}/stand/libsa + +LIBSA_DIR!= cd ${LIB_SA_DIR}; \ + printf "xxx:\n\techo \$${.OBJDIR}\n" | ${MAKE} -r -s -f - xxx + +LIBSA=${LIBSA_DIR}/libsa.a + +$(LIBSA): .NOTMAIN __always_make_libsa + @echo making sure the libsa is up to date... + @(cd ${LIB_SA_DIR}; ${MAKE}) + +__always_make_libsa: .NOTMAIN diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/SRT0.S b/sys/arch/mvme88k/stand/openbsd/libsa/SRT0.S new file mode 100644 index 00000000000..1020a7ad9d5 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/SRT0.S @@ -0,0 +1,130 @@ +| $Id: SRT0.S,v 1.1 1997/03/03 19:31:06 rahnds Exp $ + +| Copyright (c) 1995 Theo de Raadt +| +| 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 under OpenBSD by +| Theo de Raadt for Willowglen Singapore. +| 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. +| +| Copyright (c) 1995 Gordon W. Ross +| 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. The name of the author may not be used to endorse or promote products +| derived from this software without specific prior written permission. +| 4. All advertising materials mentioning features or use of this software +| must display the following acknowledgement: +| This product includes software developed by Gordon Ross +| +| 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. + +| SRT0.S - Stand-alone Run-Time startup code, part 0 + .file "SRT0.S" + .text + .globl __estack +__estack: + .globl start +start: +| Check to see if the code is located correctly. +| This SHOULD do a PC-relative load into a0, but... +| lea start, a0 | current location (0x4000) +| XXX - GAS version 1.93 gets the above lea wrong! + .word 0x41fa + .word 0xfffe +| Now force a long (not PC-relative) load to a1 and compare. + lea start:l, a1 | desired location (LINKADDR) + cmpl a0, a1 + beqs restart + +| Relocate the code and data to where they belong. + movl #_edata,d2 | Desired end of program + subl a1,d2 | Calculate length, round up. + lsrl #2,d2 +Lcp: movl a0@+, a1@+ + dbra d2, Lcp + +| Force a long jump to the relocated code (not pc-relative) + lea restart:l, a0 + jmp a0@ + +restart: +| now in the relocated code + +| Set up stack (just before relocated text) + lea __estack:l, a0 + movl a0, sp + subl a6, a6 + + movl d0, _devlun + movl d1, _ctrlun + movl a3, _oparg + movl a4, _opargend + +| Call the run-time startup C code, which will: +| initialize, call main, call exit + jsr __start:l + +| If _start returns, fall into abort. + .globl _abort +_abort: + trap #0 + +| If abort returns, fall into reset. + .globl _reset +_reset: + reset + jmp _reset + +| function to get the vector base register + .globl _getvbr +_getvbr: + movc vbr, d0 + rts + +| The end. + + .data + .globl _devlun, _ctrlun, _oparg, _opargend +_devlun: .long 0 +_ctrlun: .long 0 +_oparg: .long 0 +_opargend: .long 0 diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/SRT1.c b/sys/arch/mvme88k/stand/openbsd/libsa/SRT1.c new file mode 100644 index 00000000000..65b5f4ba030 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/SRT1.c @@ -0,0 +1,115 @@ +/* $Id: SRT1.c,v 1.1 1997/03/03 19:31:06 rahnds Exp $ */ + +/* + * Copyright (c) 1995 Theo de Raadt + * + * 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 under OpenBSD by + * Theo de Raadt for Willowglen Singapore. + * 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. + * + * Copyright (c) 1995 Gordon W. Ross + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * 4. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Gordon Ross + * + * 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. + */ + +/* SRT1.c - Stand-alone Run-time startup code, part 1 */ + +#include <stdarg.h> +#include <sys/types.h> + +#include "config.h" + +extern int edata[], end[]; +extern int * getvbr(); +extern volatile void abort(); + +volatile void +exit() +{ +#if 0 + mon_exit_to_mon(); +#endif + abort(); +} + +struct brdid brdid; +int cputyp; + +/* + * This is called by SRT0.S + * to do final prep for main + */ +_start() +{ + register int *p; + + /* Clear BSS */ + p = edata; + do *p++ = 0; + while (p < end); + +#if 0 + /* Set the vector for trap 0 used by abort. */ + p = getvbr(); + p[32] = (int)romp->abortEntry; +#endif + + asm("clrl sp@-; trap #15; .short 0x70; movl sp@+, %0" : "&=d" (p)); + bcopy(p, &brdid, sizeof brdid); + cputyp = brdid.model; + + main(0); + exit(); +} + +/* + * Boot programs in C++ ? Not likely! + */ +__main() {} diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/bug.c b/sys/arch/mvme88k/stand/openbsd/libsa/bug.c new file mode 100644 index 00000000000..e0ac46017bf --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/bug.c @@ -0,0 +1,136 @@ +/* + * Copyright (c) 1995 Theo de Raadt + * 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 Theo de Raadt + * 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. + * + * bug routines -- assumes that the necessary sections of memory + * are preserved. + */ +#include <sys/types.h> +#include <machine/prom.h> + +#define MVMEPROM_CALL(x) \ + asm volatile (__CONCAT("trap #15; .short ", __STRING(x)) ) + +/* returns 0 if no characters ready to read */ +int +mvmeprom_instat() +{ + u_short ret; + + MVMEPROM_CALL(MVMEPROM_INSTAT); + asm volatile ("movew ccr,%0": "=d" (ret)); + return (!(ret & 0x4)); +} + +void +mvmeprom_outstr(start, end) + char *start, *end; +{ + asm volatile ("movl %0, sp@-" : "=a" (start)); + asm volatile ("movl %0, sp@-" : "=a" (end)); + MVMEPROM_CALL(MVMEPROM_OUTSTR); +} + +void +mvmeprom_outln(start, end) + char *start, *end; +{ + asm volatile ("movl %0, sp@-" : "=a" (start)); + asm volatile ("movl %0, sp@-" : "=a" (end)); + MVMEPROM_CALL(MVMEPROM_OUTSTRCRLF); +} + +/* returns 0: success, nonzero: error */ +int +mvmeprom_diskrd(arg) + struct mvmeprom_dskio *arg; +{ + int ret; + + asm volatile ("movel %0, sp@-"::"d" (arg)); + MVMEPROM_CALL(MVMEPROM_DSKRD); + asm volatile ("movew ccr,%0": "=d" (ret)); + return (!(ret & 0x4)); +} + +/* returns 0: success, nonzero: error */ +int +mvmeprom_diskwr(arg) + struct mvmeprom_dskio *arg; +{ + int ret; + + asm volatile ("movel %0, sp@-"::"d" (arg)); + MVMEPROM_CALL(MVMEPROM_DSKWR); + asm volatile ("movew ccr,%0": "=d" (ret)); + return (!(ret & 0x4)); +} + +#ifdef NOTYET +mvmeprom_diskcfig() {} +mvmeprom_diskfmt(){} +mvmeprom_diskctrl(){} +#endif + +/* BUG - timing routine */ +void +mvmeprom_delay(msec) + int msec; +{ + asm volatile ("movel %0,sp@-" : :"d" (msec)); + MVMEPROM_CALL(MVMEPROM_DELAY); +} + +/* BUG - return to bug routine */ +void +mvmeprom_return() +{ + MVMEPROM_CALL(MVMEPROM_EXIT); + /*NOTREACHED*/ +} + +/* BUG - query board routines */ +struct mvmeprom_brdid * +mvmeprom_getbrdid() +{ + struct mvmeprom_brdid *id; + + asm volatile ("clrl sp@-"); + MVMEPROM_CALL(MVMEPROM_GETBRDID); + asm volatile ("movel sp@+,%0": "=d" (id):); + return (id); +} + +void +mvmeprom_rtc_rd(ptime) + struct mvmeprom_time *ptime; +{ + asm volatile ("movel %0,sp@-" : :"a" (ptime)); + MVMEPROM_CALL(MVMEPROM_RTC_RD); +} diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/clock.c b/sys/arch/mvme88k/stand/openbsd/libsa/clock.c new file mode 100644 index 00000000000..683bd48f849 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/clock.c @@ -0,0 +1,79 @@ +#include <sys/types.h> + +#include "clockreg.h" +#include "config.h" +#include "clock.h" + +/* + * BCD to decimal and decimal to BCD. + */ +#define FROMBCD(x) (((x) >> 4) * 10 + ((x) & 0xf)) +#define TOBCD(x) (((x) / 10 * 16) + ((x) % 10)) + +#define SECDAY (24 * 60 * 60) +#define SECYR (SECDAY * 365) +#define LEAPYEAR(y) (((y) & 3) == 0) + +/* + * This code is defunct after 2068. + * Will Unix still be here then?? + */ +const short dayyr[12] = +{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; + +static u_long +chiptotime(sec, min, hour, day, mon, year) + register int sec, min, hour, day, mon, year; +{ + register int days, yr; + + sec = FROMBCD(sec); + min = FROMBCD(min); + hour = FROMBCD(hour); + day = FROMBCD(day); + mon = FROMBCD(mon); + year = FROMBCD(year) + YEAR0; + if (year < 70) + year = 70; + + /* simple sanity checks */ + if (year < 70 || mon < 1 || mon > 12 || day < 1 || day > 31) + return (0); + days = 0; + for (yr = 70; yr < year; yr++) + days += LEAPYEAR(yr) ? 366 : 365; + days += dayyr[mon - 1] + day - 1; + if (LEAPYEAR(yr) && mon > 2) + days++; + /* now have days since Jan 1, 1970; the rest is easy... */ + return (days * SECDAY + hour * 3600 + min * 60 + sec); +} + +time_t +getsecs() +{ + extern int cputyp; + register struct clockreg *cl; + int sec, min, hour, day, mon, year; + + if (cputyp == CPU_147) + cl = (struct clockreg *) CLOCK_ADDR_147; + else + cl = (struct clockreg *) CLOCK_ADDR_16x; + + cl->cl_csr |= CLK_READ; /* enable read (stop time) */ + sec = cl->cl_sec; + min = cl->cl_min; + hour = cl->cl_hour; + day = cl->cl_mday; + mon = cl->cl_month; + year = cl->cl_year; + cl->cl_csr &= ~CLK_READ;/* time wears on */ + return (chiptotime(sec, min, hour, day, mon, year)); +} + +int +getticks() +{ + return getsecs() * 100; +} diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/clock.h b/sys/arch/mvme88k/stand/openbsd/libsa/clock.h new file mode 100644 index 00000000000..d61bc9b03b8 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/clock.h @@ -0,0 +1,6 @@ + +extern int hz; + +time_t getsecs(); +int getticks(); + diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/clockreg.h b/sys/arch/mvme88k/stand/openbsd/libsa/clockreg.h new file mode 100644 index 00000000000..599f681d715 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/clockreg.h @@ -0,0 +1,71 @@ +/* $Id: clockreg.h,v 1.1 1997/03/03 19:31:06 rahnds Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Lawrence Berkeley Laboratory. + * + * 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 University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)clockreg.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * Mostek MK48T02 clock. + */ +struct clockreg { + volatile u_char cl_csr; /* control register */ + volatile u_char cl_sec; /* seconds (0..59; BCD) */ + volatile u_char cl_min; /* minutes (0..59; BCD) */ + volatile u_char cl_hour;/* hour (0..23; BCD) */ + volatile u_char cl_wday;/* weekday (1..7) */ + volatile u_char cl_mday;/* day in month (1..31; BCD) */ + volatile u_char cl_month; /* month (1..12; BCD) */ + volatile u_char cl_year;/* year (0..99; BCD) */ +}; +/* bits in cl_csr */ +#define CLK_WRITE 0x80 /* want to write */ +#define CLK_READ 0x40 /* want to read (freeze clock) */ + +/* + * Sun chose the year `68' as their base count, so that + * cl_year==0 means 1968. + */ +#define YEAR0 68 + +#define CLOCK_ADDR_147 (0xfffe07f8) /* PA of clock */ +#define CLOCK_ADDR_16x (0xfffc1ff8) /* PA of clock */ diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/config.h b/sys/arch/mvme88k/stand/openbsd/libsa/config.h new file mode 100644 index 00000000000..8d5bedd9c9c --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/config.h @@ -0,0 +1,66 @@ +/* $Id: config.h,v 1.1 1997/03/03 19:31:06 rahnds Exp $ */ + +/* + * Copyright (c) 1995 Theo de Raadt + * 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 Theo de Raadt + * 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. + */ + +/* configuration information for base-line code */ + +#define ETHER_ADDR_147 (0xfffe0778) +#define ETHER_ADDR_16X (0xfffc0000+7980) +#define ERAM_ADDR (0xfffe0774) +#define LANCE_REG_ADDR (0xfffe1800) +#define INTEL_REG_ADDR (0xfff46000) + +#define CPU_147 0x147 +#define CPU_162 0x162 +#define CPU_167 0x167 +#define CPU_172 0x172 +#define CPU_177 0x177 + +struct brdid { + u_long eye_catcher; + u_char rev; + u_char month; + u_char day; + u_char year; + u_short size; + u_short rsv1; + u_short model; + u_short suffix; + u_short options; + u_char family; + u_char cpu; + u_short ctrlun; + u_short devlun; + u_short devtype; + u_short devnum; + u_long bug; +}; diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/dev_disk.c b/sys/arch/mvme88k/stand/openbsd/libsa/dev_disk.c new file mode 100644 index 00000000000..e7b1db4a478 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/dev_disk.c @@ -0,0 +1,132 @@ +/* $Id: dev_disk.c,v 1.1 1997/03/03 19:31:06 rahnds 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. + */ + +/* + * This module implements a "raw device" interface suitable for + * use by the stand-alone I/O library UFS file-system code, and + * possibly for direct access (i.e. boot from tape). + * + * The implementation is deceptively simple because it uses the + * drivers provided by the Sun PROM monitor. Note that only the + * PROM driver used to load the boot program is available here. + */ + +#include <sys/types.h> +#include <machine/mon.h> +#include <machine/saio.h> + +#include "stand.h" + +#include "dvma.h" +#include "promdev.h" + +int +disk_open(f, devname) + struct open_file *f; + char *devname; /* Device part of file name (or NULL). */ +{ + struct saioreq *sip; + int error; + +#ifdef DEBUG_PROM + printf("disk_open: %s\n", devname); +#endif + + if ((error = prom_iopen(&sip)) != 0) + return (error); + + f->f_devdata = sip; + return 0; +} + +int +disk_close(f) + struct open_file *f; +{ + struct saioreq *sip; + + sip = f->f_devdata; + prom_iclose(sip); + f->f_devdata = NULL; + return 0; +} + +int +disk_strategy(devdata, flag, dblk, size, buf, rsize) + void *devdata; + int flag; + daddr_t dblk; + u_int size; + char *buf; + u_int *rsize; +{ + struct saioreq *si; + struct boottab *ops; + char *dmabuf; + int si_flag, xcnt; + + si = devdata; + ops = si->si_boottab; + +#ifdef DEBUG_PROM + printf("disk_strategy: size=%d dblk=%d\n", size, dblk); +#else + twiddle(); +#endif + + dmabuf = dvma_mapin(buf, size); + + si->si_bn = dblk; + si->si_ma = dmabuf; + si->si_cc = size; + + si_flag = (flag == F_READ) ? SAIO_F_READ : SAIO_F_WRITE; + xcnt = (*ops->b_strategy)(si, si_flag); + dvma_mapout(dmabuf, size); + +#ifdef DEBUG_PROM + printf("disk_strategy: xcnt = %x\n", xcnt); +#endif + + if (xcnt <= 0) + return (EIO); + + *rsize = xcnt; + return (0); +} + +int +disk_ioctl() +{ + return EIO; +} + diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/dev_disk.h b/sys/arch/mvme88k/stand/openbsd/libsa/dev_disk.h new file mode 100644 index 00000000000..9f05f74bd82 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/dev_disk.h @@ -0,0 +1,6 @@ + +int disk_open __P((struct open_file *, ...)); +int disk_close __P((struct open_file *)); +int disk_strategy __P((void *, int, daddr_t, u_int, char *, u_int *)); +int disk_ioctl(); + diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/devopen.c b/sys/arch/mvme88k/stand/openbsd/libsa/devopen.c new file mode 100644 index 00000000000..92c083983cb --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/devopen.c @@ -0,0 +1,32 @@ + +#include <sys/param.h> +#include <stand.h> +#include "promboot.h" + +/* + * Open the device named by the combined device/file name + * given as the "fname" arg, something like: "sd()bsd" + * + * However, Sun PROMs don't really let you choose which + * device you will talk to. You can only open the device + * that was used to load the boot program. Therefore, we + * do not accept a "device" part in the "fname" string. + * Pass the PROM device name to open in case it needs it. + */ +int +devopen(f, fname, file) + struct open_file *f; + const char *fname; + char **file; +{ + struct devsw *dp; + char *cp, *path, *devname; + int error; + + *file = (char*)fname; + dp = &devsw[0]; + f->f_dev = dp; + error = (*dp->dv_open)(f, prom_bootdev); + + return (error); +} diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/dvma.c b/sys/arch/mvme88k/stand/openbsd/libsa/dvma.c new file mode 100644 index 00000000000..11526106c2a --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/dvma.c @@ -0,0 +1,68 @@ + +/* + * The easiest way to deal with the need for DVMA mappings is + * to just map the first four megabytes of RAM into DVMA space. + * That way, dvma_mapin can just compute the DVMA alias address, + * and dvma_mapout does nothing. + */ + +#include <sys/param.h> + +#define DVMA_BASE 0x00000000 +#define DVMA_MASK 0x00ffFFff +#define DVMA_MAPLEN 0x400000 /* 4 MB */ + +void +dvma_init() +{ +#if 0 + int segva, sme; + + for (segva = 0; segva < DVMA_MAPLEN; segva += NBSG) { + sme = get_segmap(segva); + set_segmap((DVMA_BASE | segva), sme); + } +#endif +} + +/* Convert a local address to a DVMA address. */ +char * +dvma_mapin(char *addr, int len) +{ + int va = (int)addr; + + va |= DVMA_BASE; + return ((char *) va); +} + +/* Convert a DVMA address to a local address. */ +char * +dvma_mapout(char *dmabuf, int len) +{ + if (dmabuf < (char*)DVMA_BASE) + panic("dvma_mapout"); + return (dmabuf - DVMA_BASE); +} + +extern char *alloc(int len); +char * +dvma_alloc(int len) +{ + char *mem; + + mem = alloc(len); + if (!mem) + return(mem); + return(dvma_mapin(mem, len)); +} + +extern void free(void *ptr, int len); +void +dvma_free(char *dvma, int len) +{ + char *mem; + + mem = dvma_mapout(dvma, len); + if (mem) + free(mem, len); +} diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/dvma.h b/sys/arch/mvme88k/stand/openbsd/libsa/dvma.h new file mode 100644 index 00000000000..2b8be37cbe0 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/dvma.h @@ -0,0 +1,6 @@ + +char * dvma_mapin(char *pkt, int len); +void dvma_mapout(char *dmabuf, int len); + +char * dvma_alloc(int len); + diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/exec_sun.c b/sys/arch/mvme88k/stand/openbsd/libsa/exec_sun.c new file mode 100644 index 00000000000..ecca8fd307a --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/exec_sun.c @@ -0,0 +1,212 @@ +/* $Id: exec_sun.c,v 1.1 1997/03/03 19:31:07 rahnds Exp $ */ + +/*- + * Copyright (c) 1995 Theo de Raadt + * 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 Theo de Raadt + * 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. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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 <a.out.h> + +#include "stand.h" + +extern int debug; + +extern u_int bootdev; + +/*ARGSUSED*/ +exec_sun(file, loadaddr, howto) + char *file; + char *loadaddr; + int howto; +{ + register int io; + struct exec x; + int cc, magic; + void (*entry)(); + register char *cp; + register int *ip; + int textlen; + +#ifdef DEBUG + printf("exec_sun: file=%s loadaddr=0x%x\n", file, loadaddr); +#endif + + io = open(file, 0); + if (io < 0) + return(-1); + + /* + * Read in the exec header, and validate it. + */ + if (read(io, (char *)&x, sizeof(x)) != sizeof(x)) + goto shread; + if (N_BADMAG(x)) { + errno = EFTYPE; + goto closeout; + } + + cp = loadaddr; + textlen = x.a_text; + magic = N_GETMAGIC(x); + if (magic == ZMAGIC) { + cp += sizeof(x); + textlen -= sizeof(x); + } + entry = (void (*)())cp; + + /* + * Leave a copy of the exec header before the text. + * The sun3 kernel uses this to verify that the + * symbols were loaded by this boot program. + */ + bcopy(&x, cp - sizeof(x), sizeof(x)); + + /* + * Read in the text segment. + */ + printf("%x", x.a_text); + if (read(io, cp, textlen) != textlen) + goto shread; + cp += textlen; + + /* + * NMAGIC may have a gap between text and data. + */ + if (magic == NMAGIC) { + register int mask = N_PAGSIZ(x) - 1; + while ((int)cp & mask) + *cp++ = 0; + } + + /* + * Read in the data segment. + */ + printf("+%x", x.a_data); + if (read(io, cp, x.a_data) != x.a_data) + goto shread; + cp += x.a_data; + + /* + * Zero out the BSS section. + * (Kernel does not do it itself) + */ + printf("+%x", x.a_bss); + cc = x.a_bss; + while ((int)cp & 3) { + *cp++ = 0; + --cc; + } + ip = (int *)cp; + cp += cc; + while ((char *)ip < cp) + *ip++ = 0; + + /* + * Read in the symbol table and strings. + * (Always set the symtab size word.) + */ + *ip++ = x.a_syms; + cp = (char *)ip; + + if (x.a_syms > 0) { + + /* Symbol table and string table length word. */ + cc = x.a_syms; + printf("+[%x", cc); + cc += sizeof(int); /* strtab length too */ + if (read(io, cp, cc) != cc) + goto shread; + cp += x.a_syms; + ip = (int *)cp; /* points to strtab length */ + cp += sizeof(int); + + /* String table. Length word includes itself. */ + cc = *ip; + printf("+%x]", cc); + cc -= sizeof(int); + if (cc <= 0) + goto shread; + if (read(io, cp, cc) != cc) + goto shread; + cp += cc; + } + printf("=%x\n", cp - loadaddr); + close(io); + + if (debug) { + printf("Debug mode - enter c to continue\n"); + asm(" trap #0"); + } + + printf("Starting program at 0x%x\n", (int)entry); + (*entry)(howto, bootdev, cp, 0, 0); + panic("exec returned"); + +shread: + printf("exec: short read\n"); + errno = EIO; +closeout: + close(io); + return(-1); +} diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/gets.c b/sys/arch/mvme88k/stand/openbsd/libsa/gets.c new file mode 100644 index 00000000000..11a42b29b87 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/gets.c @@ -0,0 +1,141 @@ +/* $Id: gets.c,v 1.1 1997/03/03 19:31:07 rahnds Exp $ */ + +/*- + * Copyright (c) 1995 Theo de Raadt + * 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 Theo de Raadt + * 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. + * + * Copyright (c) 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)gets.c 8.1 (Berkeley) 6/11/93 + */ + +#include "stand.h" + +/* + * This implementation assumes that getchar() does echo, because + * on some machines, it is hard to keep echo from being done. + * Those that need it can do echo in their getchar() function. + * + * Yes, the code below will echo CR, DEL, and other control chars, + * but sending CR or DEL here is harmless. All the other editing + * characters will be followed by a newline, so it doesn't matter. + * (Most terminals will not show them anyway.) + */ + +void +gets(buf) + char *buf; +{ + register int c; + register char *lp; + +top: + lp = buf; + + for (;;) { + c = getchar() & 0177; + + putchar(c); + + switch (c) { + + default: + *lp++ = c; + continue; + + case '\177': + putchar('\b'); + /* fall through */ + case '\b': + putchar(' '); + putchar('\b'); + /* fall through */ + case '#': + if (lp > buf) + lp--; + continue; + + /* + * This is not very useful in a boot program. + * (It costs you 52 bytes on m68k, gcc -O3). + */ + case 'r'&037: { + register char *p; + putchar('\n'); + for (p = buf; p < lp; ++p) + putchar(*p); + continue; + } + + case '@': + case 'u'&037: + case 'w'&037: + putchar('\n'); + goto top; + + case '\r': + putchar('\n'); + /* fall through */ + case '\n': + *lp = '\0'; + return; + + } /* switch */ + } + /*NOTREACHED*/ +} diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/log1 b/sys/arch/mvme88k/stand/openbsd/libsa/log1 new file mode 100644 index 00000000000..17047779eef --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/log1 @@ -0,0 +1,130 @@ +nfs.o nfs.o +rpc.o rpc.o +net.o net.o +ether.o ether.o +arp.o arp.o +in_cksum.o in_cksum.o +netif.o netif.o +bootparam.o bootparam.o +rarp.o rarp.o +alloc.o alloc.o +bcopy.o bcopy.o +memcpy.o memcpy.o +close.o close.o +getfile.o getfile.o +open.o open.o +printf.o printf.o +read.o read.o +strerror.o strerror.o +ufs.o ufs.o +globals.o globals.o +lseek.o lseek.o +closeall.o closeall.o +dev.o dev.o +dkcksum.o dkcksum.o +nullfs.o nullfs.o +fstat.o fstat.o +ashrdi3.o ashrdi3.o +bcmp.o bcmp.o +bzero.o bzero.o +strcmp.o strcmp.o +strlen.o strlen.o +exec_sun.o exec_sun.o +clock.o clock.o +devopen.o devopen.o +dvma.o dvma.o +gets.o gets.o +panic.o panic.o +promboot.o promboot.o +promcons.o promcons.o +ufs.o ashrdi3.o +dvma.o alloc.o +nfs.o alloc.o +ufs.o alloc.o +net.o arp.o +net.o arp.o +arp.o globals.o +ether.o globals.o +rarp.o globals.o +arp.o bcmp.o +ether.o bcmp.o +rarp.o bcmp.o +arp.o bcopy.o +bootparam.o bcopy.o +ether.o bcopy.o +exec_sun.o bcopy.o +memcpy.o bcopy.o +net.o bcopy.o +nfs.o bcopy.o +rarp.o bcopy.o +ufs.o bcopy.o +arp.o bzero.o +net.o bzero.o +netif.o bzero.o +nfs.o bzero.o +rarp.o bzero.o +rpc.o bzero.o +ufs.o bzero.o +closeall.o close.o +exec_sun.o close.o +open.o devopen.o +dvma.o alloc.o +nfs.o alloc.o +ufs.o alloc.o +gets.o promcons.o +getfile.o gets.o +net.o clock.o +net.o in_cksum.o +arp.o net.o +ether.o netif.o +ether.o netif.o +net.o globals.o +rarp.o globals.o +exec_sun.o open.o +getfile.o open.o +arp.o panic.o +exec_sun.o panic.o +net.o panic.o +netif.o panic.o +arp.o printf.o +bootparam.o printf.o +exec_sun.o printf.o +getfile.o printf.o +net.o printf.o +netif.o printf.o +nfs.o printf.o +panic.o printf.o +rarp.o printf.o +rpc.o printf.o +gets.o promcons.o +printf.o promcons.o +exec_sun.o read.o +arp.o ether.o +net.o ether.o +rarp.o ether.o +rpc.o net.o +bootparam.o rpc.o +nfs.o rpc.o +bootparam.o rpc.o +bootparam.o rpc.o +bootparam.o rpc.o +nfs.o rpc.o +arp.o ether.o +net.o ether.o +rarp.o ether.o +arp.o net.o +rarp.o net.o +rpc.o net.o +rpc.o net.o +bootparam.o netif.o +nfs.o netif.o +rarp.o netif.o +strerror.o printf.o +ufs.o strcmp.o +rpc.o strerror.o +bootparam.o strlen.o +nfs.o strlen.o +ufs.o strlen.o +nfs.o printf.o +read.o printf.o +ufs.o printf.o diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/log2 b/sys/arch/mvme88k/stand/openbsd/libsa/log2 new file mode 100644 index 00000000000..31ecde33da0 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/log2 @@ -0,0 +1,39 @@ +promboot.o +dvma.o +exec_sun.o +fstat.o +nullfs.o +dkcksum.o +dev.o +closeall.o +lseek.o +ufs.o +read.o +getfile.o +close.o +memcpy.o +rarp.o +bootparam.o +nfs.o +gets.o +strlen.o +strcmp.o +ashrdi3.o +open.o +alloc.o +rpc.o +devopen.o +strerror.o +arp.o +net.o +clock.o +in_cksum.o +ether.o +bcmp.o +globals.o +bcopy.o +netif.o +panic.o +bzero.o +printf.o +promcons.o diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/netif_sun.c b/sys/arch/mvme88k/stand/openbsd/libsa/netif_sun.c new file mode 100644 index 00000000000..20959d34f0b --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/netif_sun.c @@ -0,0 +1,284 @@ +/* $Id: netif_sun.c,v 1.1 1997/03/03 19:31:07 rahnds Exp $ */ + +/* + * Copyright (c) 1995 Gordon W. Ross + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * 4. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Gordon W. Ross + * + * 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. + */ + +/* + * The Sun PROM has a fairly general set of network drivers, + * so it is easiest to just replace the netif module with + * this adaptation to the PROM network interface. + */ + +#include <sys/param.h> +#include <sys/socket.h> +#include <string.h> +#include <time.h> + +#include <net/if.h> + +#include <netinet/in.h> +#include <netinet/if_ether.h> +#include <netinet/in_systm.h> + +#include <machine/control.h> +#include <machine/idprom.h> +#include <machine/mon.h> +#include <machine/saio.h> + +#include "stand.h" +#include "net.h" +#include "netif.h" + +#include "clock.h" +#include "dvma.h" +#include "promdev.h" + +static struct netif netif_prom; + +#ifdef NETIF_DEBUG +int netif_debug; +#endif + +struct iodesc sockets[SOPEN_MAX]; + +struct iodesc * +socktodesc(sock) + int sock; +{ + if (sock != 0) { + return(NULL); + } + return (sockets); +} + +int +netif_open(machdep_hint) + void *machdep_hint; +{ + struct saioreq *si; + struct iodesc *io; + int fd, error; + + /* find a free socket */ + io = sockets; + if (io->io_netif) { +#ifdef DEBUG + printf("netif_open: device busy\n"); +#endif + return (-1); + } + bzero(io, sizeof(*io)); + + /* + * Note: Sun PROMs will do RARP on open, but does not tell + * you the IP address it gets, so it is just noise to us... + */ + if ((error = prom_iopen(&si)) != 0) { +#ifdef DEBUG + printf("netif_open: prom_iopen, error=%d\n", error); +#endif + return (-1); + } + if (si->si_sif == NULL) { +#ifdef DEBUG + printf("netif_open: not a network device\n"); +#endif + prom_iclose(si); + return (-1); + } + + netif_prom.devdata = si; + io->io_netif = &netif_prom; + + /* Put our ethernet address in io->myea */ + sun3_getether(io->myea); + + return(0); +} + +int +netif_close(fd) + int fd; +{ + struct iodesc *io; + struct netif *ni; + + if (fd != 0) { + errno = EBADF; + return(-1); + } + + io = sockets; + ni = io->io_netif; + if (ni != NULL) { + prom_iclose(ni->devdata); + ni->devdata = NULL; + io->io_netif = NULL; + } + return(0); +} + +/* + * Send a packet. The ether header is already there. + * Return the length sent (or -1 on error). + */ +int +netif_put(desc, pkt, len) + struct iodesc *desc; + void *pkt; + int len; +{ + struct saioreq *si; + struct saif *sif; + char *dmabuf; + int rv, sendlen; + +#ifdef NETIF_DEBUG + if (netif_debug) { + struct ether_header *eh; + + printf("netif_put: desc=0x%x pkt=0x%x len=%d\n", + desc, pkt, len); + eh = pkt; + printf("dst: %s ", ether_sprintf(eh->ether_dhost)); + printf("src: %s ", ether_sprintf(eh->ether_shost)); + printf("type: 0x%x\n", eh->ether_type & 0xFFFF); + } +#endif + + si = desc->io_netif->devdata; + sif = si->si_sif; + sendlen = len; + if (sendlen < 60) { + sendlen = 60; +#ifdef NETIF_DEBUG + printf("netif_put: length padded to %d\n", sendlen); +#endif + } + +#ifdef PARANOID + if (sif == NULL) + panic("netif_put: no saif ptr\n"); +#endif + + dmabuf = dvma_mapin(pkt, sendlen); + rv = sif->sif_xmit(si->si_devdata, dmabuf, sendlen); + dvma_mapout(dmabuf, sendlen); + +#ifdef NETIF_DEBUG + if (netif_debug) + printf("netif_put: xmit returned %d\n", rv); +#endif + if (rv == 0) rv = len; + else rv = -1; + + return rv; +} + +/* + * Receive a packet, including the ether header. + * Return the total length received (or -1 on error). + */ +int +netif_get(desc, pkt, maxlen, timo) + struct iodesc *desc; + void *pkt; + int maxlen; + time_t timo; +{ + struct saioreq *si; + struct saif *sif; + char *dmabuf; + int tick0, tmo_ticks; + int len; + +#ifdef NETIF_DEBUG + if (netif_debug) + printf("netif_get: pkt=0x%x, maxlen=%d, tmo=%d\n", + pkt, maxlen, timo); +#endif + + si = desc->io_netif->devdata; + sif = si->si_sif; + +#ifdef PARANOID + if (sif == NULL) + panic("netif_get: no saif ptr\n"); +#endif + + tmo_ticks = timo * hz; + tick0 = getticks(); + + dmabuf = dvma_mapin(pkt, maxlen); + do len = sif->sif_poll(si->si_devdata, dmabuf); + while ((len == 0) && ((getticks() - tick0) < tmo_ticks)); + dvma_mapout(dmabuf, maxlen); + +#ifdef NETIF_DEBUG + if (netif_debug) + printf("netif_get: received len=%d\n", len); +#endif + + if (len < 12) + return -1; + +#ifdef NETIF_DEBUG + if (netif_debug) { + struct ether_header *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 + + return len; +} + +static struct idprom sun3_idprom; + +sun3_getether(ea) + u_char *ea; +{ + u_char *src, *dst; + int len, x; + + if (sun3_idprom.idp_format == 0) { + dst = (char*)&sun3_idprom; + src = (char*)IDPROM_BASE; + len = IDPROM_SIZE; + do { + x = get_control_byte(src++); + *dst++ = x; + } while (--len > 0); + } + MACPY(sun3_idprom.idp_etheraddr, ea); +} + diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/panic.c b/sys/arch/mvme88k/stand/openbsd/libsa/panic.c new file mode 100644 index 00000000000..f7c83a6d8e7 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/panic.c @@ -0,0 +1,31 @@ + +#include <stdarg.h> +#include "stand.h" + +extern volatile void abort(); +extern int _estack[]; + +__dead void +panic(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + printf(fmt, ap); + printf("\n"); + va_end(ap); + stackdump(0); + abort(); +} + +stackdump(dummy) + int dummy; +{ + int *ip; + + printf("stackdump:\n"); + for (ip = &dummy; ip < _estack; ip += 4) { + printf("%x: %x %x %x %x\n", + (int)ip, ip[0], ip[1], ip[2], ip[3]); + } +} diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/promboot.c b/sys/arch/mvme88k/stand/openbsd/libsa/promboot.c new file mode 100644 index 00000000000..13c6206ca7f --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/promboot.c @@ -0,0 +1,93 @@ +/* $Id: promboot.c,v 1.1 1997/03/03 19:31:07 rahnds Exp $ */ + +/* + * Copyright (c) 1995 Theo de Raadt + * 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 Theo de Raadt + * 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 <sys/reboot.h> +#include "stand.h" +#include "promboot.h" + +char prom_bootdev[32]; +char prom_bootfile[32]; +int prom_boothow; +int debug; + +void +prom_get_boot_info() +{ + char c, *src, *dst; + extern int devlun, ctrlun; + extern char *oparg, *opargend; + +#ifdef DEBUG + printf("prom_get_boot_info\n"); +#endif + + /* Get kernel filename */ + src = oparg; + while (src && (*src == ' ' || *src == '\t')) + src++; + + dst = prom_bootfile; + if (src && *src != '-') { + while (src && *src) { + if (*src == ' ' || *src == '\t') + break; + *dst++ = *src++; + } + } + *dst = '\0'; + + /* Get boothowto flags */ + while (src && (*src == ' ' || *src == '\t')) + src++; + if (src && (*src == '-')) { + while (*src) { + switch (*src++) { + case 'a': + prom_boothow |= RB_ASKNAME; + break; + case 's': + prom_boothow |= RB_SINGLE; + break; + case 'd': + prom_boothow |= RB_KDB; + debug = 1; + break; + } + } + } +#ifdef DEBUG + printf("promboot: device=\"%s\" file=\"%s\" how=0x%x\n", + prom_bootdev, prom_bootfile, prom_boothow); +#endif +} diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/promboot.h b/sys/arch/mvme88k/stand/openbsd/libsa/promboot.h new file mode 100644 index 00000000000..86b5aace21c --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/promboot.h @@ -0,0 +1,5 @@ + +extern char prom_bootdev[]; +extern char prom_bootfile[]; +extern int prom_boothow; + diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/promcons.c b/sys/arch/mvme88k/stand/openbsd/libsa/promcons.c new file mode 100644 index 00000000000..4fdb3d69e1f --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/promcons.c @@ -0,0 +1,62 @@ +/* $Id: promcons.c,v 1.1 1997/03/03 19:31:07 rahnds Exp $ */ + +/* + * Copyright (c) 1995 Theo de Raadt + * 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 Theo de Raadt + * 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 <stdarg.h> +#include <sys/types.h> + +int +getchar() +{ + char c; + + __asm("movb #0,sp@-; trap #15; .short 0x0; movb sp@+, %0" : : "d" (c)); + return (c); +} + +peekchar() +{ + int have = 0; + + __asm("trap #15; .short 0x1; beq 1f; movl #1, %0\n1:" : : "d" (have)); + return (have); +} + +void +putchar(c) + int c; +{ + if (c == '\n') + putchar('\r'); + __asm("movb %0,sp@-; trap #15; .short 0x20" : : "d" (c)); +} + diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/promdev.c b/sys/arch/mvme88k/stand/openbsd/libsa/promdev.c new file mode 100644 index 00000000000..a8a9e6aa9dd --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/promdev.c @@ -0,0 +1,193 @@ +/* $Id: promdev.c,v 1.1 1997/03/03 19:31:07 rahnds Exp $ */ + +/* + * Copyright (c) 1995 Gordon W. Ross + * 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/mon.h> +#include <machine/pte.h> +#include <machine/saio.h> + +#include <dvma.h> +#include <stand.h> + +struct saioreq prom_si; +static int promdev_inuse; + +static char * +prom_mapin(u_long physaddr, int length, int maptype); + +int +prom_iopen(void **devdatap) +{ + struct bootparam *bp; + struct boottab *ops; + struct devinfo *dip; + struct saioreq *si; + char *p; + int error; + + if (promdev_inuse) + return(EMFILE); + + bp = *romp->bootParam; + ops = bp->bootDevice; + dip = ops->b_devinfo; + +#ifdef DEBUG_PROM + printf("Boot device type: %s\n", ops->b_desc); +#endif + + dvma_init(); + + si = &prom_si; + bzero((caddr_t)si, sizeof(*si)); + si->si_boottab = ops; + si->si_ctlr = bp->ctlrNum; + si->si_unit = bp->unitNum; + si->si_boff = bp->partNum; + + if (si->si_ctlr > dip->d_stdcount) { + printf("Invalid controller number\n"); + return(ENXIO); + } + + if (dip->d_devbytes) { + si->si_devaddr = prom_mapin(dip->d_stdaddrs[si->si_ctlr], + dip->d_devbytes, dip->d_devtype); +#ifdef DEBUG_PROM + printf("prom_iopen: devaddr=0x%x pte=0x%x\n", + si->si_devaddr, get_pte(si->si_devaddr)); +#endif + } + + if (dip->d_dmabytes) { + si->si_dmaaddr = dvma_alloc(dip->d_dmabytes); +#ifdef DEBUG_PROM + printf("prom_iopen: dmaaddr=0x%x\n", si->si_dmaaddr); +#endif + } + + /* OK, call the PROM device open routine. */ + error = (*ops->b_open)(si); + if (error != 0) { + printf("prom_iopen: \"%s\" error=%d\n", + ops->b_desc, error); + return (ENXIO); + } +#ifdef DEBUG_PROM + printf("prom_iopen: succeeded, error=%d\n", error); +#endif + + *devdatap = si; + promdev_inuse++; + return (0); +} + +void +prom_iclose(void *devdata) +{ + struct boottab *ops; + struct devinfo *dip; + struct saioreq *si; + + if (promdev_inuse == 0) + return; + + si = devdata; + ops = si->si_boottab; + dip = ops->b_devinfo; + + (*ops->b_close)(si); + + if (si->si_dmaaddr) { + dvma_free(si->si_dmaaddr, dip->d_dmabytes); + si->si_dmaaddr = NULL; + } + + promdev_inuse = 0; +} + +struct mapinfo { + int maptype; + int pgtype; + int base; +}; + +static struct mapinfo +prom_mapinfo[] = { + { MAP_MAINMEM, PGT_OBMEM, 0 }, + { MAP_OBIO, PGT_OBIO, 0 }, + { MAP_MBMEM, PGT_OBMEM, 0 }, /* XXX - Sun2 Multibus? */ + { MAP_MBIO, PGT_OBIO, 0 }, /* XXX - Sun2 Multibus? */ + { MAP_VME16A16D, PGT_VME_D16, 0xFFFF0000 }, + { MAP_VME16A32D, PGT_VME_D32, 0xFFFF0000 }, + { MAP_VME24A16D, PGT_VME_D16, 0xFF000000 }, + { MAP_VME24A32D, PGT_VME_D32, 0xFF000000 }, + { MAP_VME32A16D, PGT_VME_D16, 0 }, + { MAP_VME32A32D, PGT_VME_D32, 0 }, +}; +static prom_mapinfo_cnt = sizeof(prom_mapinfo) / sizeof(prom_mapinfo[0]); + +/* The virtual address we will use for PROM device mappings. */ +static int prom_devmap = MONSHORTSEG; + +static char * +prom_mapin(physaddr, length, maptype) + u_long physaddr; + int length, maptype; +{ + int i, pa, pte, va; + + if (length > (4*NBPG)) + panic("prom_mapin: length=%d\n", length); + + for (i = 0; i < prom_mapinfo_cnt; i++) + if (prom_mapinfo[i].maptype == maptype) + goto found; + panic("prom_mapin: invalid maptype %d\n", maptype); +found: + + pte = prom_mapinfo[i].pgtype; + pte |= PG_PERM; + pa = prom_mapinfo[i].base; + pa += physaddr; + pte |= PA_PGNUM(pa); + + va = prom_devmap; + do { + set_pte(va, pte); + va += NBPG; + pte += 1; + length -= NBPG; + } while (length > 0); + return ((char*)prom_devmap); +} diff --git a/sys/arch/mvme88k/stand/openbsd/libsa/promdev.h b/sys/arch/mvme88k/stand/openbsd/libsa/promdev.h new file mode 100644 index 00000000000..e3ae5ba2d7c --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/libsa/promdev.h @@ -0,0 +1,4 @@ + +int prom_iopen(struct saioreq **sipp); +void prom_iclose(struct saioreq *sip); + diff --git a/sys/arch/mvme88k/stand/openbsd/netboot/Makefile b/sys/arch/mvme88k/stand/openbsd/netboot/Makefile new file mode 100644 index 00000000000..97900f2351c --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/netboot/Makefile @@ -0,0 +1,31 @@ +# $Id: Makefile,v 1.1 1997/03/03 19:31:08 rahnds Exp $ + +RELOC=0x3F0000 + +S= ${.CURDIR}/../../../.. +DEFS= -DSTANDALONE -DSUN_BOOTPARAMS +INCPATH=-I${.CURDIR} -I${.CURDIR}/../libsa -I${S} -I${S}/lib/libsa +CFLAGS= -O2 ${INCPATH} ${DEFS} ${COPTS} + +.include "${S}/arch/${MACHINE}/stand/libsa/Makefile.inc" +.PATH: ${S}/arch/${MACHINE}/stand/libsa +SRTOBJ= SRT0.o SRT1.o + +SRCS= boot.c conf.c version.c dev_net.c +SRCS+= if_ie.c if_le.c +OBJS= ${SRTOBJ} ${SRCS:S/.c/.o/g} + +all: netboot.bin + +netboot: ${OBJS} ${LIBSA} + ${LD} -s -N -T ${RELOC} -e start -o $@ ${OBJS} ${LIBSA} + @size $@ + +netboot.bin: netboot + dd ibs=32 skip=1 if=netboot of=$@ + +install: + install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + netboot.bin ${DESTDIR}${MDEC_DIR}/netboot + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/openbsd/netboot/boot.c b/sys/arch/mvme88k/stand/openbsd/netboot/boot.c new file mode 100644 index 00000000000..4c465af5cd0 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/netboot/boot.c @@ -0,0 +1,119 @@ +/* $Id: boot.c,v 1.1 1997/03/03 19:31:08 rahnds Exp $ */ + +/*- + * Copyright (c) 1995 Theo de Raadt + * 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 Theo de Raadt + * 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. + * + * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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 "stand.h" +#include "promboot.h" + +/* + * Boot device is derived from ROM provided information. + */ +#define LOADADDR 0x10000 + +extern char *version; +char defname[32] = "bsd"; +char line[80]; + +#if 0 +u_int bootdev = MAKEBOOTDEV(0, sdmajor, 0, 0, 0); /* disk boot */ +#endif +u_int bootdev = MAKEBOOTDEV(1, 0, 0, 0, 0); /* network boot */ + +main() +{ + char *cp, *file; + int io; + extern int cputyp; + extern char *oparg, *opargend; + int ask = 0; + + printf(">> OpenBSD netboot [%s]\n", version); + printf("model MVME%x\n", cputyp); + + *opargend = '\0'; + prom_get_boot_info(); + file = defname; + + cp = prom_bootfile; + if (cp && *cp) + file = cp; + + for (;;) { + if (ask) { + printf("boot: "); + gets(line); + if (line[0]) { + oparg = line; + prom_get_boot_info(); + } + } + exec_sun(file, (char *)LOADADDR, prom_boothow); + printf("boot: %s\n", strerror(errno)); + ask = 1; + } +} diff --git a/sys/arch/mvme88k/stand/openbsd/netboot/conf.c b/sys/arch/mvme88k/stand/openbsd/netboot/conf.c new file mode 100644 index 00000000000..5527ccf8f63 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/netboot/conf.c @@ -0,0 +1,34 @@ +/* $Id: conf.c,v 1.1 1997/03/03 19:31:08 rahnds Exp $ */ + +#include <sys/types.h> +#include <netinet/in.h> +#include <netinet/in_systm.h> + +#include <stand.h> +#include <nfs.h> +#include <dev_net.h> + +struct fs_ops file_system[] = { + { nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_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]); + +extern struct netif_driver le_driver; +extern struct netif_driver ie_driver; + +struct netif_driver *netif_drivers[] = { + &le_driver, + &ie_driver, +}; +int n_netif_drivers = sizeof(netif_drivers) / sizeof(netif_drivers[0]); + + +/* XXX */ +int netif_debug; +int debug; +int errno; diff --git a/sys/arch/mvme88k/stand/openbsd/netboot/dev_net.c b/sys/arch/mvme88k/stand/openbsd/netboot/dev_net.c new file mode 100644 index 00000000000..f0490b9dd6a --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/netboot/dev_net.c @@ -0,0 +1,211 @@ +/* $Id: dev_net.c,v 1.1 1997/03/03 19:31:08 rahnds Exp $ */ + +/* + * Copyright (c) 1995 Gordon W. Ross + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * 4. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Gordon W. Ross + * + * 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. + */ + +/* + * This module implements a "raw device" interface suitable for + * use by the stand-alone I/O library NFS code. This interface + * does not support any "block" access, and exists only for the + * purpose of initializing the network interface, getting boot + * parameters, and performing the NFS mount. + * + * At open time, this does: + * + * find interface - netif_open() + * RARP for IP address - rarp_getipaddress() + * RPC/bootparams - callrpc(d, RPC_BOOTPARAMS, ...) + * RPC/mountd - nfs_mount(sock, ip, path) + * + * the root file handle from mountd is saved in a global + * for use by the NFS open code (NFS/lookup). + */ + +#include <sys/param.h> +#include <sys/socket.h> +#include <net/if.h> +#include <netinet/in.h> +#include <netinet/if_ether.h> +#include <netinet/in_systm.h> + +#include "stand.h" +#include "net.h" +#include "netif.h" +#include "config.h" +#include "bootparam.h" + +extern int nfs_root_node[]; /* XXX - get from nfs_mount() */ + +struct in_addr myip, rootip, gateip, mask; +char rootpath[FNAME_SIZE]; + +int netdev_sock = -1; +static int open_count; + +/* + * Called by devopen after it sets f->f_dev to our devsw entry. + * This opens the low-level device and sets f->f_devdata. + */ +int +net_open(f, devname) + struct open_file *f; + char *devname; /* Device part of file name (or NULL). */ +{ + int error = 0; + + /* On first open, do netif open, mount, etc. */ + if (open_count == 0) { + /* Find network interface. */ + if ((netdev_sock = netif_open(devname)) < 0) + return (error=ENXIO); + if ((error = net_mountroot(f, devname)) != 0) + return (error); + } + open_count++; + f->f_devdata = nfs_root_node; + return (error); +} + +int +net_close(f) + struct open_file *f; +{ + /* On last close, do netif close, etc. */ + if (open_count > 0) + if (--open_count == 0) + netif_close(netdev_sock); + f->f_devdata = NULL; +} + +int +net_ioctl() +{ + return EIO; +} + +int +net_strategy() +{ + return EIO; +} + +int +net_mountroot(f, devname) + struct open_file *f; + char *devname; /* Device part of file name (or NULL). */ +{ + int error; + +#ifdef DEBUG + printf("net_mountroot: %s\n", devname); +#endif + + /* + * Get info for NFS boot: our IP address, our hostname, + * server IP address, and our root path on the server. + * There are two ways to do this: The old, Sun way, + * and the more modern, BOOTP way. (RFC951, RFC1048) + */ + +#ifdef SUN_BOOTPARAMS + /* Get boot info using RARP and Sun bootparams. */ + + /* Get our IP address. (rarp.c) */ + if (rarp_getipaddress(netdev_sock) == -1) + return (EIO); + printf("boot: client IP address: %s\n", intoa(myip.s_addr)); + + /* Get our hostname, server IP address. */ + if (bp_whoami(netdev_sock)) + return (EIO); + printf("boot: client name: %s\n", hostname); + + /* Get the root pathname. */ + if (bp_getfile(netdev_sock, "root", &rootip, rootpath)) + return (EIO); + +#else + + /* Get boot info using BOOTP way. (RFC951, RFC1048) */ + bootp(netdev_sock); + + printf("Using IP address: %s\n", intoa(myip.s_addr)); + + printf("myip: %s (%s)", hostname, intoa(myip)); + if (gateip) + printf(", gateip: %s", intoa(gateip)); + if (mask) + printf(", mask: %s", intoa(mask)); + printf("\n"); + +#endif + + printf("root addr=%s path=%s\n", intoa(rootip.s_addr), rootpath); + + /* Get the NFS file handle (mount). */ + error = nfs_mount(netdev_sock, rootip, rootpath); + + return (error); +} + +/* + * machdep_common_ether: get ethernet address + */ +void +machdep_common_ether(ether) + u_char *ether; +{ + u_char *ea; + extern int cputyp; + + if (cputyp == CPU_147) { + ea = (u_char *) ETHER_ADDR_147; + + if ((*(int *) ea & 0x2fffff00) == 0x2fffff00) + panic("ERROR: ethernet address not set!\r\n"); + ether[0] = 0x08; + ether[1] = 0x00; + ether[2] = 0x3e; + ether[3] = ea[0]; + ether[4] = ea[1]; + ether[5] = ea[2]; + } else { + ea = (u_char *) ETHER_ADDR_16X; + + if (ea[0] + ea[1] + ea[2] + ea[3] + ea[4] + ea[5] == 0) + panic("ERROR: ethernet address not set!\r\n"); + ether[0] = ea[0]; + ether[1] = ea[1]; + ether[2] = ea[2]; + ether[3] = ea[3]; + ether[4] = ea[4]; + ether[5] = ea[5]; + } +} diff --git a/sys/arch/mvme88k/stand/openbsd/netboot/dev_net.h b/sys/arch/mvme88k/stand/openbsd/netboot/dev_net.h new file mode 100644 index 00000000000..093ba193bfd --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/netboot/dev_net.h @@ -0,0 +1,6 @@ + +int net_open __P((struct open_file *, ...)); +int net_close __P((struct open_file *)); +int net_ioctl(); +int net_strategy(); + diff --git a/sys/arch/mvme88k/stand/openbsd/netboot/i82586.h b/sys/arch/mvme88k/stand/openbsd/netboot/i82586.h new file mode 100644 index 00000000000..3275601ee25 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/netboot/i82586.h @@ -0,0 +1,306 @@ +/* $Id: i82586.h,v 1.1 1997/03/03 19:31:08 rahnds Exp $ */ + +/*- + * Copyright (c) 1995 Theo de Raadt + * Copyright (c) 1992, University of Vermont and State Agricultural College. + * Copyright (c) 1992, Garrett A. Wollman. + * 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 the University of + * Vermont and State Agricultural College and Garrett A. Wollman. + * 4. Neither the name of the University nor the name of the author + * 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 UNIVERSITY OR 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. + */ + +/* + * Intel 82586 Ethernet chip + * Register, bit, and structure definitions. + * + * Written by GAW with reference to the Clarkson Packet Driver code for this + * chip written by Russ Nelson and others. + */ + +struct ie_en_addr { + u_char data[6]; +}; +/* + * the only actual IE registers. + */ +struct iereg { + u_short ie_porthigh; + u_short ie_portlow; + u_long ie_attention; +}; +#define IE_PORT_NEWSCP 0x00000002 +#define IE_PORT_RESET 0x00000000 + +/* + * This is the master configuration block. It tells the hardware where + * all the rest of the stuff is. + */ +struct ie_scp { + u_char mbz1[3]; /* must be zero */ + u_char scp_sysbus; /* true if 8-bit only */ + u_char mbz2[4]; /* must be zero */ + u_short scp_iscp_low; /* 24-bit physaddr of ISCP */ + u_char mbz3[1]; + u_char scp_iscp_high; /* the rest of the physaddr.. */ +}; +/* + * The tells the hardware where all the rest of the stuff is, too. + * FIXME: some of these should be re-commented after we figure out their + * REAL function. + */ +struct ie_iscp { + u_char mbz1[1]; + u_char iscp_busy; /* zeroed after init */ + u_short iscp_scboffset; /* 16-bit physaddr of next struct */ + u_short iscp_base_low; /* 24-bit physaddr for all 16-bit vars */ + u_char mbz2[1]; + u_char iscp_base_high; /* rest of physaddr ... */ +}; +/* + * This FINALLY tells the hardware what to do and where to put it. + */ +struct ie_scb { + u_short ie_status; /* status word */ + u_short ie_command; /* command word */ + u_short ie_command_list;/* 16-pointer to command block list */ + u_short ie_recv_list; /* 16-pointer to receive frame list */ + u_short ie_err_crc; /* CRC errors */ + u_short ie_err_align; /* Alignment errors */ + u_short ie_err_resource;/* Resource errors */ + u_short ie_err_overrun; /* Overrun errors */ +}; +/* Command values */ +#define IE_RU_COMMAND 0x0070 /* mask for RU command */ +#define IE_RU_NOP 0 /* for completeness */ +#define IE_RU_START 0x0010 /* start receive unit command */ +#define IE_RU_ENABLE 0x0020 /* enable receiver command */ +#define IE_RU_DISABLE 0x0030 /* disable receiver command */ +#define IE_RU_ABORT 0x0040 /* abort current receive operation */ + +#define IE_CU_COMMAND 0x0700 /* mask for CU command */ +#define IE_CU_NOP 0 /* included for completeness */ +#define IE_CU_START 0x0100 /* do-command command */ +#define IE_CU_RESUME 0x0200 /* resume a suspended cmd list */ +#define IE_CU_STOP 0x0300 /* SUSPEND was already taken */ +#define IE_CU_ABORT 0x0400 /* abort current command */ + +#define IE_ACK_COMMAND 0xf000 /* mask for ACK command */ +#define IE_ACK_CX 0x8000 /* ack IE_ST_DONE */ +#define IE_ACK_FR 0x4000 /* ack IE_ST_RECV */ +#define IE_ACK_CNA 0x2000 /* ack IE_ST_ALLDONE */ +#define IE_ACK_RNR 0x1000 /* ack IE_ST_RNR */ + +#define IE_ACTION_COMMAND(x) (((x) & IE_CU_COMMAND) == IE_CU_START) + /* is this command an action command? */ + +/* Status values */ +#define IE_ST_WHENCE 0xf000 /* mask for cause of interrupt */ +#define IE_ST_DONE 0x8000 /* command with I bit completed */ +#define IE_ST_RECV 0x4000 /* frame received */ +#define IE_ST_ALLDONE 0x2000 /* all commands completed */ +#define IE_ST_RNR 0x1000 /* receive not ready */ + +#define IE_CU_STATUS 0x700 /* mask for command unit status */ +#define IE_CU_ACTIVE 0x200 /* command unit is active */ +#define IE_CU_SUSPEND 0x100 /* command unit is suspended */ + +#define IE_RU_STATUS 0x70 /* mask for receiver unit status */ +#define IE_RU_SUSPEND 0x10 /* receiver is suspended */ +#define IE_RU_NOSPACE 0x20 /* receiver has no resources */ +#define IE_RU_READY 0x40 /* receiver is ready */ + +/* + * This is filled in partially by the chip, partially by us. + */ +struct ie_recv_frame_desc { + u_short ie_fd_status; /* status for this frame */ + u_short ie_fd_last; /* end of frame list flag */ + u_short ie_fd_next; /* 16-pointer to next RFD */ + u_short ie_fd_buf_desc; /* 16-pointer to list of buffer desc's */ + struct ie_en_addr dest; /* destination ether */ + struct ie_en_addr src; /* source ether */ + u_short ie_length; /* 802 length/Ether type */ + u_short mbz; /* must be zero */ +}; +#define IE_FD_LAST 0x8000 /* last rfd in list */ +#define IE_FD_SUSP 0x4000 /* suspend RU after receipt */ + +#define IE_FD_COMPLETE 0x8000 /* frame is complete */ +#define IE_FD_BUSY 0x4000 /* frame is busy */ +#define IE_FD_OK 0x2000 /* frame is bad */ +#define IE_FD_RNR 0x0200 /* receiver out of resources here */ + +/* + * linked list of buffers... + */ +struct ie_recv_buf_desc { + u_short ie_rbd_actual; /* status for this buffer */ + u_short ie_rbd_next; /* 16-pointer to next RBD */ + u_short ie_rbd_buffer_low; /* 24-pointer to buffer for this RBD */ + u_short ie_rbd_buffer_high; /* 24-pointer to buffer for this RBD */ + u_short ie_rbd_length; /* length of the buffer */ + u_short mbz; /* must be zero */ +}; +#define IE_RBD_LAST 0x8000 /* last buffer */ +#define IE_RBD_USED 0x4000 /* this buffer has data */ +/* + * All commands share this in common. + */ +struct ie_cmd_common { + u_short ie_cmd_status; /* status of this command */ + u_short ie_cmd_cmd; /* command word */ + u_short ie_cmd_link; /* link to next command */ +}; +#define IE_STAT_COMPL 0x8000 /* command is completed */ +#define IE_STAT_BUSY 0x4000 /* command is running now */ +#define IE_STAT_OK 0x2000 /* command completed successfully */ +#define IE_STAT_ABORT 0x1000 /* command was aborted */ + + +#define IE_CMD_NOP 0x0000 /* NOP */ +#define IE_CMD_IASETUP 0x0001 /* initial address setup */ +#define IE_CMD_CONFIG 0x0002 /* configure command */ +#define IE_CMD_MCAST 0x0003 /* multicast setup command */ +#define IE_CMD_XMIT 0x0004 /* transmit command */ +#define IE_CMD_TDR 0x0005 /* time-domain reflectometer command */ +#define IE_CMD_DUMP 0x0006 /* dump command */ +#define IE_CMD_DIAGNOSE 0x0007 /* diagnostics command */ + +#define IE_CMD_LAST 0x8000 /* this is the last command in the list */ +#define IE_CMD_SUSPEND 0x4000 /* suspend CU after this command */ +#define IE_CMD_INTR 0x2000 /* post an interrupt after completion */ + +/* + * This is the command to transmit a frame. + */ +struct ie_xmit_cmd { + struct ie_cmd_common com; /* common part */ +#define ie_xmit_status com.ie_cmd_status + + u_short ie_xmit_desc; /* 16-pointer to buffer descriptor */ + struct ie_en_addr ie_xmit_addr; /* destination address */ + + u_short ie_xmit_length; /* 802.3 length/Ether type field */ +}; +#define IE_XS_MAXCOLL 0x000f /* number of collisions during transmit */ +#define IE_XS_EXCMAX 0x0020 /* exceeded maximum number of collisions */ +#define IE_XS_SQE 0x0040 /* SQE positive */ +#define IE_XS_DEFERRED 0x0080 /* transmission deferred */ +#define IE_XS_UNDERRUN 0x0100 /* DMA underrun */ +#define IE_XS_LOSTCTS 0x0200 /* Lost CTS */ +#define IE_XS_NOCARRIER 0x0400 /* No Carrier */ + +/* + * This is a buffer descriptor for a frame to be transmitted. + */ + +struct ie_xmit_buf { + u_short ie_xmit_flags; /* see below */ + u_short ie_xmit_next; /* 16-pointer to next desc. */ + u_short ie_xmit_buf_low;/* 24-pointer to the actual buffer */ + u_short ie_xmit_buf_high; /* 24-pointer to the actual buffer */ +}; +#define IE_XMIT_LAST 0x8000 /* this TBD is the last one */ +/* The rest of the `flags' word is actually the length. */ + +/* + * Multicast setup command. + */ + +#define MAXMCAST 250 /* must fit in transmit buffer */ + +struct ie_mcast_cmd { + struct ie_cmd_common com; /* common part */ +#define ie_mcast_status com.ie_cmd_status + + u_short ie_mcast_bytes; /* size (in bytes) of multicast addresses */ + struct ie_en_addr ie_mcast_addrs[MAXMCAST + 1]; /* space for them */ +}; +/* + * Time Domain Reflectometer command. + */ + +struct ie_tdr_cmd { + struct ie_cmd_common com; /* common part */ +#define ie_tdr_status com.ie_cmd_status + + u_short ie_tdr_time; /* error bits and time */ +}; +#define IE_TDR_SUCCESS 0x8000 /* TDR succeeded without error */ +#define IE_TDR_XCVR 0x4000 /* detected a transceiver problem */ +#define IE_TDR_OPEN 0x2000 /* detected an open */ +#define IE_TDR_SHORT 0x1000 /* TDR detected a short */ +#define IE_TDR_TIME 0x07ff /* mask for reflection time */ + +/* + * Initial Address Setup command + */ +struct ie_iasetup_cmd { + struct ie_cmd_common com; +#define ie_iasetup_status com.ie_cmd_status + + struct ie_en_addr ie_address; +}; +/* + * Configuration command + */ +struct ie_config_cmd { + struct ie_cmd_common com; /* common part */ +#define ie_config_status com.ie_cmd_status + + u_char ie_config_count;/* byte count (0x0c) */ + u_char ie_fifo; /* fifo (8) */ + u_char ie_save_bad; /* save bad frames (0x40) */ + u_char ie_addr_len; /* address length (0x2e) (AL-LOC == 1) */ + u_char ie_priority; /* priority and backoff (0x0) */ + u_char ie_ifs; /* inter-frame spacing (0x60) */ + u_char ie_slot_low; /* slot time, LSB (0x0) */ + u_char ie_slot_high; /* slot time, MSN, and retries (0xf2) */ + u_char ie_promisc; /* 1 if promiscuous, else 0 */ + u_char ie_crs_cdt; /* CSMA/CD parameters (0x0) */ + u_char ie_min_len; /* min frame length (0x40) */ + u_char ie_junk; /* stuff for 82596 (0xff) */ +}; + +struct iemem { + volatile struct ie_scp im_scp; + u_char xx1[4]; + volatile struct ie_iscp im_iscp; + + volatile struct ie_scb im_scb; + volatile struct ie_config_cmd im_cc; + volatile struct ie_iasetup_cmd im_ic; + volatile struct ie_recv_frame_desc im_rfd[NRXBUF]; + volatile struct ie_recv_buf_desc im_rbd[NRXBUF]; + volatile struct ie_xmit_cmd im_xc[NTXBUF]; + volatile struct ie_xmit_buf im_xd[NTXBUF]; + volatile u_char im_rxbuf[NRXBUF * IE_RBUF_SIZE]; + volatile u_char im_txbuf[NTXBUF * ETHER_MAX_LEN]; + +}; diff --git a/sys/arch/mvme88k/stand/openbsd/netboot/if_ie.c b/sys/arch/mvme88k/stand/openbsd/netboot/if_ie.c new file mode 100644 index 00000000000..65e143b9339 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/netboot/if_ie.c @@ -0,0 +1,496 @@ +/* $Id: if_ie.c,v 1.1 1997/03/03 19:31:09 rahnds Exp $ */ + +/* + * Copyright (c) 1995 Theo de Raadt + * + * 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 under OpenBSD by + * Theo de Raadt for Willowglen Singapore. + * 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 <sys/types.h> + +#include <netinet/in.h> +#include <netinet/in_systm.h> + +#define ETHER_MIN_LEN 64 +#define ETHER_MAX_LEN 1518 + +#define NTXBUF 1 +#define NRXBUF 16 +#define IE_RBUF_SIZE ETHER_MAX_LEN + +#include "stand.h" +#include "netif.h" +#include "config.h" + +#include "i82586.h" +#include "if_iereg.h" + +int ie_debug = 0; + +void ie_stop __P((struct netif *)); +void ie_end __P((struct netif *)); +void ie_error __P((struct netif *, char *, volatile struct iereg *)); +int ie_get __P((struct iodesc *, void *, size_t, time_t)); +void ie_init __P((struct iodesc *, void *)); +int ie_match __P((struct netif *, void *)); +int ie_poll __P((struct iodesc *, void *, int)); +int ie_probe __P((struct netif *, void *)); +int ie_put __P((struct iodesc *, void *, size_t)); +void ie_reset __P((struct netif *, u_char *)); + +struct netif_stats ie_stats; + +struct netif_dif ie0_dif = { + 0, /* unit */ + 1, /* nsel */ + &ie_stats, + 0, + 0, +}; + +struct netif_driver ie_driver = { + "ie", /* netif_bname */ + ie_match, /* match */ + ie_probe, /* probe */ + ie_init, /* init */ + ie_get, /* get */ + ie_put, /* put */ + ie_end, /* end */ + &ie0_dif, /* netif_ifs */ + 1, /* netif_nifs */ +}; + +struct ie_configuration { + u_int phys_addr; + int used; +} ie_config[] = { + { INTEL_REG_ADDR, 0 } +}; + +int nie_config = sizeof(ie_config) / (sizeof(ie_config[0])); + +struct { + struct iereg *sc_reg; /* IE registers */ + struct iemem *sc_mem; /* RAM */ +} ie_softc; + +int +ie_match(nif, machdep_hint) + struct netif *nif; + void *machdep_hint; +{ + char *name; + int i, val = 0; + extern int cputyp; + + if (cputyp == CPU_147) + return (0); + name = machdep_hint; + if (name && !bcmp(ie_driver.netif_bname, name, 2)) + val += 10; + for (i = 0; i < nie_config; i++) { + if (ie_config[i].used) + continue; + if (ie_debug) + printf("ie%d: ie_match --> %d\n", i, val + 1); + ie_config[i].used++; + return (val + 1); + } + if (ie_debug) + printf("ie%d: ie_match --> 0\n", i); + return (0); +} + +int +ie_probe(nif, machdep_hint) + struct netif *nif; + void *machdep_hint; +{ + extern int cputyp; + + /* the set unit is the current unit */ + if (ie_debug) + printf("ie%d: ie_probe called\n", nif->nif_unit); + + if (cputyp != CPU_147) + return (0); + return (1); +} + +void +ie_error(nif, str, ier) + struct netif *nif; + char *str; + volatile struct iereg *ier; +{ + panic("ie%d: unknown error\n", nif->nif_unit); +} + +ieack(ier, iem) + volatile struct iereg *ier; + struct iemem *iem; +{ + /* ack the `interrupt' */ + iem->im_scb.ie_command = iem->im_scb.ie_status & IE_ST_WHENCE; + ier->ie_attention = 1; /* chan attention! */ + while (iem->im_scb.ie_command) + ; +} + +void +ie_reset(nif, myea) + struct netif *nif; + u_char *myea; +{ + volatile struct iereg *ier = ie_softc.sc_reg; + struct iemem *iem = ie_softc.sc_mem; + int timo = 10000, stat, i; + volatile int t; + u_int a; + + if (ie_debug) + printf("ie%d: ie_reset called\n", nif->nif_unit); + + /*printf("ier %x iem %x\n", ier, iem);*/ + + *(u_char *)0xfff4202a = 0x40; + + bzero(iem, sizeof(*iem)); + iem->im_scp.scp_sysbus = 0; + iem->im_scp.scp_iscp_low = (int) &iem->im_iscp & 0xffff; + iem->im_scp.scp_iscp_high = (int) &iem->im_iscp >> 16; + + iem->im_iscp.iscp_scboffset = (int) &iem->im_scb - (int) iem; + iem->im_iscp.iscp_busy = 1; + iem->im_iscp.iscp_base_low = (int) iem & 0xffff; + iem->im_iscp.iscp_base_high = (int) iem >> 16; + + /* + * completely and utterly unlike what i expected, the + * "write" order is: + * 1st: d15-d0 -> high address + * 2nd: d31-d16 -> low address + */ + + /* reset chip */ + a = IE_PORT_RESET; + ier->ie_porthigh = a & 0xffff; + t = 0; + t = 1; + ier->ie_portlow = a >> 16; + for (t = timo; t--;) + ; + + /* set new SCP pointer */ + a = (int) &iem->im_scp | IE_PORT_NEWSCP; + ier->ie_porthigh = a & 0xffff; + t = 0; + t = 1; + ier->ie_portlow = a >> 16; + for (t = timo; t--;) + ; + + ier->ie_attention = 1; /* chan attention! */ + for (t = timo * 10; t--;) + ; + + /* send CONFIGURE command */ + iem->im_scb.ie_command = IE_CU_START; + iem->im_scb.ie_command_list = (int) &iem->im_cc - (int) iem; + iem->im_cc.com.ie_cmd_status = 0; + iem->im_cc.com.ie_cmd_cmd = IE_CMD_CONFIG | IE_CMD_LAST; + iem->im_cc.com.ie_cmd_link = 0xffff; + iem->im_cc.ie_config_count = 0x0c; + iem->im_cc.ie_fifo = 8; + iem->im_cc.ie_save_bad = 0x40; + iem->im_cc.ie_addr_len = 0x2e; + iem->im_cc.ie_priority = 0; + iem->im_cc.ie_ifs = 0x60; + iem->im_cc.ie_slot_low = 0; + iem->im_cc.ie_slot_high = 0xf2; + iem->im_cc.ie_promisc = 0; + iem->im_cc.ie_crs_cdt = 0; + iem->im_cc.ie_min_len = 64; + iem->im_cc.ie_junk = 0xff; + + ier->ie_attention = 1; /* chan attention! */ + for (t = timo * 10; t--;) + ; + + ieack(ier, iem); + + /*printf("ic %x\n", &iem->im_ic);*/ + /* send IASETUP command */ + iem->im_scb.ie_command = IE_CU_START; + iem->im_scb.ie_command_list = (int) &iem->im_ic - (int) iem; + iem->im_ic.com.ie_cmd_status = 0; + iem->im_ic.com.ie_cmd_cmd = IE_CMD_IASETUP | IE_CMD_LAST; + iem->im_ic.com.ie_cmd_link = 0xffff; + bcopy(myea, (void *)&iem->im_ic.ie_address, sizeof iem->im_ic.ie_address); + + ier->ie_attention = 1; /* chan attention! */ + for (t = timo * 10; t--;) + ; + + ieack(ier, iem); + + /* setup buffers */ + + for (i = 0; i < NRXBUF; i++) { + iem->im_rfd[i].ie_fd_next = (int) &iem->im_rfd[(i+1) % NRXBUF] - + (int) iem; + iem->im_rbd[i].ie_rbd_next = (int) &iem->im_rbd[(i+1) % NRXBUF] - + (int) iem; + a = (int) &iem->im_rxbuf[i * IE_RBUF_SIZE]; + iem->im_rbd[i].ie_rbd_buffer_low = a & 0xffff; + iem->im_rbd[i].ie_rbd_buffer_high = a >> 16; + iem->im_rbd[i].ie_rbd_length = IE_RBUF_SIZE; + } + iem->im_rfd[NRXBUF-1].ie_fd_last |= IE_FD_LAST; + iem->im_rbd[NRXBUF-1].ie_rbd_length |= IE_RBD_LAST; + iem->im_rfd[0].ie_fd_buf_desc = (int) &iem->im_rbd[0] - (int) iem; + + /*printf("rfd[0] %x rbd[0] %x buf[0] %x\n", &iem->im_rfd, &iem->im_rbd, + &iem->im_rxbuf);*/ + + /* send receiver start command */ + iem->im_scb.ie_command = IE_RU_START; + iem->im_scb.ie_command_list = 0; + iem->im_scb.ie_recv_list = (int) &iem->im_rfd[0] - (int) iem; + ier->ie_attention = 1; /* chan attention! */ + while (iem->im_scb.ie_command) + ; + + ieack(ier, iem); +} + +int +ie_poll(desc, pkt, len) + struct iodesc *desc; + void *pkt; + int len; +{ + volatile struct iereg *ier = ie_softc.sc_reg; + struct iemem *iem = ie_softc.sc_mem; + u_char *p = pkt; + static int slot; + int length = 0; + u_int a; + u_short status; + + asm(".word 0xf518\n"); + status = iem->im_rfd[slot].ie_fd_status; + if (status & IE_FD_BUSY) + return (0); + + /* printf("slot %d: %x\n", slot, status); */ + if ((status & (IE_FD_COMPLETE | IE_FD_OK)) == (IE_FD_COMPLETE | IE_FD_OK)) { + if (status & IE_FD_OK) { + length = iem->im_rbd[slot].ie_rbd_actual & 0x3fff; + if (length > len) + length = len; + bcopy((void *)&iem->im_rxbuf[slot * IE_RBUF_SIZE], + pkt, length); + + iem->im_rfd[slot].ie_fd_status = 0; + iem->im_rfd[slot].ie_fd_last |= IE_FD_LAST; + iem->im_rfd[(slot+NRXBUF-1)%NRXBUF].ie_fd_last &= + ~IE_FD_LAST; + iem->im_rbd[slot].ie_rbd_actual = 0; + iem->im_rbd[slot].ie_rbd_length |= IE_RBD_LAST; + iem->im_rbd[(slot+NRXBUF-1)%NRXBUF].ie_rbd_length &= + ~IE_RBD_LAST; + /*printf("S%d\n", slot);*/ + + } else { + printf("shit\n"); + } + slot++; + /* should move descriptor onto end of queue... */ + } + if ((iem->im_scb.ie_status & IE_RU_READY) == 0) { + printf("RR\n"); + + for (slot = 0; slot < NRXBUF; slot++) { + iem->im_rbd[slot].ie_rbd_length &= ~IE_RBD_LAST; + iem->im_rfd[slot].ie_fd_last &= ~IE_FD_LAST; + } + iem->im_rbd[NRXBUF-1].ie_rbd_length |= IE_RBD_LAST; + iem->im_rfd[NRXBUF-1].ie_fd_last |= IE_FD_LAST; + + iem->im_rfd[0].ie_fd_buf_desc = (int)&iem->im_rbd[0] - (int)iem; + + iem->im_scb.ie_command = IE_RU_START; + iem->im_scb.ie_command_list = 0; + iem->im_scb.ie_recv_list = (int)&iem->im_rfd[0] - (int)iem; + ier->ie_attention = 1; /* chan attention! */ + while (iem->im_scb.ie_command) + ; + slot = 0; + } + slot = slot % NRXBUF; + return (length); +} + +int +ie_put(desc, pkt, len) + struct iodesc *desc; + void *pkt; + size_t len; +{ + volatile struct iereg *ier = ie_softc.sc_reg; + struct iemem *iem = ie_softc.sc_mem; + u_char *p = pkt; + int timo = 10000, stat, i; + volatile int t; + u_int a; + int xx = 0; + + /* send transmit command */ + + while (iem->im_scb.ie_command) + ; + + /* copy data */ + bcopy(p, (void *)&iem->im_txbuf[xx], len); + + len = MAX(len, ETHER_MIN_LEN); + + /* build transmit descriptor */ + iem->im_xd[xx].ie_xmit_flags = len | IE_XMIT_LAST; + iem->im_xd[xx].ie_xmit_next = 0xffff; + a = (int) &iem->im_txbuf[xx]; + iem->im_xd[xx].ie_xmit_buf_low = a & 0xffff; + iem->im_xd[xx].ie_xmit_buf_high = a >> 16; + + /* transmit command */ + iem->im_xc[xx].com.ie_cmd_status = 0; + iem->im_xc[xx].com.ie_cmd_cmd = IE_CMD_XMIT | IE_CMD_LAST; + iem->im_xc[xx].com.ie_cmd_link = 0xffff; + iem->im_xc[xx].ie_xmit_desc = (int) &iem->im_xd[xx] - (int) iem; + iem->im_xc[xx].ie_xmit_length = len; + bcopy(p, (void *)&iem->im_xc[xx].ie_xmit_addr, + sizeof iem->im_xc[xx].ie_xmit_addr); + + iem->im_scb.ie_command = IE_CU_START; + iem->im_scb.ie_command_list = (int) &iem->im_xc[xx] - (int) iem; + + ier->ie_attention = 1; /* chan attention! */ + + if (ie_debug) { + printf("ie%d: send %d to %x:%x:%x:%x:%x:%x\n", + desc->io_netif->nif_unit, len, + p[0], p[1], p[2], p[3], p[4], p[5]); + } + return (len); +} + +int +ie_get(desc, pkt, len, timeout) + struct iodesc *desc; + void *pkt; + size_t len; + time_t timeout; +{ + time_t t; + int cc; + + t = getsecs(); + cc = 0; + while (((getsecs() - t) < timeout) && !cc) { + cc = ie_poll(desc, pkt, len); + } + return (cc); +} +/* + * init ie device. return 0 on failure, 1 if ok. + */ +void +ie_init(desc, machdep_hint) + struct iodesc *desc; + void *machdep_hint; +{ + struct netif *nif = desc->io_netif; + + if (ie_debug) + printf("ie%d: ie_init called\n", desc->io_netif->nif_unit); + machdep_common_ether(desc->myea); + bzero(&ie_softc, sizeof(ie_softc)); + ie_softc.sc_reg = + (struct iereg *) ie_config[desc->io_netif->nif_unit].phys_addr; + ie_softc.sc_mem = (struct iemem *) 0x1e0000; + ie_reset(desc->io_netif, desc->myea); + printf("device: %s%d attached to %s\n", nif->nif_driver->netif_bname, + nif->nif_unit, ether_sprintf(desc->myea)); +} + +void +ie_stop(nif) + struct netif *nif; +{ + volatile struct iereg *ier = ie_softc.sc_reg; + struct iemem *iem = ie_softc.sc_mem; + int timo = 10000; + volatile int t; + u_int a; + + iem->im_iscp.iscp_busy = 1; + /* reset chip */ + a = IE_PORT_RESET; + ier->ie_porthigh = a & 0xffff; + t = 0; + t = 1; + ier->ie_portlow = a >> 16; + for (t = timo; t--;) + ; + + /* reset chip again */ + a = IE_PORT_RESET; + ier->ie_porthigh = a & 0xffff; + t = 0; + t = 1; + ier->ie_portlow = a >> 16; + for (t = timo; t--;) + ; + + /*printf("status %x busy %x\n", iem->im_scb.ie_status, + iem->im_iscp.iscp_busy);*/ +} + +void +ie_end(nif) + struct netif *nif; +{ + if (ie_debug) + printf("ie%d: ie_end called\n", nif->nif_unit); + + ie_stop(nif); + + /* *(u_char *) 0xfff42002 = 0; */ +} diff --git a/sys/arch/mvme88k/stand/openbsd/netboot/if_iereg.h b/sys/arch/mvme88k/stand/openbsd/netboot/if_iereg.h new file mode 100644 index 00000000000..32aaf377017 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/netboot/if_iereg.h @@ -0,0 +1,163 @@ +/* $Id: if_iereg.h,v 1.1 1997/03/03 19:31:09 rahnds Exp $ */ + +/* + * if_sunie.h + * + * sun's ie interface + */ + +/* + * programming notes: + * + * the ie chip operates in a 24 bit address space. + * + * most ie interfaces appear to be divided into two parts: + * - generic 586 stuff + * - board specific + * + * generic: + * the generic stuff of the ie chip is all done with data structures + * that live in the chip's memory address space. the chip expects + * its main data structure (the sys conf ptr -- SCP) to be at a fixed + * address in its 24 bit space: 0xfffff4 + * + * the SCP points to another structure called the ISCP. + * the ISCP points to another structure called the SCB. + * the SCB has a status field, a linked list of "commands", and + * a linked list of "receive buffers". these are data structures that + * live in memory, not registers. + * + * board: + * to get the chip to do anything, you first put a command in the + * command data structure list. then you have to signal "attention" + * to the chip to get it to look at the command. how you + * signal attention depends on what board you have... on PC's + * there is an i/o port number to do this, on sun's there is a + * register bit you toggle. + * + * to get data from the chip you program it to interrupt... + * + * + * sun issues: + * + * there are 3 kinds of sun "ie" interfaces: + * 1 - a VME/multibus card + * 2 - an on-board interface (sun3's, sun-4/100's, and sun-4/200's) + * 3 - another VME board called the 3E + * + * the VME boards lives in vme16 space. only 16 and 8 bit accesses + * are allowed, so functions that copy data must be aware of this. + * + * the chip is an intel chip. this means that the byte order + * on all the "short"s in the chip's data structures is wrong. + * so, constants described in the intel docs are swapped for the sun. + * that means that any buffer pointers you give the chip must be + * swapped to intel format. yuck. + * + * VME/multibus interface: + * for the multibus interface the board ignores the top 4 bits + * of the chip address. the multibus interface seems to have its + * own MMU like page map (without protections or valid bits, etc). + * there are 256 pages of physical memory on the board (each page + * is 1024 bytes). there are 1024 slots in the page map. so, + * a 1024 byte page takes up 10 bits of address for the offset, + * and if there are 1024 slots in the page that is another 10 bits + * of the address. that makes a 20 bit address, and as stated + * earlier the board ignores the top 4 bits, so that accounts + * for all 24 bits of address. + * + * note that the last entry of the page map maps the top of the + * 24 bit address space and that the SCP is supposed to be at + * 0xfffff4 (taking into account allignment). so, + * for multibus, that entry in the page map has to be used for the SCP. + * + * the page map effects BOTH how the ie chip sees the + * memory, and how the host sees it. + * + * the page map is part of the "register" area of the board + * + * on-board interface: + * + * <fill in useful info later> + * + * + * VME3E interface: + * + * <fill in useful info later> + * + */ + +/* + * PART 1: VME/multibus defs + */ +#define IEVME_PAGESIZE 1024 /* bytes */ +#define IEVME_PAGSHIFT 10 /* bits */ +#define IEVME_NPAGES 256 /* number of pages on chip */ +#define IEVME_MAPSZ 1024 /* number of entries in the map */ + +/* + * PTE for the page map + */ +#define IEVME_SBORDR 0x8000 /* sun byte order */ +#define IEVME_IBORDR 0x0000 /* intel byte ordr */ + +#define IEVME_P2MEM 0x2000 /* memory is on P2 */ +#define IEVME_OBMEM 0x0000 /* memory is on board */ + +#define IEVME_PGMASK 0x0fff /* gives the physical page frame number */ + +struct ievme { + u_short pgmap[IEVME_MAPSZ]; + u_short xxx[32]; /* prom */ + u_short status; /* see below for bits */ + u_short xxx2; /* filler */ + u_short pectrl; /* parity control (see below) */ + u_short peaddr; /* low 16 bits of address */ +}; +/* + * status bits + */ +#define IEVME_RESET 0x8000 /* reset board */ +#define IEVME_ONAIR 0x4000 /* go out of loopback 'on-air' */ +#define IEVME_ATTEN 0x2000 /* attention */ +#define IEVME_IENAB 0x1000 /* interrupt enable */ +#define IEVME_PEINT 0x0800 /* parity error interrupt enable */ +#define IEVME_PERR 0x0200 /* parity error flag */ +#define IEVME_INT 0x0100 /* interrupt flag */ +#define IEVME_P2EN 0x0020 /* enable p2 bus */ +#define IEVME_256K 0x0010 /* 256kb rams */ +#define IEVME_HADDR 0x000f /* mask for bits 17-20 of address */ + +/* + * parity control + */ +#define IEVME_PARACK 0x0100 /* parity error ack */ +#define IEVME_PARSRC 0x0080 /* parity error source */ +#define IEVME_PAREND 0x0040 /* which end of the data got the error */ +#define IEVME_PARADR 0x000f /* mask to get bits 17-20 of parity address */ + + +/* + * PART 2: the on-board interface + */ +struct ieob { + u_char obctrl; +}; +#define IEOB_NORSET 0x80 /* don't reset the board */ +#define IEOB_ONAIR 0x40 /* put us on the air */ +#define IEOB_ATTEN 0x20 /* attention! */ +#define IEOB_IENAB 0x10 /* interrupt enable */ +#define IEOB_XXXXX 0x08 /* free bit */ +#define IEOB_XCVRL2 0x04 /* level 2 transceiver? */ +#define IEOB_BUSERR 0x02 /* bus error */ +#define IEOB_INT 0x01 /* interrupt */ + +#define IEOB_ADBASE 0xff000000 /* KVA base addr of 24 bit address space */ + +/* + * PART 3: the 3E board + */ + +/* + * not supported (yet?) + */ diff --git a/sys/arch/mvme88k/stand/openbsd/netboot/if_le.c b/sys/arch/mvme88k/stand/openbsd/netboot/if_le.c new file mode 100644 index 00000000000..40e8074e207 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/netboot/if_le.c @@ -0,0 +1,460 @@ +/* $Id: if_le.c,v 1.1 1997/03/03 19:31:09 rahnds Exp $ */ + +/* + * Copyright (c) 1995 Theo de Raadt + * + * 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 under OpenBSD by + * Theo de Raadt for Willowglen Singapore. + * 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. + * + * Copyright (c) 1993 Adam Glass + * 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 Adam Glass. + * 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 Adam Glass ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/types.h> + +#include <netinet/in.h> +#include <netinet/in_systm.h> + +#include "stand.h" +#include "netif.h" +#include "config.h" + +#include "if_lereg.h" + +int le_debug = 0; + +void le_end __P((struct netif *)); +void le_error __P((struct netif *, char *, volatile struct lereg1 *)); +int le_get __P((struct iodesc *, void *, size_t, time_t)); +void le_init __P((struct iodesc *, void *)); +int le_match __P((struct netif *, void *)); +int le_poll __P((struct iodesc *, void *, int)); +int le_probe __P((struct netif *, void *)); +int le_put __P((struct iodesc *, void *, size_t)); +void le_reset __P((struct netif *, u_char *)); + +struct netif_stats le_stats; + +struct netif_dif le0_dif = { + 0, /* unit */ + 1, /* nsel */ + &le_stats, + 0, + 0, +}; + +struct netif_driver le_driver = { + "le", /* netif_bname */ + le_match, /* match */ + le_probe, /* probe */ + le_init, /* init */ + le_get, /* get */ + le_put, /* put */ + le_end, /* end */ + &le0_dif, /* netif_ifs */ + 1, /* netif_nifs */ +}; + +struct le_configuration { + unsigned int phys_addr; + int used; +} le_config[] = { + { LANCE_REG_ADDR, 0 } +}; + +int nle_config = sizeof(le_config) / (sizeof(le_config[0])); + +struct { + struct lereg1 *sc_r1; /* LANCE registers */ + struct lereg2 *sc_r2; /* RAM */ + int next_rmd; + int next_tmd; +} le_softc; + +int +le_match(nif, machdep_hint) + struct netif *nif; + void *machdep_hint; +{ + char *name; + int i, val = 0; + extern int cputyp; + + if (cputyp != CPU_147) + return (0); + name = machdep_hint; + if (name && !bcmp(le_driver.netif_bname, name, 2)) + val += 10; + for (i = 0; i < nle_config; i++) { + if (le_config[i].used) + continue; + if (le_debug) + printf("le%d: le_match --> %d\n", i, val + 1); + le_config[i].used++; + return val + 1; + } + if (le_debug) + printf("le%d: le_match --> 0\n", i); + return 0; +} + +int +le_probe(nif, machdep_hint) + struct netif *nif; + void *machdep_hint; +{ + extern int cputyp; + + /* the set unit is the current unit */ + if (le_debug) + printf("le%d: le_probe called\n", nif->nif_unit); + + if (cputyp == CPU_147) + return 0; + return 1; +} + +void +le_error(nif, str, ler1) + struct netif *nif; + char *str; + volatile struct lereg1 *ler1; +{ + /* ler1->ler1_rap = LE_CSRO done in caller */ + if (ler1->ler1_rdp & LE_C0_BABL) + panic("le%d: been babbling, found by '%s'\n", nif->nif_unit, str); + if (ler1->ler1_rdp & LE_C0_CERR) { + le_stats.collision_error++; + ler1->ler1_rdp = LE_C0_CERR; + } + if (ler1->ler1_rdp & LE_C0_MISS) { + le_stats.missed++; + ler1->ler1_rdp = LE_C0_MISS; + } + if (ler1->ler1_rdp & LE_C0_MERR) { + printf("le%d: memory error in '%s'\n", nif->nif_unit, str); + panic("memory error"); + } +} + +void +le_reset(nif, myea) + struct netif *nif; + u_char *myea; +{ + struct lereg1 *ler1 = le_softc.sc_r1; + struct lereg2 *ler2 = le_softc.sc_r2; + unsigned int a; + int timo = 100000, stat, i; + + if (le_debug) + printf("le%d: le_reset called\n", nif->nif_unit); + ler1->ler1_rap = LE_CSR0; + ler1->ler1_rdp = LE_C0_STOP; /* do nothing until we are finished */ + + bzero(ler2, sizeof(*ler2)); + + ler2->ler2_mode = LE_MODE_NORMAL; + ler2->ler2_padr[0] = myea[1]; + ler2->ler2_padr[1] = myea[0]; + ler2->ler2_padr[2] = myea[3]; + ler2->ler2_padr[3] = myea[2]; + ler2->ler2_padr[4] = myea[5]; + ler2->ler2_padr[5] = myea[4]; + + + ler2->ler2_ladrf0 = 0; + ler2->ler2_ladrf1 = 0; + + a = (u_int) ler2->ler2_rmd; + ler2->ler2_rlen = LE_RLEN | (a >> 16); + ler2->ler2_rdra = a & LE_ADDR_LOW_MASK; + + a = (u_int) ler2->ler2_tmd; + ler2->ler2_tlen = LE_TLEN | (a >> 16); + ler2->ler2_tdra = a & LE_ADDR_LOW_MASK; + + ler1->ler1_rap = LE_CSR1; + a = (u_int) ler2; + ler1->ler1_rdp = a & LE_ADDR_LOW_MASK; + ler1->ler1_rap = LE_CSR2; + ler1->ler1_rdp = a >> 16; + + for (i = 0; i < LERBUF; i++) { + a = (u_int) & ler2->ler2_rbuf[i]; + ler2->ler2_rmd[i].rmd0 = a & LE_ADDR_LOW_MASK; + ler2->ler2_rmd[i].rmd1_bits = LE_R1_OWN; + ler2->ler2_rmd[i].rmd1_hadr = a >> 16; + ler2->ler2_rmd[i].rmd2 = -LEMTU; + ler2->ler2_rmd[i].rmd3 = 0; + } + for (i = 0; i < LETBUF; i++) { + a = (u_int) & ler2->ler2_tbuf[i]; + ler2->ler2_tmd[i].tmd0 = a & LE_ADDR_LOW_MASK; + ler2->ler2_tmd[i].tmd1_bits = 0; + ler2->ler2_tmd[i].tmd1_hadr = a >> 16; + ler2->ler2_tmd[i].tmd2 = 0; + ler2->ler2_tmd[i].tmd3 = 0; + } + + ler1->ler1_rap = LE_CSR3; + ler1->ler1_rdp = LE_C3_BSWP; + + ler1->ler1_rap = LE_CSR0; + ler1->ler1_rdp = LE_C0_INIT; + do { + if (--timo == 0) { + printf("le%d: init timeout, stat = 0x%x\n", + nif->nif_unit, stat); + break; + } + stat = ler1->ler1_rdp; + } while ((stat & LE_C0_IDON) == 0); + + ler1->ler1_rdp = LE_C0_IDON; + le_softc.next_rmd = 0; + le_softc.next_tmd = 0; + ler1->ler1_rap = LE_CSR0; + ler1->ler1_rdp = LE_C0_STRT; +} + +int +le_poll(desc, pkt, len) + struct iodesc *desc; + void *pkt; + int len; +{ + struct lereg1 *ler1 = le_softc.sc_r1; + struct lereg2 *ler2 = le_softc.sc_r2; + unsigned int a; + int length; + struct lermd *rmd; + + + ler1->ler1_rap = LE_CSR0; + if ((ler1->ler1_rdp & LE_C0_RINT) != 0) + ler1->ler1_rdp = LE_C0_RINT; + rmd = &ler2->ler2_rmd[le_softc.next_rmd]; + if (rmd->rmd1_bits & LE_R1_OWN) { + return (0); + } + if (ler1->ler1_rdp & LE_C0_ERR) + le_error(desc->io_netif, "le_poll", ler1); + if (rmd->rmd1_bits & LE_R1_ERR) { + printf("le%d_poll: rmd status 0x%x\n", desc->io_netif->nif_unit, + rmd->rmd1_bits); + length = 0; + goto cleanup; + } + if ((rmd->rmd1_bits & (LE_R1_STP | LE_R1_ENP)) != (LE_R1_STP | LE_R1_ENP)) + panic("le_poll: chained packet\n"); + + length = rmd->rmd3; + if (length >= LEMTU) { + length = 0; + panic("csr0 when bad things happen: %x\n", ler1->ler1_rdp); + goto cleanup; + } + if (!length) + goto cleanup; + length -= 4; + if (length > 0) { + + /* + * if buffer is smaller than the packet truncate it. + * (is this wise?) + */ + if (length > len) + length = len; + + bcopy((void *)&ler2->ler2_rbuf[le_softc.next_rmd], pkt, length); + } +cleanup: + a = (u_int) & ler2->ler2_rbuf[le_softc.next_rmd]; + rmd->rmd0 = a & LE_ADDR_LOW_MASK; + rmd->rmd1_hadr = a >> 16; + rmd->rmd2 = -LEMTU; + le_softc.next_rmd = + (le_softc.next_rmd == (LERBUF - 1)) ? 0 : (le_softc.next_rmd + 1); + rmd->rmd1_bits = LE_R1_OWN; + return length; +} + +int +le_put(desc, pkt, len) + struct iodesc *desc; + void *pkt; + size_t len; +{ + volatile struct lereg1 *ler1 = le_softc.sc_r1; + volatile struct lereg2 *ler2 = le_softc.sc_r2; + volatile struct letmd *tmd; + int timo = 100000, stat, i; + unsigned int a; + + ler1->ler1_rap = LE_CSR0; + if (ler1->ler1_rdp & LE_C0_ERR) + le_error(desc->io_netif, "le_put(way before xmit)", ler1); + tmd = &ler2->ler2_tmd[le_softc.next_tmd]; + while (tmd->tmd1_bits & LE_T1_OWN) { + printf("le%d: output buffer busy\n", desc->io_netif->nif_unit); + } + bcopy(pkt, (void *)ler2->ler2_tbuf[le_softc.next_tmd], len); + if (len < 64) + tmd->tmd2 = -64; + else + tmd->tmd2 = -len; + tmd->tmd3 = 0; + if (ler1->ler1_rdp & LE_C0_ERR) + le_error(desc->io_netif, "le_put(before xmit)", ler1); + tmd->tmd1_bits = LE_T1_STP | LE_T1_ENP | LE_T1_OWN; + a = (u_int) & ler2->ler2_tbuf[le_softc.next_tmd]; + tmd->tmd0 = a & LE_ADDR_LOW_MASK; + tmd->tmd1_hadr = a >> 16; + ler1->ler1_rdp = LE_C0_TDMD; + if (ler1->ler1_rdp & LE_C0_ERR) + le_error(desc->io_netif, "le_put(after xmit)", ler1); + do { + if (--timo == 0) { + printf("le%d: transmit timeout, stat = 0x%x\n", + desc->io_netif->nif_unit, stat); + if (ler1->ler1_rdp & LE_C0_ERR) + le_error(desc->io_netif, "le_put(timeout)", ler1); + break; + } + stat = ler1->ler1_rdp; + } while ((stat & LE_C0_TINT) == 0); + ler1->ler1_rdp = LE_C0_TINT; + if (ler1->ler1_rdp & LE_C0_ERR) { + if ((ler1->ler1_rdp & (LE_C0_BABL | LE_C0_CERR | LE_C0_MISS | + LE_C0_MERR)) != + LE_C0_CERR) + printf("le_put: xmit error, buf %d\n", le_softc.next_tmd); + le_error(desc->io_netif, "le_put(xmit error)", ler1); + } + le_softc.next_tmd = 0; +/* (le_softc.next_tmd == (LETBUF - 1)) ? 0 : le_softc.next_tmd + 1;*/ + if (tmd->tmd1_bits & LE_T1_DEF) + le_stats.deferred++; + if (tmd->tmd1_bits & LE_T1_ONE) + le_stats.collisions++; + if (tmd->tmd1_bits & LE_T1_MORE) + le_stats.collisions += 2; + if (tmd->tmd1_bits & LE_T1_ERR) { + printf("le%d: transmit error, error = 0x%x\n", desc->io_netif->nif_unit, + tmd->tmd3); + return -1; + } + if (le_debug) { + printf("le%d: le_put() successful: sent %d\n", + desc->io_netif->nif_unit, len); + printf("le%d: le_put(): tmd1_bits: %x tmd3: %x\n", + desc->io_netif->nif_unit, + (unsigned int) tmd->tmd1_bits, + (unsigned int) tmd->tmd3); + } + return len; +} + +int +le_get(desc, pkt, len, timeout) + struct iodesc *desc; + void *pkt; + size_t len; + time_t timeout; +{ + time_t t; + int cc; + + t = getsecs(); + cc = 0; + while (((getsecs() - t) < timeout) && !cc) { + cc = le_poll(desc, pkt, len); + } + return cc; +} +/* + * init le device. return 0 on failure, 1 if ok. + */ +void +le_init(desc, machdep_hint) + struct iodesc *desc; + void *machdep_hint; +{ + u_long eram = 4*1024*1024; + struct netif *nif = desc->io_netif; + + if (le_debug) + printf("le%d: le_init called\n", desc->io_netif->nif_unit); + machdep_common_ether(desc->myea); + bzero(&le_softc, sizeof(le_softc)); + le_softc.sc_r1 = + (struct lereg1 *) le_config[desc->io_netif->nif_unit].phys_addr; + le_softc.sc_r2 = (struct lereg2 *) (eram - (1024 * 1024)); + le_reset(desc->io_netif, desc->myea); + printf("device: %s%d attached to %s\n", nif->nif_driver->netif_bname, + nif->nif_unit, ether_sprintf(desc->myea)); +} + +void +le_end(nif) + struct netif *nif; +{ + struct lereg1 *ler1 = le_softc.sc_r1; + + if (le_debug) + printf("le%d: le_end called\n", nif->nif_unit); + ler1->ler1_rap = LE_CSR0; + ler1->ler1_rdp = LE_C0_STOP; +} diff --git a/sys/arch/mvme88k/stand/openbsd/netboot/if_lereg.h b/sys/arch/mvme88k/stand/openbsd/netboot/if_lereg.h new file mode 100644 index 00000000000..e55fc19642e --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/netboot/if_lereg.h @@ -0,0 +1,173 @@ +/* $Id: if_lereg.h,v 1.1 1997/03/03 19:31:09 rahnds Exp $ */ + +/*- + * Copyright (c) 1982, 1992, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)if_lereg.h 8.2 (Berkeley) 10/30/93 + */ + +#define LEMTU 1518 +#define LEMINSIZE 60 /* should be 64 if mode DTCR is set */ +#define LERBUF 8 +#define LERBUFLOG2 3 +#define LE_RLEN (LERBUFLOG2 << 13) +#define LETBUF 1 +#define LETBUFLOG2 0 +#define LE_TLEN (LETBUFLOG2 << 13) + +/* Local Area Network Controller for Ethernet (LANCE) registers */ +struct lereg1 { + volatile u_short ler1_rdp; /* register data port */ + volatile u_short ler1_rap; /* register address port */ +}; +/* register addresses */ +#define LE_CSR0 0 /* Control and status register */ +#define LE_CSR1 1 /* low address of init block */ +#define LE_CSR2 2 /* high address of init block */ +#define LE_CSR3 3 /* Bus master and control */ + +/* Control and status register 0 (csr0) */ +#define LE_C0_ERR 0x8000 /* error summary */ +#define LE_C0_BABL 0x4000 /* transmitter timeout error */ +#define LE_C0_CERR 0x2000 /* collision */ +#define LE_C0_MISS 0x1000 /* missed a packet */ +#define LE_C0_MERR 0x0800 /* memory error */ +#define LE_C0_RINT 0x0400 /* receiver interrupt */ +#define LE_C0_TINT 0x0200 /* transmitter interrupt */ +#define LE_C0_IDON 0x0100 /* initalization done */ +#define LE_C0_INTR 0x0080 /* interrupt condition */ +#define LE_C0_INEA 0x0040 /* interrupt enable */ +#define LE_C0_RXON 0x0020 /* receiver on */ +#define LE_C0_TXON 0x0010 /* transmitter on */ +#define LE_C0_TDMD 0x0008 /* transmit demand */ +#define LE_C0_STOP 0x0004 /* disable all external activity */ +#define LE_C0_STRT 0x0002 /* enable external activity */ +#define LE_C0_INIT 0x0001 /* begin initalization */ + +#define LE_C0_BITS \ + "\20\20ERR\17BABL\16CERR\15MISS\14MERR\13RINT\ +\12TINT\11IDON\10INTR\07INEA\06RXON\05TXON\04TDMD\03STOP\02STRT\01INIT" + +/* Control and status register 3 (csr3) */ +#define LE_C3_BSWP 0x4 /* byte swap */ +#define LE_C3_ACON 0x2 /* ALE control, eh? */ +#define LE_C3_BCON 0x1 /* byte control */ +/* + * Current size is 13,758 bytes with 8 x 1518 receive buffers and + * 1 x 1518 transmit buffer. + */ +struct lereg2 { + /* initialization block */ + volatile u_short ler2_mode; /* mode */ + volatile u_char ler2_padr[6]; /* physical address */ +#ifdef new_code + volatile u_short ler2_ladrf[4]; /* logical address filter */ +#else + volatile u_long ler2_ladrf0; /* logical address filter */ + volatile u_long ler2_ladrf1; /* logical address filter */ +#endif + volatile u_short ler2_rdra; /* receive descriptor addr */ + volatile u_short ler2_rlen; /* rda high and ring size */ + volatile u_short ler2_tdra; /* transmit descriptor addr */ + volatile u_short ler2_tlen; /* tda high and ring size */ + /* receive message descriptors. bits/hadr are byte order dependent. */ + struct lermd { + volatile u_short rmd0; /* low address of packet */ + volatile u_char rmd1_bits; /* descriptor bits */ + volatile u_char rmd1_hadr; /* high address of packet */ + volatile short rmd2; /* buffer byte count */ + volatile u_short rmd3; /* message byte count */ + } ler2_rmd[LERBUF]; + /* transmit message descriptors */ + struct letmd { + volatile u_short tmd0; /* low address of packet */ + volatile u_char tmd1_bits; /* descriptor bits */ + volatile u_char tmd1_hadr; /* high address of packet */ + volatile short tmd2; /* buffer byte count */ + volatile u_short tmd3; /* transmit error bits */ + } ler2_tmd[LETBUF]; + volatile char ler2_rbuf[LERBUF][LEMTU]; + volatile char ler2_tbuf[LETBUF][LEMTU]; +}; +/* Initialzation block (mode) */ +#define LE_MODE_PROM 0x8000 /* promiscuous mode */ +/* 0x7f80 reserved, must be zero */ +#define LE_MODE_INTL 0x0040 /* internal loopback */ +#define LE_MODE_DRTY 0x0020 /* disable retry */ +#define LE_MODE_COLL 0x0010 /* force a collision */ +#define LE_MODE_DTCR 0x0008 /* disable transmit CRC */ +#define LE_MODE_LOOP 0x0004 /* loopback mode */ +#define LE_MODE_DTX 0x0002 /* disable transmitter */ +#define LE_MODE_DRX 0x0001 /* disable receiver */ +#define LE_MODE_NORMAL 0 /* none of the above */ + + +/* Receive message descriptor 1 (rmd1_bits) */ +#define LE_R1_OWN 0x80 /* LANCE owns the packet */ +#define LE_R1_ERR 0x40 /* error summary */ +#define LE_R1_FRAM 0x20 /* framing error */ +#define LE_R1_OFLO 0x10 /* overflow error */ +#define LE_R1_CRC 0x08 /* CRC error */ +#define LE_R1_BUFF 0x04 /* buffer error */ +#define LE_R1_STP 0x02 /* start of packet */ +#define LE_R1_ENP 0x01 /* end of packet */ + +#define LE_R1_BITS \ + "\20\10OWN\7ERR\6FRAM\5OFLO\4CRC\3BUFF\2STP\1ENP" + +/* Transmit message descriptor 1 (tmd1_bits) */ +#define LE_T1_OWN 0x80 /* LANCE owns the packet */ +#define LE_T1_ERR 0x40 /* error summary */ +#define LE_T1_MORE 0x10 /* multiple collisions */ +#define LE_T1_ONE 0x08 /* single collision */ +#define LE_T1_DEF 0x04 /* defferred transmit */ +#define LE_T1_STP 0x02 /* start of packet */ +#define LE_T1_ENP 0x01 /* end of packet */ + +#define LE_T1_BITS \ + "\20\10OWN\7ERR\6RES\5MORE\4ONE\3DEF\2STP\1ENP" + +/* Transmit message descriptor 3 (tmd3) */ +#define LE_T3_BUFF 0x8000 /* buffer error */ +#define LE_T3_UFLO 0x4000 /* underflow error */ +#define LE_T3_LCOL 0x1000 /* late collision */ +#define LE_T3_LCAR 0x0800 /* loss of carrier */ +#define LE_T3_RTRY 0x0400 /* retry error */ +#define LE_T3_TDR_MASK 0x03ff /* time domain reflectometry counter */ + +#define LE_XMD2_ONES 0xf000 + +#define LE_T3_BITS \ + "\20\20BUFF\17UFLO\16RES\15LCOL\14LCAR\13RTRY" + + +#define LE_ADDR_LOW_MASK (0xffff) diff --git a/sys/arch/mvme88k/stand/openbsd/netboot/netboot b/sys/arch/mvme88k/stand/openbsd/netboot/netboot Binary files differnew file mode 100644 index 00000000000..a2fe675457c --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/netboot/netboot diff --git a/sys/arch/mvme88k/stand/openbsd/netboot/netboot.bin b/sys/arch/mvme88k/stand/openbsd/netboot/netboot.bin Binary files differnew file mode 100644 index 00000000000..2c1b35d8fa7 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/netboot/netboot.bin diff --git a/sys/arch/mvme88k/stand/openbsd/netboot/version.c b/sys/arch/mvme88k/stand/openbsd/netboot/version.c new file mode 100644 index 00000000000..8f6fe5e8338 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/netboot/version.c @@ -0,0 +1,9 @@ +/* $Id: version.c,v 1.1 1997/03/03 19:31:09 rahnds Exp $ */ + +/* + * NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. + * + * 1.1 + */ + +char *version = "$Revision: 1.1 $"; diff --git a/sys/arch/mvme88k/stand/openbsd/prtvid/Makefile b/sys/arch/mvme88k/stand/openbsd/prtvid/Makefile new file mode 100644 index 00000000000..f6a6d3e1e1a --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/prtvid/Makefile @@ -0,0 +1,6 @@ +PROG= prtvid +NOMAN= + +install: + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/openbsd/prtvid/prtvid.c b/sys/arch/mvme88k/stand/openbsd/prtvid/prtvid.c new file mode 100644 index 00000000000..32784ff0dfa --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/prtvid/prtvid.c @@ -0,0 +1,132 @@ +#include <stdio.h> +#define __DBINTERFACE_PRIVATE +#include <db.h> +#include "vid.h" + +main(argc, argv) + int argc; + char *argv[]; +{ + struct vid *pvid; + struct cfg *pcfg; + + pvid = (struct vid *) malloc(sizeof (struct vid)); + + fread(pvid, sizeof(struct vid), 1, stdin); + + if (BYTE_ORDER != BIG_ENDIAN) + swabvid(pvid); + + printf("vid_id %s %x\n", pvid->vid_id, + (char *)&(pvid->vid_id[4]) - (char *)pvid); + printf("vid_oss %x %x\n", pvid->vid_oss, + (char *)&(pvid->vid_oss) - (char *)pvid); + printf("vid_osl %x %x\n", pvid->vid_osl, + (char *)&(pvid->vid_osl) - (char *)pvid); + printf("vid_osa_u %x %x\n", pvid->vid_osa_u, + (char *)&(pvid->vid_osa_u) - (char *)pvid); + printf("vid_osa_l %x %x\n", pvid->vid_osa_l, + (char *)&(pvid->vid_osa_l) - (char *)pvid); + printf("vid_vd %x\n", + (char *)&(pvid->vid_vd) - (char *)pvid); + printf("vid_cas %x %x\n", pvid->vid_cas, + (char *)&(pvid->vid_cas) - (char *)pvid); + printf("vid_cal %x %x\n", pvid->vid_cal, + (char *)&(pvid->vid_cal) - (char *)pvid); + printf("vid_moto %s %x\n", pvid->vid_mot, + (char *)&(pvid->vid_mot[0]) - (char *)pvid); + + free(pvid); + + pcfg = (struct cfg *) malloc(sizeof(struct cfg)); + + fread(pcfg, sizeof(struct cfg), 1, stdin); + + if (BYTE_ORDER != BIG_ENDIAN) + swabcfg(pcfg); + + printf("cfg_atm %x %x\n", pcfg->cfg_atm, + (char *)&(pcfg->cfg_atm) - (char *)(pcfg)); + printf("cfg_prm %x %x\n", pcfg->cfg_prm, + (char *)&(pcfg->cfg_prm) - (char *)(pcfg)); + printf("cfg_atw %x %x\n", pcfg->cfg_atw, + (char *)&(pcfg->cfg_atw) - (char *)(pcfg)); + printf("cfg_rec %x %x\n",(long)pcfg->cfg_rec, + (char *)&(pcfg->cfg_rec) - (char *)(pcfg)); + printf("cfg_spt %x %x\n", pcfg->cfg_spt, + (char *)&(pcfg->cfg_spt) - (char *)(pcfg)); + printf("cfg_hds %x %x\n", pcfg->cfg_hds, + (char *)&(pcfg->cfg_hds) - (char *)(pcfg)); + printf("cfg_trk %x %x\n", pcfg->cfg_trk, + (char *)&(pcfg->cfg_trk) - (char *)(pcfg)); + printf("cfg_ilv %x %x\n", pcfg->cfg_ilv, + (char *)&(pcfg->cfg_ilv) - (char *)(pcfg)); + printf("cfg_sof %x %x\n", pcfg->cfg_sof, + (char *)&(pcfg->cfg_sof) - (char *)(pcfg)); + printf("cfg_psm %x %x\n", pcfg->cfg_psm, + (char *)&(pcfg->cfg_psm) - (char *)(pcfg)); + printf("cfg_shd %x %x\n", pcfg->cfg_shd, + (char *)&(pcfg->cfg_shd) - (char *)(pcfg)); + printf("cfg_pcom %x %x\n", pcfg->cfg_pcom, + (char *)&(pcfg->cfg_pcom) - (char *)(pcfg)); + printf("cfg_ssr %x %x\n", pcfg->cfg_ssr, + (char *)&(pcfg->cfg_ssr) - (char *)(pcfg)); + printf("cfg_rwcc %x %x\n", pcfg->cfg_rwcc, + (char *)&(pcfg->cfg_rwcc) - (char *)(pcfg)); + printf("cfg_ecc %x %x\n", pcfg->cfg_ecc, + (char *)&(pcfg->cfg_ecc) - (char *)(pcfg)); + printf("cfg_eatm %x %x\n", pcfg->cfg_eatm, + (char *)&(pcfg->cfg_eatm) - (char *)(pcfg)); + printf("cfg_eprm %x %x\n", pcfg->cfg_eprm, + (char *)&(pcfg->cfg_eprm) - (char *)(pcfg)); + printf("cfg_eatw %x %x\n", pcfg->cfg_eatw, + (char *)&(pcfg->cfg_eatw) - (char *)(pcfg)); + printf("cfg_gpb1 %x %x\n", pcfg->cfg_gpb1, + (char *)&(pcfg->cfg_gpb1) - (char *)(pcfg)); + printf("cfg_gpb2 %x %x\n", pcfg->cfg_gpb2, + (char *)&(pcfg->cfg_gpb2) - (char *)(pcfg)); + printf("cfg_gpb3 %x %x\n", pcfg->cfg_gpb3, + (char *)&(pcfg->cfg_gpb3) - (char *)(pcfg)); + printf("cfg_gpb4 %x %x\n", pcfg->cfg_gpb4, + (char *)&(pcfg->cfg_gpb4) - (char *)(pcfg)); + printf("cfg_ssc %x %x\n", pcfg->cfg_ssc, + (char *)&(pcfg->cfg_ssc) - (char *)(pcfg)); + printf("cfg_runit %x %x\n", pcfg->cfg_runit, + (char *)&(pcfg->cfg_runit) - (char *)(pcfg)); + printf("cfg_rsvc1 %x %x\n", pcfg->cfg_rsvc1, + (char *)&(pcfg->cfg_rsvc1) - (char *)(pcfg)); + printf("cfg_rsvc2 %x %x\n", pcfg->cfg_rsvc2, + (char *)&(pcfg->cfg_rsvc2) - (char *)(pcfg)); +} + +swabvid(pvid) + struct vid *pvid; +{ + M_32_SWAP(pvid->vid_oss); + M_16_SWAP(pvid->vid_osl); + M_16_SWAP(pvid->vid_osa_u); + M_16_SWAP(pvid->vid_osa_l); + M_32_SWAP(pvid->vid_cas); +} + +swabcfg(pcfg) + struct cfg *pcfg; +{ + printf("swapping cfg\n"); + + M_16_SWAP(pcfg->cfg_atm); + M_16_SWAP(pcfg->cfg_prm); + M_16_SWAP(pcfg->cfg_atm); + M_16_SWAP(pcfg->cfg_rec); + M_16_SWAP(pcfg->cfg_trk); + M_16_SWAP(pcfg->cfg_psm); + M_16_SWAP(pcfg->cfg_shd); + M_16_SWAP(pcfg->cfg_pcom); + M_16_SWAP(pcfg->cfg_rwcc); + M_16_SWAP(pcfg->cfg_ecc); + M_16_SWAP(pcfg->cfg_eatm); + M_16_SWAP(pcfg->cfg_eprm); + M_16_SWAP(pcfg->cfg_eatw); + M_16_SWAP(pcfg->cfg_rsvc1); + M_16_SWAP(pcfg->cfg_rsvc2); +} diff --git a/sys/arch/mvme88k/stand/openbsd/sboot/Makefile b/sys/arch/mvme88k/stand/openbsd/sboot/Makefile new file mode 100644 index 00000000000..95b897d90c2 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/sboot/Makefile @@ -0,0 +1,39 @@ +# $Id: Makefile,v 1.1 1997/03/03 19:31:10 rahnds Exp $ + +S= ${.CURDIR}/../../../.. +INCL?= -I${.CURDIR} -I${.CURDIR}/../libsa -I${S}/lib/libsa -I${S} +COPTS?= ${DEFS} ${INCL} + +.include "${S}/arch/${MACHINE}/stand/libsa/Makefile.inc" + +SRCS= sboot.c clock.c etherfun.c if_le.c + +OBJS= ${SRCS:S/.c/.o/g} +CLEANFILES+=XBUG.o XSRT0.o oc_cksum.o sboot.tmp rboot.tmp srec sboot rboot +MDEC_DIR?=/usr/mdec + +all: sboot rboot + +sboot.tmp: XSRT0.o oc_cksum.o ${OBJS} ${LIBSA} + ld -N -s -static -T 0x4000 XSRT0.o ${OBJS} oc_cksum.o -o sboot.tmp ${LIBSA} + +rboot.tmp: XBUG.o XSRT0.o oc_cksum.o ${OBJS} ${LIBSA} + ld -N -s -static -Ttext 0xffa00000 -Tdata 0x4000 XBUG.o XSRT0.o \ + ${OBJS} oc_cksum.o -o rboot.tmp ${LIBSA} + +srec: srec.c + ${CC} ${.CURDIR}/srec.c -o srec + +sboot: sboot.tmp srec + dd ibs=32 skip=1 if=sboot.tmp | ${.OBJDIR}/srec 4 0x4000 sboot > sboot + +rboot: rboot.tmp srec + dd ibs=32 skip=1 if=rboot.tmp | ${.OBJDIR}/srec 4 0x4000 rboot > rboot + +install: + install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + sboot ${DESTDIR}${MDEC_DIR}/sboot + install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + rboot ${DESTDIR}${MDEC_DIR}/rboot + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/openbsd/sboot/XBUG.S b/sys/arch/mvme88k/stand/openbsd/sboot/XBUG.S new file mode 100644 index 00000000000..288f1427b21 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/sboot/XBUG.S @@ -0,0 +1,73 @@ +/* + * Copyright (c) 1995 Theo de Raadt + * + * 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 under OpenBSD by + * Theo de Raadt for Willowglen Singapore. + * 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. + */ + +/* + * Theo sez: I wrote a bootrom for the MVME147 *years* ago. To write + * this ROM I copied a few chunks from the old bootrom, like this piece: + * + * "watch this, the moto bastard struck here, shouldn't have hired people + * from intel I tried to tell them... + * "BOOT" + * offset from baseaddr to entry point. + * offset from baseaddr to first word after checksum + * garbage + * checksum made with CS command + * No need to change any of this unless you try to take our names out + * of there. Ie. don't touch." + */ + + .text +bootlabel: .ascii "BOOT" + .long bootstart-0xffa00000 | for rom install + .long bootlabelend - bootlabel + .asciz "VME147 rboot Copyright (c) 1995 Theo de Raadt" + .align 2 +bootstart: jmp bssclr + .word 0x229c | XXX bitching cksum! +bootlabelend: + .word 0 + + | clear bss and the kernel location +bssclr: movl #_edata,a0 + movl #_end - _edata,d0 +1: clrb a0@+ + subql #1,d0 + bpl 1b + + | rip the data segment from ROM into ram.. + movl #_etext,a2 | start of data + movl #0x4000,a1 | shovel address + movl #_edata - _etext,d0 +1: movb a2@+,a1@+ + subql #1,d0 + bpl 1b + + bra start diff --git a/sys/arch/mvme88k/stand/openbsd/sboot/XSRT0.S b/sys/arch/mvme88k/stand/openbsd/sboot/XSRT0.S new file mode 100644 index 00000000000..805528203f2 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/sboot/XSRT0.S @@ -0,0 +1,71 @@ +/* + * Copyright (c) 1995 Theo de Raadt + * + * 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 under OpenBSD by + * Theo de Raadt for Willowglen Singapore. + * 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. + * + * Copyright (c) 1995 Charles D. Cranor + * 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 Charles D. Cranor. + * 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. + */ + + | start at 0x4000, load at 0xa000, stack at 0x9ff0. + .text + .globl start +start: movb #0,_reboot + jra Ldoit +restart: movb #1,_reboot | fall through + +Ldoit: movl #0x00006ff0,sp + jsr _main + + .globl ___main +___main: rts diff --git a/sys/arch/mvme88k/stand/openbsd/sboot/clock.c b/sys/arch/mvme88k/stand/openbsd/sboot/clock.c new file mode 100644 index 00000000000..ca2467abb9e --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/sboot/clock.c @@ -0,0 +1,122 @@ +/* $Id: clock.c,v 1.1 1997/03/03 19:31:11 rahnds Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 1994 Gordon W. Ross + * Copyright (c) 1993 Adam Glass + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Lawrence Berkeley Laboratory. + * + * 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 University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)clock.c 8.1 (Berkeley) 6/11/93 + */ + +/* + * Clock driver. + */ + +#include <sys/cdefs.h> +#include "sboot.h" +#include "clockreg.h" + +static struct clockreg *clockreg = (struct clockreg *) CLOCK_ADDR; + +/* + * BCD to decimal and decimal to BCD. + */ +#define FROMBCD(x) (((x) >> 4) * 10 + ((x) & 0xf)) +#define TOBCD(x) (((x) / 10 * 16) + ((x) % 10)) + +#define SECDAY (24 * 60 * 60) +#define SECYR (SECDAY * 365) +#define LEAPYEAR(y) (((y) & 3) == 0) + +/* + * This code is defunct after 2068. + * Will Unix still be here then?? + */ +const short dayyr[12] = + {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; + +static u_long +chiptotime(sec, min, hour, day, mon, year) + register int sec, min, hour, day, mon, year; +{ + register int days, yr; + + sec = FROMBCD(sec); + min = FROMBCD(min); + hour = FROMBCD(hour); + day = FROMBCD(day); + mon = FROMBCD(mon); + year = FROMBCD(year) + YEAR0; + if (year < 70) + year = 70; + + /* simple sanity checks */ + if (year < 70 || mon < 1 || mon > 12 || day < 1 || day > 31) + return (0); + days = 0; + for (yr = 70; yr < year; yr++) + days += LEAPYEAR(yr) ? 366 : 365; + days += dayyr[mon - 1] + day - 1; + if (LEAPYEAR(yr) && mon > 2) + days++; + /* now have days since Jan 1, 1970; the rest is easy... */ + return (days * SECDAY + hour * 3600 + min * 60 + sec); +} + +/* + * Set up the system's time, given a `reasonable' time value. + */ +u_long +time() +{ + register struct clockreg *cl = clockreg; + int sec, min, hour, day, mon, year; + + cl->cl_csr |= CLK_READ; /* enable read (stop time) */ + sec = cl->cl_sec; + min = cl->cl_min; + hour = cl->cl_hour; + day = cl->cl_mday; + mon = cl->cl_month; + year = cl->cl_year; + cl->cl_csr &= ~CLK_READ;/* time wears on */ + return (chiptotime(sec, min, hour, day, mon, year)); +} diff --git a/sys/arch/mvme88k/stand/openbsd/sboot/clockreg.h b/sys/arch/mvme88k/stand/openbsd/sboot/clockreg.h new file mode 100644 index 00000000000..7fba3d3a9aa --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/sboot/clockreg.h @@ -0,0 +1,69 @@ +/* $Id: clockreg.h,v 1.1 1997/03/03 19:31:11 rahnds Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Lawrence Berkeley Laboratory. + * + * 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 University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)clockreg.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * Mostek MK48T02 clock. + */ +struct clockreg { + volatile u_char cl_csr; /* control register */ + volatile u_char cl_sec; /* seconds (0..59; BCD) */ + volatile u_char cl_min; /* minutes (0..59; BCD) */ + volatile u_char cl_hour; /* hour (0..23; BCD) */ + volatile u_char cl_wday; /* weekday (1..7) */ + volatile u_char cl_mday; /* day in month (1..31; BCD) */ + volatile u_char cl_month; /* month (1..12; BCD) */ + volatile u_char cl_year; /* year (0..99; BCD) */ +}; + +/* bits in cl_csr */ +#define CLK_WRITE 0x80 /* want to write */ +#define CLK_READ 0x40 /* want to read (freeze clock) */ + +/* + * Sun chose the year `68' as their base count, so that + * cl_year==0 means 1968. + */ +#define YEAR0 68 diff --git a/sys/arch/mvme88k/stand/openbsd/sboot/etherfun.c b/sys/arch/mvme88k/stand/openbsd/sboot/etherfun.c new file mode 100644 index 00000000000..01987b15f4c --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/sboot/etherfun.c @@ -0,0 +1,215 @@ +/* + * + * Copyright (c) 1995 Charles D. Cranor and Seth Widoff + * 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 Charles D. Cranor + * and Seth Widoff. + * 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. + */ +/* etherfun.c */ + +#include <sys/cdefs.h> +#include "sboot.h" +#include "etherfun.h" + +/* Construct and send a rev arp packet */ +void +do_rev_arp() +{ + int i; + + for (i = 0; i < 6; i++) + eh->ether_dhost[i] = 0xff; + + bcopy(myea, eh->ether_shost, 6); + eh->ether_type = ETYPE_RARP; + + rarp->ar_hrd = 1; /* hardware type is 1 */ + rarp->ar_pro = PTYPE_IP; + rarp->ar_hln = 6; /* length of hardware address is 6 bytes */ + rarp->ar_pln = 4; /* length of ip address is 4 byte */ + rarp->ar_op = OPCODE_RARP; + bcopy(myea, rarp->arp_sha, sizeof(myea)); + bcopy(myea, rarp->arp_tha, sizeof(myea)); + for (i = 0; i < 4; i++) + rarp->arp_spa[i] = rarp->arp_tpa[i] = 0x00; + + le_put(buf, 76); +} + +/* Receive and disassemble the rev_arp reply */ +int +get_rev_arp() +{ + le_get(buf, sizeof(buf), 6); + if (eh->ether_type == ETYPE_RARP && rarp->ar_op == OPCODE_REPLY) { + bcopy(rarp->arp_tpa, myip, sizeof(rarp->arp_tpa)); + bcopy(rarp->arp_spa, servip, sizeof(rarp->arp_spa)); + bcopy(rarp->arp_sha, servea, sizeof(rarp->arp_sha)); + return (1); + } + return (0); +} + +/* Try to get a reply to a rev arp request */ +int +rev_arp() +{ + int tries = 0; + while (tries < 5) { + do_rev_arp(); + if (get_rev_arp()) + return (1); + tries++; + } + return (0); +} + +/* + * Send a tftp read request or acknowledgement + * mesgtype 0 is a read request, 1 is an + * acknowledgement + */ +void +do_send_tftp(mesgtype) + int mesgtype; +{ + u_long res, iptmp, lcv; + char *tot; + + if (mesgtype == 0) { + tot = tftp_r + (sizeof(MSG) - 1); + myport = (u_short) time(); + if (myport < 1000) + myport += 1000; + servport = FTP_PORT; /* to start */ + } else { + tot = (char *) tftp_a + 4; + } + + bcopy(servea, eh->ether_dhost, sizeof(servea)); + bcopy(myea, eh->ether_shost, sizeof(myea)); + eh->ether_type = ETYPE_IP; + + iph->ip_v = IP_VERSION; + iph->ip_hl = IP_HLEN; + iph->ip_tos = 0; /* type of service is 0 */ + iph->ip_id = 0; /* id field is 0 */ + iph->ip_off = IP_DF; + iph->ip_ttl = 3; /* time to live is 3 seconds/hops */ + iph->ip_p = IPP_UDP; + bcopy(myip, iph->ip_src, sizeof(myip)); + bcopy(servip, iph->ip_dst, sizeof(servip)); + iph->ip_sum = 0; + iph->ip_len = tot - (char *) iph; + res = oc_cksum(iph, sizeof(struct ip), 0); + iph->ip_sum = 0xffff & ~res; + udph->uh_sport = myport; + udph->uh_dport = servport; + udph->uh_sum = 0; + + if (mesgtype) { + tftp_a->op_code = FTPOP_ACKN; + tftp_a->block = (u_short) (mesgtype); + } else { + bcopy(myip, &iptmp, sizeof(iptmp)); + bcopy(MSG, tftp_r, (sizeof(MSG) - 1)); + for (lcv = 9; lcv >= 2; lcv--) { + tftp_r[lcv] = "0123456789ABCDEF"[iptmp & 0xF]; + + iptmp = iptmp >> 4; + } + } + + udph->uh_ulen = tot - (char *) udph; + + le_put(buf, tot - buf); +} + +/* Attempt to tftp a file and read it into memory */ +int +do_get_file() +{ + int fail = 0, oldlen; + char *loadat = (char *) LOAD_ADDR; + last_ack = 0; + + do_send_tftp(READ); + while (1) { + if (le_get(buf, sizeof(buf), 5) == 0) { + /* timeout occured */ + if (last_ack) + do_send_tftp(last_ack); + else + do_send_tftp(READ); + + fail++; + if (fail > 5) { + printf("\n"); + return (1); + } + } else { + printf("%x \r", tftp->info.block * 512); + if ((eh->ether_type != ETYPE_IP) || (iph->ip_p != IPP_UDP)) { + fail++; + continue; + } + if (servport == FTP_PORT) + servport = udph->uh_sport; + if (tftp->info.op_code == FTPOP_ERR) { + printf("TFTP: Download error %d: %s\n", + tftp->info.block, tftp->data); + return (1); + } + if (tftp->info.block != last_ack + 1) { + /* we received the wrong block */ + if (tftp->info.block < last_ack + 1) { + /* nack whatever we received */ + do_send_tftp(tftp->info.block); + } else { + /* nack the last confirmed block */ + do_send_tftp(last_ack); + } + fail++; + } else {/* we got the right block */ + fail = 0; + last_ack++; + oldlen = udph->uh_ulen; + do_send_tftp(last_ack); + /* printf("bcopy %x %x %d\n", &tftp->data, + * loadat, oldlen - 12); */ + bcopy(&tftp->data, loadat, oldlen - 12); + loadat += oldlen - 12; + if (oldlen < (8 + 4 + 512)) { + printf("\n"); + return (0); + } + } + } + } + printf("\n"); + return (0); +} diff --git a/sys/arch/mvme88k/stand/openbsd/sboot/etherfun.h b/sys/arch/mvme88k/stand/openbsd/sboot/etherfun.h new file mode 100644 index 00000000000..64170e05fd9 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/sboot/etherfun.h @@ -0,0 +1,124 @@ +/* + * + * Copyright (c) 1995 Charles D. Cranor and Seth Widoff + * 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 Charles D. Cranor + * and Seth Widoff. + * 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. + */ +/* etherfun.h */ + +/* constants */ +/* ether header */ +#define ETYPE_RARP 0x8035 /* ethertype is RARP */ +#define ETYPE_IP 0x800 /* ethertype is IP */ + +/* rev arp */ +#define PTYPE_IP 0x800 /* Protocol type is IP */ +#define OPCODE_RARP 3 /* Optype is REVARP request */ +#define OPCODE_REPLY 4 /* Optype is REVARP reply */ + +/* ip header */ +#define IPP_UDP 17 /* IP Protocol is UDP */ +#define IP_VERSION 4 /* IP version number */ +#define IP_HLEN 5 /* IP header length is a fixed 50 bytes */ +#define N 1536 + +/* tftp header */ +#define FTPOP_ACKN 4 /* Opcode is acknowledge */ +#define FTPOP_ERR 5 /* Opcode is Error */ +#define FTP_PORT 69 /* Standard TFTP port number */ +#define MSG "\0\1xxxxxxxx.mvme68k\0octet\0" /* implicit NULL */ + +/* data structures */ + +struct ether_header { + u_char ether_dhost[6]; + u_char ether_shost[6]; + u_short ether_type; +}; + +struct ether_arp { + u_short ar_hrd; /* format of hardware address */ + u_short ar_pro; /* format of protocol address */ + u_char ar_hln; /* length of hardware address */ + u_char ar_pln; /* length of protocol address */ + u_short ar_op; + u_char arp_sha[6]; /* sender hardware address */ + u_char arp_spa[4]; /* sender protocol address */ + u_char arp_tha[6]; /* target hardware address */ + u_char arp_tpa[4]; /* target protocol address */ +}; + +struct ip { + u_char ip_v:4, /* version */ + ip_hl:4; /* header length */ + u_char ip_tos; /* type of service */ + short ip_len; /* total length */ + u_short ip_id; /* identification */ + short ip_off; /* fragment offset field */ +#define IP_DF 0x4000 /* dont fragment flag */ +#define IP_MF 0x2000 /* more fragments flag */ +#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ + u_char ip_ttl; /* time to live */ + u_char ip_p; /* protocol */ + u_short ip_sum; /* checksum */ + u_char ip_src[4]; + u_char ip_dst[4]; /* source and dest address */ +}; + +struct udp { + u_short uh_sport; + u_short uh_dport; + short uh_ulen; + u_short uh_sum; +}; + +struct tftph { + u_short op_code; + u_short block; +}; + +struct tftphr { + struct tftph info; + char data[1]; +}; + +/* globals */ +int last_ack; +char buf[N]; +struct ether_header *eh = (struct ether_header *)buf; +struct ether_arp *rarp = (struct ether_arp *) + (buf + sizeof(struct ether_header)); +struct ip *iph = (struct ip *)(buf + sizeof(struct ether_header)); +struct udp *udph = (struct udp *) + (buf + sizeof(struct ether_header) + sizeof(struct ip)); +char *tftp_r = buf + sizeof(struct ether_header) + sizeof(struct ip) + + sizeof(struct udp); +struct tftph *tftp_a = (struct tftph *)(buf + sizeof(struct ether_header) + + sizeof(struct ip) + sizeof(struct udp)); +struct tftphr *tftp = (struct tftphr *)(buf + sizeof(struct ether_header) + + sizeof(struct ip) + sizeof(struct udp)); diff --git a/sys/arch/mvme88k/stand/openbsd/sboot/if_le.c b/sys/arch/mvme88k/stand/openbsd/sboot/if_le.c new file mode 100644 index 00000000000..7fbcf60f69a --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/sboot/if_le.c @@ -0,0 +1,356 @@ +/* $Id: if_le.c,v 1.1 1997/03/03 19:31:11 rahnds Exp $ */ + +/* + * Copyright (c) 1995 Theo de Raadt + * + * 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 under OpenBSD by + * Theo de Raadt for Willowglen Singapore. + * 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. + * + * Copyright (c) 1993 Adam Glass + * 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 Adam Glass. + * 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 Adam Glass ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +#include "sboot.h" +#include "if_lereg.h" + +struct { + struct lereg1 *sc_r1; /* LANCE registers */ + struct lereg2 *sc_r2; /* RAM */ + int next_rmd; + int next_tmd; +} le_softc; + +void +le_error(str, ler1) + char *str; + struct lereg1 *ler1; +{ + /* ler1->ler1_rap = LE_CSRO done in caller */ + if (ler1->ler1_rdp & LE_C0_BABL) { + printf("le0: been babbling, found by '%s'\n", str); + callrom(); + } + if (ler1->ler1_rdp & LE_C0_CERR) { + ler1->ler1_rdp = LE_C0_CERR; + } + if (ler1->ler1_rdp & LE_C0_MISS) { + ler1->ler1_rdp = LE_C0_MISS; + } + if (ler1->ler1_rdp & LE_C0_MERR) { + printf("le0: memory error in '%s'\n", str); + callrom(); + } +} + +void +le_reset(myea) + u_char *myea; +{ + struct lereg1 *ler1 = le_softc.sc_r1; + struct lereg2 *ler2 = le_softc.sc_r2; + unsigned int a; + int timo = 100000, stat, i; + + ler1->ler1_rap = LE_CSR0; + ler1->ler1_rdp = LE_C0_STOP; /* do nothing until we are finished */ + + bzero(ler2, sizeof(*ler2)); + + ler2->ler2_mode = LE_MODE_NORMAL; + ler2->ler2_padr[0] = myea[1]; + ler2->ler2_padr[1] = myea[0]; + ler2->ler2_padr[2] = myea[3]; + ler2->ler2_padr[3] = myea[2]; + ler2->ler2_padr[4] = myea[5]; + ler2->ler2_padr[5] = myea[4]; + + + ler2->ler2_ladrf0 = 0; + ler2->ler2_ladrf1 = 0; + + a = (u_int) ler2->ler2_rmd; + ler2->ler2_rlen = LE_RLEN | (a >> 16); + ler2->ler2_rdra = a & LE_ADDR_LOW_MASK; + + a = (u_int) ler2->ler2_tmd; + ler2->ler2_tlen = LE_TLEN | (a >> 16); + ler2->ler2_tdra = a & LE_ADDR_LOW_MASK; + + ler1->ler1_rap = LE_CSR1; + a = (u_int) ler2; + ler1->ler1_rdp = a & LE_ADDR_LOW_MASK; + ler1->ler1_rap = LE_CSR2; + ler1->ler1_rdp = a >> 16; + + for (i = 0; i < LERBUF; i++) { + a = (u_int) & ler2->ler2_rbuf[i]; + ler2->ler2_rmd[i].rmd0 = a & LE_ADDR_LOW_MASK; + ler2->ler2_rmd[i].rmd1_bits = LE_R1_OWN; + ler2->ler2_rmd[i].rmd1_hadr = a >> 16; + ler2->ler2_rmd[i].rmd2 = -LEMTU; + ler2->ler2_rmd[i].rmd3 = 0; + } + for (i = 0; i < LETBUF; i++) { + a = (u_int) & ler2->ler2_tbuf[i]; + ler2->ler2_tmd[i].tmd0 = a & LE_ADDR_LOW_MASK; + ler2->ler2_tmd[i].tmd1_bits = 0; + ler2->ler2_tmd[i].tmd1_hadr = a >> 16; + ler2->ler2_tmd[i].tmd2 = 0; + ler2->ler2_tmd[i].tmd3 = 0; + } + + ler1->ler1_rap = LE_CSR3; + ler1->ler1_rdp = LE_C3_BSWP; + + ler1->ler1_rap = LE_CSR0; + ler1->ler1_rdp = LE_C0_INIT; + do { + if (--timo == 0) { + printf("le0: init timeout, stat = 0x%x\n", stat); + break; + } + stat = ler1->ler1_rdp; + } while ((stat & LE_C0_IDON) == 0); + + ler1->ler1_rdp = LE_C0_IDON; + le_softc.next_rmd = 0; + le_softc.next_tmd = 0; + ler1->ler1_rap = LE_CSR0; + ler1->ler1_rdp = LE_C0_STRT; +} + +int +le_poll(pkt, len) + void *pkt; + int len; +{ + struct lereg1 *ler1 = le_softc.sc_r1; + struct lereg2 *ler2 = le_softc.sc_r2; + unsigned int a; + int length; + struct lermd *rmd; + + ler1->ler1_rap = LE_CSR0; + if ((ler1->ler1_rdp & LE_C0_RINT) != 0) + ler1->ler1_rdp = LE_C0_RINT; + rmd = &ler2->ler2_rmd[le_softc.next_rmd]; + if (rmd->rmd1_bits & LE_R1_OWN) { + return (0); + } + if (ler1->ler1_rdp & LE_C0_ERR) + le_error("le_poll", ler1); + if (rmd->rmd1_bits & LE_R1_ERR) { + printf("le0_poll: rmd status 0x%x\n", rmd->rmd1_bits); + length = 0; + goto cleanup; + } + if ((rmd->rmd1_bits & (LE_R1_STP | LE_R1_ENP)) != (LE_R1_STP | LE_R1_ENP)) { + printf("le_poll: chained packet\n"); + callrom(); + } + length = rmd->rmd3; + if (length >= LEMTU) { + length = 0; + printf("csr0 when bad things happen: %x\n", ler1->ler1_rdp); + callrom(); + goto cleanup; + } + if (!length) + goto cleanup; + length -= 4; + if (length > 0) + bcopy((char *) &ler2->ler2_rbuf[le_softc.next_rmd], pkt, length); + +cleanup: + a = (u_int) & ler2->ler2_rbuf[le_softc.next_rmd]; + rmd->rmd0 = a & LE_ADDR_LOW_MASK; + rmd->rmd1_hadr = a >> 16; + rmd->rmd2 = -LEMTU; + le_softc.next_rmd = + (le_softc.next_rmd == (LERBUF - 1)) ? 0 : (le_softc.next_rmd + 1); + rmd->rmd1_bits = LE_R1_OWN; + return length; +} + +int +le_put(pkt, len) + u_char *pkt; + size_t len; +{ + struct lereg1 *ler1 = le_softc.sc_r1; + struct lereg2 *ler2 = le_softc.sc_r2; + struct letmd *tmd; + int timo = 100000, stat, i; + unsigned int a; + + ler1->ler1_rap = LE_CSR0; + if (ler1->ler1_rdp & LE_C0_ERR) + le_error("le_put(way before xmit)", ler1); + tmd = &ler2->ler2_tmd[le_softc.next_tmd]; + while (tmd->tmd1_bits & LE_T1_OWN) { + printf("le0: output buffer busy\n"); + } + bcopy(pkt, (char *) ler2->ler2_tbuf[le_softc.next_tmd], len); + if (len < 64) + tmd->tmd2 = -64; + else + tmd->tmd2 = -len; + tmd->tmd3 = 0; + if (ler1->ler1_rdp & LE_C0_ERR) + le_error("le_put(before xmit)", ler1); + tmd->tmd1_bits = LE_T1_STP | LE_T1_ENP | LE_T1_OWN; + a = (u_int) & ler2->ler2_tbuf[le_softc.next_tmd]; + tmd->tmd0 = a & LE_ADDR_LOW_MASK; + tmd->tmd1_hadr = a >> 16; + ler1->ler1_rdp = LE_C0_TDMD; + if (ler1->ler1_rdp & LE_C0_ERR) + le_error("le_put(after xmit)", ler1); + do { + if (--timo == 0) { + printf("le0: transmit timeout, stat = 0x%x\n", + stat); + if (ler1->ler1_rdp & LE_C0_ERR) + le_error("le_put(timeout)", ler1); + break; + } + stat = ler1->ler1_rdp; + } while ((stat & LE_C0_TINT) == 0); + ler1->ler1_rdp = LE_C0_TINT; + if (ler1->ler1_rdp & LE_C0_ERR) { + if ((ler1->ler1_rdp & (LE_C0_BABL | LE_C0_CERR | LE_C0_MISS | LE_C0_MERR)) != + LE_C0_CERR) + printf("le_put: xmit error, buf %d\n", le_softc.next_tmd); + le_error("le_put(xmit error)", ler1); + } + le_softc.next_tmd = 0; +/* (le_softc.next_tmd == (LETBUF - 1)) ? 0 : le_softc.next_tmd + 1;*/ + if (tmd->tmd1_bits & LE_T1_ERR) { + printf("le0: transmit error, error = 0x%x\n", + tmd->tmd3); + return -1; + } + return len; +} + +int +le_get(pkt, len, timeout) + u_char *pkt; + size_t len; + u_long timeout; +{ + int cc; + int now, then; + int stopat = time() + timeout; + then = 0; + + cc = 0; + while ((now = time()) < stopat && !cc) { + cc = le_poll(pkt, len); + if (then != now) { +#ifdef LE_DEBUG + printf("%d \r", stopat - now); +#endif + then = now; + } + if (cc && (pkt[0] != myea[0] || pkt[1] != myea[1] || + pkt[2] != myea[2] || pkt[3] != myea[3] || + pkt[4] != myea[4] || pkt[5] != myea[5])) { + cc = 0; /* ignore broadcast / multicast */ +#ifdef LE_DEBUG + printf("reject (%d sec left)\n", stopat - now); +#endif + } + } +#ifdef LE_DEBUG + printf("\n"); +#endif + return cc; +} + +void +le_init() +{ + caddr_t addr; + int *ea = (int *) LANCE_ADDR; + u_long *eram = (u_long *) ERAM_ADDR; + u_long e = *ea; + if ((e & 0x2fffff00) == 0x2fffff00) { + printf("ERROR: ethernet address not set! Use LSAD.\n"); + callrom(); + } + myea[0] = 0x08; + myea[1] = 0x00; + myea[2] = 0x3e; + e = e >> 8; + myea[5] = e & 0xff; + e = e >> 8; + myea[4] = e & 0xff; + e = e >> 8; + myea[3] = e; + printf("le0: ethernet address: %x:%x:%x:%x:%x:%x\n", + myea[0], myea[1], myea[2], myea[3], myea[4], myea[5]); + bzero(&le_softc, sizeof(le_softc)); + le_softc.sc_r1 = (struct lereg1 *) LANCE_REG_ADDR; + le_softc.sc_r2 = (struct lereg2 *) (*eram - (1024 * 1024)); + le_reset(myea); +} + +void +le_end() +{ + struct lereg1 *ler1 = le_softc.sc_r1; + + ler1->ler1_rap = LE_CSR0; + ler1->ler1_rdp = LE_C0_STOP; +} diff --git a/sys/arch/mvme88k/stand/openbsd/sboot/if_lereg.h b/sys/arch/mvme88k/stand/openbsd/sboot/if_lereg.h new file mode 100644 index 00000000000..d45f428bb80 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/sboot/if_lereg.h @@ -0,0 +1,176 @@ +/* $Id: if_lereg.h,v 1.1 1997/03/03 19:31:11 rahnds Exp $ */ + +/*- + * Copyright (c) 1982, 1992, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)if_lereg.h 8.2 (Berkeley) 10/30/93 + */ + +#define LEMTU 1518 +#define LEMINSIZE 60 /* should be 64 if mode DTCR is set */ +#define LERBUF 8 +#define LERBUFLOG2 3 +#define LE_RLEN (LERBUFLOG2 << 13) +#define LETBUF 1 +#define LETBUFLOG2 0 +#define LE_TLEN (LETBUFLOG2 << 13) + +/* Local Area Network Controller for Ethernet (LANCE) registers */ +struct lereg1 { + volatile u_short ler1_rdp; /* register data port */ + volatile u_short ler1_rap; /* register address port */ +}; + +/* register addresses */ +#define LE_CSR0 0 /* Control and status register */ +#define LE_CSR1 1 /* low address of init block */ +#define LE_CSR2 2 /* high address of init block */ +#define LE_CSR3 3 /* Bus master and control */ + +/* Control and status register 0 (csr0) */ +#define LE_C0_ERR 0x8000 /* error summary */ +#define LE_C0_BABL 0x4000 /* transmitter timeout error */ +#define LE_C0_CERR 0x2000 /* collision */ +#define LE_C0_MISS 0x1000 /* missed a packet */ +#define LE_C0_MERR 0x0800 /* memory error */ +#define LE_C0_RINT 0x0400 /* receiver interrupt */ +#define LE_C0_TINT 0x0200 /* transmitter interrupt */ +#define LE_C0_IDON 0x0100 /* initalization done */ +#define LE_C0_INTR 0x0080 /* interrupt condition */ +#define LE_C0_INEA 0x0040 /* interrupt enable */ +#define LE_C0_RXON 0x0020 /* receiver on */ +#define LE_C0_TXON 0x0010 /* transmitter on */ +#define LE_C0_TDMD 0x0008 /* transmit demand */ +#define LE_C0_STOP 0x0004 /* disable all external activity */ +#define LE_C0_STRT 0x0002 /* enable external activity */ +#define LE_C0_INIT 0x0001 /* begin initalization */ + +#define LE_C0_BITS \ + "\20\20ERR\17BABL\16CERR\15MISS\14MERR\13RINT\ +\12TINT\11IDON\10INTR\07INEA\06RXON\05TXON\04TDMD\03STOP\02STRT\01INIT" + +/* Control and status register 3 (csr3) */ +#define LE_C3_BSWP 0x4 /* byte swap */ +#define LE_C3_ACON 0x2 /* ALE control, eh? */ +#define LE_C3_BCON 0x1 /* byte control */ +/* + * Current size is 13,758 bytes with 8 x 1518 receive buffers and + * 1 x 1518 transmit buffer. + */ +struct lereg2 { + /* initialization block */ + volatile u_short ler2_mode; /* mode */ + volatile u_char ler2_padr[6]; /* physical address */ +#ifdef new_code + volatile u_short ler2_ladrf[4]; /* logical address filter */ +#else + volatile u_long ler2_ladrf0; /* logical address filter */ + volatile u_long ler2_ladrf1; /* logical address filter */ +#endif + volatile u_short ler2_rdra; /* receive descriptor addr */ + volatile u_short ler2_rlen; /* rda high and ring size */ + volatile u_short ler2_tdra; /* transmit descriptor addr */ + volatile u_short ler2_tlen; /* tda high and ring size */ + /* receive message descriptors. bits/hadr are byte order dependent. */ + struct lermd { + volatile u_short rmd0; /* low address of packet */ + volatile u_char rmd1_bits; /* descriptor bits */ + volatile u_char rmd1_hadr; /* high address of packet */ + volatile short rmd2; /* buffer byte count */ + volatile u_short rmd3; /* message byte count */ + } ler2_rmd[LERBUF]; + /* transmit message descriptors */ + struct letmd { + volatile u_short tmd0; /* low address of packet */ + volatile u_char tmd1_bits; /* descriptor bits */ + volatile u_char tmd1_hadr; /* high address of packet */ + volatile short tmd2; /* buffer byte count */ + volatile u_short tmd3; /* transmit error bits */ + } ler2_tmd[LETBUF]; + volatile char ler2_rbuf[LERBUF][LEMTU]; + volatile char ler2_tbuf[LETBUF][LEMTU]; +}; + +/* Initialzation block (mode) */ +#define LE_MODE_PROM 0x8000 /* promiscuous mode */ +/* 0x7f80 reserved, must be zero */ +#define LE_MODE_INTL 0x0040 /* internal loopback */ +#define LE_MODE_DRTY 0x0020 /* disable retry */ +#define LE_MODE_COLL 0x0010 /* force a collision */ +#define LE_MODE_DTCR 0x0008 /* disable transmit CRC */ +#define LE_MODE_LOOP 0x0004 /* loopback mode */ +#define LE_MODE_DTX 0x0002 /* disable transmitter */ +#define LE_MODE_DRX 0x0001 /* disable receiver */ +#define LE_MODE_NORMAL 0 /* none of the above */ + + +/* Receive message descriptor 1 (rmd1_bits) */ +#define LE_R1_OWN 0x80 /* LANCE owns the packet */ +#define LE_R1_ERR 0x40 /* error summary */ +#define LE_R1_FRAM 0x20 /* framing error */ +#define LE_R1_OFLO 0x10 /* overflow error */ +#define LE_R1_CRC 0x08 /* CRC error */ +#define LE_R1_BUFF 0x04 /* buffer error */ +#define LE_R1_STP 0x02 /* start of packet */ +#define LE_R1_ENP 0x01 /* end of packet */ + +#define LE_R1_BITS \ + "\20\10OWN\7ERR\6FRAM\5OFLO\4CRC\3BUFF\2STP\1ENP" + +/* Transmit message descriptor 1 (tmd1_bits) */ +#define LE_T1_OWN 0x80 /* LANCE owns the packet */ +#define LE_T1_ERR 0x40 /* error summary */ +#define LE_T1_MORE 0x10 /* multiple collisions */ +#define LE_T1_ONE 0x08 /* single collision */ +#define LE_T1_DEF 0x04 /* defferred transmit */ +#define LE_T1_STP 0x02 /* start of packet */ +#define LE_T1_ENP 0x01 /* end of packet */ + +#define LE_T1_BITS \ + "\20\10OWN\7ERR\6RES\5MORE\4ONE\3DEF\2STP\1ENP" + +/* Transmit message descriptor 3 (tmd3) */ +#define LE_T3_BUFF 0x8000 /* buffer error */ +#define LE_T3_UFLO 0x4000 /* underflow error */ +#define LE_T3_LCOL 0x1000 /* late collision */ +#define LE_T3_LCAR 0x0800 /* loss of carrier */ +#define LE_T3_RTRY 0x0400 /* retry error */ +#define LE_T3_TDR_MASK 0x03ff /* time domain reflectometry counter */ + +#define LE_XMD2_ONES 0xf000 + +#define LE_T3_BITS \ + "\20\20BUFF\17UFLO\16RES\15LCOL\14LCAR\13RTRY" + + +#define LE_ADDR_LOW_MASK (0xffff) + diff --git a/sys/arch/mvme88k/stand/openbsd/sboot/oc_cksum.S b/sys/arch/mvme88k/stand/openbsd/sboot/oc_cksum.S new file mode 100644 index 00000000000..8f0ffe61791 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/sboot/oc_cksum.S @@ -0,0 +1,187 @@ +| $Id: oc_cksum.S,v 1.1 1997/03/03 19:31:11 rahnds Exp $ + +| Copyright (c) 1988 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. All advertising materials mentioning features or use of this software +| must display the following acknowledgement: +| This product includes software developed by the University of +| California, Berkeley and its contributors. +| 4. 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. +| +| @(#)oc_cksum.s 7.2 (Berkeley) 11/3/90 +| +| +| oc_cksum: ones complement 16 bit checksum for MC68020. +| +| oc_cksum (buffer, count, strtval) +| +| Do a 16 bit ones complement sum of 'count' bytes from 'buffer'. +| 'strtval' is the starting value of the sum (usually zero). +| +| It simplifies life in in_cksum if strtval can be >= 2^16. +| This routine will work as long as strtval is < 2^31. +| +| Performance +| ----------- +| This routine is intended for MC 68020s but should also work +| for 68030s. It (deliberately) does not worry about the alignment +| of the buffer so will only work on a 68010 if the buffer is +| aligned on an even address. (Also, a routine written to use +| 68010 "loop mode" would almost certainly be faster than this +| code on a 68010). +| +| We do not worry about alignment because this routine is frequently +| called with small counts: 20 bytes for IP header checksums and 40 +| bytes for TCP ack checksums. For these small counts, testing for +| bad alignment adds ~10% to the per-call cost. Since, by the nature +| of the kernel allocator, the data we are called with is almost +| always longword aligned, there is no benefit to this added cost +| and we are better off letting the loop take a big performance hit +| in the rare cases where we are handed an unaligned buffer. +| +| Loop unrolling constants of 2, 4, 8, 16, 32 and 64 times were +| tested on random data on four different types of processors (see +| list below -- 64 was the largest unrolling because anything more +| overflows the 68020 Icache). On all the processors, the +| throughput asymptote was located between 8 and 16 (closer to 8). +| However, 16 was substantially better than 8 for small counts. +| (It is clear why this happens for a count of 40: unroll-8 pays a +| loop branch cost and unroll-16 does not. But the tests also showed +| that 16 was better than 8 for a count of 20. It is not obvious to +| me why.) So, since 16 was good for both large and small counts, +| the loop below is unrolled 16 times. +| +| The processors tested and their average time to checksum 1024 bytes +| of random data were: +| Sun 3/50 (15MHz) 190 us/KB +| Sun 3/180 (16.6MHz) 175 us/KB +| Sun 3/60 (20MHz) 134 us/KB +| Sun 3/280 (25MHz) 95 us/KB +| +| The cost of calling this routine was typically 10% of the per- +| kilobyte cost. E.g., checksumming zero bytes on a 3/60 cost 9us +| and each additional byte cost 125ns. With the high fixed cost, +| it would clearly be a gain to "inline" this routine -- the +| subroutine call adds 400% overhead to an IP header checksum. +| However, in absolute terms, inlining would only gain 10us per +| packet -- a 1% effect for a 1ms ethernet packet. This is not +| enough gain to be worth the effort. + +#include <machine/asm.h> + + .text + + .text; .even; .globl _oc_cksum; _oc_cksum: + movl sp@(4),a0 | get buffer ptr + movl sp@(8),d1 | get byte count + movl sp@(12),d0 | get starting value + movl d2,sp@- | free a reg + + | test for possible 1, 2 or 3 bytes of excess at end + | of buffer. The usual case is no excess (the usual + | case is header checksums) so we give that the faster + | 'not taken' leg of the compare. (We do the excess + | first because we are about the trash the low order + | bits of the count in d1.) + + btst #0,d1 + jne L5 | if one or three bytes excess + btst #1,d1 + jne L7 | if two bytes excess +L1: + movl d1,d2 + lsrl #6,d1 | make cnt into # of 64 byte chunks + andl #0x3c,d2 | then find fractions of a chunk + negl d2 + andb #0xf,cc | clear X + jmp pc@(L3-.-2:b,d2) +L2: + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 +L3: + dbra d1,L2 | (NB- dbra does not affect X) + + movl d0,d1 | fold 32 bit sum to 16 bits + swap d1 | (NB- swap does not affect X) + addxw d1,d0 + jcc L4 + addw #1,d0 +L4: + andl #0xffff,d0 + movl sp@+,d2 + rts + +L5: | deal with 1 or 3 excess bytes at the end of the buffer. + btst #1,d1 + jeq L6 | if 1 excess + + | 3 bytes excess + clrl d2 + movw a0@(-3,d1:l),d2 | add in last full word then drop + addl d2,d0 | through to pick up last byte + +L6: | 1 byte excess + clrl d2 + movb a0@(-1,d1:l),d2 + lsll #8,d2 + addl d2,d0 + jra L1 + +L7: | 2 bytes excess + clrl d2 + movw a0@(-2,d1:l),d2 + addl d2,d0 + jra L1 diff --git a/sys/arch/mvme88k/stand/openbsd/sboot/rboot b/sys/arch/mvme88k/stand/openbsd/sboot/rboot new file mode 100644 index 00000000000..e3a83b1327e --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/sboot/rboot @@ -0,0 +1,204 @@ +S00A0000000072626F6F74CF +S32500004000424F4F540000003C00000044564D453134372072626F6F7420436F70797269671F +S325000040206874202863292031393935205468656F2064652052616164740000004EF9FFA047 +S325000040400046229C0000207C000040207000421853806A00FFFA247CFFA01908227C00005C +S325000040604000700012DA53806A00FFFA6000000213FC00000000463C600813FC00010000FD +S32500004080463C2E7C00006FF04EB9FFA000B84E750A73626F6F743A204D564D4531343720F2 +S325000040A0626F6F7473747261702070726F6772616D0A003E3E3E20004E56FF802F0A61FF64 +S325000040C0FFFFFFCE1D7C0030FF80487AFFC461FF0000159E584F45EEFF80487AFFD761FFDE +S325000040E00000158E2F0A61FF000013F82F0A610001CA504F584F60E24E714E5600004E4F86 +S3250000410000634E5E4E754D7920697020616464726573732069733A2025642E25642E2564B5 +S325000041202E25640A0053657276657220697020616464726573732069733A2025642E2564AC +S325000041402E25642E25640A004661696C65642E0A0065786974696E6720746F20524F4D0A51 +S3250000416000446F776E6C6F6164204661696C65640A00446F776E6C6F61642077617320616E +S325000041802073756363657373210A00636C69656E7420495020616464726573732025642EC0 +S325000041A025642E25642E25640A0073657276657220495020616464726573732025642E25A6 +S325000041C0642E25642E25640A005245564152503A204661696C65642E0A00726563656976D8 +S325000041E06564207365636F6E6461727920626F6F742070726F6772616D2E0A0062736400AB +S3250000420076616C696420636F6D6D616E64730A0061202D2073656E64206120524152500AB4 +S325000042200062202D20626F6F74207468652073797374656D0A0071202D2065786974207499 +S325000042406F20524F4D0A0066202D206674702074686520626F6F742066696C650A0067202E +S325000042602D20657865637574652074686520626F6F742066696C650A0068202D2068656CEB +S32500004280700A0069202D20696E6974204C414E434520656E657420636869700A0073626FB3 +S325000042A06F743A2025733A20556E6B6E6F776E20636F6D6D616E640A00004E5600002F0BF2 +S325000042C02F0A246E000810120C000067670001F26E2E0C000062670000F86E180C000061BA +S325000042E067364A00670001EC0C00003F67000192600001D40C000066670000AE600001C853 +S325000043000C000069670001B26D0001760C00007167000084600001B061FF0000054C4A8030 +S325000043206766428010390000465F2F00428010390000465E2F00428010390000465D2F0010 +S32500004340428010390000465C2F00487AFDBA45F9FFA0166E4E92428010390000463B2F0006 +S32500004360428010390000463A2F0042801039000046392F0042801039000046382F00487A4A +S32500004380FDA54E926000014C487AFDBE61FF000012E06000013E487AFDB961FF000012D2BE +S325000043A06100FD586000012C61FF000007127201B280660E487AFDAB61FF000012B4600032 +S325000043C00112487AFDAE61FF000012A66000010461FF00000F8061FF0000048E4A80660EBB +S325000043E0487AFDE761FF00001288600000E6428010390000465F2F00428010390000465E43 +S325000044002F00428010390000465D2F00428010390000465C2F00487AFD7347F9FFA0166E19 +S325000044204E93428010390000463B2F00428010390000463A2F0042801039000046392F0067 +S3250000444042801039000046382F00487AFD5E4E93DEFC002861FF000006667201B2806608BF +S32500004460487AFCFF4E93606A487AFD7061FF00001200584F524A4A12664645FAFD80604086 +S32500004480487AFD7E45F9FFA0166E4E92487AFD824E92487AFD8D4E92487AFD9C4E92487A4E +S325000044A0FDA74E92487AFDB84E92487AFDCD4E92487AFDD14E92601A61FF00000E9860124D +S325000044C02F0A613C600C2F0A487AFDD361FF000011A0246EFFF8266EFFFC4E5E4E756A7552 +S325000044E06D70696E6720746F20626F6F742070726F6772616D20617420307825782E0A001A +S325000045004E56000048E7003C246E00083A7C70002F0D487AFFCA61FF0000115642804281B3 +S32500004520264A2F0A61FF0000108ED5C0284A4ED54CEE3C00FFF04E5E4E7500000000001FB1 +S32500004540003B005A0078009700B500D400F301110130014E4E56000048E73F30266E0008C5 +S325000045602C2E000C2A2E0010282E0014262E0018242E001C200BE880244045F20C00200ABF +S32500004580720F2E0BC287244147F20A002006E880244045F20C00200A720FC286244145F2A6 +S325000045A00A002C0A2005E880244045F20C00200A720FC285244145F20A002A0A2004E88029 +S325000045C0244045F20C00200A720FC284244145F20A00280A2003E880244045F20C00200A09 +S325000045E0720FC283244145F20A00260A2002E880720FC282244045F20C00200A244145F25D +S325000046000A44240A7E45BE826D027446200353807E0BBE80650A200453807E1EBE80640487 +S325000046204280607293C97046B4806F1C307C016E223C0000016DE8C007826604D3C8600290 +S32500004640D3C15280B4806EEE41FAFEF030703A00D1C443F098FFE8C0078266087E02BE839C +S325000046606C02524943F19A0020092200E98192802401E9829481EF822005E7809085EB8074 +S32500004680D085E9802042D1C02006E980908641F00C002008D08B4CEE0CFCFFE04E5E4E756E +S325000046A04E56000048E73E0020790000400010100000004010801C2800011A280002182851 +S325000046C000031628000514280006122800071010020000BF108042A71F41000342A71F4204 +S325000046E0000342A71F43000342A71F44000342A71F45000342A71F4600036100FE584CEE82 +S32500004700007CFFEC4E5E4E754E5600002F0A428020790000400411BC00FF08005280720524 +S32500004720B2806CEC487800062239000040045C812F0148790000465445F9FFA015D04E927A +S32500004740207900004004317C8035000C20790000400830BC0001317C08000002117C0006F0 +S325000047600004207900004008117C00040005207900004008317C0003000648780006223900 +S325000047800000400850812F014879000046544E92487800067212D2B9000040082F01487981 +S325000047A0000046544E924280DEFC0024207900004008423008184230080E52807203B28045 +S325000047C06CEA4878004C48790000402861FF00000910246EFFFC4E5E4E754E5600002F0AF6 +S325000047E0487800064878060048790000402861FF00000A6E207900004004504F584F0C688F +S325000048008035000C66562079000040080C680004000666484878000448790000465C721857 +S32500004820D2882F0145F9FFA015D04E9248780004487900004638720ED2B9000040082F01C0 +S325000048404E924878000648790000463022390000400850812F014E92700160024280246ECA +S32500004860FFFC4E5E4E754E5600002F0242826100FE986100FF664A8067047001600A52828E +S325000048807204B2826CE84280242EFFFC4E5E4E75000178787878787878782E6D766D6536BC +S325000048A0386B006F6374657400003031323334353637383941424344454600004E56FFFCEF +S325000048C048E73038242E0008663228790000401447EC001961FFFFFFFDCA33C0000046406A +S325000048E00C7903E7000046406208067903E80000464033FC00450000462C60082679000076 +S325000049004018584B487800062F390000400448790000463045F9FFA015D04E924878000685 +S325000049202639000040045C832F034879000046544E92207900004004317C0800000C20794B +S325000049400000400C7604EFD0300420790000400C7605EFD0310420790000400C42280001F4 +S3250000496020790000400C42680004317C40000006117C0003000820790000400C117C001190 +S32500004980000948780004760CD6B90000400C2F0348790000465C4E92DEFC00202EBC00008E +S325000049A000047610D6B90000400C2F034879000046384E9220790000400C4268000A384B1F +S325000049C098F90000400E314C000242A7487800142F0861FF00000A5C20790000400C46404E +S325000049E03140000A20790000401030B90000464031790000462C000242680006DEFC00181E +S32500004A004A82671020790000401830BC000431420002605448780004486EFFFC487900000D +S32500004A20465C45F9FFA015D04E92487800192F3900004014487AFE5A4E927209DEFC001830 +S32500004A4043FAFE68207900004014700FC0AEFFFC11B108001800202EFFFCE8882D40FFFCD5 +S32500004A6053817601B68165DC207900004010384B98F900004012314C000497FC00004028A2 +S32500004A802F0B48790000402861FF000006544CEE1C0CFFE84E5E4E750A002578200D005413 +S32500004AA04654503A20446F776E6C6F6164206572726F722025643A2025730A004E560000E1 +S32500004AC048E73C304282283C0000700042B90000462842A76100FDE6584F428348780005D6 +S32500004AE04878060048790000402861FF00000772504F584F4A8066304AB900004628670862 +S32500004B002F3900004628600242A76100FDB0584F52827A05BA826CC4487AFF7E61FF00005B +S32500004B200B5070016000010020790000401C3628000220037A09EBA02F00487AFF5E61FF0E +S32500004B4000000B2E207900004004504F0C680800000C667820790000400C0C280011000901 +S32500004B60666A0C7900450000462C660C20790000401033D00000462C20790000401C0C5002 +S32500004B800005661E2A0858852F054280302800022F00487AFF0B61FF00000AD6700160001B +S32500004BA0008620790000401C4280302800022239000046285281B28067186F042F00600603 +S32500004BC02F39000046286100FCF4584F52826000FF0C4282203900004628528023C0000082 +S32500004BE04628207900004010366800042F006100FCCC45EBFFF42F0A2F042A390000401C10 +S32500004C0058852F0561FF000009CAD88A504F504FB7FC0000020B6E00FEC4487AFE7C61FF1E +S32500004C2000000A4E42804CEE0C3CFFE84E5E4E756C65303A206265656E20626162626C690B +S32500004C406E672C20666F756E6420627920272573270A006C65303A206D656D6F727920658D +S32500004C6072726F7220696E20272573270A004E5600002F0A2F02242E0008246E000C30121A +S32500004C800800000E67142F02487AFFA661FF000009E061FFFFFFF466504F30120800000DEE +S32500004CA0670434BC200030120800000C670434BC100030120800000B67122F02487AFF955D +S32500004CC061FF000009AC61FFFFFFF432242EFFF8246EFFFC4E5E4E756C65303A20696E6955 +S32500004CE0742074696D656F75742C2073746174203D20307825780A004E56000048E73C3CF4 +S32500004D00246E0008287900004644267900004648283C000186A0426C000238BC00044878A8 +S32500004D2035BE2F0B61FF000008E64253176A0001000217520003176A00030004176A000262 +S32500004D400005176A00050006176A0004000742AB000842AB000C7418D48B2002424048402B +S32500004D600040600037400012374200107458D48B2002424048403740001637420014397C55 +S32500004D8000010002388B397C00020002200B42404840388091C8504F4BF08A00200DEB804C +S32500004DA09088E78090884BF30A60240D2208E7813782181817BC0080181A20024240484051 +S32500004DC01780181B37BCFA12181C4273181E52487A07BA886CC291C8327C2FD04BF08A008F +S32500004DE0200DEB809088E78090884BF10A00200D240BD4802208E781378218584233185AE6 +S32500004E002002424048401780185B4273185C4273185E52484A886FC4397C0003000238BCB5 +S32500004E200004426C000238BC00015384660E2F03487AFEA661FF00000838600C30144283CB +S32500004E4036000803000867E238BC010042B90000464C42B900004650426C000238BC000201 +S32500004E604CEE3C3CFFE04E5E4E756C655F706F6C6C006C65305F706F6C6C3A20726D642071 +S32500004E8073746174757320307825780A006C655F706F6C6C3A20636861696E6564207061FB +S32500004EA0636B65740A0063737230207768656E20626164207468696E6773206861707065CF +S32500004EC06E3A2025780A00004E56000048E72038267900004644287900004648426B00022B +S32500004EE030130800000A670436BC040020390000464C45F40E18102A00026C0642806000DC +S32500004F0000F630136C0C2F0B487AFF606100FD60504F102A0002080000066718102A00021D +S32500004F2042A71F400003487AFF4A61FF0000074242826078102A0002020000030C00000380 +S32500004F406712487AFF4961FF0000072661FFFFFFF1AC584F302A0006428234000C820000B3 +S32500004F6005ED6F1A428230133F004267487AFF3861FF000006FC61FFFFFFF182602E4A823B +S32500004F80672A59824A826F242F022F2E000820790000464C43F08A002009EB809088E780AF +S32500004FA0908848740A6061FF0000062820790000464C43F08A002009EB809088E78090880C +S32500004FC049F40A60200C34804240484015400003357CFA12000441F90000464C428072071A +S32500004FE0B290670820390000464C52802080157C0080000220024CEE1C04FFF04E5E4E75B0 +S325000050006C655F70757428776179206265666F726520786D697429006C65303A206F757437 +S325000050207075742062756666657220627573790A006C655F707574286265666F72652078CE +S325000050406D697429006C655F70757428616674657220786D697429006C65303A2074726167 +S325000050606E736D69742074696D656F75742C2073746174203D20307825780A006C655F7064 +S3250000508075742874696D656F757429006C655F7075743A20786D6974206572726F722C208E +S325000050A06275662025640A006C655F70757428786D6974206572726F7229006C65303A20B9 +S325000050C07472616E736D6974206572726F722C206572726F72203D20307825780A004E5628 +S325000050E0000048E73838282E000C247900004644287900004648263C000186A0426A00021C +S3250000510030126C0C2F0A487AFEF86100FB62504F20390000465047F40E58600C487AFEFACB +S3250000512061FF0000054C584F102B00026DEE2F0420790000465043F08A002009EB809088AE +S32500005140E7809088D080068000002FD0487408002F2E000861FF0000047A504F584F723FF7 +S32500005160B2846508377CFFC0000460083004444037400004426B000630126C0C2F0A487A0D +S32500005180FEB16100FAEA504F177C0083000220790000465043F08A002009EB809088E7805F +S325000051A09088D080068000002FD0D08C3680424048401740000334BC000830126C0C2F0A9B +S325000051C0487AFE836100FAA8504F538366202F02487AFE8661FF000004983012504F6C1AAE +S325000051E02F0A487AFE986100FA86504F600C3012428234000802000967D034BC0200301274 +S325000052006C2A3012024078000C40200067122F3900004650487AFE7661FF00000454504F86 +S325000052202F0A487AFE846100FA46504F42B900004650102B000208000006660420046014CD +S32500005240302B00063F004267487AFE7161FF0000042070FF4CEE1C1CFFE84E5E4E754E566F +S32500005260000048E73E20246E00082C2E000C242E001061FFFFFFF42C2A00DA8242844283AA +S3250000528061FFFFFFF41E2400BA826F624A83665E2F062F0A6100FC322600504FB484670273 +S325000052A028024A8367DA1212B2390000465466CE122A0001B2390000465566C2122A0002AA +S325000052C0B2390000465666B6122A0003B2390000465766AA122A0004B23900004658669E81 +S325000052E0122A0005B239000046596794609020034CEE047CFFE84E5E4E754552524F523AFB +S325000053002065746865726E65742061646472657373206E6F74207365742120205573652077 +S325000053204C5341442E0A006C65303A2065746865726E657420616464726573733A20257854 +S325000053403A25783A25783A25783A25783A25780A00004E5600002F0A2F022439FFFE077823 +S32500005360200202802FFFFF000C802FFFFF006612487AFF8861FF000002F861FFFFFFED7EB9 +S32500005380584F45F90000465414BC000842390000465513FC003E00004656E08A43F900000B +S325000053A046591282E08A41F9000046581082E08A13C200004657428010112F004280101010 +S325000053C02F002F024878003E42A748780008487AFF5761FF0000029A487800104879000013 +S325000053E0464461FF0000022823FCFFFE1800000046442239FFFE07740681FFF0000023C1A8 +S3250000540000004648DEFC00202E8A6100F8EC242EFFF8246EFFFC4E5E4E754E56000020797F +S32500005420000046444268000230BC00044E5E4E75206F0004222F0008202F000C2F02080150 +S3250000544000006674080100016600008A2401EC8902820000003C4482023C000F4EFB284252 +S325000054602418D1822418D1822418D1822418D1822418D1822418D1822418D1822418D182AE +S325000054802418D1822418D1822418D1822418D1822418D1822418D1822418D1822418D1828E +S325000054A051C9FFBE22004841D1416402524002800000FFFF241F4E75080100016708428297 +S325000054C0343018FDD0824282143018FFE18AD0826000FF7A4282343018FED0826000FF6EE9 +S325000054E04E56000048E73038262E0008264349F9FFA018E261FF000003C2747FC4802F023E +S325000055004E94584F7215B282670000886D20720AB282670000946D087208B2826738602ACE +S32500005520720DB282677C7212B2826740601C7223B28267306D087217B2826756600C724087 +S32500005540B282674E727FB282670416C260A6487800084E94584F487800204E944878000813 +S325000055604E94504FB68B648C534B60884878000A4E942443584FB7CA6300FF7A121A49C1A0 +S325000055802F0161FF0000035E584FB7CA62EE6000FF644878000A61FF0000034A584F60005B +S325000055A0FF4C4878000A4E9442134CEE1C0CFFEC4E5E4E754E560000226E000820494A11DD +S325000055C0670652484A1066FA200890894E5E4E754E560000222E0010226E0008206E000C1E +S325000055E0B1C9631AD3C1D1C1200153814A8067161121200153814A8066F6600A10D920018B +S3250000560053814A8066F64E5E4E7500004E560000206E0008202E000C538072FFB280670C9E +S32500005620421851C8FFFC4240538064F44E5E4E754E56000020790000402410AE000B52B965 +S32500005640000040244E5E4E754E56000023EE000800004024486E00102F2E000C487AFFD28E +S32500005660612420790000402442104E5E4E754E560000486E000C2F2E00084879FFA018E2BC +S3250000568061044E5E4E754E56000048E7303C2A6E0008286E000C266E0010594B600C4A822F +S325000056A0670001782F024E95584F141C49C27625B68266EA95CA141C49C2224241E9FF9E26 +S325000056C07616B6886500013A303B8A064EFB0002003400A200CA013001300130013001307F +S325000056E001300130002E0130013000EE01300130013000AE0130010401300130011A347C20 +S32500005700000160B2584B241B2453161A49C32F032F022F0D61000120504F584F4A82678AB7 +S3250000572091C8603A53817001E3A0C082672A703C4A886702702C2F004E95584F60082F0101 +S325000057404E95584F524A121249C17620B6816DEE307C00016008524A0C1200206EF8121A46 +S3250000576049C166C04A886700FF424878003E6000FF36584B767FC6932F036000FF2A584B97 +S325000057802453141A49C26700FF222F024E95584F141A49C266F46000FF12584B24136C0ABC +S325000057A04878002D4E954482584F4878000A2F022F0D61000082504F584F6000FEEE584B57 +S325000057C02413487800082F022F0D616A504F584F6000FED8584B24134878000A2F022F0DFF +S325000057E06154504F584F6000FEC2584B2413487800102F022F0D613E504F584F6000FEAC82 +S32500005800487800254E95584F4A8A6700FE984878006C4E95584F6000FE8C4CEE3C0CFFE839 +S325000058204E5E4E753031323334353637383961626364656600004E56FFF448E73038286ECD +S325000058400008222E000C242E001045EEFFF441FAFFD44C42100014F008004A8166F447EE44 +S32500005860FFF4162249C32F034E94584FB7CA65F24CEE1C0CFFE04E5E4E757C2F2D5C000074 +S325000058804E5600002F0A7003C0B90000402041FAFFEA1030080049C02F0052B900004020CA +S325000058A045F9FFA018E24E92487800084E92246EFFFC4E5E4E7500004E5600001F3C000088 +S325000058C04E4F0000101F49C04E5E4E754E56000042814E4F000167000004720142804E5E2D +S325000058E04E754E5600002F02242E0008700AB08266064878000D61EA1F024E4F0020242E50 +S32500005900FFFC4E5E4E750000FFFE07F80000402800004036000040360000404A00004052AB +S30D00005920000040520000405255 +S70300004000BB diff --git a/sys/arch/mvme88k/stand/openbsd/sboot/rboot.tmp b/sys/arch/mvme88k/stand/openbsd/sboot/rboot.tmp Binary files differnew file mode 100644 index 00000000000..db9793dc097 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/sboot/rboot.tmp diff --git a/sys/arch/mvme88k/stand/openbsd/sboot/sboot b/sys/arch/mvme88k/stand/openbsd/sboot/sboot new file mode 100644 index 00000000000..5d797b7368b --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/sboot/sboot @@ -0,0 +1,200 @@ +S00A0000000073626F6F74CE +S3250000400013FC000000005ED4600813FC000100005ED42E7C00006FF04EB9000040484E7554 +S325000040200A73626F6F743A204D564D4531343720626F6F7473747261702070726F67726175 +S325000040406D0A003E3E3E20004E56FF802F0A61FFFFFFFFCE1D7C0030FF80487AFFC461FF55 +S325000040600000159E584F45EEFF80487AFFD761FF0000158E2F0A61FF000013F82F0A610055 +S3250000408001CA504F584F60E24E714E5600004E4F00634E5E4E754D7920697020616464727B +S325000040A06573732069733A2025642E25642E25642E25640A005365727665722069702061B0 +S325000040C06464726573732069733A2025642E25642E25642E25640A004661696C65642E0ACA +S325000040E00065786974696E6720746F20524F4D0A00446F776E6C6F6164204661696C65640A +S325000041000A00446F776E6C6F61642077617320612073756363657373210A00636C69656E1C +S325000041207420495020616464726573732025642E25642E25642E25640A00736572766572D7 +S3250000414020495020616464726573732025642E25642E25642E25640A005245564152503AB8 +S32500004160204661696C65642E0A007265636569766564207365636F6E6461727920626F6F0D +S32500004180742070726F6772616D2E0A006273640076616C696420636F6D6D616E64730A0090 +S325000041A061202D2073656E64206120524152500A0062202D20626F6F7420746865207379B1 +S325000041C07374656D0A0071202D206578697420746F20524F4D0A0066202D206674702074B2 +S325000041E0686520626F6F742066696C650A0067202D20657865637574652074686520626F35 +S325000042006F742066696C650A0068202D2068656C700A0069202D20696E6974204C414E439B +S325000042204520656E657420636869700A0073626F6F743A2025733A20556E6B6E6F776E2016 +S32500004240636F6D6D616E640A00004E5600002F0B2F0A246E000810120C000067670001F2CF +S325000042606E2E0C000062670000F86E180C00006167364A00670001EC0C00003F670001925C +S32500004280600001D40C000066670000AE600001C80C000069670001B26D0001760C00007143 +S325000042A067000084600001B061FF0000054C4A8067664280103900005EF72F00428010391A +S325000042C000005EF62F004280103900005EF52F004280103900005EF42F00487AFDBA45F985 +S325000042E0000055FE4E924280103900005ED32F004280103900005ED22F00428010390000A5 +S325000043005ED12F004280103900005ED02F00487AFDA54E926000014C487AFDBE61FF000003 +S3250000432012E06000013E487AFDB961FF000012D26100FD586000012C61FF000007127201FB +S32500004340B280660E487AFDAB61FF000012B460000112487AFDAE61FF000012A660000104C4 +S3250000436061FF00000F8061FF0000048E4A80660E487AFDE761FF00001288600000E6428070 +S32500004380103900005EF72F004280103900005EF62F004280103900005EF52F004280103924 +S325000043A000005EF42F00487AFD7347F9000055FE4E934280103900005ED32F00428010395A +S325000043C000005ED22F004280103900005ED12F004280103900005ED02F00487AFD5E4E93A9 +S325000043E0DEFC002861FF000006667201B2806608487AFCFF4E93606A487AFD7061FF0000DF +S325000044001200584F524A4A12664645FAFD806040487AFD7E45F9000055FE4E92487AFD82EE +S325000044204E92487AFD8D4E92487AFD9C4E92487AFDA74E92487AFDB84E92487AFDCD4E9226 +S32500004440487AFDD14E92601A61FF00000E9860122F0A613C600C2F0A487AFDD361FF000087 +S3250000446011A0246EFFF8266EFFFC4E5E4E756A756D70696E6720746F20626F6F742070722B +S325000044806F6772616D20617420307825782E0A004E56000048E7003C246E00083A7C70009F +S325000044A02F0D487AFFCA61FF0000115642804281264A2F0A61FF0000108ED5C0284A4ED512 +S325000044C04CEE3C00FFF04E5E4E7500000000001F003B005A0078009700B500D400F30111B1 +S325000044E00130014E4E56000048E73F30266E00082C2E000C2A2E0010282E0014262E0018B4 +S32500004500242E001C200BE880244045F20C00200A720F2E0BC287244147F20A002006E8808A +S32500004520244045F20C00200A720FC286244145F20A002C0A2005E880244045F20C00200AA1 +S32500004540720FC285244145F20A002A0A2004E880244045F20C00200A720FC284244145F2F3 +S325000045600A00280A2003E880244045F20C00200A720FC283244145F20A00260A2002E88077 +S32500004580720FC282244045F20C00200A244145F20A44240A7E45BE826D0274462003538045 +S325000045A07E0BBE80650A200453807E1EBE8064044280607293C97046B4806F1C307C016E06 +S325000045C0223C0000016DE8C007826604D3C86002D3C15280B4806EEE41FAFEF030703A0078 +S325000045E0D1C443F098FFE8C0078266087E02BE836C02524943F19A0020092200E981928058 +S325000046002401E9829481EF822005E7809085EB80D085E9802042D1C02006E980908641F0EB +S325000046200C002008D08B4CEE0CFCFFE04E5E4E754E56000048E73E0020790000589810109B +S325000046400000004010801C2800011A280002182800031628000514280006122800071010D2 +S32500004660020000BF108042A71F41000342A71F42000342A71F43000342A71F44000342A7C4 +S325000046801F45000342A71F4600036100FE584CEE007CFFEC4E5E4E754E5600002F0A4280F6 +S325000046A020790000589C11BC00FF080052807205B2806CEC4878000622390000589C5C81CE +S325000046C02F01487900005EEC45F9000055604E9220790000589C317C8035000C2079000032 +S325000046E058A030BC0001317C08000002117C000600042079000058A0117C000400052079C1 +S32500004700000058A0317C00030006487800062239000058A050812F01487900005EEC4E92E0 +S32500004720487800067212D2B9000058A02F01487900005EEC4E924280DEFC00242079000032 +S3250000474058A0423008184230080E52807203B2806CEA4878004C4879000058C061FF00002D +S325000047600910246EFFFC4E5E4E754E5600002F0A48780006487806004879000058C061FF7C +S3250000478000000A6E20790000589C504F584F0C688035000C66562079000058A00C680004CE +S325000047A00006664848780004487900005EF47218D2882F0145F9000055604E9248780004BD +S325000047C0487900005ED0720ED2B9000058A02F014E9248780006487900005EC822390000C9 +S325000047E058A050812F014E92700160024280246EFFFC4E5E4E754E5600002F02428261004F +S32500004800FE986100FF664A8067047001600A52827204B2826CE84280242EFFFC4E5E4E75D6 +S32500004820000178787878787878782E6D766D6536386B006F637465740000303132333435A7 +S325000048403637383941424344454600004E56FFFC48E73038242E000866322879000058AC12 +S3250000486047EC001961FFFFFFFDCA33C000005ED80C7903E700005ED86208067903E800001F +S325000048805ED833FC004500005EC460082679000058B0584B487800062F390000589C4879B1 +S325000048A000005EC845F9000055604E924878000626390000589C5C832F03487900005EECC4 +S325000048C04E9220790000589C317C0800000C2079000058A47604EFD030042079000058A40D +S325000048E07605EFD031042079000058A4422800012079000058A442680004317C400000060D +S32500004900117C000300082079000058A4117C0011000948780004760CD6B9000058A42F03BA +S32500004920487900005EF44E92DEFC00202EBC000000047610D6B9000058A42F034879000092 +S325000049405ED04E922079000058A44268000A384B98F9000058A6314C000242A748780014AC +S325000049602F0861FF00000A5C2079000058A446403140000A2079000058A830B900005ED8E6 +S32500004980317900005EC4000242680006DEFC00184A8267102079000058B030BC000431425A +S325000049A00002605448780004486EFFFC487900005EF445F9000055604E92487800192F399F +S325000049C0000058AC487AFE5A4E927209DEFC001843FAFE682079000058AC700FC0AEFFFC3E +S325000049E011B108001800202EFFFCE8882D40FFFC53817601B68165DC2079000058A8384BCF +S32500004A0098F9000058AA314C000497FC000058C02F0B4879000058C061FF000006544CEECA +S32500004A201C0CFFE84E5E4E750A002578200D00544654503A20446F776E6C6F616420657257 +S32500004A40726F722025643A2025730A004E56000048E73C304282283C0000700042B9000086 +S32500004A605EC042A76100FDE6584F428348780005487806004879000058C061FF000007723C +S32500004A80504F584F4A8066304AB900005EC067082F3900005EC0600242A76100FDB0584F54 +S32500004AA052827A05BA826CC4487AFF7E61FF00000B507001600001002079000058B4362862 +S32500004AC0000220037A09EBA02F00487AFF5E61FF00000B2E20790000589C504F0C6808000E +S32500004AE0000C66782079000058A40C2800110009666A0C79004500005EC4660C207900001C +S32500004B0058A833D000005EC42079000058B40C500005661E2A0858852F0542803028000281 +S32500004B202F00487AFF0B61FF00000AD67001600000862079000058B44280302800022239C1 +S32500004B4000005EC05281B28067186F042F0060062F3900005EC06100FCF4584F52826000F3 +S32500004B60FF0C4282203900005EC0528023C000005EC02079000058A8366800042F0061004B +S32500004B80FCCC45EBFFF42F0A2F042A39000058B458852F0561FF000009CAD88A504F504F65 +S32500004BA0B7FC0000020B6E00FEC4487AFE7C61FF00000A4E42804CEE0C3CFFE84E5E4E7571 +S32500004BC06C65303A206265656E20626162626C696E672C20666F756E642062792027257347 +S32500004BE0270A006C65303A206D656D6F7279206572726F7220696E20272573270A004E5695 +S32500004C0000002F0A2F02242E0008246E000C30120800000E67142F02487AFFA661FF000061 +S32500004C2009E061FFFFFFF466504F30120800000D670434BC200030120800000C670434BCAB +S32500004C40100030120800000B67122F02487AFF9561FF000009AC61FFFFFFF432242EFFF807 +S32500004C60246EFFFC4E5E4E756C65303A20696E69742074696D656F75742C207374617420D4 +S32500004C803D20307825780A004E56000048E73C3C246E0008287900005EDC267900005EE0C5 +S32500004CA0283C000186A0426C000238BC0004487835BE2F0B61FF000008E64253176A000169 +S32500004CC0000217520003176A00030004176A00020005176A00050006176A0004000742AB4B +S32500004CE0000842AB000C7418D48B2002424048400040600037400012374200107458D48BB9 +S32500004D002002424048403740001637420014397C00010002388B397C00020002200B424066 +S32500004D204840388091C8504F4BF08A00200DEB809088E78090884BF30A60240D2208E781D6 +S32500004D403782181817BC0080181A2002424048401780181B37BCFA12181C4273181E524831 +S32500004D607A07BA886CC291C8327C2FD04BF08A00200DEB809088E78090884BF10A00200DCF +S32500004D80240BD4802208E781378218584233185A2002424048401780185B4273185C4273D4 +S32500004DA0185E52484A886FC4397C0003000238BC0004426C000238BC00015384660E2F0304 +S32500004DC0487AFEA661FF00000838600C3014428336000803000867E238BC010042B90000D0 +S32500004DE05EE442B900005EE8426C000238BC00024CEE3C3CFFE04E5E4E756C655F706F6C09 +S32500004E006C006C65305F706F6C6C3A20726D642073746174757320307825780A006C655F09 +S32500004E20706F6C6C3A20636861696E6564207061636B65740A0063737230207768656E2083 +S32500004E40626164207468696E67732068617070656E3A2025780A00004E56000048E72038B0 +S32500004E60267900005EDC287900005EE0426B000230130800000A670436BC040020390000B6 +S32500004E805EE445F40E18102A00026C064280600000F630136C0C2F0B487AFF606100FD60D1 +S32500004EA0504F102A0002080000066718102A000242A71F400003487AFF4A61FF0000074249 +S32500004EC042826078102A0002020000030C0000036712487AFF4961FF0000072661FFFFFF72 +S32500004EE0F1AC584F302A0006428234000C82000005ED6F1A428230133F004267487AFF381F +S32500004F0061FF000006FC61FFFFFFF182602E4A82672A59824A826F242F022F2E0008207904 +S32500004F2000005EE443F08A002009EB809088E780908848740A6061FF0000062820790000F4 +S32500004F405EE443F08A002009EB809088E780908849F40A60200C3480424048401540000338 +S32500004F60357CFA12000441F900005EE442807207B2906708203900005EE452802080157C64 +S32500004F800080000220024CEE1C04FFF04E5E4E756C655F70757428776179206265666F727F +S32500004FA06520786D697429006C65303A206F75747075742062756666657220627573790AE8 +S32500004FC0006C655F707574286265666F726520786D697429006C655F70757428616674654B +S32500004FE07220786D697429006C65303A207472616E736D69742074696D656F75742C20737B +S32500005000746174203D20307825780A006C655F7075742874696D656F757429006C655F70F4 +S3250000502075743A20786D6974206572726F722C206275662025640A006C655F7075742878B6 +S325000050406D6974206572726F7229006C65303A207472616E736D6974206572726F722C202A +S325000050606572726F72203D20307825780A004E56000048E73838282E000C247900005EDCB8 +S32500005080287900005EE0263C000186A0426A000230126C0C2F0A487AFEF86100FB62504FEC +S325000050A0203900005EE847F40E58600C487AFEFA61FF0000054C584F102B00026DEE2F0461 +S325000050C0207900005EE843F08A002009EB809088E7809088D080068000002FD0487408006A +S325000050E02F2E000861FF0000047A504F584F723FB2846508377CFFC0000460083004444037 +S3250000510037400004426B000630126C0C2F0A487AFEB16100FAEA504F177C00830002207962 +S3250000512000005EE843F08A002009EB809088E7809088D080068000002FD0D08C36804240D2 +S3250000514048401740000334BC000830126C0C2F0A487AFE836100FAA8504F538366202F020A +S32500005160487AFE8661FF000004983012504F6C1A2F0A487AFE986100FA86504F600C3012C1 +S32500005180428234000802000967D034BC020030126C2A3012024078000C40200067122F39B4 +S325000051A000005EE8487AFE7661FF00000454504F2F0A487AFE846100FA46504F42B900005E +S325000051C05EE8102B000208000006660420046014302B00063F004267487AFE7161FF00005C +S325000051E0042070FF4CEE1C1CFFE84E5E4E754E56000048E73E20246E00082C2E000C242ECB +S32500005200001061FFFFFFF42C2A00DA824284428361FFFFFFF41E2400BA826F624A83665EB7 +S325000052202F062F0A6100FC322600504FB484670228024A8367DA1212B23900005EEC66CE40 +S32500005240122A0001B23900005EED66C2122A0002B23900005EEE66B6122A0003B2390000F2 +S325000052605EEF66AA122A0004B23900005EF0669E122A0005B23900005EF1679460902003C5 +S325000052804CEE047CFFE84E5E4E754552524F523A2065746865726E65742061646472657322 +S325000052A073206E6F7420736574212020557365204C5341442E0A006C65303A20657468658D +S325000052C0726E657420616464726573733A2025783A25783A25783A25783A25783A25780AD5 +S325000052E000004E5600002F0A2F022439FFFE0778200202802FFFFF000C802FFFFF006612BF +S32500005300487AFF8861FF000002F861FFFFFFED7E584F45F900005EEC14BC00084239000099 +S325000053205EED13FC003E00005EEEE08A43F900005EF11282E08A41F900005EF01082E08A0C +S3250000534013C200005EEF428010112F00428010102F002F024878003E42A748780008487A60 +S32500005360FF5761FF0000029A48780010487900005EDC61FF0000022823FCFFFE180000004C +S325000053805EDC2239FFFE07740681FFF0000023C100005EE0DEFC00202E8A6100F8EC242E19 +S325000053A0FFF8246EFFFC4E5E4E754E560000207900005EDC4268000230BC00044E5E4E7572 +S325000053C0206F0004222F0008202F000C2F02080100006674080100016600008A2401EC89D8 +S325000053E002820000003C4482023C000F4EFB28422418D1822418D1822418D1822418D182E5 +S325000054002418D1822418D1822418D1822418D1822418D1822418D1822418D1822418D1820E +S325000054202418D1822418D1822418D1822418D18251C9FFBE22004841D1416402524002801C +S325000054400000FFFF241F4E750801000167084282343018FDD0824282143018FFE18AD0825E +S325000054606000FF7A4282343018FED0826000FF6E4E56000048E73038262E0008264349F9AE +S325000054800000587261FF000003C2747FC4802F024E94584F7215B282670000886D20720A73 +S325000054A0B282670000946D087208B2826738602A720DB282677C7212B2826740601C722365 +S325000054C0B28267306D087217B2826756600C7240B282674E727FB282670416C260A64878D7 +S325000054E000084E94584F487800204E94487800084E94504FB68B648C534B60884878000A89 +S325000055004E942443584FB7CA6300FF7A121A49C12F0161FF0000035E584FB7CA62EE600039 +S32500005520FF644878000A61FF0000034A584F6000FF4C4878000A4E9442134CEE1C0CFFECEB +S325000055404E5E4E754E560000226E000820494A11670652484A1066FA200890894E5E4E7565 +S325000055604E560000222E0010226E0008206E000CB1C9631AD3C1D1C1200153814A80671696 +S325000055801121200153814A8066F6600A10D9200153814A8066F64E5E4E7500004E56000037 +S325000055A0206E0008202E000C538072FFB280670C421851C8FFFC4240538064F44E5E4E7582 +S325000055C04E5600002079000058BC10AE000B52B9000058BC4E5E4E754E56000023EE000860 +S325000055E0000058BC486E00102F2E000C487AFFD261242079000058BC42104E5E4E754E5638 +S325000056000000486E000C2F2E000848790000587261044E5E4E754E56000048E7303C2A6E27 +S325000056200008286E000C266E0010594B600C4A82670001782F024E95584F141C49C27625C9 +S32500005640B68266EA95CA141C49C2224241E9FF9E7616B6886500013A303B8A064EFB000247 +S32500005660003400A200CA0130013001300130013001300130002E0130013000EE013001304D +S32500005680013000AE0130010401300130011A347C000160B2584B241B2453161A49C32F03E8 +S325000056A02F022F0D61000120504F584F4A82678A91C8603A53817001E3A0C082672A703CB8 +S325000056C04A886702702C2F004E95584F60082F014E95584F524A121249C17620B6816DEE20 +S325000056E0307C00016008524A0C1200206EF8121A49C166C04A886700FF424878003E60001B +S32500005700FF36584B767FC6932F036000FF2A584B2453141A49C26700FF222F024E95584F0C +S32500005720141A49C266F46000FF12584B24136C0A4878002D4E954482584F4878000A2F02D7 +S325000057402F0D61000082504F584F6000FEEE584B2413487800082F022F0D616A504F584F72 +S325000057606000FED8584B24134878000A2F022F0D6154504F584F6000FEC2584B2413487827 +S3250000578000102F022F0D613E504F584F6000FEAC487800254E95584F4A8A6700FE98487897 +S325000057A0006C4E95584F6000FE8C4CEE3C0CFFE84E5E4E753031323334353637383961625B +S325000057C06364656600004E56FFF448E73038286E0008222E000C242E001045EEFFF441FA46 +S325000057E0FFD44C42100014F008004A8166F447EEFFF4162249C32F034E94584FB7CA65F202 +S325000058004CEE1C0CFFE04E5E4E757C2F2D5C00004E5600002F0A7003C0B9000058B841FA8A +S32500005820FFEA1030080049C02F0052B9000058B845F9000058724E92487800084E92246EBC +S32500005840FFFC4E5E4E7500004E5600001F3C00004E4F0000101F49C04E5E4E754E560000F1 +S3250000586042814E4F000167000004720142804E5E4E754E5600002F02242E0008700AB082D7 +S3250000588066064878000D61EA1F024E4F0020242EFFFC4E5E4E750000FFFE07F8000058C0D0 +S31D000058A0000058CE000058CE000058E2000058EA000058EA000058EA9E +S70300004000BB diff --git a/sys/arch/mvme88k/stand/openbsd/sboot/sboot.c b/sys/arch/mvme88k/stand/openbsd/sboot/sboot.c new file mode 100644 index 00000000000..5b0f06b1a7e --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/sboot/sboot.c @@ -0,0 +1,173 @@ +/* + * Copyright (c) 1995 Theo de Raadt + * + * 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 under OpenBSD by + * Theo de Raadt for Willowglen Singapore. + * 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. + * + * Copyright (c) 1995 Charles D. Cranor and Seth Widoff + * 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 Charles D. Cranor + * and Seth Widoff. + * 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/cdefs.h> +#include "sboot.h" + +void +main() +{ + char buf[128]; + + buf[0] = '0'; + printf("\nsboot: MVME147 bootstrap program\n"); + while (1) { + printf(">>> "); + gets(buf); + do_cmd(buf); + } + /* not reached */ +} + +/* + * exit to rom + */ +void +callrom() +{ + asm("trap #15; .word 0x0063"); +} + +/* + * do_cmd: do a command + */ +void +do_cmd(buf) + char *buf; +{ + switch (*buf) { + case '\0': + break; + case 'a': + if (rev_arp()) { + printf("My ip address is: %d.%d.%d.%d\n", myip[0], + myip[1], myip[2], myip[3]); + printf("Server ip address is: %d.%d.%d.%d\n", servip[0], + servip[1], servip[2], servip[3]); + } else { + printf("Failed.\n"); + } + break; + case 'q': + printf("exiting to ROM\n"); + callrom(); + break; + case 'f': + if (do_get_file() == 1) { + printf("Download Failed\n"); + } else { + printf("Download was a success!\n"); + } + break; + case 'b': + le_init(); + if (rev_arp()) { + printf("client IP address %d.%d.%d.%d\n", myip[0], + myip[1], myip[2], myip[3]); + printf("server IP address %d.%d.%d.%d\n", servip[0], + servip[1], servip[2], servip[3]); + } else { + printf("REVARP: Failed.\n"); + return; + } + if (do_get_file() == 1) { + printf("Download Failed\n"); + return; + } else { + printf("received secondary boot program.\n"); + } + if (*++buf == '\0') + buf = "bsd"; + go(buf); + break; + case 'h': + case '?': + printf("valid commands\n"); + printf("a - send a RARP\n"); + printf("b - boot the system\n"); + printf("q - exit to ROM\n"); + printf("f - ftp the boot file\n"); + printf("g - execute the boot file\n"); + printf("h - help\n"); + printf("i - init LANCE enet chip\n"); + break; + case 'i': + le_init(); + break; + case 'g': + go(buf); + break; + default: + printf("sboot: %s: Unknown command\n", buf); + } +} + +go(buf) + char *buf; +{ + void (*entry)() = (void (*))LOAD_ADDR; + + printf("jumping to boot program at 0x%x.\n", entry); + + asm("clrl d0; clrl d1"); /* XXX network device */ + asm("movl %0, a3" : : "a" (buf) : "a3"); + asm("movl %0, a4" : : "a" (buf + strlen(buf)) : "a4"); + asm("jmp %0@" : : "a" (entry)); +} diff --git a/sys/arch/mvme88k/stand/openbsd/sboot/sboot.h b/sys/arch/mvme88k/stand/openbsd/sboot/sboot.h new file mode 100644 index 00000000000..146e0b8cce4 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/sboot/sboot.h @@ -0,0 +1,95 @@ +/* + * Copyright (c) 1995 Charles D. Cranor and Seth Widoff + * 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 Charles D. Cranor + * and Seth Widoff. + * 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. + */ + +/* + * sboot.h: stuff for MVME147's serial line boot + */ + +typedef unsigned short u_short; +typedef unsigned long u_long; +typedef unsigned char u_char; +typedef unsigned int u_int; +typedef u_long size_t; +typedef char *caddr_t; +extern caddr_t end; + +#define NULL ((char *)0) + +void bcopy __P((const void *, void *, size_t)); /* libc_sa */ +void *memset __P((void *, int, size_t)); /* libc_sa */ +int printf __P((const char *, ...)); /* libc_sa */ + +/* console */ +void puts __P((char *)); +void putchar __P((char)); +char cngetc __P((void)); +void ngets __P((char *, int)); + +/* sboot */ +void callrom __P((void)); +void do_cmd __P((char *)); + +/* le */ +#define LANCE_ADDR 0xfffe0778 +#define ERAM_ADDR 0xfffe0774 +#define LANCE_REG_ADDR 0xfffe1800 +void le_end __P((void)); +void le_init __P((void)); +int le_get __P((u_char *, size_t, u_long)); +int le_put __P((u_char *, size_t)); + +/* etherfun */ +#define READ 0 +#define ACKN 1 +void do_rev_arp __P((void)); +int get_rev_arp __P((void)); +int rev_arp __P((void)); +void do_send_tftp __P((int)); +int do_get_file __P((void)); +void tftp_file __P((char *, u_long)); + +/* clock */ +u_long time __P((void)); + +/* checksum */ +u_long oc_cksum __P((void *, u_long, u_long)); + +#define CONS_ZS_ADDR (0xfffe3002) +#define CLOCK_ADDR (0xfffe07f8) +#define LOAD_ADDR 0x7000 + +unsigned char myea[6]; /* my ether addr */ +unsigned char myip[4]; +unsigned char servip[4]; +unsigned char servea[6]; +u_short myport; +u_short servport; +unsigned char reboot; diff --git a/sys/arch/mvme88k/stand/openbsd/sboot/sboot.tmp b/sys/arch/mvme88k/stand/openbsd/sboot/sboot.tmp Binary files differnew file mode 100644 index 00000000000..a55acd6ea70 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/sboot/sboot.tmp diff --git a/sys/arch/mvme88k/stand/openbsd/sboot/srec b/sys/arch/mvme88k/stand/openbsd/sboot/srec Binary files differnew file mode 100644 index 00000000000..a60b3c76852 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/sboot/srec diff --git a/sys/arch/mvme88k/stand/openbsd/sboot/srec.c b/sys/arch/mvme88k/stand/openbsd/sboot/srec.c new file mode 100644 index 00000000000..164fb4b458c --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/sboot/srec.c @@ -0,0 +1,157 @@ +/* + * Public domain, believed to be by Mike Price. + * + * convert binary file to Srecord format + * XXX srec generates improper checksums for 4-byte dumps + */ +#include <stdio.h> +#include <ctype.h> + +int get32(); +void put32(); +void sput(); +void put(); +int checksum(); + +int mask; +int size; + +main(argc, argv) + int argc; + char *argv[]; +{ + char buf[32]; + int cc; + int base; + int addr; + char *name; + + if (argc != 4) { + fprintf(stderr, "usage: %s {size} {hex_addr} {name}\n", argv[0]); + fprintf(stderr, "Size = 2, 3, or 4 byte address\n"); + exit(1); + } + sscanf(argv[1], "%x", &size); + mask = (1 << (size * 8)) - 1; + if (!mask) + mask = (-1); + sscanf(argv[2], "%x", &base); + name = argv[3]; + + if (size == 2) + printf("S0%02X%04X", 2 + strlen(name) + 1, 0); + if (size == 3) + printf("S0%02X%06X", 3 + strlen(name) + 1, 0); + if (size == 4) + printf("S0%02X%08X", 4 + strlen(name) + 1, 0); + sput(name); + printf("%02X\n", checksum(0, name, strlen(name), size)); + + addr = base; + for (;;) { + cc = get32(buf); + if (cc > 0) { + put32(cc, addr, buf, size, mask); + addr += cc; + } else + break; + } + + buf[0] = base >> 8; + buf[1] = base; + printf("S%d%02X", 11 - size, 2 + 1); + switch (size) { + case 2: + printf("%04X", base & mask); + break; + case 3: + printf("%06X", base & mask); + break; + case 4: + printf("%08X", base & mask); + break; + } + + /* + * kludge -> don't know why you have to add the +1 = works + * for size =3 at least + */ + printf("%02X\n", checksum(base, (char *) 0, 0, size) + 1); + exit (0); +} + +int +get32(buf) + char buf[]; +{ + char *cp = buf; + int i; + int c; + + for (i = 0; i < 32; ++i) { + if ((c = getchar()) != EOF) + *cp++ = c; + else + break; + } + return (cp - buf); +} + +void +put32(len, addr, buf, size, mask) + int len; + int addr; + char buf[]; + int size, mask; +{ + char *cp = buf; + int i; + + if (size == 2) + printf("S1%02X%04X", 2 + len + 1, addr & mask); + if (size == 3) + printf("S2%02X%06X", 3 + len + 1, addr & mask); + if (size == 4) + printf("S3%02X%08X", 4 + len + 1, addr & mask); + for (i = 0; i < len; ++i) + put(*cp++); + printf("%02X\n", checksum(addr, buf, len, size)); +} + +void +sput(s) + char *s; +{ + while (*s != '\0') + put(*s++); +} + +void +put(c) + int c; +{ + printf("%02X", c & 0xff); +} + +int +checksum(addr, buf, len, size) + int addr; + char buf[]; + int len; + int size; +{ + char *cp = buf; + int sum = 0xff - 1 - size - (len & 0xff); + int i; + + if (size == 4) + sum -= (addr >> 24) & 0xff; + if (size >= 3) + sum -= (addr >> 16) & 0xff; + sum -= (addr >> 8) & 0xff; + sum -= addr & 0xff; + for (i = 0; i < len; ++i) { + sum -= *cp++ & 0xff; + } + return (sum & 0xff); +} diff --git a/sys/arch/mvme88k/stand/openbsd/wrtvid/Makefile b/sys/arch/mvme88k/stand/openbsd/wrtvid/Makefile new file mode 100644 index 00000000000..8b6cd97df7d --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/wrtvid/Makefile @@ -0,0 +1,6 @@ +PROG= wrtvid +NOMAN= + +install: + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/openbsd/wrtvid/Makefile.inc b/sys/arch/mvme88k/stand/openbsd/wrtvid/Makefile.inc new file mode 100644 index 00000000000..a8c47af8bd7 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/wrtvid/Makefile.inc @@ -0,0 +1,12 @@ +WRTVID_BASE_DIR=${S}/arch/${MACHINE}/stand/wrtvid + +WRTVID_DIR!= cd ${WRTVID_BASE_DIR}; \ + printf "xxx:\n\techo \$${.OBJDIR}\n" | ${MAKE} -r -s -f - xxx + +WRTVID=${WRTVID_DIR}/wrtvid + +$(WRTVID): .NOTMAIN __always_make_WRTVID + @echo making sure the wrtvid is up to date... + @(cd ${WRTVID_BASE_DIR}; ${MAKE}) + +__always_make_WRTVID: .NOTMAIN diff --git a/sys/arch/mvme88k/stand/openbsd/wrtvid/wrtvid b/sys/arch/mvme88k/stand/openbsd/wrtvid/wrtvid Binary files differnew file mode 100644 index 00000000000..565965fdee3 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/wrtvid/wrtvid diff --git a/sys/arch/mvme88k/stand/openbsd/wrtvid/wrtvid.c b/sys/arch/mvme88k/stand/openbsd/wrtvid/wrtvid.c new file mode 100644 index 00000000000..b2a21ad4f18 --- /dev/null +++ b/sys/arch/mvme88k/stand/openbsd/wrtvid/wrtvid.c @@ -0,0 +1,145 @@ +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <stdio.h> +#define __DBINTERFACE_PRIVATE +#include <db.h> +#include <machine/disklabel.h> + +main(argc, argv) + int argc; + char **argv; +{ + struct cpu_disklabel *pcpul; + struct stat stat; + int exe_file; + int tape_vid; + int tape_exe; + unsigned int exe_addr; + unsigned short exe_addr_u; + unsigned short exe_addr_l; + char *filename; + char fileext[256]; + char filebase[256]; + + if (argc == 0) + filename = "a.out"; + else + filename = argv[1]; + + exe_file = open(filename, O_RDONLY,0444); + if (exe_file == -1) { + perror(filename); + exit(2); + } + sprintf(fileext, "%c%cboot", filename[4], filename[5]); + tape_vid = open(fileext, O_WRONLY|O_CREAT|O_TRUNC, 0644); + sprintf(fileext, "boot%c%c", filename[4], filename[5]); + tape_exe = open(fileext, O_WRONLY|O_CREAT|O_TRUNC,0644); + + pcpul = (struct cpu_disklabel *)malloc(sizeof(struct cpu_disklabel)); + bzero(pcpul, sizeof(struct cpu_disklabel)); + + strcpy(pcpul->vid_id, "NBSD"); + + fstat(exe_file, &stat); + /* size in 256 byte blocks round up after a.out header removed */ + + if (filename[5] == 't' ) { + pcpul->vid_oss = 1; + }else { + pcpul->vid_oss = 2; + } + pcpul->vid_osl = (((stat.st_size -0x20) +511) / 512) *2; + + lseek(exe_file, 0x14, SEEK_SET); + read(exe_file, &exe_addr, 4); + + /* check this, it may not work in both endian. */ + { + union { + struct s { + unsigned short s1; + unsigned short s2; + } s; + unsigned long l; + } a; + a.l = exe_addr; + pcpul->vid_osa_u = a.s.s1; + pcpul->vid_osa_l = a.s.s2; + + } + pcpul->vid_cas = 1; + pcpul->vid_cal = 1; + /* do not want to write past end of structure, not null terminated */ + strncpy(pcpul->vid_mot, "MOTOROLA", 8); + + if (BYTE_ORDER != BIG_ENDIAN) + swabvid(pcpul); + + pcpul->cfg_rec = 0x100; + pcpul->cfg_psm = 0x200; + + if (BYTE_ORDER != BIG_ENDIAN) + swabcfg(pcpul); + + write(tape_vid, pcpul, sizeof(struct cpu_disklabel)); + + free(pcpul); + + copy_exe(exe_file, tape_exe); + close(exe_file); + close(tape_vid); + close(tape_exe); + return (0); +} + +#define BUF_SIZ 512 +copy_exe(exe_file, tape_exe) + int exe_file, tape_exe; +{ + char *buf; + int cnt = 0; + + buf = (char *)malloc(BUF_SIZ); + + lseek (exe_file, 0x20, SEEK_SET); + while (BUF_SIZ == (cnt = read(exe_file, buf, BUF_SIZ))) { + write(tape_exe, buf, cnt); + } + bzero(&buf[cnt], BUF_SIZ-cnt); + write(tape_exe, buf, BUF_SIZ); +} + +swabvid(pcpul) + struct cpu_disklabel *pcpul; +{ + M_32_SWAP(pcpul->vid_oss); + M_16_SWAP(pcpul->vid_osl); + /* + M_16_SWAP(pcpul->vid_osa_u); + M_16_SWAP(pcpul->vid_osa_l); + */ + M_32_SWAP(pcpul->vid_cas); +} + +swabcfg(pcpul) + struct cpu_disklabel *pcpul; +{ + M_16_SWAP(pcpul->cfg_atm); + M_16_SWAP(pcpul->cfg_prm); + M_16_SWAP(pcpul->cfg_atm); + M_16_SWAP(pcpul->cfg_rec); + M_16_SWAP(pcpul->cfg_trk); + M_16_SWAP(pcpul->cfg_psm); + M_16_SWAP(pcpul->cfg_shd); + M_16_SWAP(pcpul->cfg_pcom); + M_16_SWAP(pcpul->cfg_rwcc); + M_16_SWAP(pcpul->cfg_ecc); + M_16_SWAP(pcpul->cfg_eatm); + M_16_SWAP(pcpul->cfg_eprm); + M_16_SWAP(pcpul->cfg_eatw); + M_16_SWAP(pcpul->cfg_rsvc1); + M_16_SWAP(pcpul->cfg_rsvc2); +} diff --git a/sys/arch/mvme88k/stand/prtvid/Makefile b/sys/arch/mvme88k/stand/prtvid/Makefile new file mode 100644 index 00000000000..f6a6d3e1e1a --- /dev/null +++ b/sys/arch/mvme88k/stand/prtvid/Makefile @@ -0,0 +1,6 @@ +PROG= prtvid +NOMAN= + +install: + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/prtvid/chklabel b/sys/arch/mvme88k/stand/prtvid/chklabel Binary files differnew file mode 100644 index 00000000000..05637c518f5 --- /dev/null +++ b/sys/arch/mvme88k/stand/prtvid/chklabel diff --git a/sys/arch/mvme88k/stand/prtvid/chklabel.c b/sys/arch/mvme88k/stand/prtvid/chklabel.c new file mode 100644 index 00000000000..fc92660c5b5 --- /dev/null +++ b/sys/arch/mvme88k/stand/prtvid/chklabel.c @@ -0,0 +1,114 @@ +/* + * 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 <sys/disklabel.h> +#include <stdio.h> + +void cputobsdlabel __P((struct disklabel *lp, struct cpu_disklabel *clp)); + +main(int argc, char *argv[]) +{ + struct cpu_disklabel cpu_label; + struct disklabel sdlabel; + int i; + + fread((void *)&cpu_label, sizeof(struct cpu_disklabel), 1, stdin); + cputobsdlabel(&sdlabel, (struct cpu_disklabel *)&cpu_label); + + for (i = 0; i < MAXPARTITIONS; i++) { + printf("part %x off %x size %x\n", + i, sdlabel.d_partitions[i].p_offset, + sdlabel.d_partitions[i].p_size); + } +} + +void +cputobsdlabel(struct disklabel *lp, struct cpu_disklabel *clp) +{ + int i; + + lp->d_magic = clp->magic1; + lp->d_type = clp->type; + lp->d_subtype = clp->subtype; + bcopy(clp->vid_vd, lp->d_typename, 16); + bcopy(clp->packname, lp->d_packname, 16); + lp->d_secsize = clp->cfg_psm; + lp->d_nsectors = clp->cfg_spt; + lp->d_ncylinders = clp->cfg_trk; /* trk is really num of cyl! */ + lp->d_ntracks = clp->cfg_hds; + + lp->d_secpercyl = clp->secpercyl; + lp->d_secperunit = clp->secperunit; + lp->d_secpercyl = clp->secpercyl; + lp->d_secperunit = clp->secperunit; + lp->d_sparespertrack = clp->sparespertrack; + lp->d_sparespercyl = clp->sparespercyl; + lp->d_acylinders = clp->acylinders; + lp->d_rpm = clp->rpm; + lp->d_interleave = clp->cfg_ilv; + lp->d_trackskew = clp->cfg_sof; + lp->d_cylskew = clp->cylskew; + lp->d_headswitch = clp->headswitch; + + /* this silly table is for winchester drives */ + switch (clp->cfg_ssr) { + case 0: + lp->d_trkseek = 0; + break; + case 1: + lp->d_trkseek = 6; + break; + case 2: + lp->d_trkseek = 10; + break; + case 3: + lp->d_trkseek = 15; + break; + case 4: + lp->d_trkseek = 20; + break; + default: + lp->d_trkseek = 0; + break; + } + lp->d_flags = clp->flags; + for (i = 0; i < NDDATA; i++) + lp->d_drivedata[i] = clp->drivedata[i]; + for (i = 0; i < NSPARE; i++) + lp->d_spare[i] = clp->spare[i]; + lp->d_magic2 = clp->magic2; + lp->d_checksum = clp->checksum; + lp->d_npartitions = clp->partitions; + lp->d_bbsize = clp->bbsize; + lp->d_sbsize = clp->sbsize; + bcopy(clp->vid_4, &(lp->d_partitions[0]), sizeof (struct partition) * 4); + bcopy(clp->cfg_4, &(lp->d_partitions[4]), sizeof (struct partition) * 12); +} diff --git a/sys/arch/mvme88k/stand/prtvid/prtvid b/sys/arch/mvme88k/stand/prtvid/prtvid Binary files differnew file mode 100644 index 00000000000..10a4f710289 --- /dev/null +++ b/sys/arch/mvme88k/stand/prtvid/prtvid diff --git a/sys/arch/mvme88k/stand/prtvid/prtvid.c b/sys/arch/mvme88k/stand/prtvid/prtvid.c new file mode 100644 index 00000000000..32784ff0dfa --- /dev/null +++ b/sys/arch/mvme88k/stand/prtvid/prtvid.c @@ -0,0 +1,132 @@ +#include <stdio.h> +#define __DBINTERFACE_PRIVATE +#include <db.h> +#include "vid.h" + +main(argc, argv) + int argc; + char *argv[]; +{ + struct vid *pvid; + struct cfg *pcfg; + + pvid = (struct vid *) malloc(sizeof (struct vid)); + + fread(pvid, sizeof(struct vid), 1, stdin); + + if (BYTE_ORDER != BIG_ENDIAN) + swabvid(pvid); + + printf("vid_id %s %x\n", pvid->vid_id, + (char *)&(pvid->vid_id[4]) - (char *)pvid); + printf("vid_oss %x %x\n", pvid->vid_oss, + (char *)&(pvid->vid_oss) - (char *)pvid); + printf("vid_osl %x %x\n", pvid->vid_osl, + (char *)&(pvid->vid_osl) - (char *)pvid); + printf("vid_osa_u %x %x\n", pvid->vid_osa_u, + (char *)&(pvid->vid_osa_u) - (char *)pvid); + printf("vid_osa_l %x %x\n", pvid->vid_osa_l, + (char *)&(pvid->vid_osa_l) - (char *)pvid); + printf("vid_vd %x\n", + (char *)&(pvid->vid_vd) - (char *)pvid); + printf("vid_cas %x %x\n", pvid->vid_cas, + (char *)&(pvid->vid_cas) - (char *)pvid); + printf("vid_cal %x %x\n", pvid->vid_cal, + (char *)&(pvid->vid_cal) - (char *)pvid); + printf("vid_moto %s %x\n", pvid->vid_mot, + (char *)&(pvid->vid_mot[0]) - (char *)pvid); + + free(pvid); + + pcfg = (struct cfg *) malloc(sizeof(struct cfg)); + + fread(pcfg, sizeof(struct cfg), 1, stdin); + + if (BYTE_ORDER != BIG_ENDIAN) + swabcfg(pcfg); + + printf("cfg_atm %x %x\n", pcfg->cfg_atm, + (char *)&(pcfg->cfg_atm) - (char *)(pcfg)); + printf("cfg_prm %x %x\n", pcfg->cfg_prm, + (char *)&(pcfg->cfg_prm) - (char *)(pcfg)); + printf("cfg_atw %x %x\n", pcfg->cfg_atw, + (char *)&(pcfg->cfg_atw) - (char *)(pcfg)); + printf("cfg_rec %x %x\n",(long)pcfg->cfg_rec, + (char *)&(pcfg->cfg_rec) - (char *)(pcfg)); + printf("cfg_spt %x %x\n", pcfg->cfg_spt, + (char *)&(pcfg->cfg_spt) - (char *)(pcfg)); + printf("cfg_hds %x %x\n", pcfg->cfg_hds, + (char *)&(pcfg->cfg_hds) - (char *)(pcfg)); + printf("cfg_trk %x %x\n", pcfg->cfg_trk, + (char *)&(pcfg->cfg_trk) - (char *)(pcfg)); + printf("cfg_ilv %x %x\n", pcfg->cfg_ilv, + (char *)&(pcfg->cfg_ilv) - (char *)(pcfg)); + printf("cfg_sof %x %x\n", pcfg->cfg_sof, + (char *)&(pcfg->cfg_sof) - (char *)(pcfg)); + printf("cfg_psm %x %x\n", pcfg->cfg_psm, + (char *)&(pcfg->cfg_psm) - (char *)(pcfg)); + printf("cfg_shd %x %x\n", pcfg->cfg_shd, + (char *)&(pcfg->cfg_shd) - (char *)(pcfg)); + printf("cfg_pcom %x %x\n", pcfg->cfg_pcom, + (char *)&(pcfg->cfg_pcom) - (char *)(pcfg)); + printf("cfg_ssr %x %x\n", pcfg->cfg_ssr, + (char *)&(pcfg->cfg_ssr) - (char *)(pcfg)); + printf("cfg_rwcc %x %x\n", pcfg->cfg_rwcc, + (char *)&(pcfg->cfg_rwcc) - (char *)(pcfg)); + printf("cfg_ecc %x %x\n", pcfg->cfg_ecc, + (char *)&(pcfg->cfg_ecc) - (char *)(pcfg)); + printf("cfg_eatm %x %x\n", pcfg->cfg_eatm, + (char *)&(pcfg->cfg_eatm) - (char *)(pcfg)); + printf("cfg_eprm %x %x\n", pcfg->cfg_eprm, + (char *)&(pcfg->cfg_eprm) - (char *)(pcfg)); + printf("cfg_eatw %x %x\n", pcfg->cfg_eatw, + (char *)&(pcfg->cfg_eatw) - (char *)(pcfg)); + printf("cfg_gpb1 %x %x\n", pcfg->cfg_gpb1, + (char *)&(pcfg->cfg_gpb1) - (char *)(pcfg)); + printf("cfg_gpb2 %x %x\n", pcfg->cfg_gpb2, + (char *)&(pcfg->cfg_gpb2) - (char *)(pcfg)); + printf("cfg_gpb3 %x %x\n", pcfg->cfg_gpb3, + (char *)&(pcfg->cfg_gpb3) - (char *)(pcfg)); + printf("cfg_gpb4 %x %x\n", pcfg->cfg_gpb4, + (char *)&(pcfg->cfg_gpb4) - (char *)(pcfg)); + printf("cfg_ssc %x %x\n", pcfg->cfg_ssc, + (char *)&(pcfg->cfg_ssc) - (char *)(pcfg)); + printf("cfg_runit %x %x\n", pcfg->cfg_runit, + (char *)&(pcfg->cfg_runit) - (char *)(pcfg)); + printf("cfg_rsvc1 %x %x\n", pcfg->cfg_rsvc1, + (char *)&(pcfg->cfg_rsvc1) - (char *)(pcfg)); + printf("cfg_rsvc2 %x %x\n", pcfg->cfg_rsvc2, + (char *)&(pcfg->cfg_rsvc2) - (char *)(pcfg)); +} + +swabvid(pvid) + struct vid *pvid; +{ + M_32_SWAP(pvid->vid_oss); + M_16_SWAP(pvid->vid_osl); + M_16_SWAP(pvid->vid_osa_u); + M_16_SWAP(pvid->vid_osa_l); + M_32_SWAP(pvid->vid_cas); +} + +swabcfg(pcfg) + struct cfg *pcfg; +{ + printf("swapping cfg\n"); + + M_16_SWAP(pcfg->cfg_atm); + M_16_SWAP(pcfg->cfg_prm); + M_16_SWAP(pcfg->cfg_atm); + M_16_SWAP(pcfg->cfg_rec); + M_16_SWAP(pcfg->cfg_trk); + M_16_SWAP(pcfg->cfg_psm); + M_16_SWAP(pcfg->cfg_shd); + M_16_SWAP(pcfg->cfg_pcom); + M_16_SWAP(pcfg->cfg_rwcc); + M_16_SWAP(pcfg->cfg_ecc); + M_16_SWAP(pcfg->cfg_eatm); + M_16_SWAP(pcfg->cfg_eprm); + M_16_SWAP(pcfg->cfg_eatw); + M_16_SWAP(pcfg->cfg_rsvc1); + M_16_SWAP(pcfg->cfg_rsvc2); +} diff --git a/sys/arch/mvme88k/stand/sboot/Makefile b/sys/arch/mvme88k/stand/sboot/Makefile new file mode 100644 index 00000000000..b1bb7bfe205 --- /dev/null +++ b/sys/arch/mvme88k/stand/sboot/Makefile @@ -0,0 +1,39 @@ +# $Id: Makefile,v 1.1 1997/03/03 19:30:41 rahnds Exp $ + +S= ${.CURDIR}/../../../.. +INCL?= -I${.CURDIR} -I${.CURDIR}/../libsa -I${S}/lib/libsa -I${S} +COPTS?= ${DEFS} ${INCL} + +.include "${S}/arch/${MACHINE}/stand/libsa/Makefile.inc" + +SRCS= sboot.c clock.c etherfun.c if_le.c + +OBJS= ${SRCS:S/.c/.o/g} +CLEANFILES+=XBUG.o XSRT0.o oc_cksum.o sboot.tmp rboot.tmp srec sboot rboot +MDEC_DIR?=/usr/mdec + +all: sboot rboot + +sboot.tmp: XSRT0.o oc_cksum.o ${OBJS} ${LIBSA} + ld -N -s -static -T 0x4000 XSRT0.o ${OBJS} oc_cksum.o -o sboot.tmp ${LIBSA} + +rboot.tmp: XBUG.o XSRT0.o oc_cksum.o ${OBJS} ${LIBSA} + ld -N -s -static -Ttext 0xffa00000 -Tdata 0x4000 XBUG.o XSRT0.o \ + ${OBJS} oc_cksum.o -o rboot.tmp ${LIBSA} + +srec: srec.c + ${CC} ${.CURDIR}/srec.c -o srec + +sboot: sboot.tmp srec + dd ibs=32 skip=1 if=sboot.tmp | ${.OBJDIR}/srec 4 0x4000 sboot > sboot + +rboot: rboot.tmp srec + dd ibs=32 skip=1 if=rboot.tmp | ${.OBJDIR}/srec 4 0x4000 rboot > rboot + +install: + install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + sboot ${DESTDIR}${MDEC_DIR}/sboot + install ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + rboot ${DESTDIR}${MDEC_DIR}/rboot + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/sboot/XBUG.S b/sys/arch/mvme88k/stand/sboot/XBUG.S new file mode 100644 index 00000000000..288f1427b21 --- /dev/null +++ b/sys/arch/mvme88k/stand/sboot/XBUG.S @@ -0,0 +1,73 @@ +/* + * Copyright (c) 1995 Theo de Raadt + * + * 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 under OpenBSD by + * Theo de Raadt for Willowglen Singapore. + * 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. + */ + +/* + * Theo sez: I wrote a bootrom for the MVME147 *years* ago. To write + * this ROM I copied a few chunks from the old bootrom, like this piece: + * + * "watch this, the moto bastard struck here, shouldn't have hired people + * from intel I tried to tell them... + * "BOOT" + * offset from baseaddr to entry point. + * offset from baseaddr to first word after checksum + * garbage + * checksum made with CS command + * No need to change any of this unless you try to take our names out + * of there. Ie. don't touch." + */ + + .text +bootlabel: .ascii "BOOT" + .long bootstart-0xffa00000 | for rom install + .long bootlabelend - bootlabel + .asciz "VME147 rboot Copyright (c) 1995 Theo de Raadt" + .align 2 +bootstart: jmp bssclr + .word 0x229c | XXX bitching cksum! +bootlabelend: + .word 0 + + | clear bss and the kernel location +bssclr: movl #_edata,a0 + movl #_end - _edata,d0 +1: clrb a0@+ + subql #1,d0 + bpl 1b + + | rip the data segment from ROM into ram.. + movl #_etext,a2 | start of data + movl #0x4000,a1 | shovel address + movl #_edata - _etext,d0 +1: movb a2@+,a1@+ + subql #1,d0 + bpl 1b + + bra start diff --git a/sys/arch/mvme88k/stand/sboot/XSRT0.S b/sys/arch/mvme88k/stand/sboot/XSRT0.S new file mode 100644 index 00000000000..805528203f2 --- /dev/null +++ b/sys/arch/mvme88k/stand/sboot/XSRT0.S @@ -0,0 +1,71 @@ +/* + * Copyright (c) 1995 Theo de Raadt + * + * 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 under OpenBSD by + * Theo de Raadt for Willowglen Singapore. + * 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. + * + * Copyright (c) 1995 Charles D. Cranor + * 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 Charles D. Cranor. + * 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. + */ + + | start at 0x4000, load at 0xa000, stack at 0x9ff0. + .text + .globl start +start: movb #0,_reboot + jra Ldoit +restart: movb #1,_reboot | fall through + +Ldoit: movl #0x00006ff0,sp + jsr _main + + .globl ___main +___main: rts diff --git a/sys/arch/mvme88k/stand/sboot/clock.c b/sys/arch/mvme88k/stand/sboot/clock.c new file mode 100644 index 00000000000..fb7e4dd426e --- /dev/null +++ b/sys/arch/mvme88k/stand/sboot/clock.c @@ -0,0 +1,122 @@ +/* $Id: clock.c,v 1.1 1997/03/03 19:30:41 rahnds Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * Copyright (c) 1994 Gordon W. Ross + * Copyright (c) 1993 Adam Glass + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Lawrence Berkeley Laboratory. + * + * 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 University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)clock.c 8.1 (Berkeley) 6/11/93 + */ + +/* + * Clock driver. + */ + +#include <sys/cdefs.h> +#include "sboot.h" +#include "clockreg.h" + +static struct clockreg *clockreg = (struct clockreg *) CLOCK_ADDR; + +/* + * BCD to decimal and decimal to BCD. + */ +#define FROMBCD(x) (((x) >> 4) * 10 + ((x) & 0xf)) +#define TOBCD(x) (((x) / 10 * 16) + ((x) % 10)) + +#define SECDAY (24 * 60 * 60) +#define SECYR (SECDAY * 365) +#define LEAPYEAR(y) (((y) & 3) == 0) + +/* + * This code is defunct after 2068. + * Will Unix still be here then?? + */ +const short dayyr[12] = + {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; + +static u_long +chiptotime(sec, min, hour, day, mon, year) + register int sec, min, hour, day, mon, year; +{ + register int days, yr; + + sec = FROMBCD(sec); + min = FROMBCD(min); + hour = FROMBCD(hour); + day = FROMBCD(day); + mon = FROMBCD(mon); + year = FROMBCD(year) + YEAR0; + if (year < 70) + year = 70; + + /* simple sanity checks */ + if (year < 70 || mon < 1 || mon > 12 || day < 1 || day > 31) + return (0); + days = 0; + for (yr = 70; yr < year; yr++) + days += LEAPYEAR(yr) ? 366 : 365; + days += dayyr[mon - 1] + day - 1; + if (LEAPYEAR(yr) && mon > 2) + days++; + /* now have days since Jan 1, 1970; the rest is easy... */ + return (days * SECDAY + hour * 3600 + min * 60 + sec); +} + +/* + * Set up the system's time, given a `reasonable' time value. + */ +u_long +time() +{ + register struct clockreg *cl = clockreg; + int sec, min, hour, day, mon, year; + + cl->cl_csr |= CLK_READ; /* enable read (stop time) */ + sec = cl->cl_sec; + min = cl->cl_min; + hour = cl->cl_hour; + day = cl->cl_mday; + mon = cl->cl_month; + year = cl->cl_year; + cl->cl_csr &= ~CLK_READ;/* time wears on */ + return (chiptotime(sec, min, hour, day, mon, year)); +} diff --git a/sys/arch/mvme88k/stand/sboot/clockreg.h b/sys/arch/mvme88k/stand/sboot/clockreg.h new file mode 100644 index 00000000000..0fcac06446b --- /dev/null +++ b/sys/arch/mvme88k/stand/sboot/clockreg.h @@ -0,0 +1,69 @@ +/* $Id: clockreg.h,v 1.1 1997/03/03 19:30:41 rahnds Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This software was developed by the Computer Systems Engineering group + * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and + * contributed to Berkeley. + * + * All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Lawrence Berkeley Laboratory. + * + * 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 University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)clockreg.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * Mostek MK48T02 clock. + */ +struct clockreg { + volatile u_char cl_csr; /* control register */ + volatile u_char cl_sec; /* seconds (0..59; BCD) */ + volatile u_char cl_min; /* minutes (0..59; BCD) */ + volatile u_char cl_hour; /* hour (0..23; BCD) */ + volatile u_char cl_wday; /* weekday (1..7) */ + volatile u_char cl_mday; /* day in month (1..31; BCD) */ + volatile u_char cl_month; /* month (1..12; BCD) */ + volatile u_char cl_year; /* year (0..99; BCD) */ +}; + +/* bits in cl_csr */ +#define CLK_WRITE 0x80 /* want to write */ +#define CLK_READ 0x40 /* want to read (freeze clock) */ + +/* + * Sun chose the year `68' as their base count, so that + * cl_year==0 means 1968. + */ +#define YEAR0 68 diff --git a/sys/arch/mvme88k/stand/sboot/etherfun.c b/sys/arch/mvme88k/stand/sboot/etherfun.c new file mode 100644 index 00000000000..01987b15f4c --- /dev/null +++ b/sys/arch/mvme88k/stand/sboot/etherfun.c @@ -0,0 +1,215 @@ +/* + * + * Copyright (c) 1995 Charles D. Cranor and Seth Widoff + * 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 Charles D. Cranor + * and Seth Widoff. + * 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. + */ +/* etherfun.c */ + +#include <sys/cdefs.h> +#include "sboot.h" +#include "etherfun.h" + +/* Construct and send a rev arp packet */ +void +do_rev_arp() +{ + int i; + + for (i = 0; i < 6; i++) + eh->ether_dhost[i] = 0xff; + + bcopy(myea, eh->ether_shost, 6); + eh->ether_type = ETYPE_RARP; + + rarp->ar_hrd = 1; /* hardware type is 1 */ + rarp->ar_pro = PTYPE_IP; + rarp->ar_hln = 6; /* length of hardware address is 6 bytes */ + rarp->ar_pln = 4; /* length of ip address is 4 byte */ + rarp->ar_op = OPCODE_RARP; + bcopy(myea, rarp->arp_sha, sizeof(myea)); + bcopy(myea, rarp->arp_tha, sizeof(myea)); + for (i = 0; i < 4; i++) + rarp->arp_spa[i] = rarp->arp_tpa[i] = 0x00; + + le_put(buf, 76); +} + +/* Receive and disassemble the rev_arp reply */ +int +get_rev_arp() +{ + le_get(buf, sizeof(buf), 6); + if (eh->ether_type == ETYPE_RARP && rarp->ar_op == OPCODE_REPLY) { + bcopy(rarp->arp_tpa, myip, sizeof(rarp->arp_tpa)); + bcopy(rarp->arp_spa, servip, sizeof(rarp->arp_spa)); + bcopy(rarp->arp_sha, servea, sizeof(rarp->arp_sha)); + return (1); + } + return (0); +} + +/* Try to get a reply to a rev arp request */ +int +rev_arp() +{ + int tries = 0; + while (tries < 5) { + do_rev_arp(); + if (get_rev_arp()) + return (1); + tries++; + } + return (0); +} + +/* + * Send a tftp read request or acknowledgement + * mesgtype 0 is a read request, 1 is an + * acknowledgement + */ +void +do_send_tftp(mesgtype) + int mesgtype; +{ + u_long res, iptmp, lcv; + char *tot; + + if (mesgtype == 0) { + tot = tftp_r + (sizeof(MSG) - 1); + myport = (u_short) time(); + if (myport < 1000) + myport += 1000; + servport = FTP_PORT; /* to start */ + } else { + tot = (char *) tftp_a + 4; + } + + bcopy(servea, eh->ether_dhost, sizeof(servea)); + bcopy(myea, eh->ether_shost, sizeof(myea)); + eh->ether_type = ETYPE_IP; + + iph->ip_v = IP_VERSION; + iph->ip_hl = IP_HLEN; + iph->ip_tos = 0; /* type of service is 0 */ + iph->ip_id = 0; /* id field is 0 */ + iph->ip_off = IP_DF; + iph->ip_ttl = 3; /* time to live is 3 seconds/hops */ + iph->ip_p = IPP_UDP; + bcopy(myip, iph->ip_src, sizeof(myip)); + bcopy(servip, iph->ip_dst, sizeof(servip)); + iph->ip_sum = 0; + iph->ip_len = tot - (char *) iph; + res = oc_cksum(iph, sizeof(struct ip), 0); + iph->ip_sum = 0xffff & ~res; + udph->uh_sport = myport; + udph->uh_dport = servport; + udph->uh_sum = 0; + + if (mesgtype) { + tftp_a->op_code = FTPOP_ACKN; + tftp_a->block = (u_short) (mesgtype); + } else { + bcopy(myip, &iptmp, sizeof(iptmp)); + bcopy(MSG, tftp_r, (sizeof(MSG) - 1)); + for (lcv = 9; lcv >= 2; lcv--) { + tftp_r[lcv] = "0123456789ABCDEF"[iptmp & 0xF]; + + iptmp = iptmp >> 4; + } + } + + udph->uh_ulen = tot - (char *) udph; + + le_put(buf, tot - buf); +} + +/* Attempt to tftp a file and read it into memory */ +int +do_get_file() +{ + int fail = 0, oldlen; + char *loadat = (char *) LOAD_ADDR; + last_ack = 0; + + do_send_tftp(READ); + while (1) { + if (le_get(buf, sizeof(buf), 5) == 0) { + /* timeout occured */ + if (last_ack) + do_send_tftp(last_ack); + else + do_send_tftp(READ); + + fail++; + if (fail > 5) { + printf("\n"); + return (1); + } + } else { + printf("%x \r", tftp->info.block * 512); + if ((eh->ether_type != ETYPE_IP) || (iph->ip_p != IPP_UDP)) { + fail++; + continue; + } + if (servport == FTP_PORT) + servport = udph->uh_sport; + if (tftp->info.op_code == FTPOP_ERR) { + printf("TFTP: Download error %d: %s\n", + tftp->info.block, tftp->data); + return (1); + } + if (tftp->info.block != last_ack + 1) { + /* we received the wrong block */ + if (tftp->info.block < last_ack + 1) { + /* nack whatever we received */ + do_send_tftp(tftp->info.block); + } else { + /* nack the last confirmed block */ + do_send_tftp(last_ack); + } + fail++; + } else {/* we got the right block */ + fail = 0; + last_ack++; + oldlen = udph->uh_ulen; + do_send_tftp(last_ack); + /* printf("bcopy %x %x %d\n", &tftp->data, + * loadat, oldlen - 12); */ + bcopy(&tftp->data, loadat, oldlen - 12); + loadat += oldlen - 12; + if (oldlen < (8 + 4 + 512)) { + printf("\n"); + return (0); + } + } + } + } + printf("\n"); + return (0); +} diff --git a/sys/arch/mvme88k/stand/sboot/etherfun.h b/sys/arch/mvme88k/stand/sboot/etherfun.h new file mode 100644 index 00000000000..64170e05fd9 --- /dev/null +++ b/sys/arch/mvme88k/stand/sboot/etherfun.h @@ -0,0 +1,124 @@ +/* + * + * Copyright (c) 1995 Charles D. Cranor and Seth Widoff + * 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 Charles D. Cranor + * and Seth Widoff. + * 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. + */ +/* etherfun.h */ + +/* constants */ +/* ether header */ +#define ETYPE_RARP 0x8035 /* ethertype is RARP */ +#define ETYPE_IP 0x800 /* ethertype is IP */ + +/* rev arp */ +#define PTYPE_IP 0x800 /* Protocol type is IP */ +#define OPCODE_RARP 3 /* Optype is REVARP request */ +#define OPCODE_REPLY 4 /* Optype is REVARP reply */ + +/* ip header */ +#define IPP_UDP 17 /* IP Protocol is UDP */ +#define IP_VERSION 4 /* IP version number */ +#define IP_HLEN 5 /* IP header length is a fixed 50 bytes */ +#define N 1536 + +/* tftp header */ +#define FTPOP_ACKN 4 /* Opcode is acknowledge */ +#define FTPOP_ERR 5 /* Opcode is Error */ +#define FTP_PORT 69 /* Standard TFTP port number */ +#define MSG "\0\1xxxxxxxx.mvme68k\0octet\0" /* implicit NULL */ + +/* data structures */ + +struct ether_header { + u_char ether_dhost[6]; + u_char ether_shost[6]; + u_short ether_type; +}; + +struct ether_arp { + u_short ar_hrd; /* format of hardware address */ + u_short ar_pro; /* format of protocol address */ + u_char ar_hln; /* length of hardware address */ + u_char ar_pln; /* length of protocol address */ + u_short ar_op; + u_char arp_sha[6]; /* sender hardware address */ + u_char arp_spa[4]; /* sender protocol address */ + u_char arp_tha[6]; /* target hardware address */ + u_char arp_tpa[4]; /* target protocol address */ +}; + +struct ip { + u_char ip_v:4, /* version */ + ip_hl:4; /* header length */ + u_char ip_tos; /* type of service */ + short ip_len; /* total length */ + u_short ip_id; /* identification */ + short ip_off; /* fragment offset field */ +#define IP_DF 0x4000 /* dont fragment flag */ +#define IP_MF 0x2000 /* more fragments flag */ +#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ + u_char ip_ttl; /* time to live */ + u_char ip_p; /* protocol */ + u_short ip_sum; /* checksum */ + u_char ip_src[4]; + u_char ip_dst[4]; /* source and dest address */ +}; + +struct udp { + u_short uh_sport; + u_short uh_dport; + short uh_ulen; + u_short uh_sum; +}; + +struct tftph { + u_short op_code; + u_short block; +}; + +struct tftphr { + struct tftph info; + char data[1]; +}; + +/* globals */ +int last_ack; +char buf[N]; +struct ether_header *eh = (struct ether_header *)buf; +struct ether_arp *rarp = (struct ether_arp *) + (buf + sizeof(struct ether_header)); +struct ip *iph = (struct ip *)(buf + sizeof(struct ether_header)); +struct udp *udph = (struct udp *) + (buf + sizeof(struct ether_header) + sizeof(struct ip)); +char *tftp_r = buf + sizeof(struct ether_header) + sizeof(struct ip) + + sizeof(struct udp); +struct tftph *tftp_a = (struct tftph *)(buf + sizeof(struct ether_header) + + sizeof(struct ip) + sizeof(struct udp)); +struct tftphr *tftp = (struct tftphr *)(buf + sizeof(struct ether_header) + + sizeof(struct ip) + sizeof(struct udp)); diff --git a/sys/arch/mvme88k/stand/sboot/if_le.c b/sys/arch/mvme88k/stand/sboot/if_le.c new file mode 100644 index 00000000000..34cfd777217 --- /dev/null +++ b/sys/arch/mvme88k/stand/sboot/if_le.c @@ -0,0 +1,356 @@ +/* $Id: if_le.c,v 1.1 1997/03/03 19:30:41 rahnds Exp $ */ + +/* + * Copyright (c) 1995 Theo de Raadt + * + * 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 under OpenBSD by + * Theo de Raadt for Willowglen Singapore. + * 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. + * + * Copyright (c) 1993 Adam Glass + * 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 Adam Glass. + * 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 Adam Glass ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +#include "sboot.h" +#include "if_lereg.h" + +struct { + struct lereg1 *sc_r1; /* LANCE registers */ + struct lereg2 *sc_r2; /* RAM */ + int next_rmd; + int next_tmd; +} le_softc; + +void +le_error(str, ler1) + char *str; + struct lereg1 *ler1; +{ + /* ler1->ler1_rap = LE_CSRO done in caller */ + if (ler1->ler1_rdp & LE_C0_BABL) { + printf("le0: been babbling, found by '%s'\n", str); + callrom(); + } + if (ler1->ler1_rdp & LE_C0_CERR) { + ler1->ler1_rdp = LE_C0_CERR; + } + if (ler1->ler1_rdp & LE_C0_MISS) { + ler1->ler1_rdp = LE_C0_MISS; + } + if (ler1->ler1_rdp & LE_C0_MERR) { + printf("le0: memory error in '%s'\n", str); + callrom(); + } +} + +void +le_reset(myea) + u_char *myea; +{ + struct lereg1 *ler1 = le_softc.sc_r1; + struct lereg2 *ler2 = le_softc.sc_r2; + unsigned int a; + int timo = 100000, stat, i; + + ler1->ler1_rap = LE_CSR0; + ler1->ler1_rdp = LE_C0_STOP; /* do nothing until we are finished */ + + bzero(ler2, sizeof(*ler2)); + + ler2->ler2_mode = LE_MODE_NORMAL; + ler2->ler2_padr[0] = myea[1]; + ler2->ler2_padr[1] = myea[0]; + ler2->ler2_padr[2] = myea[3]; + ler2->ler2_padr[3] = myea[2]; + ler2->ler2_padr[4] = myea[5]; + ler2->ler2_padr[5] = myea[4]; + + + ler2->ler2_ladrf0 = 0; + ler2->ler2_ladrf1 = 0; + + a = (u_int) ler2->ler2_rmd; + ler2->ler2_rlen = LE_RLEN | (a >> 16); + ler2->ler2_rdra = a & LE_ADDR_LOW_MASK; + + a = (u_int) ler2->ler2_tmd; + ler2->ler2_tlen = LE_TLEN | (a >> 16); + ler2->ler2_tdra = a & LE_ADDR_LOW_MASK; + + ler1->ler1_rap = LE_CSR1; + a = (u_int) ler2; + ler1->ler1_rdp = a & LE_ADDR_LOW_MASK; + ler1->ler1_rap = LE_CSR2; + ler1->ler1_rdp = a >> 16; + + for (i = 0; i < LERBUF; i++) { + a = (u_int) & ler2->ler2_rbuf[i]; + ler2->ler2_rmd[i].rmd0 = a & LE_ADDR_LOW_MASK; + ler2->ler2_rmd[i].rmd1_bits = LE_R1_OWN; + ler2->ler2_rmd[i].rmd1_hadr = a >> 16; + ler2->ler2_rmd[i].rmd2 = -LEMTU; + ler2->ler2_rmd[i].rmd3 = 0; + } + for (i = 0; i < LETBUF; i++) { + a = (u_int) & ler2->ler2_tbuf[i]; + ler2->ler2_tmd[i].tmd0 = a & LE_ADDR_LOW_MASK; + ler2->ler2_tmd[i].tmd1_bits = 0; + ler2->ler2_tmd[i].tmd1_hadr = a >> 16; + ler2->ler2_tmd[i].tmd2 = 0; + ler2->ler2_tmd[i].tmd3 = 0; + } + + ler1->ler1_rap = LE_CSR3; + ler1->ler1_rdp = LE_C3_BSWP; + + ler1->ler1_rap = LE_CSR0; + ler1->ler1_rdp = LE_C0_INIT; + do { + if (--timo == 0) { + printf("le0: init timeout, stat = 0x%x\n", stat); + break; + } + stat = ler1->ler1_rdp; + } while ((stat & LE_C0_IDON) == 0); + + ler1->ler1_rdp = LE_C0_IDON; + le_softc.next_rmd = 0; + le_softc.next_tmd = 0; + ler1->ler1_rap = LE_CSR0; + ler1->ler1_rdp = LE_C0_STRT; +} + +int +le_poll(pkt, len) + void *pkt; + int len; +{ + struct lereg1 *ler1 = le_softc.sc_r1; + struct lereg2 *ler2 = le_softc.sc_r2; + unsigned int a; + int length; + struct lermd *rmd; + + ler1->ler1_rap = LE_CSR0; + if ((ler1->ler1_rdp & LE_C0_RINT) != 0) + ler1->ler1_rdp = LE_C0_RINT; + rmd = &ler2->ler2_rmd[le_softc.next_rmd]; + if (rmd->rmd1_bits & LE_R1_OWN) { + return (0); + } + if (ler1->ler1_rdp & LE_C0_ERR) + le_error("le_poll", ler1); + if (rmd->rmd1_bits & LE_R1_ERR) { + printf("le0_poll: rmd status 0x%x\n", rmd->rmd1_bits); + length = 0; + goto cleanup; + } + if ((rmd->rmd1_bits & (LE_R1_STP | LE_R1_ENP)) != (LE_R1_STP | LE_R1_ENP)) { + printf("le_poll: chained packet\n"); + callrom(); + } + length = rmd->rmd3; + if (length >= LEMTU) { + length = 0; + printf("csr0 when bad things happen: %x\n", ler1->ler1_rdp); + callrom(); + goto cleanup; + } + if (!length) + goto cleanup; + length -= 4; + if (length > 0) + bcopy((char *) &ler2->ler2_rbuf[le_softc.next_rmd], pkt, length); + +cleanup: + a = (u_int) & ler2->ler2_rbuf[le_softc.next_rmd]; + rmd->rmd0 = a & LE_ADDR_LOW_MASK; + rmd->rmd1_hadr = a >> 16; + rmd->rmd2 = -LEMTU; + le_softc.next_rmd = + (le_softc.next_rmd == (LERBUF - 1)) ? 0 : (le_softc.next_rmd + 1); + rmd->rmd1_bits = LE_R1_OWN; + return length; +} + +int +le_put(pkt, len) + u_char *pkt; + size_t len; +{ + struct lereg1 *ler1 = le_softc.sc_r1; + struct lereg2 *ler2 = le_softc.sc_r2; + struct letmd *tmd; + int timo = 100000, stat, i; + unsigned int a; + + ler1->ler1_rap = LE_CSR0; + if (ler1->ler1_rdp & LE_C0_ERR) + le_error("le_put(way before xmit)", ler1); + tmd = &ler2->ler2_tmd[le_softc.next_tmd]; + while (tmd->tmd1_bits & LE_T1_OWN) { + printf("le0: output buffer busy\n"); + } + bcopy(pkt, (char *) ler2->ler2_tbuf[le_softc.next_tmd], len); + if (len < 64) + tmd->tmd2 = -64; + else + tmd->tmd2 = -len; + tmd->tmd3 = 0; + if (ler1->ler1_rdp & LE_C0_ERR) + le_error("le_put(before xmit)", ler1); + tmd->tmd1_bits = LE_T1_STP | LE_T1_ENP | LE_T1_OWN; + a = (u_int) & ler2->ler2_tbuf[le_softc.next_tmd]; + tmd->tmd0 = a & LE_ADDR_LOW_MASK; + tmd->tmd1_hadr = a >> 16; + ler1->ler1_rdp = LE_C0_TDMD; + if (ler1->ler1_rdp & LE_C0_ERR) + le_error("le_put(after xmit)", ler1); + do { + if (--timo == 0) { + printf("le0: transmit timeout, stat = 0x%x\n", + stat); + if (ler1->ler1_rdp & LE_C0_ERR) + le_error("le_put(timeout)", ler1); + break; + } + stat = ler1->ler1_rdp; + } while ((stat & LE_C0_TINT) == 0); + ler1->ler1_rdp = LE_C0_TINT; + if (ler1->ler1_rdp & LE_C0_ERR) { + if ((ler1->ler1_rdp & (LE_C0_BABL | LE_C0_CERR | LE_C0_MISS | LE_C0_MERR)) != + LE_C0_CERR) + printf("le_put: xmit error, buf %d\n", le_softc.next_tmd); + le_error("le_put(xmit error)", ler1); + } + le_softc.next_tmd = 0; +/* (le_softc.next_tmd == (LETBUF - 1)) ? 0 : le_softc.next_tmd + 1;*/ + if (tmd->tmd1_bits & LE_T1_ERR) { + printf("le0: transmit error, error = 0x%x\n", + tmd->tmd3); + return -1; + } + return len; +} + +int +le_get(pkt, len, timeout) + u_char *pkt; + size_t len; + u_long timeout; +{ + int cc; + int now, then; + int stopat = time() + timeout; + then = 0; + + cc = 0; + while ((now = time()) < stopat && !cc) { + cc = le_poll(pkt, len); + if (then != now) { +#ifdef LE_DEBUG + printf("%d \r", stopat - now); +#endif + then = now; + } + if (cc && (pkt[0] != myea[0] || pkt[1] != myea[1] || + pkt[2] != myea[2] || pkt[3] != myea[3] || + pkt[4] != myea[4] || pkt[5] != myea[5])) { + cc = 0; /* ignore broadcast / multicast */ +#ifdef LE_DEBUG + printf("reject (%d sec left)\n", stopat - now); +#endif + } + } +#ifdef LE_DEBUG + printf("\n"); +#endif + return cc; +} + +void +le_init() +{ + caddr_t addr; + int *ea = (int *) LANCE_ADDR; + u_long *eram = (u_long *) ERAM_ADDR; + u_long e = *ea; + if ((e & 0x2fffff00) == 0x2fffff00) { + printf("ERROR: ethernet address not set! Use LSAD.\n"); + callrom(); + } + myea[0] = 0x08; + myea[1] = 0x00; + myea[2] = 0x3e; + e = e >> 8; + myea[5] = e & 0xff; + e = e >> 8; + myea[4] = e & 0xff; + e = e >> 8; + myea[3] = e; + printf("le0: ethernet address: %x:%x:%x:%x:%x:%x\n", + myea[0], myea[1], myea[2], myea[3], myea[4], myea[5]); + bzero(&le_softc, sizeof(le_softc)); + le_softc.sc_r1 = (struct lereg1 *) LANCE_REG_ADDR; + le_softc.sc_r2 = (struct lereg2 *) (*eram - (1024 * 1024)); + le_reset(myea); +} + +void +le_end() +{ + struct lereg1 *ler1 = le_softc.sc_r1; + + ler1->ler1_rap = LE_CSR0; + ler1->ler1_rdp = LE_C0_STOP; +} diff --git a/sys/arch/mvme88k/stand/sboot/if_lereg.h b/sys/arch/mvme88k/stand/sboot/if_lereg.h new file mode 100644 index 00000000000..a8728b13891 --- /dev/null +++ b/sys/arch/mvme88k/stand/sboot/if_lereg.h @@ -0,0 +1,176 @@ +/* $Id: if_lereg.h,v 1.1 1997/03/03 19:30:41 rahnds Exp $ */ + +/*- + * Copyright (c) 1982, 1992, 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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. + * + * @(#)if_lereg.h 8.2 (Berkeley) 10/30/93 + */ + +#define LEMTU 1518 +#define LEMINSIZE 60 /* should be 64 if mode DTCR is set */ +#define LERBUF 8 +#define LERBUFLOG2 3 +#define LE_RLEN (LERBUFLOG2 << 13) +#define LETBUF 1 +#define LETBUFLOG2 0 +#define LE_TLEN (LETBUFLOG2 << 13) + +/* Local Area Network Controller for Ethernet (LANCE) registers */ +struct lereg1 { + volatile u_short ler1_rdp; /* register data port */ + volatile u_short ler1_rap; /* register address port */ +}; + +/* register addresses */ +#define LE_CSR0 0 /* Control and status register */ +#define LE_CSR1 1 /* low address of init block */ +#define LE_CSR2 2 /* high address of init block */ +#define LE_CSR3 3 /* Bus master and control */ + +/* Control and status register 0 (csr0) */ +#define LE_C0_ERR 0x8000 /* error summary */ +#define LE_C0_BABL 0x4000 /* transmitter timeout error */ +#define LE_C0_CERR 0x2000 /* collision */ +#define LE_C0_MISS 0x1000 /* missed a packet */ +#define LE_C0_MERR 0x0800 /* memory error */ +#define LE_C0_RINT 0x0400 /* receiver interrupt */ +#define LE_C0_TINT 0x0200 /* transmitter interrupt */ +#define LE_C0_IDON 0x0100 /* initalization done */ +#define LE_C0_INTR 0x0080 /* interrupt condition */ +#define LE_C0_INEA 0x0040 /* interrupt enable */ +#define LE_C0_RXON 0x0020 /* receiver on */ +#define LE_C0_TXON 0x0010 /* transmitter on */ +#define LE_C0_TDMD 0x0008 /* transmit demand */ +#define LE_C0_STOP 0x0004 /* disable all external activity */ +#define LE_C0_STRT 0x0002 /* enable external activity */ +#define LE_C0_INIT 0x0001 /* begin initalization */ + +#define LE_C0_BITS \ + "\20\20ERR\17BABL\16CERR\15MISS\14MERR\13RINT\ +\12TINT\11IDON\10INTR\07INEA\06RXON\05TXON\04TDMD\03STOP\02STRT\01INIT" + +/* Control and status register 3 (csr3) */ +#define LE_C3_BSWP 0x4 /* byte swap */ +#define LE_C3_ACON 0x2 /* ALE control, eh? */ +#define LE_C3_BCON 0x1 /* byte control */ +/* + * Current size is 13,758 bytes with 8 x 1518 receive buffers and + * 1 x 1518 transmit buffer. + */ +struct lereg2 { + /* initialization block */ + volatile u_short ler2_mode; /* mode */ + volatile u_char ler2_padr[6]; /* physical address */ +#ifdef new_code + volatile u_short ler2_ladrf[4]; /* logical address filter */ +#else + volatile u_long ler2_ladrf0; /* logical address filter */ + volatile u_long ler2_ladrf1; /* logical address filter */ +#endif + volatile u_short ler2_rdra; /* receive descriptor addr */ + volatile u_short ler2_rlen; /* rda high and ring size */ + volatile u_short ler2_tdra; /* transmit descriptor addr */ + volatile u_short ler2_tlen; /* tda high and ring size */ + /* receive message descriptors. bits/hadr are byte order dependent. */ + struct lermd { + volatile u_short rmd0; /* low address of packet */ + volatile u_char rmd1_bits; /* descriptor bits */ + volatile u_char rmd1_hadr; /* high address of packet */ + volatile short rmd2; /* buffer byte count */ + volatile u_short rmd3; /* message byte count */ + } ler2_rmd[LERBUF]; + /* transmit message descriptors */ + struct letmd { + volatile u_short tmd0; /* low address of packet */ + volatile u_char tmd1_bits; /* descriptor bits */ + volatile u_char tmd1_hadr; /* high address of packet */ + volatile short tmd2; /* buffer byte count */ + volatile u_short tmd3; /* transmit error bits */ + } ler2_tmd[LETBUF]; + volatile char ler2_rbuf[LERBUF][LEMTU]; + volatile char ler2_tbuf[LETBUF][LEMTU]; +}; + +/* Initialzation block (mode) */ +#define LE_MODE_PROM 0x8000 /* promiscuous mode */ +/* 0x7f80 reserved, must be zero */ +#define LE_MODE_INTL 0x0040 /* internal loopback */ +#define LE_MODE_DRTY 0x0020 /* disable retry */ +#define LE_MODE_COLL 0x0010 /* force a collision */ +#define LE_MODE_DTCR 0x0008 /* disable transmit CRC */ +#define LE_MODE_LOOP 0x0004 /* loopback mode */ +#define LE_MODE_DTX 0x0002 /* disable transmitter */ +#define LE_MODE_DRX 0x0001 /* disable receiver */ +#define LE_MODE_NORMAL 0 /* none of the above */ + + +/* Receive message descriptor 1 (rmd1_bits) */ +#define LE_R1_OWN 0x80 /* LANCE owns the packet */ +#define LE_R1_ERR 0x40 /* error summary */ +#define LE_R1_FRAM 0x20 /* framing error */ +#define LE_R1_OFLO 0x10 /* overflow error */ +#define LE_R1_CRC 0x08 /* CRC error */ +#define LE_R1_BUFF 0x04 /* buffer error */ +#define LE_R1_STP 0x02 /* start of packet */ +#define LE_R1_ENP 0x01 /* end of packet */ + +#define LE_R1_BITS \ + "\20\10OWN\7ERR\6FRAM\5OFLO\4CRC\3BUFF\2STP\1ENP" + +/* Transmit message descriptor 1 (tmd1_bits) */ +#define LE_T1_OWN 0x80 /* LANCE owns the packet */ +#define LE_T1_ERR 0x40 /* error summary */ +#define LE_T1_MORE 0x10 /* multiple collisions */ +#define LE_T1_ONE 0x08 /* single collision */ +#define LE_T1_DEF 0x04 /* defferred transmit */ +#define LE_T1_STP 0x02 /* start of packet */ +#define LE_T1_ENP 0x01 /* end of packet */ + +#define LE_T1_BITS \ + "\20\10OWN\7ERR\6RES\5MORE\4ONE\3DEF\2STP\1ENP" + +/* Transmit message descriptor 3 (tmd3) */ +#define LE_T3_BUFF 0x8000 /* buffer error */ +#define LE_T3_UFLO 0x4000 /* underflow error */ +#define LE_T3_LCOL 0x1000 /* late collision */ +#define LE_T3_LCAR 0x0800 /* loss of carrier */ +#define LE_T3_RTRY 0x0400 /* retry error */ +#define LE_T3_TDR_MASK 0x03ff /* time domain reflectometry counter */ + +#define LE_XMD2_ONES 0xf000 + +#define LE_T3_BITS \ + "\20\20BUFF\17UFLO\16RES\15LCOL\14LCAR\13RTRY" + + +#define LE_ADDR_LOW_MASK (0xffff) + diff --git a/sys/arch/mvme88k/stand/sboot/oc_cksum.S b/sys/arch/mvme88k/stand/sboot/oc_cksum.S new file mode 100644 index 00000000000..c8b96b79817 --- /dev/null +++ b/sys/arch/mvme88k/stand/sboot/oc_cksum.S @@ -0,0 +1,187 @@ +| $Id: oc_cksum.S,v 1.1 1997/03/03 19:30:41 rahnds Exp $ + +| Copyright (c) 1988 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. All advertising materials mentioning features or use of this software +| must display the following acknowledgement: +| This product includes software developed by the University of +| California, Berkeley and its contributors. +| 4. 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. +| +| @(#)oc_cksum.s 7.2 (Berkeley) 11/3/90 +| +| +| oc_cksum: ones complement 16 bit checksum for MC68020. +| +| oc_cksum (buffer, count, strtval) +| +| Do a 16 bit ones complement sum of 'count' bytes from 'buffer'. +| 'strtval' is the starting value of the sum (usually zero). +| +| It simplifies life in in_cksum if strtval can be >= 2^16. +| This routine will work as long as strtval is < 2^31. +| +| Performance +| ----------- +| This routine is intended for MC 68020s but should also work +| for 68030s. It (deliberately) does not worry about the alignment +| of the buffer so will only work on a 68010 if the buffer is +| aligned on an even address. (Also, a routine written to use +| 68010 "loop mode" would almost certainly be faster than this +| code on a 68010). +| +| We do not worry about alignment because this routine is frequently +| called with small counts: 20 bytes for IP header checksums and 40 +| bytes for TCP ack checksums. For these small counts, testing for +| bad alignment adds ~10% to the per-call cost. Since, by the nature +| of the kernel allocator, the data we are called with is almost +| always longword aligned, there is no benefit to this added cost +| and we are better off letting the loop take a big performance hit +| in the rare cases where we are handed an unaligned buffer. +| +| Loop unrolling constants of 2, 4, 8, 16, 32 and 64 times were +| tested on random data on four different types of processors (see +| list below -- 64 was the largest unrolling because anything more +| overflows the 68020 Icache). On all the processors, the +| throughput asymptote was located between 8 and 16 (closer to 8). +| However, 16 was substantially better than 8 for small counts. +| (It is clear why this happens for a count of 40: unroll-8 pays a +| loop branch cost and unroll-16 does not. But the tests also showed +| that 16 was better than 8 for a count of 20. It is not obvious to +| me why.) So, since 16 was good for both large and small counts, +| the loop below is unrolled 16 times. +| +| The processors tested and their average time to checksum 1024 bytes +| of random data were: +| Sun 3/50 (15MHz) 190 us/KB +| Sun 3/180 (16.6MHz) 175 us/KB +| Sun 3/60 (20MHz) 134 us/KB +| Sun 3/280 (25MHz) 95 us/KB +| +| The cost of calling this routine was typically 10% of the per- +| kilobyte cost. E.g., checksumming zero bytes on a 3/60 cost 9us +| and each additional byte cost 125ns. With the high fixed cost, +| it would clearly be a gain to "inline" this routine -- the +| subroutine call adds 400% overhead to an IP header checksum. +| However, in absolute terms, inlining would only gain 10us per +| packet -- a 1% effect for a 1ms ethernet packet. This is not +| enough gain to be worth the effort. + +#include <machine/asm.h> + + .text + + .text; .even; .globl _oc_cksum; _oc_cksum: + movl sp@(4),a0 | get buffer ptr + movl sp@(8),d1 | get byte count + movl sp@(12),d0 | get starting value + movl d2,sp@- | free a reg + + | test for possible 1, 2 or 3 bytes of excess at end + | of buffer. The usual case is no excess (the usual + | case is header checksums) so we give that the faster + | 'not taken' leg of the compare. (We do the excess + | first because we are about the trash the low order + | bits of the count in d1.) + + btst #0,d1 + jne L5 | if one or three bytes excess + btst #1,d1 + jne L7 | if two bytes excess +L1: + movl d1,d2 + lsrl #6,d1 | make cnt into # of 64 byte chunks + andl #0x3c,d2 | then find fractions of a chunk + negl d2 + andb #0xf,cc | clear X + jmp pc@(L3-.-2:b,d2) +L2: + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 + movl a0@+,d2 + addxl d2,d0 +L3: + dbra d1,L2 | (NB- dbra does not affect X) + + movl d0,d1 | fold 32 bit sum to 16 bits + swap d1 | (NB- swap does not affect X) + addxw d1,d0 + jcc L4 + addw #1,d0 +L4: + andl #0xffff,d0 + movl sp@+,d2 + rts + +L5: | deal with 1 or 3 excess bytes at the end of the buffer. + btst #1,d1 + jeq L6 | if 1 excess + + | 3 bytes excess + clrl d2 + movw a0@(-3,d1:l),d2 | add in last full word then drop + addl d2,d0 | through to pick up last byte + +L6: | 1 byte excess + clrl d2 + movb a0@(-1,d1:l),d2 + lsll #8,d2 + addl d2,d0 + jra L1 + +L7: | 2 bytes excess + clrl d2 + movw a0@(-2,d1:l),d2 + addl d2,d0 + jra L1 diff --git a/sys/arch/mvme88k/stand/sboot/rboot b/sys/arch/mvme88k/stand/sboot/rboot new file mode 100644 index 00000000000..e3a83b1327e --- /dev/null +++ b/sys/arch/mvme88k/stand/sboot/rboot @@ -0,0 +1,204 @@ +S00A0000000072626F6F74CF +S32500004000424F4F540000003C00000044564D453134372072626F6F7420436F70797269671F +S325000040206874202863292031393935205468656F2064652052616164740000004EF9FFA047 +S325000040400046229C0000207C000040207000421853806A00FFFA247CFFA01908227C00005C +S325000040604000700012DA53806A00FFFA6000000213FC00000000463C600813FC00010000FD +S32500004080463C2E7C00006FF04EB9FFA000B84E750A73626F6F743A204D564D4531343720F2 +S325000040A0626F6F7473747261702070726F6772616D0A003E3E3E20004E56FF802F0A61FF64 +S325000040C0FFFFFFCE1D7C0030FF80487AFFC461FF0000159E584F45EEFF80487AFFD761FFDE +S325000040E00000158E2F0A61FF000013F82F0A610001CA504F584F60E24E714E5600004E4F86 +S3250000410000634E5E4E754D7920697020616464726573732069733A2025642E25642E2564B5 +S325000041202E25640A0053657276657220697020616464726573732069733A2025642E2564AC +S325000041402E25642E25640A004661696C65642E0A0065786974696E6720746F20524F4D0A51 +S3250000416000446F776E6C6F6164204661696C65640A00446F776E6C6F61642077617320616E +S325000041802073756363657373210A00636C69656E7420495020616464726573732025642EC0 +S325000041A025642E25642E25640A0073657276657220495020616464726573732025642E25A6 +S325000041C0642E25642E25640A005245564152503A204661696C65642E0A00726563656976D8 +S325000041E06564207365636F6E6461727920626F6F742070726F6772616D2E0A0062736400AB +S3250000420076616C696420636F6D6D616E64730A0061202D2073656E64206120524152500AB4 +S325000042200062202D20626F6F74207468652073797374656D0A0071202D2065786974207499 +S325000042406F20524F4D0A0066202D206674702074686520626F6F742066696C650A0067202E +S325000042602D20657865637574652074686520626F6F742066696C650A0068202D2068656CEB +S32500004280700A0069202D20696E6974204C414E434520656E657420636869700A0073626FB3 +S325000042A06F743A2025733A20556E6B6E6F776E20636F6D6D616E640A00004E5600002F0BF2 +S325000042C02F0A246E000810120C000067670001F26E2E0C000062670000F86E180C000061BA +S325000042E067364A00670001EC0C00003F67000192600001D40C000066670000AE600001C853 +S325000043000C000069670001B26D0001760C00007167000084600001B061FF0000054C4A8030 +S325000043206766428010390000465F2F00428010390000465E2F00428010390000465D2F0010 +S32500004340428010390000465C2F00487AFDBA45F9FFA0166E4E92428010390000463B2F0006 +S32500004360428010390000463A2F0042801039000046392F0042801039000046382F00487A4A +S32500004380FDA54E926000014C487AFDBE61FF000012E06000013E487AFDB961FF000012D2BE +S325000043A06100FD586000012C61FF000007127201B280660E487AFDAB61FF000012B4600032 +S325000043C00112487AFDAE61FF000012A66000010461FF00000F8061FF0000048E4A80660EBB +S325000043E0487AFDE761FF00001288600000E6428010390000465F2F00428010390000465E43 +S325000044002F00428010390000465D2F00428010390000465C2F00487AFD7347F9FFA0166E19 +S325000044204E93428010390000463B2F00428010390000463A2F0042801039000046392F0067 +S3250000444042801039000046382F00487AFD5E4E93DEFC002861FF000006667201B2806608BF +S32500004460487AFCFF4E93606A487AFD7061FF00001200584F524A4A12664645FAFD80604086 +S32500004480487AFD7E45F9FFA0166E4E92487AFD824E92487AFD8D4E92487AFD9C4E92487A4E +S325000044A0FDA74E92487AFDB84E92487AFDCD4E92487AFDD14E92601A61FF00000E9860124D +S325000044C02F0A613C600C2F0A487AFDD361FF000011A0246EFFF8266EFFFC4E5E4E756A7552 +S325000044E06D70696E6720746F20626F6F742070726F6772616D20617420307825782E0A001A +S325000045004E56000048E7003C246E00083A7C70002F0D487AFFCA61FF0000115642804281B3 +S32500004520264A2F0A61FF0000108ED5C0284A4ED54CEE3C00FFF04E5E4E7500000000001FB1 +S32500004540003B005A0078009700B500D400F301110130014E4E56000048E73F30266E0008C5 +S325000045602C2E000C2A2E0010282E0014262E0018242E001C200BE880244045F20C00200ABF +S32500004580720F2E0BC287244147F20A002006E880244045F20C00200A720FC286244145F2A6 +S325000045A00A002C0A2005E880244045F20C00200A720FC285244145F20A002A0A2004E88029 +S325000045C0244045F20C00200A720FC284244145F20A00280A2003E880244045F20C00200A09 +S325000045E0720FC283244145F20A00260A2002E880720FC282244045F20C00200A244145F25D +S325000046000A44240A7E45BE826D027446200353807E0BBE80650A200453807E1EBE80640487 +S325000046204280607293C97046B4806F1C307C016E223C0000016DE8C007826604D3C8600290 +S32500004640D3C15280B4806EEE41FAFEF030703A00D1C443F098FFE8C0078266087E02BE839C +S325000046606C02524943F19A0020092200E98192802401E9829481EF822005E7809085EB8074 +S32500004680D085E9802042D1C02006E980908641F00C002008D08B4CEE0CFCFFE04E5E4E756E +S325000046A04E56000048E73E0020790000400010100000004010801C2800011A280002182851 +S325000046C000031628000514280006122800071010020000BF108042A71F41000342A71F4204 +S325000046E0000342A71F43000342A71F44000342A71F45000342A71F4600036100FE584CEE82 +S32500004700007CFFEC4E5E4E754E5600002F0A428020790000400411BC00FF08005280720524 +S32500004720B2806CEC487800062239000040045C812F0148790000465445F9FFA015D04E927A +S32500004740207900004004317C8035000C20790000400830BC0001317C08000002117C0006F0 +S325000047600004207900004008117C00040005207900004008317C0003000648780006223900 +S325000047800000400850812F014879000046544E92487800067212D2B9000040082F01487981 +S325000047A0000046544E924280DEFC0024207900004008423008184230080E52807203B28045 +S325000047C06CEA4878004C48790000402861FF00000910246EFFFC4E5E4E754E5600002F0AF6 +S325000047E0487800064878060048790000402861FF00000A6E207900004004504F584F0C688F +S325000048008035000C66562079000040080C680004000666484878000448790000465C721857 +S32500004820D2882F0145F9FFA015D04E9248780004487900004638720ED2B9000040082F01C0 +S325000048404E924878000648790000463022390000400850812F014E92700160024280246ECA +S32500004860FFFC4E5E4E754E5600002F0242826100FE986100FF664A8067047001600A52828E +S325000048807204B2826CE84280242EFFFC4E5E4E75000178787878787878782E6D766D6536BC +S325000048A0386B006F6374657400003031323334353637383941424344454600004E56FFFCEF +S325000048C048E73038242E0008663228790000401447EC001961FFFFFFFDCA33C0000046406A +S325000048E00C7903E7000046406208067903E80000464033FC00450000462C60082679000076 +S325000049004018584B487800062F390000400448790000463045F9FFA015D04E924878000685 +S325000049202639000040045C832F034879000046544E92207900004004317C0800000C20794B +S325000049400000400C7604EFD0300420790000400C7605EFD0310420790000400C42280001F4 +S3250000496020790000400C42680004317C40000006117C0003000820790000400C117C001190 +S32500004980000948780004760CD6B90000400C2F0348790000465C4E92DEFC00202EBC00008E +S325000049A000047610D6B90000400C2F034879000046384E9220790000400C4268000A384B1F +S325000049C098F90000400E314C000242A7487800142F0861FF00000A5C20790000400C46404E +S325000049E03140000A20790000401030B90000464031790000462C000242680006DEFC00181E +S32500004A004A82671020790000401830BC000431420002605448780004486EFFFC487900000D +S32500004A20465C45F9FFA015D04E92487800192F3900004014487AFE5A4E927209DEFC001830 +S32500004A4043FAFE68207900004014700FC0AEFFFC11B108001800202EFFFCE8882D40FFFCD5 +S32500004A6053817601B68165DC207900004010384B98F900004012314C000497FC00004028A2 +S32500004A802F0B48790000402861FF000006544CEE1C0CFFE84E5E4E750A002578200D005413 +S32500004AA04654503A20446F776E6C6F6164206572726F722025643A2025730A004E560000E1 +S32500004AC048E73C304282283C0000700042B90000462842A76100FDE6584F428348780005D6 +S32500004AE04878060048790000402861FF00000772504F584F4A8066304AB900004628670862 +S32500004B002F3900004628600242A76100FDB0584F52827A05BA826CC4487AFF7E61FF00005B +S32500004B200B5070016000010020790000401C3628000220037A09EBA02F00487AFF5E61FF0E +S32500004B4000000B2E207900004004504F0C680800000C667820790000400C0C280011000901 +S32500004B60666A0C7900450000462C660C20790000401033D00000462C20790000401C0C5002 +S32500004B800005661E2A0858852F054280302800022F00487AFF0B61FF00000AD6700160001B +S32500004BA0008620790000401C4280302800022239000046285281B28067186F042F00600603 +S32500004BC02F39000046286100FCF4584F52826000FF0C4282203900004628528023C0000082 +S32500004BE04628207900004010366800042F006100FCCC45EBFFF42F0A2F042A390000401C10 +S32500004C0058852F0561FF000009CAD88A504F504FB7FC0000020B6E00FEC4487AFE7C61FF1E +S32500004C2000000A4E42804CEE0C3CFFE84E5E4E756C65303A206265656E20626162626C690B +S32500004C406E672C20666F756E6420627920272573270A006C65303A206D656D6F727920658D +S32500004C6072726F7220696E20272573270A004E5600002F0A2F02242E0008246E000C30121A +S32500004C800800000E67142F02487AFFA661FF000009E061FFFFFFF466504F30120800000DEE +S32500004CA0670434BC200030120800000C670434BC100030120800000B67122F02487AFF955D +S32500004CC061FF000009AC61FFFFFFF432242EFFF8246EFFFC4E5E4E756C65303A20696E6955 +S32500004CE0742074696D656F75742C2073746174203D20307825780A004E56000048E73C3CF4 +S32500004D00246E0008287900004644267900004648283C000186A0426C000238BC00044878A8 +S32500004D2035BE2F0B61FF000008E64253176A0001000217520003176A00030004176A000262 +S32500004D400005176A00050006176A0004000742AB000842AB000C7418D48B2002424048402B +S32500004D600040600037400012374200107458D48B2002424048403740001637420014397C55 +S32500004D8000010002388B397C00020002200B42404840388091C8504F4BF08A00200DEB804C +S32500004DA09088E78090884BF30A60240D2208E7813782181817BC0080181A20024240484051 +S32500004DC01780181B37BCFA12181C4273181E52487A07BA886CC291C8327C2FD04BF08A008F +S32500004DE0200DEB809088E78090884BF10A00200D240BD4802208E781378218584233185AE6 +S32500004E002002424048401780185B4273185C4273185E52484A886FC4397C0003000238BCB5 +S32500004E200004426C000238BC00015384660E2F03487AFEA661FF00000838600C30144283CB +S32500004E4036000803000867E238BC010042B90000464C42B900004650426C000238BC000201 +S32500004E604CEE3C3CFFE04E5E4E756C655F706F6C6C006C65305F706F6C6C3A20726D642071 +S32500004E8073746174757320307825780A006C655F706F6C6C3A20636861696E6564207061FB +S32500004EA0636B65740A0063737230207768656E20626164207468696E6773206861707065CF +S32500004EC06E3A2025780A00004E56000048E72038267900004644287900004648426B00022B +S32500004EE030130800000A670436BC040020390000464C45F40E18102A00026C0642806000DC +S32500004F0000F630136C0C2F0B487AFF606100FD60504F102A0002080000066718102A00021D +S32500004F2042A71F400003487AFF4A61FF0000074242826078102A0002020000030C00000380 +S32500004F406712487AFF4961FF0000072661FFFFFFF1AC584F302A0006428234000C820000B3 +S32500004F6005ED6F1A428230133F004267487AFF3861FF000006FC61FFFFFFF182602E4A823B +S32500004F80672A59824A826F242F022F2E000820790000464C43F08A002009EB809088E780AF +S32500004FA0908848740A6061FF0000062820790000464C43F08A002009EB809088E78090880C +S32500004FC049F40A60200C34804240484015400003357CFA12000441F90000464C428072071A +S32500004FE0B290670820390000464C52802080157C0080000220024CEE1C04FFF04E5E4E75B0 +S325000050006C655F70757428776179206265666F726520786D697429006C65303A206F757437 +S325000050207075742062756666657220627573790A006C655F707574286265666F72652078CE +S325000050406D697429006C655F70757428616674657220786D697429006C65303A2074726167 +S325000050606E736D69742074696D656F75742C2073746174203D20307825780A006C655F7064 +S3250000508075742874696D656F757429006C655F7075743A20786D6974206572726F722C208E +S325000050A06275662025640A006C655F70757428786D6974206572726F7229006C65303A20B9 +S325000050C07472616E736D6974206572726F722C206572726F72203D20307825780A004E5628 +S325000050E0000048E73838282E000C247900004644287900004648263C000186A0426A00021C +S3250000510030126C0C2F0A487AFEF86100FB62504F20390000465047F40E58600C487AFEFACB +S3250000512061FF0000054C584F102B00026DEE2F0420790000465043F08A002009EB809088AE +S32500005140E7809088D080068000002FD0487408002F2E000861FF0000047A504F584F723FF7 +S32500005160B2846508377CFFC0000460083004444037400004426B000630126C0C2F0A487A0D +S32500005180FEB16100FAEA504F177C0083000220790000465043F08A002009EB809088E7805F +S325000051A09088D080068000002FD0D08C3680424048401740000334BC000830126C0C2F0A9B +S325000051C0487AFE836100FAA8504F538366202F02487AFE8661FF000004983012504F6C1AAE +S325000051E02F0A487AFE986100FA86504F600C3012428234000802000967D034BC0200301274 +S325000052006C2A3012024078000C40200067122F3900004650487AFE7661FF00000454504F86 +S325000052202F0A487AFE846100FA46504F42B900004650102B000208000006660420046014CD +S32500005240302B00063F004267487AFE7161FF0000042070FF4CEE1C1CFFE84E5E4E754E566F +S32500005260000048E73E20246E00082C2E000C242E001061FFFFFFF42C2A00DA8242844283AA +S3250000528061FFFFFFF41E2400BA826F624A83665E2F062F0A6100FC322600504FB484670273 +S325000052A028024A8367DA1212B2390000465466CE122A0001B2390000465566C2122A0002AA +S325000052C0B2390000465666B6122A0003B2390000465766AA122A0004B23900004658669E81 +S325000052E0122A0005B239000046596794609020034CEE047CFFE84E5E4E754552524F523AFB +S325000053002065746865726E65742061646472657373206E6F74207365742120205573652077 +S325000053204C5341442E0A006C65303A2065746865726E657420616464726573733A20257854 +S325000053403A25783A25783A25783A25783A25780A00004E5600002F0A2F022439FFFE077823 +S32500005360200202802FFFFF000C802FFFFF006612487AFF8861FF000002F861FFFFFFED7EB9 +S32500005380584F45F90000465414BC000842390000465513FC003E00004656E08A43F900000B +S325000053A046591282E08A41F9000046581082E08A13C200004657428010112F004280101010 +S325000053C02F002F024878003E42A748780008487AFF5761FF0000029A487800104879000013 +S325000053E0464461FF0000022823FCFFFE1800000046442239FFFE07740681FFF0000023C1A8 +S3250000540000004648DEFC00202E8A6100F8EC242EFFF8246EFFFC4E5E4E754E56000020797F +S32500005420000046444268000230BC00044E5E4E75206F0004222F0008202F000C2F02080150 +S3250000544000006674080100016600008A2401EC8902820000003C4482023C000F4EFB284252 +S325000054602418D1822418D1822418D1822418D1822418D1822418D1822418D1822418D182AE +S325000054802418D1822418D1822418D1822418D1822418D1822418D1822418D1822418D1828E +S325000054A051C9FFBE22004841D1416402524002800000FFFF241F4E75080100016708428297 +S325000054C0343018FDD0824282143018FFE18AD0826000FF7A4282343018FED0826000FF6EE9 +S325000054E04E56000048E73038262E0008264349F9FFA018E261FF000003C2747FC4802F023E +S325000055004E94584F7215B282670000886D20720AB282670000946D087208B2826738602ACE +S32500005520720DB282677C7212B2826740601C7223B28267306D087217B2826756600C724087 +S32500005540B282674E727FB282670416C260A6487800084E94584F487800204E944878000813 +S325000055604E94504FB68B648C534B60884878000A4E942443584FB7CA6300FF7A121A49C1A0 +S325000055802F0161FF0000035E584FB7CA62EE6000FF644878000A61FF0000034A584F60005B +S325000055A0FF4C4878000A4E9442134CEE1C0CFFEC4E5E4E754E560000226E000820494A11DD +S325000055C0670652484A1066FA200890894E5E4E754E560000222E0010226E0008206E000C1E +S325000055E0B1C9631AD3C1D1C1200153814A8067161121200153814A8066F6600A10D920018B +S3250000560053814A8066F64E5E4E7500004E560000206E0008202E000C538072FFB280670C9E +S32500005620421851C8FFFC4240538064F44E5E4E754E56000020790000402410AE000B52B965 +S32500005640000040244E5E4E754E56000023EE000800004024486E00102F2E000C487AFFD28E +S32500005660612420790000402442104E5E4E754E560000486E000C2F2E00084879FFA018E2BC +S3250000568061044E5E4E754E56000048E7303C2A6E0008286E000C266E0010594B600C4A822F +S325000056A0670001782F024E95584F141C49C27625B68266EA95CA141C49C2224241E9FF9E26 +S325000056C07616B6886500013A303B8A064EFB0002003400A200CA013001300130013001307F +S325000056E001300130002E0130013000EE01300130013000AE0130010401300130011A347C20 +S32500005700000160B2584B241B2453161A49C32F032F022F0D61000120504F584F4A82678AB7 +S3250000572091C8603A53817001E3A0C082672A703C4A886702702C2F004E95584F60082F0101 +S325000057404E95584F524A121249C17620B6816DEE307C00016008524A0C1200206EF8121A46 +S3250000576049C166C04A886700FF424878003E6000FF36584B767FC6932F036000FF2A584B97 +S325000057802453141A49C26700FF222F024E95584F141A49C266F46000FF12584B24136C0ABC +S325000057A04878002D4E954482584F4878000A2F022F0D61000082504F584F6000FEEE584B57 +S325000057C02413487800082F022F0D616A504F584F6000FED8584B24134878000A2F022F0DFF +S325000057E06154504F584F6000FEC2584B2413487800102F022F0D613E504F584F6000FEAC82 +S32500005800487800254E95584F4A8A6700FE984878006C4E95584F6000FE8C4CEE3C0CFFE839 +S325000058204E5E4E753031323334353637383961626364656600004E56FFF448E73038286ECD +S325000058400008222E000C242E001045EEFFF441FAFFD44C42100014F008004A8166F447EE44 +S32500005860FFF4162249C32F034E94584FB7CA65F24CEE1C0CFFE04E5E4E757C2F2D5C000074 +S325000058804E5600002F0A7003C0B90000402041FAFFEA1030080049C02F0052B900004020CA +S325000058A045F9FFA018E24E92487800084E92246EFFFC4E5E4E7500004E5600001F3C000088 +S325000058C04E4F0000101F49C04E5E4E754E56000042814E4F000167000004720142804E5E2D +S325000058E04E754E5600002F02242E0008700AB08266064878000D61EA1F024E4F0020242E50 +S32500005900FFFC4E5E4E750000FFFE07F80000402800004036000040360000404A00004052AB +S30D00005920000040520000405255 +S70300004000BB diff --git a/sys/arch/mvme88k/stand/sboot/rboot.tmp b/sys/arch/mvme88k/stand/sboot/rboot.tmp Binary files differnew file mode 100644 index 00000000000..db9793dc097 --- /dev/null +++ b/sys/arch/mvme88k/stand/sboot/rboot.tmp diff --git a/sys/arch/mvme88k/stand/sboot/sboot b/sys/arch/mvme88k/stand/sboot/sboot new file mode 100644 index 00000000000..5d797b7368b --- /dev/null +++ b/sys/arch/mvme88k/stand/sboot/sboot @@ -0,0 +1,200 @@ +S00A0000000073626F6F74CE +S3250000400013FC000000005ED4600813FC000100005ED42E7C00006FF04EB9000040484E7554 +S325000040200A73626F6F743A204D564D4531343720626F6F7473747261702070726F67726175 +S325000040406D0A003E3E3E20004E56FF802F0A61FFFFFFFFCE1D7C0030FF80487AFFC461FF55 +S325000040600000159E584F45EEFF80487AFFD761FF0000158E2F0A61FF000013F82F0A610055 +S3250000408001CA504F584F60E24E714E5600004E4F00634E5E4E754D7920697020616464727B +S325000040A06573732069733A2025642E25642E25642E25640A005365727665722069702061B0 +S325000040C06464726573732069733A2025642E25642E25642E25640A004661696C65642E0ACA +S325000040E00065786974696E6720746F20524F4D0A00446F776E6C6F6164204661696C65640A +S325000041000A00446F776E6C6F61642077617320612073756363657373210A00636C69656E1C +S325000041207420495020616464726573732025642E25642E25642E25640A00736572766572D7 +S3250000414020495020616464726573732025642E25642E25642E25640A005245564152503AB8 +S32500004160204661696C65642E0A007265636569766564207365636F6E6461727920626F6F0D +S32500004180742070726F6772616D2E0A006273640076616C696420636F6D6D616E64730A0090 +S325000041A061202D2073656E64206120524152500A0062202D20626F6F7420746865207379B1 +S325000041C07374656D0A0071202D206578697420746F20524F4D0A0066202D206674702074B2 +S325000041E0686520626F6F742066696C650A0067202D20657865637574652074686520626F35 +S325000042006F742066696C650A0068202D2068656C700A0069202D20696E6974204C414E439B +S325000042204520656E657420636869700A0073626F6F743A2025733A20556E6B6E6F776E2016 +S32500004240636F6D6D616E640A00004E5600002F0B2F0A246E000810120C000067670001F2CF +S325000042606E2E0C000062670000F86E180C00006167364A00670001EC0C00003F670001925C +S32500004280600001D40C000066670000AE600001C80C000069670001B26D0001760C00007143 +S325000042A067000084600001B061FF0000054C4A8067664280103900005EF72F00428010391A +S325000042C000005EF62F004280103900005EF52F004280103900005EF42F00487AFDBA45F985 +S325000042E0000055FE4E924280103900005ED32F004280103900005ED22F00428010390000A5 +S325000043005ED12F004280103900005ED02F00487AFDA54E926000014C487AFDBE61FF000003 +S3250000432012E06000013E487AFDB961FF000012D26100FD586000012C61FF000007127201FB +S32500004340B280660E487AFDAB61FF000012B460000112487AFDAE61FF000012A660000104C4 +S3250000436061FF00000F8061FF0000048E4A80660E487AFDE761FF00001288600000E6428070 +S32500004380103900005EF72F004280103900005EF62F004280103900005EF52F004280103924 +S325000043A000005EF42F00487AFD7347F9000055FE4E934280103900005ED32F00428010395A +S325000043C000005ED22F004280103900005ED12F004280103900005ED02F00487AFD5E4E93A9 +S325000043E0DEFC002861FF000006667201B2806608487AFCFF4E93606A487AFD7061FF0000DF +S325000044001200584F524A4A12664645FAFD806040487AFD7E45F9000055FE4E92487AFD82EE +S325000044204E92487AFD8D4E92487AFD9C4E92487AFDA74E92487AFDB84E92487AFDCD4E9226 +S32500004440487AFDD14E92601A61FF00000E9860122F0A613C600C2F0A487AFDD361FF000087 +S3250000446011A0246EFFF8266EFFFC4E5E4E756A756D70696E6720746F20626F6F742070722B +S325000044806F6772616D20617420307825782E0A004E56000048E7003C246E00083A7C70009F +S325000044A02F0D487AFFCA61FF0000115642804281264A2F0A61FF0000108ED5C0284A4ED512 +S325000044C04CEE3C00FFF04E5E4E7500000000001F003B005A0078009700B500D400F30111B1 +S325000044E00130014E4E56000048E73F30266E00082C2E000C2A2E0010282E0014262E0018B4 +S32500004500242E001C200BE880244045F20C00200A720F2E0BC287244147F20A002006E8808A +S32500004520244045F20C00200A720FC286244145F20A002C0A2005E880244045F20C00200AA1 +S32500004540720FC285244145F20A002A0A2004E880244045F20C00200A720FC284244145F2F3 +S325000045600A00280A2003E880244045F20C00200A720FC283244145F20A00260A2002E88077 +S32500004580720FC282244045F20C00200A244145F20A44240A7E45BE826D0274462003538045 +S325000045A07E0BBE80650A200453807E1EBE8064044280607293C97046B4806F1C307C016E06 +S325000045C0223C0000016DE8C007826604D3C86002D3C15280B4806EEE41FAFEF030703A0078 +S325000045E0D1C443F098FFE8C0078266087E02BE836C02524943F19A0020092200E981928058 +S325000046002401E9829481EF822005E7809085EB80D085E9802042D1C02006E980908641F0EB +S325000046200C002008D08B4CEE0CFCFFE04E5E4E754E56000048E73E0020790000589810109B +S325000046400000004010801C2800011A280002182800031628000514280006122800071010D2 +S32500004660020000BF108042A71F41000342A71F42000342A71F43000342A71F44000342A7C4 +S325000046801F45000342A71F4600036100FE584CEE007CFFEC4E5E4E754E5600002F0A4280F6 +S325000046A020790000589C11BC00FF080052807205B2806CEC4878000622390000589C5C81CE +S325000046C02F01487900005EEC45F9000055604E9220790000589C317C8035000C2079000032 +S325000046E058A030BC0001317C08000002117C000600042079000058A0117C000400052079C1 +S32500004700000058A0317C00030006487800062239000058A050812F01487900005EEC4E92E0 +S32500004720487800067212D2B9000058A02F01487900005EEC4E924280DEFC00242079000032 +S3250000474058A0423008184230080E52807203B2806CEA4878004C4879000058C061FF00002D +S325000047600910246EFFFC4E5E4E754E5600002F0A48780006487806004879000058C061FF7C +S3250000478000000A6E20790000589C504F584F0C688035000C66562079000058A00C680004CE +S325000047A00006664848780004487900005EF47218D2882F0145F9000055604E9248780004BD +S325000047C0487900005ED0720ED2B9000058A02F014E9248780006487900005EC822390000C9 +S325000047E058A050812F014E92700160024280246EFFFC4E5E4E754E5600002F02428261004F +S32500004800FE986100FF664A8067047001600A52827204B2826CE84280242EFFFC4E5E4E75D6 +S32500004820000178787878787878782E6D766D6536386B006F637465740000303132333435A7 +S325000048403637383941424344454600004E56FFFC48E73038242E000866322879000058AC12 +S3250000486047EC001961FFFFFFFDCA33C000005ED80C7903E700005ED86208067903E800001F +S325000048805ED833FC004500005EC460082679000058B0584B487800062F390000589C4879B1 +S325000048A000005EC845F9000055604E924878000626390000589C5C832F03487900005EECC4 +S325000048C04E9220790000589C317C0800000C2079000058A47604EFD030042079000058A40D +S325000048E07605EFD031042079000058A4422800012079000058A442680004317C400000060D +S32500004900117C000300082079000058A4117C0011000948780004760CD6B9000058A42F03BA +S32500004920487900005EF44E92DEFC00202EBC000000047610D6B9000058A42F034879000092 +S325000049405ED04E922079000058A44268000A384B98F9000058A6314C000242A748780014AC +S325000049602F0861FF00000A5C2079000058A446403140000A2079000058A830B900005ED8E6 +S32500004980317900005EC4000242680006DEFC00184A8267102079000058B030BC000431425A +S325000049A00002605448780004486EFFFC487900005EF445F9000055604E92487800192F399F +S325000049C0000058AC487AFE5A4E927209DEFC001843FAFE682079000058AC700FC0AEFFFC3E +S325000049E011B108001800202EFFFCE8882D40FFFC53817601B68165DC2079000058A8384BCF +S32500004A0098F9000058AA314C000497FC000058C02F0B4879000058C061FF000006544CEECA +S32500004A201C0CFFE84E5E4E750A002578200D00544654503A20446F776E6C6F616420657257 +S32500004A40726F722025643A2025730A004E56000048E73C304282283C0000700042B9000086 +S32500004A605EC042A76100FDE6584F428348780005487806004879000058C061FF000007723C +S32500004A80504F584F4A8066304AB900005EC067082F3900005EC0600242A76100FDB0584F54 +S32500004AA052827A05BA826CC4487AFF7E61FF00000B507001600001002079000058B4362862 +S32500004AC0000220037A09EBA02F00487AFF5E61FF00000B2E20790000589C504F0C6808000E +S32500004AE0000C66782079000058A40C2800110009666A0C79004500005EC4660C207900001C +S32500004B0058A833D000005EC42079000058B40C500005661E2A0858852F0542803028000281 +S32500004B202F00487AFF0B61FF00000AD67001600000862079000058B44280302800022239C1 +S32500004B4000005EC05281B28067186F042F0060062F3900005EC06100FCF4584F52826000F3 +S32500004B60FF0C4282203900005EC0528023C000005EC02079000058A8366800042F0061004B +S32500004B80FCCC45EBFFF42F0A2F042A39000058B458852F0561FF000009CAD88A504F504F65 +S32500004BA0B7FC0000020B6E00FEC4487AFE7C61FF00000A4E42804CEE0C3CFFE84E5E4E7571 +S32500004BC06C65303A206265656E20626162626C696E672C20666F756E642062792027257347 +S32500004BE0270A006C65303A206D656D6F7279206572726F7220696E20272573270A004E5695 +S32500004C0000002F0A2F02242E0008246E000C30120800000E67142F02487AFFA661FF000061 +S32500004C2009E061FFFFFFF466504F30120800000D670434BC200030120800000C670434BCAB +S32500004C40100030120800000B67122F02487AFF9561FF000009AC61FFFFFFF432242EFFF807 +S32500004C60246EFFFC4E5E4E756C65303A20696E69742074696D656F75742C207374617420D4 +S32500004C803D20307825780A004E56000048E73C3C246E0008287900005EDC267900005EE0C5 +S32500004CA0283C000186A0426C000238BC0004487835BE2F0B61FF000008E64253176A000169 +S32500004CC0000217520003176A00030004176A00020005176A00050006176A0004000742AB4B +S32500004CE0000842AB000C7418D48B2002424048400040600037400012374200107458D48BB9 +S32500004D002002424048403740001637420014397C00010002388B397C00020002200B424066 +S32500004D204840388091C8504F4BF08A00200DEB809088E78090884BF30A60240D2208E781D6 +S32500004D403782181817BC0080181A2002424048401780181B37BCFA12181C4273181E524831 +S32500004D607A07BA886CC291C8327C2FD04BF08A00200DEB809088E78090884BF10A00200DCF +S32500004D80240BD4802208E781378218584233185A2002424048401780185B4273185C4273D4 +S32500004DA0185E52484A886FC4397C0003000238BC0004426C000238BC00015384660E2F0304 +S32500004DC0487AFEA661FF00000838600C3014428336000803000867E238BC010042B90000D0 +S32500004DE05EE442B900005EE8426C000238BC00024CEE3C3CFFE04E5E4E756C655F706F6C09 +S32500004E006C006C65305F706F6C6C3A20726D642073746174757320307825780A006C655F09 +S32500004E20706F6C6C3A20636861696E6564207061636B65740A0063737230207768656E2083 +S32500004E40626164207468696E67732068617070656E3A2025780A00004E56000048E72038B0 +S32500004E60267900005EDC287900005EE0426B000230130800000A670436BC040020390000B6 +S32500004E805EE445F40E18102A00026C064280600000F630136C0C2F0B487AFF606100FD60D1 +S32500004EA0504F102A0002080000066718102A000242A71F400003487AFF4A61FF0000074249 +S32500004EC042826078102A0002020000030C0000036712487AFF4961FF0000072661FFFFFF72 +S32500004EE0F1AC584F302A0006428234000C82000005ED6F1A428230133F004267487AFF381F +S32500004F0061FF000006FC61FFFFFFF182602E4A82672A59824A826F242F022F2E0008207904 +S32500004F2000005EE443F08A002009EB809088E780908848740A6061FF0000062820790000F4 +S32500004F405EE443F08A002009EB809088E780908849F40A60200C3480424048401540000338 +S32500004F60357CFA12000441F900005EE442807207B2906708203900005EE452802080157C64 +S32500004F800080000220024CEE1C04FFF04E5E4E756C655F70757428776179206265666F727F +S32500004FA06520786D697429006C65303A206F75747075742062756666657220627573790AE8 +S32500004FC0006C655F707574286265666F726520786D697429006C655F70757428616674654B +S32500004FE07220786D697429006C65303A207472616E736D69742074696D656F75742C20737B +S32500005000746174203D20307825780A006C655F7075742874696D656F757429006C655F70F4 +S3250000502075743A20786D6974206572726F722C206275662025640A006C655F7075742878B6 +S325000050406D6974206572726F7229006C65303A207472616E736D6974206572726F722C202A +S325000050606572726F72203D20307825780A004E56000048E73838282E000C247900005EDCB8 +S32500005080287900005EE0263C000186A0426A000230126C0C2F0A487AFEF86100FB62504FEC +S325000050A0203900005EE847F40E58600C487AFEFA61FF0000054C584F102B00026DEE2F0461 +S325000050C0207900005EE843F08A002009EB809088E7809088D080068000002FD0487408006A +S325000050E02F2E000861FF0000047A504F584F723FB2846508377CFFC0000460083004444037 +S3250000510037400004426B000630126C0C2F0A487AFEB16100FAEA504F177C00830002207962 +S3250000512000005EE843F08A002009EB809088E7809088D080068000002FD0D08C36804240D2 +S3250000514048401740000334BC000830126C0C2F0A487AFE836100FAA8504F538366202F020A +S32500005160487AFE8661FF000004983012504F6C1A2F0A487AFE986100FA86504F600C3012C1 +S32500005180428234000802000967D034BC020030126C2A3012024078000C40200067122F39B4 +S325000051A000005EE8487AFE7661FF00000454504F2F0A487AFE846100FA46504F42B900005E +S325000051C05EE8102B000208000006660420046014302B00063F004267487AFE7161FF00005C +S325000051E0042070FF4CEE1C1CFFE84E5E4E754E56000048E73E20246E00082C2E000C242ECB +S32500005200001061FFFFFFF42C2A00DA824284428361FFFFFFF41E2400BA826F624A83665EB7 +S325000052202F062F0A6100FC322600504FB484670228024A8367DA1212B23900005EEC66CE40 +S32500005240122A0001B23900005EED66C2122A0002B23900005EEE66B6122A0003B2390000F2 +S325000052605EEF66AA122A0004B23900005EF0669E122A0005B23900005EF1679460902003C5 +S325000052804CEE047CFFE84E5E4E754552524F523A2065746865726E65742061646472657322 +S325000052A073206E6F7420736574212020557365204C5341442E0A006C65303A20657468658D +S325000052C0726E657420616464726573733A2025783A25783A25783A25783A25783A25780AD5 +S325000052E000004E5600002F0A2F022439FFFE0778200202802FFFFF000C802FFFFF006612BF +S32500005300487AFF8861FF000002F861FFFFFFED7E584F45F900005EEC14BC00084239000099 +S325000053205EED13FC003E00005EEEE08A43F900005EF11282E08A41F900005EF01082E08A0C +S3250000534013C200005EEF428010112F00428010102F002F024878003E42A748780008487A60 +S32500005360FF5761FF0000029A48780010487900005EDC61FF0000022823FCFFFE180000004C +S325000053805EDC2239FFFE07740681FFF0000023C100005EE0DEFC00202E8A6100F8EC242E19 +S325000053A0FFF8246EFFFC4E5E4E754E560000207900005EDC4268000230BC00044E5E4E7572 +S325000053C0206F0004222F0008202F000C2F02080100006674080100016600008A2401EC89D8 +S325000053E002820000003C4482023C000F4EFB28422418D1822418D1822418D1822418D182E5 +S325000054002418D1822418D1822418D1822418D1822418D1822418D1822418D1822418D1820E +S325000054202418D1822418D1822418D1822418D18251C9FFBE22004841D1416402524002801C +S325000054400000FFFF241F4E750801000167084282343018FDD0824282143018FFE18AD0825E +S325000054606000FF7A4282343018FED0826000FF6E4E56000048E73038262E0008264349F9AE +S325000054800000587261FF000003C2747FC4802F024E94584F7215B282670000886D20720A73 +S325000054A0B282670000946D087208B2826738602A720DB282677C7212B2826740601C722365 +S325000054C0B28267306D087217B2826756600C7240B282674E727FB282670416C260A64878D7 +S325000054E000084E94584F487800204E94487800084E94504FB68B648C534B60884878000A89 +S325000055004E942443584FB7CA6300FF7A121A49C12F0161FF0000035E584FB7CA62EE600039 +S32500005520FF644878000A61FF0000034A584F6000FF4C4878000A4E9442134CEE1C0CFFECEB +S325000055404E5E4E754E560000226E000820494A11670652484A1066FA200890894E5E4E7565 +S325000055604E560000222E0010226E0008206E000CB1C9631AD3C1D1C1200153814A80671696 +S325000055801121200153814A8066F6600A10D9200153814A8066F64E5E4E7500004E56000037 +S325000055A0206E0008202E000C538072FFB280670C421851C8FFFC4240538064F44E5E4E7582 +S325000055C04E5600002079000058BC10AE000B52B9000058BC4E5E4E754E56000023EE000860 +S325000055E0000058BC486E00102F2E000C487AFFD261242079000058BC42104E5E4E754E5638 +S325000056000000486E000C2F2E000848790000587261044E5E4E754E56000048E7303C2A6E27 +S325000056200008286E000C266E0010594B600C4A82670001782F024E95584F141C49C27625C9 +S32500005640B68266EA95CA141C49C2224241E9FF9E7616B6886500013A303B8A064EFB000247 +S32500005660003400A200CA0130013001300130013001300130002E0130013000EE013001304D +S32500005680013000AE0130010401300130011A347C000160B2584B241B2453161A49C32F03E8 +S325000056A02F022F0D61000120504F584F4A82678A91C8603A53817001E3A0C082672A703CB8 +S325000056C04A886702702C2F004E95584F60082F014E95584F524A121249C17620B6816DEE20 +S325000056E0307C00016008524A0C1200206EF8121A49C166C04A886700FF424878003E60001B +S32500005700FF36584B767FC6932F036000FF2A584B2453141A49C26700FF222F024E95584F0C +S32500005720141A49C266F46000FF12584B24136C0A4878002D4E954482584F4878000A2F02D7 +S325000057402F0D61000082504F584F6000FEEE584B2413487800082F022F0D616A504F584F72 +S325000057606000FED8584B24134878000A2F022F0D6154504F584F6000FEC2584B2413487827 +S3250000578000102F022F0D613E504F584F6000FEAC487800254E95584F4A8A6700FE98487897 +S325000057A0006C4E95584F6000FE8C4CEE3C0CFFE84E5E4E753031323334353637383961625B +S325000057C06364656600004E56FFF448E73038286E0008222E000C242E001045EEFFF441FA46 +S325000057E0FFD44C42100014F008004A8166F447EEFFF4162249C32F034E94584FB7CA65F202 +S325000058004CEE1C0CFFE04E5E4E757C2F2D5C00004E5600002F0A7003C0B9000058B841FA8A +S32500005820FFEA1030080049C02F0052B9000058B845F9000058724E92487800084E92246EBC +S32500005840FFFC4E5E4E7500004E5600001F3C00004E4F0000101F49C04E5E4E754E560000F1 +S3250000586042814E4F000167000004720142804E5E4E754E5600002F02242E0008700AB082D7 +S3250000588066064878000D61EA1F024E4F0020242EFFFC4E5E4E750000FFFE07F8000058C0D0 +S31D000058A0000058CE000058CE000058E2000058EA000058EA000058EA9E +S70300004000BB diff --git a/sys/arch/mvme88k/stand/sboot/sboot.c b/sys/arch/mvme88k/stand/sboot/sboot.c new file mode 100644 index 00000000000..5b0f06b1a7e --- /dev/null +++ b/sys/arch/mvme88k/stand/sboot/sboot.c @@ -0,0 +1,173 @@ +/* + * Copyright (c) 1995 Theo de Raadt + * + * 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 under OpenBSD by + * Theo de Raadt for Willowglen Singapore. + * 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. + * + * Copyright (c) 1995 Charles D. Cranor and Seth Widoff + * 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 Charles D. Cranor + * and Seth Widoff. + * 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/cdefs.h> +#include "sboot.h" + +void +main() +{ + char buf[128]; + + buf[0] = '0'; + printf("\nsboot: MVME147 bootstrap program\n"); + while (1) { + printf(">>> "); + gets(buf); + do_cmd(buf); + } + /* not reached */ +} + +/* + * exit to rom + */ +void +callrom() +{ + asm("trap #15; .word 0x0063"); +} + +/* + * do_cmd: do a command + */ +void +do_cmd(buf) + char *buf; +{ + switch (*buf) { + case '\0': + break; + case 'a': + if (rev_arp()) { + printf("My ip address is: %d.%d.%d.%d\n", myip[0], + myip[1], myip[2], myip[3]); + printf("Server ip address is: %d.%d.%d.%d\n", servip[0], + servip[1], servip[2], servip[3]); + } else { + printf("Failed.\n"); + } + break; + case 'q': + printf("exiting to ROM\n"); + callrom(); + break; + case 'f': + if (do_get_file() == 1) { + printf("Download Failed\n"); + } else { + printf("Download was a success!\n"); + } + break; + case 'b': + le_init(); + if (rev_arp()) { + printf("client IP address %d.%d.%d.%d\n", myip[0], + myip[1], myip[2], myip[3]); + printf("server IP address %d.%d.%d.%d\n", servip[0], + servip[1], servip[2], servip[3]); + } else { + printf("REVARP: Failed.\n"); + return; + } + if (do_get_file() == 1) { + printf("Download Failed\n"); + return; + } else { + printf("received secondary boot program.\n"); + } + if (*++buf == '\0') + buf = "bsd"; + go(buf); + break; + case 'h': + case '?': + printf("valid commands\n"); + printf("a - send a RARP\n"); + printf("b - boot the system\n"); + printf("q - exit to ROM\n"); + printf("f - ftp the boot file\n"); + printf("g - execute the boot file\n"); + printf("h - help\n"); + printf("i - init LANCE enet chip\n"); + break; + case 'i': + le_init(); + break; + case 'g': + go(buf); + break; + default: + printf("sboot: %s: Unknown command\n", buf); + } +} + +go(buf) + char *buf; +{ + void (*entry)() = (void (*))LOAD_ADDR; + + printf("jumping to boot program at 0x%x.\n", entry); + + asm("clrl d0; clrl d1"); /* XXX network device */ + asm("movl %0, a3" : : "a" (buf) : "a3"); + asm("movl %0, a4" : : "a" (buf + strlen(buf)) : "a4"); + asm("jmp %0@" : : "a" (entry)); +} diff --git a/sys/arch/mvme88k/stand/sboot/sboot.h b/sys/arch/mvme88k/stand/sboot/sboot.h new file mode 100644 index 00000000000..146e0b8cce4 --- /dev/null +++ b/sys/arch/mvme88k/stand/sboot/sboot.h @@ -0,0 +1,95 @@ +/* + * Copyright (c) 1995 Charles D. Cranor and Seth Widoff + * 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 Charles D. Cranor + * and Seth Widoff. + * 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. + */ + +/* + * sboot.h: stuff for MVME147's serial line boot + */ + +typedef unsigned short u_short; +typedef unsigned long u_long; +typedef unsigned char u_char; +typedef unsigned int u_int; +typedef u_long size_t; +typedef char *caddr_t; +extern caddr_t end; + +#define NULL ((char *)0) + +void bcopy __P((const void *, void *, size_t)); /* libc_sa */ +void *memset __P((void *, int, size_t)); /* libc_sa */ +int printf __P((const char *, ...)); /* libc_sa */ + +/* console */ +void puts __P((char *)); +void putchar __P((char)); +char cngetc __P((void)); +void ngets __P((char *, int)); + +/* sboot */ +void callrom __P((void)); +void do_cmd __P((char *)); + +/* le */ +#define LANCE_ADDR 0xfffe0778 +#define ERAM_ADDR 0xfffe0774 +#define LANCE_REG_ADDR 0xfffe1800 +void le_end __P((void)); +void le_init __P((void)); +int le_get __P((u_char *, size_t, u_long)); +int le_put __P((u_char *, size_t)); + +/* etherfun */ +#define READ 0 +#define ACKN 1 +void do_rev_arp __P((void)); +int get_rev_arp __P((void)); +int rev_arp __P((void)); +void do_send_tftp __P((int)); +int do_get_file __P((void)); +void tftp_file __P((char *, u_long)); + +/* clock */ +u_long time __P((void)); + +/* checksum */ +u_long oc_cksum __P((void *, u_long, u_long)); + +#define CONS_ZS_ADDR (0xfffe3002) +#define CLOCK_ADDR (0xfffe07f8) +#define LOAD_ADDR 0x7000 + +unsigned char myea[6]; /* my ether addr */ +unsigned char myip[4]; +unsigned char servip[4]; +unsigned char servea[6]; +u_short myport; +u_short servport; +unsigned char reboot; diff --git a/sys/arch/mvme88k/stand/sboot/sboot.tmp b/sys/arch/mvme88k/stand/sboot/sboot.tmp Binary files differnew file mode 100644 index 00000000000..a55acd6ea70 --- /dev/null +++ b/sys/arch/mvme88k/stand/sboot/sboot.tmp diff --git a/sys/arch/mvme88k/stand/sboot/srec b/sys/arch/mvme88k/stand/sboot/srec Binary files differnew file mode 100644 index 00000000000..a60b3c76852 --- /dev/null +++ b/sys/arch/mvme88k/stand/sboot/srec diff --git a/sys/arch/mvme88k/stand/sboot/srec.c b/sys/arch/mvme88k/stand/sboot/srec.c new file mode 100644 index 00000000000..164fb4b458c --- /dev/null +++ b/sys/arch/mvme88k/stand/sboot/srec.c @@ -0,0 +1,157 @@ +/* + * Public domain, believed to be by Mike Price. + * + * convert binary file to Srecord format + * XXX srec generates improper checksums for 4-byte dumps + */ +#include <stdio.h> +#include <ctype.h> + +int get32(); +void put32(); +void sput(); +void put(); +int checksum(); + +int mask; +int size; + +main(argc, argv) + int argc; + char *argv[]; +{ + char buf[32]; + int cc; + int base; + int addr; + char *name; + + if (argc != 4) { + fprintf(stderr, "usage: %s {size} {hex_addr} {name}\n", argv[0]); + fprintf(stderr, "Size = 2, 3, or 4 byte address\n"); + exit(1); + } + sscanf(argv[1], "%x", &size); + mask = (1 << (size * 8)) - 1; + if (!mask) + mask = (-1); + sscanf(argv[2], "%x", &base); + name = argv[3]; + + if (size == 2) + printf("S0%02X%04X", 2 + strlen(name) + 1, 0); + if (size == 3) + printf("S0%02X%06X", 3 + strlen(name) + 1, 0); + if (size == 4) + printf("S0%02X%08X", 4 + strlen(name) + 1, 0); + sput(name); + printf("%02X\n", checksum(0, name, strlen(name), size)); + + addr = base; + for (;;) { + cc = get32(buf); + if (cc > 0) { + put32(cc, addr, buf, size, mask); + addr += cc; + } else + break; + } + + buf[0] = base >> 8; + buf[1] = base; + printf("S%d%02X", 11 - size, 2 + 1); + switch (size) { + case 2: + printf("%04X", base & mask); + break; + case 3: + printf("%06X", base & mask); + break; + case 4: + printf("%08X", base & mask); + break; + } + + /* + * kludge -> don't know why you have to add the +1 = works + * for size =3 at least + */ + printf("%02X\n", checksum(base, (char *) 0, 0, size) + 1); + exit (0); +} + +int +get32(buf) + char buf[]; +{ + char *cp = buf; + int i; + int c; + + for (i = 0; i < 32; ++i) { + if ((c = getchar()) != EOF) + *cp++ = c; + else + break; + } + return (cp - buf); +} + +void +put32(len, addr, buf, size, mask) + int len; + int addr; + char buf[]; + int size, mask; +{ + char *cp = buf; + int i; + + if (size == 2) + printf("S1%02X%04X", 2 + len + 1, addr & mask); + if (size == 3) + printf("S2%02X%06X", 3 + len + 1, addr & mask); + if (size == 4) + printf("S3%02X%08X", 4 + len + 1, addr & mask); + for (i = 0; i < len; ++i) + put(*cp++); + printf("%02X\n", checksum(addr, buf, len, size)); +} + +void +sput(s) + char *s; +{ + while (*s != '\0') + put(*s++); +} + +void +put(c) + int c; +{ + printf("%02X", c & 0xff); +} + +int +checksum(addr, buf, len, size) + int addr; + char buf[]; + int len; + int size; +{ + char *cp = buf; + int sum = 0xff - 1 - size - (len & 0xff); + int i; + + if (size == 4) + sum -= (addr >> 24) & 0xff; + if (size >= 3) + sum -= (addr >> 16) & 0xff; + sum -= (addr >> 8) & 0xff; + sum -= addr & 0xff; + for (i = 0; i < len; ++i) { + sum -= *cp++ & 0xff; + } + return (sum & 0xff); +} diff --git a/sys/arch/mvme88k/stand/wrtvid/Makefile b/sys/arch/mvme88k/stand/wrtvid/Makefile new file mode 100644 index 00000000000..8b6cd97df7d --- /dev/null +++ b/sys/arch/mvme88k/stand/wrtvid/Makefile @@ -0,0 +1,6 @@ +PROG= wrtvid +NOMAN= + +install: + +.include <bsd.prog.mk> diff --git a/sys/arch/mvme88k/stand/wrtvid/Makefile,v b/sys/arch/mvme88k/stand/wrtvid/Makefile,v new file mode 100644 index 00000000000..994362b6ddb --- /dev/null +++ b/sys/arch/mvme88k/stand/wrtvid/Makefile,v @@ -0,0 +1,30 @@ +head 1.1; +access; +symbols; +locks + drahn:1.1; strict; +comment @# @; + + +1.1 +date 95.09.28.19.00.28; author drahn; state Exp; +branches; +next ; + + +desc +@@ + + +1.1 +log +@Initial revision +@ +text +@PROG= wrtvid +NOMAN= + +install: + +.include <bsd.prog.mk> +@ diff --git a/sys/arch/mvme88k/stand/wrtvid/Makefile.inc b/sys/arch/mvme88k/stand/wrtvid/Makefile.inc new file mode 100644 index 00000000000..a8c47af8bd7 --- /dev/null +++ b/sys/arch/mvme88k/stand/wrtvid/Makefile.inc @@ -0,0 +1,12 @@ +WRTVID_BASE_DIR=${S}/arch/${MACHINE}/stand/wrtvid + +WRTVID_DIR!= cd ${WRTVID_BASE_DIR}; \ + printf "xxx:\n\techo \$${.OBJDIR}\n" | ${MAKE} -r -s -f - xxx + +WRTVID=${WRTVID_DIR}/wrtvid + +$(WRTVID): .NOTMAIN __always_make_WRTVID + @echo making sure the wrtvid is up to date... + @(cd ${WRTVID_BASE_DIR}; ${MAKE}) + +__always_make_WRTVID: .NOTMAIN diff --git a/sys/arch/mvme88k/stand/wrtvid/wrtvid b/sys/arch/mvme88k/stand/wrtvid/wrtvid Binary files differnew file mode 100644 index 00000000000..d27d4efdd86 --- /dev/null +++ b/sys/arch/mvme88k/stand/wrtvid/wrtvid diff --git a/sys/arch/mvme88k/stand/wrtvid/wrtvid.c b/sys/arch/mvme88k/stand/wrtvid/wrtvid.c new file mode 100644 index 00000000000..8c27dc1b8c8 --- /dev/null +++ b/sys/arch/mvme88k/stand/wrtvid/wrtvid.c @@ -0,0 +1,146 @@ +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <stdio.h> +#define __DBINTERFACE_PRIVATE +#include <db.h> +#include <machine/disklabel.h> + +main(argc, argv) + int argc; + char **argv; +{ + struct cpu_disklabel *pcpul; + struct stat stat; + int exe_file; + int tape_vid; + int tape_exe; + unsigned int exe_addr; + unsigned short exe_addr_u; + unsigned short exe_addr_l; + char *filename; + char fileext[256]; + char filebase[256]; + + if (argc == 0) + filename = "a.out"; + else + filename = argv[1]; + + exe_file = open(filename, O_RDONLY,0444); + if (exe_file == -1) { + perror(filename); + exit(2); + } + sprintf(fileext, "%c%cboot", filename[4], filename[5]); + tape_vid = open(fileext, O_WRONLY|O_CREAT|O_TRUNC, 0644); + sprintf(fileext, "boot%c%c", filename[4], filename[5]); + tape_exe = open(fileext, O_WRONLY|O_CREAT|O_TRUNC,0644); + + pcpul = (struct cpu_disklabel *)malloc(sizeof(struct cpu_disklabel)); + bzero(pcpul, sizeof(struct cpu_disklabel)); + + pcpul->version = 1; + strcpy(pcpul->vid_id, "NBSD"); + + fstat(exe_file, &stat); + /* size in 256 byte blocks round up after a.out header removed */ + + if (filename[5] == 't' ) { + pcpul->vid_oss = 1; + }else { + pcpul->vid_oss = 2; + } + pcpul->vid_osl = (((stat.st_size -0x20) +511) / 512) *2; + + lseek(exe_file, 0x14, SEEK_SET); + read(exe_file, &exe_addr, 4); + + /* check this, it may not work in both endian. */ + { + union { + struct s { + unsigned short s1; + unsigned short s2; + } s; + unsigned long l; + } a; + a.l = exe_addr; + pcpul->vid_osa_u = a.s.s1; + pcpul->vid_osa_l = a.s.s2; + + } + pcpul->vid_cas = 1; + pcpul->vid_cal = 1; + /* do not want to write past end of structure, not null terminated */ + strncpy(pcpul->vid_mot, "MOTOROLA", 8); + + if (BYTE_ORDER != BIG_ENDIAN) + swabvid(pcpul); + + pcpul->cfg_rec = 0x100; + pcpul->cfg_psm = 0x200; + + if (BYTE_ORDER != BIG_ENDIAN) + swabcfg(pcpul); + + write(tape_vid, pcpul, sizeof(struct cpu_disklabel)); + + free(pcpul); + + copy_exe(exe_file, tape_exe); + close(exe_file); + close(tape_vid); + close(tape_exe); + return (0); +} + +#define BUF_SIZ 512 +copy_exe(exe_file, tape_exe) + int exe_file, tape_exe; +{ + char *buf; + int cnt = 0; + + buf = (char *)malloc(BUF_SIZ); + + lseek (exe_file, 0x20, SEEK_SET); + while (BUF_SIZ == (cnt = read(exe_file, buf, BUF_SIZ))) { + write(tape_exe, buf, cnt); + } + bzero(&buf[cnt], BUF_SIZ-cnt); + write(tape_exe, buf, BUF_SIZ); +} + +swabvid(pcpul) + struct cpu_disklabel *pcpul; +{ + M_32_SWAP(pcpul->vid_oss); + M_16_SWAP(pcpul->vid_osl); + /* + M_16_SWAP(pcpul->vid_osa_u); + M_16_SWAP(pcpul->vid_osa_l); + */ + M_32_SWAP(pcpul->vid_cas); +} + +swabcfg(pcpul) + struct cpu_disklabel *pcpul; +{ + M_16_SWAP(pcpul->cfg_atm); + M_16_SWAP(pcpul->cfg_prm); + M_16_SWAP(pcpul->cfg_atm); + M_16_SWAP(pcpul->cfg_rec); + M_16_SWAP(pcpul->cfg_trk); + M_16_SWAP(pcpul->cfg_psm); + M_16_SWAP(pcpul->cfg_shd); + M_16_SWAP(pcpul->cfg_pcom); + M_16_SWAP(pcpul->cfg_rwcc); + M_16_SWAP(pcpul->cfg_ecc); + M_16_SWAP(pcpul->cfg_eatm); + M_16_SWAP(pcpul->cfg_eprm); + M_16_SWAP(pcpul->cfg_eatw); + M_16_SWAP(pcpul->cfg_rsvc1); + M_16_SWAP(pcpul->cfg_rsvc2); +} |