summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorBrandon Creighton <bjc@cvs.openbsd.org>2000-04-27 02:26:28 +0000
committerBrandon Creighton <bjc@cvs.openbsd.org>2000-04-27 02:26:28 +0000
commit56644002c5cb52c79e4f6d8eadc328882f24df33 (patch)
tree5fc1d2bc7c02919e1460f14f1ecba065e6fe164d /sys/arch
parent4dcb4b5a48959a6e08800e7f66b22b1af6c60e49 (diff)
sync with netbsd -- this involved rearranging things for sanity reasons
and because separate builds of libsa are done. this is a pretty nice bootloader.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/vax/boot/Makefile117
-rw-r--r--sys/arch/vax/boot/autoconf.c155
-rw-r--r--sys/arch/vax/boot/boot/Makefile47
-rw-r--r--sys/arch/vax/boot/boot/autoconf.c257
-rw-r--r--sys/arch/vax/boot/boot/boot.c (renamed from sys/arch/vax/boot/boot.c)231
-rw-r--r--sys/arch/vax/boot/boot/conf.c (renamed from sys/arch/vax/stand/conf.c)21
-rw-r--r--sys/arch/vax/boot/boot/consio.c (renamed from sys/arch/vax/stand/consio.c)183
-rw-r--r--sys/arch/vax/boot/boot/ctu.c (renamed from sys/arch/vax/stand/ctu.c)6
-rw-r--r--sys/arch/vax/boot/boot/data.h (renamed from sys/arch/vax/stand/data.h)2
-rw-r--r--sys/arch/vax/boot/boot/devopen.c (renamed from sys/arch/vax/boot/devopen.c)32
-rw-r--r--sys/arch/vax/boot/boot/hp.c (renamed from sys/arch/vax/stand/hp.c)12
-rw-r--r--sys/arch/vax/boot/boot/if_le.c (renamed from sys/arch/vax/stand/if_le.c)156
-rw-r--r--sys/arch/vax/boot/boot/if_qe.c276
-rw-r--r--sys/arch/vax/boot/boot/if_ze.c304
-rw-r--r--sys/arch/vax/boot/boot/mfm.c (renamed from sys/arch/vax/boot/mfm.c)2
-rw-r--r--sys/arch/vax/boot/boot/netio.c (renamed from sys/arch/vax/stand/netio.c)117
-rw-r--r--sys/arch/vax/boot/boot/ra.c (renamed from sys/arch/vax/stand/ra.c)94
-rw-r--r--sys/arch/vax/boot/boot/rom.c (renamed from sys/arch/vax/boot/rom.c)2
-rw-r--r--sys/arch/vax/boot/boot/tmscp.c (renamed from sys/arch/vax/stand/tmscp.c)33
-rw-r--r--sys/arch/vax/boot/common/romread.s (renamed from sys/arch/vax/stand/romread.s)2
-rw-r--r--sys/arch/vax/boot/common/srt0.s (renamed from sys/arch/vax/stand/srt0.s)40
-rw-r--r--sys/arch/vax/boot/common/str.s (renamed from sys/arch/vax/boot/str.s)38
-rw-r--r--sys/arch/vax/boot/common/vaxstand.h (renamed from sys/arch/vax/boot/vaxstand.h)12
-rw-r--r--sys/arch/vax/boot/copy.c246
-rw-r--r--sys/arch/vax/boot/edlabel.c225
-rw-r--r--sys/arch/vax/boot/ka410.h83
-rw-r--r--sys/arch/vax/boot/samachdep.h43
-rw-r--r--sys/arch/vax/boot/scsi_hi.c298
-rw-r--r--sys/arch/vax/boot/scsi_low.c480
-rw-r--r--sys/arch/vax/boot/sd.c248
-rw-r--r--sys/arch/vax/boot/so.h58
-rw-r--r--sys/arch/vax/boot/string.h3
-rw-r--r--sys/arch/vax/boot/xxboot/Makefile36
-rw-r--r--sys/arch/vax/boot/xxboot/bootxx.c (renamed from sys/arch/vax/boot/bootxx.c)221
-rw-r--r--sys/arch/vax/boot/xxboot/start.s (renamed from sys/arch/vax/boot/start.s)15
-rw-r--r--sys/arch/vax/stand/Makefile117
-rw-r--r--sys/arch/vax/stand/autoconf.c155
-rw-r--r--sys/arch/vax/stand/boot/Makefile47
-rw-r--r--sys/arch/vax/stand/boot/autoconf.c257
-rw-r--r--sys/arch/vax/stand/boot/boot.c (renamed from sys/arch/vax/stand/boot.c)231
-rw-r--r--sys/arch/vax/stand/boot/conf.c (renamed from sys/arch/vax/boot/conf.c)21
-rw-r--r--sys/arch/vax/stand/boot/consio.c (renamed from sys/arch/vax/boot/consio.c)183
-rw-r--r--sys/arch/vax/stand/boot/ctu.c (renamed from sys/arch/vax/boot/ctu.c)6
-rw-r--r--sys/arch/vax/stand/boot/data.h (renamed from sys/arch/vax/boot/data.h)2
-rw-r--r--sys/arch/vax/stand/boot/devopen.c (renamed from sys/arch/vax/stand/devopen.c)32
-rw-r--r--sys/arch/vax/stand/boot/hp.c (renamed from sys/arch/vax/boot/hp.c)12
-rw-r--r--sys/arch/vax/stand/boot/if_le.c (renamed from sys/arch/vax/boot/if_le.c)156
-rw-r--r--sys/arch/vax/stand/boot/if_qe.c276
-rw-r--r--sys/arch/vax/stand/boot/if_ze.c304
-rw-r--r--sys/arch/vax/stand/boot/mfm.c (renamed from sys/arch/vax/stand/mfm.c)2
-rw-r--r--sys/arch/vax/stand/boot/netio.c (renamed from sys/arch/vax/boot/netio.c)117
-rw-r--r--sys/arch/vax/stand/boot/ra.c (renamed from sys/arch/vax/boot/ra.c)94
-rw-r--r--sys/arch/vax/stand/boot/rom.c (renamed from sys/arch/vax/stand/rom.c)2
-rw-r--r--sys/arch/vax/stand/boot/tmscp.c (renamed from sys/arch/vax/boot/tmscp.c)33
-rw-r--r--sys/arch/vax/stand/common/romread.s (renamed from sys/arch/vax/boot/romread.s)2
-rw-r--r--sys/arch/vax/stand/common/srt0.s (renamed from sys/arch/vax/boot/srt0.s)40
-rw-r--r--sys/arch/vax/stand/common/str.s (renamed from sys/arch/vax/stand/str.s)38
-rw-r--r--sys/arch/vax/stand/common/vaxstand.h (renamed from sys/arch/vax/stand/vaxstand.h)12
-rw-r--r--sys/arch/vax/stand/copy.c246
-rw-r--r--sys/arch/vax/stand/edlabel.c225
-rw-r--r--sys/arch/vax/stand/ka410.h83
-rw-r--r--sys/arch/vax/stand/samachdep.h43
-rw-r--r--sys/arch/vax/stand/scsi_hi.c298
-rw-r--r--sys/arch/vax/stand/scsi_low.c480
-rw-r--r--sys/arch/vax/stand/sd.c248
-rw-r--r--sys/arch/vax/stand/so.h58
-rw-r--r--sys/arch/vax/stand/string.h3
-rw-r--r--sys/arch/vax/stand/xxboot/Makefile36
-rw-r--r--sys/arch/vax/stand/xxboot/bootxx.c (renamed from sys/arch/vax/stand/bootxx.c)221
-rw-r--r--sys/arch/vax/stand/xxboot/start.s (renamed from sys/arch/vax/stand/start.s)15
70 files changed, 3400 insertions, 4790 deletions
diff --git a/sys/arch/vax/boot/Makefile b/sys/arch/vax/boot/Makefile
index 4ff631c2156..50a4c81d7c4 100644
--- a/sys/arch/vax/boot/Makefile
+++ b/sys/arch/vax/boot/Makefile
@@ -1,115 +1,6 @@
-# $OpenBSD: Makefile,v 1.10 1998/05/14 13:50:35 niklas Exp $
-# $NetBSD: Makefile,v 1.14 1997/06/29 21:30:09 ragge Exp $
+# $OpenBSD: Makefile,v 1.11 2000/04/27 02:26:18 bjc Exp $
+# $NetBSD: Makefile,v 1.21 1999/03/06 16:36:04 ragge Exp $
#
-S!= cd ${.CURDIR}/../../..; pwd
-OBJ!= pwd
-
-AR?= ar
-AS?= as
-CC?= cc
-LD?= ld
-RANLIB?=ranlib
-SIZE?= size
-STRIP?= strip
-
-BINOWN= bin
-BINGRP= bin
-
-INCPATH=-nostdinc -I${OBJ} -I${.CURDIR} -I${.CURDIR}/.. -I${S} -I${S}/lib/libsa
-RELOC= 100000
-XXRPB= 0F4240
-CFLAGS+=-O ${INCPATH} -D_STANDALONE -DRELOC=0x${RELOC} -DXXRPB=0x$(XXRPB)
-
-DEVS= autoconf.o hp.o ra.o tmscp.o ctu.o mfm.o rom.o romread.o \
- scsi_low.o scsi_hi.o sd.o netio.o if_le.o
-
-SAREL=
-.include "$S/lib/libsa/Makefile.inc"
-LIBS= -L. -Llib/sa -lsvax -lsa -lsvax
-
-
-SVAX= consio.o urem.o udiv.o str.o
-
-all: ${LIBSA} xxboot boot copy edlabel
-
-includes:
-
-libsvax.a: ${SVAX}
- ${AR} crv $@ $?
- ${RANLIB} $@
-
-urem.o: ../vax/urem.s
- ${CC} -x assembler-with-cpp -E ${.CURDIR}/../vax/urem.s | \
- ${AS} -o urem.o
-
-udiv.o: ../vax/udiv.s
- ${CC} -x assembler-with-cpp -E ${.CURDIR}/../vax/udiv.s | \
- ${AS} -o udiv.o
-
-str.o: str.s
- ${CC} -x assembler-with-cpp -E ${.CURDIR}/str.s | ${AS} -o str.o
-
-# startups
-
-start.o: start.s
- ${CC} ${CFLAGS} -x assembler-with-cpp -E ${.CURDIR}/start.s | \
- ${AS} -o start.o
-
-srt0.o: srt0.s
- ${CC} -x assembler-with-cpp -E ${.CURDIR}/srt0.s | ${AS} -o srt0.o
-
-#
-
-xxboot: start.o bootxx.o romread.o libsvax.a ${SALIB}
- ${LD} -N -Ttext ${RELOC} -o a.out start.o bootxx.o romread.o ${LIBS}
- @${STRIP} a.out
- @${SIZE} a.out
- @dd if=a.out of=xxboot bs=32 skip=1
- @rm -f a.out
-
-boot: boot.o srt0.o devopen.o conf.o ${DEVS} libsvax.a ${SALIB}
- @date '+_vers: .globl _vers; .asciz ">> OpenBSD/vax boot [%y%m%d %H:%M] <<"' | ${AS} -o vers.o
- ${LD} -N -Ttext ${RELOC} -e start0 -o $@ srt0.o devopen.o boot.o \
- conf.o ${DEVS} ${LIBS} vers.o
- @${STRIP} boot
- @${SIZE} boot
-
-edlabel: edlabel.o srt0.o devopen.o conf.o ${DEVS} libsvax.a
- @date '+_vers: .globl _vers; .asciz ">> OpenBSD/vax boot [%y%m%d %H:%M] <<"' | ${AS} -o vers.o
- ${LD} -N -Ttext ${RELOC} -e start0 -o $@ srt0.o devopen.o edlabel.o\
- conf.o ${DEVS} ${LIBS} vers.o
- @${STRIP} edlabel
- @${SIZE} edlabel
-
-copy: copy.o srt0.o devopen.o conf.o ${DEVS} libsvax.a
- @date '+_vers: .globl _vers; .asciz ">> OpenBSD/vax boot [%y%m%d %H:%M] <<"' | ${AS} -o vers.o
- ${LD} -N -Ttext ${RELOC} -e start0 -o $@ srt0.o devopen.o copy.o \
- conf.o ${DEVS} ${LIBS} vers.o
- @${STRIP} copy
- @${SIZE} copy
-
-#
-
-romread.o: romread.s
- ${CC} -x assembler-with-cpp -E ${.CURDIR}/romread.s | \
- ${AS} -o romread.o
-
-#
-install: boot xxboot
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 boot ${DESTDIR}/
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 xxboot \
- ${DESTDIR}/usr/mdec
- rm -f ${DESTDIR}/usr/mdec/raboot
- ln ${DESTDIR}/usr/mdec/xxboot ${DESTDIR}/usr/mdec/raboot
- rm -f ${DESTDIR}/usr/mdec/hpboot
- ln ${DESTDIR}/usr/mdec/xxboot ${DESTDIR}/usr/mdec/hpboot
-
-clean::
- rm -f start.o romread.o bootxx.o init.o xxboot boot racopy \
- libsvax.a udiv.o urem.o consio.o ${DEVS} edlabel edlabel.o
- rm -f conf.o boot.o rom.o racopy.o srt0.o devopen.o rootcopy.o \
- copy copy.o init.o str.o vers.o
-
-.include <bsd.prog.mk>
-
+SUBDIR= boot xxboot
+.include <bsd.subdir.mk>
diff --git a/sys/arch/vax/boot/autoconf.c b/sys/arch/vax/boot/autoconf.c
deleted file mode 100644
index a1c38fee174..00000000000
--- a/sys/arch/vax/boot/autoconf.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/* $OpenBSD: autoconf.c,v 1.5 1998/02/03 11:48:24 maja Exp $ */
-/* $NetBSD: autoconf.c,v 1.9 1997/04/10 21:25:18 ragge Exp $ */
-/*
- * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
- * 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 at Ludd, University of Lule}.
- * 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.
- */
-
- /* All bugs are subject to removal without further notice */
-
-
-
-#include "sys/param.h"
-#include "../include/mtpr.h"
-#include "../include/sid.h"
-#include "vaxstand.h"
-
-int nmba=0, nuba=0, nbi=0,nsbi=0,nuda=0;
-int *mbaaddr, *ubaaddr, *biaddr;
-int *udaaddr, *uioaddr, tmsaddr, *bioaddr;
-
-static int mba750[]={0xf28000,0xf2a000,0xf2c000};
-static int uba750[]={0xf30000,0xf32000};
-static int uio750[]={0xfc0000,0xf80000};
-static int uda750[]={0772150};
-
-/* 11/780's only have 4, 8600 have 8 of these. */
-static int mba780[]={0x20010000,0x20012000,0x20014000,0x20016000,
- 0x22010000,0x22012000,0x22014000,0x22016000};
-static int uba780[]={0x20006000,0x20008000,0x2000a000,0x2000c000,
- 0x22006000,0x22008000,0x2200a000,0x2200c000};
-static int uio780[]={0x20100000,0x20140000,0x20180000,0x201c0000,
- 0x22100000,0x22140000,0x22180000,0x221c0000};
-
-static int bi8200[]={0x20000000, 0x22000000, 0x24000000, 0x26000000,
- 0x28000000, 0x2a000000};
-static int bio8200[]={0x20400000};
-
-static int uba630[]={0x20087800};
-static int uio630[]={0x30000000};
-#define qbdev(csr) (((csr) & 017777)-0x10000000)
-static int uda630[]={qbdev(0772150),qbdev(0760334)};
-/*
- * Autoconf routine is really stupid; but it actually don't
- * need any intelligence. We just assume that all possible
- * devices exists on each cpu. Fast & easy.
- */
-
-autoconf()
-{
- extern int memsz;
-
- switch (vax_cputype) {
-
- default:
- printf("CPU type %d not supported by boot\n",vax_cputype);
- printf("trying anyway...\n");
- break;
-
- case VAX_8600:
- memsz = 0;
- nmba = 8;
- nuba = 8;
- nuda = 1;
- mbaaddr = mba780;
- ubaaddr = uba780;
- udaaddr = uda750;
- uioaddr = uio780;
- tmsaddr = 0774500;
- break;
-
- case VAX_780:
- memsz = 0;
- nmba = 4;
- nuba = 4;
- nuda = 1;
- mbaaddr = mba780;
- ubaaddr = uba780;
- udaaddr = uda750;
- uioaddr = uio780;
- tmsaddr = 0774500;
- break;
-
- case VAX_750:
- memsz = 0;
- nmba = 3;
- nuba = 2;
- nuda = 1;
- mbaaddr = mba750;
- ubaaddr = uba750;
- udaaddr = uda750;
- uioaddr = uio750;
- tmsaddr = 0774500;
- break;
-
- case VAX_650: /* the same for uvaxIII */
- case VAX_78032:
- nuba = 1;
- nuda = 2;
- ubaaddr = uba630;
- udaaddr = uda630;
- uioaddr = uio630;
- tmsaddr = qbdev(0774500);
- break;
-
- case VAX_8200:
- memsz = 0;
- nbi = 1;
- biaddr = bi8200;
- bioaddr = bio8200;
-
- case VAX_TYP_SOC:
- case VAX_TYP_RIGEL:
- break;
-
- }
-}
-
-/*
- * Return seconds since sometime...
- * Some VAXen doesn't have TODR, return a fake value...
- */
-getsecs()
-{
- static int fakesecs;
- int todr = mfpr(PR_TODR);
-
- if (todr)
- return todr/100;
- return ++fakesecs;
-}
diff --git a/sys/arch/vax/boot/boot/Makefile b/sys/arch/vax/boot/boot/Makefile
new file mode 100644
index 00000000000..f2eb28f90b7
--- /dev/null
+++ b/sys/arch/vax/boot/boot/Makefile
@@ -0,0 +1,47 @@
+# $OpenBSD: Makefile,v 1.1 2000/04/27 02:26:24 bjc Exp $
+# $NetBSD: Makefile,v 1.4 1999/05/23 21:58:19 ragge Exp $
+
+S!= cd ${.CURDIR}/../../../../; pwd
+OBJ!=pwd
+
+NOMAN= 1
+PROG= boot
+DEVS= hp.c ctu.c ra.c tmscp.c mfm.c if_qe.c if_le.c if_ze.c
+SRCS= srt0.s boot.c devopen.c conf.c autoconf.c netio.c rom.c romread.s \
+ urem.s udiv.s consio.c str.s ${DEVS} findcpu.c
+#OBJS= autoconf.o boot.o conf.o consio.o ctu.o devopen.o findcpu.o hp.o \
+# if_le.o if_qe.o if_ze.o mfm.o netio.o ra.o rom.o romread.o srt0.o \
+# str.o tmscp.o udiv.o urem.o
+
+CLEANFILES+=${PROG}.mop
+CPPFLAGS+=-DSUPPORT_BOOTPARAMS -DSUPPORT_DHCP -D_STANDALONE
+#CPPFLAGS+=-DBOOTP_DEBUG -DNETIF_DEBUG -DETHER_DEBUG -DNFS_DEBUG -DDEV_DEBUG \
+# -DRPC_DEBUG -DRARP_DEBUG -DPARANOID -DSUPPORT_BOOTP
+BINDIR= /
+
+SA_ZLIB= yes
+SAREL=
+.include "${S}/lib/libsa/Makefile.inc"
+LIBSA= ${SALIB}
+
+Z_AS= library
+CFLAGS+=-I${S}/lib/libsa
+.include "${S}/lib/libz/Makefile.inc"
+LIBZ= ${ZLIB}
+
+#KERN_AS=library
+#.include "${S}/lib/libkern/Makefile.inc"
+#LIBKERN=${KERNLIB}
+
+boot: ${OBJS} ${SALIB} ${LIBZ} ${LIBKERN}
+ ld -N -Ttext ${RELOC} -e nisse -o ${PROG} -Llib/sa -L. ${OBJS} \
+ ${LIBSA} ${LIBZ} -lsa ${LIBKERN}
+ /usr/sbin/mopa.out ${PROG} ${PROG}.mop
+ strip ${PROG}
+ size ${PROG}
+
+clean::
+ rm -f a.out [Ee]rrs mklog core *.core ${PROG} ${OBJS} ${LOBJS} \
+ ${CLEANFILES}
+
+.include <bsd.prog.mk>
diff --git a/sys/arch/vax/boot/boot/autoconf.c b/sys/arch/vax/boot/boot/autoconf.c
new file mode 100644
index 00000000000..641d9184f72
--- /dev/null
+++ b/sys/arch/vax/boot/boot/autoconf.c
@@ -0,0 +1,257 @@
+/* $OpenBSD: autoconf.c,v 1.1 2000/04/27 02:26:24 bjc Exp $ */
+/* $NetBSD: autoconf.c,v 1.5 1999/08/23 19:09:27 ragge Exp $ */
+/*
+ * Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden.
+ * 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 at Ludd, University of Lule}.
+ * 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.
+ */
+
+ /* All bugs are subject to removal without further notice */
+
+
+
+#include "sys/param.h"
+#include "../../include/mtpr.h"
+#include "../../include/sid.h"
+#include "../../include/trap.h"
+#include "../../include/frame.h"
+#include "vaxstand.h"
+
+extern const struct ivec_dsp idsptch; /* since we are not KERNEL */
+
+int nmba=0, nuba=0, nbi=0,nsbi=0,nuda=0;
+int *mbaaddr, *ubaaddr, *biaddr;
+int *udaaddr, *uioaddr, tmsaddr, *bioaddr;
+
+static int mba750[]={0xf28000,0xf2a000,0xf2c000};
+static int uba750[]={0xf30000,0xf32000};
+static int uio750[]={0xfc0000,0xf80000};
+static int uda750[]={0772150};
+
+/* 11/780's only have 4, 8600 have 8 of these. */
+/* XXX - all of these should be bound to physical addresses */
+static int mba780[]={0x20010000,0x20012000,0x20014000,0x20016000,
+ 0x22010000,0x22012000,0x22014000,0x22016000};
+static int uba780[]={0, 0, 0, 0x20006000,0x20008000,0x2000a000,0x2000c000, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x22006000,0x22008000,0x2200a000,0x2200c000};
+static int uio780[]={0, 0, 0, 0x20100000,0x20140000,0x20180000,0x201c0000, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x22100000,0x22140000,0x22180000,0x221c0000};
+static int bi8200[]={0x20000000, 0x22000000, 0x24000000, 0x26000000,
+ 0x28000000, 0x2a000000};
+static int bio8200[]={0x20400000};
+
+static int uba630[]={0x20087800};
+static int uio630[]={0x30000000};
+#define qbdev(csr) (((csr) & 017777)-0x10000000)
+static int uda630[]={qbdev(0772150),qbdev(0760334)};
+
+static int uba670[]={0x20040000};
+static int uio670[]={0x20000000};
+static int uda670[]={0x20004030,0x20004230};
+#define qb670dev(csr) (((csr) & 017777)+0x20000000)
+
+/*
+ * Autoconf routine is really stupid; but it actually don't
+ * need any intelligence. We just assume that all possible
+ * devices exists on each cpu. Fast & easy.
+ */
+
+autoconf()
+{
+ extern int memsz;
+
+ findcpu(); /* Configures CPU variables */
+ consinit(); /* Allow us to print out things */
+ scbinit(); /* Fix interval clock etc */
+
+ switch (vax_boardtype) {
+
+ default:
+ printf("\nCPU type %d not supported by boot\n",vax_cputype);
+ printf("trying anyway...\n");
+ break;
+
+ case VAX_BTYP_780:
+ case VAX_BTYP_790:
+ memsz = 0;
+ nmba = 8;
+ nuba = 32; /* XXX */
+ nuda = 1;
+ mbaaddr = mba780;
+ ubaaddr = uba780;
+ udaaddr = uda750;
+ uioaddr = uio780;
+ tmsaddr = 0774500;
+ break;
+
+ case VAX_BTYP_750:
+ memsz = 0;
+ nmba = 3;
+ nuba = 2;
+ nuda = 1;
+ mbaaddr = mba750;
+ ubaaddr = uba750;
+ udaaddr = uda750;
+ uioaddr = uio750;
+ tmsaddr = 0774500;
+ break;
+
+ case VAX_BTYP_630: /* the same for uvaxIII */
+ case VAX_BTYP_650:
+ case VAX_BTYP_660:
+ case VAX_BTYP_670:
+ nuba = 1;
+ nuda = 2;
+ ubaaddr = uba630;
+ udaaddr = uda630;
+ uioaddr = uio630;
+ tmsaddr = qbdev(0774500);
+ break;
+
+ case VAX_BTYP_8000:
+ memsz = 0;
+ nbi = 1;
+ biaddr = bi8200;
+ bioaddr = bio8200;
+ break;
+
+ case VAX_BTYP_46:
+ case VAX_BTYP_48:
+ {int *map, i;
+
+ /* Map all 16MB of I/O space to low 16MB of memory */
+ map = (int *)0x700000; /* XXX */
+ *(int *)0x20080008 = (int)map; /* XXX */
+ for (i = 0; i < 0x8000; i++)
+ map[i] = 0x80000000 | i;
+ }break;
+
+ case VAX_BTYP_410:
+ case VAX_BTYP_420:
+ case VAX_BTYP_43:
+ case VAX_BTYP_49:
+ break;
+ }
+}
+
+/*
+ * Clock handling routines, needed to do timing in standalone programs.
+ */
+
+volatile int tickcnt;
+
+getsecs()
+{
+ volatile int loop;
+ int todr;
+
+ return tickcnt/100;
+}
+
+void scb_stray(), rtimer();
+struct ivec_dsp **scb;
+struct ivec_dsp *scb_vec;
+
+/*
+ * Init the SCB and set up a handler for all vectors in the lower space,
+ * to detect unwanted interrupts.
+ */
+scbinit()
+{
+ extern int timer;
+ int i;
+
+ /*
+ * Allocate space. We need one page for the SCB, and 128*16 == 2k
+ * for the vectors. The SCB must be on a page boundary.
+ */
+ i = alloc(VAX_NBPG * 6) + VAX_PGOFSET;
+ i &= ~VAX_PGOFSET;
+
+ mtpr(i, PR_SCBB);
+ scb = (void *)i;
+ scb_vec = (struct ivec_dsp *)(i + VAX_NBPG);
+
+ for (i = 0; i < 128; i++) {
+ scb[i] = &scb_vec[i];
+ (int)scb[i] |= 1; /* Only interrupt stack */
+ memcpy(&scb_vec[i], &idsptch, sizeof(struct ivec_dsp));
+ scb_vec[i].hoppaddr = scb_stray;
+ }
+ scb_vec[0xc0/4].hoppaddr = rtimer;
+
+ mtpr(-10000, PR_NICR); /* Load in count register */
+ mtpr(0x800000d1, PR_ICCS); /* Start clock and enable interrupt */
+
+ mtpr(20, PR_IPL);
+}
+
+void
+rtimer()
+{
+ mtpr(31, PR_IPL);
+ tickcnt++;
+ mtpr(0xc1, PR_ICCS);
+}
+
+asm("
+ .globl _idsptch, _eidsptch
+_idsptch:
+ pushr $0x3f
+ pushl $1
+ .long 0x9f01fb01
+ .long 0x12345678
+#
+# gas do not accept this :-/ use hexcode instead
+# nop
+# calls $1, *$0x12345678
+ popr $0x3f
+ rei
+_eidsptch:
+");
+
+/*
+ * Stray interrupt handler.
+ * This function must _not_ save any registers (in the reg save mask).
+ */
+void
+scb_stray(arg)
+ int arg;
+{
+ static struct callsframe *cf;
+ static int vector, ipl, *a;
+
+ cf = FRAMEOFFSET(arg);
+ a = &cf->ca_arg1;
+ ipl = mfpr(PR_IPL);
+ vector = ((cf->ca_pc - (u_int)scb_vec)/4) & ~3;
+ printf("stray interrupt: pc %x vector 0x%x, ipl %d\n",
+ cf->ca_pc, vector, ipl);
+}
+
diff --git a/sys/arch/vax/boot/boot.c b/sys/arch/vax/boot/boot/boot.c
index b0df2b865b0..e6cde511d76 100644
--- a/sys/arch/vax/boot/boot.c
+++ b/sys/arch/vax/boot/boot/boot.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: boot.c,v 1.5 1998/05/11 07:36:26 niklas Exp $ */
-/* $NetBSD: boot.c,v 1.7 1997/06/08 17:49:16 ragge Exp $ */
+/* $OpenBSD: boot.c,v 1.1 2000/04/27 02:26:24 bjc Exp $ */
+/* $NetBSD: boot.c,v 1.4 1999/10/23 14:42:22 ragge Exp $ */
/*-
* Copyright (c) 1982, 1986 The Regents of the University of California.
* All rights reserved.
@@ -41,7 +41,7 @@
#define V750UCODE(x) ((x>>8)&255)
-#include <sys/exec.h>
+#include "vaxstand.h"
/*
* Boot program... arguments passed in r10 and r11 determine
@@ -50,112 +50,148 @@
*/
char line[100];
-volatile int devtype, bootdev;
+int devtype, bootdev, howto, debug;
extern unsigned opendev;
extern unsigned *bootregs;
+void usage(), boot(), halt();
+
+struct vals {
+ char *namn;
+ void (*func)();
+ char *info;
+} val[] = {
+ {"?", usage, "Show this help menu"},
+ {"help", usage, "Same as '?'"},
+ {"boot", boot, "Load and execute file"},
+ {"halt", halt, "Halts the system"},
+ {0, 0},
+};
+
+char *filer[] = {
+ "bsd",
+ "bsd.gz",
+ "bsd.old",
+ 0,
+};
+
Xmain()
{
- register howto asm("r11");
- register bdev asm("r10");
- int io, retry, type;
- extern char vers[];
+ int io, type, sluttid, askname, filindex = 0;
+ int j, senast = 0, nu;
io=0;
- bootdev=bdev;
autoconf();
- if ((howto & RB_ASKNAME) == 0) {
+ askname = howto & RB_ASKNAME;
+ printf("\n\r>> OpenBSD/vax boot [%s %s] <<\n", __DATE__, __TIME__);
+ printf(">> Press any key to abort autoboot ");
+ sluttid = getsecs() + 5;
+ for (;;) {
+ nu = sluttid - getsecs();
+ if (senast != nu)
+ printf("%c%d", 8, nu);
+ if (nu <= 0)
+ break;
+ senast = nu;
+ if ((j = (testkey() & 0177))) {
+ if (j != 10 && j != 13) {
+ printf("\nPress '?' for help");
+ askname = 1;
+ }
+ break;
+ }
+ }
+ printf("\n");
+
+ /* First try to autoboot */
+ if (askname == 0) {
type = (devtype >> B_TYPESHIFT) & B_TYPEMASK;
if ((unsigned)type < ndevs && devsw[type].dv_name)
- strcpy(line, "/bsd");
- else
- howto |= RB_SINGLE|RB_ASKNAME;
+ while (filer[filindex]) {
+ errno = 0;
+ printf("> boot %s\n", filer[filindex]);
+ exec(filer[filindex++], 0, 0);
+ printf("boot failed: %s\n", strerror(errno));
+ if (testkey())
+ break;
+ }
}
- for (retry = 0;;) {
- if (io >= 0)
- printf("\n%s\n", vers);
- if (howto & RB_ASKNAME) {
- printf(": ");
- gets(line);
- if (line[0] == 0) {
- strcpy(line, "/bsd");
- printf(": %s\n", line);
- }
- } else
- printf(": %s\n", line);
- io = open(line, 0);
- if (io >= 0) {
- loadpcs();
- copyunix(howto, opendev, io);
- close(io);
- howto |= RB_SINGLE|RB_ASKNAME;
- } else {
- printf("%s\n",strerror(errno));
+ /* If any key pressed, go to conversational boot */
+ for (;;) {
+ struct vals *v = &val[0];
+ char *c, *d;
+
+ printf("> ");
+ gets(line);
+
+ c = line;
+ while (*c == ' ')
+ c++;
+
+ if (c[0] == 0)
+ continue;
+
+ if ((d = index(c, ' ')))
+ *d++ = 0;
+
+ while (v->namn) {
+ if (strcmp(v->namn, c) == 0)
+ break;
+ v++;
}
- if (++retry > 2)
- howto |= RB_SINGLE|RB_ASKNAME;
+ if (v->namn)
+ (*v->func)(d);
+ else
+ printf("Unknown command: %s\n", c);
+
}
}
-/*ARGSUSED*/
-copyunix(howto, devtype, aio)
- register howto, devtype; /* howto=r11, devtype=r10 */
- int aio;
+void
+halt()
{
- register int esym; /* must be r9 */
- struct exec x;
- register int io = aio, i;
- char *addr;
+ asm("halt");
+}
- if (read(io, (char *)&x, sizeof(x)) != sizeof(x) || N_BADMAG(x)) {
- printf("Bad format\n");
- return;
+void
+boot(arg)
+ char *arg;
+{
+ char *fn = "bsd";
+
+ if (arg) {
+ while (*arg == ' ')
+ arg++;
+
+ if (*arg != '-') {
+ fn = arg;
+ if ((arg = index(arg, ' '))) {
+ *arg++ = 0;
+ while (*arg == ' ')
+ arg++;
+ } else
+ goto load;
+ }
+ if (*arg != '-') {
+fail: printf("usage: boot [filename] [-asd]\n");
+ return;
+ }
+
+ while (*++arg) {
+ if (*arg == 'a')
+ howto |= RB_ASKNAME;
+ else if (*arg == 'd')
+ howto |= RB_KDB;
+ else if (*arg == 's')
+ howto |= RB_SINGLE;
+ else
+ goto fail;
+ }
}
- printf("%d", x.a_text);
- if (N_GETMAGIC(x) == ZMAGIC && lseek(io, 0x400, SEEK_SET) == -1)
- goto shread;
- if (read(io, (char *)0, x.a_text) != x.a_text)
- goto shread;
- addr = (char *)x.a_text;
- if (N_GETMAGIC(x) == ZMAGIC || N_GETMAGIC(x) == NMAGIC)
- while ((int)addr & CLOFSET)
- *addr++ = 0;
- printf("+%d", x.a_data);
- if (read(io, addr, x.a_data) != x.a_data)
- goto shread;
- addr += x.a_data;
- printf("+%d", x.a_bss);
- for (i = 0; i < x.a_bss; i++)
- *addr++ = 0;
- if (howto & RB_KDB && x.a_syms) {
- *(int *)addr = x.a_syms; /* symbol table size */
- addr += sizeof (int);
- printf("[+%d", x.a_syms);
- if (read(io, addr, x.a_syms) != x.a_syms)
- goto shread;
- addr += x.a_syms;
- if (read(io, addr, sizeof (int)) != sizeof (int))
- goto shread;
- i = *(int *)addr - sizeof (int); /* string table size */
- addr += sizeof (int);
- printf("+%d]", i);
- if (read(io, addr, i) != i)
- goto shread;
- addr += i;
- esym = roundup((int)addr, sizeof (int));
- x.a_bss = 0;
- } else
- howto &= ~RB_KDB;
- for (i = 0; i < 128*512; i++) /* slop */
- *addr++ = 0;
- printf(" start 0x%x\n", (x.a_entry&0x7fffffff));
- hoppabort((x.a_entry&0x7fffffff),howto, devtype, esym);
- return;
-shread:
- printf("\nShort read\n\n");
- return;
+load: exec(fn, 0, 0);
+ printf("Boot failed: %s\n", strerror(errno));
}
/* 750 Patchable Control Store magic */
@@ -180,12 +216,9 @@ shread:
loadpcs()
{
- register int *ip; /* known to be r11 below */
- register int i; /* known to be r10 below */
- register int *jp; /* known to be r9 below */
- register int j;
static int pcsdone = 0;
int mid = mfpr(PR_SID);
+ int i, j, *ip, *jp;
char pcs[100];
char *cp;
@@ -252,3 +285,15 @@ loadpcs()
printf("new rev level=%d\n", V750UCODE(mid));
pcsdone = 1;
}
+
+void
+usage()
+{
+ struct vals *v = &val[0];
+
+ printf("Commands:\n");
+ while (v->namn) {
+ printf("%s\t%s\n", v->namn, v->info);
+ v++;
+ }
+}
diff --git a/sys/arch/vax/stand/conf.c b/sys/arch/vax/boot/boot/conf.c
index 952d3060a70..334fe0cd933 100644
--- a/sys/arch/vax/stand/conf.c
+++ b/sys/arch/vax/boot/boot/conf.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: conf.c,v 1.5 1998/02/03 11:48:25 maja Exp $ */
-/* $NetBSD: conf.c,v 1.8 1997/04/10 21:25:21 ragge Exp $ */
+/* $OpenBSD: conf.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: conf.c,v 1.3 1999/10/23 14:42:21 ragge Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -36,7 +36,7 @@
#include <netinet/in.h>
-#include <machine/rpb.h>
+#include "../../include/rpb.h"
#include "lib/libsa/stand.h"
#include "lib/libsa/ufs.h"
@@ -61,9 +61,10 @@ struct devsw devsw[]={
SADEV("mt",tmscpstrategy, tmscpopen, nullsys, noioctl),
SADEV("rom",romstrategy, romopen, nullsys, noioctl),
SADEV("rd",mfmstrategy, mfmopen, nullsys, noioctl),
- SADEV("sd",sdstrategy, sdopen, nullsys, noioctl),
- SADEV("st",sdstrategy, sdopen, nullsys, noioctl),
+ SADEV("sd",romstrategy, romopen, nullsys, noioctl),
+ SADEV("st",nullsys, nullsys, nullsys, noioctl),
SADEV("le",netstrategy, netopen, netclose, noioctl), /* LANCE */
+ SADEV("ze",netstrategy, netopen, netclose, noioctl), /* SGEC */
};
int cnvtab[] = {
@@ -77,15 +78,13 @@ int cnvtab[] = {
BDEV_SD,
BDEV_ST,
BDEV_LE,
+ BDEV_ZE,
};
int ndevs = (sizeof(devsw)/sizeof(devsw[0]));
struct fs_ops file_system[] = {
- { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat }
-};
-
-struct fs_ops nfs_system[] = {
+ { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat },
{ nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat },
};
@@ -93,10 +92,12 @@ int nfsys = (sizeof(file_system) / sizeof(struct fs_ops));
extern struct netif_driver qe_driver;
extern struct netif_driver le_driver;
+extern struct netif_driver ze_driver;
struct netif_driver *netif_drivers[] = {
-/* &qe_driver, */
+ &qe_driver,
&le_driver,
+ &ze_driver,
};
int n_netif_drivers = (sizeof(netif_drivers) / sizeof(netif_drivers[0]));
diff --git a/sys/arch/vax/stand/consio.c b/sys/arch/vax/boot/boot/consio.c
index c9791416bfa..9cb131fb945 100644
--- a/sys/arch/vax/stand/consio.c
+++ b/sys/arch/vax/boot/boot/consio.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: consio.c,v 1.4 1998/02/03 11:48:26 maja Exp $ */
-/* $NetBSD: consio.c,v 1.8 1997/06/08 17:49:18 ragge Exp $ */
+/* $OpenBSD: consio.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: consio.c,v 1.6 1999/08/23 19:09:27 ragge Exp $ */
/*
- * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
+ * Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,36 +38,54 @@
#include "../vax/gencons.h"
-#include "../include/mtpr.h"
-#include "../include/sid.h"
-#include "../include/rpb.h"
+#include "mtpr.h"
+#include "sid.h"
+#include "rpb.h"
#include "data.h"
void setup __P((void));
-int vax_cputype;
-int vax_boardtype;
-
-int is_750;
-int is_mvax;
-
unsigned *bootregs;
struct rpb *rpb;
struct bqo *bqo;
static int (*put_fp) __P((int)) = NULL;
static int (*get_fp) __P((void)) = NULL;
+static int (*test_fp) __P((void)) = NULL;
int pr_putchar __P((int c)); /* putchar() using mtpr/mfpr */
int pr_getchar __P((void));
+int pr_testchar __P((void));
int rom_putchar __P((int c)); /* putchar() using ROM routines */
int rom_getchar __P((void));
+int rom_testchar __P((void));
static int rom_putc; /* ROM-address of put-routine */
static int rom_getc; /* ROM-address of get-routine */
+/* Location of address of KA630 console page */
+#define NVR_ADRS 0x200B8024
+/* Definitions for various locations in the KA630 console page */
+#define KA630_PUTC_POLL 0x20
+#define KA630_PUTC 0x24
+#define KA630_GETC 0x1C
+#define KA630_ROW 0x4C
+#define KA630_MINROW 0x4D
+#define KA630_MAXROW 0x4E
+#define KA630_COL 0x50
+#define KA630_MINCOL 0x51
+#define KA630_MAXCOL 0x52
+/* Pointer to KA630 console page, initialized by ka630_consinit */
+unsigned char *ka630_conspage;
+/* Function that initializes things for KA630 ROM console I/O */
+void ka630_consinit __P((void));
+/* Functions that use KA630 ROM for console I/O */
+int ka630_rom_putchar __P((int c));
+int ka630_rom_getchar __P((void));
+int ka630_rom_testchar __P((void));
+
putchar(c)
int c;
{
@@ -83,38 +101,28 @@ getchar()
do
c = (*get_fp)() & 0177;
while (c == 17 || c == 19); /* ignore XON/XOFF */
+ if (c < 96 && c > 64)
+ c += 32;
return c;
}
+testkey()
+{
+ return (*test_fp)();
+}
/*
* setup() is called out of the startup files (start.s, srt0.s) and
* initializes data which are globally used and is called before main().
*/
void
-setup()
+consinit()
{
- vax_cputype = (mfpr(PR_SID) >> 24) & 0xFF;
-
put_fp = pr_putchar; /* Default */
get_fp = pr_getchar;
- /*
- * according to vax_cputype we initialize vax_boardtype.
- */
- switch (vax_cputype) {
-
- case VAX_TYP_UV2:
- case VAX_TYP_CVAX:
- case VAX_TYP_RIGEL:
- case VAX_TYP_MARIAH:
- case VAX_TYP_NVAX:
- case VAX_TYP_SOC:
- is_mvax = 1;
- vax_boardtype = (vax_cputype << 24) |
- ((*(int*)0x20040004 >> 24) & 0377);
- rpb = (struct rpb *)bootregs[11]; /* bertram: ??? */
- break;
- }
+ test_fp = pr_testchar;
+
+ rpb = (struct rpb *)bootregs[11]; /* bertram: ??? */
/*
* According to the vax_boardtype (vax_cputype is not specific
@@ -127,27 +135,39 @@ setup()
*/
switch (vax_boardtype) {
- case VAX_BTYP_660:
- case VAX_BTYP_670:
case VAX_BTYP_690:
case VAX_BTYP_1303:
put_fp = rom_putchar;
get_fp = rom_getchar;
+ test_fp = rom_testchar;
rom_putc = 0x20040058; /* 537133144 */
rom_getc = 0x20040008; /* 537133064 */
break;
case VAX_BTYP_43:
- case VAX_BTYP_46:
- case VAX_BTYP_49:
case VAX_BTYP_410:
case VAX_BTYP_420:
- case VAX_BTYP_440:
put_fp = rom_putchar;
get_fp = rom_getchar;
+ test_fp = rom_testchar;
rom_putc = 0x20040058; /* 537133144 */
rom_getc = 0x20040044; /* 537133124 */
break;
+
+ case VAX_BTYP_630:
+ ka630_consinit();
+ break;
+
+ case VAX_BTYP_46:
+ case VAX_BTYP_48:
+ case VAX_BTYP_49:
+ put_fp = rom_putchar;
+ get_fp = rom_getchar;
+ test_fp = rom_testchar;
+ rom_putc = 0x20040068;
+ rom_getc = 0x20040054;
+ break;
+
#ifdef notdef
case VAX_BTYP_630:
case VAX_BTYP_650:
@@ -183,6 +203,13 @@ pr_getchar()
return (mfpr(PR_RXDB)); /* now get it */
}
+pr_testchar()
+{
+ if (mfpr(PR_RXCS) & GC_DON)
+ return mfpr(PR_RXDB);
+ else
+ return 0;
+}
/*
* int rom_putchar (int c) ==> putchar() using ROM-routines
*/
@@ -209,10 +236,88 @@ asm("
beql loop # } while (R0 == 0)
movl r1, r0 # R1 holds char
ret # we're done
+
+ _rom_testchar:
+ .word 0
+ mnegl $1,r0
+ jsb *_rom_getc
+ tstl r0
+ beql 1f
+ movl r1,r0
+ 1: ret
");
_rtt()
{
- printf("rtt\n");
-bo: goto bo;
+ asm("halt");
}
+
+
+
+/*
+ * void ka630_rom_getchar (void) ==> initialize KA630 ROM console I/O
+ */
+void ka630_consinit()
+{
+ register short *NVR;
+ register int i;
+
+ /* Find the console page */
+ NVR = (short *) NVR_ADRS;
+
+ i = *NVR++ & 0xFF;
+ i |= (*NVR++ & 0xFF) << 8;
+ i |= (*NVR++ & 0xFF) << 16;
+ i |= (*NVR++ & 0xFF) << 24;
+
+ ka630_conspage = (char *) i;
+
+ /* Go to last row to minimize confusion */
+ ka630_conspage[KA630_ROW] = ka630_conspage[KA630_MAXROW];
+ ka630_conspage[KA630_COL] = ka630_conspage[KA630_MINCOL];
+
+ /* Use KA630 ROM console I/O routines */
+ put_fp = ka630_rom_putchar;
+ get_fp = ka630_rom_getchar;
+ test_fp = ka630_rom_testchar;
+}
+
+
+/*
+ * int ka630_rom_getchar (void) ==> getchar() using ROM-routines on KA630
+ */
+asm("
+ .globl _ka630_rom_getchar
+ _ka630_rom_getchar:
+ .word 0x802 # save-mask: R1, R11
+ movl _ka630_conspage,r11 # load location of console page
+ loop630g: # do {
+ jsb *0x1C(r11) # call the getc-routine (KA630_GETC)
+ blbc r0, loop630g # } while (R0 == 0)
+ movl r1, r0 # R1 holds char
+ ret # we're done
+
+ _ka630_rom_testchar:
+ .word 0
+ movl _ka630_conspage,r3
+ jsb *0x1C(r3)
+ blbc r0,1f
+ movl r1,r0
+ 1: ret
+");
+
+/*
+ * int ka630_rom_putchar (int c) ==> putchar() using ROM-routines on KA630
+ */
+asm("
+ .globl _ka630_rom_putchar
+ _ka630_rom_putchar:
+ .word 0x802 # save-mask: R1, R11
+ movl _ka630_conspage,r11 # load location of console page
+ loop630p: # do {
+ jsb *0x20(r11) # is rom ready? (KA630_PUTC_POLL)
+ blbc r0, loop630p # } while (R0 == 0)
+ movl 4(ap), r1 # R1 holds char
+ jsb *0x24(r11) # output character (KA630_PUTC)
+ ret # we're done
+");
diff --git a/sys/arch/vax/stand/ctu.c b/sys/arch/vax/boot/boot/ctu.c
index 8e5ec6160a7..3f2c9afb891 100644
--- a/sys/arch/vax/stand/ctu.c
+++ b/sys/arch/vax/boot/boot/ctu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ctu.c,v 1.2 1997/05/29 00:04:20 niklas Exp $ */
+/* $OpenBSD: ctu.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
/* $NetBSD: ctu.c,v 1.1 1996/02/17 18:23:20 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
@@ -59,8 +59,8 @@ volatile struct tu_softc {
int sc_bbytes; /* Number of xfer'd bytes this block */
} tu_sc;
-void ctutintr __P(());
-void cturintr __P(());
+void ctutintr __P((void));
+void cturintr __P((void));
int
ctuopen(f, adapt, ctlr, unit, part)
diff --git a/sys/arch/vax/stand/data.h b/sys/arch/vax/boot/boot/data.h
index e8d92478098..9098d501d70 100644
--- a/sys/arch/vax/stand/data.h
+++ b/sys/arch/vax/boot/boot/data.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: data.h,v 1.2 1997/05/29 00:04:21 niklas Exp $ */
+/* $OpenBSD: data.h,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
/* $NetBSD: data.h,v 1.4 1995/09/16 15:58:57 ragge Exp $ */
/*
* Copyright (c) 1995 Ludd, University of Lule}, Sweden.
diff --git a/sys/arch/vax/boot/devopen.c b/sys/arch/vax/boot/boot/devopen.c
index a34e7895207..c832398b951 100644
--- a/sys/arch/vax/boot/devopen.c
+++ b/sys/arch/vax/boot/boot/devopen.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: devopen.c,v 1.5 1998/02/03 11:48:26 maja Exp $ */
-/* $NetBSD: devopen.c,v 1.8 1997/06/08 17:49:19 ragge Exp $ */
+/* $OpenBSD: devopen.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: devopen.c,v 1.2 1999/06/30 18:30:42 ragge Exp $ */
/*
* Copyright (c) 1997 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -34,7 +34,6 @@
#include <sys/reboot.h>
#include "lib/libsa/stand.h"
-#include "samachdep.h"
#include "vaxstand.h"
unsigned int opendev;
@@ -47,9 +46,8 @@ devopen(f, fname, file)
{
int dev, ctlr, unit, part, adapt, i, a[4], x;
struct devsw *dp;
- extern struct fs_ops nfs_system[];
extern int cnvtab[];
- char *s, *c;
+ char *s, *c, *u;
dev = B_TYPE(bootdev);
ctlr = B_CONTROLLER(bootdev);
@@ -101,29 +99,10 @@ devopen(f, fname, file)
if (x > 3)
adapt = a[0];
*file = c;
- } else
+ } else {
*file = (char *)fname;
-
-#ifdef notyet
- if ((u = index(s, ' '))) {
- *u++ = 0;
-
- if (*u != '-')
- goto usage;
-
- while (*++u) {
- if (*u == 'a')
- bdev |= RB_ASKNAME;
- else if (*u == 'd')
- bdev |= RB_DEBUG;
- else if (*u == 's')
- bdev |= RB_SINGLE;
- else
- goto usage;
- }
-
+ c = (char *)fname;
}
-#endif
if (!dp->dv_open)
return(ENODEV);
@@ -132,7 +111,6 @@ devopen(f, fname, file)
opendev = MAKEBOOTDEV(dev, adapt, ctlr, unit, part);
if (dev > 95) { /* MOP boot over network, root & swap over NFS */
- bcopy(nfs_system, file_system, sizeof(struct fs_ops));
i = (*dp->dv_open)(f, dp->dv_name);
} else
i = (*dp->dv_open)(f, adapt, ctlr, unit, part);
diff --git a/sys/arch/vax/stand/hp.c b/sys/arch/vax/boot/boot/hp.c
index 80d5d8ac56b..30f29ae1101 100644
--- a/sys/arch/vax/stand/hp.c
+++ b/sys/arch/vax/boot/boot/hp.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: hp.c,v 1.4 1998/05/13 07:30:22 niklas Exp $ */
-/* $NetBSD: hp.c,v 1.5 1996/02/17 18:23:22 ragge Exp $ */
+/* $OpenBSD: hp.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: hp.c,v 1.2 1999/04/01 20:40:07 ragge Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -40,7 +40,7 @@
#include "lib/libsa/stand.h"
#include "../include/pte.h"
-#include "../include/macros.h"
+/*#include "../include/macros.h"*/
#include "../mba/mbareg.h"
#include "../mba/hpreg.h"
@@ -130,12 +130,12 @@ hpstrategy(hs, func, dblk, size, buf, rsize)
hd = (void *)&mr->mba_md[hs->unit];
lp = &hplabel;
- pfnum = (u_int)buf >> PGSHIFT;
+ pfnum = (u_int)buf >> VAX_PGSHIFT;
- for(mapnr = 0, nsize = size; (nsize + NBPG) > 0; nsize -= NBPG)
+ for(mapnr = 0, nsize = size; (nsize + VAX_NBPG) > 0; nsize -= VAX_NBPG)
*(int *)&mr->mba_map[mapnr++] = PG_V | pfnum++;
- mr->mba_var = ((u_int)buf & PGOFSET);
+ mr->mba_var = ((u_int)buf & VAX_PGOFSET);
mr->mba_bc = (~size) + 1;
bn = dblk + lp->d_partitions[hs->part].p_offset;
diff --git a/sys/arch/vax/stand/if_le.c b/sys/arch/vax/boot/boot/if_le.c
index 7a223edfa54..31fb9f756b1 100644
--- a/sys/arch/vax/stand/if_le.c
+++ b/sys/arch/vax/boot/boot/if_le.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: if_le.c,v 1.1 1998/02/03 11:48:27 maja Exp $ */
-/* $NetBSD: if_le.c,v 1.2 1997/03/22 12:47:31 ragge Exp $ */
+/* $OpenBSD: if_le.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: if_le.c,v 1.4 1999/08/14 19:41:14 ragge Exp $ */
/*
- * Copyright (c) 1997 Ludd, University of Lule}, Sweden.
+ * Copyright (c) 1997, 1999 Ludd, University of Lule}, Sweden.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,18 +37,21 @@
#include <sys/param.h>
#include <sys/types.h>
+#include <sys/queue.h>
+#include <sys/socket.h>
+
+#include <net/if.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
+#include <netinet/if_ether.h>
+
+#include <../include/sid.h>
#include <lib/libsa/netif.h>
#include <dev/ic/am7990reg.h>
-#define ETHER_MIN_LEN 64
-#define ETHER_MAX_LEN 1518
-#define ETHER_ADDR_LEN 6
-
/*
* The following are incorrect. Why doesn't DEC follow its own specs???
*/
@@ -58,10 +61,12 @@
#define NRBUF (1 << RLEN)
#define BUFSIZE 1518
+#define ETHER_MIN_LEN 64 /* minimum frame length, including CRC */
#define QW_ALLOC(x) ((alloc((x) + 7) + 7) & ~7)
int le_probe(), le_match(), le_get(), le_put();
-void le_init();
+void le_init(), le_end();
+static void copyin(), copyout();
struct netif_stats le_stats;
@@ -73,7 +78,7 @@ struct netif_dif le_ifs[] = {
struct netif_stats le_stats;
struct netif_driver le_driver = {
- "le", le_match, le_probe, le_init, le_get, le_put, 0, le_ifs, 1,
+ "le", le_match, le_probe, le_init, le_get, le_put, le_end, le_ifs, 1,
};
/*
@@ -90,7 +95,7 @@ struct initblock {
} *initblock = NULL;
struct nireg {
- volatile short ni_rdp; /* data port */
+ volatile u_short ni_rdp; /* data port */
volatile short ni_pad0;
volatile short ni_rap; /* register select port */
} *nireg = (struct nireg *)0x200e0000;
@@ -102,6 +107,8 @@ volatile struct buffdesc {
short bd_mcnt;
} *rdesc, *tdesc;
+static int addoff, kopiera = 0;
+
/* Flags in the address field */
#define BR_OWN 0x80000000
#define BR_ERR 0x40000000
@@ -153,51 +160,90 @@ le_init(desc, machdep_hint)
int stat, i, *ea;
volatile int to = 100000;
- *(int *)0x20080014 = 0; /* Be sure we do DMA in low 16MB */
next_rdesc = next_tdesc = 0;
+ if (vax_boardtype == VAX_BTYP_650 &&
+ ((vax_siedata >> 8) & 0xff) == VAX_SIE_KA640) {
+ kopiera = 1;
+ ea = (void *)0x20084200;
+ nireg = (void *)0x20084400;
+ } else {
+ *(int *)0x20080014 = 0; /* Be sure we do DMA in low 16MB */
+ ea = (void *)0x20090000; /* XXX ethernetadressen */
+ }
+
+ if (vax_boardtype == VAX_BTYP_43)
+ addoff = 0x28000000;
+ else
+ addoff = 0;
+igen:
LEWRCSR(LE_CSR0, LE_C0_STOP);
while (to--)
;
- if (initblock == NULL) {
- ea = (void *)0x20090000; /* XXX ethernetadressen */
- for (i = 0; i < 6; i++)
- desc->myea[i] = ea[i] & 0377;
+ for (i = 0; i < 6; i++)
+ desc->myea[i] = ea[i] & 0377;
- initblock = (void *)alloc(sizeof(struct initblock));
+ if (initblock == NULL) {
+ initblock = (void *)QW_ALLOC(sizeof(struct initblock)) + addoff;
initblock->ib_mode = LE_MODE_NORMAL;
bcopy(desc->myea, initblock->ib_padr, 6);
initblock->ib_ladrf1 = 0;
initblock->ib_ladrf2 = 0;
- (int)rdesc = QW_ALLOC(sizeof(struct buffdesc) * NRBUF);
+ (int)rdesc = QW_ALLOC(sizeof(struct buffdesc) * NRBUF) + addoff;
initblock->ib_rdr = (RLEN << 29) | (int)rdesc;
- (int)tdesc = QW_ALLOC(sizeof(struct buffdesc) * NTBUF);
+ if (kopiera)
+ initblock->ib_rdr -= (int)initblock;
+ (int)tdesc = QW_ALLOC(sizeof(struct buffdesc) * NTBUF) + addoff;
initblock->ib_tdr = (TLEN << 29) | (int)tdesc;
+ if (kopiera)
+ initblock->ib_tdr -= (int)initblock;
+ if (kopiera)
+ copyout(initblock, 0, sizeof(struct initblock));
for (i = 0; i < NRBUF; i++) {
- rdesc[i].bd_adrflg = alloc(BUFSIZE) | BR_OWN;
+ rdesc[i].bd_adrflg = QW_ALLOC(BUFSIZE) | BR_OWN;
+ if (kopiera)
+ rdesc[i].bd_adrflg -= (int)initblock;
rdesc[i].bd_bcnt = -BUFSIZE;
rdesc[i].bd_mcnt = 0;
}
+ if (kopiera)
+ copyout(rdesc, (int)rdesc - (int)initblock,
+ sizeof(struct buffdesc) * NRBUF);
for (i = 0; i < NTBUF; i++) {
- tdesc[i].bd_adrflg = alloc(BUFSIZE);
+ tdesc[i].bd_adrflg = QW_ALLOC(BUFSIZE);
+ if (kopiera)
+ tdesc[i].bd_adrflg -= (int)initblock;
tdesc[i].bd_bcnt = 0xf000;
tdesc[i].bd_mcnt = 0;
}
+ if (kopiera)
+ copyout(tdesc, (int)tdesc - (int)initblock,
+ sizeof(struct buffdesc) * NTBUF);
}
- LEWRCSR(LE_CSR1, (int)initblock & 0xffff);
- LEWRCSR(LE_CSR2, ((int)initblock >> 16) & 0xff);
+ if (kopiera) {
+ LEWRCSR(LE_CSR1, 0);
+ LEWRCSR(LE_CSR2, 0);
+ } else {
+ LEWRCSR(LE_CSR1, (int)initblock & 0xffff);
+ LEWRCSR(LE_CSR2, ((int)initblock >> 16) & 0xff);
+ }
LEWRCSR(LE_CSR0, LE_C0_INIT);
to = 100000;
- while (to--)
+ while (to--) {
if (LERDCSR(LE_CSR0) & LE_C0_IDON)
break;
+ if (LERDCSR(LE_CSR0) & LE_C0_ERR) {
+ printf("lance init error: csr0 %x\n", LERDCSR(LE_CSR0));
+ goto igen;
+ }
+ }
LEWRCSR(LE_CSR0, LE_C0_INEA | LE_C0_STRT | LE_C0_IDON);
}
@@ -219,6 +265,9 @@ retry:
csr = LERDCSR(LE_CSR0);
LEWRCSR(LE_CSR0, csr & (LE_C0_BABL|LE_C0_MISS|LE_C0_MERR|LE_C0_RINT));
+ if (kopiera)
+ copyin((int)&rdesc[next_rdesc] - (int)initblock,
+ &rdesc[next_rdesc], sizeof(struct buffdesc));
if (rdesc[next_rdesc].bd_adrflg & BR_OWN)
goto retry;
@@ -228,14 +277,23 @@ retry:
if ((len = rdesc[next_rdesc].bd_mcnt - 4) > maxlen)
len = maxlen;
- bcopy((void *)(rdesc[next_rdesc].bd_adrflg&0xffffff),pkt,len);
+ if (kopiera)
+ copyin((rdesc[next_rdesc].bd_adrflg&0xffffff),
+ pkt, len);
+ else
+ bcopy((void *)(rdesc[next_rdesc].bd_adrflg&0xffffff) +
+ addoff, pkt, len);
}
rdesc[next_rdesc].bd_mcnt = 0;
rdesc[next_rdesc].bd_adrflg |= BR_OWN;
+ if (kopiera)
+ copyout(&rdesc[next_rdesc], (int)&rdesc[next_rdesc] -
+ (int)initblock, sizeof(struct buffdesc));
if (++next_rdesc >= NRBUF)
next_rdesc = 0;
+
if (len == 0)
goto retry;
return len;
@@ -257,14 +315,24 @@ retry:
csr = LERDCSR(LE_CSR0);
LEWRCSR(LE_CSR0, csr & (LE_C0_MISS|LE_C0_CERR|LE_C0_TINT));
+ if (kopiera)
+ copyin((int)&tdesc[next_tdesc] - (int)initblock,
+ &tdesc[next_tdesc], sizeof(struct buffdesc));
if (tdesc[next_tdesc].bd_adrflg & BT_OWN)
goto retry;
- bcopy(pkt, (void *)(tdesc[next_tdesc].bd_adrflg & 0xffffff), len);
+ if (kopiera)
+ copyout(pkt, (tdesc[next_tdesc].bd_adrflg & 0xffffff), len);
+ else
+ bcopy(pkt, (void *)(tdesc[next_tdesc].bd_adrflg & 0xffffff) +
+ addoff, len);
tdesc[next_tdesc].bd_bcnt =
(len < ETHER_MIN_LEN ? -ETHER_MIN_LEN : -len);
tdesc[next_tdesc].bd_mcnt = 0;
tdesc[next_tdesc].bd_adrflg |= BT_OWN | BT_STP | BT_ENP;
+ if (kopiera)
+ copyout(&tdesc[next_tdesc], (int)&tdesc[next_tdesc] -
+ (int)initblock, sizeof(struct buffdesc));
LEWRCSR(LE_CSR0, LE_C0_TDMD);
@@ -281,3 +349,41 @@ retry:
return -1;
}
+
+void
+le_end()
+{
+ LEWRCSR(LE_CSR0, LE_C0_STOP);
+}
+
+void
+copyout(from, dest, len)
+ short *from;
+ int dest, len;
+{
+ short *toaddr;
+
+ toaddr = (short *)0x20120000 + dest;
+
+ while (len > 0) {
+ *toaddr = *from++;
+ toaddr += 2;
+ len -= 2;
+ }
+}
+
+void
+copyin(src, to, len)
+ short *to;
+ int src, len;
+{
+ short *fromaddr;
+
+ fromaddr = (short *)0x20120000 + src;
+
+ while (len > 0) {
+ *to++ = *fromaddr;
+ fromaddr += 2;
+ len -= 2;
+ }
+}
diff --git a/sys/arch/vax/boot/boot/if_qe.c b/sys/arch/vax/boot/boot/if_qe.c
new file mode 100644
index 00000000000..247f82a4728
--- /dev/null
+++ b/sys/arch/vax/boot/boot/if_qe.c
@@ -0,0 +1,276 @@
+/* $OpenBSD: if_qe.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: if_qe.c,v 1.2 1999/06/30 18:19:26 ragge Exp $ */
+
+/*
+ * Copyright (c) 1998 Roar Thronæs. 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 Roar Thronæs.
+ * 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.
+ *
+ * Standalone routine for the DEQNA.
+ */
+
+#include <sys/param.h>
+#include <sys/types.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+
+#include <lib/libsa/netif.h>
+
+#include <arch/vax/if/if_qereg.h>
+
+int qe_probe(), qe_match(), qe_get(), qe_put();
+void qe_init(), qe_end();
+
+struct netif_stats qe_stats;
+
+struct netif_dif qe_ifs[] = {
+/* dif_unit dif_nsel dif_stats dif_private */
+{ 0, 1, &qe_stats, },
+};
+
+struct netif_stats qe_stats;
+
+struct netif_driver qe_driver = {
+ "qe", qe_match, qe_probe, qe_init, qe_get, qe_put, qe_end, qe_ifs, 1,
+};
+
+#define PG_V 0x80000000
+#define QBAMAP 0x20088000
+
+#define NRCV 1 /* Receive descriptors */
+#define NXMT 1 /* Transmit descriptors */
+
+#define QE_INTS (QE_RCV_INT | QE_XMIT_INT)
+#define MAXPACKETSIZE 0x800 /* Because of (buggy) DEQNA */
+
+struct qe_softc {
+ struct qe_ring rring[NRCV+2]; /* Receive ring descriptors */
+ struct qe_ring tring[NXMT+2]; /* Xmit ring descriptors */
+ u_char setup_pkt[16][8]; /* Setup packet */
+ char qein[2048], qeout[2048];/* Packet buffers */
+};
+
+static volatile struct qe_softc *sc;
+static int addr;
+
+#define QE_WCSR(csr, val) \
+ (*((volatile u_short *)(addr + (csr))) = (val))
+#define QE_RCSR(csr) \
+ *((volatile u_short *)(addr + (csr)))
+#define DELAY(x) {volatile int i = x;while (--i);}
+#define LOWORD(x) ((int)(x) & 0xffff)
+#define HIWORD(x) (((int)(x) >> 16) & 0x3f)
+
+int
+qe_match(nif, machdep_hint)
+ struct netif *nif;
+ void *machdep_hint;
+{
+ return strcmp(machdep_hint, "qe") == 0;
+}
+
+int
+qe_probe(nif, machdep_hint)
+ struct netif *nif;
+ void *machdep_hint;
+{
+ return 0;
+}
+
+void
+qe_init(desc, machdep_hint)
+ struct iodesc *desc;
+ void *machdep_hint;
+{
+
+ int i,j;
+ u_int *qm=(u_int *) QBAMAP;
+
+ sc = (void *)alloc(sizeof(struct qe_softc));
+
+ bzero(sc,sizeof(struct qe_softc));
+
+ for(i = 0; i < 8192; i++)
+ qm[i] = PG_V | i;
+
+ /* XXX hardcoded addr */
+ addr = (0x20000000 + (0774440 & 017777));
+
+ QE_WCSR(QE_CSR_CSR, QE_RESET);
+ QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) & ~QE_RESET);
+
+ for (i = 0; i < 6; i++) {
+ sc->setup_pkt[i][1] = QE_RCSR(i * 2);
+ sc->setup_pkt[i+8][1] = QE_RCSR(i * 2);
+ sc->setup_pkt[i][2] = 0xff;
+ sc->setup_pkt[i+8][2] = QE_RCSR(i * 2);
+ for (j=3; j < 8; j++) {
+ sc->setup_pkt[i][j] = QE_RCSR(i * 2);
+ sc->setup_pkt[i+8][j] = QE_RCSR(i * 2);
+ }
+ desc->myea[i] = QE_RCSR(i * 2);
+ }
+
+ bzero((caddr_t)sc->rring, sizeof(struct qe_ring));
+ sc->rring->qe_buf_len = -64;
+ sc->rring->qe_addr_lo = (short)((int)sc->setup_pkt);
+ sc->rring->qe_addr_hi = (short)((int)sc->setup_pkt >> 16);
+
+ bzero((caddr_t)sc->tring, sizeof(struct qe_ring));
+ sc->tring->qe_buf_len = -64;
+ sc->tring->qe_addr_lo = (short)((int)sc->setup_pkt);
+ sc->tring->qe_addr_hi = (short)((int)sc->setup_pkt >> 16);
+
+ sc->rring[0].qe_flag = sc->rring[0].qe_status1 = QE_NOTYET;
+ sc->rring->qe_addr_hi |= QE_VALID;
+
+ sc->tring[0].qe_flag = sc->tring[0].qe_status1 = QE_NOTYET;
+ sc->tring->qe_addr_hi |= QE_VALID | QE_SETUP | QE_EOMSG;
+
+ QE_WCSR(QE_CSR_CSR, QE_XMIT_INT | QE_RCV_INT);
+
+ QE_WCSR(QE_CSR_RCLL, LOWORD(sc->rring));
+ QE_WCSR(QE_CSR_RCLH, HIWORD(sc->rring));
+ QE_WCSR(QE_CSR_XMTL, LOWORD(sc->tring));
+ QE_WCSR(QE_CSR_XMTH, HIWORD(sc->tring));
+
+ while ((QE_RCSR(QE_CSR_CSR) & QE_INTS) != QE_INTS)
+ ;
+ QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) | QE_INTS);
+ QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) & ~(QE_INT_ENABLE|QE_ELOOP));
+ QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) | QE_ILOOP);
+
+ sc->rring[0].qe_addr_lo = (short)((int)sc->qein & 0xffff);
+ sc->rring[0].qe_addr_hi = (short)((int)sc->qein >> 16);
+ sc->rring[0].qe_buf_len=-MAXPACKETSIZE/2;
+ sc->rring[0].qe_addr_hi |= QE_VALID;
+ sc->rring[0].qe_flag=sc->rring[0].qe_status1=QE_NOTYET;
+ sc->rring[0].qe_status2=1;
+
+ sc->rring[1].qe_addr_lo = 0;
+ sc->rring[1].qe_addr_hi = 0;
+ sc->rring[1].qe_flag=sc->rring[1].qe_status1=QE_NOTYET;
+ sc->rring[1].qe_status2=1;
+
+ sc->tring[0].qe_addr_lo = (short)((int)sc->qeout & 0xffff);
+ sc->tring[0].qe_addr_hi = (short)((int)sc->qeout >> 16);
+ sc->tring[0].qe_buf_len=0;
+ sc->tring[0].qe_flag=sc->tring[0].qe_status1=QE_NOTYET;
+ sc->tring[0].qe_addr_hi |= QE_EOMSG|QE_VALID;
+
+ sc->tring[1].qe_flag=sc->tring[1].qe_status1=QE_NOTYET;
+ sc->tring[1].qe_addr_lo = 0;
+ sc->tring[1].qe_addr_hi = 0;
+
+ QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) | QE_RCV_ENABLE);
+ QE_WCSR(QE_CSR_RCLL, LOWORD(sc->rring));
+ QE_WCSR(QE_CSR_RCLH, HIWORD(sc->rring));
+}
+
+int
+qe_get(desc, pkt, maxlen, timeout)
+ struct iodesc *desc;
+ void *pkt;
+ int maxlen;
+ time_t timeout;
+{
+ int len, j;
+
+retry:
+ for(j = 0x10000;j && (QE_RCSR(QE_CSR_CSR) & QE_RCV_INT) == 0; j--)
+ ;
+
+ if ((QE_RCSR(QE_CSR_CSR) & QE_RCV_INT) == 0)
+ goto fail;
+
+ QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) & ~(QE_RCV_ENABLE|QE_XMIT_INT));
+
+ len= ((sc->rring[0].qe_status1 & QE_RBL_HI) |
+ (sc->rring[0].qe_status2 & QE_RBL_LO)) + 60;
+
+ if (sc->rring[0].qe_status1 & 0xc000)
+ goto fail;
+
+ if (len == 0)
+ goto retry;
+
+ bcopy((void*)sc->qein,pkt,len);
+
+
+end:
+ sc->rring[0].qe_status2 = sc->rring[1].qe_status2 = 1;
+ sc->rring[0].qe_flag=sc->rring[0].qe_status1=QE_NOTYET;
+ sc->rring[1].qe_flag=sc->rring[1].qe_status1=QE_NOTYET;
+ QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) | QE_RCV_ENABLE);
+
+ QE_WCSR(QE_CSR_RCLL, LOWORD(sc->rring));
+ QE_WCSR(QE_CSR_RCLH, HIWORD(sc->rring));
+ return len;
+
+fail: len = -1;
+ goto end;
+}
+
+int
+qe_put(desc, pkt, len)
+ struct iodesc *desc;
+ void *pkt;
+ int len;
+{
+ int j;
+
+ bcopy(pkt,sc->qeout,len);
+ sc->tring[0].qe_buf_len=-len/2;
+ sc->tring[0].qe_flag=sc->tring[0].qe_status1=QE_NOTYET;
+ sc->tring[1].qe_flag=sc->tring[1].qe_status1=QE_NOTYET;
+
+ QE_WCSR(QE_CSR_XMTL, LOWORD(sc->tring));
+ QE_WCSR(QE_CSR_XMTH, HIWORD(sc->tring));
+
+ for(j = 0; (j < 0x10000) && ((QE_RCSR(QE_CSR_CSR) & QE_XMIT_INT) == 0); j++)
+ ;
+
+ if ((QE_RCSR(QE_CSR_CSR) & QE_XMIT_INT) == 0) {
+ qe_init(desc,0);
+ return -1;
+ }
+ QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) & ~QE_RCV_INT);
+
+ if (sc->tring[0].qe_status1 & 0xc000) {
+ qe_init(desc,0);
+ return -1;
+ }
+ return len;
+}
+
+void
+qe_end(nif)
+ struct netif *nif;
+{
+ QE_WCSR(QE_CSR_CSR, QE_RESET);
+ QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) & ~QE_RESET);
+}
diff --git a/sys/arch/vax/boot/boot/if_ze.c b/sys/arch/vax/boot/boot/if_ze.c
new file mode 100644
index 00000000000..89a4c43290e
--- /dev/null
+++ b/sys/arch/vax/boot/boot/if_ze.c
@@ -0,0 +1,304 @@
+/* $OpenBSD: if_ze.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: if_ze.c,v 1.5 1999/08/23 19:09:27 ragge Exp $ */
+/*
+ * Copyright (c) 1998 James R. Maynard III. 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 James R. Maynard III.
+ * 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.
+ *
+ * Standalone routine for the SGEC Ethernet controller.
+ */
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/queue.h>
+
+#include <net/if.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/if_ether.h>
+
+#include <lib/libkern/libkern.h>
+#include <lib/libsa/netif.h>
+#include <lib/libsa/stand.h>
+
+#include <arch/vax/if/sgecreg.h>
+
+#include "arch/vax/include/sid.h"
+
+int ze_probe(), ze_match(), ze_get(), ze_put();
+void ze_init(), ze_end();
+
+struct netif_stats ze_stats;
+
+struct netif_dif ze_ifs[] = {
+/* dif_unit dif_nsel dif_stats dif_private */
+{ 0, 1, &ze_stats, },
+};
+
+struct netif_stats ze_stats;
+
+#define ETHER_MIN_LEN 64
+#define ETHER_MAX_LEN 1518
+
+struct netif_driver ze_driver = {
+ "ze", ze_match, ze_probe, ze_init, ze_get, ze_put, ze_end, ze_ifs, 1,
+};
+
+#define NRCV 5 /* allocate 5 receive descriptors */
+#define NXMT 5 /* and 5 transmit - must be >1 */
+#define SETUP_FRAME_LEN 128 /* length of the setup frame */
+
+/* allocate a buffer on an octaword boundary */
+#define OW_ALLOC(x) ((void *)((int)(alloc((x) + 15) + 15) & ~15))
+
+static volatile struct zedevice *addr;
+
+struct ze_tdes *ze_tdes_list; /* transmit desc list */
+struct ze_rdes *ze_rdes_list; /* and receive desc list */
+u_char ze_myaddr[ETHER_ADDR_LEN]; /* my Ethernet address */
+
+int
+ze_match(nif, machdep_hint)
+ struct netif *nif;
+ void *machdep_hint;
+{
+ return strcmp(machdep_hint, "ze") == 0;
+}
+
+int
+ze_probe(nif, machdep_hint)
+ struct netif *nif;
+ void *machdep_hint;
+{
+ return 0;
+}
+
+void
+ze_init(desc, machdep_hint)
+ struct iodesc *desc;
+ void *machdep_hint;
+{
+ u_long nicsr0_work, *nisa_rom;
+ int i;
+ u_char *saved_buf;
+ struct ze_tdes *ze_setup_tdes_list;
+
+ /* point to the device in memory */
+ addr = (struct zedevice *)0x20008000;
+
+ /* reset the device and wait for completion */
+ addr->ze_nicsr6 = ZE_NICSR6_MBO | ZE_NICSR6_RE;
+ while ((addr->ze_nicsr5 & ZE_NICSR5_ID) == 0)
+ ;
+ if (addr->ze_nicsr5 & ZE_NICSR5_SF) {
+ printf("SGEC self-test failed...\n");
+ }
+
+ /* Get our Ethernet address */
+ if (vax_boardtype == VAX_BTYP_49) {
+ nisa_rom = (u_long *)0x27800000;
+ for (i=0; i<ETHER_ADDR_LEN; i++)
+ ze_myaddr[i] = nisa_rom[i] & 0377;
+ } else {
+ nisa_rom = (u_long *)0x20084000;
+ for (i=0; i<ETHER_ADDR_LEN; i++)
+ ze_myaddr[i] = (nisa_rom[i] & 0x0000ff00) >> 8;
+ }
+ bcopy(ze_myaddr,desc->myea,ETHER_ADDR_LEN);
+
+ /* initialize SGEC operating mode */
+ /* disable interrupts here */
+ nicsr0_work = ZE_NICSR0_IPL14 | ZE_NICSR0_SA | ZE_NICSR0_MBO |
+ (ZE_NICSR0_IV_MASK & 0x0108);
+ while (addr->ze_nicsr0 != nicsr0_work)
+ addr->ze_nicsr0 = nicsr0_work;
+ if (addr->ze_nicsr5 & ZE_NICSR5_ME)
+ addr->ze_nicsr5 |= ZE_NICSR5_ME;
+ /* reenable interrupts here */
+
+ /* Allocate space for descriptor lists and buffers,
+ then initialize them. Set up both lists as a ring. */
+ ze_rdes_list = OW_ALLOC((NRCV+1) * sizeof(struct ze_rdes));
+ ze_tdes_list = OW_ALLOC((NXMT+1) * sizeof(struct ze_tdes));
+ for (i=0; i < NRCV; i++) {
+ bzero(ze_rdes_list+i,sizeof(struct ze_rdes));
+ ze_rdes_list[i].ze_framelen = ZE_FRAMELEN_OW;
+ ze_rdes_list[i].ze_bufsize = ETHER_MAX_LEN;
+ ze_rdes_list[i].ze_bufaddr = alloc(ETHER_MAX_LEN);
+ }
+ bzero(ze_rdes_list+NRCV,sizeof(struct ze_rdes));
+ ze_rdes_list[NRCV].ze_framelen = ZE_FRAMELEN_OW;
+ ze_rdes_list[NRCV].ze_rdes1 = ZE_RDES1_CA;
+ ze_rdes_list[NRCV].ze_bufaddr = (u_char *)ze_rdes_list;
+ for (i=0; i < NXMT; i++) {
+ bzero(ze_tdes_list+i,sizeof(struct ze_tdes));
+ ze_tdes_list[i].ze_tdes1 = ZE_TDES1_FS | ZE_TDES1_LS;
+ ze_tdes_list[i].ze_bufsize = ETHER_MAX_LEN;
+ ze_tdes_list[i].ze_bufaddr = alloc(ETHER_MAX_LEN);
+ }
+ bzero(ze_tdes_list+NXMT,sizeof(struct ze_tdes));
+ ze_tdes_list[NXMT].ze_tdes1 = ZE_TDES1_CA;
+ ze_tdes_list[NXMT].ze_tdr = ZE_TDR_OW;
+ ze_tdes_list[NXMT].ze_bufaddr = (u_char *)ze_tdes_list;
+
+ /* Build setup frame. We set the SGEC to do a
+ perfect filter on our own address. */
+ ze_setup_tdes_list = OW_ALLOC(2*sizeof(struct ze_tdes));
+ bzero(ze_setup_tdes_list+0,2*sizeof(struct ze_tdes));
+ ze_setup_tdes_list[0].ze_tdr = ZE_TDR_OW;
+ ze_setup_tdes_list[0].ze_tdes1 = ZE_TDES1_DT_SETUP;
+ ze_setup_tdes_list[0].ze_bufsize = SETUP_FRAME_LEN;
+ ze_setup_tdes_list[0].ze_bufaddr = alloc(SETUP_FRAME_LEN);
+ bzero(ze_setup_tdes_list[0].ze_bufaddr,SETUP_FRAME_LEN);
+ for (i=0; i < 16; i++)
+ bcopy(ze_myaddr,ze_setup_tdes_list[0].ze_bufaddr+(8*i),
+ ETHER_ADDR_LEN);
+ ze_setup_tdes_list[1].ze_tdes1 = ZE_TDES1_CA;
+ ze_setup_tdes_list[1].ze_bufaddr = (u_char *)ze_setup_tdes_list;
+
+ /* Start the transmitter and initialize almost everything else. */
+ addr->ze_nicsr4 = ze_setup_tdes_list;
+ addr->ze_nicsr6 = ZE_NICSR6_MBO | ZE_NICSR6_SE | ZE_NICSR6_ST |
+ ZE_NICSR6_DC | ZE_NICSR6_BL_4;
+ while ((addr->ze_nicsr5 & ZE_NICSR5_TS) != ZE_NICSR5_TS_SUSP)
+ ; /* wait for the frame to be processed */
+
+ /* Setup frame is done processing, initialize the receiver and
+ point the transmitter to the real tdes list. */
+ addr->ze_nicsr4 = ze_tdes_list;
+ addr->ze_nicsr3 = ze_rdes_list;
+ addr->ze_nicsr6 |= ZE_NICSR6_SR;
+
+ /* And away-y-y we go! */
+}
+
+int
+ze_get(desc, pkt, maxlen, timeout)
+ struct iodesc *desc;
+ void *pkt;
+ int maxlen;
+ time_t timeout;
+{
+ int timeout_ctr=100000*timeout, len, rdes;
+
+ while (timeout_ctr-- > 0) {
+
+ /* If there's not a packet waiting for us, just decrement the
+ timeout counter. */
+ if (!(addr->ze_nicsr5 & ZE_NICSR5_RI))
+ continue;
+
+ /* Look through the receive descriptor list for the packet. */
+ for (rdes=0; rdes<NRCV; rdes++) {
+ if (ze_rdes_list[rdes].ze_framelen & ZE_FRAMELEN_OW)
+ continue;
+
+ /* If the packet has an error, ignore it. */
+ if (ze_rdes_list[rdes].ze_rdes0 & ZE_RDES0_ES)
+ len = 0;
+
+ /* Copy the packet, up to the length supplied by the caller, to
+ the caller's buffer. */
+ else {
+ if ((len = (ze_rdes_list[rdes].ze_framelen &
+ (~ ZE_FRAMELEN_OW))) > maxlen)
+ len = maxlen;
+ bcopy((void *)ze_rdes_list[rdes].ze_bufaddr,
+ pkt,len);
+ }
+
+ /* Give ownership of this descriptor back to the SGEC. */
+ ze_rdes_list[rdes].ze_framelen = ZE_FRAMELEN_OW;
+
+ /* If we actually got a good packet, reset the error flags and
+ tell the SGEC to look for more before returning. */
+ if (len > 0) {
+ addr->ze_nicsr5=ZE_NICSR5_RU | ZE_NICSR5_RI |
+ ZE_NICSR5_IS;
+ addr->ze_nicsr2=ZE_NICSR2_RXPD;
+ return len;
+ }
+ }
+ }
+
+ /* If we're going to return an error indication, at least reset the
+ error flags and tell the SGEC to keep receiving first. */
+ addr->ze_nicsr5=ZE_NICSR5_RU | ZE_NICSR5_RI | ZE_NICSR5_IS;
+ addr->ze_nicsr2=ZE_NICSR2_RXPD;
+ return 0;
+}
+
+int
+ze_put(desc, pkt, len)
+ struct iodesc *desc;
+ void *pkt;
+ int len;
+{
+ int timeout=100000;
+
+ /* The SGEC maintains its position in the transmit descriptor list
+ for the next frame to transmit. Unfortunately, there's no way to tell
+ from software just where that is. We're forced to reset the position
+ whenever we send a frame, which requires waiting for the previous
+ frame to be sent. Argh. */
+ while ((addr->ze_nicsr5 & ZE_NICSR5_TS) == ZE_NICSR5_TS_RUN)
+ ;
+
+ /* Copy the packet to the buffer we allocated. */
+ bcopy(pkt, (void *)ze_tdes_list[0].ze_bufaddr, len);
+
+ /* Set the packet length in the descriptor, increasing it to the
+ minimum size if needed. */
+ ze_tdes_list[0].ze_bufsize = len;
+ if (len < ETHER_MIN_LEN)
+ ze_tdes_list[0].ze_bufsize = ETHER_MIN_LEN;
+
+ /* Give ownership of the descriptor to the SGEC and tell it to start
+ transmitting. */
+ ze_tdes_list[0].ze_tdr = ZE_TDR_OW;
+ addr->ze_nicsr4 = ze_tdes_list;
+ addr->ze_nicsr1 = ZE_NICSR1_TXPD;
+
+ /* Wait for the frame to be sent, but not too long. */
+ timeout = 100000;
+ while ((addr->ze_nicsr5 & ZE_NICSR5_TI == 0) && (--timeout>0))
+ ;
+
+ /* Reset the transmitter interrupt pending flag. */
+ addr->ze_nicsr5 |= ZE_NICSR5_TI;
+
+ /* Return good if we didn't timeout, or error if we did. */
+ if (timeout>0) return len;
+ return -1;
+}
+
+void
+ze_end()
+{
+ addr->ze_nicsr6 = ZE_NICSR6_RE;
+}
diff --git a/sys/arch/vax/boot/mfm.c b/sys/arch/vax/boot/boot/mfm.c
index 20465089651..33fbbbc3065 100644
--- a/sys/arch/vax/boot/mfm.c
+++ b/sys/arch/vax/boot/boot/mfm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfm.c,v 1.4 1998/05/13 07:30:23 niklas Exp $ */
+/* $OpenBSD: mfm.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
/* $NetBSD: mfm.c,v 1.2 1997/03/15 13:04:28 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
diff --git a/sys/arch/vax/stand/netio.c b/sys/arch/vax/boot/boot/netio.c
index 99c58e02615..bbc01d23acc 100644
--- a/sys/arch/vax/stand/netio.c
+++ b/sys/arch/vax/boot/boot/netio.c
@@ -1,8 +1,43 @@
-/* $OpenBSD: netio.c,v 1.1 1998/02/03 11:48:28 maja Exp $ */
-/* $NetBSD: netio.c,v 1.1 1997/03/15 13:04:29 ragge Exp $ */
+/* $OpenBSD: netio.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: netio.c,v 1.4 1999/06/30 18:38:03 ragge Exp $ */
+
+/*-
+ * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
/*
- * Copyright (c) 1995, 1996 Jason R. Thorpe
* Copyright (c) 1995 Gordon W. Ross
* All rights reserved.
*
@@ -57,12 +92,11 @@
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
-#include "stand.h"
-#include "samachdep.h"
-#include "net.h"
-#include "netif.h"
-#include "bootparam.h"
-#include "nfs.h"
+#include "lib/libsa/stand.h"
+#include "lib/libsa/net.h"
+#include "lib/libsa/netif.h"
+#include "lib/libsa/bootparam.h"
+#include "lib/libsa/nfs.h"
extern int nfs_root_node[]; /* XXX - get from nfs_mount() */
@@ -77,9 +111,6 @@ int netio_ask = 0; /* default to bootparam, can override */
static char input_line[100];
-/* Why be any different? */
-#define SUN_BOOTPARAMS
-
/*
* Called by devopen after it sets f->f_dev to our devsw entry.
* This opens the low-level device and sets f->f_devdata.
@@ -108,10 +139,7 @@ int
netclose(f)
struct open_file *f;
{
- /* On last close, do netif close, etc. */
- if (open_count > 0)
- if (--open_count == 0)
- netif_close(netdev_sock);
+ netif_close(netdev_sock);
f->f_devdata = NULL;
}
@@ -200,41 +228,46 @@ netmountroot(f, devname)
* 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 (errno);
-
- printf("boot: client IP address: %s\n", inet_ntoa(myip));
+#ifdef SUPPORT_BOOTP
- /* Get our hostname, server IP address. */
- if (bp_whoami(netdev_sock))
- return (errno);
+ /* Get boot info using BOOTP way. (RFC951, RFC1048) */
+ printf("Trying BOOTP\n");
+ bootp(netdev_sock);
- printf("boot: client name: %s\n", hostname);
+ if (myip.s_addr) {
+ printf("Using IP address: %s\n", inet_ntoa(myip));
- /* Get the root pathname. */
- if (bp_getfile(netdev_sock, "root", &rootip, rootpath))
- return (errno);
+ printf("myip: %s (%s)", hostname, inet_ntoa(myip));
+ if (gateip.s_addr)
+ printf(", gateip: %s", inet_ntoa(gateip));
+ if (netmask)
+ printf(", mask: %s", intoa(netmask));
+ printf("\n");
+ } else
-#else
+#endif /* SUPPORT_BOOTP */
+ {
+#ifdef SUPPORT_BOOTPARAMS
+ /* Get boot info using RARP and Sun bootparams. */
- /* Get boot info using BOOTP way. (RFC951, RFC1048) */
- bootp(netdev_sock);
+ printf("Trying BOOTPARAMS\n");
+ /* Get our IP address. (rarp.c) */
+ if (rarp_getipaddress(netdev_sock) == -1)
+ return (errno);
- printf("Using IP address: %s\n", inet_ntoa(myip));
+ printf("boot: client IP address: %s\n", inet_ntoa(myip));
- printf("myip: %s (%s)", hostname, inet_ntoa(myip));
- if (gateip)
- printf(", gateip: %s", inet_ntoa(gateip));
- if (mask)
- printf(", mask: %s", intoa(netmask));
- printf("\n");
+ /* Get our hostname, server IP address. */
+ if (bp_whoami(netdev_sock))
+ return (errno);
-#endif /* SUN_BOOTPARAMS */
+ printf("boot: client name: %s\n", hostname);
+ /* Get the root pathname. */
+ if (bp_getfile(netdev_sock, "root", &rootip, rootpath))
+ return (errno);
+#endif
+ }
printf("root addr=%s path=%s\n", inet_ntoa(rootip), rootpath);
do_nfs_mount:
diff --git a/sys/arch/vax/stand/ra.c b/sys/arch/vax/boot/boot/ra.c
index c349d2ec463..96be3fcfc00 100644
--- a/sys/arch/vax/stand/ra.c
+++ b/sys/arch/vax/boot/boot/ra.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: ra.c,v 1.5 1998/05/13 07:30:24 niklas Exp $ */
-/* $NetBSD: ra.c,v 1.5 1996/08/02 11:22:18 ragge Exp $ */
+/* $OpenBSD: ra.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: ra.c,v 1.4 1999/08/07 11:19:04 ragge Exp $ */
/*
* Copyright (c) 1995 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -41,22 +41,20 @@
#include "lib/libsa/stand.h"
#include "../include/pte.h"
-#include "../include/macros.h"
#include "../include/sid.h"
-#include "../uba/ubareg.h"
-#include "../uba/udareg.h"
+#include "arch/vax/mscp/mscp.h"
+#include "arch/vax/mscp/mscpreg.h"
-#include "../mscp/mscp.h"
-#include "../mscp/mscpreg.h"
-
-#include "../bi/bireg.h"
-#include "../bi/kdbreg.h"
+#include "arch/vax/bi/bireg.h"
+#include "arch/vax/bi/kdbreg.h"
#include "vaxstand.h"
static command(int);
+
+
/*
* These routines for RA disk standalone boot is wery simple,
* assuming a lots of thing like that we only working at one ra disk
@@ -82,7 +80,6 @@ volatile struct uda {
} uda;
volatile struct uda *ubauda;
-volatile struct udadevice *udacsr;
struct disklabel ralabel;
struct ra_softc ra_softc;
char io_buf[DEV_BSIZE];
@@ -94,11 +91,14 @@ raopen(f, adapt, ctlr, unit, part)
char *msg;
struct disklabel *lp = &ralabel;
volatile struct ra_softc *ra = &ra_softc;
- volatile struct uba_regs *mr = (void *)ubaaddr[adapt];
volatile u_int *nisse;
unsigned short johan, johan2;
- int i,err;
+ int i,err, udacsr;
+#ifdef DEV_DEBUG
+ printf("raopen: adapter %d ctlr %d unit %d part %d\n",
+ adapt, ctlr, unit, part);
+#endif
bzero(lp, sizeof(struct disklabel));
ra->unit = unit;
ra->part = part;
@@ -107,50 +107,63 @@ raopen(f, adapt, ctlr, unit, part)
return(EADAPT);
if (ctlr > nuda)
return(ECTLR);
- nisse = (u_int *)&mr->uba_map[0];
+ nisse = ((u_int *)ubaaddr[adapt]) + 512;
nisse[494] = PG_V | (((u_int)&uda) >> 9);
nisse[495] = nisse[494] + 1;
- udacsr = (void*)uioaddr[adapt] + udaaddr[ctlr];
+ udacsr = (int)uioaddr[adapt] + udaaddr[ctlr];
ubauda = (void*)0x3dc00 + (((u_int)(&uda))&0x1ff);
johan = (((u_int)ubauda) & 0xffff) + 8;
johan2 = 3;
- ra->ra_ip = (short *)&udacsr->udaip;
- ra->ra_sa = ra->ra_sw = (short *)&udacsr->udasa;
+ ra->ra_ip = (short *)udacsr;
+ ra->ra_sa = ra->ra_sw = (short *)udacsr + 1;
ra->udaddr = uioaddr[adapt] + udaaddr[ctlr];
- ra->ubaddr = (int)mr;
+ ra->ubaddr = (int)ubaaddr[adapt];
*ra->ra_ip = 0; /* Start init */
} else {
- struct bi_node *bi = (void *)biaddr[adapt];
- struct kdb_regs *kb = (void *)&bi[ctlr];
+ paddr_t kdaddr = (paddr_t)biaddr[adapt] + BI_NODE(ctlr);
+ volatile int *w;
volatile int i = 10000;
- ra->ra_ip = &kb->kdb_ip;
- ra->ra_sa = &kb->kdb_sa;
- ra->ra_sw = &kb->kdb_sw;
+ ra->ra_ip = (short *)(kdaddr + KDB_IP);
+ ra->ra_sa = (short *)(kdaddr + KDB_SA);
+ ra->ra_sw = (short *)(kdaddr + KDB_SW);
johan = ((u_int)&uda.uda_ca.ca_rspdsc) & 0xffff;
johan2 = (((u_int)&uda.uda_ca.ca_rspdsc) & 0xffff0000) >> 16;
- kb->kdb_bi.bi_csr |= BICSR_NRST;
+ w = (int *)(kdaddr + BIREG_VAXBICSR);
+ *w = *w | BICSR_NRST;
while (i--) /* Need delay??? */
;
- kb->kdb_bi.bi_ber = ~(BIBER_MBZ|BIBER_NMR|BIBER_UPEN);/* ??? */
+ w = (int *)(kdaddr + BIREG_BER);
+ *w = ~(BIBER_MBZ|BIBER_NMR|BIBER_UPEN);/* ??? */
ubauda = &uda;
}
/* Init of this uda */
while ((*ra->ra_sa & MP_STEP1) == 0)
;
-
+#ifdef DEV_DEBUG
+ printf("MP_STEP1...");
+#endif
*ra->ra_sw = 0x8000;
while ((*ra->ra_sa & MP_STEP2) == 0)
;
+#ifdef DEV_DEBUG
+ printf("MP_STEP2...");
+#endif
*ra->ra_sw = johan;
while ((*ra->ra_sa & MP_STEP3) == 0)
;
+#ifdef DEV_DEBUG
+ printf("MP_STEP3...");
+#endif
*ra->ra_sw = johan2;
while ((*ra->ra_sa & MP_STEP4) == 0)
;
+#ifdef DEV_DEBUG
+ printf("MP_STEP4\n");
+#endif
*ra->ra_sw = 0x0001;
uda.uda_ca.ca_rspdsc = (int)&ubauda->uda_rsp.mscp_cmdref;
@@ -160,12 +173,18 @@ raopen(f, adapt, ctlr, unit, part)
uda.uda_cmd.mscp_unit = ra->unit;
command(M_OP_ONLINE);
+#ifdef DEV_DEBUG
+ printf("reading disklabel\n");
+#endif
err = rastrategy(ra,F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i);
if(err){
printf("reading disklabel: %s\n",strerror(err));
return 0;
}
+#ifdef DEV_DEBUG
+ printf("getting disklabel\n");
+#endif
msg = getdisklabel(io_buf+LABELOFFSET, lp);
if (msg)
printf("getdisklabel: %s\n", msg);
@@ -183,10 +202,15 @@ command(cmd)
uda.uda_rsp.mscp_msglen = MSCP_MSGLEN;
uda.uda_ca.ca_rspdsc |= MSCP_OWN|MSCP_INT;
uda.uda_ca.ca_cmddsc |= MSCP_OWN|MSCP_INT;
+#ifdef DEV_DEBUG
+ printf("sending cmd %x...", cmd);
+#endif
hej = *ra_softc.ra_ip;
while(uda.uda_ca.ca_rspdsc<0)
;
-
+#ifdef DEV_DEBUG
+ printf("sent.\n");
+#endif
}
rastrategy(ra, func, dblk, size, buf, rsize)
@@ -196,22 +220,18 @@ rastrategy(ra, func, dblk, size, buf, rsize)
char *buf;
u_int size, *rsize;
{
- volatile struct uba_regs *ur;
- volatile struct udadevice *udadev;
volatile u_int *ptmapp;
struct disklabel *lp;
u_int i, j, pfnum, mapnr, nsize;
volatile int hej;
-
if (vax_cputype != VAX_8200) {
- ur = (void *)ra->ubaddr;
- udadev = (void*)ra->udaddr;
- ptmapp = (u_int *)&ur->uba_map[0];
+ ptmapp = ((u_int *)ra->ubaddr) + 512;
- pfnum = (u_int)buf >> PGSHIFT;
+ pfnum = (u_int)buf >> VAX_PGSHIFT;
- for(mapnr = 0, nsize = size; (nsize + NBPG) > 0; nsize -= NBPG)
+ for(mapnr = 0, nsize = size; (nsize + VAX_NBPG) > 0;
+ nsize -= VAX_NBPG)
ptmapp[mapnr++] = PG_V | pfnum++;
uda.uda_cmd.mscp_seq.seq_buffer = ((u_int)buf) & 0x1ff;
} else
@@ -222,6 +242,10 @@ rastrategy(ra, func, dblk, size, buf, rsize)
dblk + lp->d_partitions[ra->part].p_offset;
uda.uda_cmd.mscp_seq.seq_bytecount = size;
uda.uda_cmd.mscp_unit = ra->unit;
+#ifdef DEV_DEBUG
+ printf("rastrategy: blk 0x%lx count %lx unit %lx\n",
+ uda.uda_cmd.mscp_seq.seq_lbn, size, ra->unit);
+#endif
if (func == F_WRITE)
command(M_OP_WRITE);
else
diff --git a/sys/arch/vax/boot/rom.c b/sys/arch/vax/boot/boot/rom.c
index 1e14e6049a4..8e36badc906 100644
--- a/sys/arch/vax/boot/rom.c
+++ b/sys/arch/vax/boot/boot/rom.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rom.c,v 1.3 1998/05/13 07:30:26 niklas Exp $ */
+/* $OpenBSD: rom.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
/* $NetBSD: rom.c,v 1.1 1996/08/02 11:22:21 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
diff --git a/sys/arch/vax/stand/tmscp.c b/sys/arch/vax/boot/boot/tmscp.c
index 90ca7e9fa48..5dbd5aef582 100644
--- a/sys/arch/vax/stand/tmscp.c
+++ b/sys/arch/vax/boot/boot/tmscp.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: tmscp.c,v 1.5 1998/02/03 11:48:30 maja Exp $ */
-/* $NetBSD: tmscp.c,v 1.4 1997/03/15 13:04:31 ragge Exp $ */
+/* $OpenBSD: tmscp.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: tmscp.c,v 1.3 1999/06/30 18:19:26 ragge Exp $ */
/*
* Copyright (c) 1995 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -41,11 +41,8 @@
#include "lib/libsa/stand.h"
#include "../include/pte.h"
-#include "../include/macros.h"
-#include "../uba/ubareg.h"
-#include "../uba/udareg.h"
-#include "../mscp/mscp.h"
-#include "../mscp/mscpreg.h"
+#include "arch/vax/mscp/mscp.h"
+#include "arch/vax/mscp/mscpreg.h"
#include "vaxstand.h"
@@ -70,9 +67,16 @@ static volatile struct uda {
struct mscp uda_cmd; /* command packets */
} uda;
+struct udadevice {
+ short udaip;
+ short udasa;
+};
+
static volatile struct uda *ubauda;
static volatile struct udadevice *udacsr;
static struct ra_softc ra_softc;
+static int curblock;
+
tmscpopen(f, adapt, ctlr, unit, part)
struct open_file *f;
@@ -81,18 +85,18 @@ tmscpopen(f, adapt, ctlr, unit, part)
char *msg;
extern u_int tmsaddr;
volatile struct ra_softc *ra=&ra_softc;
- volatile struct uba_regs *mr=(void *)ubaaddr[adapt];
volatile u_int *nisse;
unsigned short johan;
int i,err;
+ curblock = 0;
if(adapt>nuba) return(EADAPT);
if(ctlr>nuda) return(ECTLR);
ra->udaddr=uioaddr[adapt]+tmsaddr;
- ra->ubaddr=(int)mr;
+ ra->ubaddr=(int)ubaaddr[adapt];
ra->unit=unit;
udacsr=(void*)ra->udaddr;
- nisse=(u_int *)&mr->uba_map[0];
+ nisse=((u_int *)ubaaddr[adapt]) + 512;
nisse[494]=PG_V|(((u_int)&uda)>>9);
nisse[495]=nisse[494]+1;
ubauda=(void*)0x3dc00+(((u_int)(&uda))&0x1ff);
@@ -153,8 +157,6 @@ command(cmd, arg)
}
-static int curblock = 0;
-
tmscpstrategy(ra, func, dblk, size, buf, rsize)
struct ra_softc *ra;
int func;
@@ -163,14 +165,13 @@ tmscpstrategy(ra, func, dblk, size, buf, rsize)
u_int size, *rsize;
{
u_int i,j,pfnum, mapnr, nsize, bn, cn, sn, tn;
- volatile struct uba_regs *ur=(void *)ra->ubaddr;
volatile struct udadevice *udadev=(void*)ra->udaddr;
- volatile u_int *ptmapp = (u_int *)&ur->uba_map[0];
+ volatile u_int *ptmapp = (u_int *)ra->ubaddr + 512;
volatile int hej;
- pfnum=(u_int)buf>>PGSHIFT;
+ pfnum=(u_int)buf>>VAX_PGSHIFT;
- for(mapnr=0, nsize=size;(nsize+NBPG)>0;nsize-=NBPG)
+ for(mapnr=0, nsize=size;(nsize+VAX_NBPG)>0;nsize-=VAX_NBPG)
ptmapp[mapnr++]=PG_V|pfnum++;
/*
diff --git a/sys/arch/vax/stand/romread.s b/sys/arch/vax/boot/common/romread.s
index 41cb4e2d33d..749a70bae2d 100644
--- a/sys/arch/vax/stand/romread.s
+++ b/sys/arch/vax/boot/common/romread.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: romread.s,v 1.3 1997/05/29 00:04:24 niklas Exp $ */
+/* $OpenBSD: romread.s,v 1.1 2000/04/27 02:26:26 bjc Exp $ */
/* $NetBSD: romread.s,v 1.4 1996/08/02 11:22:24 ragge Exp $ */
/*
* Copyright (c) 1995 Ludd, University of Lule}, Sweden.
diff --git a/sys/arch/vax/stand/srt0.s b/sys/arch/vax/boot/common/srt0.s
index f96bc035eb1..350c47394a5 100644
--- a/sys/arch/vax/stand/srt0.s
+++ b/sys/arch/vax/boot/common/srt0.s
@@ -1,5 +1,5 @@
-/* $OpenBSD: srt0.s,v 1.6 1998/05/14 13:50:36 niklas Exp $ */
-/* $NetBSD: srt0.s,v 1.9 1997/03/22 12:47:32 ragge Exp $ */
+/* $OpenBSD: srt0.s,v 1.1 2000/04/27 02:26:26 bjc Exp $ */
+/* $NetBSD: srt0.s,v 1.2 1999/05/23 21:58:19 ragge Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -32,7 +32,7 @@
/* All bugs are subject to removal without further notice */
-
+#include "../include/asm.h"
/*
* Auto-moving startup code for standalone programs. Can be loaded
* (almost) anywhere in memory but moves itself to the position
@@ -41,8 +41,8 @@
* position set in a.out header.
*/
-start0: .set start0,0 # passing -e start0 to ld gives OK start addr
- .globl start0
+nisse: .set nisse,0 # pass -e nisse to ld gives OK start addr
+ .globl nisse
_start: .globl _start
nop;nop; # If we get called by calls, or something
@@ -58,28 +58,32 @@ _start: .globl _start
subl2 $52, sp # do not overwrite saved boot-registers
subl3 $_start, $_edata, r0
- moval _start, r1
- subl3 $_start, $_end, r2
+ movab _start, r1
movl $_start, r3
- movc5 r0, (r1), $0, r2, (r3)
+ movc3 r0,(r1),(r3) # Kopiera text + data
+ subl3 $_edata, $_end, r2
+ movc5 $0,(r3),$0,r2,(r3) # Nolla bss också.
+
jsb 1f
1: movl $relocated, (sp) # return-address on top of stack
rsb # can be replaced with new address
relocated: # now relocation is done !!!
+ movl r10,_bootdev # Save bootdev early
+ movl r11,_howto # howto also...
movl sp, _bootregs
- calls $0, _setup
calls $0, _Xmain # Were here!
halt # no return
-
- .globl _hoppabort
-_hoppabort: .word 0x0
- movl 4(ap), r6
- movl 8(ap), r11
- movl 0xc(ap), r10
- movl 16(ap), r9
- movl _memsz,r8
- calls $0,(r6)
+ENTRY(machdep_start, 0)
+ mtpr $0x1f,$0x12 # Block all interrupts
+ mtpr $0,$0x18 # stop real time interrupt clock
+ movl 4(ap), r6
+ movl _howto, r11
+ movl _opendev, r10
+ movl 20(ap), r9
+ movl _memsz, r8
+ calls $0,(r6)
+ ret
.globl _memsz
_memsz: .long 0x0
diff --git a/sys/arch/vax/boot/str.s b/sys/arch/vax/boot/common/str.s
index 8b393d5ddb3..b2f93510ec7 100644
--- a/sys/arch/vax/boot/str.s
+++ b/sys/arch/vax/boot/common/str.s
@@ -1,5 +1,5 @@
-/* $OpenBSD: str.s,v 1.4 1998/05/11 07:37:39 niklas Exp $ */
-/* $NetBSD: str.s,v 1.3 1997/03/15 13:04:30 ragge Exp $ */
+/* $OpenBSD: str.s,v 1.1 2000/04/27 02:26:26 bjc Exp $ */
+/* $NetBSD: str.s,v 1.1 1999/03/06 16:36:06 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -36,7 +36,7 @@
* emulated instructions.
*/
-#include "../include/asm.h"
+#include "asm.h"
/*
* atoi() used in devopen.
@@ -86,16 +86,11 @@ ENTRY(bcmp, 0);
* Is movc3/movc5 emulated on any CPU? I dont think so; use them here.
*/
ENTRY(bzero,0);
- movl 4(ap), r0
- movl 8(ap), r1
- movc5 $0,(r0),$0,r1,(r0)
+ movc5 $0,*4(ap),$0,8(ap),*4(ap)
ret
ENTRY(bcopy,0);
- movl 4(ap), r0
- movl 8(ap), r1
- movl 12(ap), r2
- movc3 r2, (r0), (r1)
+ movc3 12(ap), *4(ap), *8(ap)
ret
ENTRY(strlen, 0);
@@ -106,7 +101,6 @@ ENTRY(strlen, 0);
subl2 4(ap), r0
ret
-#if 0
ENTRY(strncmp, 0)
movl 12(ap), r3
brb 5f
@@ -130,4 +124,24 @@ ENTRY(strcmp, 0)
1: bgtr 3f
mnegl r0, r0
3: ret
-#endif
+
+ENTRY(strncpy, 0)
+ movl 4(ap), r1
+ movl 8(ap), r2
+ movl 12(ap), r3
+ bleq 2f
+
+1: movb (r2)+, (r1)+
+ beql 2f
+ decl r3
+ bneq 1b
+2: ret
+
+ENTRY(strcat, 0)
+ pushl 4(ap)
+ calls $1,_strlen
+ addl2 4(ap),r0
+ movl 8(ap),r1
+1: movb (r1)+,(r0)+
+ bneq 1b
+ ret
diff --git a/sys/arch/vax/boot/vaxstand.h b/sys/arch/vax/boot/common/vaxstand.h
index ad2ec8d7598..86cdb8bffdc 100644
--- a/sys/arch/vax/boot/vaxstand.h
+++ b/sys/arch/vax/boot/common/vaxstand.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: vaxstand.h,v 1.6 1998/05/11 07:35:24 niklas Exp $ */
-/* $NetBSD: vaxstand.h,v 1.6 1997/03/15 13:04:31 ragge Exp $ */
+/* $OpenBSD: vaxstand.h,v 1.1 2000/04/27 02:26:26 bjc Exp $ */
+/* $NetBSD: vaxstand.h,v 1.1 1999/03/06 16:36:05 ragge Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -40,7 +40,8 @@
/* Variables used in autoconf */
extern int nmba, nuba, nbi, nsbi, nuda;
extern int *ubaaddr, *mbaaddr, *udaaddr, *uioaddr, *biaddr;
-extern int cpunumber;
+extern int cpunumber, howto;
+extern dev_t bootdev;
/* devsw type definitions, used in bootxx and conf */
#define SADEV(name,strategy,open,close,ioctl) \
@@ -50,4 +51,9 @@ extern int cpunumber;
(int(*)(struct open_file *))close, \
(int(*)(struct open_file *,u_long, void *))ioctl}
+#define SDELAY(count) {volatile int i; for (i = count; i; i--);}
+/*
+ * Easy-to-use definitions
+ */
+
char *index();
diff --git a/sys/arch/vax/boot/copy.c b/sys/arch/vax/boot/copy.c
deleted file mode 100644
index 137530507b6..00000000000
--- a/sys/arch/vax/boot/copy.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/* $OpenBSD: copy.c,v 1.5 1998/05/11 07:36:25 niklas Exp $ */
-/* $NetBSD: copy.c,v 1.4 1997/02/12 18:00:42 ragge Exp $ */
-/*-
- * Copyright (c) 1982, 1986 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 7.15 (Berkeley) 5/4/91
- */
-
-#include "sys/param.h"
-#include "sys/reboot.h"
-#include "lib/libsa/stand.h"
-
-#include "vaxstand.h"
-
-#include <sys/exec.h>
-
-char line[100];
-volatile u_int devtype, bootdev;
-extern unsigned opendev;
-
-static char *progname = "copy";
-static char *iobuf = NULL;
-static char *bufp = NULL;
-static int bufsize = 0;
-static int partlist[8];
-
-int fill_buffer (void);
-int write_disk (void);
-
-Xmain()
-{
- int adapt, ctlr, unit, part;
- int res, i, loops;
- char line[64];
-
- autoconf ();
-
- printf ("\n");
- printf ("%s: \n", progname);
- printf ("This program will read miniroot from tape/floppy/disk \n");
- printf ("and install this miniroot onto disk.\n");
- printf ("\n");
-
- res = fill_buffer ();
- if (res < 0) {
- printf ("errors occured during read. Continue at your own risk.\n");
- printf ("Do you want to continue ? [y/n] ");
- gets (line);
- if (*line != 'y' && *line != 'Y') {
- printf ("bye.\n");
- return (-1);
- }
- }
-
- printf ("\n");
- res = write_disk ();
-
- printf ("\n");
- printf ("Halt/Reboot the machine NOW.\n");
- for (;;)
- ;
- /* NOTREACHED */
-}
-
-int
-fill_buffer (void)
-{
- char devname[64];
- int numblocks;
- int blocksize = 512;
- int bpv = 0; /* blocks per volume */
- int bpt = 8; /* blocks per transfer */
- struct open_file file;
- char *filename;
- int i, loops;
- int size, rsize;
- int res, errors = 0;
-
-again:
- printf("\n");
- printf("Specify the device to read from as xx(N,?), where\n");
- printf("xx is the device-name, ? is file/partition number\n");
- printf("and N is the unit-number, e.g.\n");
- printf("\"mt(0,1)\" for the first TMSCP-tape (TK50),\n");
- printf("\"ra(2,0)\" for the third MSCP-disk/floppy (RX33/RX50)\n");
- printf("\n");
- printf("device to read from ? ");
- gets(devname);
-
- printf("\n");
- printf("Specify number of blocks to transfer. Usually this is\n");
- printf("sizeof(miniroot) / 512.\n");
- printf("It's safe to transfer more blocks than just the miniroot.\n");
- printf("\n");
- while (1) {
- printf ("number of blocks ? ");
- gets (line);
- if (atoi(line) > 0) {
- if (iobuf && bufsize)
- free (iobuf, bufsize);
- numblocks = atoi (line);
- bufsize = 512 * numblocks;
- iobuf = alloc (bufsize);
- bufp = iobuf;
- if (iobuf == NULL) {
- printf ("cannot allocate this much memory.\n");
- continue;
- }
- break;
- }
- printf ("invalid number %d.\n", atoi(line));
- }
-
- printf ("\n");
- printf ("If your miniroot is split into volumes, then you must\n");
- printf ("specify the number of blocks per volume.\n");
- printf ("(e.g. 800 blocks per RX50, 2400 blocks per RX33)\n");
- printf ("\n");
- while (1) {
- printf ("number of blocks per volume ? [%d] ", numblocks);
- gets (line);
- if (!*line || atoi(line) > 0) {
- bpv = (atoi(line) > 0 ? atoi(line) : numblocks);
- break;
- }
- printf ("invalid number %d.\n", atoi(line));
- }
-
- printf ("\n");
- do {
- printf ("Make sure unit %s is online and holds the proper volume.\n", devname);
- printf ("Then type \'g\' to Go or \'a\' to Abort.\n");
- printf ("\n");
- printf ("OK to go on ? [g/a] ");
- gets (line);
- if (*line == 'g' || *line == 'G') {
- printf ("Reading ... ");
- if (devopen (&file, devname, &filename)) {
- printf ("cannot open unit %s.\n", devname);
- goto again;
- }
- loops = bpv / bpt + (bpv % bpt != 0);
- for (i=0; i<loops; i++) {
- twiddle ();
- size = 512 * min (bpt, bpv - (i*bpt));
- res = (*file.f_dev->dv_strategy)
- (file.f_devdata, F_READ,
- (daddr_t)i*bpt, size, bufp, &rsize);
- if (res != 0) {
- printf ("error %d in read.\n", res);
- errors++;
- /* continue ? halt ??? */
- }
- bufp += size;
- }
- numblocks -= bpv;
- }
- if (numblocks > 0) {
- int vn = ((bufp - iobuf) / 512) / bpv;
- printf ("\n");
- printf ("volume #%d done. Now insert volume #%d\n",
- vn - 1, vn);
- }
- } while (numblocks > 0);
- printf ("Reading of miniroot done. (%d blocks read)\n",
- (bufp - iobuf) / 512);
-
- return (-errors);
-}
-
-int
-write_disk (void)
-{
- char line[64];
- char devname[64];
- struct open_file file;
- char *fname;
- int rsize, res;
- int i, errors = 0;
-
- printf ("\n");
- printf ("Now specify the device to write miniroot to as xx(N,1)\n");
- printf ("where xx is the drive type and N is the drive number.\n");
- printf ("For example: ra(0,1) refers to MSCP drive #0, b partition\n");
- printf ("\n");
- do {
- printf ("Root disk ? : ");
- gets (devname);
- } while (devopen (&file, devname, &fname));
-
- /*
- * next: initialize the partition
- */
- printf ("Initializing partition ... ");
- bufp = iobuf + (16 * 512);
- for (i=16; i<bufsize/512; i++) {
- twiddle ();
- res = (*file.f_dev->dv_strategy) (file.f_devdata, F_WRITE,
- (daddr_t)i, 512, bufp, &rsize);
- if (res != 0) {
- errors++;
- printf ("error writing block %d.\n");
- printf ("trying to continue ...\n");
- }
- bufp += 512;
- }
- printf ("done.\n");
- printf ("(%d blocks written.)\n", bufsize/512);
-
- printf ("\n");
- printf ("Halt the machine and reboot from distribution media,\n");
- printf ("giving second partition as part to mount as root. Ex:\n");
- printf (": ra(0,1) for ra disk 0, hp(2,1) for massbuss disk 2\n");
-
- return (-errors);
-}
-
diff --git a/sys/arch/vax/boot/edlabel.c b/sys/arch/vax/boot/edlabel.c
deleted file mode 100644
index c5d55167922..00000000000
--- a/sys/arch/vax/boot/edlabel.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/* $OpenBSD: edlabel.c,v 1.3 1997/05/29 00:04:22 niklas Exp $ */
-/* $NetBSD: edlabel.c,v 1.2 1996/08/02 11:22:11 ragge Exp $ */
-/*
- * Copyright (c) 1995 Ludd, University of Lule}, Sweden.
- * 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 at Ludd, University of
- * Lule}, Sweden and its contributors.
- * 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.
- */
-
-#define DKTYPENAMES
-
-#include "sys/param.h"
-#include "sys/disklabel.h"
-
-#include "lib/libsa/stand.h"
-#include "ufs/ffs/fs.h"
-
-struct disklabel dlabel;
-char bootblock[8192];
-
-void
-showlabel()
-{
- struct disklabel *lp;
- struct partition *pp;
- int i, j;
-
- lp = &dlabel;
-
- printf("\n\ndisk type %d (%s), %s: %s%s%s\n", lp->d_type, lp->d_type
- <DKMAXTYPES?dktypenames[lp->d_type]:dktypenames[0], lp->d_typename,
- lp->d_flags & D_REMOVABLE?" removable":"", lp->d_flags & D_ECC?
- " ecc":"", lp->d_flags & D_BADSECT?" badsect":"");
-
- printf("interleave %d, rpm %d, trackskew %d, cylinderskew %d\n",
- lp->d_interleave, lp->d_rpm, lp->d_trackskew, lp->d_cylskew);
- printf("headswitch %d, track-to-track %d, drivedata: %d %d %d %d %d\n",
- lp->d_headswitch, lp->d_trkseek, lp->d_drivedata[0],
- lp->d_drivedata[1], lp->d_drivedata[2], lp->d_drivedata[3],
- lp->d_drivedata[4]);
-
- printf("\nbytes/sector: %d\n", lp->d_secsize);
- printf("sectors/track: %d\n", lp->d_nsectors);
- printf("tracks/cylinder: %d\n", lp->d_ntracks);
- printf("sectors/cylinder: %d\n", lp->d_secpercyl);
- printf("cylinders: %d\n", lp->d_ncylinders);
-
- printf("\n%d partitions:\n", lp->d_npartitions);
- printf(" size offset\n");
- pp = lp->d_partitions;
- for (i = 0; i < lp->d_npartitions; i++) {
- printf("%c: %d, %d\n", 97 + i, lp->d_partitions[i].p_size,
- lp->d_partitions[i].p_offset);
- }
- printf("\n");
-}
-
-setdefaultlabel()
-{
- printf("Sorry, not implemented yet. Later...\n\n");
-}
-
-#define GETNUM(out, num) printf(out, num);gets(store); \
- if (*store) num = atoi(store);
-#define GETNUM2(out, num1, num) printf(out, num1, num);gets(store); \
- if (*store) num = atoi(store);
-#define GETSTR(out, str) printf(out, str);gets(store); \
- if (*store) bcopy(store, str, strlen(store));
-#define FLAGS(out, flag) printf(out, lp->d_flags & flag?'y':'n');gets(store); \
- if (*store == 'y' || *store == 'Y') lp->d_flags |= flag; \
- else lp->d_flags &= ~flag;
-
-editlabel()
-{
- struct disklabel *lp;
- char store[256];
- int i;
-
- lp = &dlabel;
- printf("\nFirst set disk type. Valid types are:\n");
- for (i = 0; i < DKMAXTYPES; i++)
- printf("%d %s\n", i, dktypenames[i]);
-
- GETNUM("\nNumeric disk type? [%d] ", lp->d_type);
- GETSTR("Disk name? [%s] ", lp->d_typename);
- FLAGS("badsectoring? [%c] ", D_BADSECT);
- FLAGS("ecc? [%c] ", D_ECC);
- FLAGS("removable? [%c] ", D_REMOVABLE);
-
- GETNUM("Interleave? [%d] ", lp->d_interleave);
- GETNUM("rpm? [%d] ", lp->d_rpm);
- GETNUM("trackskew? [%d] ", lp->d_trackskew);
- GETNUM("cylinderskew? [%d] ", lp->d_cylskew);
- GETNUM("headswitch? [%d] ", lp->d_headswitch);
- GETNUM("track-to-track? [%d] ", lp->d_trkseek);
- GETNUM("drivedata 0? [%d] ", lp->d_drivedata[0]);
- GETNUM("drivedata 1? [%d] ", lp->d_drivedata[1]);
- GETNUM("drivedata 2? [%d] ", lp->d_drivedata[2]);
- GETNUM("drivedata 3? [%d] ", lp->d_drivedata[3]);
- GETNUM("drivedata 4? [%d] ", lp->d_drivedata[4]);
- lp->d_secsize = 512;
- GETNUM("\nbytes/sector? [%d] ", lp->d_secsize);
- GETNUM("sectors/track? [%d] ", lp->d_nsectors);
- GETNUM("tracks/cylinder? [%d] ", lp->d_ntracks);
- lp->d_secpercyl = lp->d_nsectors * lp->d_ntracks;
- GETNUM("sectors/cylinder? [%d] ", lp->d_secpercyl);
- GETNUM("cylinders? [%d] ", lp->d_ncylinders);
- lp->d_npartitions = MAXPARTITIONS;
- for (i = 0; i < 8; i++) {
- GETNUM2("%c partition: offset? [%d] ", 97 + i,
- lp->d_partitions[i].p_offset);
- GETNUM(" size? [%d] ", lp->d_partitions[i].p_size);
- }
-}
-
-int bootdev;
-
-void
-Xmain()
-{
- register bdev asm("r10");
-
- struct open_file file;
- char diskname[64], *msg, *filename, indata[64];
- int i, rsize;
-
- bootdev = bdev;
- printf("With this program you can modify everything in the on-disk\n");
- printf("disklabel. To do something useful you must know the exact\n");
- printf("geometry of your disk, and have ideas about how you want\n");
- printf("your partitions to be placed on disk. Some hints:\n");
- printf("The a partition should be at least ~20000 blocks, the\n");
- printf("b (swap) is depending on your use of the machine but it\n");
- printf("should almost never be less than ~32000 blocks.\n\n");
- printf("Disk geometry for most DEC disks can be found in the disktab");
- printf("\nfile, and disknames is listed in the installation notes.\n");
- printf("\nRemember that disk names is given as disk(adapt, ctrl, ");
- printf("disk, part)\nwhen using the installation tools.\n\n");
-
- autoconf();
-igen:
- printf("Label which disk? ");
- gets(diskname);
- if (*diskname == 0) goto igen;
- if (devopen(&file, diskname, &filename)) {
- printf("cannot open %s\n", diskname);
- goto igen;
- }
- if ((*file.f_dev->dv_strategy)(file.f_devdata, F_READ,
- (daddr_t)0, 8192, bootblock, &rsize)) {
- printf("cannot read label block\n");
- goto igen;
- }
- if (msg = (char *) getdisklabel(LABELOFFSET + bootblock, &dlabel))
- printf("%s: %s\n", diskname, msg);
-
- do {
- printf("(E)dit, (S)how, (D)efaults, (W)rite, (Q)uit) : ");
- gets(indata);
- switch (*indata) {
- case ('e'):
- case ('E'):
- editlabel();
- break;
- case ('s'):
- case ('S'):
- showlabel();
- break;
- case ('d'):
- case ('D'):
- setdefaultlabel();
- break;
- case ('w'):
- case ('W'):
- dlabel.d_magic = DISKMAGIC;
- dlabel.d_magic2 = DISKMAGIC;
- dlabel.d_bbsize = BBSIZE;
- dlabel.d_sbsize = SBSIZE;
- dlabel.d_checksum = 0;
- dlabel.d_checksum = dkcksum(&dlabel);
- bcopy(&dlabel, LABELOFFSET + bootblock,
- sizeof(struct disklabel));
- if ((*file.f_dev->dv_strategy)(file.f_devdata, F_WRITE,
- (daddr_t)0, 8192, bootblock, &rsize)) {
- printf("cannot write label sectors.\n");
- break;
- }
- printf("\nThis program does not (yet) write");
- printf(" bootblocks, only disklabel.\n");
- printf("Remember to write the bootblocks from the ");
- printf("miniroot later with the\ncommand ");
- printf("\"disklabel -B <diskname>\".\n\n");
- break;
- case ('q'):
- case ('Q'):
- default:
- break;
- }
- } while (*indata != 'q' && *indata != 'Q');
- goto igen;
-}
diff --git a/sys/arch/vax/boot/ka410.h b/sys/arch/vax/boot/ka410.h
deleted file mode 100644
index ef2c656df0e..00000000000
--- a/sys/arch/vax/boot/ka410.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* $OpenBSD: ka410.h,v 1.2 1997/05/29 00:04:23 niklas Exp $ */
-/* $NetBSD: ka410.h,v 1.1 1996/08/02 11:22:13 ragge Exp $ */
-/*
- * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
- * All rights reserved.
- *
- * This code is derived from software contributed to Ludd by
- * Bertram Barth.
- *
- * 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 at Ludd, University of
- * Lule}, Sweden and its contributors.
- * 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.
- */
-
-
-
-/*
- * interrupt request-, clear-, and mask register
- */
-extern volatile unsigned char *ka410_intreq;
-extern volatile unsigned char *ka410_intclr;
-extern volatile unsigned char *ka410_intmsk;
-
-#define INTR_SR (1<<7) /* Serial line receiver or silo full */
-#define INTR_ST (1<<6) /* Serial line transmitter done */
-#define INTR_NP (1<<5) /* Network controller primary */
-#define INTR_NS (1<<4) /* Network controller secondary */
-#define INTR_VF (1<<3) /* Video end of frame */
-#define INTR_VS (1<<2) /* Video secondary */
-#define INTR_SC (1<<1) /* SCSI controller */
-#define INTR_DC (1<<0) /* Disk controller */
-
-/*
- * interrupt vector numbers
- */
-#define IVEC_BASE 0x20040020
-#define IVEC_SR 0x000002C0
-#define IVEC_ST 0x000002C4
-#define IVEC_NP 0x00000250
-#define IVEC_NS 0x00000254
-#define IVEC_VF 0x00000244
-#define IVEC_VS 0x00000248
-#define IVEC_SC 0x000003F8
-#define IVEC_DC 0x000003FC
-
-/*
- * Clock-Chip data in NVRAM
- */
-#define KA410_CPMBX 0x200B0038 /* Console Mailbox (1 byte) */
-#define KA410_CPFLG 0x200B003C /* Console Program Flags (1 byte) */
-#define KA410_LK201_ID 0x200B0040 /* Keyboard Variation (1 byte) */
-#define KA410_CONS_ID 0x200B0044 /* Console Device Type (1 byte) */
-#define KA410_SCR 0x200B0048 /* Console Scratch RAM */
-#define KA410_TEMP 0x200B0058 /* Used by System Firmware */
-#define KA410_BAT_CHK 0x200B0088 /* Battery Check Data */
-#define KA410_BOOTDEV 0x200B0098 /* Default Boot Device (4 bytes) */
-#define KA410_BOOTFLG 0x200B00A8 /* Default Boot Flags (4 bytes) */
-#define KA410_SCRLEN 0x200B00B8 /* Number of pages of SCR (1 byte) */
-#define KA410_SCSIPORT 0x200B00BC /* Tape Controller Port Data */
-#define KA410_RESERVED 0x200B00C0 /* Reserved (16 bytes) */
-
diff --git a/sys/arch/vax/boot/samachdep.h b/sys/arch/vax/boot/samachdep.h
deleted file mode 100644
index 4aab837f096..00000000000
--- a/sys/arch/vax/boot/samachdep.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* $OpenBSD: samachdep.h,v 1.2 1997/05/29 00:04:25 niklas Exp $ */
-/* $NetBSD: samachdep.h,v 1.1 1996/08/02 11:22:28 ragge Exp $ */
-
-/*
- * Copyright (c) 1982, 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.
- *
- * @(#)samachdep.h 8.1 (Berkeley) 6/10/93
- */
-
-#define NSCSI 1
-#define NSD 8
-
-extern int howto;
-extern unsigned int bootdev;
diff --git a/sys/arch/vax/boot/scsi_hi.c b/sys/arch/vax/boot/scsi_hi.c
deleted file mode 100644
index b49e0f2610c..00000000000
--- a/sys/arch/vax/boot/scsi_hi.c
+++ /dev/null
@@ -1,298 +0,0 @@
-/* $OpenBSD: scsi_hi.c,v 1.2 1997/05/29 00:04:25 niklas Exp $ */
-/* $NetBSD: scsi_hi.c,v 1.1 1996/08/02 11:22:31 ragge Exp $ */
-
-/****************************************************************************
- * NS32K Monitor SCSI high-level driver
- * Bruce Culbertson
- * 8 March 1990
- * (This source is public domain source)
- *
- * There are three monitor SCSI commands. "Read" and "write" I think are
- * fairly self explanatory once you read the help messages. They, in fact,
- * execute the "extended read", "extended write", and "request sense"
- * commands from the SCSI standard.
- *
- * "Raw" lets you execute any SCSI command but you need a SCSI reference to
- * know what the commands are and what their formats are. The SCSI
- * standard specifies that there are six buffers which, for example, hold a
- * SCSI command or are the source or destination for data. You provide
- * "raw" with an array of pointers to the six buffers. Using "edit", you
- * can enter a SCSI command somewhere in memory and you can create the
- * array of pointers. The array must actually be eight entries long; two
- * entries are not used. By typing "raw <array address>", the SCSI command
- * is executed.
- *
- * By the way, "read", "write", and "raw" talk only to the DP8490 SCSI
- * controller. I have not had time to read the Adaptec data sheet and
- * write a driver for it.
- ****************************************************************************/
-#include "so.h"
-
-#define OK 0
-#define NOT_OK OK+1
-#define PRIVATE
-#define PUBLIC
-#define U8 unsigned char
-
-long scsiAdr = DEFAULT_SCSI_ADR, /* default SCSI address */
- scsiLun = DEFAULT_SCSI_LUN;
-
-struct cmd_desc { /* SCSI command description */
- const U8 *cmd; /* command string */
- const U8 *odata; /* data to output, if any */
- const struct cmd_desc *chain; /* next command */
-};
-
-struct drive { /* SCSI drive description */
- U8 adr, lun; /* SCSI address and LUN */
- U8 flags; /* drive characteristics */
- U8 stat; /* drive state */
- const struct cmd_desc *init; /* list of initialize commands */
-};
-/* for drive.flags */
-#define EXTENDED_RDWR 1 /* device does extended read, write */
-#define EXTENDED_SENSE 2 /* device does extended sense */
-/* for drive.stat */
-#define INITIALIZED 1 /* device is initialized */
-
-PRIVATE struct drive drive_tbl[] = {
-#if 1
- {0, 0, 0, 1, 0},
- {1, 0, 0, 1, 0},
- {2, 0, 0, 1, 0},
- {3, 0, 0, 1, 0},
- {4, 0, 0, 1, 0},
- {5, 0, 0, 1, 0},
- {6, 0, 0, 1, 0},
- {7, 0, 0, 1, 0},
-#else
- {0, 0, EXTENDED_RDWR | EXTENDED_SENSE, 1, 0},
- {1, 0, EXTENDED_RDWR | EXTENDED_SENSE, 1, 0},
- {2, 0, EXTENDED_RDWR | EXTENDED_SENSE, 1, 0},
- {3, 0, EXTENDED_RDWR | EXTENDED_SENSE, 1, 0},
- {4, 0, EXTENDED_RDWR | EXTENDED_SENSE, 1, 0},
- {5, 0, EXTENDED_RDWR | EXTENDED_SENSE, 1, 0},
- {6, 0, EXTENDED_RDWR | EXTENDED_SENSE, 1, 0},
- {7, 0, EXTENDED_RDWR | EXTENDED_SENSE, 1, 0},
-#endif
-};
-#define DRV_TBL_SZ (sizeof (drive_tbl) / sizeof (struct drive))
-
-/* Round up to multiple of four since SCSI transfers are always multiples
- * of four bytes.
- */
-#define CMD_LEN 12 /* longest SCSI command */
-#define SENSE_LEN 24 /* extended sense length */
-#define MSG_LEN 4
-#define STAT_LEN 4
-
-#define MAX_SCSI_RETRIES 6
-#define CMD_IX 2
-#define CMD_SENSE 0x03
-#define CMD_READ 0x08
-#define CMD_WRITE 0x0a
-#define CMD_XREAD 0x28
-#define CMD_XWRITE 0x2a
-PRIVATE U8 cmd_buf[CMD_LEN];
-
-#define SENSE_KEY 2
-#define NO_SENSE 0
-#define RECOVERY_ERR 1
-#define UNIT_ATTN 6
-#define ADD_SENSE_CODE 12
-#define SENSE_RST 0x29
-PRIVATE U8 sense_buf[SENSE_LEN];
-
-#define CHECK_CONDITION 2
-#define STAT_IX 3
-#define STAT_MASK 0x1f
-PRIVATE U8 stat_buf[STAT_LEN];
-#define IMSG_IX 7
-PRIVATE U8 msg_buf[MSG_LEN];
-
-#define ODATA_IX 0
-#define IDATA_IX 1
-PRIVATE struct scsi_args scsi_args;
-
-/*===========================================================================*
- * sc_rdwt *
- *===========================================================================*/
-/* Carry out a read or write request for the SCSI disk. */
-PRIVATE int
-sc_rdwt(op, block, ram_adr, len, sc_adr, lun)
-long block, ram_adr, len, sc_adr, lun;
-{
- int retries, ret;
- U8 *p;
- struct drive *dp;
-
- printf ("sc_rdwt: op %x, block %d, ram %x, len %d, sc_adr %d, lun %d\n",
- op, block, ram_adr, len, sc_adr, lun);
-
- /* get drive characteristics */
- for (dp = drive_tbl; dp < drive_tbl + DRV_TBL_SZ - 1; ++dp)
- if (dp->adr == sc_adr && dp->lun == lun) break;
- if (dp == drive_tbl + DRV_TBL_SZ - 1) {
- dp->adr = sc_adr; /* have default, set adr, lun */
- dp->lun = lun;
- }
- for (retries = 0; retries < MAX_SCSI_RETRIES; ++retries) {
- if (dp->init && !(dp->stat & INITIALIZED))
- if (OK != sc_initialize (dp)) {
- printf("SCSI cannot initialize device\n");
- return NOT_OK;
- }
- p = cmd_buf; /* build SCSI command */
- if (dp->flags & EXTENDED_RDWR) { /* use extended commands */
- *p++ = (op == DISK_READ)? CMD_XREAD: CMD_XWRITE;
- *p++ = lun << 5;
- *p++ = (block >> 24) & 0xff;
- *p++ = (block >> 16) & 0xff;
- *p++ = (block >> 8) & 0xff;
- *p++ = (block >> 0) & 0xff;
- *p++ = 0;
- *p++ = (len >> 8) & 0xff;
- *p++ = (len >> 0) & 0xff;
- *p = 0;
- } else { /* use short (SASI) commands */
- *p++ = (op == DISK_READ)? CMD_READ: CMD_WRITE;
- *p++ = (lun << 5) | ((block >> 16) & 0x1f);
- *p++ = (block >> 8) & 0xff;
- *p++ = (block >> 0) & 0xff;
- *p++ = len;
- *p = 0;
- }
- if (op == DISK_READ)
- ret = exec_scsi_hi (cmd_buf, (U8 *)ram_adr, (U8 *)0, dp);
- else
- ret = exec_scsi_hi (cmd_buf, (U8 *)0, (U8 *)ram_adr, dp);
- if (OK == ret) return OK;
- dp->stat &= ~INITIALIZED;
- }
- printf("SCSI %s, block %d failed even after retries\n",
- op == DISK_READ? "READ": "WRITE", block);
- return NOT_OK;
-}
-
-/*===========================================================================*
- * sc_initialize *
- *===========================================================================*/
-/* Execute the list of initialization commands for the given drive.
- */
-int
-sc_initialize (dp)
-struct drive *dp;
-{
- const struct cmd_desc *cp;
-
- for (cp = dp->init; cp != 0; cp = cp->chain)
- if (OK != exec_scsi_hi (cp->cmd, 0, cp->odata, dp)) {
- dp->stat &= ~INITIALIZED;
- return NOT_OK;
- }
- dp->stat |= INITIALIZED;
- return OK;
-}
-
-/*===========================================================================*
- * exec_scsi_hi *
- *===========================================================================*/
-/* Execute a "high-level" SCSI command. This means execute a low level
- * command and, if it fails, execute a request sense to find out why.
- */
-PRIVATE int
-exec_scsi_hi(cmd, data_in, data_out, dp)
-U8 *cmd, *data_out, *data_in;
-struct drive *dp;
-{
- scsi_args.ptr[CMD_IX] = (long)cmd;
- scsi_args.ptr[STAT_IX] = (long)stat_buf;
- scsi_args.ptr[IMSG_IX] = (long)msg_buf;
- scsi_args.ptr[IDATA_IX] = (long)data_in;
- scsi_args.ptr[ODATA_IX] = (long)data_out;
- if (OK != exec_scsi_low (&scsi_args, dp->adr))
- return NOT_OK;
- *stat_buf &= STAT_MASK; /* strip off lun */
- if (*stat_buf == 0)
- /* Success -- this should be the usual case */
- return OK;
- if (*stat_buf != CHECK_CONDITION) {
- /* do not know how to handle this so return error */
- printf("SCSI device returned unknown status: %d\n", *stat_buf);
- return NOT_OK;
- }
- /* Something funny happened, need to execute request-sense command
- * to learn more.
- */
- if (OK == get_sense(dp))
- /* Something funny happened, but the device recovered from it and
- * the command succeeded.
- */
- return OK;
- return NOT_OK;
-}
-
-/*===========================================================================*
- * get_sense *
- *===========================================================================*/
-/* Execute a "request sense" SCSI command and check results. When a SCSI
- * command returns CHECK_CONDITION, a request-sense command must be executed.
- * A request-sense command provides information about the original command.
- * The original command might have succeeded, in which case it does not
- * need to be retried and OK is returned. Examples: read error corrected
- * with error correction code, or error corrected by retries performed by
- * the SCSI device. The original command also could have failed, in
- * which case NOT_OK is returned.
- */
-#define XLOGICAL_ADR \
- (sense_buf[3]<<24 | sense_buf[4]<<16 | sense_buf[5]<<8 | sense_buf[6])
-#define LOGICAL_ADR \
- (sense_buf[1]<<16 | sense_buf[2]<<8 | sense_buf[3])
-
-PRIVATE int
-get_sense (dp)
-struct drive *dp;
-{
- U8 *p;
-
- p = cmd_buf; /* build SCSI command */
- *p++ = CMD_SENSE;
- *p++ = dp->lun << 5;
- *p++ = 0;
- *p++ = 0;
- *p++ = (dp->flags & EXTENDED_SENSE)? SENSE_LEN: 0;
- *p = 0;
- scsi_args.ptr[IDATA_IX] = (long)sense_buf;
- scsi_args.ptr[ODATA_IX] = 0;
- scsi_args.ptr[CMD_IX] = (long)cmd_buf;
- scsi_args.ptr[STAT_IX] = (long)stat_buf;
- scsi_args.ptr[IMSG_IX] = (long)msg_buf;
- if (OK != exec_scsi_low (&scsi_args, dp->adr)) {
- printf("SCSI SENSE command failed\n");
- return NOT_OK;
- }
- if ((*stat_buf & STAT_MASK) != 0) {
- printf("SCSI SENSE returned wrong status %d\n", *stat_buf);
- return NOT_OK;
- }
- if (0 == (dp->flags & EXTENDED_SENSE)) {
- printf("SCSI request sense, code 0x%x, log_adr 0x%x\n",
- sense_buf[0], LOGICAL_ADR);
- return NOT_OK;
- }
- switch (sense_buf[SENSE_KEY] & 0xf) {
- case NO_SENSE:
- case UNIT_ATTN: /* reset */
- return NOT_OK; /* must retry command */
- case RECOVERY_ERR:
- /* eventually, we probably do not want to hear about these. */
- printf("SCSI ok with recovery, code 0x%x, logical address 0x%x\n",
- sense_buf[ADD_SENSE_CODE], XLOGICAL_ADR);
- return OK; /* orig command was ok with recovery */
- default:
- printf("SCSI failure: key 0x%x code 0x%x log adr 0x%x sense buf 0x%x\n",
- sense_buf[SENSE_KEY], sense_buf[ADD_SENSE_CODE],
- XLOGICAL_ADR, sense_buf);
- return NOT_OK; /* orig command failed */
- }
-}
diff --git a/sys/arch/vax/boot/scsi_low.c b/sys/arch/vax/boot/scsi_low.c
deleted file mode 100644
index 9a6f1d61876..00000000000
--- a/sys/arch/vax/boot/scsi_low.c
+++ /dev/null
@@ -1,480 +0,0 @@
-/* $OpenBSD: scsi_low.c,v 1.2 1997/05/29 00:04:26 niklas Exp $ */
-/* $NetBSD: scsi_low.c,v 1.1 1996/08/02 11:22:34 ragge Exp $ */
-
-/****************************************************************************
- * NS32K Monitor SCSI low-level driver
- * Bruce Culbertson
- * 8 March 1990
- * (This source is public domain source.)
- *
- * Originally written by Bruce Culbertson for a ns32016 port of Minix.
- * Adapted from that for the pc532 (ns32632) monitor.
- * Adapted from that for NetBSD/pc532 by Philip L. Bunde.
- *
- * Do not use DMA -- makes 32016 and pc532 versions compatible.
- * Do not use interrupts -- makes it harder for the user code to bomb
- * this code.
- ****************************************************************************/
-
-#include "so.h"
-#include "ka410.h"
-
-#define BB_DEBUG(x) printf x
-#define CLEAR_INTR() *ka410_intclr=INTR_SC
-#define CHECK_INTR() *ka410_intreq&INTR_SC
-
-#define OK 0
-#define NOT_OK OK+1
-#define PRIVATE
-#define PUBLIC
-#define WR_ADR(adr,val) (*((volatile unsigned char *)(adr))=(val))
-#define RD_ADR(adr) (*((volatile unsigned char *)(adr)))
-/* #define AIC6250 0 */
-/* #define DP8490 1 */
-#define MAX_CACHE 0x4000
-
-/* SCSI bus phases
- */
-#define PH_ODATA 0
-#define PH_IDATA 1
-#define PH_CMD 2
-#define PH_STAT 3
-#define PH_IMSG 7
-#define PH_NONE 8
-#define PH_IN(phase) ((phase) & 1)
-
-/* NCR5380 SCSI controller registers
- */
-#define SC_CTL 0x200C0080 /* base for control registers */
-#define SC_DMA 0x200D0000 /* base for data registers (8/16K) */
-#define SC_CURDATA SC_CTL+(4*0)
-#define SC_OUTDATA SC_CTL+(4*0)
-#define SC_ICMD SC_CTL+(4*1)
-#define SC_MODE SC_CTL+(4*2)
-#define SC_TCMD SC_CTL+(4*3)
-#define SC_STAT1 SC_CTL+(4*4)
-#define SC_STAT2 SC_CTL+(4*5)
-#define SC_START_SEND SC_CTL+(4*5)
-#define SC_INDATA SC_CTL+(4*6)
-#define SC_RESETIP SC_CTL+(4*7)
-#define SC_START_RCV SC_CTL+(4*7)
-
-/* Bits in NCR5380 registers
- */
-#define SC_A_RST 0x80
-#define SC_A_SEL 0x04
-#define SC_S_SEL 0x02
-#define SC_S_REQ 0x20
-#define SC_S_BSY 0x40
-#define SC_S_BSYERR 0x04
-#define SC_S_PHASE 0x08
-#define SC_S_IRQ 0x10
-#define SC_S_DRQ 0x40
-#define SC_M_DMA 0x02
-#define SC_M_BSY 0x04
-#define SC_ENABLE_DB 0x01
-
-/* Status of interrupt routine, returned in m1_i1 field of message.
- */
-#define ISR_NOTDONE 0
-#define ISR_OK 1
-#define ISR_BSYERR 2
-#define ISR_RSTERR 3
-#define ISR_BADPHASE 4
-#define ISR_TIMEOUT 5
-
-#define ICU_ADR 0xfffffe00
-#define ICU_IO (ICU_ADR+20)
-#define ICU_DIR (ICU_ADR+21)
-#define ICU_DATA (ICU_ADR+19)
-#define ICU_SCSI_BIT 0x80
-
-/* Miscellaneous
- */
-#define MAX_WAIT (1000*1000)
-#define SC_LOG_LEN 32
-
-PRIVATE struct scsi_args *sc_ptrs;
-PRIVATE char sc_cur_phase,
- sc_reset_done = 1,
- sc_have_msg,
- sc_accept_int,
- sc_dma_dir;
-
-long sc_dma_port = SC_DMA,
- sc_dma_adr;
-
-#ifdef DEBUG
-struct sc_log {
- unsigned char stat1, stat2;
-} sc_log [SC_LOG_LEN],
- *sc_log_head = sc_log;
-int sc_spurious_int;
-#endif
-unsigned char
- sc_watchdog_error; /* watch dog error */
-
-/* error messages */
-char *scsi_errors[] = {
- 0, /* ISR_NOTDONE */
- 0, /* ISR_OK */
- "busy error", /* ISR_BSYERR */
- "reset error", /* ISR_RSTERR */
- "NULL pointer for current phase", /* ISR_BADPHASE */
- "timeout", /* ISR_TIMEOUT */
-};
-
-/*===========================================================================*
- * exec_scsi_low *
- *===========================================================================*/
-/* Execute a generic SCSI command. Passed pointers to eight buffers:
- * data-out, data-in, command, status, dummy, dummy, message-out, message-in.
- */
-PUBLIC
-int
-exec_scsi_low (args, scsi_adr)
-struct scsi_args *args;
-long scsi_adr;
-{
- int ret;
-
- BB_DEBUG (("exec_scsi_low(0x%x, %d)\n", args, scsi_adr));
-
- sc_ptrs = args; /* make pointers globally accessible */
- /* bertram ??? scCtlrSelect (DP8490); */
- if (!sc_reset_done) sc_reset();
- /* TCMD has some undocumented behavior in initiator mode. I think the
- * data bus cannot be enabled if i/o is asserted.
- */
- WR_ADR (SC_TCMD, 0);
- if (OK != sc_wait_bus_free ()) { /* bus-free phase */
- printf("SCSI: bus not free\n");
- return NOT_OK;
- }
- sc_cur_phase = PH_NONE;
- sc_have_msg = 0;
- if (OK != sc_select (scsi_adr)) /* select phase */
- return NOT_OK;
- sc_watchdog_error = 0;
- ret = sc_receive (); /* isr does the rest */
- if (ret == ISR_OK) return OK;
- else {
- sc_reset();
- printf("SCSI: %s\n", scsi_errors[ret]);
- return NOT_OK;
- }
-}
-
-/*===========================================================================*
- * sc_reset *
- *===========================================================================*/
-/*
- * Reset SCSI bus.
- */
-PRIVATE
-sc_reset()
-{
- volatile int i;
-
- BB_DEBUG (("sc_reset()\n"));
-
- WR_ADR (SC_MODE, 0); /* get into harmless state */
- WR_ADR (SC_OUTDATA, 0);
- WR_ADR (SC_ICMD, SC_A_RST); /* assert RST on SCSI bus */
- i = 200; /* wait 25 usec */
- while (i--);
- WR_ADR (SC_ICMD, 0); /* deassert RST, get off bus */
- sc_reset_done = 1;
-}
-
-/*===========================================================================*
- * sc_wait_bus_free *
- *===========================================================================*/
-PRIVATE int
-sc_wait_bus_free()
-{
- int i = MAX_WAIT;
- volatile int j;
-
- BB_DEBUG (("sc_wait_bus_free()\n"));
-
- while (i--) {
- /* Must be clear for 2 usec, so read twice */
- if (RD_ADR (SC_STAT1) & (SC_S_BSY | SC_S_SEL)) continue;
- for (j = 0; j < 25; ++j);
- if (RD_ADR (SC_STAT1) & (SC_S_BSY | SC_S_SEL)) continue;
- return OK;
- }
- sc_reset_done = 0;
- return NOT_OK;
-}
-
-/*===========================================================================*
- * sc_select *
- *===========================================================================*/
-/* This duplicates much of the work that the interrupt routine would do on a
- * phase mismatch and, in fact, the original plan was to just do the select,
- * let a phase mismatch occur, and let the interrupt routine do the rest.
- * That didn't work because the 5380 did not reliably generate the phase
- * mismatch interrupt after selection.
- */
-PRIVATE int
-sc_select(adr)
-long adr;
-{
- int i, stat1;
- long new_ptr;
-
- BB_DEBUG (("sc_select(%d)\n", adr));
-
- CLEAR_INTR();
- WR_ADR (SC_OUTDATA, adr); /* SCSI bus address */
- WR_ADR (SC_ICMD, SC_A_SEL | SC_ENABLE_DB);
- for (i = 0;; ++i) { /* wait for target to assert SEL */
- if (CHECK_INTR() == 0)
- continue;
- stat1 = RD_ADR (SC_STAT1);
- if (stat1 & SC_S_BSY) break; /* select successful */
- if (i > MAX_WAIT) { /* timeout */
- printf("SCSI: SELECT timeout\n");
- sc_reset();
- return NOT_OK;
- }
- }
- CLEAR_INTR();
- WR_ADR (SC_ICMD, 0); /* clear SEL, disable data out */
- WR_ADR (SC_OUTDATA, 0);
- for (i = 0;; ++i) { /* wait for target to assert REQ */
- if (CHECK_INTR() == 0)
- continue;
- if (stat1 & SC_S_REQ) break; /* target requesting transfer */
- if (i > MAX_WAIT) { /* timeout */
- printf("SCSI: REQ timeout\n");
- sc_reset();
- return NOT_OK;
- }
- stat1 = RD_ADR (SC_STAT1);
- }
- sc_cur_phase = (stat1 >> 2) & 7; /* get new phase from controller */
- if (sc_cur_phase != PH_CMD) {
- printf("SCSI: bad phase = %d\n", sc_cur_phase);
- sc_reset();
- return NOT_OK;
- }
- new_ptr = sc_ptrs->ptr[PH_CMD];
- if (new_ptr == 0) {
- printf("SCSI: NULL command pointer\n");
- sc_reset();
- return NOT_OK;
- }
- sc_accept_int = 1;
- sc_dma_setup (DISK_WRITE, new_ptr);
- CLEAR_INTR();
- WR_ADR (SC_TCMD, PH_CMD);
- WR_ADR (SC_ICMD, SC_ENABLE_DB);
- WR_ADR (SC_MODE, SC_M_BSY | SC_M_DMA);
- WR_ADR (SC_START_SEND, 0);
- return OK;
-}
-
-/*===========================================================================*
- * scsi_interrupt *
- *===========================================================================*/
-/* SCSI interrupt handler.
- */
-PUBLIC
-int
-scsi_interrupt()
-{
- unsigned char stat2, dummy;
- long new_ptr;
- int ret = ISR_NOTDONE;
-
- BB_DEBUG (("scsi_interrupt()\n"));
-
- stat2 = RD_ADR (SC_STAT2); /* get status before clearing request */
-
-# ifdef DEBUG /* debugging log of interrupts */
- sc_log_head->stat1 = RD_ADR (SC_STAT1);
- sc_log_head->stat2 = stat2;
- if (++sc_log_head >= sc_log + SC_LOG_LEN) sc_log_head = sc_log;
- sc_log_head->stat1 = sc_log_head->stat2 = 0xff;
-# endif
-
- for (;;) {
- dummy = RD_ADR (SC_RESETIP); /* clear interrupt request */
- if (!sc_accept_int || /* return if spurious interrupt */
- (!sc_watchdog_error &&
- (stat2 & SC_S_BSYERR) == 0 && (stat2 & SC_S_PHASE) != 0))
- {
-# ifdef DEBUG
- ++sc_spurious_int;
-# endif
- printf ("sc_spurious_int\n");
- return ret;
- }
- RD_ADR (SC_MODE) &= ~SC_M_DMA; /* clear DMA mode */
- WR_ADR (SC_ICMD, 0); /* disable data bus */
- if (sc_cur_phase != PH_NONE) { /* if did DMA, save the new pointer */
- new_ptr = sc_dma_adr; /* fetch new pointer from DMA cntlr */
- if (sc_cur_phase == PH_IMSG && /* have message? */
- new_ptr != sc_ptrs->ptr[PH_IMSG]) sc_have_msg = 1;
- sc_ptrs->ptr[sc_cur_phase] = /* save pointer */
- new_ptr;
- }
- if (sc_watchdog_error) ret = ISR_TIMEOUT;
- else if (stat2 & SC_S_BSYERR) { /* target deasserted BSY? */
- printf ("target deasserted BSY?\n");
- if (sc_have_msg) ret = ISR_OK;
- else ret = ISR_BSYERR;
- } else if (!(stat2 & SC_S_PHASE)) {/* if phase mismatch, setup new phase */
- printf ("phase mismatch\n");
- sc_cur_phase = /* get new phase from controller */
- (RD_ADR (SC_STAT1) >> 2) & 7;
- new_ptr = sc_ptrs->ptr[sc_cur_phase];
- if (new_ptr == 0) ret = ISR_BADPHASE;
- else {
- WR_ADR (SC_TCMD, sc_cur_phase); /* write new phase into TCMD */
- if (PH_IN (sc_cur_phase)) { /* set DMA controller */
- sc_dma_setup (DISK_READ, new_ptr);
- RD_ADR (SC_MODE) |= SC_M_DMA;
- CLEAR_INTR();
- WR_ADR (SC_START_RCV, 0); /* tell SCSI to start DMA */
- } else {
- sc_dma_setup (DISK_WRITE, new_ptr);
- RD_ADR (SC_MODE) |= SC_M_DMA;
- WR_ADR (SC_ICMD, SC_ENABLE_DB);
- CLEAR_INTR();
- WR_ADR (SC_START_SEND, 0);
- }
- }
- } else ret = ISR_RSTERR;
- if (ret != ISR_NOTDONE) { /* if done, send message to task */
- sc_watchdog_error = 0;
- sc_accept_int = 0;
- WR_ADR (SC_MODE, 0); /* clear monbsy, dma */
- break; /* reti re-enables ints */
- }
- if (0 == ((stat2 = /* check for another interrupt */
- RD_ADR (SC_STAT2)) & SC_S_IRQ))
- {
- break;
- }
- }
- return ret;
-}
-
-/*===========================================================================*
- * sc_dma_setup *
- *===========================================================================*/
-/* Fake DMA setup. Just store pointers and direction in global variables.
- *
- * The pseudo-DMA is subtler than it looks because of the cache.
- *
- * 1) When accessing I/O devices through a cache, some mechanism is
- * necessary to ensure you access the device rather than the cache.
- * On the 32532, the IODEC signal is supposed to be asserted for I/O
- * addresses to accomplish this. However, a bug makes this much
- * slower than necessary and severely hurts pseudo-DMA performance.
- * Hence, IODEC is not asserted for the SCSI DMA port.
- *
- * 2) Because of (1), we must devise our own method of forcing the
- * SCSI DMA port to be read. 0x8000000 addresses have been decoded
- * to all access this port. By always using new addresses to access
- * the DMA port (wrapping only after reading MAX_CACHE bytes), we
- * force cache misses and, hence, device reads. Since the cache
- * is write-through, we do not need to worry about writes.
- *
- * 3) It is possible to miss the last few bytes of a transfer if
- * bus transfer size is not considered. The loop in sc_receive()
- * transfers data until the interrupt signal is asserted. If
- * bytes are transferred, the attempt to move the first byte of a
- * double word causes the whole word to be read into the cache.
- * Then the byte is transferred. If reading the double word
- * completed the SCSI transfer, then the loop exits since
- * interrupt is asserted. However, the last few bytes have only
- * been moved into the cache -- they have not been moved to the
- * DMA destination.
- *
- * 4) It is also possible to miss the first few bytes of a transfer.
- * If the address used to access pseudo-dma port is not double word
- * aligned, the whole double word is read into the cache, and then
- * data is moved from the middle of the word (i.e. something other
- * than the first bytes read from the SCSI controller) by the
- * pseudo-dma loop in sc_receive().
- */
-sc_dma_setup (dir, adr)
-int dir;
-long adr;
-{
- BB_DEBUG (("sc_dma_setup(%d, %d)\n", dir, adr));
-
- CLEAR_INTR();
- /* if (sc_dma_port > SC_DMA + MAX_CACHE) */
- sc_dma_port = SC_DMA;
- sc_dma_dir = dir;
- sc_dma_adr = adr;
-}
-
-/*===========================================================================*
- * sc_receive *
- *===========================================================================*/
-/* Replacement for Minix receive(), which waits for a message. This code
- * spins, waiting for data to transfer or interrupt requests to handle.
- * See sc_dma_setup for details.
- */
-int
-sc_receive()
-{
- int stat2, isr_ret;
- int i, c;
-
- BB_DEBUG (("sc_receive()\n"));
-
- /*
- * check the interrupt-flag and wait if it reappears...
- */
- c = *ka410_intreq;
- printf ("begin: %x/%x ", c, *ka410_intreq);
- for (i=0; i<100; i++) {
- if ((c = *ka410_intreq) & INTR_SC)
- break;
- printf (" %x ", c);
- }
- if (i==100)
- printf ("timeout in sc_receive.\n");
-
-#if 1
- for (;;) {
- stat2 = RD_ADR (SC_STAT2);
- if (stat2 & SC_S_IRQ) {
- if (ISR_NOTDONE != (isr_ret = scsi_interrupt())) break;
- } else if (stat2 & SC_S_DRQ) { /* test really not necessary on pc532 */
- if (sc_dma_dir == DISK_READ)
- *((long *)sc_dma_adr)++ = *((volatile long *)sc_dma_port)++;
- else *((volatile long *)sc_dma_port)++ = *((long *)sc_dma_adr)++;
- }
- }
-#endif
- printf ("isr_ret: %d (ISR_NOTDONE: %d)\n", isr_ret, ISR_NOTDONE);
- return isr_ret;
-}
-
-/*===========================================================================*
- * scCtlrSelect
- *===========================================================================*/
-/* Select a SCSI device.
- */
-scCtlrSelect (ctlr)
-int ctlr;
-{
- BB_DEBUG (("scCtlrSelect()\n"));
-#if 0
- RD_ADR (ICU_IO) &= ~ICU_SCSI_BIT; /* i/o, not port */
- RD_ADR (ICU_DIR) &= ~ICU_SCSI_BIT; /* output */
- if (ctlr == DP8490)
- RD_ADR (ICU_DATA) &= ~ICU_SCSI_BIT; /* select = 0 for 8490 */
- else
- RD_ADR (ICU_DATA) |= ICU_SCSI_BIT; /* select = 1 for AIC6250 */
-#endif
-}
diff --git a/sys/arch/vax/boot/sd.c b/sys/arch/vax/boot/sd.c
deleted file mode 100644
index 72b5318cecc..00000000000
--- a/sys/arch/vax/boot/sd.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/* $OpenBSD: sd.c,v 1.3 1998/05/13 07:30:27 niklas Exp $ */
-/* $NetBSD: sd.c,v 1.1 1996/08/02 11:22:36 ragge Exp $ */
-
-/*
- * Copyright (c) 1988 University of Utah.
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Van Jacobson of Lawrence Berkeley Laboratory and the Systems
- * Programming Group of the University of Utah Computer Science Department.
- *
- * 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: Utah $Hdr: sd.c 1.9 92/12/21$
- *
- * @(#)sd.c 8.1 (Berkeley) 6/10/93
- */
-
-/*
- * SCSI CCS disk driver
- */
-
-#include <sys/param.h>
-#include <sys/disklabel.h>
-#include "stand.h"
-#include "samachdep.h"
-
-#define SC_DEBUG 1 /* bertram */
-#define SD_DEBUG 1 /* bertram */
-
-/*----------------------------------------------------------------------*/
-int
-scsialive(int ctlr)
-{
- return 1; /* controller always alive! */
-}
-
-/* call functions in scsi_hi.c */
-#include "so.h"
-
-int
-scsi_tt_read(ctlr, slave, buf, len, blk, nblk)
- int ctlr, slave;
- u_char *buf;
- u_int len;
- daddr_t blk;
- u_int nblk;
-{
-#ifdef SC_DEBUG
-printf("scsi_tt_read: ctlr %d, slave %d, len %d, blk %d, nblk %d\n",
- ctlr, slave, len, blk, nblk );
-#endif
- if (sc_rdwt(DISK_READ, blk, buf, nblk, 1<<slave, 0) == 0)
- return 0;
- return -2;
-}
-
-int
-scsi_tt_write(ctlr, slave, buf, len, blk, nblk)
- int ctlr, slave;
- u_char *buf;
- u_int len;
- daddr_t blk;
- u_int nblk;
-{
-#ifdef SC_DEBUG
-printf("scsi_tt_write: ctlr %d, slave %d, len %d, blk %d, nblk %d\n",
- ctlr, slave, len, blk, nblk );
-#endif
-#if 0
- if (sc_rdwt(DISK_WRITE, blk, buf, nblk, 1<<slave, 0) == 0)
- return 0;
-#endif
- return -2;
-}
-
-/*----------------------------------------------------------------------*/
-
-struct sd_softc {
- int sc_ctlr;
- int sc_unit;
- int sc_part;
- char sc_retry;
- char sc_alive;
- struct disklabel sc_label;
-} sd_softc[NSCSI][NSD];
-
-#ifdef SD_DEBUG
-int debug = SD_DEBUG;
-#endif
-
-#define SDRETRY 2
-
-sdinit(ctlr, unit)
- int ctlr, unit;
-{
- register struct sd_softc *ss = &sd_softc[ctlr][unit];
-
- /* HP version does test_unit_ready
- * followed by read_capacity to get blocksize
- */
- ss->sc_alive = 1;
- return (1);
-}
-
-sdreset(ctlr, unit)
- int ctlr, unit;
-{
-}
-
-char io_buf[DEV_BSIZE];
-
-sdgetinfo(ss)
- register struct sd_softc *ss;
-{
- register struct disklabel *lp;
- char *msg, *getdisklabel();
- int sdstrategy(), i, err;
-
- lp = &sd_softc[ss->sc_ctlr][ss->sc_unit].sc_label;
- bzero((caddr_t)lp, sizeof *lp);
- lp->d_secsize = DEV_BSIZE;
- lp->d_secpercyl = 1;
- lp->d_npartitions = MAXPARTITIONS;
- lp->d_partitions[ss->sc_part].p_offset = 0;
- lp->d_partitions[ss->sc_part].p_size = 0x7fffffff;
-
- if (err = sdstrategy(ss, F_READ,
- LABELSECTOR, DEV_BSIZE, io_buf, &i) < 0) {
- printf("sdgetinfo: sdstrategy error %d\n", err);
- return 0;
- }
-
- msg = getdisklabel(io_buf, lp);
- if (msg) {
- printf("sd(%d,%d,%d): %s\n",
- ss->sc_ctlr, ss->sc_unit, ss->sc_part, msg);
- return 0;
- }
- return(1);
-}
-
-sdopen(f, ctlr, unit, part)
- struct open_file *f;
- int ctlr, unit, part;
-{
- register struct sd_softc *ss;
- register struct disklabel *lp;
-
-#ifdef SD_DEBUG
- if (debug)
- printf("sdopen: ctlr=%d unit=%d part=%d\n",
- ctlr, unit, part);
-#endif
-
- if (ctlr >= NSCSI || !scsialive(ctlr))
- return (EADAPT);
- if (unit >= NSD)
- return (ECTLR);
- ss = &sd_softc[ctlr][unit]; /* XXX alloc()? keep pointers? */
- ss->sc_part = part;
- ss->sc_unit = unit;
- ss->sc_ctlr = ctlr;
- if (!ss->sc_alive) {
- if (!sdinit(ctlr, unit))
- return (ENXIO);
- if (!sdgetinfo(ss))
- return (ERDLAB);
- }
- lp = &sd_softc[ctlr][unit].sc_label;
- if (part >= lp->d_npartitions || lp->d_partitions[part].p_size == 0)
- return (EPART);
-
- f->f_devdata = (void *)ss;
- return (0);
-}
-
-int
-sdstrategy(ss, func, dblk, size, buf, rsize)
- register struct sd_softc *ss;
- int func;
- daddr_t dblk; /* block number */
- u_int size; /* request size in bytes */
- char *buf;
- u_int *rsize; /* out: bytes transferred */
-{
- register int ctlr = ss->sc_ctlr;
- register int unit = ss->sc_unit;
- register int part = ss->sc_part;
- register struct partition *pp = &ss->sc_label.d_partitions[part];
- u_int nblk = size >> DEV_BSHIFT;
- u_int blk = dblk + pp->p_offset;
- char stat;
-
- if (size == 0)
- return(0);
-
- ss->sc_retry = 0;
-
-#ifdef SD_DEBUG
- if (debug)
- printf("sdstrategy(%d,%d): size=%d blk=%d nblk=%d\n",
- ctlr, unit, size, blk, nblk);
-#endif
-
-retry:
- if (func == F_READ)
- stat = scsi_tt_read(ctlr, unit, buf, size, blk, nblk);
- else
- stat = scsi_tt_write(ctlr, unit, buf, size, blk, nblk);
- if (stat) {
- printf("sd(%d,%d,%d): block=%x, error=0x%x\n",
- ctlr, unit, ss->sc_part, blk, stat);
- if (++ss->sc_retry > SDRETRY)
- return(EIO);
- goto retry;
- }
- *rsize = size;
-
- return(0);
-}
diff --git a/sys/arch/vax/boot/so.h b/sys/arch/vax/boot/so.h
deleted file mode 100644
index 0780371fe47..00000000000
--- a/sys/arch/vax/boot/so.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* $OpenBSD: so.h,v 1.2 1997/05/29 00:04:27 niklas Exp $ */
-/* $NetBSD: so.h,v 1.1 1996/08/02 11:22:41 ragge Exp $ */
-
-#ifndef _SO_H_INCLUDE
-#define _SO_H_INCLUDE
-
-/* Definitions for standalone I/O lib */
-
-/* #define SCSI_POLLED 0x200C0080 */
-#define SCSI_DMA 0x200D0000
-
-/* Which SCSI device to use by default */
-#define DEFAULT_SCSI_ADR 1
-#define DEFAULT_SCSI_LUN 0
-
-/* Low level scsi operation codes */
-#define DISK_READ 3
-#define DISK_WRITE 4
-
-/* The size of a disk block */
-#define DBLKSIZE 512
-
-/* Some disk address that will never be used */
-#define INSANE_BADDR 0x800000
-
-struct scsi_args {
- long ptr [8];
-};
-
-#ifndef NULL
-#define NULL 0L
-#endif
-
-/*
- * The next macro defines where the "break" area in memory ends for
- * malloc() and friends. The area between edata and this address will
- * then be reserved and should not be used for anything else (or you will
- * no doubt have big problems). Depending on where your program's end-of-data
- * is, you may wish to locate this in such a way as to usurp a minimum
- * amount of memory.
- */
-#define BREAK_END_ADDR ((char *)0x400000) /* to 4MB */
-
-/* Selectivly enable inline functions */
-#ifndef NO_INLINE
-#define Inline inline
-#else
-#define Inline
-#endif
-
-extern void fatal(), warn();
-extern long ulimit(int, long);
-extern int brk(char *);
-extern char *sbrk(int);
-
-extern int sc_rdwt();
-
-#endif /* _SO_H_INCLUDE */
diff --git a/sys/arch/vax/boot/string.h b/sys/arch/vax/boot/string.h
deleted file mode 100644
index 13f47b6cfb3..00000000000
--- a/sys/arch/vax/boot/string.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/* $OpenBSD: string.h,v 1.1 1998/05/11 07:38:23 niklas Exp $ */
-
-#define NULL ((char *)0)
diff --git a/sys/arch/vax/boot/xxboot/Makefile b/sys/arch/vax/boot/xxboot/Makefile
new file mode 100644
index 00000000000..22bef4f3d13
--- /dev/null
+++ b/sys/arch/vax/boot/xxboot/Makefile
@@ -0,0 +1,36 @@
+# $OpenBSD: Makefile,v 1.1 2000/04/27 02:26:27 bjc Exp $
+# $NetBSD: Makefile,v 1.2 1999/10/23 14:40:39 ragge Exp $
+
+S=../../../..
+
+PROG= xxboot
+LINKS= ${BINDIR}/xxboot ${BINDIR}/raboot
+LINKS+= ${BINDIR}/xxboot ${BINDIR}/rdboot
+LINKS+= ${BINDIR}/xxboot ${BINDIR}/sdboot
+LINKS+= ${BINDIR}/xxboot ${BINDIR}/hpboot
+
+SRCS= start.s bootxx.c romread.s urem.s udiv.s str.s
+
+STRIPFLAG=
+CPPFLAGS+=-D_STANDALONE -DLIBSA_NO_FD_CHECKING -DLIBSA_NO_RAW_ACCESS \
+ -DLIBSA_NO_TWIDDLE -DLIBSA_SINGLE_DEVICE=rom \
+ -DLIBSA_SINGLE_FILESYSTEM=ufs
+BINDIR= /usr/mdec
+NOMAN= 1
+
+SA_AS= library
+.include "${S}/lib/libsa/Makefile.inc"
+LIBSA= ${SALIB}
+
+${PROG}: ${OBJS} ${LIBSA}
+ ld -N -Ttext 100000 -o a.out ${OBJS} ${LIBSA}
+ strip a.out
+ size a.out
+ dd if=a.out of=${PROG} bs=32 skip=1
+# rm -f a.out
+
+clean::
+ rm -f a.out [Ee]rrs mklog core *.core ${PROG} ${OBJS} ${LOBJS} \
+ ${CLEANFILES}
+
+.include <bsd.prog.mk>
diff --git a/sys/arch/vax/boot/bootxx.c b/sys/arch/vax/boot/xxboot/bootxx.c
index 5cdc2246964..3a1d48fab9f 100644
--- a/sys/arch/vax/boot/bootxx.c
+++ b/sys/arch/vax/boot/xxboot/bootxx.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: bootxx.c,v 1.8 1998/05/13 07:30:21 niklas Exp $ */
-/* $NetBSD: bootxx.c,v 1.11 1997/06/08 17:49:17 ragge Exp $ */
+/* $OpenBSD: bootxx.c,v 1.1 2000/04/27 02:26:27 bjc Exp $ */
+/* $NetBSD: bootxx.c,v 1.2 1999/10/23 14:40:38 ragge Exp $ */
/*-
* Copyright (c) 1982, 1986 The Regents of the University of California.
* All rights reserved.
@@ -54,30 +54,39 @@
#define NRSP 1 /* Kludge */
#define NCMD 1 /* Kludge */
-#include "../uba/ubareg.h"
-#include "../uba/udareg.h"
-
#include "../mscp/mscp.h"
#include "../mscp/mscpreg.h"
-#include "data.h"
#include "vaxstand.h"
-#include <sys/exec.h>
-int romstrategy(), romopen();
-int command(int, int);
+int romstrategy __P((void *, int, daddr_t, size_t, void *, size_t *));
+
+struct fs_ops file_system[] = {
+ { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat }
+};
+
+struct devsw devsw[] = {
+ SADEV("rom", romstrategy, nullsys, nullsys, noioctl),
+};
+
+int nfsys = (sizeof(file_system) / sizeof(struct fs_ops));
+
+int command __P((int cmd, int arg));
/*
* Boot program... argume passed in r10 and r11 determine whether boot
* stops to ask for system name and which device boot comes from.
*/
-volatile u_int devtype, bootdev;
+volatile dev_t devtype, bootdev;
unsigned opendev, boothowto, bootset, memsz;
-extern unsigned *bootregs;
-extern struct rpb *rpb;
+struct open_file file;
+
+unsigned *bootregs;
+struct rpb *rpb;
+int vax_cputype;
/*
* The boot block are used by 11/750, 8200, MicroVAX II/III, VS2000,
@@ -87,13 +96,16 @@ Xmain()
{
int io;
char *scbb;
- char *new;
+ char *new, *bqo;
char *hej = "/boot";
- switch (vax_cputype) {
+ vax_cputype = (mfpr(PR_SID) >> 24) & 0xFF;
- case VAX_TYP_UV2:
- case VAX_TYP_CVAX:
+ /*
+ */
+ switch (vax_cputype) {
+ case VAX_TYP_UV2:
+ case VAX_TYP_CVAX:
case VAX_TYP_RIGEL:
case VAX_TYP_NVAX:
case VAX_TYP_SOC:
@@ -109,71 +121,24 @@ Xmain()
bootregs[11] = (int)rpb;
bootdev = rpb->devtyp;
memsz = rpb->pfncnt << 9;
-
- break;
+ break;
case VAX_8200:
case VAX_750:
bootdev = bootregs[10];
memsz = 0;
-
- break;
+ break;
default:
- printf("unknown cpu type %d\nRegister dump:\n", vax_cputype);
- for (io = 0; io < 16; io++)
- printf("r%d 0x%x\n", io, bootregs[io]);
asm("halt");
- }
+ }
bootset = getbootdev();
- printf("\nhowto 0x%x, bdev 0x%x, booting...", boothowto, bootdev);
io = open(hej, 0);
- if (io >= 0 && io < SOPEN_MAX) {
- copyunix(io);
- } else {
- printf("Boot failed, saerrno %d\n", errno);
- }
-}
-
-/* ARGSUSED */
-copyunix(aio)
-{
- struct exec x;
- register int io = aio, i;
- char *addr;
-
- i = read(io, (char *) &x, sizeof(x));
- if (i != sizeof(x) || N_BADMAG(x)) {
- printf("Bad format\n");
- return;
- }
-
- if (N_GETMAGIC(x) == ZMAGIC && lseek(io, N_TXTADDR(x), SEEK_SET) == -1)
- goto shread;
- if (read(io, (char *) 0x10000, x.a_text) != x.a_text)
- goto shread;
- addr = (char *) x.a_text;
- if (N_GETMAGIC(x) == ZMAGIC || N_GETMAGIC(x) == NMAGIC)
- while ((int) addr & CLOFSET)
- *addr++ = 0;
-
- if (read(io, addr + 0x10000, x.a_data) != x.a_data)
- goto shread;
- addr += x.a_data;
- bcopy((void *) 0x10000, 0, (int) addr);
-
- for (i = 0; i < x.a_bss; i++)
- *addr++ = 0;
- for (i = 0; i < 128 * 512; i++) /* slop */
- *addr++ = 0;
- printf("done. (%d+%d)\n", x.a_text + x.a_data, x.a_bss);
- hoppabort(x.a_entry, boothowto, bootset);
- (*((int (*) ()) x.a_entry)) ();
- return;
-shread:
- printf("Short read\n");
- return;
+ read(io, (void *)0x10000, 0x10000);
+ bcopy((void *) 0x10000, 0, 0xffff);
+ hoppabort(32, boothowto, bootset);
+ asm("halt");
}
getbootdev()
@@ -185,22 +150,19 @@ getbootdev()
switch (vax_cputype) {
case VAX_TYP_UV2:
case VAX_TYP_CVAX:
- adaptor = 0;
- controller = ((rpb->csrphy & 017777) == 0xDC)?1:0;
- unit = rpb->unit; /* DUC, DUD? */
-
- break;
-
case VAX_TYP_RIGEL:
- unit = rpb->unit;
- if (unit > 99)
- unit /= 100; /* DKB300 is target 3 */
+ if (rpb->devtyp == BDEV_SD) {
+ unit = rpb->unit / 100;
+ controller = (rpb->csrphy & 0x100 ? 1 : 0);
+ } else {
+ controller = ((rpb->csrphy & 017777) == 0xDC)?1:0;
+ unit = rpb->unit; /* DUC, DUD? */
+ }
break;
-
case VAX_TYP_8SS:
case VAX_TYP_750:
- controller = 0; /* XXX Actually massbuss can be on 3 ctlr's */
+ controller = bootregs[1];
unit = bootregs[3];
break;
}
@@ -218,43 +180,63 @@ getbootdev()
case BDEV_TK: /* TK50 boot */
case BDEV_CNSL: /* Console storage boot */
case BDEV_RD: /* RD/RX on HDC9224 (MV2000) */
- controller = 0; /* They are always on ctlr 0 */
- break;
-
case BDEV_ST: /* SCSI-tape on NCR5380 (MV2000) */
case BDEV_SD: /* SCSI-disk on NCR5380 (3100/76) */
- /*
- * No standalone routines for SCSI support yet.
- * Use rom-routines instead!
- */
+ break;
+
+ case BDEV_KDB: /* DSA disk on KDB50 (VAXBI VAXen) */
+ bootdev = (bootdev & ~B_TYPEMASK) | BDEV_UDA;
break;
default:
- printf("Unsupported boot device %d, trying anyway.\n", bootdev);
boothowto |= (RB_SINGLE | RB_ASKNAME);
}
return MAKEBOOTDEV(bootdev, adaptor, controller, unit, partition);
}
-struct devsw devsw[] = {
- SADEV("rom", romstrategy,nullsys,nullsys, noioctl),
-};
+/*
+ * Write an extremely limited version of a (us)tar filesystem, suitable
+ * for loading secondary-stage boot loader.
+ * - Can only load file "boot".
+ * - Must be the first file on tape.
+ */
+int tar_open(char *path, struct open_file *f);
+ssize_t tar_read(struct open_file *f, void *buf, size_t size, size_t *resid);
-int ndevs = (sizeof(devsw) / sizeof(devsw[0]));
+int
+tar_open(path, f)
+ char *path;
+ struct open_file *f;
+{
+ char *buf = alloc(512);
-struct fs_ops file_system[] = {
- {ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat}
-};
+ bzero(buf, 512);
+ romstrategy(0, 0, 8192, 512, buf, 0);
+ if (bcmp(buf, "boot", 5) || bcmp(&buf[257], "ustar", 5))
+ return EINVAL; /* Not a ustarfs with "boot" first */
+ return 0;
+}
-int nfsys = (sizeof(file_system) / sizeof(struct fs_ops));
+ssize_t
+tar_read(f, buf, size, resid)
+ struct open_file *f;
+ void *buf;
+ size_t size;
+ size_t *resid;
+{
+ romstrategy(0, 0, (8192+512), size, buf, 0);
+ *resid = size;
+}
struct disklabel lp;
int part_off = 0; /* offset into partition holding /boot */
+char io_buf[DEV_BSIZE];
volatile struct uda {
struct mscp_1ca uda_ca; /* communications area */
struct mscp uda_rsp; /* response packets */
struct mscp uda_cmd; /* command packets */
} uda;
+struct udadevice {u_short udaip;u_short udasa;};
volatile struct udadevice *csr;
devopen(f, fname, file)
@@ -262,6 +244,7 @@ devopen(f, fname, file)
const char *fname;
char **file;
{
+ extern char start;
char *msg;
int i, err, off;
char line[64];
@@ -306,11 +289,7 @@ devopen(f, fname, file)
* Actually disklabel is only needed when using hp disks,
* but it doesn't hurt to always get it.
*/
- if ((bootdev != BDEV_TK) && (bootdev != BDEV_CNSL)) {
- msg = getdisklabel((void *)LABELOFFSET + RELOC, &lp);
- if (msg)
- printf("getdisklabel: %s\n", msg);
- }
+ getdisklabel(LABELOFFSET + &start, &lp);
return 0;
}
@@ -336,8 +315,9 @@ romstrategy(sc, func, dblk, size, buf, rsize)
void *sc;
int func;
daddr_t dblk;
- char *buf;
- int size, *rsize;
+ size_t size;
+ void *buf;
+ size_t *rsize;
{
int i;
int block = dblk;
@@ -395,8 +375,8 @@ romstrategy(sc, func, dblk, size, buf, rsize)
case VAX_750:
if (bootdev != BDEV_HP) {
while (size > 0) {
- while ((read750(block, bootregs) & 0x01) == 0)
- printf("Retrying read bn# %d\n", block);
+ while ((read750(block, bootregs) & 0x01) == 0){
+ }
bcopy(0, buf, 512);
size -= 512;
buf += 512;
@@ -407,7 +387,8 @@ romstrategy(sc, func, dblk, size, buf, rsize)
break;
}
- *rsize = nsize;
+ if (rsize)
+ *rsize = nsize;
return 0;
}
@@ -439,3 +420,29 @@ hpread(block, size, buf)
}
return 0;
}
+
+extern char end[];
+static char *top = (char*)end;
+
+void *
+alloc(size)
+ unsigned size;
+{
+ void *ut = top;
+ top += size;
+ return ut;
+}
+
+void
+free(ptr, size)
+ void *ptr;
+ unsigned size;
+{
+}
+
+int
+romclose(f)
+ struct open_file *f;
+{
+ return 0;
+}
diff --git a/sys/arch/vax/boot/start.s b/sys/arch/vax/boot/xxboot/start.s
index 61f75d87ba4..d20753cf901 100644
--- a/sys/arch/vax/boot/start.s
+++ b/sys/arch/vax/boot/xxboot/start.s
@@ -1,5 +1,5 @@
-/* $OpenBSD: start.s,v 1.6 1998/02/03 11:48:29 maja Exp $ */
-/* $NetBSD: start.s,v 1.10 1997/03/22 12:47:32 ragge Exp $ */
+/* $OpenBSD: start.s,v 1.1 2000/04/27 02:26:27 bjc Exp $ */
+/* $NetBSD: start.s,v 1.2 1999/10/23 14:40:38 ragge Exp $ */
/*
* Copyright (c) 1995 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -173,7 +173,6 @@ start_all:
relocated: # now relocation is done !!!
movl sp, _bootregs
movl ap, _boothowto
- calls $0, _setup
calls $0, _Xmain # call Xmain (gcc workaround)which is
halt # not intended to return ...
@@ -189,3 +188,13 @@ ENTRY(hoppabort, 0)
jmp 2(r6)
# calls $0,(r6)
halt
+
+# A bunch of functions unwanted in boot blocks.
+ENTRY(getchar, 0)
+ halt
+
+ENTRY(putchar, 0)
+ ret
+
+ENTRY(panic, 0)
+ halt
diff --git a/sys/arch/vax/stand/Makefile b/sys/arch/vax/stand/Makefile
index 4ff631c2156..50a4c81d7c4 100644
--- a/sys/arch/vax/stand/Makefile
+++ b/sys/arch/vax/stand/Makefile
@@ -1,115 +1,6 @@
-# $OpenBSD: Makefile,v 1.10 1998/05/14 13:50:35 niklas Exp $
-# $NetBSD: Makefile,v 1.14 1997/06/29 21:30:09 ragge Exp $
+# $OpenBSD: Makefile,v 1.11 2000/04/27 02:26:18 bjc Exp $
+# $NetBSD: Makefile,v 1.21 1999/03/06 16:36:04 ragge Exp $
#
-S!= cd ${.CURDIR}/../../..; pwd
-OBJ!= pwd
-
-AR?= ar
-AS?= as
-CC?= cc
-LD?= ld
-RANLIB?=ranlib
-SIZE?= size
-STRIP?= strip
-
-BINOWN= bin
-BINGRP= bin
-
-INCPATH=-nostdinc -I${OBJ} -I${.CURDIR} -I${.CURDIR}/.. -I${S} -I${S}/lib/libsa
-RELOC= 100000
-XXRPB= 0F4240
-CFLAGS+=-O ${INCPATH} -D_STANDALONE -DRELOC=0x${RELOC} -DXXRPB=0x$(XXRPB)
-
-DEVS= autoconf.o hp.o ra.o tmscp.o ctu.o mfm.o rom.o romread.o \
- scsi_low.o scsi_hi.o sd.o netio.o if_le.o
-
-SAREL=
-.include "$S/lib/libsa/Makefile.inc"
-LIBS= -L. -Llib/sa -lsvax -lsa -lsvax
-
-
-SVAX= consio.o urem.o udiv.o str.o
-
-all: ${LIBSA} xxboot boot copy edlabel
-
-includes:
-
-libsvax.a: ${SVAX}
- ${AR} crv $@ $?
- ${RANLIB} $@
-
-urem.o: ../vax/urem.s
- ${CC} -x assembler-with-cpp -E ${.CURDIR}/../vax/urem.s | \
- ${AS} -o urem.o
-
-udiv.o: ../vax/udiv.s
- ${CC} -x assembler-with-cpp -E ${.CURDIR}/../vax/udiv.s | \
- ${AS} -o udiv.o
-
-str.o: str.s
- ${CC} -x assembler-with-cpp -E ${.CURDIR}/str.s | ${AS} -o str.o
-
-# startups
-
-start.o: start.s
- ${CC} ${CFLAGS} -x assembler-with-cpp -E ${.CURDIR}/start.s | \
- ${AS} -o start.o
-
-srt0.o: srt0.s
- ${CC} -x assembler-with-cpp -E ${.CURDIR}/srt0.s | ${AS} -o srt0.o
-
-#
-
-xxboot: start.o bootxx.o romread.o libsvax.a ${SALIB}
- ${LD} -N -Ttext ${RELOC} -o a.out start.o bootxx.o romread.o ${LIBS}
- @${STRIP} a.out
- @${SIZE} a.out
- @dd if=a.out of=xxboot bs=32 skip=1
- @rm -f a.out
-
-boot: boot.o srt0.o devopen.o conf.o ${DEVS} libsvax.a ${SALIB}
- @date '+_vers: .globl _vers; .asciz ">> OpenBSD/vax boot [%y%m%d %H:%M] <<"' | ${AS} -o vers.o
- ${LD} -N -Ttext ${RELOC} -e start0 -o $@ srt0.o devopen.o boot.o \
- conf.o ${DEVS} ${LIBS} vers.o
- @${STRIP} boot
- @${SIZE} boot
-
-edlabel: edlabel.o srt0.o devopen.o conf.o ${DEVS} libsvax.a
- @date '+_vers: .globl _vers; .asciz ">> OpenBSD/vax boot [%y%m%d %H:%M] <<"' | ${AS} -o vers.o
- ${LD} -N -Ttext ${RELOC} -e start0 -o $@ srt0.o devopen.o edlabel.o\
- conf.o ${DEVS} ${LIBS} vers.o
- @${STRIP} edlabel
- @${SIZE} edlabel
-
-copy: copy.o srt0.o devopen.o conf.o ${DEVS} libsvax.a
- @date '+_vers: .globl _vers; .asciz ">> OpenBSD/vax boot [%y%m%d %H:%M] <<"' | ${AS} -o vers.o
- ${LD} -N -Ttext ${RELOC} -e start0 -o $@ srt0.o devopen.o copy.o \
- conf.o ${DEVS} ${LIBS} vers.o
- @${STRIP} copy
- @${SIZE} copy
-
-#
-
-romread.o: romread.s
- ${CC} -x assembler-with-cpp -E ${.CURDIR}/romread.s | \
- ${AS} -o romread.o
-
-#
-install: boot xxboot
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 boot ${DESTDIR}/
- ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 444 xxboot \
- ${DESTDIR}/usr/mdec
- rm -f ${DESTDIR}/usr/mdec/raboot
- ln ${DESTDIR}/usr/mdec/xxboot ${DESTDIR}/usr/mdec/raboot
- rm -f ${DESTDIR}/usr/mdec/hpboot
- ln ${DESTDIR}/usr/mdec/xxboot ${DESTDIR}/usr/mdec/hpboot
-
-clean::
- rm -f start.o romread.o bootxx.o init.o xxboot boot racopy \
- libsvax.a udiv.o urem.o consio.o ${DEVS} edlabel edlabel.o
- rm -f conf.o boot.o rom.o racopy.o srt0.o devopen.o rootcopy.o \
- copy copy.o init.o str.o vers.o
-
-.include <bsd.prog.mk>
-
+SUBDIR= boot xxboot
+.include <bsd.subdir.mk>
diff --git a/sys/arch/vax/stand/autoconf.c b/sys/arch/vax/stand/autoconf.c
deleted file mode 100644
index a1c38fee174..00000000000
--- a/sys/arch/vax/stand/autoconf.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/* $OpenBSD: autoconf.c,v 1.5 1998/02/03 11:48:24 maja Exp $ */
-/* $NetBSD: autoconf.c,v 1.9 1997/04/10 21:25:18 ragge Exp $ */
-/*
- * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
- * 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 at Ludd, University of Lule}.
- * 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.
- */
-
- /* All bugs are subject to removal without further notice */
-
-
-
-#include "sys/param.h"
-#include "../include/mtpr.h"
-#include "../include/sid.h"
-#include "vaxstand.h"
-
-int nmba=0, nuba=0, nbi=0,nsbi=0,nuda=0;
-int *mbaaddr, *ubaaddr, *biaddr;
-int *udaaddr, *uioaddr, tmsaddr, *bioaddr;
-
-static int mba750[]={0xf28000,0xf2a000,0xf2c000};
-static int uba750[]={0xf30000,0xf32000};
-static int uio750[]={0xfc0000,0xf80000};
-static int uda750[]={0772150};
-
-/* 11/780's only have 4, 8600 have 8 of these. */
-static int mba780[]={0x20010000,0x20012000,0x20014000,0x20016000,
- 0x22010000,0x22012000,0x22014000,0x22016000};
-static int uba780[]={0x20006000,0x20008000,0x2000a000,0x2000c000,
- 0x22006000,0x22008000,0x2200a000,0x2200c000};
-static int uio780[]={0x20100000,0x20140000,0x20180000,0x201c0000,
- 0x22100000,0x22140000,0x22180000,0x221c0000};
-
-static int bi8200[]={0x20000000, 0x22000000, 0x24000000, 0x26000000,
- 0x28000000, 0x2a000000};
-static int bio8200[]={0x20400000};
-
-static int uba630[]={0x20087800};
-static int uio630[]={0x30000000};
-#define qbdev(csr) (((csr) & 017777)-0x10000000)
-static int uda630[]={qbdev(0772150),qbdev(0760334)};
-/*
- * Autoconf routine is really stupid; but it actually don't
- * need any intelligence. We just assume that all possible
- * devices exists on each cpu. Fast & easy.
- */
-
-autoconf()
-{
- extern int memsz;
-
- switch (vax_cputype) {
-
- default:
- printf("CPU type %d not supported by boot\n",vax_cputype);
- printf("trying anyway...\n");
- break;
-
- case VAX_8600:
- memsz = 0;
- nmba = 8;
- nuba = 8;
- nuda = 1;
- mbaaddr = mba780;
- ubaaddr = uba780;
- udaaddr = uda750;
- uioaddr = uio780;
- tmsaddr = 0774500;
- break;
-
- case VAX_780:
- memsz = 0;
- nmba = 4;
- nuba = 4;
- nuda = 1;
- mbaaddr = mba780;
- ubaaddr = uba780;
- udaaddr = uda750;
- uioaddr = uio780;
- tmsaddr = 0774500;
- break;
-
- case VAX_750:
- memsz = 0;
- nmba = 3;
- nuba = 2;
- nuda = 1;
- mbaaddr = mba750;
- ubaaddr = uba750;
- udaaddr = uda750;
- uioaddr = uio750;
- tmsaddr = 0774500;
- break;
-
- case VAX_650: /* the same for uvaxIII */
- case VAX_78032:
- nuba = 1;
- nuda = 2;
- ubaaddr = uba630;
- udaaddr = uda630;
- uioaddr = uio630;
- tmsaddr = qbdev(0774500);
- break;
-
- case VAX_8200:
- memsz = 0;
- nbi = 1;
- biaddr = bi8200;
- bioaddr = bio8200;
-
- case VAX_TYP_SOC:
- case VAX_TYP_RIGEL:
- break;
-
- }
-}
-
-/*
- * Return seconds since sometime...
- * Some VAXen doesn't have TODR, return a fake value...
- */
-getsecs()
-{
- static int fakesecs;
- int todr = mfpr(PR_TODR);
-
- if (todr)
- return todr/100;
- return ++fakesecs;
-}
diff --git a/sys/arch/vax/stand/boot/Makefile b/sys/arch/vax/stand/boot/Makefile
new file mode 100644
index 00000000000..f2eb28f90b7
--- /dev/null
+++ b/sys/arch/vax/stand/boot/Makefile
@@ -0,0 +1,47 @@
+# $OpenBSD: Makefile,v 1.1 2000/04/27 02:26:24 bjc Exp $
+# $NetBSD: Makefile,v 1.4 1999/05/23 21:58:19 ragge Exp $
+
+S!= cd ${.CURDIR}/../../../../; pwd
+OBJ!=pwd
+
+NOMAN= 1
+PROG= boot
+DEVS= hp.c ctu.c ra.c tmscp.c mfm.c if_qe.c if_le.c if_ze.c
+SRCS= srt0.s boot.c devopen.c conf.c autoconf.c netio.c rom.c romread.s \
+ urem.s udiv.s consio.c str.s ${DEVS} findcpu.c
+#OBJS= autoconf.o boot.o conf.o consio.o ctu.o devopen.o findcpu.o hp.o \
+# if_le.o if_qe.o if_ze.o mfm.o netio.o ra.o rom.o romread.o srt0.o \
+# str.o tmscp.o udiv.o urem.o
+
+CLEANFILES+=${PROG}.mop
+CPPFLAGS+=-DSUPPORT_BOOTPARAMS -DSUPPORT_DHCP -D_STANDALONE
+#CPPFLAGS+=-DBOOTP_DEBUG -DNETIF_DEBUG -DETHER_DEBUG -DNFS_DEBUG -DDEV_DEBUG \
+# -DRPC_DEBUG -DRARP_DEBUG -DPARANOID -DSUPPORT_BOOTP
+BINDIR= /
+
+SA_ZLIB= yes
+SAREL=
+.include "${S}/lib/libsa/Makefile.inc"
+LIBSA= ${SALIB}
+
+Z_AS= library
+CFLAGS+=-I${S}/lib/libsa
+.include "${S}/lib/libz/Makefile.inc"
+LIBZ= ${ZLIB}
+
+#KERN_AS=library
+#.include "${S}/lib/libkern/Makefile.inc"
+#LIBKERN=${KERNLIB}
+
+boot: ${OBJS} ${SALIB} ${LIBZ} ${LIBKERN}
+ ld -N -Ttext ${RELOC} -e nisse -o ${PROG} -Llib/sa -L. ${OBJS} \
+ ${LIBSA} ${LIBZ} -lsa ${LIBKERN}
+ /usr/sbin/mopa.out ${PROG} ${PROG}.mop
+ strip ${PROG}
+ size ${PROG}
+
+clean::
+ rm -f a.out [Ee]rrs mklog core *.core ${PROG} ${OBJS} ${LOBJS} \
+ ${CLEANFILES}
+
+.include <bsd.prog.mk>
diff --git a/sys/arch/vax/stand/boot/autoconf.c b/sys/arch/vax/stand/boot/autoconf.c
new file mode 100644
index 00000000000..641d9184f72
--- /dev/null
+++ b/sys/arch/vax/stand/boot/autoconf.c
@@ -0,0 +1,257 @@
+/* $OpenBSD: autoconf.c,v 1.1 2000/04/27 02:26:24 bjc Exp $ */
+/* $NetBSD: autoconf.c,v 1.5 1999/08/23 19:09:27 ragge Exp $ */
+/*
+ * Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden.
+ * 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 at Ludd, University of Lule}.
+ * 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.
+ */
+
+ /* All bugs are subject to removal without further notice */
+
+
+
+#include "sys/param.h"
+#include "../../include/mtpr.h"
+#include "../../include/sid.h"
+#include "../../include/trap.h"
+#include "../../include/frame.h"
+#include "vaxstand.h"
+
+extern const struct ivec_dsp idsptch; /* since we are not KERNEL */
+
+int nmba=0, nuba=0, nbi=0,nsbi=0,nuda=0;
+int *mbaaddr, *ubaaddr, *biaddr;
+int *udaaddr, *uioaddr, tmsaddr, *bioaddr;
+
+static int mba750[]={0xf28000,0xf2a000,0xf2c000};
+static int uba750[]={0xf30000,0xf32000};
+static int uio750[]={0xfc0000,0xf80000};
+static int uda750[]={0772150};
+
+/* 11/780's only have 4, 8600 have 8 of these. */
+/* XXX - all of these should be bound to physical addresses */
+static int mba780[]={0x20010000,0x20012000,0x20014000,0x20016000,
+ 0x22010000,0x22012000,0x22014000,0x22016000};
+static int uba780[]={0, 0, 0, 0x20006000,0x20008000,0x2000a000,0x2000c000, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x22006000,0x22008000,0x2200a000,0x2200c000};
+static int uio780[]={0, 0, 0, 0x20100000,0x20140000,0x20180000,0x201c0000, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0x22100000,0x22140000,0x22180000,0x221c0000};
+static int bi8200[]={0x20000000, 0x22000000, 0x24000000, 0x26000000,
+ 0x28000000, 0x2a000000};
+static int bio8200[]={0x20400000};
+
+static int uba630[]={0x20087800};
+static int uio630[]={0x30000000};
+#define qbdev(csr) (((csr) & 017777)-0x10000000)
+static int uda630[]={qbdev(0772150),qbdev(0760334)};
+
+static int uba670[]={0x20040000};
+static int uio670[]={0x20000000};
+static int uda670[]={0x20004030,0x20004230};
+#define qb670dev(csr) (((csr) & 017777)+0x20000000)
+
+/*
+ * Autoconf routine is really stupid; but it actually don't
+ * need any intelligence. We just assume that all possible
+ * devices exists on each cpu. Fast & easy.
+ */
+
+autoconf()
+{
+ extern int memsz;
+
+ findcpu(); /* Configures CPU variables */
+ consinit(); /* Allow us to print out things */
+ scbinit(); /* Fix interval clock etc */
+
+ switch (vax_boardtype) {
+
+ default:
+ printf("\nCPU type %d not supported by boot\n",vax_cputype);
+ printf("trying anyway...\n");
+ break;
+
+ case VAX_BTYP_780:
+ case VAX_BTYP_790:
+ memsz = 0;
+ nmba = 8;
+ nuba = 32; /* XXX */
+ nuda = 1;
+ mbaaddr = mba780;
+ ubaaddr = uba780;
+ udaaddr = uda750;
+ uioaddr = uio780;
+ tmsaddr = 0774500;
+ break;
+
+ case VAX_BTYP_750:
+ memsz = 0;
+ nmba = 3;
+ nuba = 2;
+ nuda = 1;
+ mbaaddr = mba750;
+ ubaaddr = uba750;
+ udaaddr = uda750;
+ uioaddr = uio750;
+ tmsaddr = 0774500;
+ break;
+
+ case VAX_BTYP_630: /* the same for uvaxIII */
+ case VAX_BTYP_650:
+ case VAX_BTYP_660:
+ case VAX_BTYP_670:
+ nuba = 1;
+ nuda = 2;
+ ubaaddr = uba630;
+ udaaddr = uda630;
+ uioaddr = uio630;
+ tmsaddr = qbdev(0774500);
+ break;
+
+ case VAX_BTYP_8000:
+ memsz = 0;
+ nbi = 1;
+ biaddr = bi8200;
+ bioaddr = bio8200;
+ break;
+
+ case VAX_BTYP_46:
+ case VAX_BTYP_48:
+ {int *map, i;
+
+ /* Map all 16MB of I/O space to low 16MB of memory */
+ map = (int *)0x700000; /* XXX */
+ *(int *)0x20080008 = (int)map; /* XXX */
+ for (i = 0; i < 0x8000; i++)
+ map[i] = 0x80000000 | i;
+ }break;
+
+ case VAX_BTYP_410:
+ case VAX_BTYP_420:
+ case VAX_BTYP_43:
+ case VAX_BTYP_49:
+ break;
+ }
+}
+
+/*
+ * Clock handling routines, needed to do timing in standalone programs.
+ */
+
+volatile int tickcnt;
+
+getsecs()
+{
+ volatile int loop;
+ int todr;
+
+ return tickcnt/100;
+}
+
+void scb_stray(), rtimer();
+struct ivec_dsp **scb;
+struct ivec_dsp *scb_vec;
+
+/*
+ * Init the SCB and set up a handler for all vectors in the lower space,
+ * to detect unwanted interrupts.
+ */
+scbinit()
+{
+ extern int timer;
+ int i;
+
+ /*
+ * Allocate space. We need one page for the SCB, and 128*16 == 2k
+ * for the vectors. The SCB must be on a page boundary.
+ */
+ i = alloc(VAX_NBPG * 6) + VAX_PGOFSET;
+ i &= ~VAX_PGOFSET;
+
+ mtpr(i, PR_SCBB);
+ scb = (void *)i;
+ scb_vec = (struct ivec_dsp *)(i + VAX_NBPG);
+
+ for (i = 0; i < 128; i++) {
+ scb[i] = &scb_vec[i];
+ (int)scb[i] |= 1; /* Only interrupt stack */
+ memcpy(&scb_vec[i], &idsptch, sizeof(struct ivec_dsp));
+ scb_vec[i].hoppaddr = scb_stray;
+ }
+ scb_vec[0xc0/4].hoppaddr = rtimer;
+
+ mtpr(-10000, PR_NICR); /* Load in count register */
+ mtpr(0x800000d1, PR_ICCS); /* Start clock and enable interrupt */
+
+ mtpr(20, PR_IPL);
+}
+
+void
+rtimer()
+{
+ mtpr(31, PR_IPL);
+ tickcnt++;
+ mtpr(0xc1, PR_ICCS);
+}
+
+asm("
+ .globl _idsptch, _eidsptch
+_idsptch:
+ pushr $0x3f
+ pushl $1
+ .long 0x9f01fb01
+ .long 0x12345678
+#
+# gas do not accept this :-/ use hexcode instead
+# nop
+# calls $1, *$0x12345678
+ popr $0x3f
+ rei
+_eidsptch:
+");
+
+/*
+ * Stray interrupt handler.
+ * This function must _not_ save any registers (in the reg save mask).
+ */
+void
+scb_stray(arg)
+ int arg;
+{
+ static struct callsframe *cf;
+ static int vector, ipl, *a;
+
+ cf = FRAMEOFFSET(arg);
+ a = &cf->ca_arg1;
+ ipl = mfpr(PR_IPL);
+ vector = ((cf->ca_pc - (u_int)scb_vec)/4) & ~3;
+ printf("stray interrupt: pc %x vector 0x%x, ipl %d\n",
+ cf->ca_pc, vector, ipl);
+}
+
diff --git a/sys/arch/vax/stand/boot.c b/sys/arch/vax/stand/boot/boot.c
index b0df2b865b0..e6cde511d76 100644
--- a/sys/arch/vax/stand/boot.c
+++ b/sys/arch/vax/stand/boot/boot.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: boot.c,v 1.5 1998/05/11 07:36:26 niklas Exp $ */
-/* $NetBSD: boot.c,v 1.7 1997/06/08 17:49:16 ragge Exp $ */
+/* $OpenBSD: boot.c,v 1.1 2000/04/27 02:26:24 bjc Exp $ */
+/* $NetBSD: boot.c,v 1.4 1999/10/23 14:42:22 ragge Exp $ */
/*-
* Copyright (c) 1982, 1986 The Regents of the University of California.
* All rights reserved.
@@ -41,7 +41,7 @@
#define V750UCODE(x) ((x>>8)&255)
-#include <sys/exec.h>
+#include "vaxstand.h"
/*
* Boot program... arguments passed in r10 and r11 determine
@@ -50,112 +50,148 @@
*/
char line[100];
-volatile int devtype, bootdev;
+int devtype, bootdev, howto, debug;
extern unsigned opendev;
extern unsigned *bootregs;
+void usage(), boot(), halt();
+
+struct vals {
+ char *namn;
+ void (*func)();
+ char *info;
+} val[] = {
+ {"?", usage, "Show this help menu"},
+ {"help", usage, "Same as '?'"},
+ {"boot", boot, "Load and execute file"},
+ {"halt", halt, "Halts the system"},
+ {0, 0},
+};
+
+char *filer[] = {
+ "bsd",
+ "bsd.gz",
+ "bsd.old",
+ 0,
+};
+
Xmain()
{
- register howto asm("r11");
- register bdev asm("r10");
- int io, retry, type;
- extern char vers[];
+ int io, type, sluttid, askname, filindex = 0;
+ int j, senast = 0, nu;
io=0;
- bootdev=bdev;
autoconf();
- if ((howto & RB_ASKNAME) == 0) {
+ askname = howto & RB_ASKNAME;
+ printf("\n\r>> OpenBSD/vax boot [%s %s] <<\n", __DATE__, __TIME__);
+ printf(">> Press any key to abort autoboot ");
+ sluttid = getsecs() + 5;
+ for (;;) {
+ nu = sluttid - getsecs();
+ if (senast != nu)
+ printf("%c%d", 8, nu);
+ if (nu <= 0)
+ break;
+ senast = nu;
+ if ((j = (testkey() & 0177))) {
+ if (j != 10 && j != 13) {
+ printf("\nPress '?' for help");
+ askname = 1;
+ }
+ break;
+ }
+ }
+ printf("\n");
+
+ /* First try to autoboot */
+ if (askname == 0) {
type = (devtype >> B_TYPESHIFT) & B_TYPEMASK;
if ((unsigned)type < ndevs && devsw[type].dv_name)
- strcpy(line, "/bsd");
- else
- howto |= RB_SINGLE|RB_ASKNAME;
+ while (filer[filindex]) {
+ errno = 0;
+ printf("> boot %s\n", filer[filindex]);
+ exec(filer[filindex++], 0, 0);
+ printf("boot failed: %s\n", strerror(errno));
+ if (testkey())
+ break;
+ }
}
- for (retry = 0;;) {
- if (io >= 0)
- printf("\n%s\n", vers);
- if (howto & RB_ASKNAME) {
- printf(": ");
- gets(line);
- if (line[0] == 0) {
- strcpy(line, "/bsd");
- printf(": %s\n", line);
- }
- } else
- printf(": %s\n", line);
- io = open(line, 0);
- if (io >= 0) {
- loadpcs();
- copyunix(howto, opendev, io);
- close(io);
- howto |= RB_SINGLE|RB_ASKNAME;
- } else {
- printf("%s\n",strerror(errno));
+ /* If any key pressed, go to conversational boot */
+ for (;;) {
+ struct vals *v = &val[0];
+ char *c, *d;
+
+ printf("> ");
+ gets(line);
+
+ c = line;
+ while (*c == ' ')
+ c++;
+
+ if (c[0] == 0)
+ continue;
+
+ if ((d = index(c, ' ')))
+ *d++ = 0;
+
+ while (v->namn) {
+ if (strcmp(v->namn, c) == 0)
+ break;
+ v++;
}
- if (++retry > 2)
- howto |= RB_SINGLE|RB_ASKNAME;
+ if (v->namn)
+ (*v->func)(d);
+ else
+ printf("Unknown command: %s\n", c);
+
}
}
-/*ARGSUSED*/
-copyunix(howto, devtype, aio)
- register howto, devtype; /* howto=r11, devtype=r10 */
- int aio;
+void
+halt()
{
- register int esym; /* must be r9 */
- struct exec x;
- register int io = aio, i;
- char *addr;
+ asm("halt");
+}
- if (read(io, (char *)&x, sizeof(x)) != sizeof(x) || N_BADMAG(x)) {
- printf("Bad format\n");
- return;
+void
+boot(arg)
+ char *arg;
+{
+ char *fn = "bsd";
+
+ if (arg) {
+ while (*arg == ' ')
+ arg++;
+
+ if (*arg != '-') {
+ fn = arg;
+ if ((arg = index(arg, ' '))) {
+ *arg++ = 0;
+ while (*arg == ' ')
+ arg++;
+ } else
+ goto load;
+ }
+ if (*arg != '-') {
+fail: printf("usage: boot [filename] [-asd]\n");
+ return;
+ }
+
+ while (*++arg) {
+ if (*arg == 'a')
+ howto |= RB_ASKNAME;
+ else if (*arg == 'd')
+ howto |= RB_KDB;
+ else if (*arg == 's')
+ howto |= RB_SINGLE;
+ else
+ goto fail;
+ }
}
- printf("%d", x.a_text);
- if (N_GETMAGIC(x) == ZMAGIC && lseek(io, 0x400, SEEK_SET) == -1)
- goto shread;
- if (read(io, (char *)0, x.a_text) != x.a_text)
- goto shread;
- addr = (char *)x.a_text;
- if (N_GETMAGIC(x) == ZMAGIC || N_GETMAGIC(x) == NMAGIC)
- while ((int)addr & CLOFSET)
- *addr++ = 0;
- printf("+%d", x.a_data);
- if (read(io, addr, x.a_data) != x.a_data)
- goto shread;
- addr += x.a_data;
- printf("+%d", x.a_bss);
- for (i = 0; i < x.a_bss; i++)
- *addr++ = 0;
- if (howto & RB_KDB && x.a_syms) {
- *(int *)addr = x.a_syms; /* symbol table size */
- addr += sizeof (int);
- printf("[+%d", x.a_syms);
- if (read(io, addr, x.a_syms) != x.a_syms)
- goto shread;
- addr += x.a_syms;
- if (read(io, addr, sizeof (int)) != sizeof (int))
- goto shread;
- i = *(int *)addr - sizeof (int); /* string table size */
- addr += sizeof (int);
- printf("+%d]", i);
- if (read(io, addr, i) != i)
- goto shread;
- addr += i;
- esym = roundup((int)addr, sizeof (int));
- x.a_bss = 0;
- } else
- howto &= ~RB_KDB;
- for (i = 0; i < 128*512; i++) /* slop */
- *addr++ = 0;
- printf(" start 0x%x\n", (x.a_entry&0x7fffffff));
- hoppabort((x.a_entry&0x7fffffff),howto, devtype, esym);
- return;
-shread:
- printf("\nShort read\n\n");
- return;
+load: exec(fn, 0, 0);
+ printf("Boot failed: %s\n", strerror(errno));
}
/* 750 Patchable Control Store magic */
@@ -180,12 +216,9 @@ shread:
loadpcs()
{
- register int *ip; /* known to be r11 below */
- register int i; /* known to be r10 below */
- register int *jp; /* known to be r9 below */
- register int j;
static int pcsdone = 0;
int mid = mfpr(PR_SID);
+ int i, j, *ip, *jp;
char pcs[100];
char *cp;
@@ -252,3 +285,15 @@ loadpcs()
printf("new rev level=%d\n", V750UCODE(mid));
pcsdone = 1;
}
+
+void
+usage()
+{
+ struct vals *v = &val[0];
+
+ printf("Commands:\n");
+ while (v->namn) {
+ printf("%s\t%s\n", v->namn, v->info);
+ v++;
+ }
+}
diff --git a/sys/arch/vax/boot/conf.c b/sys/arch/vax/stand/boot/conf.c
index 952d3060a70..334fe0cd933 100644
--- a/sys/arch/vax/boot/conf.c
+++ b/sys/arch/vax/stand/boot/conf.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: conf.c,v 1.5 1998/02/03 11:48:25 maja Exp $ */
-/* $NetBSD: conf.c,v 1.8 1997/04/10 21:25:21 ragge Exp $ */
+/* $OpenBSD: conf.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: conf.c,v 1.3 1999/10/23 14:42:21 ragge Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -36,7 +36,7 @@
#include <netinet/in.h>
-#include <machine/rpb.h>
+#include "../../include/rpb.h"
#include "lib/libsa/stand.h"
#include "lib/libsa/ufs.h"
@@ -61,9 +61,10 @@ struct devsw devsw[]={
SADEV("mt",tmscpstrategy, tmscpopen, nullsys, noioctl),
SADEV("rom",romstrategy, romopen, nullsys, noioctl),
SADEV("rd",mfmstrategy, mfmopen, nullsys, noioctl),
- SADEV("sd",sdstrategy, sdopen, nullsys, noioctl),
- SADEV("st",sdstrategy, sdopen, nullsys, noioctl),
+ SADEV("sd",romstrategy, romopen, nullsys, noioctl),
+ SADEV("st",nullsys, nullsys, nullsys, noioctl),
SADEV("le",netstrategy, netopen, netclose, noioctl), /* LANCE */
+ SADEV("ze",netstrategy, netopen, netclose, noioctl), /* SGEC */
};
int cnvtab[] = {
@@ -77,15 +78,13 @@ int cnvtab[] = {
BDEV_SD,
BDEV_ST,
BDEV_LE,
+ BDEV_ZE,
};
int ndevs = (sizeof(devsw)/sizeof(devsw[0]));
struct fs_ops file_system[] = {
- { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat }
-};
-
-struct fs_ops nfs_system[] = {
+ { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat },
{ nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat },
};
@@ -93,10 +92,12 @@ int nfsys = (sizeof(file_system) / sizeof(struct fs_ops));
extern struct netif_driver qe_driver;
extern struct netif_driver le_driver;
+extern struct netif_driver ze_driver;
struct netif_driver *netif_drivers[] = {
-/* &qe_driver, */
+ &qe_driver,
&le_driver,
+ &ze_driver,
};
int n_netif_drivers = (sizeof(netif_drivers) / sizeof(netif_drivers[0]));
diff --git a/sys/arch/vax/boot/consio.c b/sys/arch/vax/stand/boot/consio.c
index c9791416bfa..9cb131fb945 100644
--- a/sys/arch/vax/boot/consio.c
+++ b/sys/arch/vax/stand/boot/consio.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: consio.c,v 1.4 1998/02/03 11:48:26 maja Exp $ */
-/* $NetBSD: consio.c,v 1.8 1997/06/08 17:49:18 ragge Exp $ */
+/* $OpenBSD: consio.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: consio.c,v 1.6 1999/08/23 19:09:27 ragge Exp $ */
/*
- * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
+ * Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,36 +38,54 @@
#include "../vax/gencons.h"
-#include "../include/mtpr.h"
-#include "../include/sid.h"
-#include "../include/rpb.h"
+#include "mtpr.h"
+#include "sid.h"
+#include "rpb.h"
#include "data.h"
void setup __P((void));
-int vax_cputype;
-int vax_boardtype;
-
-int is_750;
-int is_mvax;
-
unsigned *bootregs;
struct rpb *rpb;
struct bqo *bqo;
static int (*put_fp) __P((int)) = NULL;
static int (*get_fp) __P((void)) = NULL;
+static int (*test_fp) __P((void)) = NULL;
int pr_putchar __P((int c)); /* putchar() using mtpr/mfpr */
int pr_getchar __P((void));
+int pr_testchar __P((void));
int rom_putchar __P((int c)); /* putchar() using ROM routines */
int rom_getchar __P((void));
+int rom_testchar __P((void));
static int rom_putc; /* ROM-address of put-routine */
static int rom_getc; /* ROM-address of get-routine */
+/* Location of address of KA630 console page */
+#define NVR_ADRS 0x200B8024
+/* Definitions for various locations in the KA630 console page */
+#define KA630_PUTC_POLL 0x20
+#define KA630_PUTC 0x24
+#define KA630_GETC 0x1C
+#define KA630_ROW 0x4C
+#define KA630_MINROW 0x4D
+#define KA630_MAXROW 0x4E
+#define KA630_COL 0x50
+#define KA630_MINCOL 0x51
+#define KA630_MAXCOL 0x52
+/* Pointer to KA630 console page, initialized by ka630_consinit */
+unsigned char *ka630_conspage;
+/* Function that initializes things for KA630 ROM console I/O */
+void ka630_consinit __P((void));
+/* Functions that use KA630 ROM for console I/O */
+int ka630_rom_putchar __P((int c));
+int ka630_rom_getchar __P((void));
+int ka630_rom_testchar __P((void));
+
putchar(c)
int c;
{
@@ -83,38 +101,28 @@ getchar()
do
c = (*get_fp)() & 0177;
while (c == 17 || c == 19); /* ignore XON/XOFF */
+ if (c < 96 && c > 64)
+ c += 32;
return c;
}
+testkey()
+{
+ return (*test_fp)();
+}
/*
* setup() is called out of the startup files (start.s, srt0.s) and
* initializes data which are globally used and is called before main().
*/
void
-setup()
+consinit()
{
- vax_cputype = (mfpr(PR_SID) >> 24) & 0xFF;
-
put_fp = pr_putchar; /* Default */
get_fp = pr_getchar;
- /*
- * according to vax_cputype we initialize vax_boardtype.
- */
- switch (vax_cputype) {
-
- case VAX_TYP_UV2:
- case VAX_TYP_CVAX:
- case VAX_TYP_RIGEL:
- case VAX_TYP_MARIAH:
- case VAX_TYP_NVAX:
- case VAX_TYP_SOC:
- is_mvax = 1;
- vax_boardtype = (vax_cputype << 24) |
- ((*(int*)0x20040004 >> 24) & 0377);
- rpb = (struct rpb *)bootregs[11]; /* bertram: ??? */
- break;
- }
+ test_fp = pr_testchar;
+
+ rpb = (struct rpb *)bootregs[11]; /* bertram: ??? */
/*
* According to the vax_boardtype (vax_cputype is not specific
@@ -127,27 +135,39 @@ setup()
*/
switch (vax_boardtype) {
- case VAX_BTYP_660:
- case VAX_BTYP_670:
case VAX_BTYP_690:
case VAX_BTYP_1303:
put_fp = rom_putchar;
get_fp = rom_getchar;
+ test_fp = rom_testchar;
rom_putc = 0x20040058; /* 537133144 */
rom_getc = 0x20040008; /* 537133064 */
break;
case VAX_BTYP_43:
- case VAX_BTYP_46:
- case VAX_BTYP_49:
case VAX_BTYP_410:
case VAX_BTYP_420:
- case VAX_BTYP_440:
put_fp = rom_putchar;
get_fp = rom_getchar;
+ test_fp = rom_testchar;
rom_putc = 0x20040058; /* 537133144 */
rom_getc = 0x20040044; /* 537133124 */
break;
+
+ case VAX_BTYP_630:
+ ka630_consinit();
+ break;
+
+ case VAX_BTYP_46:
+ case VAX_BTYP_48:
+ case VAX_BTYP_49:
+ put_fp = rom_putchar;
+ get_fp = rom_getchar;
+ test_fp = rom_testchar;
+ rom_putc = 0x20040068;
+ rom_getc = 0x20040054;
+ break;
+
#ifdef notdef
case VAX_BTYP_630:
case VAX_BTYP_650:
@@ -183,6 +203,13 @@ pr_getchar()
return (mfpr(PR_RXDB)); /* now get it */
}
+pr_testchar()
+{
+ if (mfpr(PR_RXCS) & GC_DON)
+ return mfpr(PR_RXDB);
+ else
+ return 0;
+}
/*
* int rom_putchar (int c) ==> putchar() using ROM-routines
*/
@@ -209,10 +236,88 @@ asm("
beql loop # } while (R0 == 0)
movl r1, r0 # R1 holds char
ret # we're done
+
+ _rom_testchar:
+ .word 0
+ mnegl $1,r0
+ jsb *_rom_getc
+ tstl r0
+ beql 1f
+ movl r1,r0
+ 1: ret
");
_rtt()
{
- printf("rtt\n");
-bo: goto bo;
+ asm("halt");
}
+
+
+
+/*
+ * void ka630_rom_getchar (void) ==> initialize KA630 ROM console I/O
+ */
+void ka630_consinit()
+{
+ register short *NVR;
+ register int i;
+
+ /* Find the console page */
+ NVR = (short *) NVR_ADRS;
+
+ i = *NVR++ & 0xFF;
+ i |= (*NVR++ & 0xFF) << 8;
+ i |= (*NVR++ & 0xFF) << 16;
+ i |= (*NVR++ & 0xFF) << 24;
+
+ ka630_conspage = (char *) i;
+
+ /* Go to last row to minimize confusion */
+ ka630_conspage[KA630_ROW] = ka630_conspage[KA630_MAXROW];
+ ka630_conspage[KA630_COL] = ka630_conspage[KA630_MINCOL];
+
+ /* Use KA630 ROM console I/O routines */
+ put_fp = ka630_rom_putchar;
+ get_fp = ka630_rom_getchar;
+ test_fp = ka630_rom_testchar;
+}
+
+
+/*
+ * int ka630_rom_getchar (void) ==> getchar() using ROM-routines on KA630
+ */
+asm("
+ .globl _ka630_rom_getchar
+ _ka630_rom_getchar:
+ .word 0x802 # save-mask: R1, R11
+ movl _ka630_conspage,r11 # load location of console page
+ loop630g: # do {
+ jsb *0x1C(r11) # call the getc-routine (KA630_GETC)
+ blbc r0, loop630g # } while (R0 == 0)
+ movl r1, r0 # R1 holds char
+ ret # we're done
+
+ _ka630_rom_testchar:
+ .word 0
+ movl _ka630_conspage,r3
+ jsb *0x1C(r3)
+ blbc r0,1f
+ movl r1,r0
+ 1: ret
+");
+
+/*
+ * int ka630_rom_putchar (int c) ==> putchar() using ROM-routines on KA630
+ */
+asm("
+ .globl _ka630_rom_putchar
+ _ka630_rom_putchar:
+ .word 0x802 # save-mask: R1, R11
+ movl _ka630_conspage,r11 # load location of console page
+ loop630p: # do {
+ jsb *0x20(r11) # is rom ready? (KA630_PUTC_POLL)
+ blbc r0, loop630p # } while (R0 == 0)
+ movl 4(ap), r1 # R1 holds char
+ jsb *0x24(r11) # output character (KA630_PUTC)
+ ret # we're done
+");
diff --git a/sys/arch/vax/boot/ctu.c b/sys/arch/vax/stand/boot/ctu.c
index 8e5ec6160a7..3f2c9afb891 100644
--- a/sys/arch/vax/boot/ctu.c
+++ b/sys/arch/vax/stand/boot/ctu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ctu.c,v 1.2 1997/05/29 00:04:20 niklas Exp $ */
+/* $OpenBSD: ctu.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
/* $NetBSD: ctu.c,v 1.1 1996/02/17 18:23:20 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
@@ -59,8 +59,8 @@ volatile struct tu_softc {
int sc_bbytes; /* Number of xfer'd bytes this block */
} tu_sc;
-void ctutintr __P(());
-void cturintr __P(());
+void ctutintr __P((void));
+void cturintr __P((void));
int
ctuopen(f, adapt, ctlr, unit, part)
diff --git a/sys/arch/vax/boot/data.h b/sys/arch/vax/stand/boot/data.h
index e8d92478098..9098d501d70 100644
--- a/sys/arch/vax/boot/data.h
+++ b/sys/arch/vax/stand/boot/data.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: data.h,v 1.2 1997/05/29 00:04:21 niklas Exp $ */
+/* $OpenBSD: data.h,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
/* $NetBSD: data.h,v 1.4 1995/09/16 15:58:57 ragge Exp $ */
/*
* Copyright (c) 1995 Ludd, University of Lule}, Sweden.
diff --git a/sys/arch/vax/stand/devopen.c b/sys/arch/vax/stand/boot/devopen.c
index a34e7895207..c832398b951 100644
--- a/sys/arch/vax/stand/devopen.c
+++ b/sys/arch/vax/stand/boot/devopen.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: devopen.c,v 1.5 1998/02/03 11:48:26 maja Exp $ */
-/* $NetBSD: devopen.c,v 1.8 1997/06/08 17:49:19 ragge Exp $ */
+/* $OpenBSD: devopen.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: devopen.c,v 1.2 1999/06/30 18:30:42 ragge Exp $ */
/*
* Copyright (c) 1997 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -34,7 +34,6 @@
#include <sys/reboot.h>
#include "lib/libsa/stand.h"
-#include "samachdep.h"
#include "vaxstand.h"
unsigned int opendev;
@@ -47,9 +46,8 @@ devopen(f, fname, file)
{
int dev, ctlr, unit, part, adapt, i, a[4], x;
struct devsw *dp;
- extern struct fs_ops nfs_system[];
extern int cnvtab[];
- char *s, *c;
+ char *s, *c, *u;
dev = B_TYPE(bootdev);
ctlr = B_CONTROLLER(bootdev);
@@ -101,29 +99,10 @@ devopen(f, fname, file)
if (x > 3)
adapt = a[0];
*file = c;
- } else
+ } else {
*file = (char *)fname;
-
-#ifdef notyet
- if ((u = index(s, ' '))) {
- *u++ = 0;
-
- if (*u != '-')
- goto usage;
-
- while (*++u) {
- if (*u == 'a')
- bdev |= RB_ASKNAME;
- else if (*u == 'd')
- bdev |= RB_DEBUG;
- else if (*u == 's')
- bdev |= RB_SINGLE;
- else
- goto usage;
- }
-
+ c = (char *)fname;
}
-#endif
if (!dp->dv_open)
return(ENODEV);
@@ -132,7 +111,6 @@ devopen(f, fname, file)
opendev = MAKEBOOTDEV(dev, adapt, ctlr, unit, part);
if (dev > 95) { /* MOP boot over network, root & swap over NFS */
- bcopy(nfs_system, file_system, sizeof(struct fs_ops));
i = (*dp->dv_open)(f, dp->dv_name);
} else
i = (*dp->dv_open)(f, adapt, ctlr, unit, part);
diff --git a/sys/arch/vax/boot/hp.c b/sys/arch/vax/stand/boot/hp.c
index 80d5d8ac56b..30f29ae1101 100644
--- a/sys/arch/vax/boot/hp.c
+++ b/sys/arch/vax/stand/boot/hp.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: hp.c,v 1.4 1998/05/13 07:30:22 niklas Exp $ */
-/* $NetBSD: hp.c,v 1.5 1996/02/17 18:23:22 ragge Exp $ */
+/* $OpenBSD: hp.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: hp.c,v 1.2 1999/04/01 20:40:07 ragge Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -40,7 +40,7 @@
#include "lib/libsa/stand.h"
#include "../include/pte.h"
-#include "../include/macros.h"
+/*#include "../include/macros.h"*/
#include "../mba/mbareg.h"
#include "../mba/hpreg.h"
@@ -130,12 +130,12 @@ hpstrategy(hs, func, dblk, size, buf, rsize)
hd = (void *)&mr->mba_md[hs->unit];
lp = &hplabel;
- pfnum = (u_int)buf >> PGSHIFT;
+ pfnum = (u_int)buf >> VAX_PGSHIFT;
- for(mapnr = 0, nsize = size; (nsize + NBPG) > 0; nsize -= NBPG)
+ for(mapnr = 0, nsize = size; (nsize + VAX_NBPG) > 0; nsize -= VAX_NBPG)
*(int *)&mr->mba_map[mapnr++] = PG_V | pfnum++;
- mr->mba_var = ((u_int)buf & PGOFSET);
+ mr->mba_var = ((u_int)buf & VAX_PGOFSET);
mr->mba_bc = (~size) + 1;
bn = dblk + lp->d_partitions[hs->part].p_offset;
diff --git a/sys/arch/vax/boot/if_le.c b/sys/arch/vax/stand/boot/if_le.c
index 7a223edfa54..31fb9f756b1 100644
--- a/sys/arch/vax/boot/if_le.c
+++ b/sys/arch/vax/stand/boot/if_le.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: if_le.c,v 1.1 1998/02/03 11:48:27 maja Exp $ */
-/* $NetBSD: if_le.c,v 1.2 1997/03/22 12:47:31 ragge Exp $ */
+/* $OpenBSD: if_le.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: if_le.c,v 1.4 1999/08/14 19:41:14 ragge Exp $ */
/*
- * Copyright (c) 1997 Ludd, University of Lule}, Sweden.
+ * Copyright (c) 1997, 1999 Ludd, University of Lule}, Sweden.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -37,18 +37,21 @@
#include <sys/param.h>
#include <sys/types.h>
+#include <sys/queue.h>
+#include <sys/socket.h>
+
+#include <net/if.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
+#include <netinet/if_ether.h>
+
+#include <../include/sid.h>
#include <lib/libsa/netif.h>
#include <dev/ic/am7990reg.h>
-#define ETHER_MIN_LEN 64
-#define ETHER_MAX_LEN 1518
-#define ETHER_ADDR_LEN 6
-
/*
* The following are incorrect. Why doesn't DEC follow its own specs???
*/
@@ -58,10 +61,12 @@
#define NRBUF (1 << RLEN)
#define BUFSIZE 1518
+#define ETHER_MIN_LEN 64 /* minimum frame length, including CRC */
#define QW_ALLOC(x) ((alloc((x) + 7) + 7) & ~7)
int le_probe(), le_match(), le_get(), le_put();
-void le_init();
+void le_init(), le_end();
+static void copyin(), copyout();
struct netif_stats le_stats;
@@ -73,7 +78,7 @@ struct netif_dif le_ifs[] = {
struct netif_stats le_stats;
struct netif_driver le_driver = {
- "le", le_match, le_probe, le_init, le_get, le_put, 0, le_ifs, 1,
+ "le", le_match, le_probe, le_init, le_get, le_put, le_end, le_ifs, 1,
};
/*
@@ -90,7 +95,7 @@ struct initblock {
} *initblock = NULL;
struct nireg {
- volatile short ni_rdp; /* data port */
+ volatile u_short ni_rdp; /* data port */
volatile short ni_pad0;
volatile short ni_rap; /* register select port */
} *nireg = (struct nireg *)0x200e0000;
@@ -102,6 +107,8 @@ volatile struct buffdesc {
short bd_mcnt;
} *rdesc, *tdesc;
+static int addoff, kopiera = 0;
+
/* Flags in the address field */
#define BR_OWN 0x80000000
#define BR_ERR 0x40000000
@@ -153,51 +160,90 @@ le_init(desc, machdep_hint)
int stat, i, *ea;
volatile int to = 100000;
- *(int *)0x20080014 = 0; /* Be sure we do DMA in low 16MB */
next_rdesc = next_tdesc = 0;
+ if (vax_boardtype == VAX_BTYP_650 &&
+ ((vax_siedata >> 8) & 0xff) == VAX_SIE_KA640) {
+ kopiera = 1;
+ ea = (void *)0x20084200;
+ nireg = (void *)0x20084400;
+ } else {
+ *(int *)0x20080014 = 0; /* Be sure we do DMA in low 16MB */
+ ea = (void *)0x20090000; /* XXX ethernetadressen */
+ }
+
+ if (vax_boardtype == VAX_BTYP_43)
+ addoff = 0x28000000;
+ else
+ addoff = 0;
+igen:
LEWRCSR(LE_CSR0, LE_C0_STOP);
while (to--)
;
- if (initblock == NULL) {
- ea = (void *)0x20090000; /* XXX ethernetadressen */
- for (i = 0; i < 6; i++)
- desc->myea[i] = ea[i] & 0377;
+ for (i = 0; i < 6; i++)
+ desc->myea[i] = ea[i] & 0377;
- initblock = (void *)alloc(sizeof(struct initblock));
+ if (initblock == NULL) {
+ initblock = (void *)QW_ALLOC(sizeof(struct initblock)) + addoff;
initblock->ib_mode = LE_MODE_NORMAL;
bcopy(desc->myea, initblock->ib_padr, 6);
initblock->ib_ladrf1 = 0;
initblock->ib_ladrf2 = 0;
- (int)rdesc = QW_ALLOC(sizeof(struct buffdesc) * NRBUF);
+ (int)rdesc = QW_ALLOC(sizeof(struct buffdesc) * NRBUF) + addoff;
initblock->ib_rdr = (RLEN << 29) | (int)rdesc;
- (int)tdesc = QW_ALLOC(sizeof(struct buffdesc) * NTBUF);
+ if (kopiera)
+ initblock->ib_rdr -= (int)initblock;
+ (int)tdesc = QW_ALLOC(sizeof(struct buffdesc) * NTBUF) + addoff;
initblock->ib_tdr = (TLEN << 29) | (int)tdesc;
+ if (kopiera)
+ initblock->ib_tdr -= (int)initblock;
+ if (kopiera)
+ copyout(initblock, 0, sizeof(struct initblock));
for (i = 0; i < NRBUF; i++) {
- rdesc[i].bd_adrflg = alloc(BUFSIZE) | BR_OWN;
+ rdesc[i].bd_adrflg = QW_ALLOC(BUFSIZE) | BR_OWN;
+ if (kopiera)
+ rdesc[i].bd_adrflg -= (int)initblock;
rdesc[i].bd_bcnt = -BUFSIZE;
rdesc[i].bd_mcnt = 0;
}
+ if (kopiera)
+ copyout(rdesc, (int)rdesc - (int)initblock,
+ sizeof(struct buffdesc) * NRBUF);
for (i = 0; i < NTBUF; i++) {
- tdesc[i].bd_adrflg = alloc(BUFSIZE);
+ tdesc[i].bd_adrflg = QW_ALLOC(BUFSIZE);
+ if (kopiera)
+ tdesc[i].bd_adrflg -= (int)initblock;
tdesc[i].bd_bcnt = 0xf000;
tdesc[i].bd_mcnt = 0;
}
+ if (kopiera)
+ copyout(tdesc, (int)tdesc - (int)initblock,
+ sizeof(struct buffdesc) * NTBUF);
}
- LEWRCSR(LE_CSR1, (int)initblock & 0xffff);
- LEWRCSR(LE_CSR2, ((int)initblock >> 16) & 0xff);
+ if (kopiera) {
+ LEWRCSR(LE_CSR1, 0);
+ LEWRCSR(LE_CSR2, 0);
+ } else {
+ LEWRCSR(LE_CSR1, (int)initblock & 0xffff);
+ LEWRCSR(LE_CSR2, ((int)initblock >> 16) & 0xff);
+ }
LEWRCSR(LE_CSR0, LE_C0_INIT);
to = 100000;
- while (to--)
+ while (to--) {
if (LERDCSR(LE_CSR0) & LE_C0_IDON)
break;
+ if (LERDCSR(LE_CSR0) & LE_C0_ERR) {
+ printf("lance init error: csr0 %x\n", LERDCSR(LE_CSR0));
+ goto igen;
+ }
+ }
LEWRCSR(LE_CSR0, LE_C0_INEA | LE_C0_STRT | LE_C0_IDON);
}
@@ -219,6 +265,9 @@ retry:
csr = LERDCSR(LE_CSR0);
LEWRCSR(LE_CSR0, csr & (LE_C0_BABL|LE_C0_MISS|LE_C0_MERR|LE_C0_RINT));
+ if (kopiera)
+ copyin((int)&rdesc[next_rdesc] - (int)initblock,
+ &rdesc[next_rdesc], sizeof(struct buffdesc));
if (rdesc[next_rdesc].bd_adrflg & BR_OWN)
goto retry;
@@ -228,14 +277,23 @@ retry:
if ((len = rdesc[next_rdesc].bd_mcnt - 4) > maxlen)
len = maxlen;
- bcopy((void *)(rdesc[next_rdesc].bd_adrflg&0xffffff),pkt,len);
+ if (kopiera)
+ copyin((rdesc[next_rdesc].bd_adrflg&0xffffff),
+ pkt, len);
+ else
+ bcopy((void *)(rdesc[next_rdesc].bd_adrflg&0xffffff) +
+ addoff, pkt, len);
}
rdesc[next_rdesc].bd_mcnt = 0;
rdesc[next_rdesc].bd_adrflg |= BR_OWN;
+ if (kopiera)
+ copyout(&rdesc[next_rdesc], (int)&rdesc[next_rdesc] -
+ (int)initblock, sizeof(struct buffdesc));
if (++next_rdesc >= NRBUF)
next_rdesc = 0;
+
if (len == 0)
goto retry;
return len;
@@ -257,14 +315,24 @@ retry:
csr = LERDCSR(LE_CSR0);
LEWRCSR(LE_CSR0, csr & (LE_C0_MISS|LE_C0_CERR|LE_C0_TINT));
+ if (kopiera)
+ copyin((int)&tdesc[next_tdesc] - (int)initblock,
+ &tdesc[next_tdesc], sizeof(struct buffdesc));
if (tdesc[next_tdesc].bd_adrflg & BT_OWN)
goto retry;
- bcopy(pkt, (void *)(tdesc[next_tdesc].bd_adrflg & 0xffffff), len);
+ if (kopiera)
+ copyout(pkt, (tdesc[next_tdesc].bd_adrflg & 0xffffff), len);
+ else
+ bcopy(pkt, (void *)(tdesc[next_tdesc].bd_adrflg & 0xffffff) +
+ addoff, len);
tdesc[next_tdesc].bd_bcnt =
(len < ETHER_MIN_LEN ? -ETHER_MIN_LEN : -len);
tdesc[next_tdesc].bd_mcnt = 0;
tdesc[next_tdesc].bd_adrflg |= BT_OWN | BT_STP | BT_ENP;
+ if (kopiera)
+ copyout(&tdesc[next_tdesc], (int)&tdesc[next_tdesc] -
+ (int)initblock, sizeof(struct buffdesc));
LEWRCSR(LE_CSR0, LE_C0_TDMD);
@@ -281,3 +349,41 @@ retry:
return -1;
}
+
+void
+le_end()
+{
+ LEWRCSR(LE_CSR0, LE_C0_STOP);
+}
+
+void
+copyout(from, dest, len)
+ short *from;
+ int dest, len;
+{
+ short *toaddr;
+
+ toaddr = (short *)0x20120000 + dest;
+
+ while (len > 0) {
+ *toaddr = *from++;
+ toaddr += 2;
+ len -= 2;
+ }
+}
+
+void
+copyin(src, to, len)
+ short *to;
+ int src, len;
+{
+ short *fromaddr;
+
+ fromaddr = (short *)0x20120000 + src;
+
+ while (len > 0) {
+ *to++ = *fromaddr;
+ fromaddr += 2;
+ len -= 2;
+ }
+}
diff --git a/sys/arch/vax/stand/boot/if_qe.c b/sys/arch/vax/stand/boot/if_qe.c
new file mode 100644
index 00000000000..247f82a4728
--- /dev/null
+++ b/sys/arch/vax/stand/boot/if_qe.c
@@ -0,0 +1,276 @@
+/* $OpenBSD: if_qe.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: if_qe.c,v 1.2 1999/06/30 18:19:26 ragge Exp $ */
+
+/*
+ * Copyright (c) 1998 Roar Thronæs. 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 Roar Thronæs.
+ * 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.
+ *
+ * Standalone routine for the DEQNA.
+ */
+
+#include <sys/param.h>
+#include <sys/types.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+
+#include <lib/libsa/netif.h>
+
+#include <arch/vax/if/if_qereg.h>
+
+int qe_probe(), qe_match(), qe_get(), qe_put();
+void qe_init(), qe_end();
+
+struct netif_stats qe_stats;
+
+struct netif_dif qe_ifs[] = {
+/* dif_unit dif_nsel dif_stats dif_private */
+{ 0, 1, &qe_stats, },
+};
+
+struct netif_stats qe_stats;
+
+struct netif_driver qe_driver = {
+ "qe", qe_match, qe_probe, qe_init, qe_get, qe_put, qe_end, qe_ifs, 1,
+};
+
+#define PG_V 0x80000000
+#define QBAMAP 0x20088000
+
+#define NRCV 1 /* Receive descriptors */
+#define NXMT 1 /* Transmit descriptors */
+
+#define QE_INTS (QE_RCV_INT | QE_XMIT_INT)
+#define MAXPACKETSIZE 0x800 /* Because of (buggy) DEQNA */
+
+struct qe_softc {
+ struct qe_ring rring[NRCV+2]; /* Receive ring descriptors */
+ struct qe_ring tring[NXMT+2]; /* Xmit ring descriptors */
+ u_char setup_pkt[16][8]; /* Setup packet */
+ char qein[2048], qeout[2048];/* Packet buffers */
+};
+
+static volatile struct qe_softc *sc;
+static int addr;
+
+#define QE_WCSR(csr, val) \
+ (*((volatile u_short *)(addr + (csr))) = (val))
+#define QE_RCSR(csr) \
+ *((volatile u_short *)(addr + (csr)))
+#define DELAY(x) {volatile int i = x;while (--i);}
+#define LOWORD(x) ((int)(x) & 0xffff)
+#define HIWORD(x) (((int)(x) >> 16) & 0x3f)
+
+int
+qe_match(nif, machdep_hint)
+ struct netif *nif;
+ void *machdep_hint;
+{
+ return strcmp(machdep_hint, "qe") == 0;
+}
+
+int
+qe_probe(nif, machdep_hint)
+ struct netif *nif;
+ void *machdep_hint;
+{
+ return 0;
+}
+
+void
+qe_init(desc, machdep_hint)
+ struct iodesc *desc;
+ void *machdep_hint;
+{
+
+ int i,j;
+ u_int *qm=(u_int *) QBAMAP;
+
+ sc = (void *)alloc(sizeof(struct qe_softc));
+
+ bzero(sc,sizeof(struct qe_softc));
+
+ for(i = 0; i < 8192; i++)
+ qm[i] = PG_V | i;
+
+ /* XXX hardcoded addr */
+ addr = (0x20000000 + (0774440 & 017777));
+
+ QE_WCSR(QE_CSR_CSR, QE_RESET);
+ QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) & ~QE_RESET);
+
+ for (i = 0; i < 6; i++) {
+ sc->setup_pkt[i][1] = QE_RCSR(i * 2);
+ sc->setup_pkt[i+8][1] = QE_RCSR(i * 2);
+ sc->setup_pkt[i][2] = 0xff;
+ sc->setup_pkt[i+8][2] = QE_RCSR(i * 2);
+ for (j=3; j < 8; j++) {
+ sc->setup_pkt[i][j] = QE_RCSR(i * 2);
+ sc->setup_pkt[i+8][j] = QE_RCSR(i * 2);
+ }
+ desc->myea[i] = QE_RCSR(i * 2);
+ }
+
+ bzero((caddr_t)sc->rring, sizeof(struct qe_ring));
+ sc->rring->qe_buf_len = -64;
+ sc->rring->qe_addr_lo = (short)((int)sc->setup_pkt);
+ sc->rring->qe_addr_hi = (short)((int)sc->setup_pkt >> 16);
+
+ bzero((caddr_t)sc->tring, sizeof(struct qe_ring));
+ sc->tring->qe_buf_len = -64;
+ sc->tring->qe_addr_lo = (short)((int)sc->setup_pkt);
+ sc->tring->qe_addr_hi = (short)((int)sc->setup_pkt >> 16);
+
+ sc->rring[0].qe_flag = sc->rring[0].qe_status1 = QE_NOTYET;
+ sc->rring->qe_addr_hi |= QE_VALID;
+
+ sc->tring[0].qe_flag = sc->tring[0].qe_status1 = QE_NOTYET;
+ sc->tring->qe_addr_hi |= QE_VALID | QE_SETUP | QE_EOMSG;
+
+ QE_WCSR(QE_CSR_CSR, QE_XMIT_INT | QE_RCV_INT);
+
+ QE_WCSR(QE_CSR_RCLL, LOWORD(sc->rring));
+ QE_WCSR(QE_CSR_RCLH, HIWORD(sc->rring));
+ QE_WCSR(QE_CSR_XMTL, LOWORD(sc->tring));
+ QE_WCSR(QE_CSR_XMTH, HIWORD(sc->tring));
+
+ while ((QE_RCSR(QE_CSR_CSR) & QE_INTS) != QE_INTS)
+ ;
+ QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) | QE_INTS);
+ QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) & ~(QE_INT_ENABLE|QE_ELOOP));
+ QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) | QE_ILOOP);
+
+ sc->rring[0].qe_addr_lo = (short)((int)sc->qein & 0xffff);
+ sc->rring[0].qe_addr_hi = (short)((int)sc->qein >> 16);
+ sc->rring[0].qe_buf_len=-MAXPACKETSIZE/2;
+ sc->rring[0].qe_addr_hi |= QE_VALID;
+ sc->rring[0].qe_flag=sc->rring[0].qe_status1=QE_NOTYET;
+ sc->rring[0].qe_status2=1;
+
+ sc->rring[1].qe_addr_lo = 0;
+ sc->rring[1].qe_addr_hi = 0;
+ sc->rring[1].qe_flag=sc->rring[1].qe_status1=QE_NOTYET;
+ sc->rring[1].qe_status2=1;
+
+ sc->tring[0].qe_addr_lo = (short)((int)sc->qeout & 0xffff);
+ sc->tring[0].qe_addr_hi = (short)((int)sc->qeout >> 16);
+ sc->tring[0].qe_buf_len=0;
+ sc->tring[0].qe_flag=sc->tring[0].qe_status1=QE_NOTYET;
+ sc->tring[0].qe_addr_hi |= QE_EOMSG|QE_VALID;
+
+ sc->tring[1].qe_flag=sc->tring[1].qe_status1=QE_NOTYET;
+ sc->tring[1].qe_addr_lo = 0;
+ sc->tring[1].qe_addr_hi = 0;
+
+ QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) | QE_RCV_ENABLE);
+ QE_WCSR(QE_CSR_RCLL, LOWORD(sc->rring));
+ QE_WCSR(QE_CSR_RCLH, HIWORD(sc->rring));
+}
+
+int
+qe_get(desc, pkt, maxlen, timeout)
+ struct iodesc *desc;
+ void *pkt;
+ int maxlen;
+ time_t timeout;
+{
+ int len, j;
+
+retry:
+ for(j = 0x10000;j && (QE_RCSR(QE_CSR_CSR) & QE_RCV_INT) == 0; j--)
+ ;
+
+ if ((QE_RCSR(QE_CSR_CSR) & QE_RCV_INT) == 0)
+ goto fail;
+
+ QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) & ~(QE_RCV_ENABLE|QE_XMIT_INT));
+
+ len= ((sc->rring[0].qe_status1 & QE_RBL_HI) |
+ (sc->rring[0].qe_status2 & QE_RBL_LO)) + 60;
+
+ if (sc->rring[0].qe_status1 & 0xc000)
+ goto fail;
+
+ if (len == 0)
+ goto retry;
+
+ bcopy((void*)sc->qein,pkt,len);
+
+
+end:
+ sc->rring[0].qe_status2 = sc->rring[1].qe_status2 = 1;
+ sc->rring[0].qe_flag=sc->rring[0].qe_status1=QE_NOTYET;
+ sc->rring[1].qe_flag=sc->rring[1].qe_status1=QE_NOTYET;
+ QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) | QE_RCV_ENABLE);
+
+ QE_WCSR(QE_CSR_RCLL, LOWORD(sc->rring));
+ QE_WCSR(QE_CSR_RCLH, HIWORD(sc->rring));
+ return len;
+
+fail: len = -1;
+ goto end;
+}
+
+int
+qe_put(desc, pkt, len)
+ struct iodesc *desc;
+ void *pkt;
+ int len;
+{
+ int j;
+
+ bcopy(pkt,sc->qeout,len);
+ sc->tring[0].qe_buf_len=-len/2;
+ sc->tring[0].qe_flag=sc->tring[0].qe_status1=QE_NOTYET;
+ sc->tring[1].qe_flag=sc->tring[1].qe_status1=QE_NOTYET;
+
+ QE_WCSR(QE_CSR_XMTL, LOWORD(sc->tring));
+ QE_WCSR(QE_CSR_XMTH, HIWORD(sc->tring));
+
+ for(j = 0; (j < 0x10000) && ((QE_RCSR(QE_CSR_CSR) & QE_XMIT_INT) == 0); j++)
+ ;
+
+ if ((QE_RCSR(QE_CSR_CSR) & QE_XMIT_INT) == 0) {
+ qe_init(desc,0);
+ return -1;
+ }
+ QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) & ~QE_RCV_INT);
+
+ if (sc->tring[0].qe_status1 & 0xc000) {
+ qe_init(desc,0);
+ return -1;
+ }
+ return len;
+}
+
+void
+qe_end(nif)
+ struct netif *nif;
+{
+ QE_WCSR(QE_CSR_CSR, QE_RESET);
+ QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) & ~QE_RESET);
+}
diff --git a/sys/arch/vax/stand/boot/if_ze.c b/sys/arch/vax/stand/boot/if_ze.c
new file mode 100644
index 00000000000..89a4c43290e
--- /dev/null
+++ b/sys/arch/vax/stand/boot/if_ze.c
@@ -0,0 +1,304 @@
+/* $OpenBSD: if_ze.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: if_ze.c,v 1.5 1999/08/23 19:09:27 ragge Exp $ */
+/*
+ * Copyright (c) 1998 James R. Maynard III. 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 James R. Maynard III.
+ * 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.
+ *
+ * Standalone routine for the SGEC Ethernet controller.
+ */
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/queue.h>
+
+#include <net/if.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/if_ether.h>
+
+#include <lib/libkern/libkern.h>
+#include <lib/libsa/netif.h>
+#include <lib/libsa/stand.h>
+
+#include <arch/vax/if/sgecreg.h>
+
+#include "arch/vax/include/sid.h"
+
+int ze_probe(), ze_match(), ze_get(), ze_put();
+void ze_init(), ze_end();
+
+struct netif_stats ze_stats;
+
+struct netif_dif ze_ifs[] = {
+/* dif_unit dif_nsel dif_stats dif_private */
+{ 0, 1, &ze_stats, },
+};
+
+struct netif_stats ze_stats;
+
+#define ETHER_MIN_LEN 64
+#define ETHER_MAX_LEN 1518
+
+struct netif_driver ze_driver = {
+ "ze", ze_match, ze_probe, ze_init, ze_get, ze_put, ze_end, ze_ifs, 1,
+};
+
+#define NRCV 5 /* allocate 5 receive descriptors */
+#define NXMT 5 /* and 5 transmit - must be >1 */
+#define SETUP_FRAME_LEN 128 /* length of the setup frame */
+
+/* allocate a buffer on an octaword boundary */
+#define OW_ALLOC(x) ((void *)((int)(alloc((x) + 15) + 15) & ~15))
+
+static volatile struct zedevice *addr;
+
+struct ze_tdes *ze_tdes_list; /* transmit desc list */
+struct ze_rdes *ze_rdes_list; /* and receive desc list */
+u_char ze_myaddr[ETHER_ADDR_LEN]; /* my Ethernet address */
+
+int
+ze_match(nif, machdep_hint)
+ struct netif *nif;
+ void *machdep_hint;
+{
+ return strcmp(machdep_hint, "ze") == 0;
+}
+
+int
+ze_probe(nif, machdep_hint)
+ struct netif *nif;
+ void *machdep_hint;
+{
+ return 0;
+}
+
+void
+ze_init(desc, machdep_hint)
+ struct iodesc *desc;
+ void *machdep_hint;
+{
+ u_long nicsr0_work, *nisa_rom;
+ int i;
+ u_char *saved_buf;
+ struct ze_tdes *ze_setup_tdes_list;
+
+ /* point to the device in memory */
+ addr = (struct zedevice *)0x20008000;
+
+ /* reset the device and wait for completion */
+ addr->ze_nicsr6 = ZE_NICSR6_MBO | ZE_NICSR6_RE;
+ while ((addr->ze_nicsr5 & ZE_NICSR5_ID) == 0)
+ ;
+ if (addr->ze_nicsr5 & ZE_NICSR5_SF) {
+ printf("SGEC self-test failed...\n");
+ }
+
+ /* Get our Ethernet address */
+ if (vax_boardtype == VAX_BTYP_49) {
+ nisa_rom = (u_long *)0x27800000;
+ for (i=0; i<ETHER_ADDR_LEN; i++)
+ ze_myaddr[i] = nisa_rom[i] & 0377;
+ } else {
+ nisa_rom = (u_long *)0x20084000;
+ for (i=0; i<ETHER_ADDR_LEN; i++)
+ ze_myaddr[i] = (nisa_rom[i] & 0x0000ff00) >> 8;
+ }
+ bcopy(ze_myaddr,desc->myea,ETHER_ADDR_LEN);
+
+ /* initialize SGEC operating mode */
+ /* disable interrupts here */
+ nicsr0_work = ZE_NICSR0_IPL14 | ZE_NICSR0_SA | ZE_NICSR0_MBO |
+ (ZE_NICSR0_IV_MASK & 0x0108);
+ while (addr->ze_nicsr0 != nicsr0_work)
+ addr->ze_nicsr0 = nicsr0_work;
+ if (addr->ze_nicsr5 & ZE_NICSR5_ME)
+ addr->ze_nicsr5 |= ZE_NICSR5_ME;
+ /* reenable interrupts here */
+
+ /* Allocate space for descriptor lists and buffers,
+ then initialize them. Set up both lists as a ring. */
+ ze_rdes_list = OW_ALLOC((NRCV+1) * sizeof(struct ze_rdes));
+ ze_tdes_list = OW_ALLOC((NXMT+1) * sizeof(struct ze_tdes));
+ for (i=0; i < NRCV; i++) {
+ bzero(ze_rdes_list+i,sizeof(struct ze_rdes));
+ ze_rdes_list[i].ze_framelen = ZE_FRAMELEN_OW;
+ ze_rdes_list[i].ze_bufsize = ETHER_MAX_LEN;
+ ze_rdes_list[i].ze_bufaddr = alloc(ETHER_MAX_LEN);
+ }
+ bzero(ze_rdes_list+NRCV,sizeof(struct ze_rdes));
+ ze_rdes_list[NRCV].ze_framelen = ZE_FRAMELEN_OW;
+ ze_rdes_list[NRCV].ze_rdes1 = ZE_RDES1_CA;
+ ze_rdes_list[NRCV].ze_bufaddr = (u_char *)ze_rdes_list;
+ for (i=0; i < NXMT; i++) {
+ bzero(ze_tdes_list+i,sizeof(struct ze_tdes));
+ ze_tdes_list[i].ze_tdes1 = ZE_TDES1_FS | ZE_TDES1_LS;
+ ze_tdes_list[i].ze_bufsize = ETHER_MAX_LEN;
+ ze_tdes_list[i].ze_bufaddr = alloc(ETHER_MAX_LEN);
+ }
+ bzero(ze_tdes_list+NXMT,sizeof(struct ze_tdes));
+ ze_tdes_list[NXMT].ze_tdes1 = ZE_TDES1_CA;
+ ze_tdes_list[NXMT].ze_tdr = ZE_TDR_OW;
+ ze_tdes_list[NXMT].ze_bufaddr = (u_char *)ze_tdes_list;
+
+ /* Build setup frame. We set the SGEC to do a
+ perfect filter on our own address. */
+ ze_setup_tdes_list = OW_ALLOC(2*sizeof(struct ze_tdes));
+ bzero(ze_setup_tdes_list+0,2*sizeof(struct ze_tdes));
+ ze_setup_tdes_list[0].ze_tdr = ZE_TDR_OW;
+ ze_setup_tdes_list[0].ze_tdes1 = ZE_TDES1_DT_SETUP;
+ ze_setup_tdes_list[0].ze_bufsize = SETUP_FRAME_LEN;
+ ze_setup_tdes_list[0].ze_bufaddr = alloc(SETUP_FRAME_LEN);
+ bzero(ze_setup_tdes_list[0].ze_bufaddr,SETUP_FRAME_LEN);
+ for (i=0; i < 16; i++)
+ bcopy(ze_myaddr,ze_setup_tdes_list[0].ze_bufaddr+(8*i),
+ ETHER_ADDR_LEN);
+ ze_setup_tdes_list[1].ze_tdes1 = ZE_TDES1_CA;
+ ze_setup_tdes_list[1].ze_bufaddr = (u_char *)ze_setup_tdes_list;
+
+ /* Start the transmitter and initialize almost everything else. */
+ addr->ze_nicsr4 = ze_setup_tdes_list;
+ addr->ze_nicsr6 = ZE_NICSR6_MBO | ZE_NICSR6_SE | ZE_NICSR6_ST |
+ ZE_NICSR6_DC | ZE_NICSR6_BL_4;
+ while ((addr->ze_nicsr5 & ZE_NICSR5_TS) != ZE_NICSR5_TS_SUSP)
+ ; /* wait for the frame to be processed */
+
+ /* Setup frame is done processing, initialize the receiver and
+ point the transmitter to the real tdes list. */
+ addr->ze_nicsr4 = ze_tdes_list;
+ addr->ze_nicsr3 = ze_rdes_list;
+ addr->ze_nicsr6 |= ZE_NICSR6_SR;
+
+ /* And away-y-y we go! */
+}
+
+int
+ze_get(desc, pkt, maxlen, timeout)
+ struct iodesc *desc;
+ void *pkt;
+ int maxlen;
+ time_t timeout;
+{
+ int timeout_ctr=100000*timeout, len, rdes;
+
+ while (timeout_ctr-- > 0) {
+
+ /* If there's not a packet waiting for us, just decrement the
+ timeout counter. */
+ if (!(addr->ze_nicsr5 & ZE_NICSR5_RI))
+ continue;
+
+ /* Look through the receive descriptor list for the packet. */
+ for (rdes=0; rdes<NRCV; rdes++) {
+ if (ze_rdes_list[rdes].ze_framelen & ZE_FRAMELEN_OW)
+ continue;
+
+ /* If the packet has an error, ignore it. */
+ if (ze_rdes_list[rdes].ze_rdes0 & ZE_RDES0_ES)
+ len = 0;
+
+ /* Copy the packet, up to the length supplied by the caller, to
+ the caller's buffer. */
+ else {
+ if ((len = (ze_rdes_list[rdes].ze_framelen &
+ (~ ZE_FRAMELEN_OW))) > maxlen)
+ len = maxlen;
+ bcopy((void *)ze_rdes_list[rdes].ze_bufaddr,
+ pkt,len);
+ }
+
+ /* Give ownership of this descriptor back to the SGEC. */
+ ze_rdes_list[rdes].ze_framelen = ZE_FRAMELEN_OW;
+
+ /* If we actually got a good packet, reset the error flags and
+ tell the SGEC to look for more before returning. */
+ if (len > 0) {
+ addr->ze_nicsr5=ZE_NICSR5_RU | ZE_NICSR5_RI |
+ ZE_NICSR5_IS;
+ addr->ze_nicsr2=ZE_NICSR2_RXPD;
+ return len;
+ }
+ }
+ }
+
+ /* If we're going to return an error indication, at least reset the
+ error flags and tell the SGEC to keep receiving first. */
+ addr->ze_nicsr5=ZE_NICSR5_RU | ZE_NICSR5_RI | ZE_NICSR5_IS;
+ addr->ze_nicsr2=ZE_NICSR2_RXPD;
+ return 0;
+}
+
+int
+ze_put(desc, pkt, len)
+ struct iodesc *desc;
+ void *pkt;
+ int len;
+{
+ int timeout=100000;
+
+ /* The SGEC maintains its position in the transmit descriptor list
+ for the next frame to transmit. Unfortunately, there's no way to tell
+ from software just where that is. We're forced to reset the position
+ whenever we send a frame, which requires waiting for the previous
+ frame to be sent. Argh. */
+ while ((addr->ze_nicsr5 & ZE_NICSR5_TS) == ZE_NICSR5_TS_RUN)
+ ;
+
+ /* Copy the packet to the buffer we allocated. */
+ bcopy(pkt, (void *)ze_tdes_list[0].ze_bufaddr, len);
+
+ /* Set the packet length in the descriptor, increasing it to the
+ minimum size if needed. */
+ ze_tdes_list[0].ze_bufsize = len;
+ if (len < ETHER_MIN_LEN)
+ ze_tdes_list[0].ze_bufsize = ETHER_MIN_LEN;
+
+ /* Give ownership of the descriptor to the SGEC and tell it to start
+ transmitting. */
+ ze_tdes_list[0].ze_tdr = ZE_TDR_OW;
+ addr->ze_nicsr4 = ze_tdes_list;
+ addr->ze_nicsr1 = ZE_NICSR1_TXPD;
+
+ /* Wait for the frame to be sent, but not too long. */
+ timeout = 100000;
+ while ((addr->ze_nicsr5 & ZE_NICSR5_TI == 0) && (--timeout>0))
+ ;
+
+ /* Reset the transmitter interrupt pending flag. */
+ addr->ze_nicsr5 |= ZE_NICSR5_TI;
+
+ /* Return good if we didn't timeout, or error if we did. */
+ if (timeout>0) return len;
+ return -1;
+}
+
+void
+ze_end()
+{
+ addr->ze_nicsr6 = ZE_NICSR6_RE;
+}
diff --git a/sys/arch/vax/stand/mfm.c b/sys/arch/vax/stand/boot/mfm.c
index 20465089651..33fbbbc3065 100644
--- a/sys/arch/vax/stand/mfm.c
+++ b/sys/arch/vax/stand/boot/mfm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfm.c,v 1.4 1998/05/13 07:30:23 niklas Exp $ */
+/* $OpenBSD: mfm.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
/* $NetBSD: mfm.c,v 1.2 1997/03/15 13:04:28 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
diff --git a/sys/arch/vax/boot/netio.c b/sys/arch/vax/stand/boot/netio.c
index 99c58e02615..bbc01d23acc 100644
--- a/sys/arch/vax/boot/netio.c
+++ b/sys/arch/vax/stand/boot/netio.c
@@ -1,8 +1,43 @@
-/* $OpenBSD: netio.c,v 1.1 1998/02/03 11:48:28 maja Exp $ */
-/* $NetBSD: netio.c,v 1.1 1997/03/15 13:04:29 ragge Exp $ */
+/* $OpenBSD: netio.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: netio.c,v 1.4 1999/06/30 18:38:03 ragge Exp $ */
+
+/*-
+ * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
/*
- * Copyright (c) 1995, 1996 Jason R. Thorpe
* Copyright (c) 1995 Gordon W. Ross
* All rights reserved.
*
@@ -57,12 +92,11 @@
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
-#include "stand.h"
-#include "samachdep.h"
-#include "net.h"
-#include "netif.h"
-#include "bootparam.h"
-#include "nfs.h"
+#include "lib/libsa/stand.h"
+#include "lib/libsa/net.h"
+#include "lib/libsa/netif.h"
+#include "lib/libsa/bootparam.h"
+#include "lib/libsa/nfs.h"
extern int nfs_root_node[]; /* XXX - get from nfs_mount() */
@@ -77,9 +111,6 @@ int netio_ask = 0; /* default to bootparam, can override */
static char input_line[100];
-/* Why be any different? */
-#define SUN_BOOTPARAMS
-
/*
* Called by devopen after it sets f->f_dev to our devsw entry.
* This opens the low-level device and sets f->f_devdata.
@@ -108,10 +139,7 @@ int
netclose(f)
struct open_file *f;
{
- /* On last close, do netif close, etc. */
- if (open_count > 0)
- if (--open_count == 0)
- netif_close(netdev_sock);
+ netif_close(netdev_sock);
f->f_devdata = NULL;
}
@@ -200,41 +228,46 @@ netmountroot(f, devname)
* 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 (errno);
-
- printf("boot: client IP address: %s\n", inet_ntoa(myip));
+#ifdef SUPPORT_BOOTP
- /* Get our hostname, server IP address. */
- if (bp_whoami(netdev_sock))
- return (errno);
+ /* Get boot info using BOOTP way. (RFC951, RFC1048) */
+ printf("Trying BOOTP\n");
+ bootp(netdev_sock);
- printf("boot: client name: %s\n", hostname);
+ if (myip.s_addr) {
+ printf("Using IP address: %s\n", inet_ntoa(myip));
- /* Get the root pathname. */
- if (bp_getfile(netdev_sock, "root", &rootip, rootpath))
- return (errno);
+ printf("myip: %s (%s)", hostname, inet_ntoa(myip));
+ if (gateip.s_addr)
+ printf(", gateip: %s", inet_ntoa(gateip));
+ if (netmask)
+ printf(", mask: %s", intoa(netmask));
+ printf("\n");
+ } else
-#else
+#endif /* SUPPORT_BOOTP */
+ {
+#ifdef SUPPORT_BOOTPARAMS
+ /* Get boot info using RARP and Sun bootparams. */
- /* Get boot info using BOOTP way. (RFC951, RFC1048) */
- bootp(netdev_sock);
+ printf("Trying BOOTPARAMS\n");
+ /* Get our IP address. (rarp.c) */
+ if (rarp_getipaddress(netdev_sock) == -1)
+ return (errno);
- printf("Using IP address: %s\n", inet_ntoa(myip));
+ printf("boot: client IP address: %s\n", inet_ntoa(myip));
- printf("myip: %s (%s)", hostname, inet_ntoa(myip));
- if (gateip)
- printf(", gateip: %s", inet_ntoa(gateip));
- if (mask)
- printf(", mask: %s", intoa(netmask));
- printf("\n");
+ /* Get our hostname, server IP address. */
+ if (bp_whoami(netdev_sock))
+ return (errno);
-#endif /* SUN_BOOTPARAMS */
+ printf("boot: client name: %s\n", hostname);
+ /* Get the root pathname. */
+ if (bp_getfile(netdev_sock, "root", &rootip, rootpath))
+ return (errno);
+#endif
+ }
printf("root addr=%s path=%s\n", inet_ntoa(rootip), rootpath);
do_nfs_mount:
diff --git a/sys/arch/vax/boot/ra.c b/sys/arch/vax/stand/boot/ra.c
index c349d2ec463..96be3fcfc00 100644
--- a/sys/arch/vax/boot/ra.c
+++ b/sys/arch/vax/stand/boot/ra.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: ra.c,v 1.5 1998/05/13 07:30:24 niklas Exp $ */
-/* $NetBSD: ra.c,v 1.5 1996/08/02 11:22:18 ragge Exp $ */
+/* $OpenBSD: ra.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: ra.c,v 1.4 1999/08/07 11:19:04 ragge Exp $ */
/*
* Copyright (c) 1995 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -41,22 +41,20 @@
#include "lib/libsa/stand.h"
#include "../include/pte.h"
-#include "../include/macros.h"
#include "../include/sid.h"
-#include "../uba/ubareg.h"
-#include "../uba/udareg.h"
+#include "arch/vax/mscp/mscp.h"
+#include "arch/vax/mscp/mscpreg.h"
-#include "../mscp/mscp.h"
-#include "../mscp/mscpreg.h"
-
-#include "../bi/bireg.h"
-#include "../bi/kdbreg.h"
+#include "arch/vax/bi/bireg.h"
+#include "arch/vax/bi/kdbreg.h"
#include "vaxstand.h"
static command(int);
+
+
/*
* These routines for RA disk standalone boot is wery simple,
* assuming a lots of thing like that we only working at one ra disk
@@ -82,7 +80,6 @@ volatile struct uda {
} uda;
volatile struct uda *ubauda;
-volatile struct udadevice *udacsr;
struct disklabel ralabel;
struct ra_softc ra_softc;
char io_buf[DEV_BSIZE];
@@ -94,11 +91,14 @@ raopen(f, adapt, ctlr, unit, part)
char *msg;
struct disklabel *lp = &ralabel;
volatile struct ra_softc *ra = &ra_softc;
- volatile struct uba_regs *mr = (void *)ubaaddr[adapt];
volatile u_int *nisse;
unsigned short johan, johan2;
- int i,err;
+ int i,err, udacsr;
+#ifdef DEV_DEBUG
+ printf("raopen: adapter %d ctlr %d unit %d part %d\n",
+ adapt, ctlr, unit, part);
+#endif
bzero(lp, sizeof(struct disklabel));
ra->unit = unit;
ra->part = part;
@@ -107,50 +107,63 @@ raopen(f, adapt, ctlr, unit, part)
return(EADAPT);
if (ctlr > nuda)
return(ECTLR);
- nisse = (u_int *)&mr->uba_map[0];
+ nisse = ((u_int *)ubaaddr[adapt]) + 512;
nisse[494] = PG_V | (((u_int)&uda) >> 9);
nisse[495] = nisse[494] + 1;
- udacsr = (void*)uioaddr[adapt] + udaaddr[ctlr];
+ udacsr = (int)uioaddr[adapt] + udaaddr[ctlr];
ubauda = (void*)0x3dc00 + (((u_int)(&uda))&0x1ff);
johan = (((u_int)ubauda) & 0xffff) + 8;
johan2 = 3;
- ra->ra_ip = (short *)&udacsr->udaip;
- ra->ra_sa = ra->ra_sw = (short *)&udacsr->udasa;
+ ra->ra_ip = (short *)udacsr;
+ ra->ra_sa = ra->ra_sw = (short *)udacsr + 1;
ra->udaddr = uioaddr[adapt] + udaaddr[ctlr];
- ra->ubaddr = (int)mr;
+ ra->ubaddr = (int)ubaaddr[adapt];
*ra->ra_ip = 0; /* Start init */
} else {
- struct bi_node *bi = (void *)biaddr[adapt];
- struct kdb_regs *kb = (void *)&bi[ctlr];
+ paddr_t kdaddr = (paddr_t)biaddr[adapt] + BI_NODE(ctlr);
+ volatile int *w;
volatile int i = 10000;
- ra->ra_ip = &kb->kdb_ip;
- ra->ra_sa = &kb->kdb_sa;
- ra->ra_sw = &kb->kdb_sw;
+ ra->ra_ip = (short *)(kdaddr + KDB_IP);
+ ra->ra_sa = (short *)(kdaddr + KDB_SA);
+ ra->ra_sw = (short *)(kdaddr + KDB_SW);
johan = ((u_int)&uda.uda_ca.ca_rspdsc) & 0xffff;
johan2 = (((u_int)&uda.uda_ca.ca_rspdsc) & 0xffff0000) >> 16;
- kb->kdb_bi.bi_csr |= BICSR_NRST;
+ w = (int *)(kdaddr + BIREG_VAXBICSR);
+ *w = *w | BICSR_NRST;
while (i--) /* Need delay??? */
;
- kb->kdb_bi.bi_ber = ~(BIBER_MBZ|BIBER_NMR|BIBER_UPEN);/* ??? */
+ w = (int *)(kdaddr + BIREG_BER);
+ *w = ~(BIBER_MBZ|BIBER_NMR|BIBER_UPEN);/* ??? */
ubauda = &uda;
}
/* Init of this uda */
while ((*ra->ra_sa & MP_STEP1) == 0)
;
-
+#ifdef DEV_DEBUG
+ printf("MP_STEP1...");
+#endif
*ra->ra_sw = 0x8000;
while ((*ra->ra_sa & MP_STEP2) == 0)
;
+#ifdef DEV_DEBUG
+ printf("MP_STEP2...");
+#endif
*ra->ra_sw = johan;
while ((*ra->ra_sa & MP_STEP3) == 0)
;
+#ifdef DEV_DEBUG
+ printf("MP_STEP3...");
+#endif
*ra->ra_sw = johan2;
while ((*ra->ra_sa & MP_STEP4) == 0)
;
+#ifdef DEV_DEBUG
+ printf("MP_STEP4\n");
+#endif
*ra->ra_sw = 0x0001;
uda.uda_ca.ca_rspdsc = (int)&ubauda->uda_rsp.mscp_cmdref;
@@ -160,12 +173,18 @@ raopen(f, adapt, ctlr, unit, part)
uda.uda_cmd.mscp_unit = ra->unit;
command(M_OP_ONLINE);
+#ifdef DEV_DEBUG
+ printf("reading disklabel\n");
+#endif
err = rastrategy(ra,F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i);
if(err){
printf("reading disklabel: %s\n",strerror(err));
return 0;
}
+#ifdef DEV_DEBUG
+ printf("getting disklabel\n");
+#endif
msg = getdisklabel(io_buf+LABELOFFSET, lp);
if (msg)
printf("getdisklabel: %s\n", msg);
@@ -183,10 +202,15 @@ command(cmd)
uda.uda_rsp.mscp_msglen = MSCP_MSGLEN;
uda.uda_ca.ca_rspdsc |= MSCP_OWN|MSCP_INT;
uda.uda_ca.ca_cmddsc |= MSCP_OWN|MSCP_INT;
+#ifdef DEV_DEBUG
+ printf("sending cmd %x...", cmd);
+#endif
hej = *ra_softc.ra_ip;
while(uda.uda_ca.ca_rspdsc<0)
;
-
+#ifdef DEV_DEBUG
+ printf("sent.\n");
+#endif
}
rastrategy(ra, func, dblk, size, buf, rsize)
@@ -196,22 +220,18 @@ rastrategy(ra, func, dblk, size, buf, rsize)
char *buf;
u_int size, *rsize;
{
- volatile struct uba_regs *ur;
- volatile struct udadevice *udadev;
volatile u_int *ptmapp;
struct disklabel *lp;
u_int i, j, pfnum, mapnr, nsize;
volatile int hej;
-
if (vax_cputype != VAX_8200) {
- ur = (void *)ra->ubaddr;
- udadev = (void*)ra->udaddr;
- ptmapp = (u_int *)&ur->uba_map[0];
+ ptmapp = ((u_int *)ra->ubaddr) + 512;
- pfnum = (u_int)buf >> PGSHIFT;
+ pfnum = (u_int)buf >> VAX_PGSHIFT;
- for(mapnr = 0, nsize = size; (nsize + NBPG) > 0; nsize -= NBPG)
+ for(mapnr = 0, nsize = size; (nsize + VAX_NBPG) > 0;
+ nsize -= VAX_NBPG)
ptmapp[mapnr++] = PG_V | pfnum++;
uda.uda_cmd.mscp_seq.seq_buffer = ((u_int)buf) & 0x1ff;
} else
@@ -222,6 +242,10 @@ rastrategy(ra, func, dblk, size, buf, rsize)
dblk + lp->d_partitions[ra->part].p_offset;
uda.uda_cmd.mscp_seq.seq_bytecount = size;
uda.uda_cmd.mscp_unit = ra->unit;
+#ifdef DEV_DEBUG
+ printf("rastrategy: blk 0x%lx count %lx unit %lx\n",
+ uda.uda_cmd.mscp_seq.seq_lbn, size, ra->unit);
+#endif
if (func == F_WRITE)
command(M_OP_WRITE);
else
diff --git a/sys/arch/vax/stand/rom.c b/sys/arch/vax/stand/boot/rom.c
index 1e14e6049a4..8e36badc906 100644
--- a/sys/arch/vax/stand/rom.c
+++ b/sys/arch/vax/stand/boot/rom.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rom.c,v 1.3 1998/05/13 07:30:26 niklas Exp $ */
+/* $OpenBSD: rom.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
/* $NetBSD: rom.c,v 1.1 1996/08/02 11:22:21 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
diff --git a/sys/arch/vax/boot/tmscp.c b/sys/arch/vax/stand/boot/tmscp.c
index 90ca7e9fa48..5dbd5aef582 100644
--- a/sys/arch/vax/boot/tmscp.c
+++ b/sys/arch/vax/stand/boot/tmscp.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: tmscp.c,v 1.5 1998/02/03 11:48:30 maja Exp $ */
-/* $NetBSD: tmscp.c,v 1.4 1997/03/15 13:04:31 ragge Exp $ */
+/* $OpenBSD: tmscp.c,v 1.1 2000/04/27 02:26:25 bjc Exp $ */
+/* $NetBSD: tmscp.c,v 1.3 1999/06/30 18:19:26 ragge Exp $ */
/*
* Copyright (c) 1995 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -41,11 +41,8 @@
#include "lib/libsa/stand.h"
#include "../include/pte.h"
-#include "../include/macros.h"
-#include "../uba/ubareg.h"
-#include "../uba/udareg.h"
-#include "../mscp/mscp.h"
-#include "../mscp/mscpreg.h"
+#include "arch/vax/mscp/mscp.h"
+#include "arch/vax/mscp/mscpreg.h"
#include "vaxstand.h"
@@ -70,9 +67,16 @@ static volatile struct uda {
struct mscp uda_cmd; /* command packets */
} uda;
+struct udadevice {
+ short udaip;
+ short udasa;
+};
+
static volatile struct uda *ubauda;
static volatile struct udadevice *udacsr;
static struct ra_softc ra_softc;
+static int curblock;
+
tmscpopen(f, adapt, ctlr, unit, part)
struct open_file *f;
@@ -81,18 +85,18 @@ tmscpopen(f, adapt, ctlr, unit, part)
char *msg;
extern u_int tmsaddr;
volatile struct ra_softc *ra=&ra_softc;
- volatile struct uba_regs *mr=(void *)ubaaddr[adapt];
volatile u_int *nisse;
unsigned short johan;
int i,err;
+ curblock = 0;
if(adapt>nuba) return(EADAPT);
if(ctlr>nuda) return(ECTLR);
ra->udaddr=uioaddr[adapt]+tmsaddr;
- ra->ubaddr=(int)mr;
+ ra->ubaddr=(int)ubaaddr[adapt];
ra->unit=unit;
udacsr=(void*)ra->udaddr;
- nisse=(u_int *)&mr->uba_map[0];
+ nisse=((u_int *)ubaaddr[adapt]) + 512;
nisse[494]=PG_V|(((u_int)&uda)>>9);
nisse[495]=nisse[494]+1;
ubauda=(void*)0x3dc00+(((u_int)(&uda))&0x1ff);
@@ -153,8 +157,6 @@ command(cmd, arg)
}
-static int curblock = 0;
-
tmscpstrategy(ra, func, dblk, size, buf, rsize)
struct ra_softc *ra;
int func;
@@ -163,14 +165,13 @@ tmscpstrategy(ra, func, dblk, size, buf, rsize)
u_int size, *rsize;
{
u_int i,j,pfnum, mapnr, nsize, bn, cn, sn, tn;
- volatile struct uba_regs *ur=(void *)ra->ubaddr;
volatile struct udadevice *udadev=(void*)ra->udaddr;
- volatile u_int *ptmapp = (u_int *)&ur->uba_map[0];
+ volatile u_int *ptmapp = (u_int *)ra->ubaddr + 512;
volatile int hej;
- pfnum=(u_int)buf>>PGSHIFT;
+ pfnum=(u_int)buf>>VAX_PGSHIFT;
- for(mapnr=0, nsize=size;(nsize+NBPG)>0;nsize-=NBPG)
+ for(mapnr=0, nsize=size;(nsize+VAX_NBPG)>0;nsize-=VAX_NBPG)
ptmapp[mapnr++]=PG_V|pfnum++;
/*
diff --git a/sys/arch/vax/boot/romread.s b/sys/arch/vax/stand/common/romread.s
index 41cb4e2d33d..749a70bae2d 100644
--- a/sys/arch/vax/boot/romread.s
+++ b/sys/arch/vax/stand/common/romread.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: romread.s,v 1.3 1997/05/29 00:04:24 niklas Exp $ */
+/* $OpenBSD: romread.s,v 1.1 2000/04/27 02:26:26 bjc Exp $ */
/* $NetBSD: romread.s,v 1.4 1996/08/02 11:22:24 ragge Exp $ */
/*
* Copyright (c) 1995 Ludd, University of Lule}, Sweden.
diff --git a/sys/arch/vax/boot/srt0.s b/sys/arch/vax/stand/common/srt0.s
index f96bc035eb1..350c47394a5 100644
--- a/sys/arch/vax/boot/srt0.s
+++ b/sys/arch/vax/stand/common/srt0.s
@@ -1,5 +1,5 @@
-/* $OpenBSD: srt0.s,v 1.6 1998/05/14 13:50:36 niklas Exp $ */
-/* $NetBSD: srt0.s,v 1.9 1997/03/22 12:47:32 ragge Exp $ */
+/* $OpenBSD: srt0.s,v 1.1 2000/04/27 02:26:26 bjc Exp $ */
+/* $NetBSD: srt0.s,v 1.2 1999/05/23 21:58:19 ragge Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -32,7 +32,7 @@
/* All bugs are subject to removal without further notice */
-
+#include "../include/asm.h"
/*
* Auto-moving startup code for standalone programs. Can be loaded
* (almost) anywhere in memory but moves itself to the position
@@ -41,8 +41,8 @@
* position set in a.out header.
*/
-start0: .set start0,0 # passing -e start0 to ld gives OK start addr
- .globl start0
+nisse: .set nisse,0 # pass -e nisse to ld gives OK start addr
+ .globl nisse
_start: .globl _start
nop;nop; # If we get called by calls, or something
@@ -58,28 +58,32 @@ _start: .globl _start
subl2 $52, sp # do not overwrite saved boot-registers
subl3 $_start, $_edata, r0
- moval _start, r1
- subl3 $_start, $_end, r2
+ movab _start, r1
movl $_start, r3
- movc5 r0, (r1), $0, r2, (r3)
+ movc3 r0,(r1),(r3) # Kopiera text + data
+ subl3 $_edata, $_end, r2
+ movc5 $0,(r3),$0,r2,(r3) # Nolla bss också.
+
jsb 1f
1: movl $relocated, (sp) # return-address on top of stack
rsb # can be replaced with new address
relocated: # now relocation is done !!!
+ movl r10,_bootdev # Save bootdev early
+ movl r11,_howto # howto also...
movl sp, _bootregs
- calls $0, _setup
calls $0, _Xmain # Were here!
halt # no return
-
- .globl _hoppabort
-_hoppabort: .word 0x0
- movl 4(ap), r6
- movl 8(ap), r11
- movl 0xc(ap), r10
- movl 16(ap), r9
- movl _memsz,r8
- calls $0,(r6)
+ENTRY(machdep_start, 0)
+ mtpr $0x1f,$0x12 # Block all interrupts
+ mtpr $0,$0x18 # stop real time interrupt clock
+ movl 4(ap), r6
+ movl _howto, r11
+ movl _opendev, r10
+ movl 20(ap), r9
+ movl _memsz, r8
+ calls $0,(r6)
+ ret
.globl _memsz
_memsz: .long 0x0
diff --git a/sys/arch/vax/stand/str.s b/sys/arch/vax/stand/common/str.s
index 8b393d5ddb3..b2f93510ec7 100644
--- a/sys/arch/vax/stand/str.s
+++ b/sys/arch/vax/stand/common/str.s
@@ -1,5 +1,5 @@
-/* $OpenBSD: str.s,v 1.4 1998/05/11 07:37:39 niklas Exp $ */
-/* $NetBSD: str.s,v 1.3 1997/03/15 13:04:30 ragge Exp $ */
+/* $OpenBSD: str.s,v 1.1 2000/04/27 02:26:26 bjc Exp $ */
+/* $NetBSD: str.s,v 1.1 1999/03/06 16:36:06 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -36,7 +36,7 @@
* emulated instructions.
*/
-#include "../include/asm.h"
+#include "asm.h"
/*
* atoi() used in devopen.
@@ -86,16 +86,11 @@ ENTRY(bcmp, 0);
* Is movc3/movc5 emulated on any CPU? I dont think so; use them here.
*/
ENTRY(bzero,0);
- movl 4(ap), r0
- movl 8(ap), r1
- movc5 $0,(r0),$0,r1,(r0)
+ movc5 $0,*4(ap),$0,8(ap),*4(ap)
ret
ENTRY(bcopy,0);
- movl 4(ap), r0
- movl 8(ap), r1
- movl 12(ap), r2
- movc3 r2, (r0), (r1)
+ movc3 12(ap), *4(ap), *8(ap)
ret
ENTRY(strlen, 0);
@@ -106,7 +101,6 @@ ENTRY(strlen, 0);
subl2 4(ap), r0
ret
-#if 0
ENTRY(strncmp, 0)
movl 12(ap), r3
brb 5f
@@ -130,4 +124,24 @@ ENTRY(strcmp, 0)
1: bgtr 3f
mnegl r0, r0
3: ret
-#endif
+
+ENTRY(strncpy, 0)
+ movl 4(ap), r1
+ movl 8(ap), r2
+ movl 12(ap), r3
+ bleq 2f
+
+1: movb (r2)+, (r1)+
+ beql 2f
+ decl r3
+ bneq 1b
+2: ret
+
+ENTRY(strcat, 0)
+ pushl 4(ap)
+ calls $1,_strlen
+ addl2 4(ap),r0
+ movl 8(ap),r1
+1: movb (r1)+,(r0)+
+ bneq 1b
+ ret
diff --git a/sys/arch/vax/stand/vaxstand.h b/sys/arch/vax/stand/common/vaxstand.h
index ad2ec8d7598..86cdb8bffdc 100644
--- a/sys/arch/vax/stand/vaxstand.h
+++ b/sys/arch/vax/stand/common/vaxstand.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: vaxstand.h,v 1.6 1998/05/11 07:35:24 niklas Exp $ */
-/* $NetBSD: vaxstand.h,v 1.6 1997/03/15 13:04:31 ragge Exp $ */
+/* $OpenBSD: vaxstand.h,v 1.1 2000/04/27 02:26:26 bjc Exp $ */
+/* $NetBSD: vaxstand.h,v 1.1 1999/03/06 16:36:05 ragge Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -40,7 +40,8 @@
/* Variables used in autoconf */
extern int nmba, nuba, nbi, nsbi, nuda;
extern int *ubaaddr, *mbaaddr, *udaaddr, *uioaddr, *biaddr;
-extern int cpunumber;
+extern int cpunumber, howto;
+extern dev_t bootdev;
/* devsw type definitions, used in bootxx and conf */
#define SADEV(name,strategy,open,close,ioctl) \
@@ -50,4 +51,9 @@ extern int cpunumber;
(int(*)(struct open_file *))close, \
(int(*)(struct open_file *,u_long, void *))ioctl}
+#define SDELAY(count) {volatile int i; for (i = count; i; i--);}
+/*
+ * Easy-to-use definitions
+ */
+
char *index();
diff --git a/sys/arch/vax/stand/copy.c b/sys/arch/vax/stand/copy.c
deleted file mode 100644
index 137530507b6..00000000000
--- a/sys/arch/vax/stand/copy.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/* $OpenBSD: copy.c,v 1.5 1998/05/11 07:36:25 niklas Exp $ */
-/* $NetBSD: copy.c,v 1.4 1997/02/12 18:00:42 ragge Exp $ */
-/*-
- * Copyright (c) 1982, 1986 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 7.15 (Berkeley) 5/4/91
- */
-
-#include "sys/param.h"
-#include "sys/reboot.h"
-#include "lib/libsa/stand.h"
-
-#include "vaxstand.h"
-
-#include <sys/exec.h>
-
-char line[100];
-volatile u_int devtype, bootdev;
-extern unsigned opendev;
-
-static char *progname = "copy";
-static char *iobuf = NULL;
-static char *bufp = NULL;
-static int bufsize = 0;
-static int partlist[8];
-
-int fill_buffer (void);
-int write_disk (void);
-
-Xmain()
-{
- int adapt, ctlr, unit, part;
- int res, i, loops;
- char line[64];
-
- autoconf ();
-
- printf ("\n");
- printf ("%s: \n", progname);
- printf ("This program will read miniroot from tape/floppy/disk \n");
- printf ("and install this miniroot onto disk.\n");
- printf ("\n");
-
- res = fill_buffer ();
- if (res < 0) {
- printf ("errors occured during read. Continue at your own risk.\n");
- printf ("Do you want to continue ? [y/n] ");
- gets (line);
- if (*line != 'y' && *line != 'Y') {
- printf ("bye.\n");
- return (-1);
- }
- }
-
- printf ("\n");
- res = write_disk ();
-
- printf ("\n");
- printf ("Halt/Reboot the machine NOW.\n");
- for (;;)
- ;
- /* NOTREACHED */
-}
-
-int
-fill_buffer (void)
-{
- char devname[64];
- int numblocks;
- int blocksize = 512;
- int bpv = 0; /* blocks per volume */
- int bpt = 8; /* blocks per transfer */
- struct open_file file;
- char *filename;
- int i, loops;
- int size, rsize;
- int res, errors = 0;
-
-again:
- printf("\n");
- printf("Specify the device to read from as xx(N,?), where\n");
- printf("xx is the device-name, ? is file/partition number\n");
- printf("and N is the unit-number, e.g.\n");
- printf("\"mt(0,1)\" for the first TMSCP-tape (TK50),\n");
- printf("\"ra(2,0)\" for the third MSCP-disk/floppy (RX33/RX50)\n");
- printf("\n");
- printf("device to read from ? ");
- gets(devname);
-
- printf("\n");
- printf("Specify number of blocks to transfer. Usually this is\n");
- printf("sizeof(miniroot) / 512.\n");
- printf("It's safe to transfer more blocks than just the miniroot.\n");
- printf("\n");
- while (1) {
- printf ("number of blocks ? ");
- gets (line);
- if (atoi(line) > 0) {
- if (iobuf && bufsize)
- free (iobuf, bufsize);
- numblocks = atoi (line);
- bufsize = 512 * numblocks;
- iobuf = alloc (bufsize);
- bufp = iobuf;
- if (iobuf == NULL) {
- printf ("cannot allocate this much memory.\n");
- continue;
- }
- break;
- }
- printf ("invalid number %d.\n", atoi(line));
- }
-
- printf ("\n");
- printf ("If your miniroot is split into volumes, then you must\n");
- printf ("specify the number of blocks per volume.\n");
- printf ("(e.g. 800 blocks per RX50, 2400 blocks per RX33)\n");
- printf ("\n");
- while (1) {
- printf ("number of blocks per volume ? [%d] ", numblocks);
- gets (line);
- if (!*line || atoi(line) > 0) {
- bpv = (atoi(line) > 0 ? atoi(line) : numblocks);
- break;
- }
- printf ("invalid number %d.\n", atoi(line));
- }
-
- printf ("\n");
- do {
- printf ("Make sure unit %s is online and holds the proper volume.\n", devname);
- printf ("Then type \'g\' to Go or \'a\' to Abort.\n");
- printf ("\n");
- printf ("OK to go on ? [g/a] ");
- gets (line);
- if (*line == 'g' || *line == 'G') {
- printf ("Reading ... ");
- if (devopen (&file, devname, &filename)) {
- printf ("cannot open unit %s.\n", devname);
- goto again;
- }
- loops = bpv / bpt + (bpv % bpt != 0);
- for (i=0; i<loops; i++) {
- twiddle ();
- size = 512 * min (bpt, bpv - (i*bpt));
- res = (*file.f_dev->dv_strategy)
- (file.f_devdata, F_READ,
- (daddr_t)i*bpt, size, bufp, &rsize);
- if (res != 0) {
- printf ("error %d in read.\n", res);
- errors++;
- /* continue ? halt ??? */
- }
- bufp += size;
- }
- numblocks -= bpv;
- }
- if (numblocks > 0) {
- int vn = ((bufp - iobuf) / 512) / bpv;
- printf ("\n");
- printf ("volume #%d done. Now insert volume #%d\n",
- vn - 1, vn);
- }
- } while (numblocks > 0);
- printf ("Reading of miniroot done. (%d blocks read)\n",
- (bufp - iobuf) / 512);
-
- return (-errors);
-}
-
-int
-write_disk (void)
-{
- char line[64];
- char devname[64];
- struct open_file file;
- char *fname;
- int rsize, res;
- int i, errors = 0;
-
- printf ("\n");
- printf ("Now specify the device to write miniroot to as xx(N,1)\n");
- printf ("where xx is the drive type and N is the drive number.\n");
- printf ("For example: ra(0,1) refers to MSCP drive #0, b partition\n");
- printf ("\n");
- do {
- printf ("Root disk ? : ");
- gets (devname);
- } while (devopen (&file, devname, &fname));
-
- /*
- * next: initialize the partition
- */
- printf ("Initializing partition ... ");
- bufp = iobuf + (16 * 512);
- for (i=16; i<bufsize/512; i++) {
- twiddle ();
- res = (*file.f_dev->dv_strategy) (file.f_devdata, F_WRITE,
- (daddr_t)i, 512, bufp, &rsize);
- if (res != 0) {
- errors++;
- printf ("error writing block %d.\n");
- printf ("trying to continue ...\n");
- }
- bufp += 512;
- }
- printf ("done.\n");
- printf ("(%d blocks written.)\n", bufsize/512);
-
- printf ("\n");
- printf ("Halt the machine and reboot from distribution media,\n");
- printf ("giving second partition as part to mount as root. Ex:\n");
- printf (": ra(0,1) for ra disk 0, hp(2,1) for massbuss disk 2\n");
-
- return (-errors);
-}
-
diff --git a/sys/arch/vax/stand/edlabel.c b/sys/arch/vax/stand/edlabel.c
deleted file mode 100644
index c5d55167922..00000000000
--- a/sys/arch/vax/stand/edlabel.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/* $OpenBSD: edlabel.c,v 1.3 1997/05/29 00:04:22 niklas Exp $ */
-/* $NetBSD: edlabel.c,v 1.2 1996/08/02 11:22:11 ragge Exp $ */
-/*
- * Copyright (c) 1995 Ludd, University of Lule}, Sweden.
- * 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 at Ludd, University of
- * Lule}, Sweden and its contributors.
- * 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.
- */
-
-#define DKTYPENAMES
-
-#include "sys/param.h"
-#include "sys/disklabel.h"
-
-#include "lib/libsa/stand.h"
-#include "ufs/ffs/fs.h"
-
-struct disklabel dlabel;
-char bootblock[8192];
-
-void
-showlabel()
-{
- struct disklabel *lp;
- struct partition *pp;
- int i, j;
-
- lp = &dlabel;
-
- printf("\n\ndisk type %d (%s), %s: %s%s%s\n", lp->d_type, lp->d_type
- <DKMAXTYPES?dktypenames[lp->d_type]:dktypenames[0], lp->d_typename,
- lp->d_flags & D_REMOVABLE?" removable":"", lp->d_flags & D_ECC?
- " ecc":"", lp->d_flags & D_BADSECT?" badsect":"");
-
- printf("interleave %d, rpm %d, trackskew %d, cylinderskew %d\n",
- lp->d_interleave, lp->d_rpm, lp->d_trackskew, lp->d_cylskew);
- printf("headswitch %d, track-to-track %d, drivedata: %d %d %d %d %d\n",
- lp->d_headswitch, lp->d_trkseek, lp->d_drivedata[0],
- lp->d_drivedata[1], lp->d_drivedata[2], lp->d_drivedata[3],
- lp->d_drivedata[4]);
-
- printf("\nbytes/sector: %d\n", lp->d_secsize);
- printf("sectors/track: %d\n", lp->d_nsectors);
- printf("tracks/cylinder: %d\n", lp->d_ntracks);
- printf("sectors/cylinder: %d\n", lp->d_secpercyl);
- printf("cylinders: %d\n", lp->d_ncylinders);
-
- printf("\n%d partitions:\n", lp->d_npartitions);
- printf(" size offset\n");
- pp = lp->d_partitions;
- for (i = 0; i < lp->d_npartitions; i++) {
- printf("%c: %d, %d\n", 97 + i, lp->d_partitions[i].p_size,
- lp->d_partitions[i].p_offset);
- }
- printf("\n");
-}
-
-setdefaultlabel()
-{
- printf("Sorry, not implemented yet. Later...\n\n");
-}
-
-#define GETNUM(out, num) printf(out, num);gets(store); \
- if (*store) num = atoi(store);
-#define GETNUM2(out, num1, num) printf(out, num1, num);gets(store); \
- if (*store) num = atoi(store);
-#define GETSTR(out, str) printf(out, str);gets(store); \
- if (*store) bcopy(store, str, strlen(store));
-#define FLAGS(out, flag) printf(out, lp->d_flags & flag?'y':'n');gets(store); \
- if (*store == 'y' || *store == 'Y') lp->d_flags |= flag; \
- else lp->d_flags &= ~flag;
-
-editlabel()
-{
- struct disklabel *lp;
- char store[256];
- int i;
-
- lp = &dlabel;
- printf("\nFirst set disk type. Valid types are:\n");
- for (i = 0; i < DKMAXTYPES; i++)
- printf("%d %s\n", i, dktypenames[i]);
-
- GETNUM("\nNumeric disk type? [%d] ", lp->d_type);
- GETSTR("Disk name? [%s] ", lp->d_typename);
- FLAGS("badsectoring? [%c] ", D_BADSECT);
- FLAGS("ecc? [%c] ", D_ECC);
- FLAGS("removable? [%c] ", D_REMOVABLE);
-
- GETNUM("Interleave? [%d] ", lp->d_interleave);
- GETNUM("rpm? [%d] ", lp->d_rpm);
- GETNUM("trackskew? [%d] ", lp->d_trackskew);
- GETNUM("cylinderskew? [%d] ", lp->d_cylskew);
- GETNUM("headswitch? [%d] ", lp->d_headswitch);
- GETNUM("track-to-track? [%d] ", lp->d_trkseek);
- GETNUM("drivedata 0? [%d] ", lp->d_drivedata[0]);
- GETNUM("drivedata 1? [%d] ", lp->d_drivedata[1]);
- GETNUM("drivedata 2? [%d] ", lp->d_drivedata[2]);
- GETNUM("drivedata 3? [%d] ", lp->d_drivedata[3]);
- GETNUM("drivedata 4? [%d] ", lp->d_drivedata[4]);
- lp->d_secsize = 512;
- GETNUM("\nbytes/sector? [%d] ", lp->d_secsize);
- GETNUM("sectors/track? [%d] ", lp->d_nsectors);
- GETNUM("tracks/cylinder? [%d] ", lp->d_ntracks);
- lp->d_secpercyl = lp->d_nsectors * lp->d_ntracks;
- GETNUM("sectors/cylinder? [%d] ", lp->d_secpercyl);
- GETNUM("cylinders? [%d] ", lp->d_ncylinders);
- lp->d_npartitions = MAXPARTITIONS;
- for (i = 0; i < 8; i++) {
- GETNUM2("%c partition: offset? [%d] ", 97 + i,
- lp->d_partitions[i].p_offset);
- GETNUM(" size? [%d] ", lp->d_partitions[i].p_size);
- }
-}
-
-int bootdev;
-
-void
-Xmain()
-{
- register bdev asm("r10");
-
- struct open_file file;
- char diskname[64], *msg, *filename, indata[64];
- int i, rsize;
-
- bootdev = bdev;
- printf("With this program you can modify everything in the on-disk\n");
- printf("disklabel. To do something useful you must know the exact\n");
- printf("geometry of your disk, and have ideas about how you want\n");
- printf("your partitions to be placed on disk. Some hints:\n");
- printf("The a partition should be at least ~20000 blocks, the\n");
- printf("b (swap) is depending on your use of the machine but it\n");
- printf("should almost never be less than ~32000 blocks.\n\n");
- printf("Disk geometry for most DEC disks can be found in the disktab");
- printf("\nfile, and disknames is listed in the installation notes.\n");
- printf("\nRemember that disk names is given as disk(adapt, ctrl, ");
- printf("disk, part)\nwhen using the installation tools.\n\n");
-
- autoconf();
-igen:
- printf("Label which disk? ");
- gets(diskname);
- if (*diskname == 0) goto igen;
- if (devopen(&file, diskname, &filename)) {
- printf("cannot open %s\n", diskname);
- goto igen;
- }
- if ((*file.f_dev->dv_strategy)(file.f_devdata, F_READ,
- (daddr_t)0, 8192, bootblock, &rsize)) {
- printf("cannot read label block\n");
- goto igen;
- }
- if (msg = (char *) getdisklabel(LABELOFFSET + bootblock, &dlabel))
- printf("%s: %s\n", diskname, msg);
-
- do {
- printf("(E)dit, (S)how, (D)efaults, (W)rite, (Q)uit) : ");
- gets(indata);
- switch (*indata) {
- case ('e'):
- case ('E'):
- editlabel();
- break;
- case ('s'):
- case ('S'):
- showlabel();
- break;
- case ('d'):
- case ('D'):
- setdefaultlabel();
- break;
- case ('w'):
- case ('W'):
- dlabel.d_magic = DISKMAGIC;
- dlabel.d_magic2 = DISKMAGIC;
- dlabel.d_bbsize = BBSIZE;
- dlabel.d_sbsize = SBSIZE;
- dlabel.d_checksum = 0;
- dlabel.d_checksum = dkcksum(&dlabel);
- bcopy(&dlabel, LABELOFFSET + bootblock,
- sizeof(struct disklabel));
- if ((*file.f_dev->dv_strategy)(file.f_devdata, F_WRITE,
- (daddr_t)0, 8192, bootblock, &rsize)) {
- printf("cannot write label sectors.\n");
- break;
- }
- printf("\nThis program does not (yet) write");
- printf(" bootblocks, only disklabel.\n");
- printf("Remember to write the bootblocks from the ");
- printf("miniroot later with the\ncommand ");
- printf("\"disklabel -B <diskname>\".\n\n");
- break;
- case ('q'):
- case ('Q'):
- default:
- break;
- }
- } while (*indata != 'q' && *indata != 'Q');
- goto igen;
-}
diff --git a/sys/arch/vax/stand/ka410.h b/sys/arch/vax/stand/ka410.h
deleted file mode 100644
index ef2c656df0e..00000000000
--- a/sys/arch/vax/stand/ka410.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* $OpenBSD: ka410.h,v 1.2 1997/05/29 00:04:23 niklas Exp $ */
-/* $NetBSD: ka410.h,v 1.1 1996/08/02 11:22:13 ragge Exp $ */
-/*
- * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
- * All rights reserved.
- *
- * This code is derived from software contributed to Ludd by
- * Bertram Barth.
- *
- * 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 at Ludd, University of
- * Lule}, Sweden and its contributors.
- * 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.
- */
-
-
-
-/*
- * interrupt request-, clear-, and mask register
- */
-extern volatile unsigned char *ka410_intreq;
-extern volatile unsigned char *ka410_intclr;
-extern volatile unsigned char *ka410_intmsk;
-
-#define INTR_SR (1<<7) /* Serial line receiver or silo full */
-#define INTR_ST (1<<6) /* Serial line transmitter done */
-#define INTR_NP (1<<5) /* Network controller primary */
-#define INTR_NS (1<<4) /* Network controller secondary */
-#define INTR_VF (1<<3) /* Video end of frame */
-#define INTR_VS (1<<2) /* Video secondary */
-#define INTR_SC (1<<1) /* SCSI controller */
-#define INTR_DC (1<<0) /* Disk controller */
-
-/*
- * interrupt vector numbers
- */
-#define IVEC_BASE 0x20040020
-#define IVEC_SR 0x000002C0
-#define IVEC_ST 0x000002C4
-#define IVEC_NP 0x00000250
-#define IVEC_NS 0x00000254
-#define IVEC_VF 0x00000244
-#define IVEC_VS 0x00000248
-#define IVEC_SC 0x000003F8
-#define IVEC_DC 0x000003FC
-
-/*
- * Clock-Chip data in NVRAM
- */
-#define KA410_CPMBX 0x200B0038 /* Console Mailbox (1 byte) */
-#define KA410_CPFLG 0x200B003C /* Console Program Flags (1 byte) */
-#define KA410_LK201_ID 0x200B0040 /* Keyboard Variation (1 byte) */
-#define KA410_CONS_ID 0x200B0044 /* Console Device Type (1 byte) */
-#define KA410_SCR 0x200B0048 /* Console Scratch RAM */
-#define KA410_TEMP 0x200B0058 /* Used by System Firmware */
-#define KA410_BAT_CHK 0x200B0088 /* Battery Check Data */
-#define KA410_BOOTDEV 0x200B0098 /* Default Boot Device (4 bytes) */
-#define KA410_BOOTFLG 0x200B00A8 /* Default Boot Flags (4 bytes) */
-#define KA410_SCRLEN 0x200B00B8 /* Number of pages of SCR (1 byte) */
-#define KA410_SCSIPORT 0x200B00BC /* Tape Controller Port Data */
-#define KA410_RESERVED 0x200B00C0 /* Reserved (16 bytes) */
-
diff --git a/sys/arch/vax/stand/samachdep.h b/sys/arch/vax/stand/samachdep.h
deleted file mode 100644
index 4aab837f096..00000000000
--- a/sys/arch/vax/stand/samachdep.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* $OpenBSD: samachdep.h,v 1.2 1997/05/29 00:04:25 niklas Exp $ */
-/* $NetBSD: samachdep.h,v 1.1 1996/08/02 11:22:28 ragge Exp $ */
-
-/*
- * Copyright (c) 1982, 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.
- *
- * @(#)samachdep.h 8.1 (Berkeley) 6/10/93
- */
-
-#define NSCSI 1
-#define NSD 8
-
-extern int howto;
-extern unsigned int bootdev;
diff --git a/sys/arch/vax/stand/scsi_hi.c b/sys/arch/vax/stand/scsi_hi.c
deleted file mode 100644
index b49e0f2610c..00000000000
--- a/sys/arch/vax/stand/scsi_hi.c
+++ /dev/null
@@ -1,298 +0,0 @@
-/* $OpenBSD: scsi_hi.c,v 1.2 1997/05/29 00:04:25 niklas Exp $ */
-/* $NetBSD: scsi_hi.c,v 1.1 1996/08/02 11:22:31 ragge Exp $ */
-
-/****************************************************************************
- * NS32K Monitor SCSI high-level driver
- * Bruce Culbertson
- * 8 March 1990
- * (This source is public domain source)
- *
- * There are three monitor SCSI commands. "Read" and "write" I think are
- * fairly self explanatory once you read the help messages. They, in fact,
- * execute the "extended read", "extended write", and "request sense"
- * commands from the SCSI standard.
- *
- * "Raw" lets you execute any SCSI command but you need a SCSI reference to
- * know what the commands are and what their formats are. The SCSI
- * standard specifies that there are six buffers which, for example, hold a
- * SCSI command or are the source or destination for data. You provide
- * "raw" with an array of pointers to the six buffers. Using "edit", you
- * can enter a SCSI command somewhere in memory and you can create the
- * array of pointers. The array must actually be eight entries long; two
- * entries are not used. By typing "raw <array address>", the SCSI command
- * is executed.
- *
- * By the way, "read", "write", and "raw" talk only to the DP8490 SCSI
- * controller. I have not had time to read the Adaptec data sheet and
- * write a driver for it.
- ****************************************************************************/
-#include "so.h"
-
-#define OK 0
-#define NOT_OK OK+1
-#define PRIVATE
-#define PUBLIC
-#define U8 unsigned char
-
-long scsiAdr = DEFAULT_SCSI_ADR, /* default SCSI address */
- scsiLun = DEFAULT_SCSI_LUN;
-
-struct cmd_desc { /* SCSI command description */
- const U8 *cmd; /* command string */
- const U8 *odata; /* data to output, if any */
- const struct cmd_desc *chain; /* next command */
-};
-
-struct drive { /* SCSI drive description */
- U8 adr, lun; /* SCSI address and LUN */
- U8 flags; /* drive characteristics */
- U8 stat; /* drive state */
- const struct cmd_desc *init; /* list of initialize commands */
-};
-/* for drive.flags */
-#define EXTENDED_RDWR 1 /* device does extended read, write */
-#define EXTENDED_SENSE 2 /* device does extended sense */
-/* for drive.stat */
-#define INITIALIZED 1 /* device is initialized */
-
-PRIVATE struct drive drive_tbl[] = {
-#if 1
- {0, 0, 0, 1, 0},
- {1, 0, 0, 1, 0},
- {2, 0, 0, 1, 0},
- {3, 0, 0, 1, 0},
- {4, 0, 0, 1, 0},
- {5, 0, 0, 1, 0},
- {6, 0, 0, 1, 0},
- {7, 0, 0, 1, 0},
-#else
- {0, 0, EXTENDED_RDWR | EXTENDED_SENSE, 1, 0},
- {1, 0, EXTENDED_RDWR | EXTENDED_SENSE, 1, 0},
- {2, 0, EXTENDED_RDWR | EXTENDED_SENSE, 1, 0},
- {3, 0, EXTENDED_RDWR | EXTENDED_SENSE, 1, 0},
- {4, 0, EXTENDED_RDWR | EXTENDED_SENSE, 1, 0},
- {5, 0, EXTENDED_RDWR | EXTENDED_SENSE, 1, 0},
- {6, 0, EXTENDED_RDWR | EXTENDED_SENSE, 1, 0},
- {7, 0, EXTENDED_RDWR | EXTENDED_SENSE, 1, 0},
-#endif
-};
-#define DRV_TBL_SZ (sizeof (drive_tbl) / sizeof (struct drive))
-
-/* Round up to multiple of four since SCSI transfers are always multiples
- * of four bytes.
- */
-#define CMD_LEN 12 /* longest SCSI command */
-#define SENSE_LEN 24 /* extended sense length */
-#define MSG_LEN 4
-#define STAT_LEN 4
-
-#define MAX_SCSI_RETRIES 6
-#define CMD_IX 2
-#define CMD_SENSE 0x03
-#define CMD_READ 0x08
-#define CMD_WRITE 0x0a
-#define CMD_XREAD 0x28
-#define CMD_XWRITE 0x2a
-PRIVATE U8 cmd_buf[CMD_LEN];
-
-#define SENSE_KEY 2
-#define NO_SENSE 0
-#define RECOVERY_ERR 1
-#define UNIT_ATTN 6
-#define ADD_SENSE_CODE 12
-#define SENSE_RST 0x29
-PRIVATE U8 sense_buf[SENSE_LEN];
-
-#define CHECK_CONDITION 2
-#define STAT_IX 3
-#define STAT_MASK 0x1f
-PRIVATE U8 stat_buf[STAT_LEN];
-#define IMSG_IX 7
-PRIVATE U8 msg_buf[MSG_LEN];
-
-#define ODATA_IX 0
-#define IDATA_IX 1
-PRIVATE struct scsi_args scsi_args;
-
-/*===========================================================================*
- * sc_rdwt *
- *===========================================================================*/
-/* Carry out a read or write request for the SCSI disk. */
-PRIVATE int
-sc_rdwt(op, block, ram_adr, len, sc_adr, lun)
-long block, ram_adr, len, sc_adr, lun;
-{
- int retries, ret;
- U8 *p;
- struct drive *dp;
-
- printf ("sc_rdwt: op %x, block %d, ram %x, len %d, sc_adr %d, lun %d\n",
- op, block, ram_adr, len, sc_adr, lun);
-
- /* get drive characteristics */
- for (dp = drive_tbl; dp < drive_tbl + DRV_TBL_SZ - 1; ++dp)
- if (dp->adr == sc_adr && dp->lun == lun) break;
- if (dp == drive_tbl + DRV_TBL_SZ - 1) {
- dp->adr = sc_adr; /* have default, set adr, lun */
- dp->lun = lun;
- }
- for (retries = 0; retries < MAX_SCSI_RETRIES; ++retries) {
- if (dp->init && !(dp->stat & INITIALIZED))
- if (OK != sc_initialize (dp)) {
- printf("SCSI cannot initialize device\n");
- return NOT_OK;
- }
- p = cmd_buf; /* build SCSI command */
- if (dp->flags & EXTENDED_RDWR) { /* use extended commands */
- *p++ = (op == DISK_READ)? CMD_XREAD: CMD_XWRITE;
- *p++ = lun << 5;
- *p++ = (block >> 24) & 0xff;
- *p++ = (block >> 16) & 0xff;
- *p++ = (block >> 8) & 0xff;
- *p++ = (block >> 0) & 0xff;
- *p++ = 0;
- *p++ = (len >> 8) & 0xff;
- *p++ = (len >> 0) & 0xff;
- *p = 0;
- } else { /* use short (SASI) commands */
- *p++ = (op == DISK_READ)? CMD_READ: CMD_WRITE;
- *p++ = (lun << 5) | ((block >> 16) & 0x1f);
- *p++ = (block >> 8) & 0xff;
- *p++ = (block >> 0) & 0xff;
- *p++ = len;
- *p = 0;
- }
- if (op == DISK_READ)
- ret = exec_scsi_hi (cmd_buf, (U8 *)ram_adr, (U8 *)0, dp);
- else
- ret = exec_scsi_hi (cmd_buf, (U8 *)0, (U8 *)ram_adr, dp);
- if (OK == ret) return OK;
- dp->stat &= ~INITIALIZED;
- }
- printf("SCSI %s, block %d failed even after retries\n",
- op == DISK_READ? "READ": "WRITE", block);
- return NOT_OK;
-}
-
-/*===========================================================================*
- * sc_initialize *
- *===========================================================================*/
-/* Execute the list of initialization commands for the given drive.
- */
-int
-sc_initialize (dp)
-struct drive *dp;
-{
- const struct cmd_desc *cp;
-
- for (cp = dp->init; cp != 0; cp = cp->chain)
- if (OK != exec_scsi_hi (cp->cmd, 0, cp->odata, dp)) {
- dp->stat &= ~INITIALIZED;
- return NOT_OK;
- }
- dp->stat |= INITIALIZED;
- return OK;
-}
-
-/*===========================================================================*
- * exec_scsi_hi *
- *===========================================================================*/
-/* Execute a "high-level" SCSI command. This means execute a low level
- * command and, if it fails, execute a request sense to find out why.
- */
-PRIVATE int
-exec_scsi_hi(cmd, data_in, data_out, dp)
-U8 *cmd, *data_out, *data_in;
-struct drive *dp;
-{
- scsi_args.ptr[CMD_IX] = (long)cmd;
- scsi_args.ptr[STAT_IX] = (long)stat_buf;
- scsi_args.ptr[IMSG_IX] = (long)msg_buf;
- scsi_args.ptr[IDATA_IX] = (long)data_in;
- scsi_args.ptr[ODATA_IX] = (long)data_out;
- if (OK != exec_scsi_low (&scsi_args, dp->adr))
- return NOT_OK;
- *stat_buf &= STAT_MASK; /* strip off lun */
- if (*stat_buf == 0)
- /* Success -- this should be the usual case */
- return OK;
- if (*stat_buf != CHECK_CONDITION) {
- /* do not know how to handle this so return error */
- printf("SCSI device returned unknown status: %d\n", *stat_buf);
- return NOT_OK;
- }
- /* Something funny happened, need to execute request-sense command
- * to learn more.
- */
- if (OK == get_sense(dp))
- /* Something funny happened, but the device recovered from it and
- * the command succeeded.
- */
- return OK;
- return NOT_OK;
-}
-
-/*===========================================================================*
- * get_sense *
- *===========================================================================*/
-/* Execute a "request sense" SCSI command and check results. When a SCSI
- * command returns CHECK_CONDITION, a request-sense command must be executed.
- * A request-sense command provides information about the original command.
- * The original command might have succeeded, in which case it does not
- * need to be retried and OK is returned. Examples: read error corrected
- * with error correction code, or error corrected by retries performed by
- * the SCSI device. The original command also could have failed, in
- * which case NOT_OK is returned.
- */
-#define XLOGICAL_ADR \
- (sense_buf[3]<<24 | sense_buf[4]<<16 | sense_buf[5]<<8 | sense_buf[6])
-#define LOGICAL_ADR \
- (sense_buf[1]<<16 | sense_buf[2]<<8 | sense_buf[3])
-
-PRIVATE int
-get_sense (dp)
-struct drive *dp;
-{
- U8 *p;
-
- p = cmd_buf; /* build SCSI command */
- *p++ = CMD_SENSE;
- *p++ = dp->lun << 5;
- *p++ = 0;
- *p++ = 0;
- *p++ = (dp->flags & EXTENDED_SENSE)? SENSE_LEN: 0;
- *p = 0;
- scsi_args.ptr[IDATA_IX] = (long)sense_buf;
- scsi_args.ptr[ODATA_IX] = 0;
- scsi_args.ptr[CMD_IX] = (long)cmd_buf;
- scsi_args.ptr[STAT_IX] = (long)stat_buf;
- scsi_args.ptr[IMSG_IX] = (long)msg_buf;
- if (OK != exec_scsi_low (&scsi_args, dp->adr)) {
- printf("SCSI SENSE command failed\n");
- return NOT_OK;
- }
- if ((*stat_buf & STAT_MASK) != 0) {
- printf("SCSI SENSE returned wrong status %d\n", *stat_buf);
- return NOT_OK;
- }
- if (0 == (dp->flags & EXTENDED_SENSE)) {
- printf("SCSI request sense, code 0x%x, log_adr 0x%x\n",
- sense_buf[0], LOGICAL_ADR);
- return NOT_OK;
- }
- switch (sense_buf[SENSE_KEY] & 0xf) {
- case NO_SENSE:
- case UNIT_ATTN: /* reset */
- return NOT_OK; /* must retry command */
- case RECOVERY_ERR:
- /* eventually, we probably do not want to hear about these. */
- printf("SCSI ok with recovery, code 0x%x, logical address 0x%x\n",
- sense_buf[ADD_SENSE_CODE], XLOGICAL_ADR);
- return OK; /* orig command was ok with recovery */
- default:
- printf("SCSI failure: key 0x%x code 0x%x log adr 0x%x sense buf 0x%x\n",
- sense_buf[SENSE_KEY], sense_buf[ADD_SENSE_CODE],
- XLOGICAL_ADR, sense_buf);
- return NOT_OK; /* orig command failed */
- }
-}
diff --git a/sys/arch/vax/stand/scsi_low.c b/sys/arch/vax/stand/scsi_low.c
deleted file mode 100644
index 9a6f1d61876..00000000000
--- a/sys/arch/vax/stand/scsi_low.c
+++ /dev/null
@@ -1,480 +0,0 @@
-/* $OpenBSD: scsi_low.c,v 1.2 1997/05/29 00:04:26 niklas Exp $ */
-/* $NetBSD: scsi_low.c,v 1.1 1996/08/02 11:22:34 ragge Exp $ */
-
-/****************************************************************************
- * NS32K Monitor SCSI low-level driver
- * Bruce Culbertson
- * 8 March 1990
- * (This source is public domain source.)
- *
- * Originally written by Bruce Culbertson for a ns32016 port of Minix.
- * Adapted from that for the pc532 (ns32632) monitor.
- * Adapted from that for NetBSD/pc532 by Philip L. Bunde.
- *
- * Do not use DMA -- makes 32016 and pc532 versions compatible.
- * Do not use interrupts -- makes it harder for the user code to bomb
- * this code.
- ****************************************************************************/
-
-#include "so.h"
-#include "ka410.h"
-
-#define BB_DEBUG(x) printf x
-#define CLEAR_INTR() *ka410_intclr=INTR_SC
-#define CHECK_INTR() *ka410_intreq&INTR_SC
-
-#define OK 0
-#define NOT_OK OK+1
-#define PRIVATE
-#define PUBLIC
-#define WR_ADR(adr,val) (*((volatile unsigned char *)(adr))=(val))
-#define RD_ADR(adr) (*((volatile unsigned char *)(adr)))
-/* #define AIC6250 0 */
-/* #define DP8490 1 */
-#define MAX_CACHE 0x4000
-
-/* SCSI bus phases
- */
-#define PH_ODATA 0
-#define PH_IDATA 1
-#define PH_CMD 2
-#define PH_STAT 3
-#define PH_IMSG 7
-#define PH_NONE 8
-#define PH_IN(phase) ((phase) & 1)
-
-/* NCR5380 SCSI controller registers
- */
-#define SC_CTL 0x200C0080 /* base for control registers */
-#define SC_DMA 0x200D0000 /* base for data registers (8/16K) */
-#define SC_CURDATA SC_CTL+(4*0)
-#define SC_OUTDATA SC_CTL+(4*0)
-#define SC_ICMD SC_CTL+(4*1)
-#define SC_MODE SC_CTL+(4*2)
-#define SC_TCMD SC_CTL+(4*3)
-#define SC_STAT1 SC_CTL+(4*4)
-#define SC_STAT2 SC_CTL+(4*5)
-#define SC_START_SEND SC_CTL+(4*5)
-#define SC_INDATA SC_CTL+(4*6)
-#define SC_RESETIP SC_CTL+(4*7)
-#define SC_START_RCV SC_CTL+(4*7)
-
-/* Bits in NCR5380 registers
- */
-#define SC_A_RST 0x80
-#define SC_A_SEL 0x04
-#define SC_S_SEL 0x02
-#define SC_S_REQ 0x20
-#define SC_S_BSY 0x40
-#define SC_S_BSYERR 0x04
-#define SC_S_PHASE 0x08
-#define SC_S_IRQ 0x10
-#define SC_S_DRQ 0x40
-#define SC_M_DMA 0x02
-#define SC_M_BSY 0x04
-#define SC_ENABLE_DB 0x01
-
-/* Status of interrupt routine, returned in m1_i1 field of message.
- */
-#define ISR_NOTDONE 0
-#define ISR_OK 1
-#define ISR_BSYERR 2
-#define ISR_RSTERR 3
-#define ISR_BADPHASE 4
-#define ISR_TIMEOUT 5
-
-#define ICU_ADR 0xfffffe00
-#define ICU_IO (ICU_ADR+20)
-#define ICU_DIR (ICU_ADR+21)
-#define ICU_DATA (ICU_ADR+19)
-#define ICU_SCSI_BIT 0x80
-
-/* Miscellaneous
- */
-#define MAX_WAIT (1000*1000)
-#define SC_LOG_LEN 32
-
-PRIVATE struct scsi_args *sc_ptrs;
-PRIVATE char sc_cur_phase,
- sc_reset_done = 1,
- sc_have_msg,
- sc_accept_int,
- sc_dma_dir;
-
-long sc_dma_port = SC_DMA,
- sc_dma_adr;
-
-#ifdef DEBUG
-struct sc_log {
- unsigned char stat1, stat2;
-} sc_log [SC_LOG_LEN],
- *sc_log_head = sc_log;
-int sc_spurious_int;
-#endif
-unsigned char
- sc_watchdog_error; /* watch dog error */
-
-/* error messages */
-char *scsi_errors[] = {
- 0, /* ISR_NOTDONE */
- 0, /* ISR_OK */
- "busy error", /* ISR_BSYERR */
- "reset error", /* ISR_RSTERR */
- "NULL pointer for current phase", /* ISR_BADPHASE */
- "timeout", /* ISR_TIMEOUT */
-};
-
-/*===========================================================================*
- * exec_scsi_low *
- *===========================================================================*/
-/* Execute a generic SCSI command. Passed pointers to eight buffers:
- * data-out, data-in, command, status, dummy, dummy, message-out, message-in.
- */
-PUBLIC
-int
-exec_scsi_low (args, scsi_adr)
-struct scsi_args *args;
-long scsi_adr;
-{
- int ret;
-
- BB_DEBUG (("exec_scsi_low(0x%x, %d)\n", args, scsi_adr));
-
- sc_ptrs = args; /* make pointers globally accessible */
- /* bertram ??? scCtlrSelect (DP8490); */
- if (!sc_reset_done) sc_reset();
- /* TCMD has some undocumented behavior in initiator mode. I think the
- * data bus cannot be enabled if i/o is asserted.
- */
- WR_ADR (SC_TCMD, 0);
- if (OK != sc_wait_bus_free ()) { /* bus-free phase */
- printf("SCSI: bus not free\n");
- return NOT_OK;
- }
- sc_cur_phase = PH_NONE;
- sc_have_msg = 0;
- if (OK != sc_select (scsi_adr)) /* select phase */
- return NOT_OK;
- sc_watchdog_error = 0;
- ret = sc_receive (); /* isr does the rest */
- if (ret == ISR_OK) return OK;
- else {
- sc_reset();
- printf("SCSI: %s\n", scsi_errors[ret]);
- return NOT_OK;
- }
-}
-
-/*===========================================================================*
- * sc_reset *
- *===========================================================================*/
-/*
- * Reset SCSI bus.
- */
-PRIVATE
-sc_reset()
-{
- volatile int i;
-
- BB_DEBUG (("sc_reset()\n"));
-
- WR_ADR (SC_MODE, 0); /* get into harmless state */
- WR_ADR (SC_OUTDATA, 0);
- WR_ADR (SC_ICMD, SC_A_RST); /* assert RST on SCSI bus */
- i = 200; /* wait 25 usec */
- while (i--);
- WR_ADR (SC_ICMD, 0); /* deassert RST, get off bus */
- sc_reset_done = 1;
-}
-
-/*===========================================================================*
- * sc_wait_bus_free *
- *===========================================================================*/
-PRIVATE int
-sc_wait_bus_free()
-{
- int i = MAX_WAIT;
- volatile int j;
-
- BB_DEBUG (("sc_wait_bus_free()\n"));
-
- while (i--) {
- /* Must be clear for 2 usec, so read twice */
- if (RD_ADR (SC_STAT1) & (SC_S_BSY | SC_S_SEL)) continue;
- for (j = 0; j < 25; ++j);
- if (RD_ADR (SC_STAT1) & (SC_S_BSY | SC_S_SEL)) continue;
- return OK;
- }
- sc_reset_done = 0;
- return NOT_OK;
-}
-
-/*===========================================================================*
- * sc_select *
- *===========================================================================*/
-/* This duplicates much of the work that the interrupt routine would do on a
- * phase mismatch and, in fact, the original plan was to just do the select,
- * let a phase mismatch occur, and let the interrupt routine do the rest.
- * That didn't work because the 5380 did not reliably generate the phase
- * mismatch interrupt after selection.
- */
-PRIVATE int
-sc_select(adr)
-long adr;
-{
- int i, stat1;
- long new_ptr;
-
- BB_DEBUG (("sc_select(%d)\n", adr));
-
- CLEAR_INTR();
- WR_ADR (SC_OUTDATA, adr); /* SCSI bus address */
- WR_ADR (SC_ICMD, SC_A_SEL | SC_ENABLE_DB);
- for (i = 0;; ++i) { /* wait for target to assert SEL */
- if (CHECK_INTR() == 0)
- continue;
- stat1 = RD_ADR (SC_STAT1);
- if (stat1 & SC_S_BSY) break; /* select successful */
- if (i > MAX_WAIT) { /* timeout */
- printf("SCSI: SELECT timeout\n");
- sc_reset();
- return NOT_OK;
- }
- }
- CLEAR_INTR();
- WR_ADR (SC_ICMD, 0); /* clear SEL, disable data out */
- WR_ADR (SC_OUTDATA, 0);
- for (i = 0;; ++i) { /* wait for target to assert REQ */
- if (CHECK_INTR() == 0)
- continue;
- if (stat1 & SC_S_REQ) break; /* target requesting transfer */
- if (i > MAX_WAIT) { /* timeout */
- printf("SCSI: REQ timeout\n");
- sc_reset();
- return NOT_OK;
- }
- stat1 = RD_ADR (SC_STAT1);
- }
- sc_cur_phase = (stat1 >> 2) & 7; /* get new phase from controller */
- if (sc_cur_phase != PH_CMD) {
- printf("SCSI: bad phase = %d\n", sc_cur_phase);
- sc_reset();
- return NOT_OK;
- }
- new_ptr = sc_ptrs->ptr[PH_CMD];
- if (new_ptr == 0) {
- printf("SCSI: NULL command pointer\n");
- sc_reset();
- return NOT_OK;
- }
- sc_accept_int = 1;
- sc_dma_setup (DISK_WRITE, new_ptr);
- CLEAR_INTR();
- WR_ADR (SC_TCMD, PH_CMD);
- WR_ADR (SC_ICMD, SC_ENABLE_DB);
- WR_ADR (SC_MODE, SC_M_BSY | SC_M_DMA);
- WR_ADR (SC_START_SEND, 0);
- return OK;
-}
-
-/*===========================================================================*
- * scsi_interrupt *
- *===========================================================================*/
-/* SCSI interrupt handler.
- */
-PUBLIC
-int
-scsi_interrupt()
-{
- unsigned char stat2, dummy;
- long new_ptr;
- int ret = ISR_NOTDONE;
-
- BB_DEBUG (("scsi_interrupt()\n"));
-
- stat2 = RD_ADR (SC_STAT2); /* get status before clearing request */
-
-# ifdef DEBUG /* debugging log of interrupts */
- sc_log_head->stat1 = RD_ADR (SC_STAT1);
- sc_log_head->stat2 = stat2;
- if (++sc_log_head >= sc_log + SC_LOG_LEN) sc_log_head = sc_log;
- sc_log_head->stat1 = sc_log_head->stat2 = 0xff;
-# endif
-
- for (;;) {
- dummy = RD_ADR (SC_RESETIP); /* clear interrupt request */
- if (!sc_accept_int || /* return if spurious interrupt */
- (!sc_watchdog_error &&
- (stat2 & SC_S_BSYERR) == 0 && (stat2 & SC_S_PHASE) != 0))
- {
-# ifdef DEBUG
- ++sc_spurious_int;
-# endif
- printf ("sc_spurious_int\n");
- return ret;
- }
- RD_ADR (SC_MODE) &= ~SC_M_DMA; /* clear DMA mode */
- WR_ADR (SC_ICMD, 0); /* disable data bus */
- if (sc_cur_phase != PH_NONE) { /* if did DMA, save the new pointer */
- new_ptr = sc_dma_adr; /* fetch new pointer from DMA cntlr */
- if (sc_cur_phase == PH_IMSG && /* have message? */
- new_ptr != sc_ptrs->ptr[PH_IMSG]) sc_have_msg = 1;
- sc_ptrs->ptr[sc_cur_phase] = /* save pointer */
- new_ptr;
- }
- if (sc_watchdog_error) ret = ISR_TIMEOUT;
- else if (stat2 & SC_S_BSYERR) { /* target deasserted BSY? */
- printf ("target deasserted BSY?\n");
- if (sc_have_msg) ret = ISR_OK;
- else ret = ISR_BSYERR;
- } else if (!(stat2 & SC_S_PHASE)) {/* if phase mismatch, setup new phase */
- printf ("phase mismatch\n");
- sc_cur_phase = /* get new phase from controller */
- (RD_ADR (SC_STAT1) >> 2) & 7;
- new_ptr = sc_ptrs->ptr[sc_cur_phase];
- if (new_ptr == 0) ret = ISR_BADPHASE;
- else {
- WR_ADR (SC_TCMD, sc_cur_phase); /* write new phase into TCMD */
- if (PH_IN (sc_cur_phase)) { /* set DMA controller */
- sc_dma_setup (DISK_READ, new_ptr);
- RD_ADR (SC_MODE) |= SC_M_DMA;
- CLEAR_INTR();
- WR_ADR (SC_START_RCV, 0); /* tell SCSI to start DMA */
- } else {
- sc_dma_setup (DISK_WRITE, new_ptr);
- RD_ADR (SC_MODE) |= SC_M_DMA;
- WR_ADR (SC_ICMD, SC_ENABLE_DB);
- CLEAR_INTR();
- WR_ADR (SC_START_SEND, 0);
- }
- }
- } else ret = ISR_RSTERR;
- if (ret != ISR_NOTDONE) { /* if done, send message to task */
- sc_watchdog_error = 0;
- sc_accept_int = 0;
- WR_ADR (SC_MODE, 0); /* clear monbsy, dma */
- break; /* reti re-enables ints */
- }
- if (0 == ((stat2 = /* check for another interrupt */
- RD_ADR (SC_STAT2)) & SC_S_IRQ))
- {
- break;
- }
- }
- return ret;
-}
-
-/*===========================================================================*
- * sc_dma_setup *
- *===========================================================================*/
-/* Fake DMA setup. Just store pointers and direction in global variables.
- *
- * The pseudo-DMA is subtler than it looks because of the cache.
- *
- * 1) When accessing I/O devices through a cache, some mechanism is
- * necessary to ensure you access the device rather than the cache.
- * On the 32532, the IODEC signal is supposed to be asserted for I/O
- * addresses to accomplish this. However, a bug makes this much
- * slower than necessary and severely hurts pseudo-DMA performance.
- * Hence, IODEC is not asserted for the SCSI DMA port.
- *
- * 2) Because of (1), we must devise our own method of forcing the
- * SCSI DMA port to be read. 0x8000000 addresses have been decoded
- * to all access this port. By always using new addresses to access
- * the DMA port (wrapping only after reading MAX_CACHE bytes), we
- * force cache misses and, hence, device reads. Since the cache
- * is write-through, we do not need to worry about writes.
- *
- * 3) It is possible to miss the last few bytes of a transfer if
- * bus transfer size is not considered. The loop in sc_receive()
- * transfers data until the interrupt signal is asserted. If
- * bytes are transferred, the attempt to move the first byte of a
- * double word causes the whole word to be read into the cache.
- * Then the byte is transferred. If reading the double word
- * completed the SCSI transfer, then the loop exits since
- * interrupt is asserted. However, the last few bytes have only
- * been moved into the cache -- they have not been moved to the
- * DMA destination.
- *
- * 4) It is also possible to miss the first few bytes of a transfer.
- * If the address used to access pseudo-dma port is not double word
- * aligned, the whole double word is read into the cache, and then
- * data is moved from the middle of the word (i.e. something other
- * than the first bytes read from the SCSI controller) by the
- * pseudo-dma loop in sc_receive().
- */
-sc_dma_setup (dir, adr)
-int dir;
-long adr;
-{
- BB_DEBUG (("sc_dma_setup(%d, %d)\n", dir, adr));
-
- CLEAR_INTR();
- /* if (sc_dma_port > SC_DMA + MAX_CACHE) */
- sc_dma_port = SC_DMA;
- sc_dma_dir = dir;
- sc_dma_adr = adr;
-}
-
-/*===========================================================================*
- * sc_receive *
- *===========================================================================*/
-/* Replacement for Minix receive(), which waits for a message. This code
- * spins, waiting for data to transfer or interrupt requests to handle.
- * See sc_dma_setup for details.
- */
-int
-sc_receive()
-{
- int stat2, isr_ret;
- int i, c;
-
- BB_DEBUG (("sc_receive()\n"));
-
- /*
- * check the interrupt-flag and wait if it reappears...
- */
- c = *ka410_intreq;
- printf ("begin: %x/%x ", c, *ka410_intreq);
- for (i=0; i<100; i++) {
- if ((c = *ka410_intreq) & INTR_SC)
- break;
- printf (" %x ", c);
- }
- if (i==100)
- printf ("timeout in sc_receive.\n");
-
-#if 1
- for (;;) {
- stat2 = RD_ADR (SC_STAT2);
- if (stat2 & SC_S_IRQ) {
- if (ISR_NOTDONE != (isr_ret = scsi_interrupt())) break;
- } else if (stat2 & SC_S_DRQ) { /* test really not necessary on pc532 */
- if (sc_dma_dir == DISK_READ)
- *((long *)sc_dma_adr)++ = *((volatile long *)sc_dma_port)++;
- else *((volatile long *)sc_dma_port)++ = *((long *)sc_dma_adr)++;
- }
- }
-#endif
- printf ("isr_ret: %d (ISR_NOTDONE: %d)\n", isr_ret, ISR_NOTDONE);
- return isr_ret;
-}
-
-/*===========================================================================*
- * scCtlrSelect
- *===========================================================================*/
-/* Select a SCSI device.
- */
-scCtlrSelect (ctlr)
-int ctlr;
-{
- BB_DEBUG (("scCtlrSelect()\n"));
-#if 0
- RD_ADR (ICU_IO) &= ~ICU_SCSI_BIT; /* i/o, not port */
- RD_ADR (ICU_DIR) &= ~ICU_SCSI_BIT; /* output */
- if (ctlr == DP8490)
- RD_ADR (ICU_DATA) &= ~ICU_SCSI_BIT; /* select = 0 for 8490 */
- else
- RD_ADR (ICU_DATA) |= ICU_SCSI_BIT; /* select = 1 for AIC6250 */
-#endif
-}
diff --git a/sys/arch/vax/stand/sd.c b/sys/arch/vax/stand/sd.c
deleted file mode 100644
index 72b5318cecc..00000000000
--- a/sys/arch/vax/stand/sd.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/* $OpenBSD: sd.c,v 1.3 1998/05/13 07:30:27 niklas Exp $ */
-/* $NetBSD: sd.c,v 1.1 1996/08/02 11:22:36 ragge Exp $ */
-
-/*
- * Copyright (c) 1988 University of Utah.
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Van Jacobson of Lawrence Berkeley Laboratory and the Systems
- * Programming Group of the University of Utah Computer Science Department.
- *
- * 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: Utah $Hdr: sd.c 1.9 92/12/21$
- *
- * @(#)sd.c 8.1 (Berkeley) 6/10/93
- */
-
-/*
- * SCSI CCS disk driver
- */
-
-#include <sys/param.h>
-#include <sys/disklabel.h>
-#include "stand.h"
-#include "samachdep.h"
-
-#define SC_DEBUG 1 /* bertram */
-#define SD_DEBUG 1 /* bertram */
-
-/*----------------------------------------------------------------------*/
-int
-scsialive(int ctlr)
-{
- return 1; /* controller always alive! */
-}
-
-/* call functions in scsi_hi.c */
-#include "so.h"
-
-int
-scsi_tt_read(ctlr, slave, buf, len, blk, nblk)
- int ctlr, slave;
- u_char *buf;
- u_int len;
- daddr_t blk;
- u_int nblk;
-{
-#ifdef SC_DEBUG
-printf("scsi_tt_read: ctlr %d, slave %d, len %d, blk %d, nblk %d\n",
- ctlr, slave, len, blk, nblk );
-#endif
- if (sc_rdwt(DISK_READ, blk, buf, nblk, 1<<slave, 0) == 0)
- return 0;
- return -2;
-}
-
-int
-scsi_tt_write(ctlr, slave, buf, len, blk, nblk)
- int ctlr, slave;
- u_char *buf;
- u_int len;
- daddr_t blk;
- u_int nblk;
-{
-#ifdef SC_DEBUG
-printf("scsi_tt_write: ctlr %d, slave %d, len %d, blk %d, nblk %d\n",
- ctlr, slave, len, blk, nblk );
-#endif
-#if 0
- if (sc_rdwt(DISK_WRITE, blk, buf, nblk, 1<<slave, 0) == 0)
- return 0;
-#endif
- return -2;
-}
-
-/*----------------------------------------------------------------------*/
-
-struct sd_softc {
- int sc_ctlr;
- int sc_unit;
- int sc_part;
- char sc_retry;
- char sc_alive;
- struct disklabel sc_label;
-} sd_softc[NSCSI][NSD];
-
-#ifdef SD_DEBUG
-int debug = SD_DEBUG;
-#endif
-
-#define SDRETRY 2
-
-sdinit(ctlr, unit)
- int ctlr, unit;
-{
- register struct sd_softc *ss = &sd_softc[ctlr][unit];
-
- /* HP version does test_unit_ready
- * followed by read_capacity to get blocksize
- */
- ss->sc_alive = 1;
- return (1);
-}
-
-sdreset(ctlr, unit)
- int ctlr, unit;
-{
-}
-
-char io_buf[DEV_BSIZE];
-
-sdgetinfo(ss)
- register struct sd_softc *ss;
-{
- register struct disklabel *lp;
- char *msg, *getdisklabel();
- int sdstrategy(), i, err;
-
- lp = &sd_softc[ss->sc_ctlr][ss->sc_unit].sc_label;
- bzero((caddr_t)lp, sizeof *lp);
- lp->d_secsize = DEV_BSIZE;
- lp->d_secpercyl = 1;
- lp->d_npartitions = MAXPARTITIONS;
- lp->d_partitions[ss->sc_part].p_offset = 0;
- lp->d_partitions[ss->sc_part].p_size = 0x7fffffff;
-
- if (err = sdstrategy(ss, F_READ,
- LABELSECTOR, DEV_BSIZE, io_buf, &i) < 0) {
- printf("sdgetinfo: sdstrategy error %d\n", err);
- return 0;
- }
-
- msg = getdisklabel(io_buf, lp);
- if (msg) {
- printf("sd(%d,%d,%d): %s\n",
- ss->sc_ctlr, ss->sc_unit, ss->sc_part, msg);
- return 0;
- }
- return(1);
-}
-
-sdopen(f, ctlr, unit, part)
- struct open_file *f;
- int ctlr, unit, part;
-{
- register struct sd_softc *ss;
- register struct disklabel *lp;
-
-#ifdef SD_DEBUG
- if (debug)
- printf("sdopen: ctlr=%d unit=%d part=%d\n",
- ctlr, unit, part);
-#endif
-
- if (ctlr >= NSCSI || !scsialive(ctlr))
- return (EADAPT);
- if (unit >= NSD)
- return (ECTLR);
- ss = &sd_softc[ctlr][unit]; /* XXX alloc()? keep pointers? */
- ss->sc_part = part;
- ss->sc_unit = unit;
- ss->sc_ctlr = ctlr;
- if (!ss->sc_alive) {
- if (!sdinit(ctlr, unit))
- return (ENXIO);
- if (!sdgetinfo(ss))
- return (ERDLAB);
- }
- lp = &sd_softc[ctlr][unit].sc_label;
- if (part >= lp->d_npartitions || lp->d_partitions[part].p_size == 0)
- return (EPART);
-
- f->f_devdata = (void *)ss;
- return (0);
-}
-
-int
-sdstrategy(ss, func, dblk, size, buf, rsize)
- register struct sd_softc *ss;
- int func;
- daddr_t dblk; /* block number */
- u_int size; /* request size in bytes */
- char *buf;
- u_int *rsize; /* out: bytes transferred */
-{
- register int ctlr = ss->sc_ctlr;
- register int unit = ss->sc_unit;
- register int part = ss->sc_part;
- register struct partition *pp = &ss->sc_label.d_partitions[part];
- u_int nblk = size >> DEV_BSHIFT;
- u_int blk = dblk + pp->p_offset;
- char stat;
-
- if (size == 0)
- return(0);
-
- ss->sc_retry = 0;
-
-#ifdef SD_DEBUG
- if (debug)
- printf("sdstrategy(%d,%d): size=%d blk=%d nblk=%d\n",
- ctlr, unit, size, blk, nblk);
-#endif
-
-retry:
- if (func == F_READ)
- stat = scsi_tt_read(ctlr, unit, buf, size, blk, nblk);
- else
- stat = scsi_tt_write(ctlr, unit, buf, size, blk, nblk);
- if (stat) {
- printf("sd(%d,%d,%d): block=%x, error=0x%x\n",
- ctlr, unit, ss->sc_part, blk, stat);
- if (++ss->sc_retry > SDRETRY)
- return(EIO);
- goto retry;
- }
- *rsize = size;
-
- return(0);
-}
diff --git a/sys/arch/vax/stand/so.h b/sys/arch/vax/stand/so.h
deleted file mode 100644
index 0780371fe47..00000000000
--- a/sys/arch/vax/stand/so.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* $OpenBSD: so.h,v 1.2 1997/05/29 00:04:27 niklas Exp $ */
-/* $NetBSD: so.h,v 1.1 1996/08/02 11:22:41 ragge Exp $ */
-
-#ifndef _SO_H_INCLUDE
-#define _SO_H_INCLUDE
-
-/* Definitions for standalone I/O lib */
-
-/* #define SCSI_POLLED 0x200C0080 */
-#define SCSI_DMA 0x200D0000
-
-/* Which SCSI device to use by default */
-#define DEFAULT_SCSI_ADR 1
-#define DEFAULT_SCSI_LUN 0
-
-/* Low level scsi operation codes */
-#define DISK_READ 3
-#define DISK_WRITE 4
-
-/* The size of a disk block */
-#define DBLKSIZE 512
-
-/* Some disk address that will never be used */
-#define INSANE_BADDR 0x800000
-
-struct scsi_args {
- long ptr [8];
-};
-
-#ifndef NULL
-#define NULL 0L
-#endif
-
-/*
- * The next macro defines where the "break" area in memory ends for
- * malloc() and friends. The area between edata and this address will
- * then be reserved and should not be used for anything else (or you will
- * no doubt have big problems). Depending on where your program's end-of-data
- * is, you may wish to locate this in such a way as to usurp a minimum
- * amount of memory.
- */
-#define BREAK_END_ADDR ((char *)0x400000) /* to 4MB */
-
-/* Selectivly enable inline functions */
-#ifndef NO_INLINE
-#define Inline inline
-#else
-#define Inline
-#endif
-
-extern void fatal(), warn();
-extern long ulimit(int, long);
-extern int brk(char *);
-extern char *sbrk(int);
-
-extern int sc_rdwt();
-
-#endif /* _SO_H_INCLUDE */
diff --git a/sys/arch/vax/stand/string.h b/sys/arch/vax/stand/string.h
deleted file mode 100644
index 13f47b6cfb3..00000000000
--- a/sys/arch/vax/stand/string.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/* $OpenBSD: string.h,v 1.1 1998/05/11 07:38:23 niklas Exp $ */
-
-#define NULL ((char *)0)
diff --git a/sys/arch/vax/stand/xxboot/Makefile b/sys/arch/vax/stand/xxboot/Makefile
new file mode 100644
index 00000000000..22bef4f3d13
--- /dev/null
+++ b/sys/arch/vax/stand/xxboot/Makefile
@@ -0,0 +1,36 @@
+# $OpenBSD: Makefile,v 1.1 2000/04/27 02:26:27 bjc Exp $
+# $NetBSD: Makefile,v 1.2 1999/10/23 14:40:39 ragge Exp $
+
+S=../../../..
+
+PROG= xxboot
+LINKS= ${BINDIR}/xxboot ${BINDIR}/raboot
+LINKS+= ${BINDIR}/xxboot ${BINDIR}/rdboot
+LINKS+= ${BINDIR}/xxboot ${BINDIR}/sdboot
+LINKS+= ${BINDIR}/xxboot ${BINDIR}/hpboot
+
+SRCS= start.s bootxx.c romread.s urem.s udiv.s str.s
+
+STRIPFLAG=
+CPPFLAGS+=-D_STANDALONE -DLIBSA_NO_FD_CHECKING -DLIBSA_NO_RAW_ACCESS \
+ -DLIBSA_NO_TWIDDLE -DLIBSA_SINGLE_DEVICE=rom \
+ -DLIBSA_SINGLE_FILESYSTEM=ufs
+BINDIR= /usr/mdec
+NOMAN= 1
+
+SA_AS= library
+.include "${S}/lib/libsa/Makefile.inc"
+LIBSA= ${SALIB}
+
+${PROG}: ${OBJS} ${LIBSA}
+ ld -N -Ttext 100000 -o a.out ${OBJS} ${LIBSA}
+ strip a.out
+ size a.out
+ dd if=a.out of=${PROG} bs=32 skip=1
+# rm -f a.out
+
+clean::
+ rm -f a.out [Ee]rrs mklog core *.core ${PROG} ${OBJS} ${LOBJS} \
+ ${CLEANFILES}
+
+.include <bsd.prog.mk>
diff --git a/sys/arch/vax/stand/bootxx.c b/sys/arch/vax/stand/xxboot/bootxx.c
index 5cdc2246964..3a1d48fab9f 100644
--- a/sys/arch/vax/stand/bootxx.c
+++ b/sys/arch/vax/stand/xxboot/bootxx.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: bootxx.c,v 1.8 1998/05/13 07:30:21 niklas Exp $ */
-/* $NetBSD: bootxx.c,v 1.11 1997/06/08 17:49:17 ragge Exp $ */
+/* $OpenBSD: bootxx.c,v 1.1 2000/04/27 02:26:27 bjc Exp $ */
+/* $NetBSD: bootxx.c,v 1.2 1999/10/23 14:40:38 ragge Exp $ */
/*-
* Copyright (c) 1982, 1986 The Regents of the University of California.
* All rights reserved.
@@ -54,30 +54,39 @@
#define NRSP 1 /* Kludge */
#define NCMD 1 /* Kludge */
-#include "../uba/ubareg.h"
-#include "../uba/udareg.h"
-
#include "../mscp/mscp.h"
#include "../mscp/mscpreg.h"
-#include "data.h"
#include "vaxstand.h"
-#include <sys/exec.h>
-int romstrategy(), romopen();
-int command(int, int);
+int romstrategy __P((void *, int, daddr_t, size_t, void *, size_t *));
+
+struct fs_ops file_system[] = {
+ { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat }
+};
+
+struct devsw devsw[] = {
+ SADEV("rom", romstrategy, nullsys, nullsys, noioctl),
+};
+
+int nfsys = (sizeof(file_system) / sizeof(struct fs_ops));
+
+int command __P((int cmd, int arg));
/*
* Boot program... argume passed in r10 and r11 determine whether boot
* stops to ask for system name and which device boot comes from.
*/
-volatile u_int devtype, bootdev;
+volatile dev_t devtype, bootdev;
unsigned opendev, boothowto, bootset, memsz;
-extern unsigned *bootregs;
-extern struct rpb *rpb;
+struct open_file file;
+
+unsigned *bootregs;
+struct rpb *rpb;
+int vax_cputype;
/*
* The boot block are used by 11/750, 8200, MicroVAX II/III, VS2000,
@@ -87,13 +96,16 @@ Xmain()
{
int io;
char *scbb;
- char *new;
+ char *new, *bqo;
char *hej = "/boot";
- switch (vax_cputype) {
+ vax_cputype = (mfpr(PR_SID) >> 24) & 0xFF;
- case VAX_TYP_UV2:
- case VAX_TYP_CVAX:
+ /*
+ */
+ switch (vax_cputype) {
+ case VAX_TYP_UV2:
+ case VAX_TYP_CVAX:
case VAX_TYP_RIGEL:
case VAX_TYP_NVAX:
case VAX_TYP_SOC:
@@ -109,71 +121,24 @@ Xmain()
bootregs[11] = (int)rpb;
bootdev = rpb->devtyp;
memsz = rpb->pfncnt << 9;
-
- break;
+ break;
case VAX_8200:
case VAX_750:
bootdev = bootregs[10];
memsz = 0;
-
- break;
+ break;
default:
- printf("unknown cpu type %d\nRegister dump:\n", vax_cputype);
- for (io = 0; io < 16; io++)
- printf("r%d 0x%x\n", io, bootregs[io]);
asm("halt");
- }
+ }
bootset = getbootdev();
- printf("\nhowto 0x%x, bdev 0x%x, booting...", boothowto, bootdev);
io = open(hej, 0);
- if (io >= 0 && io < SOPEN_MAX) {
- copyunix(io);
- } else {
- printf("Boot failed, saerrno %d\n", errno);
- }
-}
-
-/* ARGSUSED */
-copyunix(aio)
-{
- struct exec x;
- register int io = aio, i;
- char *addr;
-
- i = read(io, (char *) &x, sizeof(x));
- if (i != sizeof(x) || N_BADMAG(x)) {
- printf("Bad format\n");
- return;
- }
-
- if (N_GETMAGIC(x) == ZMAGIC && lseek(io, N_TXTADDR(x), SEEK_SET) == -1)
- goto shread;
- if (read(io, (char *) 0x10000, x.a_text) != x.a_text)
- goto shread;
- addr = (char *) x.a_text;
- if (N_GETMAGIC(x) == ZMAGIC || N_GETMAGIC(x) == NMAGIC)
- while ((int) addr & CLOFSET)
- *addr++ = 0;
-
- if (read(io, addr + 0x10000, x.a_data) != x.a_data)
- goto shread;
- addr += x.a_data;
- bcopy((void *) 0x10000, 0, (int) addr);
-
- for (i = 0; i < x.a_bss; i++)
- *addr++ = 0;
- for (i = 0; i < 128 * 512; i++) /* slop */
- *addr++ = 0;
- printf("done. (%d+%d)\n", x.a_text + x.a_data, x.a_bss);
- hoppabort(x.a_entry, boothowto, bootset);
- (*((int (*) ()) x.a_entry)) ();
- return;
-shread:
- printf("Short read\n");
- return;
+ read(io, (void *)0x10000, 0x10000);
+ bcopy((void *) 0x10000, 0, 0xffff);
+ hoppabort(32, boothowto, bootset);
+ asm("halt");
}
getbootdev()
@@ -185,22 +150,19 @@ getbootdev()
switch (vax_cputype) {
case VAX_TYP_UV2:
case VAX_TYP_CVAX:
- adaptor = 0;
- controller = ((rpb->csrphy & 017777) == 0xDC)?1:0;
- unit = rpb->unit; /* DUC, DUD? */
-
- break;
-
case VAX_TYP_RIGEL:
- unit = rpb->unit;
- if (unit > 99)
- unit /= 100; /* DKB300 is target 3 */
+ if (rpb->devtyp == BDEV_SD) {
+ unit = rpb->unit / 100;
+ controller = (rpb->csrphy & 0x100 ? 1 : 0);
+ } else {
+ controller = ((rpb->csrphy & 017777) == 0xDC)?1:0;
+ unit = rpb->unit; /* DUC, DUD? */
+ }
break;
-
case VAX_TYP_8SS:
case VAX_TYP_750:
- controller = 0; /* XXX Actually massbuss can be on 3 ctlr's */
+ controller = bootregs[1];
unit = bootregs[3];
break;
}
@@ -218,43 +180,63 @@ getbootdev()
case BDEV_TK: /* TK50 boot */
case BDEV_CNSL: /* Console storage boot */
case BDEV_RD: /* RD/RX on HDC9224 (MV2000) */
- controller = 0; /* They are always on ctlr 0 */
- break;
-
case BDEV_ST: /* SCSI-tape on NCR5380 (MV2000) */
case BDEV_SD: /* SCSI-disk on NCR5380 (3100/76) */
- /*
- * No standalone routines for SCSI support yet.
- * Use rom-routines instead!
- */
+ break;
+
+ case BDEV_KDB: /* DSA disk on KDB50 (VAXBI VAXen) */
+ bootdev = (bootdev & ~B_TYPEMASK) | BDEV_UDA;
break;
default:
- printf("Unsupported boot device %d, trying anyway.\n", bootdev);
boothowto |= (RB_SINGLE | RB_ASKNAME);
}
return MAKEBOOTDEV(bootdev, adaptor, controller, unit, partition);
}
-struct devsw devsw[] = {
- SADEV("rom", romstrategy,nullsys,nullsys, noioctl),
-};
+/*
+ * Write an extremely limited version of a (us)tar filesystem, suitable
+ * for loading secondary-stage boot loader.
+ * - Can only load file "boot".
+ * - Must be the first file on tape.
+ */
+int tar_open(char *path, struct open_file *f);
+ssize_t tar_read(struct open_file *f, void *buf, size_t size, size_t *resid);
-int ndevs = (sizeof(devsw) / sizeof(devsw[0]));
+int
+tar_open(path, f)
+ char *path;
+ struct open_file *f;
+{
+ char *buf = alloc(512);
-struct fs_ops file_system[] = {
- {ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat}
-};
+ bzero(buf, 512);
+ romstrategy(0, 0, 8192, 512, buf, 0);
+ if (bcmp(buf, "boot", 5) || bcmp(&buf[257], "ustar", 5))
+ return EINVAL; /* Not a ustarfs with "boot" first */
+ return 0;
+}
-int nfsys = (sizeof(file_system) / sizeof(struct fs_ops));
+ssize_t
+tar_read(f, buf, size, resid)
+ struct open_file *f;
+ void *buf;
+ size_t size;
+ size_t *resid;
+{
+ romstrategy(0, 0, (8192+512), size, buf, 0);
+ *resid = size;
+}
struct disklabel lp;
int part_off = 0; /* offset into partition holding /boot */
+char io_buf[DEV_BSIZE];
volatile struct uda {
struct mscp_1ca uda_ca; /* communications area */
struct mscp uda_rsp; /* response packets */
struct mscp uda_cmd; /* command packets */
} uda;
+struct udadevice {u_short udaip;u_short udasa;};
volatile struct udadevice *csr;
devopen(f, fname, file)
@@ -262,6 +244,7 @@ devopen(f, fname, file)
const char *fname;
char **file;
{
+ extern char start;
char *msg;
int i, err, off;
char line[64];
@@ -306,11 +289,7 @@ devopen(f, fname, file)
* Actually disklabel is only needed when using hp disks,
* but it doesn't hurt to always get it.
*/
- if ((bootdev != BDEV_TK) && (bootdev != BDEV_CNSL)) {
- msg = getdisklabel((void *)LABELOFFSET + RELOC, &lp);
- if (msg)
- printf("getdisklabel: %s\n", msg);
- }
+ getdisklabel(LABELOFFSET + &start, &lp);
return 0;
}
@@ -336,8 +315,9 @@ romstrategy(sc, func, dblk, size, buf, rsize)
void *sc;
int func;
daddr_t dblk;
- char *buf;
- int size, *rsize;
+ size_t size;
+ void *buf;
+ size_t *rsize;
{
int i;
int block = dblk;
@@ -395,8 +375,8 @@ romstrategy(sc, func, dblk, size, buf, rsize)
case VAX_750:
if (bootdev != BDEV_HP) {
while (size > 0) {
- while ((read750(block, bootregs) & 0x01) == 0)
- printf("Retrying read bn# %d\n", block);
+ while ((read750(block, bootregs) & 0x01) == 0){
+ }
bcopy(0, buf, 512);
size -= 512;
buf += 512;
@@ -407,7 +387,8 @@ romstrategy(sc, func, dblk, size, buf, rsize)
break;
}
- *rsize = nsize;
+ if (rsize)
+ *rsize = nsize;
return 0;
}
@@ -439,3 +420,29 @@ hpread(block, size, buf)
}
return 0;
}
+
+extern char end[];
+static char *top = (char*)end;
+
+void *
+alloc(size)
+ unsigned size;
+{
+ void *ut = top;
+ top += size;
+ return ut;
+}
+
+void
+free(ptr, size)
+ void *ptr;
+ unsigned size;
+{
+}
+
+int
+romclose(f)
+ struct open_file *f;
+{
+ return 0;
+}
diff --git a/sys/arch/vax/stand/start.s b/sys/arch/vax/stand/xxboot/start.s
index 61f75d87ba4..d20753cf901 100644
--- a/sys/arch/vax/stand/start.s
+++ b/sys/arch/vax/stand/xxboot/start.s
@@ -1,5 +1,5 @@
-/* $OpenBSD: start.s,v 1.6 1998/02/03 11:48:29 maja Exp $ */
-/* $NetBSD: start.s,v 1.10 1997/03/22 12:47:32 ragge Exp $ */
+/* $OpenBSD: start.s,v 1.1 2000/04/27 02:26:27 bjc Exp $ */
+/* $NetBSD: start.s,v 1.2 1999/10/23 14:40:38 ragge Exp $ */
/*
* Copyright (c) 1995 Ludd, University of Lule}, Sweden.
* All rights reserved.
@@ -173,7 +173,6 @@ start_all:
relocated: # now relocation is done !!!
movl sp, _bootregs
movl ap, _boothowto
- calls $0, _setup
calls $0, _Xmain # call Xmain (gcc workaround)which is
halt # not intended to return ...
@@ -189,3 +188,13 @@ ENTRY(hoppabort, 0)
jmp 2(r6)
# calls $0,(r6)
halt
+
+# A bunch of functions unwanted in boot blocks.
+ENTRY(getchar, 0)
+ halt
+
+ENTRY(putchar, 0)
+ ret
+
+ENTRY(panic, 0)
+ halt