From 56644002c5cb52c79e4f6d8eadc328882f24df33 Mon Sep 17 00:00:00 2001 From: Brandon Creighton Date: Thu, 27 Apr 2000 02:26:28 +0000 Subject: sync with netbsd -- this involved rearranging things for sanity reasons and because separate builds of libsa are done. this is a pretty nice bootloader. --- sys/arch/vax/boot/Makefile | 117 +------ sys/arch/vax/boot/autoconf.c | 155 --------- sys/arch/vax/boot/boot.c | 254 -------------- sys/arch/vax/boot/boot/Makefile | 47 +++ sys/arch/vax/boot/boot/autoconf.c | 257 ++++++++++++++ sys/arch/vax/boot/boot/boot.c | 299 ++++++++++++++++ sys/arch/vax/boot/boot/conf.c | 103 ++++++ sys/arch/vax/boot/boot/consio.c | 323 +++++++++++++++++ sys/arch/vax/boot/boot/ctu.c | 182 ++++++++++ sys/arch/vax/boot/boot/data.h | 75 ++++ sys/arch/vax/boot/boot/devopen.c | 123 +++++++ sys/arch/vax/boot/boot/hp.c | 166 +++++++++ sys/arch/vax/boot/boot/if_le.c | 389 +++++++++++++++++++++ sys/arch/vax/boot/boot/if_qe.c | 276 +++++++++++++++ sys/arch/vax/boot/boot/if_ze.c | 304 ++++++++++++++++ sys/arch/vax/boot/boot/mfm.c | 655 +++++++++++++++++++++++++++++++++++ sys/arch/vax/boot/boot/netio.c | 278 +++++++++++++++ sys/arch/vax/boot/boot/ra.c | 256 ++++++++++++++ sys/arch/vax/boot/boot/rom.c | 124 +++++++ sys/arch/vax/boot/boot/tmscp.c | 204 +++++++++++ sys/arch/vax/boot/bootxx.c | 441 ----------------------- sys/arch/vax/boot/common/romread.s | 94 +++++ sys/arch/vax/boot/common/srt0.s | 89 +++++ sys/arch/vax/boot/common/str.s | 147 ++++++++ sys/arch/vax/boot/common/vaxstand.h | 59 ++++ sys/arch/vax/boot/conf.c | 102 ------ sys/arch/vax/boot/consio.c | 218 ------------ sys/arch/vax/boot/copy.c | 246 ------------- sys/arch/vax/boot/ctu.c | 182 ---------- sys/arch/vax/boot/data.h | 75 ---- sys/arch/vax/boot/devopen.c | 145 -------- sys/arch/vax/boot/edlabel.c | 225 ------------ sys/arch/vax/boot/hp.c | 166 --------- sys/arch/vax/boot/if_le.c | 283 --------------- sys/arch/vax/boot/ka410.h | 83 ----- sys/arch/vax/boot/mfm.c | 655 ----------------------------------- sys/arch/vax/boot/netio.c | 245 ------------- sys/arch/vax/boot/ra.c | 232 ------------- sys/arch/vax/boot/rom.c | 124 ------- sys/arch/vax/boot/romread.s | 94 ----- sys/arch/vax/boot/samachdep.h | 43 --- sys/arch/vax/boot/scsi_hi.c | 298 ---------------- sys/arch/vax/boot/scsi_low.c | 480 ------------------------- sys/arch/vax/boot/sd.c | 248 ------------- sys/arch/vax/boot/so.h | 58 ---- sys/arch/vax/boot/srt0.s | 85 ----- sys/arch/vax/boot/start.s | 191 ---------- sys/arch/vax/boot/str.s | 133 ------- sys/arch/vax/boot/string.h | 3 - sys/arch/vax/boot/tmscp.c | 203 ----------- sys/arch/vax/boot/vaxstand.h | 53 --- sys/arch/vax/boot/xxboot/Makefile | 36 ++ sys/arch/vax/boot/xxboot/bootxx.c | 448 ++++++++++++++++++++++++ sys/arch/vax/boot/xxboot/start.s | 200 +++++++++++ sys/arch/vax/stand/Makefile | 117 +------ sys/arch/vax/stand/autoconf.c | 155 --------- sys/arch/vax/stand/boot.c | 254 -------------- sys/arch/vax/stand/boot/Makefile | 47 +++ sys/arch/vax/stand/boot/autoconf.c | 257 ++++++++++++++ sys/arch/vax/stand/boot/boot.c | 299 ++++++++++++++++ sys/arch/vax/stand/boot/conf.c | 103 ++++++ sys/arch/vax/stand/boot/consio.c | 323 +++++++++++++++++ sys/arch/vax/stand/boot/ctu.c | 182 ++++++++++ sys/arch/vax/stand/boot/data.h | 75 ++++ sys/arch/vax/stand/boot/devopen.c | 123 +++++++ sys/arch/vax/stand/boot/hp.c | 166 +++++++++ sys/arch/vax/stand/boot/if_le.c | 389 +++++++++++++++++++++ sys/arch/vax/stand/boot/if_qe.c | 276 +++++++++++++++ sys/arch/vax/stand/boot/if_ze.c | 304 ++++++++++++++++ sys/arch/vax/stand/boot/mfm.c | 655 +++++++++++++++++++++++++++++++++++ sys/arch/vax/stand/boot/netio.c | 278 +++++++++++++++ sys/arch/vax/stand/boot/ra.c | 256 ++++++++++++++ sys/arch/vax/stand/boot/rom.c | 124 +++++++ sys/arch/vax/stand/boot/tmscp.c | 204 +++++++++++ sys/arch/vax/stand/bootxx.c | 441 ----------------------- sys/arch/vax/stand/common/romread.s | 94 +++++ sys/arch/vax/stand/common/srt0.s | 89 +++++ sys/arch/vax/stand/common/str.s | 147 ++++++++ sys/arch/vax/stand/common/vaxstand.h | 59 ++++ sys/arch/vax/stand/conf.c | 102 ------ sys/arch/vax/stand/consio.c | 218 ------------ sys/arch/vax/stand/copy.c | 246 ------------- sys/arch/vax/stand/ctu.c | 182 ---------- sys/arch/vax/stand/data.h | 75 ---- sys/arch/vax/stand/devopen.c | 145 -------- sys/arch/vax/stand/edlabel.c | 225 ------------ sys/arch/vax/stand/hp.c | 166 --------- sys/arch/vax/stand/if_le.c | 283 --------------- sys/arch/vax/stand/ka410.h | 83 ----- sys/arch/vax/stand/mfm.c | 655 ----------------------------------- sys/arch/vax/stand/netio.c | 245 ------------- sys/arch/vax/stand/ra.c | 232 ------------- sys/arch/vax/stand/rom.c | 124 ------- sys/arch/vax/stand/romread.s | 94 ----- sys/arch/vax/stand/samachdep.h | 43 --- sys/arch/vax/stand/scsi_hi.c | 298 ---------------- sys/arch/vax/stand/scsi_low.c | 480 ------------------------- sys/arch/vax/stand/sd.c | 248 ------------- sys/arch/vax/stand/so.h | 58 ---- sys/arch/vax/stand/srt0.s | 85 ----- sys/arch/vax/stand/start.s | 191 ---------- sys/arch/vax/stand/str.s | 133 ------- sys/arch/vax/stand/string.h | 3 - sys/arch/vax/stand/tmscp.c | 203 ----------- sys/arch/vax/stand/vaxstand.h | 53 --- sys/arch/vax/stand/xxboot/Makefile | 36 ++ sys/arch/vax/stand/xxboot/bootxx.c | 448 ++++++++++++++++++++++++ sys/arch/vax/stand/xxboot/start.s | 200 +++++++++++ 108 files changed, 10276 insertions(+), 11666 deletions(-) delete mode 100644 sys/arch/vax/boot/autoconf.c delete mode 100644 sys/arch/vax/boot/boot.c create mode 100644 sys/arch/vax/boot/boot/Makefile create mode 100644 sys/arch/vax/boot/boot/autoconf.c create mode 100644 sys/arch/vax/boot/boot/boot.c create mode 100644 sys/arch/vax/boot/boot/conf.c create mode 100644 sys/arch/vax/boot/boot/consio.c create mode 100644 sys/arch/vax/boot/boot/ctu.c create mode 100644 sys/arch/vax/boot/boot/data.h create mode 100644 sys/arch/vax/boot/boot/devopen.c create mode 100644 sys/arch/vax/boot/boot/hp.c create mode 100644 sys/arch/vax/boot/boot/if_le.c create mode 100644 sys/arch/vax/boot/boot/if_qe.c create mode 100644 sys/arch/vax/boot/boot/if_ze.c create mode 100644 sys/arch/vax/boot/boot/mfm.c create mode 100644 sys/arch/vax/boot/boot/netio.c create mode 100644 sys/arch/vax/boot/boot/ra.c create mode 100644 sys/arch/vax/boot/boot/rom.c create mode 100644 sys/arch/vax/boot/boot/tmscp.c delete mode 100644 sys/arch/vax/boot/bootxx.c create mode 100644 sys/arch/vax/boot/common/romread.s create mode 100644 sys/arch/vax/boot/common/srt0.s create mode 100644 sys/arch/vax/boot/common/str.s create mode 100644 sys/arch/vax/boot/common/vaxstand.h delete mode 100644 sys/arch/vax/boot/conf.c delete mode 100644 sys/arch/vax/boot/consio.c delete mode 100644 sys/arch/vax/boot/copy.c delete mode 100644 sys/arch/vax/boot/ctu.c delete mode 100644 sys/arch/vax/boot/data.h delete mode 100644 sys/arch/vax/boot/devopen.c delete mode 100644 sys/arch/vax/boot/edlabel.c delete mode 100644 sys/arch/vax/boot/hp.c delete mode 100644 sys/arch/vax/boot/if_le.c delete mode 100644 sys/arch/vax/boot/ka410.h delete mode 100644 sys/arch/vax/boot/mfm.c delete mode 100644 sys/arch/vax/boot/netio.c delete mode 100644 sys/arch/vax/boot/ra.c delete mode 100644 sys/arch/vax/boot/rom.c delete mode 100644 sys/arch/vax/boot/romread.s delete mode 100644 sys/arch/vax/boot/samachdep.h delete mode 100644 sys/arch/vax/boot/scsi_hi.c delete mode 100644 sys/arch/vax/boot/scsi_low.c delete mode 100644 sys/arch/vax/boot/sd.c delete mode 100644 sys/arch/vax/boot/so.h delete mode 100644 sys/arch/vax/boot/srt0.s delete mode 100644 sys/arch/vax/boot/start.s delete mode 100644 sys/arch/vax/boot/str.s delete mode 100644 sys/arch/vax/boot/string.h delete mode 100644 sys/arch/vax/boot/tmscp.c delete mode 100644 sys/arch/vax/boot/vaxstand.h create mode 100644 sys/arch/vax/boot/xxboot/Makefile create mode 100644 sys/arch/vax/boot/xxboot/bootxx.c create mode 100644 sys/arch/vax/boot/xxboot/start.s delete mode 100644 sys/arch/vax/stand/autoconf.c delete mode 100644 sys/arch/vax/stand/boot.c create mode 100644 sys/arch/vax/stand/boot/Makefile create mode 100644 sys/arch/vax/stand/boot/autoconf.c create mode 100644 sys/arch/vax/stand/boot/boot.c create mode 100644 sys/arch/vax/stand/boot/conf.c create mode 100644 sys/arch/vax/stand/boot/consio.c create mode 100644 sys/arch/vax/stand/boot/ctu.c create mode 100644 sys/arch/vax/stand/boot/data.h create mode 100644 sys/arch/vax/stand/boot/devopen.c create mode 100644 sys/arch/vax/stand/boot/hp.c create mode 100644 sys/arch/vax/stand/boot/if_le.c create mode 100644 sys/arch/vax/stand/boot/if_qe.c create mode 100644 sys/arch/vax/stand/boot/if_ze.c create mode 100644 sys/arch/vax/stand/boot/mfm.c create mode 100644 sys/arch/vax/stand/boot/netio.c create mode 100644 sys/arch/vax/stand/boot/ra.c create mode 100644 sys/arch/vax/stand/boot/rom.c create mode 100644 sys/arch/vax/stand/boot/tmscp.c delete mode 100644 sys/arch/vax/stand/bootxx.c create mode 100644 sys/arch/vax/stand/common/romread.s create mode 100644 sys/arch/vax/stand/common/srt0.s create mode 100644 sys/arch/vax/stand/common/str.s create mode 100644 sys/arch/vax/stand/common/vaxstand.h delete mode 100644 sys/arch/vax/stand/conf.c delete mode 100644 sys/arch/vax/stand/consio.c delete mode 100644 sys/arch/vax/stand/copy.c delete mode 100644 sys/arch/vax/stand/ctu.c delete mode 100644 sys/arch/vax/stand/data.h delete mode 100644 sys/arch/vax/stand/devopen.c delete mode 100644 sys/arch/vax/stand/edlabel.c delete mode 100644 sys/arch/vax/stand/hp.c delete mode 100644 sys/arch/vax/stand/if_le.c delete mode 100644 sys/arch/vax/stand/ka410.h delete mode 100644 sys/arch/vax/stand/mfm.c delete mode 100644 sys/arch/vax/stand/netio.c delete mode 100644 sys/arch/vax/stand/ra.c delete mode 100644 sys/arch/vax/stand/rom.c delete mode 100644 sys/arch/vax/stand/romread.s delete mode 100644 sys/arch/vax/stand/samachdep.h delete mode 100644 sys/arch/vax/stand/scsi_hi.c delete mode 100644 sys/arch/vax/stand/scsi_low.c delete mode 100644 sys/arch/vax/stand/sd.c delete mode 100644 sys/arch/vax/stand/so.h delete mode 100644 sys/arch/vax/stand/srt0.s delete mode 100644 sys/arch/vax/stand/start.s delete mode 100644 sys/arch/vax/stand/str.s delete mode 100644 sys/arch/vax/stand/string.h delete mode 100644 sys/arch/vax/stand/tmscp.c delete mode 100644 sys/arch/vax/stand/vaxstand.h create mode 100644 sys/arch/vax/stand/xxboot/Makefile create mode 100644 sys/arch/vax/stand/xxboot/bootxx.c create mode 100644 sys/arch/vax/stand/xxboot/start.s (limited to 'sys/arch/vax') 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 - +SUBDIR= boot xxboot +.include 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.c b/sys/arch/vax/boot/boot.c deleted file mode 100644 index b0df2b865b0..00000000000 --- a/sys/arch/vax/boot/boot.c +++ /dev/null @@ -1,254 +0,0 @@ -/* $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 $ */ -/*- - * 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" - -#define V750UCODE(x) ((x>>8)&255) - -#include - -/* - * Boot program... arguments passed in r10 and r11 determine - * whether boot stops to ask for system name and which device - * boot comes from. - */ - -char line[100]; -volatile int devtype, bootdev; -extern unsigned opendev; -extern unsigned *bootregs; - -Xmain() -{ - register howto asm("r11"); - register bdev asm("r10"); - int io, retry, type; - extern char vers[]; - - io=0; - bootdev=bdev; - autoconf(); - - if ((howto & RB_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; - } - - 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 (++retry > 2) - howto |= RB_SINGLE|RB_ASKNAME; - } -} - -/*ARGSUSED*/ -copyunix(howto, devtype, aio) - register howto, devtype; /* howto=r11, devtype=r10 */ - int aio; -{ - register int esym; /* must be r9 */ - struct exec x; - register int io = aio, i; - char *addr; - - if (read(io, (char *)&x, sizeof(x)) != sizeof(x) || N_BADMAG(x)) { - printf("Bad format\n"); - return; - } - 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; -} - -/* 750 Patchable Control Store magic */ - -#include "../include/mtpr.h" -#include "../include/cpu.h" -#include "../include/sid.h" -#define PCS_BITCNT 0x2000 /* number of patchbits */ -#define PCS_MICRONUM 0x400 /* number of ucode locs */ -#define PCS_PATCHADDR 0xf00000 /* start addr of patchbits */ -#define PCS_PCSADDR (PCS_PATCHADDR+0x8000) /* start addr of pcs */ -#define PCS_PATCHBIT (PCS_PATCHADDR+0xc000) /* patchbits enable reg */ -#define PCS_ENABLE 0xfff00000 /* enable bits for pcs */ - -#define extzv(one, two, three,four) \ -({ \ - asm __volatile (" extzv %0,%3,(%1),(%2)+" \ - : \ - : "g"(one),"g"(two),"g"(three),"g"(four)); \ -}) - - -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); - char pcs[100]; - char *cp; - - if ((mid >> 24) != VAX_750 || ((mid >> 8) & 255) < 95 || pcsdone) - return; - printf("Updating 11/750 microcode: "); - for (cp = line; *cp; cp++) - if (*cp == ')' || *cp == ':') - break; - if (*cp) { - bcopy(line, pcs, 99); - pcs[99] = 0; - i = cp - line + 1; - } else - i = 0; - strcpy(pcs + i, "pcs750.bin"); - i = open(pcs, 0); - if (i < 0) { - printf("bad luck - missing pcs750.bin :-(\n"); - return; - } - /* - * We ask for more than we need to be sure we get only what we expect. - * After read: - * locs 0 - 1023 packed patchbits - * 1024 - 11264 packed microcode - */ - if (read(i, (char *)0, 23*512) != 22*512) { - printf("Error reading %s\n", pcs); - close(i); - return; - } - close(i); - - /* - * Enable patchbit loading and load the bits one at a time. - */ - *((int *)PCS_PATCHBIT) = 1; - ip = (int *)PCS_PATCHADDR; - jp = (int *)0; - for (i=0; i < PCS_BITCNT; i++) { - extzv(i,jp,ip,1); - } - *((int *)PCS_PATCHBIT) = 0; - - /* - * Load PCS microcode 20 bits at a time. - */ - ip = (int *)PCS_PCSADDR; - jp = (int *)1024; - for (i=j=0; j < PCS_MICRONUM * 4; i+=20, j++) { - extzv(i,jp,ip,20); - } - - /* - * Enable PCS. - */ - i = *jp; /* get 1st 20 bits of microcode again */ - i &= 0xfffff; - i |= PCS_ENABLE; /* reload these bits with PCS enable set */ - *((int *)PCS_PCSADDR) = i; - - mid = mfpr(PR_SID); - printf("new rev level=%d\n", V750UCODE(mid)); - pcsdone = 1; -} 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 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/boot.c b/sys/arch/vax/boot/boot/boot.c new file mode 100644 index 00000000000..e6cde511d76 --- /dev/null +++ b/sys/arch/vax/boot/boot/boot.c @@ -0,0 +1,299 @@ +/* $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. + * + * 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" + +#define V750UCODE(x) ((x>>8)&255) + +#include "vaxstand.h" + +/* + * Boot program... arguments passed in r10 and r11 determine + * whether boot stops to ask for system name and which device + * boot comes from. + */ + +char line[100]; +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() +{ + int io, type, sluttid, askname, filindex = 0; + int j, senast = 0, nu; + + io=0; + autoconf(); + + 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) + 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; + } + } + + /* 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 (v->namn) + (*v->func)(d); + else + printf("Unknown command: %s\n", c); + + } +} + +void +halt() +{ + asm("halt"); +} + +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; + } + } +load: exec(fn, 0, 0); + printf("Boot failed: %s\n", strerror(errno)); +} + +/* 750 Patchable Control Store magic */ + +#include "../include/mtpr.h" +#include "../include/cpu.h" +#include "../include/sid.h" +#define PCS_BITCNT 0x2000 /* number of patchbits */ +#define PCS_MICRONUM 0x400 /* number of ucode locs */ +#define PCS_PATCHADDR 0xf00000 /* start addr of patchbits */ +#define PCS_PCSADDR (PCS_PATCHADDR+0x8000) /* start addr of pcs */ +#define PCS_PATCHBIT (PCS_PATCHADDR+0xc000) /* patchbits enable reg */ +#define PCS_ENABLE 0xfff00000 /* enable bits for pcs */ + +#define extzv(one, two, three,four) \ +({ \ + asm __volatile (" extzv %0,%3,(%1),(%2)+" \ + : \ + : "g"(one),"g"(two),"g"(three),"g"(four)); \ +}) + + +loadpcs() +{ + static int pcsdone = 0; + int mid = mfpr(PR_SID); + int i, j, *ip, *jp; + char pcs[100]; + char *cp; + + if ((mid >> 24) != VAX_750 || ((mid >> 8) & 255) < 95 || pcsdone) + return; + printf("Updating 11/750 microcode: "); + for (cp = line; *cp; cp++) + if (*cp == ')' || *cp == ':') + break; + if (*cp) { + bcopy(line, pcs, 99); + pcs[99] = 0; + i = cp - line + 1; + } else + i = 0; + strcpy(pcs + i, "pcs750.bin"); + i = open(pcs, 0); + if (i < 0) { + printf("bad luck - missing pcs750.bin :-(\n"); + return; + } + /* + * We ask for more than we need to be sure we get only what we expect. + * After read: + * locs 0 - 1023 packed patchbits + * 1024 - 11264 packed microcode + */ + if (read(i, (char *)0, 23*512) != 22*512) { + printf("Error reading %s\n", pcs); + close(i); + return; + } + close(i); + + /* + * Enable patchbit loading and load the bits one at a time. + */ + *((int *)PCS_PATCHBIT) = 1; + ip = (int *)PCS_PATCHADDR; + jp = (int *)0; + for (i=0; i < PCS_BITCNT; i++) { + extzv(i,jp,ip,1); + } + *((int *)PCS_PATCHBIT) = 0; + + /* + * Load PCS microcode 20 bits at a time. + */ + ip = (int *)PCS_PCSADDR; + jp = (int *)1024; + for (i=j=0; j < PCS_MICRONUM * 4; i+=20, j++) { + extzv(i,jp,ip,20); + } + + /* + * Enable PCS. + */ + i = *jp; /* get 1st 20 bits of microcode again */ + i &= 0xfffff; + i |= PCS_ENABLE; /* reload these bits with PCS enable set */ + *((int *)PCS_PCSADDR) = i; + + mid = mfpr(PR_SID); + 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/boot/conf.c b/sys/arch/vax/boot/boot/conf.c new file mode 100644 index 00000000000..334fe0cd933 --- /dev/null +++ b/sys/arch/vax/boot/boot/conf.c @@ -0,0 +1,103 @@ +/* $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. + * + * 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 "../../include/rpb.h" + +#include "lib/libsa/stand.h" +#include "lib/libsa/ufs.h" +#include "lib/libsa/nfs.h" + +#include "vaxstand.h" + +int raopen(), rastrategy(); +int hpopen(), hpstrategy(); +int ctuopen(), ctustrategy(); +int tmscpopen(), tmscpstrategy(); +int romopen(), romstrategy(); +int mfmopen(), mfmstrategy(); +int sdopen(), sdstrategy(); +int netopen(), netstrategy(), netclose(); + +struct devsw devsw[]={ + SADEV("hp",hpstrategy, hpopen, nullsys, noioctl), + SADEV("qe",netstrategy, netopen, netclose, noioctl), /* DEQNA */ + SADEV("ctu",ctustrategy, ctuopen, nullsys, noioctl), + SADEV("ra",rastrategy, raopen, nullsys, noioctl), + SADEV("mt",tmscpstrategy, tmscpopen, nullsys, noioctl), + SADEV("rom",romstrategy, romopen, nullsys, noioctl), + SADEV("rd",mfmstrategy, mfmopen, 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[] = { + BDEV_HP, + BDEV_QE, + BDEV_CNSL, + BDEV_UDA, + BDEV_TK, + -1, + BDEV_RD, + 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 }, + { nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat }, +}; + +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, + &le_driver, + &ze_driver, +}; +int n_netif_drivers = (sizeof(netif_drivers) / sizeof(netif_drivers[0])); + diff --git a/sys/arch/vax/boot/boot/consio.c b/sys/arch/vax/boot/boot/consio.c new file mode 100644 index 00000000000..9cb131fb945 --- /dev/null +++ b/sys/arch/vax/boot/boot/consio.c @@ -0,0 +1,323 @@ +/* $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, 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 "../vax/gencons.h" + +#include "mtpr.h" +#include "sid.h" +#include "rpb.h" + +#include "data.h" + +void setup __P((void)); + +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; +{ + (*put_fp)(c); + if (c == 10) + (*put_fp)(13); /* CR/LF */ +} + +getchar() +{ + int c; + + 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 +consinit() +{ + put_fp = pr_putchar; /* Default */ + get_fp = pr_getchar; + test_fp = pr_testchar; + + rpb = (struct rpb *)bootregs[11]; /* bertram: ??? */ + + /* + * According to the vax_boardtype (vax_cputype is not specific + * enough to do that) we decide which method/routines to use + * for console I/O. + * mtpr/mfpr are restricted to serial consoles, ROM-based routines + * support both serial and graphical consoles. + * We default to mtpr routines; so that we don't crash if + * it isn't a supported system. + */ + switch (vax_boardtype) { + + 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_410: + case VAX_BTYP_420: + 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: + case VAX_BTYP_9CC: + case VAX_BTYP_60: + put_fp = pr_putchar; + get_fp = pr_getchar; + break +#endif + } + return; +} + +/* + * putchar() using MTPR + */ +pr_putchar(c) + int c; +{ + int timeout = 1<<15; /* don't hang the machine! */ + while ((mfpr(PR_TXCS) & GC_RDY) == 0) /* Wait until xmit ready */ + if (--timeout < 0) + break; + mtpr(c, PR_TXDB); /* xmit character */ +} + +/* + * getchar() using MFPR + */ +pr_getchar() +{ + while ((mfpr(PR_RXCS) & GC_DON) == 0); /* wait for char */ + 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 + */ +asm(" + .globl _rom_putchar + _rom_putchar: + .word 0x04 # save-mask: R2 + movl 4(ap), r2 # move argument to R2 + jsb *_rom_putc # write it + ret # that's all +"); + + +/* + * int rom_getchar (void) ==> getchar() using ROM-routines + */ +asm(" + .globl _rom_getchar + _rom_getchar: + .word 0x02 # save-mask: R1 + loop: # do { + jsb *_rom_getc # call the getc-routine + tstl r0 # check if char ready + 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() +{ + 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/boot/ctu.c b/sys/arch/vax/boot/boot/ctu.c new file mode 100644 index 00000000000..3f2c9afb891 --- /dev/null +++ b/sys/arch/vax/boot/boot/ctu.c @@ -0,0 +1,182 @@ +/* $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. + * 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. + */ + +/* + * Standalone device driver for 11/750 Console TU58. + * It can only handle reads, and doesn't calculate checksum. + */ + +#include + +#include + +#include +#include + +enum tu_state { + SC_INIT, + SC_READY, + SC_SEND_CMD, + SC_GET_RESP, +}; + +volatile struct tu_softc { + enum tu_state sc_state; + char sc_rsp[15]; /* Should be struct rsb; but don't work */ + u_char *sc_xfptr; /* Current char to xfer */ + int sc_nbytes; /* Number of bytes to xfer */ + int sc_xbytes; /* Number of xfer'd bytes */ + int sc_bbytes; /* Number of xfer'd bytes this block */ +} tu_sc; + +void ctutintr __P((void)); +void cturintr __P((void)); + +int +ctuopen(f, adapt, ctlr, unit, part) + struct open_file *f; + int ctlr, unit, part; +{ + + tu_sc.sc_state = SC_INIT; + + mtpr(RSP_TYP_INIT, PR_CSTD); + cturintr(); + tu_sc.sc_state = SC_READY; + return 0; + +} + +int +ctustrategy(ra, func, dblk, size, buf, rsize) + struct ra_softc *ra; + int func; + daddr_t dblk; + char *buf; + u_int size, *rsize; +{ + int s; + + struct rsp *rsp = (struct rsp *)tu_sc.sc_rsp; + + tu_sc.sc_xfptr = buf; + tu_sc.sc_nbytes = size; + tu_sc.sc_xbytes = tu_sc.sc_bbytes = 0; + + rsp->rsp_typ = RSP_TYP_COMMAND; + rsp->rsp_sz = 012; + rsp->rsp_op = RSP_OP_READ; + rsp->rsp_mod = 0; + rsp->rsp_drv = 0; + rsp->rsp_sw = rsp->rsp_xx1 = rsp->rsp_xx2 = 0; + rsp->rsp_cnt = tu_sc.sc_nbytes; + rsp->rsp_blk = dblk; + rsp->rsp_sum = ctu_cksum(rsp, 6); + tu_sc.sc_state = SC_SEND_CMD; + while (tu_sc.sc_state != SC_GET_RESP) + ctutintr(); + while (tu_sc.sc_state != SC_READY) + cturintr(); + *rsize = size; + return 0; +} + +void +cturintr() +{ + int status; + + while ((mfpr(PR_CSRS) & 0x80) == 0) + ; + + status = mfpr(PR_CSRD); + + switch (tu_sc.sc_state) { + + case SC_INIT: + break; + + case SC_GET_RESP: + if (tu_sc.sc_xbytes == tu_sc.sc_nbytes) { + tu_sc.sc_bbytes++; + if (tu_sc.sc_bbytes == 146) + tu_sc.sc_state = SC_READY; + break; + } + tu_sc.sc_bbytes++; + if (tu_sc.sc_bbytes < 3) /* Data header */ + break; + if (tu_sc.sc_bbytes == 132) { /* Finished */ + tu_sc.sc_bbytes = 0; + break; + } + if (tu_sc.sc_bbytes == 131) /* First checksum */ + break; + tu_sc.sc_xfptr[tu_sc.sc_xbytes++] = status; + break; + + } + +} + +void +ctutintr() +{ + int c; + + while ((mfpr(PR_CSTS) & 0x80) == 0) + ; + + c = tu_sc.sc_rsp[tu_sc.sc_xbytes++] & 0xff; + mtpr(c, PR_CSTD); + if (tu_sc.sc_xbytes > 13) { + tu_sc.sc_state = SC_GET_RESP; + tu_sc.sc_xbytes = 0; + } +} + +ctu_cksum(buf, words) + unsigned short *buf; + int words; +{ + int i, cksum; + + for (i = cksum = 0; i < words; i++) + cksum += buf[i]; + +hej: if (cksum > 65535) { + cksum = (cksum & 65535) + (cksum >> 16); + goto hej; + } + return cksum; +} diff --git a/sys/arch/vax/boot/boot/data.h b/sys/arch/vax/boot/boot/data.h new file mode 100644 index 00000000000..9098d501d70 --- /dev/null +++ b/sys/arch/vax/boot/boot/data.h @@ -0,0 +1,75 @@ +/* $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. + * 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. + */ + + /* All bugs are subject to removal without further notice */ + + + +extern unsigned *bootregs; + +/* + * rpb->iovec gives pointer to this structure. + * + * bqo->unit_init() is used to initialize the controller, + * bqo->qio() is used to read from boot-device + */ + +struct bqo { + long qio; /* 4 QIO entry */ + long map; /* 4 Mapping entry */ + long select; /* 4 Selection entry */ + long drivrname; /* 4 Offset to driver name */ + short version; /* 2 Version number of VMB */ + short vercheck; /* 2 Check field */ + /* offset: 20 */ + long reselect; /* 4 Reselection entry */ + long move; /* 4 Move driver entry */ + long unit_init; /* 4 Unit initialization entry */ + long auxdrname; /* 4 Offset to auxiliary driver name */ + long umr_dis; /* 4 UNIBUS Map Registers to disable */ + /* offset: 40 */ + long ucode; /* 4 Absolute address of booting microcode */ + long unit_disc; /* 4 Unit disconnecting entry */ + long devname; /* 4 Offset to boot device name */ + long umr_tmpl; /* 4 UNIBUS map register template */ + /* offset: 60 */ + /* + * the rest is unknown / unneccessary ... + */ + long xxx[6]; /* 24 -- total: 84 bytes */ +}; + +extern struct bqo *bqo; diff --git a/sys/arch/vax/boot/boot/devopen.c b/sys/arch/vax/boot/boot/devopen.c new file mode 100644 index 00000000000..c832398b951 --- /dev/null +++ b/sys/arch/vax/boot/boot/devopen.c @@ -0,0 +1,123 @@ +/* $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. + * + * 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. + */ + +#include + +#include "lib/libsa/stand.h" +#include "vaxstand.h" + +unsigned int opendev; + +int +devopen(f, fname, file) + struct open_file *f; + const char *fname; + char **file; +{ + int dev, ctlr, unit, part, adapt, i, a[4], x; + struct devsw *dp; + extern int cnvtab[]; + char *s, *c, *u; + + dev = B_TYPE(bootdev); + ctlr = B_CONTROLLER(bootdev); + unit = B_UNIT(bootdev); + part = B_PARTITION(bootdev); + adapt = B_ADAPTOR(bootdev); + + for (i = 0, dp = 0; i < ndevs; i++) + if (cnvtab[i] == dev) + dp = devsw + i; + + x = 0; + if ((s = index(fname, '('))) { + *s++ = 0; + + for (i = 0, dp = devsw; i < ndevs; i++, dp++) + if (dp->dv_name && strcmp(dp->dv_name, fname) == 0) + break; + + if (i == ndevs) { + printf("No such device - Configured devices are:\n"); + for (dp = devsw, i = 0; i < ndevs; i++, dp++) + if (dp->dv_name) + printf(" %s", dp->dv_name); + printf("\n"); + return -1; + } + dev = cnvtab[i]; + if ((c = index(s, ')')) == 0) + goto usage; + + *c++ = 0; + + if (*s) do { + a[x++] = atoi(s); + while (*s >= '0' && *s <= '9') + s++; + + if (*s != ',' && *s != 0) + goto usage; + } while (*s++); + + if (x) + part = a[x - 1]; + if (x > 1) + unit = a[x - 2]; + if (x > 2) + ctlr = a[x - 3]; + if (x > 3) + adapt = a[0]; + *file = c; + } else { + *file = (char *)fname; + c = (char *)fname; + } + + if (!dp->dv_open) + return(ENODEV); + f->f_dev = dp; + + opendev = MAKEBOOTDEV(dev, adapt, ctlr, unit, part); + + if (dev > 95) { /* MOP boot over network, root & swap over NFS */ + i = (*dp->dv_open)(f, dp->dv_name); + } else + i = (*dp->dv_open)(f, adapt, ctlr, unit, part); + + return i; + +usage: + printf("usage: dev(adapter,controller,unit,partition)file -asd\n"); + return -1; +} diff --git a/sys/arch/vax/boot/boot/hp.c b/sys/arch/vax/boot/boot/hp.c new file mode 100644 index 00000000000..30f29ae1101 --- /dev/null +++ b/sys/arch/vax/boot/boot/hp.c @@ -0,0 +1,166 @@ +/* $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. + * + * 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 "sys/disklabel.h" + +#include "lib/libsa/stand.h" + +#include "../include/pte.h" +/*#include "../include/macros.h"*/ + +#include "../mba/mbareg.h" +#include "../mba/hpreg.h" + +#include "vaxstand.h" + +/* + * These routines for HP disk standalone boot is wery simple, + * assuming a lots of thing like that we only working at one hp disk + * a time, no separate routines for mba driver etc.. + * But it works :) + */ + +struct hp_softc { + int adapt; + int ctlr; + int unit; + int part; +}; + +struct disklabel hplabel; +struct hp_softc hp_softc; +char io_buf[DEV_BSIZE]; +daddr_t part_offset; + +hpopen(f, adapt, ctlr, unit, part) + struct open_file *f; + int ctlr, unit, part; +{ + struct disklabel *lp; + struct hp_softc *hs; + volatile struct mba_regs *mr; + volatile struct hp_drv *hd; + char *msg; + int i,err; + + lp = &hplabel; + hs = &hp_softc; + mr = (void *)mbaaddr[ctlr]; + hd = (void *)&mr->mba_md[unit]; + + if (adapt > nsbi) return(EADAPT); + if (ctlr > nmba) return(ECTLR); + if (unit > MAXMBAU) return(EUNIT); + + bzero(lp, sizeof(struct disklabel)); + + lp->d_secpercyl = 32; + lp->d_nsectors = 32; + hs->adapt = adapt; + hs->ctlr = ctlr; + hs->unit = unit; + hs->part = part; + + /* Set volume valid and 16 bit format; only done once */ + mr->mba_cr = MBACR_INIT; + hd->hp_cs1 = HPCS_PA; + hd->hp_of = HPOF_FMT; + + err = hpstrategy(hs, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); + if (err) { + printf("reading disklabel: %s\n", strerror(err)); + return 0; + } + + msg = getdisklabel(io_buf + LABELOFFSET, lp); + if (msg) + printf("getdisklabel: %s\n", msg); + + f->f_devdata = (void *)hs; + return 0; +} + +hpstrategy(hs, func, dblk, size, buf, rsize) + struct hp_softc *hs; + daddr_t dblk; + u_int size, *rsize; + char *buf; + int func; +{ + volatile struct mba_regs *mr; + volatile struct hp_drv *hd; + struct disklabel *lp; + unsigned int i, pfnum, mapnr, nsize, bn, cn, sn, tn; + + mr = (void *)mbaaddr[hs->ctlr]; + hd = (void *)&mr->mba_md[hs->unit]; + lp = &hplabel; + + pfnum = (u_int)buf >> VAX_PGSHIFT; + + 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 & VAX_PGOFSET); + mr->mba_bc = (~size) + 1; + bn = dblk + lp->d_partitions[hs->part].p_offset; + + if (bn) { + cn = bn / lp->d_secpercyl; + sn = bn % lp->d_secpercyl; + tn = sn / lp->d_nsectors; + sn = sn % lp->d_nsectors; + } else + cn = sn = tn = 0; + + hd->hp_dc = cn; + hd->hp_da = (tn << 8) | sn; + if (func == F_WRITE) + hd->hp_cs1 = HPCS_WRITE; + else + hd->hp_cs1 = HPCS_READ; + + while (mr->mba_sr & MBASR_DTBUSY) + ; + + if (mr->mba_sr & MBACR_ABORT) + return 1; + + *rsize = size; + + return 0; +} diff --git a/sys/arch/vax/boot/boot/if_le.c b/sys/arch/vax/boot/boot/if_le.c new file mode 100644 index 00000000000..31fb9f756b1 --- /dev/null +++ b/sys/arch/vax/boot/boot/if_le.c @@ -0,0 +1,389 @@ +/* $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, 1999 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. + */ + +/* + * Standalone routine for MicroVAX LANCE chip. + */ + +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include <../include/sid.h> + +#include + +#include + +/* + * The following are incorrect. Why doesn't DEC follow its own specs??? + */ +#define TLEN 1 +#define NTBUF (1 << TLEN) +#define RLEN 3 +#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(), le_end(); +static void copyin(), copyout(); + +struct netif_stats le_stats; + +struct netif_dif le_ifs[] = { +/* dif_unit dif_nsel dif_stats dif_private */ +{ 0, 1, &le_stats, }, +}; + +struct netif_stats le_stats; + +struct netif_driver le_driver = { + "le", le_match, le_probe, le_init, le_get, le_put, le_end, le_ifs, 1, +}; + +/* + * Init block & buffer descriptors according to DEC system + * specification documentation. + */ +struct initblock { + short ib_mode; + char ib_padr[6]; /* Ethernet address */ + int ib_ladrf1; + int ib_ladrf2; + int ib_rdr; /* Receive address */ + int ib_tdr; /* Transmit address */ +} *initblock = NULL; + +struct nireg { + volatile u_short ni_rdp; /* data port */ + volatile short ni_pad0; + volatile short ni_rap; /* register select port */ +} *nireg = (struct nireg *)0x200e0000; + + +volatile struct buffdesc { + int bd_adrflg; + short bd_bcnt; + short bd_mcnt; +} *rdesc, *tdesc; + +static int addoff, kopiera = 0; + +/* Flags in the address field */ +#define BR_OWN 0x80000000 +#define BR_ERR 0x40000000 +#define BR_FRAM 0x20000000 +#define BR_OFLO 0x10000000 +#define BR_CRC 0x08000000 +#define BR_BUFF 0x04000000 +#define BR_STP 0x02000000 +#define BR_ENP 0x01000000 + +#define BT_OWN 0x80000000 +#define BT_ERR 0x40000000 +#define BT_MORE 0x10000000 +#define BT_ONE 0x08000000 +#define BT_DEF 0x04000000 +#define BT_STP 0x02000000 +#define BT_ENP 0x01000000 + +int next_rdesc, next_tdesc; + +#define LEWRCSR(port, val) { \ + nireg->ni_rap = (port); \ + nireg->ni_rdp = (val); \ +} + +#define LERDCSR(port) \ + (nireg->ni_rap = port, nireg->ni_rdp) + +int +le_match(nif, machdep_hint) + struct netif *nif; + void *machdep_hint; +{ + return strcmp(machdep_hint, "le") == 0; +} + +le_probe(nif, machdep_hint) + struct netif *nif; + void *machdep_hint; +{ + return 0; +} + +void +le_init(desc, machdep_hint) + struct iodesc *desc; + void *machdep_hint; +{ + int stat, i, *ea; + volatile int to = 100000; + + 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--) + ; + + for (i = 0; i < 6; i++) + desc->myea[i] = ea[i] & 0377; + + 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) + addoff; + initblock->ib_rdr = (RLEN << 29) | (int)rdesc; + 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 = 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 = 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); + } + + 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--) { + 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); +} + +int +le_get(desc, pkt, maxlen, timeout) + struct iodesc *desc; + void *pkt; + int maxlen; + time_t timeout; +{ + int csr, len; + volatile int to = 100000 * timeout; + +retry: + if (to-- == 0) + return 0; + + 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; + + if (rdesc[next_rdesc].bd_adrflg & BR_ERR) + len = 0; + else { + if ((len = rdesc[next_rdesc].bd_mcnt - 4) > maxlen) + len = maxlen; + + 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; +} + +int +le_put(desc, pkt, len) + struct iodesc *desc; + void *pkt; + int len; +{ + volatile int to = 100000; + int csr; + +retry: + if (--to == 0) + return -1; + + 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; + + 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); + + to = 100000; + while (((LERDCSR(LE_CSR0) & LE_C0_TINT) == 0) && --to) + ; + + LEWRCSR(LE_CSR0, LE_C0_TINT); + if (++next_tdesc >= NTBUF) + next_tdesc = 0; + + if (to) + return len; + + 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 +#include + +#include +#include + +#include + +#include + +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 +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include + +#include + +#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> 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 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/boot/mfm.c b/sys/arch/vax/boot/boot/mfm.c new file mode 100644 index 00000000000..33fbbbc3065 --- /dev/null +++ b/sys/arch/vax/boot/boot/mfm.c @@ -0,0 +1,655 @@ +/* $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. + * 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. + */ + +/* + * ToDo: + * + * - insert appropriate delays for diskette-drive where needed + * - allow more than one sector per diskette-read + * - check for and handle bad sectors + * - ??? + */ + +#include "sys/param.h" +#include "sys/reboot.h" +#include "sys/disklabel.h" + +#include "lib/libsa/stand.h" +#include "lib/libsa/ufs.h" + +#include "../include/pte.h" +#include "../include/sid.h" +#include "../include/mtpr.h" +#include "../include/reg.h" +#include "../include/rpb.h" + +#include "ka410.h" +#include "../vsa/hdc9224.h" + +#include "data.h" +#include "vaxstand.h" + +#define MAX_WAIT (1000*1000) /* # of loop-instructions in seconds */ + +struct mfm_softc { + int part; + int unit; +}; + +int mfmstrategy(), mfmopen(); +struct disklabel mfmlabel; +struct mfm_softc mfm_softc; +char io_buf[DEV_BSIZE]; + +/* + * These should probably be somewhere else, but ka410 is the only + * one with mfm disks anyway... + */ +volatile unsigned char *ka410_intreq = (void*)0x2008000f; +volatile unsigned char *ka410_intclr = (void*)0x2008000f; +volatile unsigned char *ka410_intmsk = (void*)0x2008000c; + +static volatile struct hdc9224_DKCreg *dkc = (void *) 0x200c0000; +static volatile struct hdc9224_UDCreg sreg; /* input */ +static volatile struct hdc9224_UDCreg creg; /* output */ + +/* + * we have to wait 0.7 usec between two accesses to any of the + * dkc-registers, on a VS2000 with 1 MIPS, this is roughly one + * instruction. Thus the loop-overhead will be enough... + */ +static int +sreg_read() +{ + int i; + char *p; + + dkc->dkc_cmd = 0x40; /* set internal counter to zero */ + p = (void *) &sreg; + for (i = 0; i < 10; i++) + *p++ = dkc->dkc_reg; /* dkc_reg auto-increments */ +} + +static int +creg_write() +{ + int i; + char *p; + + dkc->dkc_cmd = 0x40; /* set internal counter to zero */ + p = (void *) &creg; + for (i = 0; i < 10; i++) + dkc->dkc_reg = *p++; /* dkc_reg auto-increments */ +} + +/* + * floppies are handled in a quite strange way by this controller... + * + * before reading/writing a sector from/to floppy, we use the SEEK/READ_ID + * command to place the head at the desired location. Then we wait some + * time before issueing the real command in order to let the drive become + * ready... + */ +int +mfm_rxprepare() +{ + int error; + + error = mfm_command(DKC_CMD_SEEKREADID | 0x04); /* step=1, verify=0 */ + if (error) { + printf("error while stepping to position %d/%d/%x. Retry...\n", + creg.udc_dsect, creg.udc_dhead, creg.udc_dcyl); + error = mfm_command(DKC_CMD_SEEKREADID | 0x04); + } + return error; +} + +int +mfm_rxselect(unit) + int unit; +{ + int error; + + /* + * bring "creg" in some known-to-work state and + * select the drive with the DRIVE SELECT command. + */ + creg.udc_dma7 = 0; + creg.udc_dma15 = 0; + creg.udc_dma23 = 0; + creg.udc_dsect = 1; /* sectors are numbered 1..15 !!! */ + creg.udc_dhead = 0; + creg.udc_dcyl = 0; + creg.udc_scnt = 0; + + creg.udc_rtcnt = UDC_RC_RX33READ; + creg.udc_mode = UDC_MD_RX33; + creg.udc_term = UDC_TC_FDD; + + /* + * this is ... + */ + error = mfm_command(DKC_CMD_DRSEL_RX33 | unit); + + if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 0)) { + printf("\nfloppy-drive not ready (new floppy inserted?)\n\n"); + + creg.udc_rtcnt &= ~UDC_RC_INVRDY; /* clear INVRDY-flag */ + error = mfm_command(DKC_CMD_DRSEL_RX33 | unit); + if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 0)) { + printf("diskette not ready(1): %x/%x\n", + error, sreg.udc_dstat); + printf("floppy-drive offline?\n"); + return (-1); + } + if (sreg.udc_dstat & UDC_DS_TRK00) + error = mfm_command(DKC_CMD_STEPIN_FDD); + else + error = mfm_command(DKC_CMD_STEPOUT_FDD); + + /* + * now ready should be 0, cause INVRDY is not set + * (retrying a command makes this fail...) + */ + if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 1)) { + printf("diskette not ready(2): %x/%x\n", + error, sreg.udc_dstat); + } + creg.udc_rtcnt |= UDC_RC_INVRDY; + error = mfm_command(DKC_CMD_DRSEL_RX33 | unit); + + if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 0)) { + printf("diskette not ready(3): %x/%x\n", + error, sreg.udc_dstat); + printf("no floppy inserted or floppy-door open\n"); + return (-1); + } + printf("floppy-drive reselected.\n"); + } + return (error); +} + +int +mfm_rdselect(unit) + int unit; +{ + int error; + + /* + * bring "creg" in some known-to-work state and + * select the drive with the DRIVE SELECT command. + */ + creg.udc_dma7 = 0; + creg.udc_dma15 = 0; + creg.udc_dma23 = 0; + creg.udc_dsect = 0; /* sectors are numbered 0..16 */ + creg.udc_dhead = 0; + creg.udc_dcyl = 0; + creg.udc_scnt = 0; + + creg.udc_rtcnt = UDC_RC_HDD_READ; + creg.udc_mode = UDC_MD_HDD; + creg.udc_term = UDC_TC_HDD; + + error = mfm_command(DKC_CMD_DRSEL_HDD | unit); + + return (error); +} + +static int mfm_retry = 0; + +int +mfm_command(cmd) + int cmd; +{ + int termcode, ready, i; + + creg_write(); /* write command-registers */ + *ka410_intclr = INTR_DC; + dkc->dkc_cmd = cmd; /* issue command */ + for (i = 0; i < MAX_WAIT; i++) { + if (*ka410_intreq & INTR_DC) /* wait for interrupt */ + break; + } + if ((*ka410_intreq & INTR_DC) == 0) + printf("timeout in mfm_command...\n"); + + sreg_read(); /* read status-registers */ + + if (dkc->dkc_stat == (DKC_ST_DONE | DKC_TC_SUCCESS)) + return (0); + + if (sreg.udc_cstat & UDC_CS_ECCERR) { + printf( +"\nspurious(?) ECC/CRC error at s%d/t%d/c%d [s%d/t%d/c%d(%d)]\n", + sreg.udc_csect, sreg.udc_chead, sreg.udc_ccyl, + creg.udc_dsect, creg.udc_dhead, creg.udc_dcyl,creg.udc_scnt); + if (sreg.udc_csect != creg.udc_dsect + creg.udc_scnt - 1) { + printf("DMA: %x %x %x [%x]\n", + sreg.udc_dma23, sreg.udc_dma15, + sreg.udc_dma7, 512 * (sreg.udc_csect - + creg.udc_dsect)); + creg.udc_scnt = creg.udc_scnt - + (sreg.udc_csect - creg.udc_dsect) - 1; + creg.udc_dsect = sreg.udc_csect + 1; + creg.udc_dma23 = sreg.udc_dma23; + creg.udc_dma15 = sreg.udc_dma15 + 2; + creg.udc_dma7 = 0; + printf("Retry starting from s%d/t%d/c%d (%d). ", + creg.udc_dsect, creg.udc_dhead, creg.udc_dcyl, + creg.udc_scnt); + } + goto retry; + } + termcode = (dkc->dkc_stat & DKC_ST_TERMCOD) >> 3; + ready = sreg.udc_dstat & UDC_DS_READY; + + printf("cmd:0x%x: termcode=0x%x, status=0x%x, cstat=0x%x, dstat=0x%x\n", + cmd, termcode, dkc->dkc_stat, sreg.udc_cstat, sreg.udc_dstat); + + if (dkc->dkc_stat & DKC_ST_BADSECT) + printf("bad sector found: s%d/t%d/c%d\n", creg.udc_dsect, + creg.udc_dhead, creg.udc_dcyl); +retry: + if ((mfm_retry == 0) && (sreg.udc_cstat & UDC_CS_RETREQ)) { + mfm_retry = 1; + printf("Retrying... "); + mfm_command(cmd); + printf("Retry done.\n"); + mfm_retry = 0; + } + return ((dkc->dkc_stat & DKC_ST_TERMCOD) >> 3); +} + +/* + * on-disk geometry block + */ +#define _aP __attribute__ ((packed)) /* force byte-alignment */ + +volatile struct mfm_xbn { + char mbz[10];/* 10 bytes of zero */ + long xbn_count _aP; /* number of XBNs */ + long dbn_count _aP; /* number of DBNs */ + long lbn_count _aP; /* number of LBNs (Logical-Block-Numbers) */ + long rbn_count _aP; /* number of RBNs (Replacement-Block-Numbers) */ + short nspt; /* number of sectors per track */ + short ntracks;/* number of tracks */ + short ncylinders; /* number of cylinders */ + short precomp;/* first cylinder for write precompensation */ + short reduced;/* first cylinder for reduced write current */ + short seek_rate; /* seek rate or zero for buffered + * seeks */ + short crc_eec;/* 0 if CRC is being used or 1 if ECC is + * being used */ + short rct; /* "replacement control table" (RCT) */ + short rct_ncopies; /* number of copies of the RCT */ + long media_id _aP; /* media identifier */ + short interleave; /* sector-to-sector interleave */ + short headskew; /* head-to-head skew */ + short cylskew;/* cylinder-to-cylinder skew */ + short gap0_size; /* size of GAP 0 in the MFM format */ + short gap1_size; /* size of GAP 1 in the MFM format */ + short gap2_size; /* size of GAP 2 in the MFM format */ + short gap3_size; /* size of GAP 3 in the MFM format */ + short sync_value; /* sync value used to start a track + * when formatting */ + char reserved[32]; /* reserved for use by the RQDX1/2/3 + * formatter */ + short serial_number; /* serial number */ + char fill[412]; /* Filler bytes to the end of the + * block */ + short checksum; /* checksum over the XBN */ +} mfm_xbn; + +#ifdef verbose +display_xbn(p) + struct mfm_xbn *p; +{ + printf("**DiskData** XBNs: %d, DBNs: %d, LBNs: %d, RBNs: %d\n", + p->xbn_count, p->dbn_count, p->lbn_count, p->rbn_count); + printf("sect/track: %d, tracks: %d, cyl: %d, precomp/reduced: %d/%d\n", + p->nspt, p->ntracks, p->ncylinders, p->precomp, p->reduced); + printf("seek-rate: %d, crc/eec: %s, RCT: %d, RCT-copies: %d\n", + p->seek_rate, p->crc_eec ? "EEC" : "CRC", p->rct, p->rct_ncopies); + printf("media-ID: 0x%x, interleave: %d, headskew: %d, cylskew: %d\n", + &p->media_id, p->interleave, p->headskew, p->cylskew); + printf("gap0: %d, gap1: %d, gap2: %d, gap3: %d, sync-value: %d\n", + p->gap0_size, p->gap1_size, p->gap2_size, p->gap3_size, + p->sync_value); + printf("serial: %d, checksum: %d, size: %d, reserved: %32c\n", + p->serial_number, p->checksum, sizeof(*p), p->reserved); +} +#endif + +mfmopen(f, adapt, ctlr, unit, part) + struct open_file *f; + int ctlr, unit, part; +{ + char *msg; + struct disklabel *lp = &mfmlabel; + volatile struct mfm_softc *msc = &mfm_softc; + int i, err; + + bzero(lp, sizeof(struct disklabel)); + msc->unit = unit; + msc->part = part; + + err = mfmstrategy(msc, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); + if (err) { + printf("reading disklabel: %s\n", strerror(err)); + return 0; + } + msg = getdisklabel(io_buf + LABELOFFSET, lp); + if (msg) + printf("getdisklabel: %s\n", msg); + + f->f_devdata = (void *) msc; + + { + int k; + unsigned char *ucp; + struct mfm_xbn *xp; + + /* mfmstrategy(msc, F_READ, -16, 8192, io_buf, &i); */ + mfmstrategy(msc, F_READ, -16, DEV_BSIZE, io_buf, &i); +#ifdef verbose + printf("dumping raw disk-block #0:\n"); + ucp = io_buf; + for (k = 0; k < 128; k++) { + if (ucp[k] < 0x10) + printf("0"); + printf("%x ", ucp[k]); + if (k % 8 == 7) + printf(" "); + if (k % 16 == 15) + printf("\n"); + } + printf("\n"); + + xp = (void *) io_buf; + display_xbn(xp); + printf("\n"); +#endif + } + + if (unit == 2) { /* floppy! */ + if (lp->d_ntracks != 2) { +#ifdef verbose + printf("changing number of tracks from %d to %d.\n", + lp->d_ntracks, 2); +#endif + lp->d_ntracks = 2; + } + } else { /* hard-disk */ + unsigned short *usp = (void *) io_buf; +#ifdef verbose + printf("label says: s/t/c = %d/%d/%d\n", + lp->d_nsectors, lp->d_ntracks, lp->d_ncylinders); +#endif + if (lp->d_nsectors != usp[13]) { +#ifdef verbose + printf("changing number of sectors from %d to %d.\n", + lp->d_nsectors, usp[13]); +#endif + lp->d_nsectors = usp[13]; + } + if (lp->d_ntracks != usp[14]) { +#ifdef verbose + printf("changing number of heads/tracks from %d to %d.\n", + lp->d_ntracks, usp[14]); +#endif + lp->d_ntracks = usp[14]; + } + if (lp->d_ncylinders != usp[15]) { +#ifdef verbose + printf("changing number of cylinders from %d to %d.\n", + lp->d_ncylinders, usp[15]); +#endif + lp->d_ncylinders = usp[15]; + } + lp->d_secpercyl = lp->d_nsectors * lp->d_ntracks; + } + + return (0); +} + +mfm_rxstrategy(msc, func, dblk, size, buf, rsize) + struct mfm_softc *msc; + int func; + daddr_t dblk; + char *buf; + int size, *rsize; +{ + struct disklabel *lp; + int block, sect, head, cyl, scount, i, cmd, res, sval; + + lp = &mfmlabel; + block = (dblk < 0 ? 0 : dblk + lp->d_partitions[msc->part].p_offset); + + mfm_rxselect(msc->unit); + + /* + * if label is empty, assume RX33 + */ + if (lp->d_nsectors == 0) + lp->d_nsectors = 15; + if (lp->d_ntracks == 0) + lp->d_ntracks = 2; + if (lp->d_secpercyl == 0) + lp->d_secpercyl = 30; + + bzero((void *) 0x200D0000, size); + scount = size / 512; + + while (scount) { + /* + * prepare drive/operation parameter + */ + cyl = block / lp->d_secpercyl; + sect = block % lp->d_secpercyl; + head = sect / lp->d_nsectors; + sect = sect % lp->d_nsectors; + + /* + * *rsize = 512; /* one sector after the other + * ... + */ + *rsize = 512 * min(scount, lp->d_nsectors - sect); + + /* + * now initialize the register values ... + */ + creg.udc_dma7 = 0; + creg.udc_dma15 = 0; + creg.udc_dma23 = 0; + + creg.udc_dsect = sect + 1; /* sectors are numbered 1..15 + * !!! */ + head |= (cyl >> 4) & 0x70; + creg.udc_dhead = head; + creg.udc_dcyl = cyl; + + creg.udc_scnt = *rsize / 512; + + if (func == F_WRITE) { + creg.udc_rtcnt = UDC_RC_RX33WRT; + creg.udc_mode = UDC_MD_RX33; + creg.udc_term = UDC_TC_FDD; + + mfm_rxprepare(); + /* copy from buf */ + bcopy(buf, (void *) 0x200D0000, *rsize); + res = mfm_command(DKC_CMD_WRITE_RX33); + } else { + creg.udc_rtcnt = UDC_RC_RX33READ; + creg.udc_mode = UDC_MD_RX33; + creg.udc_term = UDC_TC_FDD; + + mfm_rxprepare(); + /* clear disk buffer */ + bzero((void *) 0x200D0000, *rsize); + res = mfm_command(DKC_CMD_READ_RX33); + /* copy to buf */ + bcopy((void *) 0x200D0000, buf, *rsize); + } + + scount -= *rsize / 512; + block += *rsize / 512; + buf += *rsize; + } + + *rsize = size; + return 0; +} + +mfm_rdstrategy(msc, func, dblk, size, buf, rsize) + struct mfm_softc *msc; + int func; + daddr_t dblk; + char *buf; + int size, *rsize; +{ + struct disklabel *lp; + int block, sect, head, cyl, scount, i, cmd, res, sval; + + lp = &mfmlabel; + block = (dblk < 0 ? 0 : dblk + lp->d_partitions[msc->part].p_offset); + + /* + * if label is empty, assume RD32 (XXX this must go away!!!) + */ + if (lp->d_nsectors == 0) + lp->d_nsectors = 17; + if (lp->d_ntracks == 0) + lp->d_ntracks = 6; + if (lp->d_secpercyl == 0) + lp->d_secpercyl = 102; + + mfm_rdselect(msc->unit); + + bzero((void *) 0x200D0000, size); + scount = size / 512; + + while (scount) { + /* + * prepare drive/operation parameter + */ + cyl = block / lp->d_secpercyl; + sect = block % lp->d_secpercyl; + head = sect / lp->d_nsectors; + sect = sect % lp->d_nsectors; + + if (dblk < 0) { +#ifdef verbose + printf("using raw diskblock-data!\n"); + printf("block %d, dblk %d ==> cyl %d, head %d, sect %d\n", + block, dblk, cyl, sect, head); +#endif + } else + cyl += 1; /* first cylinder is reserved for + * controller! */ + + *rsize = 512 * min(scount, lp->d_nsectors - sect); + /* + * now re-initialize the register values ... + */ + creg.udc_dma7 = 0; + creg.udc_dma15 = 0; + creg.udc_dma23 = 0; + + creg.udc_dsect = sect; + head |= (cyl >> 4) & 0x70; + creg.udc_dhead = head; + creg.udc_dcyl = cyl; + + creg.udc_scnt = *rsize / 512; + + if (func == F_WRITE) { + creg.udc_rtcnt = UDC_RC_HDD_WRT; + creg.udc_mode = UDC_MD_HDD; + creg.udc_term = UDC_TC_HDD; + cmd = DKC_CMD_WRITE_HDD; + + bcopy(buf, (void *) 0x200D0000, *rsize); + res = mfm_command(cmd); + } else { + creg.udc_rtcnt = UDC_RC_HDD_READ; + creg.udc_mode = UDC_MD_HDD; + creg.udc_term = UDC_TC_HDD; + cmd = DKC_CMD_READ_HDD; + + bzero((void *) 0x200D0000, *rsize); + res = mfm_command(cmd); + bcopy((void *) 0x200D0000, buf, *rsize); + } + + scount -= *rsize / 512; + block += *rsize / 512; + buf += *rsize; + } + + /* + * unselect the drive ... + */ + mfm_command(DKC_CMD_DRDESELECT); + + *rsize = size; + return 0; +} + +int +mfmstrategy(msc, func, dblk, size, buf, rsize) + struct mfm_softc *msc; + int func; + daddr_t dblk; + char *buf; + int size, *rsize; +{ + int res = -1; + + switch (msc->unit) { + case 0: + case 1: + res = mfm_rdstrategy(msc, func, dblk, size, buf, rsize); + break; + case 2: + res = mfm_rxstrategy(msc, func, dblk, size, buf, rsize); + break; + default: + printf("invalid unit %d in mfmstrategy()\n"); + } + return (res); +} diff --git a/sys/arch/vax/boot/boot/netio.c b/sys/arch/vax/boot/boot/netio.c new file mode 100644 index 00000000000..bbc01d23acc --- /dev/null +++ b/sys/arch/vax/boot/boot/netio.c @@ -0,0 +1,278 @@ +/* $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 Gordon W. Ross + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * 4. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Gordon W. Ross + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This module implements a "raw device" interface suitable for + * use by the stand-alone I/O library NFS code. This interface + * does not support any "block" access, and exists only for the + * purpose of initializing the network interface, getting boot + * parameters, and performing the NFS mount. + * + * At open time, this does: + * + * find interface - netif_open() + * RARP for IP address - rarp_getipaddress() + * RPC/bootparams - callrpc(d, RPC_BOOTPARAMS, ...) + * RPC/mountd - nfs_mount(sock, ip, path) + * + * the root file handle from mountd is saved in a global + * for use by the NFS open code (NFS/lookup). + */ + +#include +#include +#include +#include +#include +#include + +#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() */ + +struct in_addr myip, rootip, gateip; +n_long netmask; +char rootpath[FNAME_SIZE]; + +int netdev_sock = -1; +static int open_count; + +int netio_ask = 0; /* default to bootparam, can override */ + +static char input_line[100]; + +/* + * Called by devopen after it sets f->f_dev to our devsw entry. + * This opens the low-level device and sets f->f_devdata. + */ +int +netopen(f, devname) + struct open_file *f; + char *devname; /* Device part of file name (or NULL). */ +{ + int error = 0; + + /* On first open, do netif open, mount, etc. */ + if (open_count == 0) { + /* Find network interface. */ + if ((netdev_sock = netif_open(devname)) < 0) + return (error=ENXIO); + if ((error = netmountroot(f, devname)) != 0) + return (error); + } + open_count++; + f->f_devdata = nfs_root_node; + return (error); +} + +int +netclose(f) + struct open_file *f; +{ + netif_close(netdev_sock); + f->f_devdata = NULL; +} + +int +netstrategy(devdata, func, dblk, size, v_buf, rsize) + void *devdata; + int func; + daddr_t dblk; + size_t size; + void *v_buf; + size_t *rsize; +{ + + *rsize = size; + return EIO; +} + +int +netmountroot(f, devname) + struct open_file *f; + char *devname; /* Device part of file name (or NULL). */ +{ + int error; + struct iodesc *d; + + if (netio_ask) { + get_my_ip: + printf("My IP address? "); + bzero(input_line, sizeof(input_line)); + gets(input_line); + if ((myip.s_addr = inet_addr(input_line)) == + htonl(INADDR_NONE)) { + printf("invalid IP address: %s\n", input_line); + goto get_my_ip; + } + + get_my_netmask: + printf("My netmask? "); + bzero(input_line, sizeof(input_line)); + gets(input_line); + if ((netmask = inet_addr(input_line)) == + htonl(INADDR_NONE)) { + printf("invalid netmask: %s\n", input_line); + goto get_my_netmask; + } + + get_my_gateway: + printf("My gateway? "); + bzero(input_line, sizeof(input_line)); + gets(input_line); + if ((gateip.s_addr = inet_addr(input_line)) == + htonl(INADDR_NONE)) { + printf("invalid IP address: %s\n", input_line); + goto get_my_gateway; + } + + get_server_ip: + printf("Server IP address? "); + bzero(input_line, sizeof(input_line)); + gets(input_line); + if ((rootip.s_addr = inet_addr(input_line)) == + htonl(INADDR_NONE)) { + printf("invalid IP address: %s\n", input_line); + goto get_server_ip; + } + + get_server_path: + printf("Server path? "); + bzero(rootpath, sizeof(rootpath)); + gets(rootpath); + if (rootpath[0] == '\0' || rootpath[0] == '\n') + goto get_server_path; + + if ((d = socktodesc(netdev_sock)) == NULL) + return (EMFILE); + + d->myip = myip; + + goto do_nfs_mount; + } + + /* + * Get info for NFS boot: our IP address, our hostname, + * server IP address, and our root path on the server. + * There are two ways to do this: The old, Sun way, + * and the more modern, BOOTP way. (RFC951, RFC1048) + */ + +#ifdef SUPPORT_BOOTP + + /* Get boot info using BOOTP way. (RFC951, RFC1048) */ + printf("Trying BOOTP\n"); + bootp(netdev_sock); + + if (myip.s_addr) { + printf("Using IP address: %s\n", inet_ntoa(myip)); + + 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 + +#endif /* SUPPORT_BOOTP */ + { +#ifdef SUPPORT_BOOTPARAMS + /* Get boot info using RARP and Sun bootparams. */ + + printf("Trying BOOTPARAMS\n"); + /* Get our IP address. (rarp.c) */ + if (rarp_getipaddress(netdev_sock) == -1) + return (errno); + + printf("boot: client IP address: %s\n", inet_ntoa(myip)); + + /* Get our hostname, server IP address. */ + if (bp_whoami(netdev_sock)) + return (errno); + + 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: + /* Get the NFS file handle (mount). */ + error = nfs_mount(netdev_sock, rootip, rootpath); + + return (error); +} diff --git a/sys/arch/vax/boot/boot/ra.c b/sys/arch/vax/boot/boot/ra.c new file mode 100644 index 00000000000..96be3fcfc00 --- /dev/null +++ b/sys/arch/vax/boot/boot/ra.c @@ -0,0 +1,256 @@ +/* $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. + * + * 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 */ + +#define NRSP 1 /* Kludge */ +#define NCMD 1 /* Kludge */ + +#include "sys/param.h" +#include "sys/disklabel.h" + +#include "lib/libsa/stand.h" + +#include "../include/pte.h" +#include "../include/sid.h" + +#include "arch/vax/mscp/mscp.h" +#include "arch/vax/mscp/mscpreg.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 + * a time, no separate routines for uba driver etc.. + * This code is foolish and should need a cleanup. + * But it works :) + */ + +struct ra_softc { + int udaddr; + int ubaddr; + int part; + int unit; + unsigned short *ra_ip; + unsigned short *ra_sa; + unsigned short *ra_sw; +}; + +volatile struct uda { + struct mscp_1ca uda_ca; /* communications area */ + struct mscp uda_rsp; /* response packets */ + struct mscp uda_cmd; /* command packets */ +} uda; + +volatile struct uda *ubauda; +struct disklabel ralabel; +struct ra_softc ra_softc; +char io_buf[DEV_BSIZE]; + +raopen(f, adapt, ctlr, unit, part) + struct open_file *f; + int ctlr, unit, part; +{ + char *msg; + struct disklabel *lp = &ralabel; + volatile struct ra_softc *ra = &ra_softc; + volatile u_int *nisse; + unsigned short johan, johan2; + 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; + if (vax_cputype != VAX_8200) { + if (adapt > nuba) + return(EADAPT); + if (ctlr > nuda) + return(ECTLR); + nisse = ((u_int *)ubaaddr[adapt]) + 512; + nisse[494] = PG_V | (((u_int)&uda) >> 9); + nisse[495] = nisse[494] + 1; + 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; + ra->ra_sa = ra->ra_sw = (short *)udacsr + 1; + ra->udaddr = uioaddr[adapt] + udaaddr[ctlr]; + ra->ubaddr = (int)ubaaddr[adapt]; + *ra->ra_ip = 0; /* Start init */ + } else { + paddr_t kdaddr = (paddr_t)biaddr[adapt] + BI_NODE(ctlr); + volatile int *w; + volatile int i = 10000; + + 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; + w = (int *)(kdaddr + BIREG_VAXBICSR); + *w = *w | BICSR_NRST; + while (i--) /* Need delay??? */ + ; + 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; + uda.uda_ca.ca_cmddsc = (int)&ubauda->uda_cmd.mscp_cmdref; + + command(M_OP_SETCTLRC); + 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); + f->f_devdata = (void *)ra; + return(0); +} + +static +command(cmd) +{ + volatile int hej; + + uda.uda_cmd.mscp_opcode = cmd; + uda.uda_cmd.mscp_msglen = MSCP_MSGLEN; + 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) + struct ra_softc *ra; + int func; + daddr_t dblk; + char *buf; + u_int size, *rsize; +{ + volatile u_int *ptmapp; + struct disklabel *lp; + u_int i, j, pfnum, mapnr, nsize; + volatile int hej; + + if (vax_cputype != VAX_8200) { + ptmapp = ((u_int *)ra->ubaddr) + 512; + + pfnum = (u_int)buf >> VAX_PGSHIFT; + + 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 + uda.uda_cmd.mscp_seq.seq_buffer = ((u_int)buf); + + lp = &ralabel; + uda.uda_cmd.mscp_seq.seq_lbn = + 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 + command(M_OP_READ); + + *rsize = size; + return 0; +} diff --git a/sys/arch/vax/boot/boot/rom.c b/sys/arch/vax/boot/boot/rom.c new file mode 100644 index 00000000000..8e36badc906 --- /dev/null +++ b/sys/arch/vax/boot/boot/rom.c @@ -0,0 +1,124 @@ +/* $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. + * 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. + */ + +#include "sys/param.h" +#include "sys/reboot.h" +#include "sys/disklabel.h" + +#include "lib/libsa/stand.h" +#include "lib/libsa/ufs.h" + +#include "../include/pte.h" +#include "../include/sid.h" +#include "../include/mtpr.h" +#include "../include/reg.h" +#include "../include/rpb.h" + +#include "data.h" +#include "vaxstand.h" + +extern unsigned *bootregs; +extern struct rpb *rpb; + +struct rom_softc { + int part; + int unit; +}; + +int romstrategy(), romopen(); +struct disklabel romlabel; +struct rom_softc rom_softc; +char io_buf[DEV_BSIZE]; + +romopen(f, adapt, ctlr, unit, part) + struct open_file *f; + int ctlr, unit, part; +{ + char *msg; + struct disklabel *lp = &romlabel; + volatile struct rom_softc *rsc = &rom_softc; + int i,err; + + bootregs[11] = XXRPB; + rpb = (void*)XXRPB; + bqo = (void*)rpb->iovec; + + if (rpb->unit > 0 && (rpb->unit % 100) == 0) { + printf ("changing rpb->unit from %d ", rpb->unit); + rpb->unit /= 100; + printf ("to %d\n", rpb->unit); + } + + bzero(lp, sizeof(struct disklabel)); + rsc->unit = unit; + rsc->part = part; + + err = romstrategy(rsc, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); + if (err) { + printf("reading disklabel: %s\n",strerror(err)); + return 0; + } + msg = getdisklabel(io_buf+LABELOFFSET, lp); + if (msg) + printf("getdisklabel: %s\n",msg); + f->f_devdata = (void*)rsc; + return(0); +} + +romstrategy (rsc, func, dblk, size, buf, rsize) + struct rom_softc *rsc; + int func; + daddr_t dblk; + char *buf; + int size, *rsize; +{ + struct disklabel *lp; + int block; + + lp = &romlabel; + block = dblk + lp->d_partitions[rsc->part].p_offset; + if (rsc->unit >= 0 && rsc->unit < 10) + rpb->unit = rsc->unit; + + if (func == F_WRITE) + romwrite_uvax(block, size, buf, bootregs); + else + romread_uvax(block, size, buf, bootregs); + + *rsize = size; + return 0; +} + diff --git a/sys/arch/vax/boot/boot/tmscp.c b/sys/arch/vax/boot/boot/tmscp.c new file mode 100644 index 00000000000..5dbd5aef582 --- /dev/null +++ b/sys/arch/vax/boot/boot/tmscp.c @@ -0,0 +1,204 @@ +/* $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. + * + * 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 */ + +#define NRSP 0 /* Kludge */ +#define NCMD 0 /* Kludge */ + +#include "sys/param.h" +#include "sys/disklabel.h" + +#include "lib/libsa/stand.h" + +#include "../include/pte.h" +#include "arch/vax/mscp/mscp.h" +#include "arch/vax/mscp/mscpreg.h" + +#include "vaxstand.h" + +static command(int,int); + +/* + * These routines for TMSCP tape standalone boot is very simple, + * assuming a lots of thing like that we only working at one tape at + * a time, no separate routines for uba driver etc.. + * This code is directly copied from ra disk driver. + */ + +struct ra_softc { + int udaddr; + int ubaddr; + int unit; +}; + +static 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 { + 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; + int ctlr, unit, part; +{ + char *msg; + extern u_int tmsaddr; + volatile struct ra_softc *ra=&ra_softc; + 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)ubaaddr[adapt]; + ra->unit=unit; + udacsr=(void*)ra->udaddr; + 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); + + /* + * Init of this tmscp ctlr. + */ + udacsr->udaip=0; /* Start init */ + while((udacsr->udasa&MP_STEP1) == 0); + udacsr->udasa=0x8000; + while((udacsr->udasa&MP_STEP2) == 0); + johan=(((u_int)ubauda)&0xffff)+8; + udacsr->udasa=johan; + while((udacsr->udasa&MP_STEP3) == 0); + udacsr->udasa=3; + while((udacsr->udasa&MP_STEP4) == 0); + udacsr->udasa=0x0001; + + uda.uda_ca.ca_rspdsc=(int)&ubauda->uda_rsp.mscp_cmdref; + uda.uda_ca.ca_cmddsc=(int)&ubauda->uda_cmd.mscp_cmdref; + uda.uda_cmd.mscp_un.un_seq.seq_addr = (long *)&uda.uda_ca.ca_cmddsc; + uda.uda_rsp.mscp_un.un_seq.seq_addr = (long *)&uda.uda_ca.ca_rspdsc; + uda.uda_cmd.mscp_vcid = 1; + uda.uda_cmd.mscp_un.un_sccc.sccc_ctlrflags = 0; + + command(M_OP_SETCTLRC, 0); + uda.uda_cmd.mscp_unit=ra->unit; + command(M_OP_ONLINE, 0); + + if (part) { + uda.uda_cmd.mscp_un.un_seq.seq_buffer = part; + command(M_OP_POS, 0); + uda.uda_cmd.mscp_un.un_seq.seq_buffer = 0; + } + + f->f_devdata=(void *)ra; + return(0); +} + +static +command(cmd, arg) +{ + volatile int hej; + + uda.uda_cmd.mscp_opcode = cmd; + uda.uda_cmd.mscp_modifier = arg; + + uda.uda_cmd.mscp_msglen = MSCP_MSGLEN; + 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; + hej = udacsr->udaip; + while (uda.uda_ca.ca_rspdsc < 0) { + if (uda.uda_ca.ca_cmdint) + uda.uda_ca.ca_cmdint = 0; + } + +} + +tmscpstrategy(ra, func, dblk, size, buf, rsize) + struct ra_softc *ra; + int func; + daddr_t dblk; + char *buf; + u_int size, *rsize; +{ + u_int i,j,pfnum, mapnr, nsize, bn, cn, sn, tn; + volatile struct udadevice *udadev=(void*)ra->udaddr; + volatile u_int *ptmapp = (u_int *)ra->ubaddr + 512; + volatile int hej; + + pfnum=(u_int)buf>>VAX_PGSHIFT; + + for(mapnr=0, nsize=size;(nsize+VAX_NBPG)>0;nsize-=VAX_NBPG) + ptmapp[mapnr++]=PG_V|pfnum++; + + /* + * First position tape. Remember where we are. + */ + if (dblk < curblock) { + uda.uda_cmd.mscp_seq.seq_bytecount = curblock - dblk; + command(M_OP_POS, 12); /* 12 == step block backward */ + } else { + uda.uda_cmd.mscp_seq.seq_bytecount = dblk - curblock; + command(M_OP_POS, 4); /* 4 == step block forward */ + } + curblock = size/512 + dblk; + + /* + * Read in the number of blocks we need. + * Why doesn't read of multiple blocks work????? + */ + for (i = 0 ; i < size/512 ; i++) { + uda.uda_cmd.mscp_seq.seq_lbn = 1; + uda.uda_cmd.mscp_seq.seq_bytecount = 512; + uda.uda_cmd.mscp_seq.seq_buffer = + (((u_int)buf) & 0x1ff) + i * 512; + uda.uda_cmd.mscp_unit = ra->unit; + command(M_OP_READ, 0); + } + + *rsize=size; + return 0; +} diff --git a/sys/arch/vax/boot/bootxx.c b/sys/arch/vax/boot/bootxx.c deleted file mode 100644 index 5cdc2246964..00000000000 --- a/sys/arch/vax/boot/bootxx.c +++ /dev/null @@ -1,441 +0,0 @@ -/* $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 $ */ -/*- - * 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 "sys/disklabel.h" - -#include "lib/libsa/stand.h" -#include "lib/libsa/ufs.h" - -#include "../include/pte.h" -#include "../include/sid.h" -#include "../include/mtpr.h" -#include "../include/reg.h" -#include "../include/rpb.h" - -#include "../mba/mbareg.h" -#include "../mba/hpreg.h" - -#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 - -int romstrategy(), romopen(); -int command(int, int); - -/* - * 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; -unsigned opendev, boothowto, bootset, memsz; - -extern unsigned *bootregs; -extern struct rpb *rpb; - -/* - * The boot block are used by 11/750, 8200, MicroVAX II/III, VS2000, - * VS3100/??, VS4000 and VAX6000/???, and only when booting from disk. - */ -Xmain() -{ - int io; - char *scbb; - char *new; - char *hej = "/boot"; - - switch (vax_cputype) { - - case VAX_TYP_UV2: - case VAX_TYP_CVAX: - case VAX_TYP_RIGEL: - case VAX_TYP_NVAX: - case VAX_TYP_SOC: - /* - * now relocate rpb/bqo (which are used by ROM-routines) - */ - rpb = (void*)XXRPB; - bcopy ((void*)bootregs[11], rpb, 512); - rpb->rpb_base = rpb; - bqo = (void*)(512+(int)rpb); - bcopy ((void*)rpb->iovec, bqo, rpb->iovecsz); - rpb->iovec = (int)bqo; - bootregs[11] = (int)rpb; - bootdev = rpb->devtyp; - memsz = rpb->pfncnt << 9; - - break; - case VAX_8200: - case VAX_750: - bootdev = bootregs[10]; - memsz = 0; - - 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; -} - -getbootdev() -{ - int i, adaptor, controller, unit, partition, retval; - - adaptor = controller = unit = partition = 0; - - 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 */ - break; - - - case VAX_TYP_8SS: - case VAX_TYP_750: - controller = 0; /* XXX Actually massbuss can be on 3 ctlr's */ - unit = bootregs[3]; - break; - } - - switch (B_TYPE(bootdev)) { - case BDEV_HP: /* massbuss boot */ - adaptor = (bootregs[1] & 0x6000) >> 17; - break; - - case BDEV_UDA: /* UDA50 boot */ - if (vax_cputype == VAX_750) - adaptor = (bootregs[1] & 0x40000 ? 0 : 1); - break; - - 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; - - 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), -}; - -int ndevs = (sizeof(devsw) / sizeof(devsw[0])); - -struct fs_ops file_system[] = { - {ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat} -}; - -int nfsys = (sizeof(file_system) / sizeof(struct fs_ops)); - -struct disklabel lp; -int part_off = 0; /* offset into partition holding /boot */ -volatile struct uda { - struct mscp_1ca uda_ca; /* communications area */ - struct mscp uda_rsp; /* response packets */ - struct mscp uda_cmd; /* command packets */ -} uda; -volatile struct udadevice *csr; - -devopen(f, fname, file) - struct open_file *f; - const char *fname; - char **file; -{ - char *msg; - int i, err, off; - char line[64]; - - f->f_dev = &devsw[0]; - *file = (char *)fname; - - /* - * On uVAX we need to init [T]MSCP ctlr to be able to use it. - */ - if (vax_cputype == VAX_TYP_UV2 || vax_cputype == VAX_TYP_CVAX) { - switch (bootdev) { - case BDEV_UDA: /* MSCP */ - case BDEV_TK: /* TMSCP */ - csr = (struct udadevice *)rpb->csrphy; - - csr->udaip = 0; /* Start init */ - while((csr->udasa & MP_STEP1) == 0); - csr->udasa = 0x8000; - while((csr->udasa & MP_STEP2) == 0); - csr->udasa = (short)(((u_int)&uda)&0xffff) + 8; - while((csr->udasa & MP_STEP3) == 0); - csr->udasa = 0x10; - while((csr->udasa & MP_STEP4) == 0); - csr->udasa = 0x0001; - - uda.uda_ca.ca_rspdsc = - (int) &uda.uda_rsp.mscp_cmdref; - uda.uda_ca.ca_cmddsc = - (int) &uda.uda_cmd.mscp_cmdref; - if (bootdev == BDEV_TK) - uda.uda_cmd.mscp_vcid = 1; - command(M_OP_SETCTLRC, 0); - uda.uda_cmd.mscp_unit = rpb->unit; - command(M_OP_ONLINE, 0); - } - } - - /* - * the disklabel _shall_ be at address LABELOFFSET + RELOC in - * phys memory now, no need at all to reread it again. - * 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); - } - return 0; -} - -command(cmd, arg) -{ - volatile int hej; - - uda.uda_cmd.mscp_opcode = cmd; - uda.uda_cmd.mscp_modifier = arg; - - uda.uda_cmd.mscp_msglen = MSCP_MSGLEN; - 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; - hej = csr->udaip; - while (uda.uda_ca.ca_rspdsc < 0); - -} - -int curblock = 0; - -romstrategy(sc, func, dblk, size, buf, rsize) - void *sc; - int func; - daddr_t dblk; - char *buf; - int size, *rsize; -{ - int i; - int block = dblk; - int nsize = size; - - switch (vax_cputype) { - /* - * case VAX_TYP_UV2: - * case VAX_TYP_CVAX: - * case VAX_TYP_RIGEL: - */ - default: - switch (bootdev) { - - case BDEV_UDA: /* MSCP */ - uda.uda_cmd.mscp_seq.seq_lbn = dblk; - uda.uda_cmd.mscp_seq.seq_bytecount = size; - uda.uda_cmd.mscp_seq.seq_buffer = (int)buf; - uda.uda_cmd.mscp_unit = rpb->unit; - command(M_OP_READ, 0); - break; - - case BDEV_TK: /* TMSCP */ - if (dblk < curblock) { - uda.uda_cmd.mscp_seq.seq_bytecount = - curblock - dblk; - command(M_OP_POS, 12); - } else { - uda.uda_cmd.mscp_seq.seq_bytecount = - dblk - curblock; - command(M_OP_POS, 4); - } - curblock = size/512 + dblk; - for (i = 0 ; i < size/512 ; i++) { - uda.uda_cmd.mscp_seq.seq_lbn = 1; - uda.uda_cmd.mscp_seq.seq_bytecount = 512; - uda.uda_cmd.mscp_seq.seq_buffer = - (int)buf + i * 512; - uda.uda_cmd.mscp_unit = rpb->unit; - command(M_OP_READ, 0); - } - break; - case BDEV_RD: - case BDEV_ST: - case BDEV_SD: - - default: - romread_uvax(block, size, buf, bootregs); - break; - - } - break; - - case VAX_8200: - case VAX_750: - if (bootdev != BDEV_HP) { - while (size > 0) { - while ((read750(block, bootregs) & 0x01) == 0) - printf("Retrying read bn# %d\n", block); - bcopy(0, buf, 512); - size -= 512; - buf += 512; - block++; - } - } else - hpread(block, size, buf); - break; - } - - *rsize = nsize; - return 0; -} - -hpread(block, size, buf) - char *buf; -{ - volatile struct mba_regs *mr = (void *) bootregs[1]; - volatile struct hp_drv *hd = (void*)&mr->mba_md[bootregs[3]]; - struct disklabel *dp = &lp; - u_int pfnum, nsize, mapnr, bn, cn, sn, tn; - - pfnum = (u_int) buf >> PGSHIFT; - - for (mapnr = 0, nsize = size; (nsize + NBPG) > 0; nsize -= NBPG) - *(int *)&mr->mba_map[mapnr++] = PG_V | pfnum++; - mr->mba_var = ((u_int) buf & PGOFSET); - mr->mba_bc = (~size) + 1; - bn = block; - cn = bn / dp->d_secpercyl; - sn = bn % dp->d_secpercyl; - tn = sn / dp->d_nsectors; - sn = sn % dp->d_nsectors; - hd->hp_dc = cn; - hd->hp_da = (tn << 8) | sn; - hd->hp_cs1 = HPCS_READ; - while (mr->mba_sr & MBASR_DTBUSY); - if (mr->mba_sr & MBACR_ABORT){ - return 1; - } - return 0; -} diff --git a/sys/arch/vax/boot/common/romread.s b/sys/arch/vax/boot/common/romread.s new file mode 100644 index 00000000000..749a70bae2d --- /dev/null +++ b/sys/arch/vax/boot/common/romread.s @@ -0,0 +1,94 @@ +/* $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. + * 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. + */ + + /* All bugs are subject to removal without further notice */ + + + +#include "../include/asm.h" + +/* + * read750 (int block, int *regs) + */ +ENTRY(read750, 0xFFE) + movl 8(ap), r8 + movl 4(r8), r1 + movl 8(r8), r2 + movl 12(r8), r3 + movl 24(r8), r6 + clrl r5 + movl 4(ap), r8 + pushl $0 + movl $0, 4(sp) + movl fp, 0xf0000 # ragge ??? + jsb (r6) + movl 0xf0000, fp + ret + +/* + * romread_uvax (int lbn, int size, void *buf, int *regs) + */ +ENTRY(romread_uvax, 0xFFE) + movl 16(ap), r11 # array of bootregs + movl 44(r11), r11 # restore boot-contents of r11 (rpb) + movl 52(r11), r7 # load iovec/bqo into r7 + addl3 (r7), r7, r6 # load qio into r6 + pushl r11 # base of rpb + pushl $0 # virtual-flag + pushl $33 # read-logical-block + pushl 4(ap) # lbn to start reading + pushl 8(ap) # number of bytes to read + pushl 12(ap) # buffer-address + calls $6, (r6) # call the qio-routine + ret # r0 holds the result + +/* + * romwrite_uvax (int lbn, int size, void *buf, int *regs) + */ +ENTRY(romwrite_uvax, 0xFFE) + movl 16(ap), r11 # array of bootregs + movl 44(r11), r11 # restore boot-contents of r11 (rpb) + movl 52(r11), r7 # load iovec/bqo into r7 + addl3 (r7), r7, r6 # load qio into r6 + pushl r11 # base of rpb + pushl $0 # virtual-flag + pushl $32 # write-logical-block + pushl 4(ap) # lbn to start reading + pushl 8(ap) # number of bytes to read + pushl 12(ap) # buffer-address + calls $6, (r6) # call the qio-routine + ret # r0 holds the result + diff --git a/sys/arch/vax/boot/common/srt0.s b/sys/arch/vax/boot/common/srt0.s new file mode 100644 index 00000000000..350c47394a5 --- /dev/null +++ b/sys/arch/vax/boot/common/srt0.s @@ -0,0 +1,89 @@ +/* $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. + * + * 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 "../include/asm.h" +/* + * Auto-moving startup code for standalone programs. Can be loaded + * (almost) anywhere in memory but moves itself to the position + * it is linked for. Must be started at first position, recommended + * is phys addr 0 (boot loads programs at 0, but starts them at the + * position set in a.out header. + */ + +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 + + movl r8, _memsz # If we come from disk, save memsize + cmpl ap, $-1 # Check if we are net-booted. XXX - kludge + beql 2f # jump if not + ashl $9,76(r11),_memsz # got memsize from rpb + movzbl 102(r11), r10 # Get bootdev from rpb. + movzwl 48(r11), r11 # Get howto + +2: movl $_start, sp # Probably safe place for stack + subl2 $52, sp # do not overwrite saved boot-registers + + subl3 $_start, $_edata, r0 + movab _start, r1 + movl $_start, 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, _Xmain # Were here! + halt # no return + +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/common/str.s b/sys/arch/vax/boot/common/str.s new file mode 100644 index 00000000000..b2f93510ec7 --- /dev/null +++ b/sys/arch/vax/boot/common/str.s @@ -0,0 +1,147 @@ +/* $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. + * + * 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. + */ + +/* + * Small versions of the most common functions not using any + * emulated instructions. + */ + +#include "asm.h" + +/* + * atoi() used in devopen. + */ +ENTRY(atoi, 0); + movl 4(ap),r1 + clrl r0 + +2: movzbl (r1)+,r2 + cmpb r2,$48 + blss 1f + cmpb r2,$57 + bgtr 1f + subl2 $48,r2 + mull2 $10,r0 + addl2 r2,r0 + brb 2b +1: ret + +/* + * index() small and easy. + * doesnt work if we search for null. + */ +ENTRY(index, 0); + movq 4(ap),r0 +1: cmpb (r0), r1 + beql 2f + tstb (r0)+ + bneq 1b + clrl r0 +2: ret + +/* + * cmpc3 is emulated on MVII. + */ +ENTRY(bcmp, 0); + movl 4(ap), r2 + movl 8(ap), r1 + movl 12(ap), r0 +2: cmpb (r2)+, (r1)+ + bneq 1f + decl r0 + bneq 2b +1: ret + +/* + * Is movc3/movc5 emulated on any CPU? I dont think so; use them here. + */ +ENTRY(bzero,0); + movc5 $0,*4(ap),$0,8(ap),*4(ap) + ret + +ENTRY(bcopy,0); + movc3 12(ap), *4(ap), *8(ap) + ret + +ENTRY(strlen, 0); + movl 4(ap), r0 +1: tstb (r0)+ + bneq 1b + decl r0 + subl2 4(ap), r0 + ret + +ENTRY(strncmp, 0) + movl 12(ap), r3 + brb 5f + +ENTRY(strcmp, 0) + movl $250, r3 # max string len to compare +5: movl 4(ap), r2 + movl 8(ap), r1 + movl $1, r0 + +2: cmpb (r2),(r1)+ + bneq 1f # something differ + tstb (r2)+ + beql 4f # continue, strings unequal + decl r3 # max string len encountered? + bneq 2b + +4: clrl r0 # We are done, strings equal. + ret + +1: bgtr 3f + mnegl r0, r0 +3: ret + +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/common/vaxstand.h b/sys/arch/vax/boot/common/vaxstand.h new file mode 100644 index 00000000000..86cdb8bffdc --- /dev/null +++ b/sys/arch/vax/boot/common/vaxstand.h @@ -0,0 +1,59 @@ +/* $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. + * + * 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 */ + + +#define MAXNMBA 8 /* Massbussadapters */ +#define MAXNUBA 8 /* Unibusadapters */ +#define MAXMBAU 8 /* Units on an mba */ + +/* Variables used in autoconf */ +extern int nmba, nuba, nbi, nsbi, nuda; +extern int *ubaaddr, *mbaaddr, *udaaddr, *uioaddr, *biaddr; +extern int cpunumber, howto; +extern dev_t bootdev; + +/* devsw type definitions, used in bootxx and conf */ +#define SADEV(name,strategy,open,close,ioctl) \ + { (char *)name, \ + (int(*)(void *, int ,daddr_t , size_t, void *, size_t *))strategy, \ + (int(*)(struct open_file *, ...))open, \ + (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/conf.c b/sys/arch/vax/boot/conf.c deleted file mode 100644 index 952d3060a70..00000000000 --- a/sys/arch/vax/boot/conf.c +++ /dev/null @@ -1,102 +0,0 @@ -/* $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 $ */ -/* - * 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 - -#include "lib/libsa/stand.h" -#include "lib/libsa/ufs.h" -#include "lib/libsa/nfs.h" - -#include "vaxstand.h" - -int raopen(), rastrategy(); -int hpopen(), hpstrategy(); -int ctuopen(), ctustrategy(); -int tmscpopen(), tmscpstrategy(); -int romopen(), romstrategy(); -int mfmopen(), mfmstrategy(); -int sdopen(), sdstrategy(); -int netopen(), netstrategy(), netclose(); - -struct devsw devsw[]={ - SADEV("hp",hpstrategy, hpopen, nullsys, noioctl), - SADEV("qe",netstrategy, netopen, netclose, noioctl), /* DEQNA */ - SADEV("ctu",ctustrategy, ctuopen, nullsys, noioctl), - SADEV("ra",rastrategy, raopen, nullsys, noioctl), - 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("le",netstrategy, netopen, netclose, noioctl), /* LANCE */ -}; - -int cnvtab[] = { - BDEV_HP, - BDEV_QE, - BDEV_CNSL, - BDEV_UDA, - BDEV_TK, - -1, - BDEV_RD, - BDEV_SD, - BDEV_ST, - BDEV_LE, -}; - -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[] = { - { nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat }, -}; - -int nfsys = (sizeof(file_system) / sizeof(struct fs_ops)); - -extern struct netif_driver qe_driver; -extern struct netif_driver le_driver; - -struct netif_driver *netif_drivers[] = { -/* &qe_driver, */ - &le_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/boot/consio.c deleted file mode 100644 index c9791416bfa..00000000000 --- a/sys/arch/vax/boot/consio.c +++ /dev/null @@ -1,218 +0,0 @@ -/* $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 $ */ -/* - * 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 "../vax/gencons.h" - -#include "../include/mtpr.h" -#include "../include/sid.h" -#include "../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; - -int pr_putchar __P((int c)); /* putchar() using mtpr/mfpr */ -int pr_getchar __P((void)); - -int rom_putchar __P((int c)); /* putchar() using ROM routines */ -int rom_getchar __P((void)); - -static int rom_putc; /* ROM-address of put-routine */ -static int rom_getc; /* ROM-address of get-routine */ - -putchar(c) - int c; -{ - (*put_fp)(c); - if (c == 10) - (*put_fp)(13); /* CR/LF */ -} - -getchar() -{ - int c; - - do - c = (*get_fp)() & 0177; - while (c == 17 || c == 19); /* ignore XON/XOFF */ - return c; -} - - -/* - * 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() -{ - 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; - } - - /* - * According to the vax_boardtype (vax_cputype is not specific - * enough to do that) we decide which method/routines to use - * for console I/O. - * mtpr/mfpr are restricted to serial consoles, ROM-based routines - * support both serial and graphical consoles. - * We default to mtpr routines; so that we don't crash if - * it isn't a supported system. - */ - 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; - 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; - rom_putc = 0x20040058; /* 537133144 */ - rom_getc = 0x20040044; /* 537133124 */ - break; -#ifdef notdef - case VAX_BTYP_630: - case VAX_BTYP_650: - case VAX_BTYP_9CC: - case VAX_BTYP_60: - put_fp = pr_putchar; - get_fp = pr_getchar; - break -#endif - } - return; -} - -/* - * putchar() using MTPR - */ -pr_putchar(c) - int c; -{ - int timeout = 1<<15; /* don't hang the machine! */ - while ((mfpr(PR_TXCS) & GC_RDY) == 0) /* Wait until xmit ready */ - if (--timeout < 0) - break; - mtpr(c, PR_TXDB); /* xmit character */ -} - -/* - * getchar() using MFPR - */ -pr_getchar() -{ - while ((mfpr(PR_RXCS) & GC_DON) == 0); /* wait for char */ - return (mfpr(PR_RXDB)); /* now get it */ -} - -/* - * int rom_putchar (int c) ==> putchar() using ROM-routines - */ -asm(" - .globl _rom_putchar - _rom_putchar: - .word 0x04 # save-mask: R2 - movl 4(ap), r2 # move argument to R2 - jsb *_rom_putc # write it - ret # that's all -"); - - -/* - * int rom_getchar (void) ==> getchar() using ROM-routines - */ -asm(" - .globl _rom_getchar - _rom_getchar: - .word 0x02 # save-mask: R1 - loop: # do { - jsb *_rom_getc # call the getc-routine - tstl r0 # check if char ready - beql loop # } while (R0 == 0) - movl r1, r0 # R1 holds char - ret # we're done -"); - -_rtt() -{ - printf("rtt\n"); -bo: goto bo; -} 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 - -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; idv_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; idv_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/ctu.c b/sys/arch/vax/boot/ctu.c deleted file mode 100644 index 8e5ec6160a7..00000000000 --- a/sys/arch/vax/boot/ctu.c +++ /dev/null @@ -1,182 +0,0 @@ -/* $OpenBSD: ctu.c,v 1.2 1997/05/29 00:04:20 niklas Exp $ */ -/* $NetBSD: ctu.c,v 1.1 1996/02/17 18:23:20 ragge Exp $ */ -/* - * Copyright (c) 1996 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. - */ - -/* - * Standalone device driver for 11/750 Console TU58. - * It can only handle reads, and doesn't calculate checksum. - */ - -#include - -#include - -#include -#include - -enum tu_state { - SC_INIT, - SC_READY, - SC_SEND_CMD, - SC_GET_RESP, -}; - -volatile struct tu_softc { - enum tu_state sc_state; - char sc_rsp[15]; /* Should be struct rsb; but don't work */ - u_char *sc_xfptr; /* Current char to xfer */ - int sc_nbytes; /* Number of bytes to xfer */ - int sc_xbytes; /* Number of xfer'd bytes */ - int sc_bbytes; /* Number of xfer'd bytes this block */ -} tu_sc; - -void ctutintr __P(()); -void cturintr __P(()); - -int -ctuopen(f, adapt, ctlr, unit, part) - struct open_file *f; - int ctlr, unit, part; -{ - - tu_sc.sc_state = SC_INIT; - - mtpr(RSP_TYP_INIT, PR_CSTD); - cturintr(); - tu_sc.sc_state = SC_READY; - return 0; - -} - -int -ctustrategy(ra, func, dblk, size, buf, rsize) - struct ra_softc *ra; - int func; - daddr_t dblk; - char *buf; - u_int size, *rsize; -{ - int s; - - struct rsp *rsp = (struct rsp *)tu_sc.sc_rsp; - - tu_sc.sc_xfptr = buf; - tu_sc.sc_nbytes = size; - tu_sc.sc_xbytes = tu_sc.sc_bbytes = 0; - - rsp->rsp_typ = RSP_TYP_COMMAND; - rsp->rsp_sz = 012; - rsp->rsp_op = RSP_OP_READ; - rsp->rsp_mod = 0; - rsp->rsp_drv = 0; - rsp->rsp_sw = rsp->rsp_xx1 = rsp->rsp_xx2 = 0; - rsp->rsp_cnt = tu_sc.sc_nbytes; - rsp->rsp_blk = dblk; - rsp->rsp_sum = ctu_cksum(rsp, 6); - tu_sc.sc_state = SC_SEND_CMD; - while (tu_sc.sc_state != SC_GET_RESP) - ctutintr(); - while (tu_sc.sc_state != SC_READY) - cturintr(); - *rsize = size; - return 0; -} - -void -cturintr() -{ - int status; - - while ((mfpr(PR_CSRS) & 0x80) == 0) - ; - - status = mfpr(PR_CSRD); - - switch (tu_sc.sc_state) { - - case SC_INIT: - break; - - case SC_GET_RESP: - if (tu_sc.sc_xbytes == tu_sc.sc_nbytes) { - tu_sc.sc_bbytes++; - if (tu_sc.sc_bbytes == 146) - tu_sc.sc_state = SC_READY; - break; - } - tu_sc.sc_bbytes++; - if (tu_sc.sc_bbytes < 3) /* Data header */ - break; - if (tu_sc.sc_bbytes == 132) { /* Finished */ - tu_sc.sc_bbytes = 0; - break; - } - if (tu_sc.sc_bbytes == 131) /* First checksum */ - break; - tu_sc.sc_xfptr[tu_sc.sc_xbytes++] = status; - break; - - } - -} - -void -ctutintr() -{ - int c; - - while ((mfpr(PR_CSTS) & 0x80) == 0) - ; - - c = tu_sc.sc_rsp[tu_sc.sc_xbytes++] & 0xff; - mtpr(c, PR_CSTD); - if (tu_sc.sc_xbytes > 13) { - tu_sc.sc_state = SC_GET_RESP; - tu_sc.sc_xbytes = 0; - } -} - -ctu_cksum(buf, words) - unsigned short *buf; - int words; -{ - int i, cksum; - - for (i = cksum = 0; i < words; i++) - cksum += buf[i]; - -hej: if (cksum > 65535) { - cksum = (cksum & 65535) + (cksum >> 16); - goto hej; - } - return cksum; -} diff --git a/sys/arch/vax/boot/data.h b/sys/arch/vax/boot/data.h deleted file mode 100644 index e8d92478098..00000000000 --- a/sys/arch/vax/boot/data.h +++ /dev/null @@ -1,75 +0,0 @@ -/* $OpenBSD: data.h,v 1.2 1997/05/29 00:04:21 niklas Exp $ */ -/* $NetBSD: data.h,v 1.4 1995/09/16 15:58:57 ragge Exp $ */ -/* - * Copyright (c) 1995 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. - */ - - /* All bugs are subject to removal without further notice */ - - - -extern unsigned *bootregs; - -/* - * rpb->iovec gives pointer to this structure. - * - * bqo->unit_init() is used to initialize the controller, - * bqo->qio() is used to read from boot-device - */ - -struct bqo { - long qio; /* 4 QIO entry */ - long map; /* 4 Mapping entry */ - long select; /* 4 Selection entry */ - long drivrname; /* 4 Offset to driver name */ - short version; /* 2 Version number of VMB */ - short vercheck; /* 2 Check field */ - /* offset: 20 */ - long reselect; /* 4 Reselection entry */ - long move; /* 4 Move driver entry */ - long unit_init; /* 4 Unit initialization entry */ - long auxdrname; /* 4 Offset to auxiliary driver name */ - long umr_dis; /* 4 UNIBUS Map Registers to disable */ - /* offset: 40 */ - long ucode; /* 4 Absolute address of booting microcode */ - long unit_disc; /* 4 Unit disconnecting entry */ - long devname; /* 4 Offset to boot device name */ - long umr_tmpl; /* 4 UNIBUS map register template */ - /* offset: 60 */ - /* - * the rest is unknown / unneccessary ... - */ - long xxx[6]; /* 24 -- total: 84 bytes */ -}; - -extern struct bqo *bqo; diff --git a/sys/arch/vax/boot/devopen.c b/sys/arch/vax/boot/devopen.c deleted file mode 100644 index a34e7895207..00000000000 --- a/sys/arch/vax/boot/devopen.c +++ /dev/null @@ -1,145 +0,0 @@ -/* $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 $ */ -/* - * Copyright (c) 1997 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. - */ - -#include - -#include "lib/libsa/stand.h" -#include "samachdep.h" -#include "vaxstand.h" - -unsigned int opendev; - -int -devopen(f, fname, file) - struct open_file *f; - const char *fname; - char **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; - - dev = B_TYPE(bootdev); - ctlr = B_CONTROLLER(bootdev); - unit = B_UNIT(bootdev); - part = B_PARTITION(bootdev); - adapt = B_ADAPTOR(bootdev); - - for (i = 0, dp = 0; i < ndevs; i++) - if (cnvtab[i] == dev) - dp = devsw + i; - - x = 0; - if ((s = index(fname, '('))) { - *s++ = 0; - - for (i = 0, dp = devsw; i < ndevs; i++, dp++) - if (dp->dv_name && strcmp(dp->dv_name, fname) == 0) - break; - - if (i == ndevs) { - printf("No such device - Configured devices are:\n"); - for (dp = devsw, i = 0; i < ndevs; i++, dp++) - if (dp->dv_name) - printf(" %s", dp->dv_name); - printf("\n"); - return -1; - } - dev = cnvtab[i]; - if ((c = index(s, ')')) == 0) - goto usage; - - *c++ = 0; - - if (*s) do { - a[x++] = atoi(s); - while (*s >= '0' && *s <= '9') - s++; - - if (*s != ',' && *s != 0) - goto usage; - } while (*s++); - - if (x) - part = a[x - 1]; - if (x > 1) - unit = a[x - 2]; - if (x > 2) - ctlr = a[x - 3]; - if (x > 3) - adapt = a[0]; - *file = c; - } 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; - } - - } -#endif - - if (!dp->dv_open) - return(ENODEV); - f->f_dev = dp; - - 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); - - return i; - -usage: - printf("usage: dev(adapter,controller,unit,partition)file -asd\n"); - return -1; -} 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 - 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 \".\n\n"); - break; - case ('q'): - case ('Q'): - default: - break; - } - } while (*indata != 'q' && *indata != 'Q'); - goto igen; -} diff --git a/sys/arch/vax/boot/hp.c b/sys/arch/vax/boot/hp.c deleted file mode 100644 index 80d5d8ac56b..00000000000 --- a/sys/arch/vax/boot/hp.c +++ /dev/null @@ -1,166 +0,0 @@ -/* $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 $ */ -/* - * 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 "sys/disklabel.h" - -#include "lib/libsa/stand.h" - -#include "../include/pte.h" -#include "../include/macros.h" - -#include "../mba/mbareg.h" -#include "../mba/hpreg.h" - -#include "vaxstand.h" - -/* - * These routines for HP disk standalone boot is wery simple, - * assuming a lots of thing like that we only working at one hp disk - * a time, no separate routines for mba driver etc.. - * But it works :) - */ - -struct hp_softc { - int adapt; - int ctlr; - int unit; - int part; -}; - -struct disklabel hplabel; -struct hp_softc hp_softc; -char io_buf[DEV_BSIZE]; -daddr_t part_offset; - -hpopen(f, adapt, ctlr, unit, part) - struct open_file *f; - int ctlr, unit, part; -{ - struct disklabel *lp; - struct hp_softc *hs; - volatile struct mba_regs *mr; - volatile struct hp_drv *hd; - char *msg; - int i,err; - - lp = &hplabel; - hs = &hp_softc; - mr = (void *)mbaaddr[ctlr]; - hd = (void *)&mr->mba_md[unit]; - - if (adapt > nsbi) return(EADAPT); - if (ctlr > nmba) return(ECTLR); - if (unit > MAXMBAU) return(EUNIT); - - bzero(lp, sizeof(struct disklabel)); - - lp->d_secpercyl = 32; - lp->d_nsectors = 32; - hs->adapt = adapt; - hs->ctlr = ctlr; - hs->unit = unit; - hs->part = part; - - /* Set volume valid and 16 bit format; only done once */ - mr->mba_cr = MBACR_INIT; - hd->hp_cs1 = HPCS_PA; - hd->hp_of = HPOF_FMT; - - err = hpstrategy(hs, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); - if (err) { - printf("reading disklabel: %s\n", strerror(err)); - return 0; - } - - msg = getdisklabel(io_buf + LABELOFFSET, lp); - if (msg) - printf("getdisklabel: %s\n", msg); - - f->f_devdata = (void *)hs; - return 0; -} - -hpstrategy(hs, func, dblk, size, buf, rsize) - struct hp_softc *hs; - daddr_t dblk; - u_int size, *rsize; - char *buf; - int func; -{ - volatile struct mba_regs *mr; - volatile struct hp_drv *hd; - struct disklabel *lp; - unsigned int i, pfnum, mapnr, nsize, bn, cn, sn, tn; - - mr = (void *)mbaaddr[hs->ctlr]; - hd = (void *)&mr->mba_md[hs->unit]; - lp = &hplabel; - - pfnum = (u_int)buf >> PGSHIFT; - - for(mapnr = 0, nsize = size; (nsize + NBPG) > 0; nsize -= NBPG) - *(int *)&mr->mba_map[mapnr++] = PG_V | pfnum++; - - mr->mba_var = ((u_int)buf & PGOFSET); - mr->mba_bc = (~size) + 1; - bn = dblk + lp->d_partitions[hs->part].p_offset; - - if (bn) { - cn = bn / lp->d_secpercyl; - sn = bn % lp->d_secpercyl; - tn = sn / lp->d_nsectors; - sn = sn % lp->d_nsectors; - } else - cn = sn = tn = 0; - - hd->hp_dc = cn; - hd->hp_da = (tn << 8) | sn; - if (func == F_WRITE) - hd->hp_cs1 = HPCS_WRITE; - else - hd->hp_cs1 = HPCS_READ; - - while (mr->mba_sr & MBASR_DTBUSY) - ; - - if (mr->mba_sr & MBACR_ABORT) - return 1; - - *rsize = size; - - return 0; -} diff --git a/sys/arch/vax/boot/if_le.c b/sys/arch/vax/boot/if_le.c deleted file mode 100644 index 7a223edfa54..00000000000 --- a/sys/arch/vax/boot/if_le.c +++ /dev/null @@ -1,283 +0,0 @@ -/* $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 $ */ -/* - * Copyright (c) 1997 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. - */ - -/* - * Standalone routine for MicroVAX LANCE chip. - */ - -#include -#include - -#include -#include - -#include - -#include - -#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??? - */ -#define TLEN 1 -#define NTBUF (1 << TLEN) -#define RLEN 3 -#define NRBUF (1 << RLEN) -#define BUFSIZE 1518 - -#define QW_ALLOC(x) ((alloc((x) + 7) + 7) & ~7) - -int le_probe(), le_match(), le_get(), le_put(); -void le_init(); - -struct netif_stats le_stats; - -struct netif_dif le_ifs[] = { -/* dif_unit dif_nsel dif_stats dif_private */ -{ 0, 1, &le_stats, }, -}; - -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, -}; - -/* - * Init block & buffer descriptors according to DEC system - * specification documentation. - */ -struct initblock { - short ib_mode; - char ib_padr[6]; /* Ethernet address */ - int ib_ladrf1; - int ib_ladrf2; - int ib_rdr; /* Receive address */ - int ib_tdr; /* Transmit address */ -} *initblock = NULL; - -struct nireg { - volatile short ni_rdp; /* data port */ - volatile short ni_pad0; - volatile short ni_rap; /* register select port */ -} *nireg = (struct nireg *)0x200e0000; - - -volatile struct buffdesc { - int bd_adrflg; - short bd_bcnt; - short bd_mcnt; -} *rdesc, *tdesc; - -/* Flags in the address field */ -#define BR_OWN 0x80000000 -#define BR_ERR 0x40000000 -#define BR_FRAM 0x20000000 -#define BR_OFLO 0x10000000 -#define BR_CRC 0x08000000 -#define BR_BUFF 0x04000000 -#define BR_STP 0x02000000 -#define BR_ENP 0x01000000 - -#define BT_OWN 0x80000000 -#define BT_ERR 0x40000000 -#define BT_MORE 0x10000000 -#define BT_ONE 0x08000000 -#define BT_DEF 0x04000000 -#define BT_STP 0x02000000 -#define BT_ENP 0x01000000 - -int next_rdesc, next_tdesc; - -#define LEWRCSR(port, val) { \ - nireg->ni_rap = (port); \ - nireg->ni_rdp = (val); \ -} - -#define LERDCSR(port) \ - (nireg->ni_rap = port, nireg->ni_rdp) - -int -le_match(nif, machdep_hint) - struct netif *nif; - void *machdep_hint; -{ - return strcmp(machdep_hint, "le") == 0; -} - -le_probe(nif, machdep_hint) - struct netif *nif; - void *machdep_hint; -{ - return 0; -} - -void -le_init(desc, machdep_hint) - struct iodesc *desc; - void *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; - - 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; - - initblock = (void *)alloc(sizeof(struct initblock)); - 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); - initblock->ib_rdr = (RLEN << 29) | (int)rdesc; - (int)tdesc = QW_ALLOC(sizeof(struct buffdesc) * NTBUF); - initblock->ib_tdr = (TLEN << 29) | (int)tdesc; - - for (i = 0; i < NRBUF; i++) { - rdesc[i].bd_adrflg = alloc(BUFSIZE) | BR_OWN; - rdesc[i].bd_bcnt = -BUFSIZE; - rdesc[i].bd_mcnt = 0; - } - - for (i = 0; i < NTBUF; i++) { - tdesc[i].bd_adrflg = alloc(BUFSIZE); - tdesc[i].bd_bcnt = 0xf000; - tdesc[i].bd_mcnt = 0; - } - } - - LEWRCSR(LE_CSR1, (int)initblock & 0xffff); - LEWRCSR(LE_CSR2, ((int)initblock >> 16) & 0xff); - - LEWRCSR(LE_CSR0, LE_C0_INIT); - - to = 100000; - while (to--) - if (LERDCSR(LE_CSR0) & LE_C0_IDON) - break; - - LEWRCSR(LE_CSR0, LE_C0_INEA | LE_C0_STRT | LE_C0_IDON); -} - -int -le_get(desc, pkt, maxlen, timeout) - struct iodesc *desc; - void *pkt; - int maxlen; - time_t timeout; -{ - int csr, len; - volatile int to = 100000 * timeout; - -retry: - if (to-- == 0) - return 0; - - csr = LERDCSR(LE_CSR0); - LEWRCSR(LE_CSR0, csr & (LE_C0_BABL|LE_C0_MISS|LE_C0_MERR|LE_C0_RINT)); - - if (rdesc[next_rdesc].bd_adrflg & BR_OWN) - goto retry; - - if (rdesc[next_rdesc].bd_adrflg & BR_ERR) - len = 0; - else { - if ((len = rdesc[next_rdesc].bd_mcnt - 4) > maxlen) - len = maxlen; - - bcopy((void *)(rdesc[next_rdesc].bd_adrflg&0xffffff),pkt,len); - } - - rdesc[next_rdesc].bd_mcnt = 0; - rdesc[next_rdesc].bd_adrflg |= BR_OWN; - if (++next_rdesc >= NRBUF) - next_rdesc = 0; - - if (len == 0) - goto retry; - return len; -} - -int -le_put(desc, pkt, len) - struct iodesc *desc; - void *pkt; - int len; -{ - volatile int to = 100000; - int csr; - -retry: - if (--to == 0) - return -1; - - csr = LERDCSR(LE_CSR0); - LEWRCSR(LE_CSR0, csr & (LE_C0_MISS|LE_C0_CERR|LE_C0_TINT)); - - if (tdesc[next_tdesc].bd_adrflg & BT_OWN) - goto retry; - - bcopy(pkt, (void *)(tdesc[next_tdesc].bd_adrflg & 0xffffff), 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; - - LEWRCSR(LE_CSR0, LE_C0_TDMD); - - to = 100000; - while (((LERDCSR(LE_CSR0) & LE_C0_TINT) == 0) && --to) - ; - - LEWRCSR(LE_CSR0, LE_C0_TINT); - if (++next_tdesc >= NTBUF) - next_tdesc = 0; - - if (to) - return len; - - return -1; -} 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/mfm.c b/sys/arch/vax/boot/mfm.c deleted file mode 100644 index 20465089651..00000000000 --- a/sys/arch/vax/boot/mfm.c +++ /dev/null @@ -1,655 +0,0 @@ -/* $OpenBSD: mfm.c,v 1.4 1998/05/13 07:30:23 niklas Exp $ */ -/* $NetBSD: mfm.c,v 1.2 1997/03/15 13:04:28 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. - */ - -/* - * ToDo: - * - * - insert appropriate delays for diskette-drive where needed - * - allow more than one sector per diskette-read - * - check for and handle bad sectors - * - ??? - */ - -#include "sys/param.h" -#include "sys/reboot.h" -#include "sys/disklabel.h" - -#include "lib/libsa/stand.h" -#include "lib/libsa/ufs.h" - -#include "../include/pte.h" -#include "../include/sid.h" -#include "../include/mtpr.h" -#include "../include/reg.h" -#include "../include/rpb.h" - -#include "ka410.h" -#include "../vsa/hdc9224.h" - -#include "data.h" -#include "vaxstand.h" - -#define MAX_WAIT (1000*1000) /* # of loop-instructions in seconds */ - -struct mfm_softc { - int part; - int unit; -}; - -int mfmstrategy(), mfmopen(); -struct disklabel mfmlabel; -struct mfm_softc mfm_softc; -char io_buf[DEV_BSIZE]; - -/* - * These should probably be somewhere else, but ka410 is the only - * one with mfm disks anyway... - */ -volatile unsigned char *ka410_intreq = (void*)0x2008000f; -volatile unsigned char *ka410_intclr = (void*)0x2008000f; -volatile unsigned char *ka410_intmsk = (void*)0x2008000c; - -static volatile struct hdc9224_DKCreg *dkc = (void *) 0x200c0000; -static volatile struct hdc9224_UDCreg sreg; /* input */ -static volatile struct hdc9224_UDCreg creg; /* output */ - -/* - * we have to wait 0.7 usec between two accesses to any of the - * dkc-registers, on a VS2000 with 1 MIPS, this is roughly one - * instruction. Thus the loop-overhead will be enough... - */ -static int -sreg_read() -{ - int i; - char *p; - - dkc->dkc_cmd = 0x40; /* set internal counter to zero */ - p = (void *) &sreg; - for (i = 0; i < 10; i++) - *p++ = dkc->dkc_reg; /* dkc_reg auto-increments */ -} - -static int -creg_write() -{ - int i; - char *p; - - dkc->dkc_cmd = 0x40; /* set internal counter to zero */ - p = (void *) &creg; - for (i = 0; i < 10; i++) - dkc->dkc_reg = *p++; /* dkc_reg auto-increments */ -} - -/* - * floppies are handled in a quite strange way by this controller... - * - * before reading/writing a sector from/to floppy, we use the SEEK/READ_ID - * command to place the head at the desired location. Then we wait some - * time before issueing the real command in order to let the drive become - * ready... - */ -int -mfm_rxprepare() -{ - int error; - - error = mfm_command(DKC_CMD_SEEKREADID | 0x04); /* step=1, verify=0 */ - if (error) { - printf("error while stepping to position %d/%d/%x. Retry...\n", - creg.udc_dsect, creg.udc_dhead, creg.udc_dcyl); - error = mfm_command(DKC_CMD_SEEKREADID | 0x04); - } - return error; -} - -int -mfm_rxselect(unit) - int unit; -{ - int error; - - /* - * bring "creg" in some known-to-work state and - * select the drive with the DRIVE SELECT command. - */ - creg.udc_dma7 = 0; - creg.udc_dma15 = 0; - creg.udc_dma23 = 0; - creg.udc_dsect = 1; /* sectors are numbered 1..15 !!! */ - creg.udc_dhead = 0; - creg.udc_dcyl = 0; - creg.udc_scnt = 0; - - creg.udc_rtcnt = UDC_RC_RX33READ; - creg.udc_mode = UDC_MD_RX33; - creg.udc_term = UDC_TC_FDD; - - /* - * this is ... - */ - error = mfm_command(DKC_CMD_DRSEL_RX33 | unit); - - if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 0)) { - printf("\nfloppy-drive not ready (new floppy inserted?)\n\n"); - - creg.udc_rtcnt &= ~UDC_RC_INVRDY; /* clear INVRDY-flag */ - error = mfm_command(DKC_CMD_DRSEL_RX33 | unit); - if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 0)) { - printf("diskette not ready(1): %x/%x\n", - error, sreg.udc_dstat); - printf("floppy-drive offline?\n"); - return (-1); - } - if (sreg.udc_dstat & UDC_DS_TRK00) - error = mfm_command(DKC_CMD_STEPIN_FDD); - else - error = mfm_command(DKC_CMD_STEPOUT_FDD); - - /* - * now ready should be 0, cause INVRDY is not set - * (retrying a command makes this fail...) - */ - if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 1)) { - printf("diskette not ready(2): %x/%x\n", - error, sreg.udc_dstat); - } - creg.udc_rtcnt |= UDC_RC_INVRDY; - error = mfm_command(DKC_CMD_DRSEL_RX33 | unit); - - if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 0)) { - printf("diskette not ready(3): %x/%x\n", - error, sreg.udc_dstat); - printf("no floppy inserted or floppy-door open\n"); - return (-1); - } - printf("floppy-drive reselected.\n"); - } - return (error); -} - -int -mfm_rdselect(unit) - int unit; -{ - int error; - - /* - * bring "creg" in some known-to-work state and - * select the drive with the DRIVE SELECT command. - */ - creg.udc_dma7 = 0; - creg.udc_dma15 = 0; - creg.udc_dma23 = 0; - creg.udc_dsect = 0; /* sectors are numbered 0..16 */ - creg.udc_dhead = 0; - creg.udc_dcyl = 0; - creg.udc_scnt = 0; - - creg.udc_rtcnt = UDC_RC_HDD_READ; - creg.udc_mode = UDC_MD_HDD; - creg.udc_term = UDC_TC_HDD; - - error = mfm_command(DKC_CMD_DRSEL_HDD | unit); - - return (error); -} - -static int mfm_retry = 0; - -int -mfm_command(cmd) - int cmd; -{ - int termcode, ready, i; - - creg_write(); /* write command-registers */ - *ka410_intclr = INTR_DC; - dkc->dkc_cmd = cmd; /* issue command */ - for (i = 0; i < MAX_WAIT; i++) { - if (*ka410_intreq & INTR_DC) /* wait for interrupt */ - break; - } - if ((*ka410_intreq & INTR_DC) == 0) - printf("timeout in mfm_command...\n"); - - sreg_read(); /* read status-registers */ - - if (dkc->dkc_stat == (DKC_ST_DONE | DKC_TC_SUCCESS)) - return (0); - - if (sreg.udc_cstat & UDC_CS_ECCERR) { - printf( -"\nspurious(?) ECC/CRC error at s%d/t%d/c%d [s%d/t%d/c%d(%d)]\n", - sreg.udc_csect, sreg.udc_chead, sreg.udc_ccyl, - creg.udc_dsect, creg.udc_dhead, creg.udc_dcyl,creg.udc_scnt); - if (sreg.udc_csect != creg.udc_dsect + creg.udc_scnt - 1) { - printf("DMA: %x %x %x [%x]\n", - sreg.udc_dma23, sreg.udc_dma15, - sreg.udc_dma7, 512 * (sreg.udc_csect - - creg.udc_dsect)); - creg.udc_scnt = creg.udc_scnt - - (sreg.udc_csect - creg.udc_dsect) - 1; - creg.udc_dsect = sreg.udc_csect + 1; - creg.udc_dma23 = sreg.udc_dma23; - creg.udc_dma15 = sreg.udc_dma15 + 2; - creg.udc_dma7 = 0; - printf("Retry starting from s%d/t%d/c%d (%d). ", - creg.udc_dsect, creg.udc_dhead, creg.udc_dcyl, - creg.udc_scnt); - } - goto retry; - } - termcode = (dkc->dkc_stat & DKC_ST_TERMCOD) >> 3; - ready = sreg.udc_dstat & UDC_DS_READY; - - printf("cmd:0x%x: termcode=0x%x, status=0x%x, cstat=0x%x, dstat=0x%x\n", - cmd, termcode, dkc->dkc_stat, sreg.udc_cstat, sreg.udc_dstat); - - if (dkc->dkc_stat & DKC_ST_BADSECT) - printf("bad sector found: s%d/t%d/c%d\n", creg.udc_dsect, - creg.udc_dhead, creg.udc_dcyl); -retry: - if ((mfm_retry == 0) && (sreg.udc_cstat & UDC_CS_RETREQ)) { - mfm_retry = 1; - printf("Retrying... "); - mfm_command(cmd); - printf("Retry done.\n"); - mfm_retry = 0; - } - return ((dkc->dkc_stat & DKC_ST_TERMCOD) >> 3); -} - -/* - * on-disk geometry block - */ -#define _aP __attribute__ ((packed)) /* force byte-alignment */ - -volatile struct mfm_xbn { - char mbz[10];/* 10 bytes of zero */ - long xbn_count _aP; /* number of XBNs */ - long dbn_count _aP; /* number of DBNs */ - long lbn_count _aP; /* number of LBNs (Logical-Block-Numbers) */ - long rbn_count _aP; /* number of RBNs (Replacement-Block-Numbers) */ - short nspt; /* number of sectors per track */ - short ntracks;/* number of tracks */ - short ncylinders; /* number of cylinders */ - short precomp;/* first cylinder for write precompensation */ - short reduced;/* first cylinder for reduced write current */ - short seek_rate; /* seek rate or zero for buffered - * seeks */ - short crc_eec;/* 0 if CRC is being used or 1 if ECC is - * being used */ - short rct; /* "replacement control table" (RCT) */ - short rct_ncopies; /* number of copies of the RCT */ - long media_id _aP; /* media identifier */ - short interleave; /* sector-to-sector interleave */ - short headskew; /* head-to-head skew */ - short cylskew;/* cylinder-to-cylinder skew */ - short gap0_size; /* size of GAP 0 in the MFM format */ - short gap1_size; /* size of GAP 1 in the MFM format */ - short gap2_size; /* size of GAP 2 in the MFM format */ - short gap3_size; /* size of GAP 3 in the MFM format */ - short sync_value; /* sync value used to start a track - * when formatting */ - char reserved[32]; /* reserved for use by the RQDX1/2/3 - * formatter */ - short serial_number; /* serial number */ - char fill[412]; /* Filler bytes to the end of the - * block */ - short checksum; /* checksum over the XBN */ -} mfm_xbn; - -#ifdef verbose -display_xbn(p) - struct mfm_xbn *p; -{ - printf("**DiskData** XBNs: %d, DBNs: %d, LBNs: %d, RBNs: %d\n", - p->xbn_count, p->dbn_count, p->lbn_count, p->rbn_count); - printf("sect/track: %d, tracks: %d, cyl: %d, precomp/reduced: %d/%d\n", - p->nspt, p->ntracks, p->ncylinders, p->precomp, p->reduced); - printf("seek-rate: %d, crc/eec: %s, RCT: %d, RCT-copies: %d\n", - p->seek_rate, p->crc_eec ? "EEC" : "CRC", p->rct, p->rct_ncopies); - printf("media-ID: 0x%x, interleave: %d, headskew: %d, cylskew: %d\n", - &p->media_id, p->interleave, p->headskew, p->cylskew); - printf("gap0: %d, gap1: %d, gap2: %d, gap3: %d, sync-value: %d\n", - p->gap0_size, p->gap1_size, p->gap2_size, p->gap3_size, - p->sync_value); - printf("serial: %d, checksum: %d, size: %d, reserved: %32c\n", - p->serial_number, p->checksum, sizeof(*p), p->reserved); -} -#endif - -mfmopen(f, adapt, ctlr, unit, part) - struct open_file *f; - int ctlr, unit, part; -{ - char *msg; - struct disklabel *lp = &mfmlabel; - volatile struct mfm_softc *msc = &mfm_softc; - int i, err; - - bzero(lp, sizeof(struct disklabel)); - msc->unit = unit; - msc->part = part; - - err = mfmstrategy(msc, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); - if (err) { - printf("reading disklabel: %s\n", strerror(err)); - return 0; - } - msg = getdisklabel(io_buf + LABELOFFSET, lp); - if (msg) - printf("getdisklabel: %s\n", msg); - - f->f_devdata = (void *) msc; - - { - int k; - unsigned char *ucp; - struct mfm_xbn *xp; - - /* mfmstrategy(msc, F_READ, -16, 8192, io_buf, &i); */ - mfmstrategy(msc, F_READ, -16, DEV_BSIZE, io_buf, &i); -#ifdef verbose - printf("dumping raw disk-block #0:\n"); - ucp = io_buf; - for (k = 0; k < 128; k++) { - if (ucp[k] < 0x10) - printf("0"); - printf("%x ", ucp[k]); - if (k % 8 == 7) - printf(" "); - if (k % 16 == 15) - printf("\n"); - } - printf("\n"); - - xp = (void *) io_buf; - display_xbn(xp); - printf("\n"); -#endif - } - - if (unit == 2) { /* floppy! */ - if (lp->d_ntracks != 2) { -#ifdef verbose - printf("changing number of tracks from %d to %d.\n", - lp->d_ntracks, 2); -#endif - lp->d_ntracks = 2; - } - } else { /* hard-disk */ - unsigned short *usp = (void *) io_buf; -#ifdef verbose - printf("label says: s/t/c = %d/%d/%d\n", - lp->d_nsectors, lp->d_ntracks, lp->d_ncylinders); -#endif - if (lp->d_nsectors != usp[13]) { -#ifdef verbose - printf("changing number of sectors from %d to %d.\n", - lp->d_nsectors, usp[13]); -#endif - lp->d_nsectors = usp[13]; - } - if (lp->d_ntracks != usp[14]) { -#ifdef verbose - printf("changing number of heads/tracks from %d to %d.\n", - lp->d_ntracks, usp[14]); -#endif - lp->d_ntracks = usp[14]; - } - if (lp->d_ncylinders != usp[15]) { -#ifdef verbose - printf("changing number of cylinders from %d to %d.\n", - lp->d_ncylinders, usp[15]); -#endif - lp->d_ncylinders = usp[15]; - } - lp->d_secpercyl = lp->d_nsectors * lp->d_ntracks; - } - - return (0); -} - -mfm_rxstrategy(msc, func, dblk, size, buf, rsize) - struct mfm_softc *msc; - int func; - daddr_t dblk; - char *buf; - int size, *rsize; -{ - struct disklabel *lp; - int block, sect, head, cyl, scount, i, cmd, res, sval; - - lp = &mfmlabel; - block = (dblk < 0 ? 0 : dblk + lp->d_partitions[msc->part].p_offset); - - mfm_rxselect(msc->unit); - - /* - * if label is empty, assume RX33 - */ - if (lp->d_nsectors == 0) - lp->d_nsectors = 15; - if (lp->d_ntracks == 0) - lp->d_ntracks = 2; - if (lp->d_secpercyl == 0) - lp->d_secpercyl = 30; - - bzero((void *) 0x200D0000, size); - scount = size / 512; - - while (scount) { - /* - * prepare drive/operation parameter - */ - cyl = block / lp->d_secpercyl; - sect = block % lp->d_secpercyl; - head = sect / lp->d_nsectors; - sect = sect % lp->d_nsectors; - - /* - * *rsize = 512; /* one sector after the other - * ... - */ - *rsize = 512 * min(scount, lp->d_nsectors - sect); - - /* - * now initialize the register values ... - */ - creg.udc_dma7 = 0; - creg.udc_dma15 = 0; - creg.udc_dma23 = 0; - - creg.udc_dsect = sect + 1; /* sectors are numbered 1..15 - * !!! */ - head |= (cyl >> 4) & 0x70; - creg.udc_dhead = head; - creg.udc_dcyl = cyl; - - creg.udc_scnt = *rsize / 512; - - if (func == F_WRITE) { - creg.udc_rtcnt = UDC_RC_RX33WRT; - creg.udc_mode = UDC_MD_RX33; - creg.udc_term = UDC_TC_FDD; - - mfm_rxprepare(); - /* copy from buf */ - bcopy(buf, (void *) 0x200D0000, *rsize); - res = mfm_command(DKC_CMD_WRITE_RX33); - } else { - creg.udc_rtcnt = UDC_RC_RX33READ; - creg.udc_mode = UDC_MD_RX33; - creg.udc_term = UDC_TC_FDD; - - mfm_rxprepare(); - /* clear disk buffer */ - bzero((void *) 0x200D0000, *rsize); - res = mfm_command(DKC_CMD_READ_RX33); - /* copy to buf */ - bcopy((void *) 0x200D0000, buf, *rsize); - } - - scount -= *rsize / 512; - block += *rsize / 512; - buf += *rsize; - } - - *rsize = size; - return 0; -} - -mfm_rdstrategy(msc, func, dblk, size, buf, rsize) - struct mfm_softc *msc; - int func; - daddr_t dblk; - char *buf; - int size, *rsize; -{ - struct disklabel *lp; - int block, sect, head, cyl, scount, i, cmd, res, sval; - - lp = &mfmlabel; - block = (dblk < 0 ? 0 : dblk + lp->d_partitions[msc->part].p_offset); - - /* - * if label is empty, assume RD32 (XXX this must go away!!!) - */ - if (lp->d_nsectors == 0) - lp->d_nsectors = 17; - if (lp->d_ntracks == 0) - lp->d_ntracks = 6; - if (lp->d_secpercyl == 0) - lp->d_secpercyl = 102; - - mfm_rdselect(msc->unit); - - bzero((void *) 0x200D0000, size); - scount = size / 512; - - while (scount) { - /* - * prepare drive/operation parameter - */ - cyl = block / lp->d_secpercyl; - sect = block % lp->d_secpercyl; - head = sect / lp->d_nsectors; - sect = sect % lp->d_nsectors; - - if (dblk < 0) { -#ifdef verbose - printf("using raw diskblock-data!\n"); - printf("block %d, dblk %d ==> cyl %d, head %d, sect %d\n", - block, dblk, cyl, sect, head); -#endif - } else - cyl += 1; /* first cylinder is reserved for - * controller! */ - - *rsize = 512 * min(scount, lp->d_nsectors - sect); - /* - * now re-initialize the register values ... - */ - creg.udc_dma7 = 0; - creg.udc_dma15 = 0; - creg.udc_dma23 = 0; - - creg.udc_dsect = sect; - head |= (cyl >> 4) & 0x70; - creg.udc_dhead = head; - creg.udc_dcyl = cyl; - - creg.udc_scnt = *rsize / 512; - - if (func == F_WRITE) { - creg.udc_rtcnt = UDC_RC_HDD_WRT; - creg.udc_mode = UDC_MD_HDD; - creg.udc_term = UDC_TC_HDD; - cmd = DKC_CMD_WRITE_HDD; - - bcopy(buf, (void *) 0x200D0000, *rsize); - res = mfm_command(cmd); - } else { - creg.udc_rtcnt = UDC_RC_HDD_READ; - creg.udc_mode = UDC_MD_HDD; - creg.udc_term = UDC_TC_HDD; - cmd = DKC_CMD_READ_HDD; - - bzero((void *) 0x200D0000, *rsize); - res = mfm_command(cmd); - bcopy((void *) 0x200D0000, buf, *rsize); - } - - scount -= *rsize / 512; - block += *rsize / 512; - buf += *rsize; - } - - /* - * unselect the drive ... - */ - mfm_command(DKC_CMD_DRDESELECT); - - *rsize = size; - return 0; -} - -int -mfmstrategy(msc, func, dblk, size, buf, rsize) - struct mfm_softc *msc; - int func; - daddr_t dblk; - char *buf; - int size, *rsize; -{ - int res = -1; - - switch (msc->unit) { - case 0: - case 1: - res = mfm_rdstrategy(msc, func, dblk, size, buf, rsize); - break; - case 2: - res = mfm_rxstrategy(msc, func, dblk, size, buf, rsize); - break; - default: - printf("invalid unit %d in mfmstrategy()\n"); - } - return (res); -} diff --git a/sys/arch/vax/boot/netio.c b/sys/arch/vax/boot/netio.c deleted file mode 100644 index 99c58e02615..00000000000 --- a/sys/arch/vax/boot/netio.c +++ /dev/null @@ -1,245 +0,0 @@ -/* $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 $ */ - -/* - * Copyright (c) 1995, 1996 Jason R. Thorpe - * Copyright (c) 1995 Gordon W. Ross - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * 4. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Gordon W. Ross - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * This module implements a "raw device" interface suitable for - * use by the stand-alone I/O library NFS code. This interface - * does not support any "block" access, and exists only for the - * purpose of initializing the network interface, getting boot - * parameters, and performing the NFS mount. - * - * At open time, this does: - * - * find interface - netif_open() - * RARP for IP address - rarp_getipaddress() - * RPC/bootparams - callrpc(d, RPC_BOOTPARAMS, ...) - * RPC/mountd - nfs_mount(sock, ip, path) - * - * the root file handle from mountd is saved in a global - * for use by the NFS open code (NFS/lookup). - */ - -#include -#include -#include -#include -#include -#include - -#include "stand.h" -#include "samachdep.h" -#include "net.h" -#include "netif.h" -#include "bootparam.h" -#include "nfs.h" - -extern int nfs_root_node[]; /* XXX - get from nfs_mount() */ - -struct in_addr myip, rootip, gateip; -n_long netmask; -char rootpath[FNAME_SIZE]; - -int netdev_sock = -1; -static int open_count; - -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. - */ -int -netopen(f, devname) - struct open_file *f; - char *devname; /* Device part of file name (or NULL). */ -{ - int error = 0; - - /* On first open, do netif open, mount, etc. */ - if (open_count == 0) { - /* Find network interface. */ - if ((netdev_sock = netif_open(devname)) < 0) - return (error=ENXIO); - if ((error = netmountroot(f, devname)) != 0) - return (error); - } - open_count++; - f->f_devdata = nfs_root_node; - return (error); -} - -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); - f->f_devdata = NULL; -} - -int -netstrategy(devdata, func, dblk, size, v_buf, rsize) - void *devdata; - int func; - daddr_t dblk; - size_t size; - void *v_buf; - size_t *rsize; -{ - - *rsize = size; - return EIO; -} - -int -netmountroot(f, devname) - struct open_file *f; - char *devname; /* Device part of file name (or NULL). */ -{ - int error; - struct iodesc *d; - - if (netio_ask) { - get_my_ip: - printf("My IP address? "); - bzero(input_line, sizeof(input_line)); - gets(input_line); - if ((myip.s_addr = inet_addr(input_line)) == - htonl(INADDR_NONE)) { - printf("invalid IP address: %s\n", input_line); - goto get_my_ip; - } - - get_my_netmask: - printf("My netmask? "); - bzero(input_line, sizeof(input_line)); - gets(input_line); - if ((netmask = inet_addr(input_line)) == - htonl(INADDR_NONE)) { - printf("invalid netmask: %s\n", input_line); - goto get_my_netmask; - } - - get_my_gateway: - printf("My gateway? "); - bzero(input_line, sizeof(input_line)); - gets(input_line); - if ((gateip.s_addr = inet_addr(input_line)) == - htonl(INADDR_NONE)) { - printf("invalid IP address: %s\n", input_line); - goto get_my_gateway; - } - - get_server_ip: - printf("Server IP address? "); - bzero(input_line, sizeof(input_line)); - gets(input_line); - if ((rootip.s_addr = inet_addr(input_line)) == - htonl(INADDR_NONE)) { - printf("invalid IP address: %s\n", input_line); - goto get_server_ip; - } - - get_server_path: - printf("Server path? "); - bzero(rootpath, sizeof(rootpath)); - gets(rootpath); - if (rootpath[0] == '\0' || rootpath[0] == '\n') - goto get_server_path; - - if ((d = socktodesc(netdev_sock)) == NULL) - return (EMFILE); - - d->myip = myip; - - goto do_nfs_mount; - } - - /* - * Get info for NFS boot: our IP address, our hostname, - * server IP address, and our root path on the server. - * There are two ways to do this: The old, Sun way, - * and the more modern, BOOTP way. (RFC951, RFC1048) - */ - -#ifdef SUN_BOOTPARAMS - /* Get boot info using RARP and Sun bootparams. */ - - /* Get our IP address. (rarp.c) */ - if (rarp_getipaddress(netdev_sock) == -1) - return (errno); - - printf("boot: client IP address: %s\n", inet_ntoa(myip)); - - /* Get our hostname, server IP address. */ - if (bp_whoami(netdev_sock)) - return (errno); - - printf("boot: client name: %s\n", hostname); - - /* Get the root pathname. */ - if (bp_getfile(netdev_sock, "root", &rootip, rootpath)) - return (errno); - -#else - - /* Get boot info using BOOTP way. (RFC951, RFC1048) */ - bootp(netdev_sock); - - printf("Using 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"); - -#endif /* SUN_BOOTPARAMS */ - - printf("root addr=%s path=%s\n", inet_ntoa(rootip), rootpath); - - do_nfs_mount: - /* Get the NFS file handle (mount). */ - error = nfs_mount(netdev_sock, rootip, rootpath); - - return (error); -} diff --git a/sys/arch/vax/boot/ra.c b/sys/arch/vax/boot/ra.c deleted file mode 100644 index c349d2ec463..00000000000 --- a/sys/arch/vax/boot/ra.c +++ /dev/null @@ -1,232 +0,0 @@ -/* $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 $ */ -/* - * 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}. - * 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 */ - -#define NRSP 1 /* Kludge */ -#define NCMD 1 /* Kludge */ - -#include "sys/param.h" -#include "sys/disklabel.h" - -#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 "../mscp/mscp.h" -#include "../mscp/mscpreg.h" - -#include "../bi/bireg.h" -#include "../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 - * a time, no separate routines for uba driver etc.. - * This code is foolish and should need a cleanup. - * But it works :) - */ - -struct ra_softc { - int udaddr; - int ubaddr; - int part; - int unit; - unsigned short *ra_ip; - unsigned short *ra_sa; - unsigned short *ra_sw; -}; - -volatile struct uda { - struct mscp_1ca uda_ca; /* communications area */ - struct mscp uda_rsp; /* response packets */ - struct mscp uda_cmd; /* command packets */ -} uda; - -volatile struct uda *ubauda; -volatile struct udadevice *udacsr; -struct disklabel ralabel; -struct ra_softc ra_softc; -char io_buf[DEV_BSIZE]; - -raopen(f, adapt, ctlr, unit, part) - struct open_file *f; - int 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; - - bzero(lp, sizeof(struct disklabel)); - ra->unit = unit; - ra->part = part; - if (vax_cputype != VAX_8200) { - if (adapt > nuba) - return(EADAPT); - if (ctlr > nuda) - return(ECTLR); - nisse = (u_int *)&mr->uba_map[0]; - nisse[494] = PG_V | (((u_int)&uda) >> 9); - nisse[495] = nisse[494] + 1; - udacsr = (void*)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->udaddr = uioaddr[adapt] + udaaddr[ctlr]; - ra->ubaddr = (int)mr; - *ra->ra_ip = 0; /* Start init */ - } else { - struct bi_node *bi = (void *)biaddr[adapt]; - struct kdb_regs *kb = (void *)&bi[ctlr]; - volatile int i = 10000; - - ra->ra_ip = &kb->kdb_ip; - ra->ra_sa = &kb->kdb_sa; - ra->ra_sw = &kb->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; - while (i--) /* Need delay??? */ - ; - kb->kdb_bi.bi_ber = ~(BIBER_MBZ|BIBER_NMR|BIBER_UPEN);/* ??? */ - ubauda = &uda; - } - - /* Init of this uda */ - while ((*ra->ra_sa & MP_STEP1) == 0) - ; - - *ra->ra_sw = 0x8000; - while ((*ra->ra_sa & MP_STEP2) == 0) - ; - - *ra->ra_sw = johan; - while ((*ra->ra_sa & MP_STEP3) == 0) - ; - - *ra->ra_sw = johan2; - while ((*ra->ra_sa & MP_STEP4) == 0) - ; - - *ra->ra_sw = 0x0001; - uda.uda_ca.ca_rspdsc = (int)&ubauda->uda_rsp.mscp_cmdref; - uda.uda_ca.ca_cmddsc = (int)&ubauda->uda_cmd.mscp_cmdref; - - command(M_OP_SETCTLRC); - uda.uda_cmd.mscp_unit = ra->unit; - command(M_OP_ONLINE); - - err = rastrategy(ra,F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); - if(err){ - printf("reading disklabel: %s\n",strerror(err)); - return 0; - } - - msg = getdisklabel(io_buf+LABELOFFSET, lp); - if (msg) - printf("getdisklabel: %s\n", msg); - f->f_devdata = (void *)ra; - return(0); -} - -static -command(cmd) -{ - volatile int hej; - - uda.uda_cmd.mscp_opcode = cmd; - uda.uda_cmd.mscp_msglen = MSCP_MSGLEN; - 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; - hej = *ra_softc.ra_ip; - while(uda.uda_ca.ca_rspdsc<0) - ; - -} - -rastrategy(ra, func, dblk, size, buf, rsize) - struct ra_softc *ra; - int func; - daddr_t dblk; - 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]; - - pfnum = (u_int)buf >> PGSHIFT; - - for(mapnr = 0, nsize = size; (nsize + NBPG) > 0; nsize -= NBPG) - ptmapp[mapnr++] = PG_V | pfnum++; - uda.uda_cmd.mscp_seq.seq_buffer = ((u_int)buf) & 0x1ff; - } else - uda.uda_cmd.mscp_seq.seq_buffer = ((u_int)buf); - - lp = &ralabel; - uda.uda_cmd.mscp_seq.seq_lbn = - dblk + lp->d_partitions[ra->part].p_offset; - uda.uda_cmd.mscp_seq.seq_bytecount = size; - uda.uda_cmd.mscp_unit = ra->unit; - if (func == F_WRITE) - command(M_OP_WRITE); - else - command(M_OP_READ); - - *rsize = size; - return 0; -} diff --git a/sys/arch/vax/boot/rom.c b/sys/arch/vax/boot/rom.c deleted file mode 100644 index 1e14e6049a4..00000000000 --- a/sys/arch/vax/boot/rom.c +++ /dev/null @@ -1,124 +0,0 @@ -/* $OpenBSD: rom.c,v 1.3 1998/05/13 07:30:26 niklas Exp $ */ -/* $NetBSD: rom.c,v 1.1 1996/08/02 11:22:21 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. - */ - -#include "sys/param.h" -#include "sys/reboot.h" -#include "sys/disklabel.h" - -#include "lib/libsa/stand.h" -#include "lib/libsa/ufs.h" - -#include "../include/pte.h" -#include "../include/sid.h" -#include "../include/mtpr.h" -#include "../include/reg.h" -#include "../include/rpb.h" - -#include "data.h" -#include "vaxstand.h" - -extern unsigned *bootregs; -extern struct rpb *rpb; - -struct rom_softc { - int part; - int unit; -}; - -int romstrategy(), romopen(); -struct disklabel romlabel; -struct rom_softc rom_softc; -char io_buf[DEV_BSIZE]; - -romopen(f, adapt, ctlr, unit, part) - struct open_file *f; - int ctlr, unit, part; -{ - char *msg; - struct disklabel *lp = &romlabel; - volatile struct rom_softc *rsc = &rom_softc; - int i,err; - - bootregs[11] = XXRPB; - rpb = (void*)XXRPB; - bqo = (void*)rpb->iovec; - - if (rpb->unit > 0 && (rpb->unit % 100) == 0) { - printf ("changing rpb->unit from %d ", rpb->unit); - rpb->unit /= 100; - printf ("to %d\n", rpb->unit); - } - - bzero(lp, sizeof(struct disklabel)); - rsc->unit = unit; - rsc->part = part; - - err = romstrategy(rsc, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); - if (err) { - printf("reading disklabel: %s\n",strerror(err)); - return 0; - } - msg = getdisklabel(io_buf+LABELOFFSET, lp); - if (msg) - printf("getdisklabel: %s\n",msg); - f->f_devdata = (void*)rsc; - return(0); -} - -romstrategy (rsc, func, dblk, size, buf, rsize) - struct rom_softc *rsc; - int func; - daddr_t dblk; - char *buf; - int size, *rsize; -{ - struct disklabel *lp; - int block; - - lp = &romlabel; - block = dblk + lp->d_partitions[rsc->part].p_offset; - if (rsc->unit >= 0 && rsc->unit < 10) - rpb->unit = rsc->unit; - - if (func == F_WRITE) - romwrite_uvax(block, size, buf, bootregs); - else - romread_uvax(block, size, buf, bootregs); - - *rsize = size; - return 0; -} - diff --git a/sys/arch/vax/boot/romread.s b/sys/arch/vax/boot/romread.s deleted file mode 100644 index 41cb4e2d33d..00000000000 --- a/sys/arch/vax/boot/romread.s +++ /dev/null @@ -1,94 +0,0 @@ -/* $OpenBSD: romread.s,v 1.3 1997/05/29 00:04:24 niklas Exp $ */ -/* $NetBSD: romread.s,v 1.4 1996/08/02 11:22:24 ragge Exp $ */ -/* - * Copyright (c) 1995 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. - */ - - /* All bugs are subject to removal without further notice */ - - - -#include "../include/asm.h" - -/* - * read750 (int block, int *regs) - */ -ENTRY(read750, 0xFFE) - movl 8(ap), r8 - movl 4(r8), r1 - movl 8(r8), r2 - movl 12(r8), r3 - movl 24(r8), r6 - clrl r5 - movl 4(ap), r8 - pushl $0 - movl $0, 4(sp) - movl fp, 0xf0000 # ragge ??? - jsb (r6) - movl 0xf0000, fp - ret - -/* - * romread_uvax (int lbn, int size, void *buf, int *regs) - */ -ENTRY(romread_uvax, 0xFFE) - movl 16(ap), r11 # array of bootregs - movl 44(r11), r11 # restore boot-contents of r11 (rpb) - movl 52(r11), r7 # load iovec/bqo into r7 - addl3 (r7), r7, r6 # load qio into r6 - pushl r11 # base of rpb - pushl $0 # virtual-flag - pushl $33 # read-logical-block - pushl 4(ap) # lbn to start reading - pushl 8(ap) # number of bytes to read - pushl 12(ap) # buffer-address - calls $6, (r6) # call the qio-routine - ret # r0 holds the result - -/* - * romwrite_uvax (int lbn, int size, void *buf, int *regs) - */ -ENTRY(romwrite_uvax, 0xFFE) - movl 16(ap), r11 # array of bootregs - movl 44(r11), r11 # restore boot-contents of r11 (rpb) - movl 52(r11), r7 # load iovec/bqo into r7 - addl3 (r7), r7, r6 # load qio into r6 - pushl r11 # base of rpb - pushl $0 # virtual-flag - pushl $32 # write-logical-block - pushl 4(ap) # lbn to start reading - pushl 8(ap) # number of bytes to read - pushl 12(ap) # buffer-address - calls $6, (r6) # call the qio-routine - ret # r0 holds the result - 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 ", 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 -#include -#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<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/srt0.s b/sys/arch/vax/boot/srt0.s deleted file mode 100644 index f96bc035eb1..00000000000 --- a/sys/arch/vax/boot/srt0.s +++ /dev/null @@ -1,85 +0,0 @@ -/* $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 $ */ -/* - * 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 */ - - -/* - * Auto-moving startup code for standalone programs. Can be loaded - * (almost) anywhere in memory but moves itself to the position - * it is linked for. Must be started at first position, recommended - * is phys addr 0 (boot loads programs at 0, but starts them at the - * position set in a.out header. - */ - -start0: .set start0,0 # passing -e start0 to ld gives OK start addr - .globl start0 - -_start: .globl _start - nop;nop; # If we get called by calls, or something - - movl r8, _memsz # If we come from disk, save memsize - cmpl ap, $-1 # Check if we are net-booted. XXX - kludge - beql 2f # jump if not - ashl $9,76(r11),_memsz # got memsize from rpb - movzbl 102(r11), r10 # Get bootdev from rpb. - movzwl 48(r11), r11 # Get howto - -2: movl $_start, sp # Probably safe place for stack - subl2 $52, sp # do not overwrite saved boot-registers - - subl3 $_start, $_edata, r0 - moval _start, r1 - subl3 $_start, $_end, r2 - movl $_start, r3 - movc5 r0, (r1), $0, r2, (r3) - 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 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) - - .globl _memsz -_memsz: .long 0x0 diff --git a/sys/arch/vax/boot/start.s b/sys/arch/vax/boot/start.s deleted file mode 100644 index 61f75d87ba4..00000000000 --- a/sys/arch/vax/boot/start.s +++ /dev/null @@ -1,191 +0,0 @@ -/* $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 $ */ -/* - * Copyright (c) 1995 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. - */ - - /* All bugs are subject to removal without further notice */ - - -#define _LOCORE - -#include "sys/disklabel.h" - -#include "../include/mtpr.h" -#include "../include/asm.h" - -_start: .globl _start # this is the symbolic name for the start - # of code to be relocated. We can use this - # to get the actual/real adress (pc-rel) - # or to get the relocated address (abs). - -.org 0x00 # uVAX booted from TK50 starts here - brb from_0x00 # continue behind dispatch-block - -.org 0x02 # information used by uVAX-ROM - .byte (LABELOFFSET + d_end_)/2 # offset in words to identification area - .byte 1 # this byte must be 1 - .word 0 # logical block number (word swapped) - .word 0 # of the secondary image - -.org 0x08 # - brb from_0x08 # skip ... - -.org 0x0A # uVAX booted from disk starts here - brb from_0x0A # skip ... - -.org 0x0C # 11/750 & 8200 starts here - brw cont_750 - - -from_0x00: # uVAX from TK50 -from_0x0A: # uVAX from disk - brw start_uvax # all(?) uVAXen continue there - -from_0x08: # What comes here??? - halt - -.org LABELOFFSET - 6 -regmask: .word 0x0fff # using a variable saves 3 bytes !!! -bootinfo: .long 0x0 # another 3 bytes if within byte-offset - -# the complete area reserved for label -# must be empty (i.e. filled with zeroes). -# disklabel(8) checks that before installing -# the bootblocks over existing label. - -/* - * Parameter block for uVAX boot. - */ -#define VOLINFO 0 /* 1=single-sided 81=double-sided volumes */ -#define SISIZE 16 /* size in blocks of secondary image */ -#define SILOAD 0 /* load offset (usually 0) from the default */ -#define SIOFF 0x0A /* byte offset into secondary image */ - -.org LABELOFFSET + d_end_ - .byte 0x18 # must be 0x18 - .byte 0x00 # must be 0x00 (MBZ) - .byte 0x00 # any value - .byte 0xFF - (0x18 + 0x00 + 0x00) - /* 4th byte holds 1s' complement of sum of previous 3 bytes */ - - .byte 0x00 # must be 0x00 (MBZ) - .byte VOLINFO - .byte 0x00 # any value - .byte 0x00 # any value - - .long SISIZE # size in blocks of secondary image - .long SILOAD # load offset (usually 0) - .long SIOFF # byte offset into secondary image - .long (SISIZE + SILOAD + SIOFF) # sum of previous 3 - -/* - * After bootblock (LBN0) has been loaded into the first page - * of good memory by 11/750's ROM-code (transfer address - * of bootblock-code is: base of good memory + 0x0C) registers - * are initialized as: - * R0: type of boot-device - * 0: Massbus device - * 1: RK06/RK07 - * 2: RL02 - * 17: UDA50 - * 35: TK50 - * 64: TU58 - * R1: (UBA) address of UNIBUS I/O-page - * (MBA) address of boot device's adapter - * R2: (UBA) address of the boot device's CSR - * (MBA) controller number of boot device - * R6: address of driver subroutine in ROM - * - * cont_750 reads in LBN1-15 for further execution. - */ - .align 2 -cont_750: - movl r0,r10 - movl r5, ap # ap not used here - clrl r5 - clrl r4 - movl $_start,sp -1: incl r4 - movl r4,r8 - addl2 $0x200,r5 - cmpl $16,r4 - beql 2f - pushl r5 - jsb (r6) - blbs r0,1b -2: movl r10, r0 - movl r11, r5 - brw start_all - - -start_uvax: - mtpr $0, $PR_MAPEN # Turn off MM, please. - movl $_start, sp - movl 48(r11), ap - brb start_all - -/* - * start_all: stack already at RELOC, we save registers, move ourself - * to RELOC and loads boot. - */ -start_all: - pushr $0xfff # save all regs, used later. - - subl3 $_start, $_edata, r0 # get size of text+data (w/o bss) - moval _start, r1 # get actual base-address of code - subl3 $_start, $_end, r2 # get complete size (incl. bss) - movl $_start, r3 # get relocated base-address of code - movc5 r0, (r1), $0, r2, (r3) # copy code to new location - - movl $relocated, -(sp) # return-address on top of stack - rsb # can be replaced with new address -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 ... - -/* - * hoppabort() is called when jumping to the newly loaded program. - */ -ENTRY(hoppabort, 0) - movl 4(ap),r6 - movl 8(ap),r11 - movl 0xc(ap),r10 - movl _memsz, r8 - mnegl $1, ap # Hack to figure out boot device. - jmp 2(r6) -# calls $0,(r6) - halt diff --git a/sys/arch/vax/boot/str.s b/sys/arch/vax/boot/str.s deleted file mode 100644 index 8b393d5ddb3..00000000000 --- a/sys/arch/vax/boot/str.s +++ /dev/null @@ -1,133 +0,0 @@ -/* $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 $ */ -/* - * Copyright (c) 1996 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. - */ - -/* - * Small versions of the most common functions not using any - * emulated instructions. - */ - -#include "../include/asm.h" - -/* - * atoi() used in devopen. - */ -ENTRY(atoi, 0); - movl 4(ap),r1 - clrl r0 - -2: movzbl (r1)+,r2 - cmpb r2,$48 - blss 1f - cmpb r2,$57 - bgtr 1f - subl2 $48,r2 - mull2 $10,r0 - addl2 r2,r0 - brb 2b -1: ret - -/* - * index() small and easy. - * doesnt work if we search for null. - */ -ENTRY(index, 0); - movq 4(ap),r0 -1: cmpb (r0), r1 - beql 2f - tstb (r0)+ - bneq 1b - clrl r0 -2: ret - -/* - * cmpc3 is emulated on MVII. - */ -ENTRY(bcmp, 0); - movl 4(ap), r2 - movl 8(ap), r1 - movl 12(ap), r0 -2: cmpb (r2)+, (r1)+ - bneq 1f - decl r0 - bneq 2b -1: ret - -/* - * 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) - ret - -ENTRY(bcopy,0); - movl 4(ap), r0 - movl 8(ap), r1 - movl 12(ap), r2 - movc3 r2, (r0), (r1) - ret - -ENTRY(strlen, 0); - movl 4(ap), r0 -1: tstb (r0)+ - bneq 1b - decl r0 - subl2 4(ap), r0 - ret - -#if 0 -ENTRY(strncmp, 0) - movl 12(ap), r3 - brb 5f - -ENTRY(strcmp, 0) - movl $250, r3 # max string len to compare -5: movl 4(ap), r2 - movl 8(ap), r1 - movl $1, r0 - -2: cmpb (r2),(r1)+ - bneq 1f # something differ - tstb (r2)+ - beql 4f # continue, strings unequal - decl r3 # max string len encountered? - bneq 2b - -4: clrl r0 # We are done, strings equal. - ret - -1: bgtr 3f - mnegl r0, r0 -3: ret -#endif 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/tmscp.c b/sys/arch/vax/boot/tmscp.c deleted file mode 100644 index 90ca7e9fa48..00000000000 --- a/sys/arch/vax/boot/tmscp.c +++ /dev/null @@ -1,203 +0,0 @@ -/* $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 $ */ -/* - * 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}. - * 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 */ - -#define NRSP 0 /* Kludge */ -#define NCMD 0 /* Kludge */ - -#include "sys/param.h" -#include "sys/disklabel.h" - -#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 "vaxstand.h" - -static command(int,int); - -/* - * These routines for TMSCP tape standalone boot is very simple, - * assuming a lots of thing like that we only working at one tape at - * a time, no separate routines for uba driver etc.. - * This code is directly copied from ra disk driver. - */ - -struct ra_softc { - int udaddr; - int ubaddr; - int unit; -}; - -static volatile struct uda { - struct mscp_1ca uda_ca; /* communications area */ - struct mscp uda_rsp; /* response packets */ - struct mscp uda_cmd; /* command packets */ -} uda; - -static volatile struct uda *ubauda; -static volatile struct udadevice *udacsr; -static struct ra_softc ra_softc; - -tmscpopen(f, adapt, ctlr, unit, part) - struct open_file *f; - int 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; - - if(adapt>nuba) return(EADAPT); - if(ctlr>nuda) return(ECTLR); - ra->udaddr=uioaddr[adapt]+tmsaddr; - ra->ubaddr=(int)mr; - ra->unit=unit; - udacsr=(void*)ra->udaddr; - nisse=(u_int *)&mr->uba_map[0]; - nisse[494]=PG_V|(((u_int)&uda)>>9); - nisse[495]=nisse[494]+1; - ubauda=(void*)0x3dc00+(((u_int)(&uda))&0x1ff); - - /* - * Init of this tmscp ctlr. - */ - udacsr->udaip=0; /* Start init */ - while((udacsr->udasa&MP_STEP1) == 0); - udacsr->udasa=0x8000; - while((udacsr->udasa&MP_STEP2) == 0); - johan=(((u_int)ubauda)&0xffff)+8; - udacsr->udasa=johan; - while((udacsr->udasa&MP_STEP3) == 0); - udacsr->udasa=3; - while((udacsr->udasa&MP_STEP4) == 0); - udacsr->udasa=0x0001; - - uda.uda_ca.ca_rspdsc=(int)&ubauda->uda_rsp.mscp_cmdref; - uda.uda_ca.ca_cmddsc=(int)&ubauda->uda_cmd.mscp_cmdref; - uda.uda_cmd.mscp_un.un_seq.seq_addr = (long *)&uda.uda_ca.ca_cmddsc; - uda.uda_rsp.mscp_un.un_seq.seq_addr = (long *)&uda.uda_ca.ca_rspdsc; - uda.uda_cmd.mscp_vcid = 1; - uda.uda_cmd.mscp_un.un_sccc.sccc_ctlrflags = 0; - - command(M_OP_SETCTLRC, 0); - uda.uda_cmd.mscp_unit=ra->unit; - command(M_OP_ONLINE, 0); - - if (part) { - uda.uda_cmd.mscp_un.un_seq.seq_buffer = part; - command(M_OP_POS, 0); - uda.uda_cmd.mscp_un.un_seq.seq_buffer = 0; - } - - f->f_devdata=(void *)ra; - return(0); -} - -static -command(cmd, arg) -{ - volatile int hej; - - uda.uda_cmd.mscp_opcode = cmd; - uda.uda_cmd.mscp_modifier = arg; - - uda.uda_cmd.mscp_msglen = MSCP_MSGLEN; - 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; - hej = udacsr->udaip; - while (uda.uda_ca.ca_rspdsc < 0) { - if (uda.uda_ca.ca_cmdint) - uda.uda_ca.ca_cmdint = 0; - } - -} - -static int curblock = 0; - -tmscpstrategy(ra, func, dblk, size, buf, rsize) - struct ra_softc *ra; - int func; - daddr_t dblk; - char *buf; - 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 int hej; - - pfnum=(u_int)buf>>PGSHIFT; - - for(mapnr=0, nsize=size;(nsize+NBPG)>0;nsize-=NBPG) - ptmapp[mapnr++]=PG_V|pfnum++; - - /* - * First position tape. Remember where we are. - */ - if (dblk < curblock) { - uda.uda_cmd.mscp_seq.seq_bytecount = curblock - dblk; - command(M_OP_POS, 12); /* 12 == step block backward */ - } else { - uda.uda_cmd.mscp_seq.seq_bytecount = dblk - curblock; - command(M_OP_POS, 4); /* 4 == step block forward */ - } - curblock = size/512 + dblk; - - /* - * Read in the number of blocks we need. - * Why doesn't read of multiple blocks work????? - */ - for (i = 0 ; i < size/512 ; i++) { - uda.uda_cmd.mscp_seq.seq_lbn = 1; - uda.uda_cmd.mscp_seq.seq_bytecount = 512; - uda.uda_cmd.mscp_seq.seq_buffer = - (((u_int)buf) & 0x1ff) + i * 512; - uda.uda_cmd.mscp_unit = ra->unit; - command(M_OP_READ, 0); - } - - *rsize=size; - return 0; -} diff --git a/sys/arch/vax/boot/vaxstand.h b/sys/arch/vax/boot/vaxstand.h deleted file mode 100644 index ad2ec8d7598..00000000000 --- a/sys/arch/vax/boot/vaxstand.h +++ /dev/null @@ -1,53 +0,0 @@ -/* $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 $ */ -/* - * 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 */ - - -#define MAXNMBA 8 /* Massbussadapters */ -#define MAXNUBA 8 /* Unibusadapters */ -#define MAXMBAU 8 /* Units on an mba */ - -/* Variables used in autoconf */ -extern int nmba, nuba, nbi, nsbi, nuda; -extern int *ubaaddr, *mbaaddr, *udaaddr, *uioaddr, *biaddr; -extern int cpunumber; - -/* devsw type definitions, used in bootxx and conf */ -#define SADEV(name,strategy,open,close,ioctl) \ - { (char *)name, \ - (int(*)(void *, int ,daddr_t , size_t, void *, size_t *))strategy, \ - (int(*)(struct open_file *, ...))open, \ - (int(*)(struct open_file *))close, \ - (int(*)(struct open_file *,u_long, void *))ioctl} - -char *index(); 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 diff --git a/sys/arch/vax/boot/xxboot/bootxx.c b/sys/arch/vax/boot/xxboot/bootxx.c new file mode 100644 index 00000000000..3a1d48fab9f --- /dev/null +++ b/sys/arch/vax/boot/xxboot/bootxx.c @@ -0,0 +1,448 @@ +/* $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. + * + * 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 "sys/disklabel.h" + +#include "lib/libsa/stand.h" +#include "lib/libsa/ufs.h" + +#include "../include/pte.h" +#include "../include/sid.h" +#include "../include/mtpr.h" +#include "../include/reg.h" +#include "../include/rpb.h" + +#include "../mba/mbareg.h" +#include "../mba/hpreg.h" + +#define NRSP 1 /* Kludge */ +#define NCMD 1 /* Kludge */ + +#include "../mscp/mscp.h" +#include "../mscp/mscpreg.h" + +#include "vaxstand.h" + + +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 dev_t devtype, bootdev; +unsigned opendev, boothowto, bootset, memsz; + +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, + * VS3100/??, VS4000 and VAX6000/???, and only when booting from disk. + */ +Xmain() +{ + int io; + char *scbb; + char *new, *bqo; + char *hej = "/boot"; + + vax_cputype = (mfpr(PR_SID) >> 24) & 0xFF; + + /* + */ + switch (vax_cputype) { + case VAX_TYP_UV2: + case VAX_TYP_CVAX: + case VAX_TYP_RIGEL: + case VAX_TYP_NVAX: + case VAX_TYP_SOC: + /* + * now relocate rpb/bqo (which are used by ROM-routines) + */ + rpb = (void*)XXRPB; + bcopy ((void*)bootregs[11], rpb, 512); + rpb->rpb_base = rpb; + bqo = (void*)(512+(int)rpb); + bcopy ((void*)rpb->iovec, bqo, rpb->iovecsz); + rpb->iovec = (int)bqo; + bootregs[11] = (int)rpb; + bootdev = rpb->devtyp; + memsz = rpb->pfncnt << 9; + break; + case VAX_8200: + case VAX_750: + bootdev = bootregs[10]; + memsz = 0; + break; + default: + asm("halt"); + } + + bootset = getbootdev(); + + io = open(hej, 0); + + read(io, (void *)0x10000, 0x10000); + bcopy((void *) 0x10000, 0, 0xffff); + hoppabort(32, boothowto, bootset); + asm("halt"); +} + +getbootdev() +{ + int i, adaptor, controller, unit, partition, retval; + + adaptor = controller = unit = partition = 0; + + switch (vax_cputype) { + case VAX_TYP_UV2: + case VAX_TYP_CVAX: + case VAX_TYP_RIGEL: + 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 = bootregs[1]; + unit = bootregs[3]; + break; + } + + switch (B_TYPE(bootdev)) { + case BDEV_HP: /* massbuss boot */ + adaptor = (bootregs[1] & 0x6000) >> 17; + break; + + case BDEV_UDA: /* UDA50 boot */ + if (vax_cputype == VAX_750) + adaptor = (bootregs[1] & 0x40000 ? 0 : 1); + break; + + case BDEV_TK: /* TK50 boot */ + case BDEV_CNSL: /* Console storage boot */ + case BDEV_RD: /* RD/RX on HDC9224 (MV2000) */ + case BDEV_ST: /* SCSI-tape on NCR5380 (MV2000) */ + case BDEV_SD: /* SCSI-disk on NCR5380 (3100/76) */ + break; + + case BDEV_KDB: /* DSA disk on KDB50 (VAXBI VAXen) */ + bootdev = (bootdev & ~B_TYPEMASK) | BDEV_UDA; + break; + + default: + boothowto |= (RB_SINGLE | RB_ASKNAME); + } + return MAKEBOOTDEV(bootdev, adaptor, controller, unit, partition); +} + +/* + * 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 +tar_open(path, f) + char *path; + struct open_file *f; +{ + char *buf = alloc(512); + + 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; +} + +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) + struct open_file *f; + const char *fname; + char **file; +{ + extern char start; + char *msg; + int i, err, off; + char line[64]; + + f->f_dev = &devsw[0]; + *file = (char *)fname; + + /* + * On uVAX we need to init [T]MSCP ctlr to be able to use it. + */ + if (vax_cputype == VAX_TYP_UV2 || vax_cputype == VAX_TYP_CVAX) { + switch (bootdev) { + case BDEV_UDA: /* MSCP */ + case BDEV_TK: /* TMSCP */ + csr = (struct udadevice *)rpb->csrphy; + + csr->udaip = 0; /* Start init */ + while((csr->udasa & MP_STEP1) == 0); + csr->udasa = 0x8000; + while((csr->udasa & MP_STEP2) == 0); + csr->udasa = (short)(((u_int)&uda)&0xffff) + 8; + while((csr->udasa & MP_STEP3) == 0); + csr->udasa = 0x10; + while((csr->udasa & MP_STEP4) == 0); + csr->udasa = 0x0001; + + uda.uda_ca.ca_rspdsc = + (int) &uda.uda_rsp.mscp_cmdref; + uda.uda_ca.ca_cmddsc = + (int) &uda.uda_cmd.mscp_cmdref; + if (bootdev == BDEV_TK) + uda.uda_cmd.mscp_vcid = 1; + command(M_OP_SETCTLRC, 0); + uda.uda_cmd.mscp_unit = rpb->unit; + command(M_OP_ONLINE, 0); + } + } + + /* + * the disklabel _shall_ be at address LABELOFFSET + RELOC in + * phys memory now, no need at all to reread it again. + * Actually disklabel is only needed when using hp disks, + * but it doesn't hurt to always get it. + */ + getdisklabel(LABELOFFSET + &start, &lp); + return 0; +} + +command(cmd, arg) +{ + volatile int hej; + + uda.uda_cmd.mscp_opcode = cmd; + uda.uda_cmd.mscp_modifier = arg; + + uda.uda_cmd.mscp_msglen = MSCP_MSGLEN; + 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; + hej = csr->udaip; + while (uda.uda_ca.ca_rspdsc < 0); + +} + +int curblock = 0; + +romstrategy(sc, func, dblk, size, buf, rsize) + void *sc; + int func; + daddr_t dblk; + size_t size; + void *buf; + size_t *rsize; +{ + int i; + int block = dblk; + int nsize = size; + + switch (vax_cputype) { + /* + * case VAX_TYP_UV2: + * case VAX_TYP_CVAX: + * case VAX_TYP_RIGEL: + */ + default: + switch (bootdev) { + + case BDEV_UDA: /* MSCP */ + uda.uda_cmd.mscp_seq.seq_lbn = dblk; + uda.uda_cmd.mscp_seq.seq_bytecount = size; + uda.uda_cmd.mscp_seq.seq_buffer = (int)buf; + uda.uda_cmd.mscp_unit = rpb->unit; + command(M_OP_READ, 0); + break; + + case BDEV_TK: /* TMSCP */ + if (dblk < curblock) { + uda.uda_cmd.mscp_seq.seq_bytecount = + curblock - dblk; + command(M_OP_POS, 12); + } else { + uda.uda_cmd.mscp_seq.seq_bytecount = + dblk - curblock; + command(M_OP_POS, 4); + } + curblock = size/512 + dblk; + for (i = 0 ; i < size/512 ; i++) { + uda.uda_cmd.mscp_seq.seq_lbn = 1; + uda.uda_cmd.mscp_seq.seq_bytecount = 512; + uda.uda_cmd.mscp_seq.seq_buffer = + (int)buf + i * 512; + uda.uda_cmd.mscp_unit = rpb->unit; + command(M_OP_READ, 0); + } + break; + case BDEV_RD: + case BDEV_ST: + case BDEV_SD: + + default: + romread_uvax(block, size, buf, bootregs); + break; + + } + break; + + case VAX_8200: + case VAX_750: + if (bootdev != BDEV_HP) { + while (size > 0) { + while ((read750(block, bootregs) & 0x01) == 0){ + } + bcopy(0, buf, 512); + size -= 512; + buf += 512; + block++; + } + } else + hpread(block, size, buf); + break; + } + + if (rsize) + *rsize = nsize; + return 0; +} + +hpread(block, size, buf) + char *buf; +{ + volatile struct mba_regs *mr = (void *) bootregs[1]; + volatile struct hp_drv *hd = (void*)&mr->mba_md[bootregs[3]]; + struct disklabel *dp = &lp; + u_int pfnum, nsize, mapnr, bn, cn, sn, tn; + + pfnum = (u_int) buf >> PGSHIFT; + + for (mapnr = 0, nsize = size; (nsize + NBPG) > 0; nsize -= NBPG) + *(int *)&mr->mba_map[mapnr++] = PG_V | pfnum++; + mr->mba_var = ((u_int) buf & PGOFSET); + mr->mba_bc = (~size) + 1; + bn = block; + cn = bn / dp->d_secpercyl; + sn = bn % dp->d_secpercyl; + tn = sn / dp->d_nsectors; + sn = sn % dp->d_nsectors; + hd->hp_dc = cn; + hd->hp_da = (tn << 8) | sn; + hd->hp_cs1 = HPCS_READ; + while (mr->mba_sr & MBASR_DTBUSY); + if (mr->mba_sr & MBACR_ABORT){ + return 1; + } + 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/xxboot/start.s b/sys/arch/vax/boot/xxboot/start.s new file mode 100644 index 00000000000..d20753cf901 --- /dev/null +++ b/sys/arch/vax/boot/xxboot/start.s @@ -0,0 +1,200 @@ +/* $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. + * + * 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. + */ + + /* All bugs are subject to removal without further notice */ + + +#define _LOCORE + +#include "sys/disklabel.h" + +#include "../include/mtpr.h" +#include "../include/asm.h" + +_start: .globl _start # this is the symbolic name for the start + # of code to be relocated. We can use this + # to get the actual/real adress (pc-rel) + # or to get the relocated address (abs). + +.org 0x00 # uVAX booted from TK50 starts here + brb from_0x00 # continue behind dispatch-block + +.org 0x02 # information used by uVAX-ROM + .byte (LABELOFFSET + d_end_)/2 # offset in words to identification area + .byte 1 # this byte must be 1 + .word 0 # logical block number (word swapped) + .word 0 # of the secondary image + +.org 0x08 # + brb from_0x08 # skip ... + +.org 0x0A # uVAX booted from disk starts here + brb from_0x0A # skip ... + +.org 0x0C # 11/750 & 8200 starts here + brw cont_750 + + +from_0x00: # uVAX from TK50 +from_0x0A: # uVAX from disk + brw start_uvax # all(?) uVAXen continue there + +from_0x08: # What comes here??? + halt + +.org LABELOFFSET - 6 +regmask: .word 0x0fff # using a variable saves 3 bytes !!! +bootinfo: .long 0x0 # another 3 bytes if within byte-offset + +# the complete area reserved for label +# must be empty (i.e. filled with zeroes). +# disklabel(8) checks that before installing +# the bootblocks over existing label. + +/* + * Parameter block for uVAX boot. + */ +#define VOLINFO 0 /* 1=single-sided 81=double-sided volumes */ +#define SISIZE 16 /* size in blocks of secondary image */ +#define SILOAD 0 /* load offset (usually 0) from the default */ +#define SIOFF 0x0A /* byte offset into secondary image */ + +.org LABELOFFSET + d_end_ + .byte 0x18 # must be 0x18 + .byte 0x00 # must be 0x00 (MBZ) + .byte 0x00 # any value + .byte 0xFF - (0x18 + 0x00 + 0x00) + /* 4th byte holds 1s' complement of sum of previous 3 bytes */ + + .byte 0x00 # must be 0x00 (MBZ) + .byte VOLINFO + .byte 0x00 # any value + .byte 0x00 # any value + + .long SISIZE # size in blocks of secondary image + .long SILOAD # load offset (usually 0) + .long SIOFF # byte offset into secondary image + .long (SISIZE + SILOAD + SIOFF) # sum of previous 3 + +/* + * After bootblock (LBN0) has been loaded into the first page + * of good memory by 11/750's ROM-code (transfer address + * of bootblock-code is: base of good memory + 0x0C) registers + * are initialized as: + * R0: type of boot-device + * 0: Massbus device + * 1: RK06/RK07 + * 2: RL02 + * 17: UDA50 + * 35: TK50 + * 64: TU58 + * R1: (UBA) address of UNIBUS I/O-page + * (MBA) address of boot device's adapter + * R2: (UBA) address of the boot device's CSR + * (MBA) controller number of boot device + * R6: address of driver subroutine in ROM + * + * cont_750 reads in LBN1-15 for further execution. + */ + .align 2 +cont_750: + movl r0,r10 + movl r5, ap # ap not used here + clrl r5 + clrl r4 + movl $_start,sp +1: incl r4 + movl r4,r8 + addl2 $0x200,r5 + cmpl $16,r4 + beql 2f + pushl r5 + jsb (r6) + blbs r0,1b +2: movl r10, r0 + movl r11, r5 + brw start_all + + +start_uvax: + mtpr $0, $PR_MAPEN # Turn off MM, please. + movl $_start, sp + movl 48(r11), ap + brb start_all + +/* + * start_all: stack already at RELOC, we save registers, move ourself + * to RELOC and loads boot. + */ +start_all: + pushr $0xfff # save all regs, used later. + + subl3 $_start, $_edata, r0 # get size of text+data (w/o bss) + moval _start, r1 # get actual base-address of code + subl3 $_start, $_end, r2 # get complete size (incl. bss) + movl $_start, r3 # get relocated base-address of code + movc5 r0, (r1), $0, r2, (r3) # copy code to new location + + movl $relocated, -(sp) # return-address on top of stack + rsb # can be replaced with new address +relocated: # now relocation is done !!! + movl sp, _bootregs + movl ap, _boothowto + calls $0, _Xmain # call Xmain (gcc workaround)which is + halt # not intended to return ... + +/* + * hoppabort() is called when jumping to the newly loaded program. + */ +ENTRY(hoppabort, 0) + movl 4(ap),r6 + movl 8(ap),r11 + movl 0xc(ap),r10 + movl _memsz, r8 + mnegl $1, ap # Hack to figure out boot device. + 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 - +SUBDIR= boot xxboot +.include 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.c b/sys/arch/vax/stand/boot.c deleted file mode 100644 index b0df2b865b0..00000000000 --- a/sys/arch/vax/stand/boot.c +++ /dev/null @@ -1,254 +0,0 @@ -/* $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 $ */ -/*- - * 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" - -#define V750UCODE(x) ((x>>8)&255) - -#include - -/* - * Boot program... arguments passed in r10 and r11 determine - * whether boot stops to ask for system name and which device - * boot comes from. - */ - -char line[100]; -volatile int devtype, bootdev; -extern unsigned opendev; -extern unsigned *bootregs; - -Xmain() -{ - register howto asm("r11"); - register bdev asm("r10"); - int io, retry, type; - extern char vers[]; - - io=0; - bootdev=bdev; - autoconf(); - - if ((howto & RB_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; - } - - 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 (++retry > 2) - howto |= RB_SINGLE|RB_ASKNAME; - } -} - -/*ARGSUSED*/ -copyunix(howto, devtype, aio) - register howto, devtype; /* howto=r11, devtype=r10 */ - int aio; -{ - register int esym; /* must be r9 */ - struct exec x; - register int io = aio, i; - char *addr; - - if (read(io, (char *)&x, sizeof(x)) != sizeof(x) || N_BADMAG(x)) { - printf("Bad format\n"); - return; - } - 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; -} - -/* 750 Patchable Control Store magic */ - -#include "../include/mtpr.h" -#include "../include/cpu.h" -#include "../include/sid.h" -#define PCS_BITCNT 0x2000 /* number of patchbits */ -#define PCS_MICRONUM 0x400 /* number of ucode locs */ -#define PCS_PATCHADDR 0xf00000 /* start addr of patchbits */ -#define PCS_PCSADDR (PCS_PATCHADDR+0x8000) /* start addr of pcs */ -#define PCS_PATCHBIT (PCS_PATCHADDR+0xc000) /* patchbits enable reg */ -#define PCS_ENABLE 0xfff00000 /* enable bits for pcs */ - -#define extzv(one, two, three,four) \ -({ \ - asm __volatile (" extzv %0,%3,(%1),(%2)+" \ - : \ - : "g"(one),"g"(two),"g"(three),"g"(four)); \ -}) - - -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); - char pcs[100]; - char *cp; - - if ((mid >> 24) != VAX_750 || ((mid >> 8) & 255) < 95 || pcsdone) - return; - printf("Updating 11/750 microcode: "); - for (cp = line; *cp; cp++) - if (*cp == ')' || *cp == ':') - break; - if (*cp) { - bcopy(line, pcs, 99); - pcs[99] = 0; - i = cp - line + 1; - } else - i = 0; - strcpy(pcs + i, "pcs750.bin"); - i = open(pcs, 0); - if (i < 0) { - printf("bad luck - missing pcs750.bin :-(\n"); - return; - } - /* - * We ask for more than we need to be sure we get only what we expect. - * After read: - * locs 0 - 1023 packed patchbits - * 1024 - 11264 packed microcode - */ - if (read(i, (char *)0, 23*512) != 22*512) { - printf("Error reading %s\n", pcs); - close(i); - return; - } - close(i); - - /* - * Enable patchbit loading and load the bits one at a time. - */ - *((int *)PCS_PATCHBIT) = 1; - ip = (int *)PCS_PATCHADDR; - jp = (int *)0; - for (i=0; i < PCS_BITCNT; i++) { - extzv(i,jp,ip,1); - } - *((int *)PCS_PATCHBIT) = 0; - - /* - * Load PCS microcode 20 bits at a time. - */ - ip = (int *)PCS_PCSADDR; - jp = (int *)1024; - for (i=j=0; j < PCS_MICRONUM * 4; i+=20, j++) { - extzv(i,jp,ip,20); - } - - /* - * Enable PCS. - */ - i = *jp; /* get 1st 20 bits of microcode again */ - i &= 0xfffff; - i |= PCS_ENABLE; /* reload these bits with PCS enable set */ - *((int *)PCS_PCSADDR) = i; - - mid = mfpr(PR_SID); - printf("new rev level=%d\n", V750UCODE(mid)); - pcsdone = 1; -} 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 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/boot.c b/sys/arch/vax/stand/boot/boot.c new file mode 100644 index 00000000000..e6cde511d76 --- /dev/null +++ b/sys/arch/vax/stand/boot/boot.c @@ -0,0 +1,299 @@ +/* $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. + * + * 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" + +#define V750UCODE(x) ((x>>8)&255) + +#include "vaxstand.h" + +/* + * Boot program... arguments passed in r10 and r11 determine + * whether boot stops to ask for system name and which device + * boot comes from. + */ + +char line[100]; +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() +{ + int io, type, sluttid, askname, filindex = 0; + int j, senast = 0, nu; + + io=0; + autoconf(); + + 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) + 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; + } + } + + /* 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 (v->namn) + (*v->func)(d); + else + printf("Unknown command: %s\n", c); + + } +} + +void +halt() +{ + asm("halt"); +} + +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; + } + } +load: exec(fn, 0, 0); + printf("Boot failed: %s\n", strerror(errno)); +} + +/* 750 Patchable Control Store magic */ + +#include "../include/mtpr.h" +#include "../include/cpu.h" +#include "../include/sid.h" +#define PCS_BITCNT 0x2000 /* number of patchbits */ +#define PCS_MICRONUM 0x400 /* number of ucode locs */ +#define PCS_PATCHADDR 0xf00000 /* start addr of patchbits */ +#define PCS_PCSADDR (PCS_PATCHADDR+0x8000) /* start addr of pcs */ +#define PCS_PATCHBIT (PCS_PATCHADDR+0xc000) /* patchbits enable reg */ +#define PCS_ENABLE 0xfff00000 /* enable bits for pcs */ + +#define extzv(one, two, three,four) \ +({ \ + asm __volatile (" extzv %0,%3,(%1),(%2)+" \ + : \ + : "g"(one),"g"(two),"g"(three),"g"(four)); \ +}) + + +loadpcs() +{ + static int pcsdone = 0; + int mid = mfpr(PR_SID); + int i, j, *ip, *jp; + char pcs[100]; + char *cp; + + if ((mid >> 24) != VAX_750 || ((mid >> 8) & 255) < 95 || pcsdone) + return; + printf("Updating 11/750 microcode: "); + for (cp = line; *cp; cp++) + if (*cp == ')' || *cp == ':') + break; + if (*cp) { + bcopy(line, pcs, 99); + pcs[99] = 0; + i = cp - line + 1; + } else + i = 0; + strcpy(pcs + i, "pcs750.bin"); + i = open(pcs, 0); + if (i < 0) { + printf("bad luck - missing pcs750.bin :-(\n"); + return; + } + /* + * We ask for more than we need to be sure we get only what we expect. + * After read: + * locs 0 - 1023 packed patchbits + * 1024 - 11264 packed microcode + */ + if (read(i, (char *)0, 23*512) != 22*512) { + printf("Error reading %s\n", pcs); + close(i); + return; + } + close(i); + + /* + * Enable patchbit loading and load the bits one at a time. + */ + *((int *)PCS_PATCHBIT) = 1; + ip = (int *)PCS_PATCHADDR; + jp = (int *)0; + for (i=0; i < PCS_BITCNT; i++) { + extzv(i,jp,ip,1); + } + *((int *)PCS_PATCHBIT) = 0; + + /* + * Load PCS microcode 20 bits at a time. + */ + ip = (int *)PCS_PCSADDR; + jp = (int *)1024; + for (i=j=0; j < PCS_MICRONUM * 4; i+=20, j++) { + extzv(i,jp,ip,20); + } + + /* + * Enable PCS. + */ + i = *jp; /* get 1st 20 bits of microcode again */ + i &= 0xfffff; + i |= PCS_ENABLE; /* reload these bits with PCS enable set */ + *((int *)PCS_PCSADDR) = i; + + mid = mfpr(PR_SID); + 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/boot/conf.c b/sys/arch/vax/stand/boot/conf.c new file mode 100644 index 00000000000..334fe0cd933 --- /dev/null +++ b/sys/arch/vax/stand/boot/conf.c @@ -0,0 +1,103 @@ +/* $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. + * + * 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 "../../include/rpb.h" + +#include "lib/libsa/stand.h" +#include "lib/libsa/ufs.h" +#include "lib/libsa/nfs.h" + +#include "vaxstand.h" + +int raopen(), rastrategy(); +int hpopen(), hpstrategy(); +int ctuopen(), ctustrategy(); +int tmscpopen(), tmscpstrategy(); +int romopen(), romstrategy(); +int mfmopen(), mfmstrategy(); +int sdopen(), sdstrategy(); +int netopen(), netstrategy(), netclose(); + +struct devsw devsw[]={ + SADEV("hp",hpstrategy, hpopen, nullsys, noioctl), + SADEV("qe",netstrategy, netopen, netclose, noioctl), /* DEQNA */ + SADEV("ctu",ctustrategy, ctuopen, nullsys, noioctl), + SADEV("ra",rastrategy, raopen, nullsys, noioctl), + SADEV("mt",tmscpstrategy, tmscpopen, nullsys, noioctl), + SADEV("rom",romstrategy, romopen, nullsys, noioctl), + SADEV("rd",mfmstrategy, mfmopen, 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[] = { + BDEV_HP, + BDEV_QE, + BDEV_CNSL, + BDEV_UDA, + BDEV_TK, + -1, + BDEV_RD, + 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 }, + { nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat }, +}; + +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, + &le_driver, + &ze_driver, +}; +int n_netif_drivers = (sizeof(netif_drivers) / sizeof(netif_drivers[0])); + diff --git a/sys/arch/vax/stand/boot/consio.c b/sys/arch/vax/stand/boot/consio.c new file mode 100644 index 00000000000..9cb131fb945 --- /dev/null +++ b/sys/arch/vax/stand/boot/consio.c @@ -0,0 +1,323 @@ +/* $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, 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 "../vax/gencons.h" + +#include "mtpr.h" +#include "sid.h" +#include "rpb.h" + +#include "data.h" + +void setup __P((void)); + +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; +{ + (*put_fp)(c); + if (c == 10) + (*put_fp)(13); /* CR/LF */ +} + +getchar() +{ + int c; + + 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 +consinit() +{ + put_fp = pr_putchar; /* Default */ + get_fp = pr_getchar; + test_fp = pr_testchar; + + rpb = (struct rpb *)bootregs[11]; /* bertram: ??? */ + + /* + * According to the vax_boardtype (vax_cputype is not specific + * enough to do that) we decide which method/routines to use + * for console I/O. + * mtpr/mfpr are restricted to serial consoles, ROM-based routines + * support both serial and graphical consoles. + * We default to mtpr routines; so that we don't crash if + * it isn't a supported system. + */ + switch (vax_boardtype) { + + 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_410: + case VAX_BTYP_420: + 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: + case VAX_BTYP_9CC: + case VAX_BTYP_60: + put_fp = pr_putchar; + get_fp = pr_getchar; + break +#endif + } + return; +} + +/* + * putchar() using MTPR + */ +pr_putchar(c) + int c; +{ + int timeout = 1<<15; /* don't hang the machine! */ + while ((mfpr(PR_TXCS) & GC_RDY) == 0) /* Wait until xmit ready */ + if (--timeout < 0) + break; + mtpr(c, PR_TXDB); /* xmit character */ +} + +/* + * getchar() using MFPR + */ +pr_getchar() +{ + while ((mfpr(PR_RXCS) & GC_DON) == 0); /* wait for char */ + 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 + */ +asm(" + .globl _rom_putchar + _rom_putchar: + .word 0x04 # save-mask: R2 + movl 4(ap), r2 # move argument to R2 + jsb *_rom_putc # write it + ret # that's all +"); + + +/* + * int rom_getchar (void) ==> getchar() using ROM-routines + */ +asm(" + .globl _rom_getchar + _rom_getchar: + .word 0x02 # save-mask: R1 + loop: # do { + jsb *_rom_getc # call the getc-routine + tstl r0 # check if char ready + 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() +{ + 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/boot/ctu.c b/sys/arch/vax/stand/boot/ctu.c new file mode 100644 index 00000000000..3f2c9afb891 --- /dev/null +++ b/sys/arch/vax/stand/boot/ctu.c @@ -0,0 +1,182 @@ +/* $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. + * 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. + */ + +/* + * Standalone device driver for 11/750 Console TU58. + * It can only handle reads, and doesn't calculate checksum. + */ + +#include + +#include + +#include +#include + +enum tu_state { + SC_INIT, + SC_READY, + SC_SEND_CMD, + SC_GET_RESP, +}; + +volatile struct tu_softc { + enum tu_state sc_state; + char sc_rsp[15]; /* Should be struct rsb; but don't work */ + u_char *sc_xfptr; /* Current char to xfer */ + int sc_nbytes; /* Number of bytes to xfer */ + int sc_xbytes; /* Number of xfer'd bytes */ + int sc_bbytes; /* Number of xfer'd bytes this block */ +} tu_sc; + +void ctutintr __P((void)); +void cturintr __P((void)); + +int +ctuopen(f, adapt, ctlr, unit, part) + struct open_file *f; + int ctlr, unit, part; +{ + + tu_sc.sc_state = SC_INIT; + + mtpr(RSP_TYP_INIT, PR_CSTD); + cturintr(); + tu_sc.sc_state = SC_READY; + return 0; + +} + +int +ctustrategy(ra, func, dblk, size, buf, rsize) + struct ra_softc *ra; + int func; + daddr_t dblk; + char *buf; + u_int size, *rsize; +{ + int s; + + struct rsp *rsp = (struct rsp *)tu_sc.sc_rsp; + + tu_sc.sc_xfptr = buf; + tu_sc.sc_nbytes = size; + tu_sc.sc_xbytes = tu_sc.sc_bbytes = 0; + + rsp->rsp_typ = RSP_TYP_COMMAND; + rsp->rsp_sz = 012; + rsp->rsp_op = RSP_OP_READ; + rsp->rsp_mod = 0; + rsp->rsp_drv = 0; + rsp->rsp_sw = rsp->rsp_xx1 = rsp->rsp_xx2 = 0; + rsp->rsp_cnt = tu_sc.sc_nbytes; + rsp->rsp_blk = dblk; + rsp->rsp_sum = ctu_cksum(rsp, 6); + tu_sc.sc_state = SC_SEND_CMD; + while (tu_sc.sc_state != SC_GET_RESP) + ctutintr(); + while (tu_sc.sc_state != SC_READY) + cturintr(); + *rsize = size; + return 0; +} + +void +cturintr() +{ + int status; + + while ((mfpr(PR_CSRS) & 0x80) == 0) + ; + + status = mfpr(PR_CSRD); + + switch (tu_sc.sc_state) { + + case SC_INIT: + break; + + case SC_GET_RESP: + if (tu_sc.sc_xbytes == tu_sc.sc_nbytes) { + tu_sc.sc_bbytes++; + if (tu_sc.sc_bbytes == 146) + tu_sc.sc_state = SC_READY; + break; + } + tu_sc.sc_bbytes++; + if (tu_sc.sc_bbytes < 3) /* Data header */ + break; + if (tu_sc.sc_bbytes == 132) { /* Finished */ + tu_sc.sc_bbytes = 0; + break; + } + if (tu_sc.sc_bbytes == 131) /* First checksum */ + break; + tu_sc.sc_xfptr[tu_sc.sc_xbytes++] = status; + break; + + } + +} + +void +ctutintr() +{ + int c; + + while ((mfpr(PR_CSTS) & 0x80) == 0) + ; + + c = tu_sc.sc_rsp[tu_sc.sc_xbytes++] & 0xff; + mtpr(c, PR_CSTD); + if (tu_sc.sc_xbytes > 13) { + tu_sc.sc_state = SC_GET_RESP; + tu_sc.sc_xbytes = 0; + } +} + +ctu_cksum(buf, words) + unsigned short *buf; + int words; +{ + int i, cksum; + + for (i = cksum = 0; i < words; i++) + cksum += buf[i]; + +hej: if (cksum > 65535) { + cksum = (cksum & 65535) + (cksum >> 16); + goto hej; + } + return cksum; +} diff --git a/sys/arch/vax/stand/boot/data.h b/sys/arch/vax/stand/boot/data.h new file mode 100644 index 00000000000..9098d501d70 --- /dev/null +++ b/sys/arch/vax/stand/boot/data.h @@ -0,0 +1,75 @@ +/* $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. + * 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. + */ + + /* All bugs are subject to removal without further notice */ + + + +extern unsigned *bootregs; + +/* + * rpb->iovec gives pointer to this structure. + * + * bqo->unit_init() is used to initialize the controller, + * bqo->qio() is used to read from boot-device + */ + +struct bqo { + long qio; /* 4 QIO entry */ + long map; /* 4 Mapping entry */ + long select; /* 4 Selection entry */ + long drivrname; /* 4 Offset to driver name */ + short version; /* 2 Version number of VMB */ + short vercheck; /* 2 Check field */ + /* offset: 20 */ + long reselect; /* 4 Reselection entry */ + long move; /* 4 Move driver entry */ + long unit_init; /* 4 Unit initialization entry */ + long auxdrname; /* 4 Offset to auxiliary driver name */ + long umr_dis; /* 4 UNIBUS Map Registers to disable */ + /* offset: 40 */ + long ucode; /* 4 Absolute address of booting microcode */ + long unit_disc; /* 4 Unit disconnecting entry */ + long devname; /* 4 Offset to boot device name */ + long umr_tmpl; /* 4 UNIBUS map register template */ + /* offset: 60 */ + /* + * the rest is unknown / unneccessary ... + */ + long xxx[6]; /* 24 -- total: 84 bytes */ +}; + +extern struct bqo *bqo; diff --git a/sys/arch/vax/stand/boot/devopen.c b/sys/arch/vax/stand/boot/devopen.c new file mode 100644 index 00000000000..c832398b951 --- /dev/null +++ b/sys/arch/vax/stand/boot/devopen.c @@ -0,0 +1,123 @@ +/* $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. + * + * 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. + */ + +#include + +#include "lib/libsa/stand.h" +#include "vaxstand.h" + +unsigned int opendev; + +int +devopen(f, fname, file) + struct open_file *f; + const char *fname; + char **file; +{ + int dev, ctlr, unit, part, adapt, i, a[4], x; + struct devsw *dp; + extern int cnvtab[]; + char *s, *c, *u; + + dev = B_TYPE(bootdev); + ctlr = B_CONTROLLER(bootdev); + unit = B_UNIT(bootdev); + part = B_PARTITION(bootdev); + adapt = B_ADAPTOR(bootdev); + + for (i = 0, dp = 0; i < ndevs; i++) + if (cnvtab[i] == dev) + dp = devsw + i; + + x = 0; + if ((s = index(fname, '('))) { + *s++ = 0; + + for (i = 0, dp = devsw; i < ndevs; i++, dp++) + if (dp->dv_name && strcmp(dp->dv_name, fname) == 0) + break; + + if (i == ndevs) { + printf("No such device - Configured devices are:\n"); + for (dp = devsw, i = 0; i < ndevs; i++, dp++) + if (dp->dv_name) + printf(" %s", dp->dv_name); + printf("\n"); + return -1; + } + dev = cnvtab[i]; + if ((c = index(s, ')')) == 0) + goto usage; + + *c++ = 0; + + if (*s) do { + a[x++] = atoi(s); + while (*s >= '0' && *s <= '9') + s++; + + if (*s != ',' && *s != 0) + goto usage; + } while (*s++); + + if (x) + part = a[x - 1]; + if (x > 1) + unit = a[x - 2]; + if (x > 2) + ctlr = a[x - 3]; + if (x > 3) + adapt = a[0]; + *file = c; + } else { + *file = (char *)fname; + c = (char *)fname; + } + + if (!dp->dv_open) + return(ENODEV); + f->f_dev = dp; + + opendev = MAKEBOOTDEV(dev, adapt, ctlr, unit, part); + + if (dev > 95) { /* MOP boot over network, root & swap over NFS */ + i = (*dp->dv_open)(f, dp->dv_name); + } else + i = (*dp->dv_open)(f, adapt, ctlr, unit, part); + + return i; + +usage: + printf("usage: dev(adapter,controller,unit,partition)file -asd\n"); + return -1; +} diff --git a/sys/arch/vax/stand/boot/hp.c b/sys/arch/vax/stand/boot/hp.c new file mode 100644 index 00000000000..30f29ae1101 --- /dev/null +++ b/sys/arch/vax/stand/boot/hp.c @@ -0,0 +1,166 @@ +/* $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. + * + * 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 "sys/disklabel.h" + +#include "lib/libsa/stand.h" + +#include "../include/pte.h" +/*#include "../include/macros.h"*/ + +#include "../mba/mbareg.h" +#include "../mba/hpreg.h" + +#include "vaxstand.h" + +/* + * These routines for HP disk standalone boot is wery simple, + * assuming a lots of thing like that we only working at one hp disk + * a time, no separate routines for mba driver etc.. + * But it works :) + */ + +struct hp_softc { + int adapt; + int ctlr; + int unit; + int part; +}; + +struct disklabel hplabel; +struct hp_softc hp_softc; +char io_buf[DEV_BSIZE]; +daddr_t part_offset; + +hpopen(f, adapt, ctlr, unit, part) + struct open_file *f; + int ctlr, unit, part; +{ + struct disklabel *lp; + struct hp_softc *hs; + volatile struct mba_regs *mr; + volatile struct hp_drv *hd; + char *msg; + int i,err; + + lp = &hplabel; + hs = &hp_softc; + mr = (void *)mbaaddr[ctlr]; + hd = (void *)&mr->mba_md[unit]; + + if (adapt > nsbi) return(EADAPT); + if (ctlr > nmba) return(ECTLR); + if (unit > MAXMBAU) return(EUNIT); + + bzero(lp, sizeof(struct disklabel)); + + lp->d_secpercyl = 32; + lp->d_nsectors = 32; + hs->adapt = adapt; + hs->ctlr = ctlr; + hs->unit = unit; + hs->part = part; + + /* Set volume valid and 16 bit format; only done once */ + mr->mba_cr = MBACR_INIT; + hd->hp_cs1 = HPCS_PA; + hd->hp_of = HPOF_FMT; + + err = hpstrategy(hs, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); + if (err) { + printf("reading disklabel: %s\n", strerror(err)); + return 0; + } + + msg = getdisklabel(io_buf + LABELOFFSET, lp); + if (msg) + printf("getdisklabel: %s\n", msg); + + f->f_devdata = (void *)hs; + return 0; +} + +hpstrategy(hs, func, dblk, size, buf, rsize) + struct hp_softc *hs; + daddr_t dblk; + u_int size, *rsize; + char *buf; + int func; +{ + volatile struct mba_regs *mr; + volatile struct hp_drv *hd; + struct disklabel *lp; + unsigned int i, pfnum, mapnr, nsize, bn, cn, sn, tn; + + mr = (void *)mbaaddr[hs->ctlr]; + hd = (void *)&mr->mba_md[hs->unit]; + lp = &hplabel; + + pfnum = (u_int)buf >> VAX_PGSHIFT; + + 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 & VAX_PGOFSET); + mr->mba_bc = (~size) + 1; + bn = dblk + lp->d_partitions[hs->part].p_offset; + + if (bn) { + cn = bn / lp->d_secpercyl; + sn = bn % lp->d_secpercyl; + tn = sn / lp->d_nsectors; + sn = sn % lp->d_nsectors; + } else + cn = sn = tn = 0; + + hd->hp_dc = cn; + hd->hp_da = (tn << 8) | sn; + if (func == F_WRITE) + hd->hp_cs1 = HPCS_WRITE; + else + hd->hp_cs1 = HPCS_READ; + + while (mr->mba_sr & MBASR_DTBUSY) + ; + + if (mr->mba_sr & MBACR_ABORT) + return 1; + + *rsize = size; + + return 0; +} diff --git a/sys/arch/vax/stand/boot/if_le.c b/sys/arch/vax/stand/boot/if_le.c new file mode 100644 index 00000000000..31fb9f756b1 --- /dev/null +++ b/sys/arch/vax/stand/boot/if_le.c @@ -0,0 +1,389 @@ +/* $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, 1999 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. + */ + +/* + * Standalone routine for MicroVAX LANCE chip. + */ + +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include <../include/sid.h> + +#include + +#include + +/* + * The following are incorrect. Why doesn't DEC follow its own specs??? + */ +#define TLEN 1 +#define NTBUF (1 << TLEN) +#define RLEN 3 +#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(), le_end(); +static void copyin(), copyout(); + +struct netif_stats le_stats; + +struct netif_dif le_ifs[] = { +/* dif_unit dif_nsel dif_stats dif_private */ +{ 0, 1, &le_stats, }, +}; + +struct netif_stats le_stats; + +struct netif_driver le_driver = { + "le", le_match, le_probe, le_init, le_get, le_put, le_end, le_ifs, 1, +}; + +/* + * Init block & buffer descriptors according to DEC system + * specification documentation. + */ +struct initblock { + short ib_mode; + char ib_padr[6]; /* Ethernet address */ + int ib_ladrf1; + int ib_ladrf2; + int ib_rdr; /* Receive address */ + int ib_tdr; /* Transmit address */ +} *initblock = NULL; + +struct nireg { + volatile u_short ni_rdp; /* data port */ + volatile short ni_pad0; + volatile short ni_rap; /* register select port */ +} *nireg = (struct nireg *)0x200e0000; + + +volatile struct buffdesc { + int bd_adrflg; + short bd_bcnt; + short bd_mcnt; +} *rdesc, *tdesc; + +static int addoff, kopiera = 0; + +/* Flags in the address field */ +#define BR_OWN 0x80000000 +#define BR_ERR 0x40000000 +#define BR_FRAM 0x20000000 +#define BR_OFLO 0x10000000 +#define BR_CRC 0x08000000 +#define BR_BUFF 0x04000000 +#define BR_STP 0x02000000 +#define BR_ENP 0x01000000 + +#define BT_OWN 0x80000000 +#define BT_ERR 0x40000000 +#define BT_MORE 0x10000000 +#define BT_ONE 0x08000000 +#define BT_DEF 0x04000000 +#define BT_STP 0x02000000 +#define BT_ENP 0x01000000 + +int next_rdesc, next_tdesc; + +#define LEWRCSR(port, val) { \ + nireg->ni_rap = (port); \ + nireg->ni_rdp = (val); \ +} + +#define LERDCSR(port) \ + (nireg->ni_rap = port, nireg->ni_rdp) + +int +le_match(nif, machdep_hint) + struct netif *nif; + void *machdep_hint; +{ + return strcmp(machdep_hint, "le") == 0; +} + +le_probe(nif, machdep_hint) + struct netif *nif; + void *machdep_hint; +{ + return 0; +} + +void +le_init(desc, machdep_hint) + struct iodesc *desc; + void *machdep_hint; +{ + int stat, i, *ea; + volatile int to = 100000; + + 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--) + ; + + for (i = 0; i < 6; i++) + desc->myea[i] = ea[i] & 0377; + + 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) + addoff; + initblock->ib_rdr = (RLEN << 29) | (int)rdesc; + 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 = 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 = 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); + } + + 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--) { + 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); +} + +int +le_get(desc, pkt, maxlen, timeout) + struct iodesc *desc; + void *pkt; + int maxlen; + time_t timeout; +{ + int csr, len; + volatile int to = 100000 * timeout; + +retry: + if (to-- == 0) + return 0; + + 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; + + if (rdesc[next_rdesc].bd_adrflg & BR_ERR) + len = 0; + else { + if ((len = rdesc[next_rdesc].bd_mcnt - 4) > maxlen) + len = maxlen; + + 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; +} + +int +le_put(desc, pkt, len) + struct iodesc *desc; + void *pkt; + int len; +{ + volatile int to = 100000; + int csr; + +retry: + if (--to == 0) + return -1; + + 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; + + 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); + + to = 100000; + while (((LERDCSR(LE_CSR0) & LE_C0_TINT) == 0) && --to) + ; + + LEWRCSR(LE_CSR0, LE_C0_TINT); + if (++next_tdesc >= NTBUF) + next_tdesc = 0; + + if (to) + return len; + + 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 +#include + +#include +#include + +#include + +#include + +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 +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include + +#include + +#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> 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 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/boot/mfm.c b/sys/arch/vax/stand/boot/mfm.c new file mode 100644 index 00000000000..33fbbbc3065 --- /dev/null +++ b/sys/arch/vax/stand/boot/mfm.c @@ -0,0 +1,655 @@ +/* $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. + * 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. + */ + +/* + * ToDo: + * + * - insert appropriate delays for diskette-drive where needed + * - allow more than one sector per diskette-read + * - check for and handle bad sectors + * - ??? + */ + +#include "sys/param.h" +#include "sys/reboot.h" +#include "sys/disklabel.h" + +#include "lib/libsa/stand.h" +#include "lib/libsa/ufs.h" + +#include "../include/pte.h" +#include "../include/sid.h" +#include "../include/mtpr.h" +#include "../include/reg.h" +#include "../include/rpb.h" + +#include "ka410.h" +#include "../vsa/hdc9224.h" + +#include "data.h" +#include "vaxstand.h" + +#define MAX_WAIT (1000*1000) /* # of loop-instructions in seconds */ + +struct mfm_softc { + int part; + int unit; +}; + +int mfmstrategy(), mfmopen(); +struct disklabel mfmlabel; +struct mfm_softc mfm_softc; +char io_buf[DEV_BSIZE]; + +/* + * These should probably be somewhere else, but ka410 is the only + * one with mfm disks anyway... + */ +volatile unsigned char *ka410_intreq = (void*)0x2008000f; +volatile unsigned char *ka410_intclr = (void*)0x2008000f; +volatile unsigned char *ka410_intmsk = (void*)0x2008000c; + +static volatile struct hdc9224_DKCreg *dkc = (void *) 0x200c0000; +static volatile struct hdc9224_UDCreg sreg; /* input */ +static volatile struct hdc9224_UDCreg creg; /* output */ + +/* + * we have to wait 0.7 usec between two accesses to any of the + * dkc-registers, on a VS2000 with 1 MIPS, this is roughly one + * instruction. Thus the loop-overhead will be enough... + */ +static int +sreg_read() +{ + int i; + char *p; + + dkc->dkc_cmd = 0x40; /* set internal counter to zero */ + p = (void *) &sreg; + for (i = 0; i < 10; i++) + *p++ = dkc->dkc_reg; /* dkc_reg auto-increments */ +} + +static int +creg_write() +{ + int i; + char *p; + + dkc->dkc_cmd = 0x40; /* set internal counter to zero */ + p = (void *) &creg; + for (i = 0; i < 10; i++) + dkc->dkc_reg = *p++; /* dkc_reg auto-increments */ +} + +/* + * floppies are handled in a quite strange way by this controller... + * + * before reading/writing a sector from/to floppy, we use the SEEK/READ_ID + * command to place the head at the desired location. Then we wait some + * time before issueing the real command in order to let the drive become + * ready... + */ +int +mfm_rxprepare() +{ + int error; + + error = mfm_command(DKC_CMD_SEEKREADID | 0x04); /* step=1, verify=0 */ + if (error) { + printf("error while stepping to position %d/%d/%x. Retry...\n", + creg.udc_dsect, creg.udc_dhead, creg.udc_dcyl); + error = mfm_command(DKC_CMD_SEEKREADID | 0x04); + } + return error; +} + +int +mfm_rxselect(unit) + int unit; +{ + int error; + + /* + * bring "creg" in some known-to-work state and + * select the drive with the DRIVE SELECT command. + */ + creg.udc_dma7 = 0; + creg.udc_dma15 = 0; + creg.udc_dma23 = 0; + creg.udc_dsect = 1; /* sectors are numbered 1..15 !!! */ + creg.udc_dhead = 0; + creg.udc_dcyl = 0; + creg.udc_scnt = 0; + + creg.udc_rtcnt = UDC_RC_RX33READ; + creg.udc_mode = UDC_MD_RX33; + creg.udc_term = UDC_TC_FDD; + + /* + * this is ... + */ + error = mfm_command(DKC_CMD_DRSEL_RX33 | unit); + + if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 0)) { + printf("\nfloppy-drive not ready (new floppy inserted?)\n\n"); + + creg.udc_rtcnt &= ~UDC_RC_INVRDY; /* clear INVRDY-flag */ + error = mfm_command(DKC_CMD_DRSEL_RX33 | unit); + if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 0)) { + printf("diskette not ready(1): %x/%x\n", + error, sreg.udc_dstat); + printf("floppy-drive offline?\n"); + return (-1); + } + if (sreg.udc_dstat & UDC_DS_TRK00) + error = mfm_command(DKC_CMD_STEPIN_FDD); + else + error = mfm_command(DKC_CMD_STEPOUT_FDD); + + /* + * now ready should be 0, cause INVRDY is not set + * (retrying a command makes this fail...) + */ + if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 1)) { + printf("diskette not ready(2): %x/%x\n", + error, sreg.udc_dstat); + } + creg.udc_rtcnt |= UDC_RC_INVRDY; + error = mfm_command(DKC_CMD_DRSEL_RX33 | unit); + + if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 0)) { + printf("diskette not ready(3): %x/%x\n", + error, sreg.udc_dstat); + printf("no floppy inserted or floppy-door open\n"); + return (-1); + } + printf("floppy-drive reselected.\n"); + } + return (error); +} + +int +mfm_rdselect(unit) + int unit; +{ + int error; + + /* + * bring "creg" in some known-to-work state and + * select the drive with the DRIVE SELECT command. + */ + creg.udc_dma7 = 0; + creg.udc_dma15 = 0; + creg.udc_dma23 = 0; + creg.udc_dsect = 0; /* sectors are numbered 0..16 */ + creg.udc_dhead = 0; + creg.udc_dcyl = 0; + creg.udc_scnt = 0; + + creg.udc_rtcnt = UDC_RC_HDD_READ; + creg.udc_mode = UDC_MD_HDD; + creg.udc_term = UDC_TC_HDD; + + error = mfm_command(DKC_CMD_DRSEL_HDD | unit); + + return (error); +} + +static int mfm_retry = 0; + +int +mfm_command(cmd) + int cmd; +{ + int termcode, ready, i; + + creg_write(); /* write command-registers */ + *ka410_intclr = INTR_DC; + dkc->dkc_cmd = cmd; /* issue command */ + for (i = 0; i < MAX_WAIT; i++) { + if (*ka410_intreq & INTR_DC) /* wait for interrupt */ + break; + } + if ((*ka410_intreq & INTR_DC) == 0) + printf("timeout in mfm_command...\n"); + + sreg_read(); /* read status-registers */ + + if (dkc->dkc_stat == (DKC_ST_DONE | DKC_TC_SUCCESS)) + return (0); + + if (sreg.udc_cstat & UDC_CS_ECCERR) { + printf( +"\nspurious(?) ECC/CRC error at s%d/t%d/c%d [s%d/t%d/c%d(%d)]\n", + sreg.udc_csect, sreg.udc_chead, sreg.udc_ccyl, + creg.udc_dsect, creg.udc_dhead, creg.udc_dcyl,creg.udc_scnt); + if (sreg.udc_csect != creg.udc_dsect + creg.udc_scnt - 1) { + printf("DMA: %x %x %x [%x]\n", + sreg.udc_dma23, sreg.udc_dma15, + sreg.udc_dma7, 512 * (sreg.udc_csect - + creg.udc_dsect)); + creg.udc_scnt = creg.udc_scnt - + (sreg.udc_csect - creg.udc_dsect) - 1; + creg.udc_dsect = sreg.udc_csect + 1; + creg.udc_dma23 = sreg.udc_dma23; + creg.udc_dma15 = sreg.udc_dma15 + 2; + creg.udc_dma7 = 0; + printf("Retry starting from s%d/t%d/c%d (%d). ", + creg.udc_dsect, creg.udc_dhead, creg.udc_dcyl, + creg.udc_scnt); + } + goto retry; + } + termcode = (dkc->dkc_stat & DKC_ST_TERMCOD) >> 3; + ready = sreg.udc_dstat & UDC_DS_READY; + + printf("cmd:0x%x: termcode=0x%x, status=0x%x, cstat=0x%x, dstat=0x%x\n", + cmd, termcode, dkc->dkc_stat, sreg.udc_cstat, sreg.udc_dstat); + + if (dkc->dkc_stat & DKC_ST_BADSECT) + printf("bad sector found: s%d/t%d/c%d\n", creg.udc_dsect, + creg.udc_dhead, creg.udc_dcyl); +retry: + if ((mfm_retry == 0) && (sreg.udc_cstat & UDC_CS_RETREQ)) { + mfm_retry = 1; + printf("Retrying... "); + mfm_command(cmd); + printf("Retry done.\n"); + mfm_retry = 0; + } + return ((dkc->dkc_stat & DKC_ST_TERMCOD) >> 3); +} + +/* + * on-disk geometry block + */ +#define _aP __attribute__ ((packed)) /* force byte-alignment */ + +volatile struct mfm_xbn { + char mbz[10];/* 10 bytes of zero */ + long xbn_count _aP; /* number of XBNs */ + long dbn_count _aP; /* number of DBNs */ + long lbn_count _aP; /* number of LBNs (Logical-Block-Numbers) */ + long rbn_count _aP; /* number of RBNs (Replacement-Block-Numbers) */ + short nspt; /* number of sectors per track */ + short ntracks;/* number of tracks */ + short ncylinders; /* number of cylinders */ + short precomp;/* first cylinder for write precompensation */ + short reduced;/* first cylinder for reduced write current */ + short seek_rate; /* seek rate or zero for buffered + * seeks */ + short crc_eec;/* 0 if CRC is being used or 1 if ECC is + * being used */ + short rct; /* "replacement control table" (RCT) */ + short rct_ncopies; /* number of copies of the RCT */ + long media_id _aP; /* media identifier */ + short interleave; /* sector-to-sector interleave */ + short headskew; /* head-to-head skew */ + short cylskew;/* cylinder-to-cylinder skew */ + short gap0_size; /* size of GAP 0 in the MFM format */ + short gap1_size; /* size of GAP 1 in the MFM format */ + short gap2_size; /* size of GAP 2 in the MFM format */ + short gap3_size; /* size of GAP 3 in the MFM format */ + short sync_value; /* sync value used to start a track + * when formatting */ + char reserved[32]; /* reserved for use by the RQDX1/2/3 + * formatter */ + short serial_number; /* serial number */ + char fill[412]; /* Filler bytes to the end of the + * block */ + short checksum; /* checksum over the XBN */ +} mfm_xbn; + +#ifdef verbose +display_xbn(p) + struct mfm_xbn *p; +{ + printf("**DiskData** XBNs: %d, DBNs: %d, LBNs: %d, RBNs: %d\n", + p->xbn_count, p->dbn_count, p->lbn_count, p->rbn_count); + printf("sect/track: %d, tracks: %d, cyl: %d, precomp/reduced: %d/%d\n", + p->nspt, p->ntracks, p->ncylinders, p->precomp, p->reduced); + printf("seek-rate: %d, crc/eec: %s, RCT: %d, RCT-copies: %d\n", + p->seek_rate, p->crc_eec ? "EEC" : "CRC", p->rct, p->rct_ncopies); + printf("media-ID: 0x%x, interleave: %d, headskew: %d, cylskew: %d\n", + &p->media_id, p->interleave, p->headskew, p->cylskew); + printf("gap0: %d, gap1: %d, gap2: %d, gap3: %d, sync-value: %d\n", + p->gap0_size, p->gap1_size, p->gap2_size, p->gap3_size, + p->sync_value); + printf("serial: %d, checksum: %d, size: %d, reserved: %32c\n", + p->serial_number, p->checksum, sizeof(*p), p->reserved); +} +#endif + +mfmopen(f, adapt, ctlr, unit, part) + struct open_file *f; + int ctlr, unit, part; +{ + char *msg; + struct disklabel *lp = &mfmlabel; + volatile struct mfm_softc *msc = &mfm_softc; + int i, err; + + bzero(lp, sizeof(struct disklabel)); + msc->unit = unit; + msc->part = part; + + err = mfmstrategy(msc, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); + if (err) { + printf("reading disklabel: %s\n", strerror(err)); + return 0; + } + msg = getdisklabel(io_buf + LABELOFFSET, lp); + if (msg) + printf("getdisklabel: %s\n", msg); + + f->f_devdata = (void *) msc; + + { + int k; + unsigned char *ucp; + struct mfm_xbn *xp; + + /* mfmstrategy(msc, F_READ, -16, 8192, io_buf, &i); */ + mfmstrategy(msc, F_READ, -16, DEV_BSIZE, io_buf, &i); +#ifdef verbose + printf("dumping raw disk-block #0:\n"); + ucp = io_buf; + for (k = 0; k < 128; k++) { + if (ucp[k] < 0x10) + printf("0"); + printf("%x ", ucp[k]); + if (k % 8 == 7) + printf(" "); + if (k % 16 == 15) + printf("\n"); + } + printf("\n"); + + xp = (void *) io_buf; + display_xbn(xp); + printf("\n"); +#endif + } + + if (unit == 2) { /* floppy! */ + if (lp->d_ntracks != 2) { +#ifdef verbose + printf("changing number of tracks from %d to %d.\n", + lp->d_ntracks, 2); +#endif + lp->d_ntracks = 2; + } + } else { /* hard-disk */ + unsigned short *usp = (void *) io_buf; +#ifdef verbose + printf("label says: s/t/c = %d/%d/%d\n", + lp->d_nsectors, lp->d_ntracks, lp->d_ncylinders); +#endif + if (lp->d_nsectors != usp[13]) { +#ifdef verbose + printf("changing number of sectors from %d to %d.\n", + lp->d_nsectors, usp[13]); +#endif + lp->d_nsectors = usp[13]; + } + if (lp->d_ntracks != usp[14]) { +#ifdef verbose + printf("changing number of heads/tracks from %d to %d.\n", + lp->d_ntracks, usp[14]); +#endif + lp->d_ntracks = usp[14]; + } + if (lp->d_ncylinders != usp[15]) { +#ifdef verbose + printf("changing number of cylinders from %d to %d.\n", + lp->d_ncylinders, usp[15]); +#endif + lp->d_ncylinders = usp[15]; + } + lp->d_secpercyl = lp->d_nsectors * lp->d_ntracks; + } + + return (0); +} + +mfm_rxstrategy(msc, func, dblk, size, buf, rsize) + struct mfm_softc *msc; + int func; + daddr_t dblk; + char *buf; + int size, *rsize; +{ + struct disklabel *lp; + int block, sect, head, cyl, scount, i, cmd, res, sval; + + lp = &mfmlabel; + block = (dblk < 0 ? 0 : dblk + lp->d_partitions[msc->part].p_offset); + + mfm_rxselect(msc->unit); + + /* + * if label is empty, assume RX33 + */ + if (lp->d_nsectors == 0) + lp->d_nsectors = 15; + if (lp->d_ntracks == 0) + lp->d_ntracks = 2; + if (lp->d_secpercyl == 0) + lp->d_secpercyl = 30; + + bzero((void *) 0x200D0000, size); + scount = size / 512; + + while (scount) { + /* + * prepare drive/operation parameter + */ + cyl = block / lp->d_secpercyl; + sect = block % lp->d_secpercyl; + head = sect / lp->d_nsectors; + sect = sect % lp->d_nsectors; + + /* + * *rsize = 512; /* one sector after the other + * ... + */ + *rsize = 512 * min(scount, lp->d_nsectors - sect); + + /* + * now initialize the register values ... + */ + creg.udc_dma7 = 0; + creg.udc_dma15 = 0; + creg.udc_dma23 = 0; + + creg.udc_dsect = sect + 1; /* sectors are numbered 1..15 + * !!! */ + head |= (cyl >> 4) & 0x70; + creg.udc_dhead = head; + creg.udc_dcyl = cyl; + + creg.udc_scnt = *rsize / 512; + + if (func == F_WRITE) { + creg.udc_rtcnt = UDC_RC_RX33WRT; + creg.udc_mode = UDC_MD_RX33; + creg.udc_term = UDC_TC_FDD; + + mfm_rxprepare(); + /* copy from buf */ + bcopy(buf, (void *) 0x200D0000, *rsize); + res = mfm_command(DKC_CMD_WRITE_RX33); + } else { + creg.udc_rtcnt = UDC_RC_RX33READ; + creg.udc_mode = UDC_MD_RX33; + creg.udc_term = UDC_TC_FDD; + + mfm_rxprepare(); + /* clear disk buffer */ + bzero((void *) 0x200D0000, *rsize); + res = mfm_command(DKC_CMD_READ_RX33); + /* copy to buf */ + bcopy((void *) 0x200D0000, buf, *rsize); + } + + scount -= *rsize / 512; + block += *rsize / 512; + buf += *rsize; + } + + *rsize = size; + return 0; +} + +mfm_rdstrategy(msc, func, dblk, size, buf, rsize) + struct mfm_softc *msc; + int func; + daddr_t dblk; + char *buf; + int size, *rsize; +{ + struct disklabel *lp; + int block, sect, head, cyl, scount, i, cmd, res, sval; + + lp = &mfmlabel; + block = (dblk < 0 ? 0 : dblk + lp->d_partitions[msc->part].p_offset); + + /* + * if label is empty, assume RD32 (XXX this must go away!!!) + */ + if (lp->d_nsectors == 0) + lp->d_nsectors = 17; + if (lp->d_ntracks == 0) + lp->d_ntracks = 6; + if (lp->d_secpercyl == 0) + lp->d_secpercyl = 102; + + mfm_rdselect(msc->unit); + + bzero((void *) 0x200D0000, size); + scount = size / 512; + + while (scount) { + /* + * prepare drive/operation parameter + */ + cyl = block / lp->d_secpercyl; + sect = block % lp->d_secpercyl; + head = sect / lp->d_nsectors; + sect = sect % lp->d_nsectors; + + if (dblk < 0) { +#ifdef verbose + printf("using raw diskblock-data!\n"); + printf("block %d, dblk %d ==> cyl %d, head %d, sect %d\n", + block, dblk, cyl, sect, head); +#endif + } else + cyl += 1; /* first cylinder is reserved for + * controller! */ + + *rsize = 512 * min(scount, lp->d_nsectors - sect); + /* + * now re-initialize the register values ... + */ + creg.udc_dma7 = 0; + creg.udc_dma15 = 0; + creg.udc_dma23 = 0; + + creg.udc_dsect = sect; + head |= (cyl >> 4) & 0x70; + creg.udc_dhead = head; + creg.udc_dcyl = cyl; + + creg.udc_scnt = *rsize / 512; + + if (func == F_WRITE) { + creg.udc_rtcnt = UDC_RC_HDD_WRT; + creg.udc_mode = UDC_MD_HDD; + creg.udc_term = UDC_TC_HDD; + cmd = DKC_CMD_WRITE_HDD; + + bcopy(buf, (void *) 0x200D0000, *rsize); + res = mfm_command(cmd); + } else { + creg.udc_rtcnt = UDC_RC_HDD_READ; + creg.udc_mode = UDC_MD_HDD; + creg.udc_term = UDC_TC_HDD; + cmd = DKC_CMD_READ_HDD; + + bzero((void *) 0x200D0000, *rsize); + res = mfm_command(cmd); + bcopy((void *) 0x200D0000, buf, *rsize); + } + + scount -= *rsize / 512; + block += *rsize / 512; + buf += *rsize; + } + + /* + * unselect the drive ... + */ + mfm_command(DKC_CMD_DRDESELECT); + + *rsize = size; + return 0; +} + +int +mfmstrategy(msc, func, dblk, size, buf, rsize) + struct mfm_softc *msc; + int func; + daddr_t dblk; + char *buf; + int size, *rsize; +{ + int res = -1; + + switch (msc->unit) { + case 0: + case 1: + res = mfm_rdstrategy(msc, func, dblk, size, buf, rsize); + break; + case 2: + res = mfm_rxstrategy(msc, func, dblk, size, buf, rsize); + break; + default: + printf("invalid unit %d in mfmstrategy()\n"); + } + return (res); +} diff --git a/sys/arch/vax/stand/boot/netio.c b/sys/arch/vax/stand/boot/netio.c new file mode 100644 index 00000000000..bbc01d23acc --- /dev/null +++ b/sys/arch/vax/stand/boot/netio.c @@ -0,0 +1,278 @@ +/* $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 Gordon W. Ross + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * 4. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Gordon W. Ross + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This module implements a "raw device" interface suitable for + * use by the stand-alone I/O library NFS code. This interface + * does not support any "block" access, and exists only for the + * purpose of initializing the network interface, getting boot + * parameters, and performing the NFS mount. + * + * At open time, this does: + * + * find interface - netif_open() + * RARP for IP address - rarp_getipaddress() + * RPC/bootparams - callrpc(d, RPC_BOOTPARAMS, ...) + * RPC/mountd - nfs_mount(sock, ip, path) + * + * the root file handle from mountd is saved in a global + * for use by the NFS open code (NFS/lookup). + */ + +#include +#include +#include +#include +#include +#include + +#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() */ + +struct in_addr myip, rootip, gateip; +n_long netmask; +char rootpath[FNAME_SIZE]; + +int netdev_sock = -1; +static int open_count; + +int netio_ask = 0; /* default to bootparam, can override */ + +static char input_line[100]; + +/* + * Called by devopen after it sets f->f_dev to our devsw entry. + * This opens the low-level device and sets f->f_devdata. + */ +int +netopen(f, devname) + struct open_file *f; + char *devname; /* Device part of file name (or NULL). */ +{ + int error = 0; + + /* On first open, do netif open, mount, etc. */ + if (open_count == 0) { + /* Find network interface. */ + if ((netdev_sock = netif_open(devname)) < 0) + return (error=ENXIO); + if ((error = netmountroot(f, devname)) != 0) + return (error); + } + open_count++; + f->f_devdata = nfs_root_node; + return (error); +} + +int +netclose(f) + struct open_file *f; +{ + netif_close(netdev_sock); + f->f_devdata = NULL; +} + +int +netstrategy(devdata, func, dblk, size, v_buf, rsize) + void *devdata; + int func; + daddr_t dblk; + size_t size; + void *v_buf; + size_t *rsize; +{ + + *rsize = size; + return EIO; +} + +int +netmountroot(f, devname) + struct open_file *f; + char *devname; /* Device part of file name (or NULL). */ +{ + int error; + struct iodesc *d; + + if (netio_ask) { + get_my_ip: + printf("My IP address? "); + bzero(input_line, sizeof(input_line)); + gets(input_line); + if ((myip.s_addr = inet_addr(input_line)) == + htonl(INADDR_NONE)) { + printf("invalid IP address: %s\n", input_line); + goto get_my_ip; + } + + get_my_netmask: + printf("My netmask? "); + bzero(input_line, sizeof(input_line)); + gets(input_line); + if ((netmask = inet_addr(input_line)) == + htonl(INADDR_NONE)) { + printf("invalid netmask: %s\n", input_line); + goto get_my_netmask; + } + + get_my_gateway: + printf("My gateway? "); + bzero(input_line, sizeof(input_line)); + gets(input_line); + if ((gateip.s_addr = inet_addr(input_line)) == + htonl(INADDR_NONE)) { + printf("invalid IP address: %s\n", input_line); + goto get_my_gateway; + } + + get_server_ip: + printf("Server IP address? "); + bzero(input_line, sizeof(input_line)); + gets(input_line); + if ((rootip.s_addr = inet_addr(input_line)) == + htonl(INADDR_NONE)) { + printf("invalid IP address: %s\n", input_line); + goto get_server_ip; + } + + get_server_path: + printf("Server path? "); + bzero(rootpath, sizeof(rootpath)); + gets(rootpath); + if (rootpath[0] == '\0' || rootpath[0] == '\n') + goto get_server_path; + + if ((d = socktodesc(netdev_sock)) == NULL) + return (EMFILE); + + d->myip = myip; + + goto do_nfs_mount; + } + + /* + * Get info for NFS boot: our IP address, our hostname, + * server IP address, and our root path on the server. + * There are two ways to do this: The old, Sun way, + * and the more modern, BOOTP way. (RFC951, RFC1048) + */ + +#ifdef SUPPORT_BOOTP + + /* Get boot info using BOOTP way. (RFC951, RFC1048) */ + printf("Trying BOOTP\n"); + bootp(netdev_sock); + + if (myip.s_addr) { + printf("Using IP address: %s\n", inet_ntoa(myip)); + + 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 + +#endif /* SUPPORT_BOOTP */ + { +#ifdef SUPPORT_BOOTPARAMS + /* Get boot info using RARP and Sun bootparams. */ + + printf("Trying BOOTPARAMS\n"); + /* Get our IP address. (rarp.c) */ + if (rarp_getipaddress(netdev_sock) == -1) + return (errno); + + printf("boot: client IP address: %s\n", inet_ntoa(myip)); + + /* Get our hostname, server IP address. */ + if (bp_whoami(netdev_sock)) + return (errno); + + 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: + /* Get the NFS file handle (mount). */ + error = nfs_mount(netdev_sock, rootip, rootpath); + + return (error); +} diff --git a/sys/arch/vax/stand/boot/ra.c b/sys/arch/vax/stand/boot/ra.c new file mode 100644 index 00000000000..96be3fcfc00 --- /dev/null +++ b/sys/arch/vax/stand/boot/ra.c @@ -0,0 +1,256 @@ +/* $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. + * + * 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 */ + +#define NRSP 1 /* Kludge */ +#define NCMD 1 /* Kludge */ + +#include "sys/param.h" +#include "sys/disklabel.h" + +#include "lib/libsa/stand.h" + +#include "../include/pte.h" +#include "../include/sid.h" + +#include "arch/vax/mscp/mscp.h" +#include "arch/vax/mscp/mscpreg.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 + * a time, no separate routines for uba driver etc.. + * This code is foolish and should need a cleanup. + * But it works :) + */ + +struct ra_softc { + int udaddr; + int ubaddr; + int part; + int unit; + unsigned short *ra_ip; + unsigned short *ra_sa; + unsigned short *ra_sw; +}; + +volatile struct uda { + struct mscp_1ca uda_ca; /* communications area */ + struct mscp uda_rsp; /* response packets */ + struct mscp uda_cmd; /* command packets */ +} uda; + +volatile struct uda *ubauda; +struct disklabel ralabel; +struct ra_softc ra_softc; +char io_buf[DEV_BSIZE]; + +raopen(f, adapt, ctlr, unit, part) + struct open_file *f; + int ctlr, unit, part; +{ + char *msg; + struct disklabel *lp = &ralabel; + volatile struct ra_softc *ra = &ra_softc; + volatile u_int *nisse; + unsigned short johan, johan2; + 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; + if (vax_cputype != VAX_8200) { + if (adapt > nuba) + return(EADAPT); + if (ctlr > nuda) + return(ECTLR); + nisse = ((u_int *)ubaaddr[adapt]) + 512; + nisse[494] = PG_V | (((u_int)&uda) >> 9); + nisse[495] = nisse[494] + 1; + 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; + ra->ra_sa = ra->ra_sw = (short *)udacsr + 1; + ra->udaddr = uioaddr[adapt] + udaaddr[ctlr]; + ra->ubaddr = (int)ubaaddr[adapt]; + *ra->ra_ip = 0; /* Start init */ + } else { + paddr_t kdaddr = (paddr_t)biaddr[adapt] + BI_NODE(ctlr); + volatile int *w; + volatile int i = 10000; + + 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; + w = (int *)(kdaddr + BIREG_VAXBICSR); + *w = *w | BICSR_NRST; + while (i--) /* Need delay??? */ + ; + 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; + uda.uda_ca.ca_cmddsc = (int)&ubauda->uda_cmd.mscp_cmdref; + + command(M_OP_SETCTLRC); + 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); + f->f_devdata = (void *)ra; + return(0); +} + +static +command(cmd) +{ + volatile int hej; + + uda.uda_cmd.mscp_opcode = cmd; + uda.uda_cmd.mscp_msglen = MSCP_MSGLEN; + 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) + struct ra_softc *ra; + int func; + daddr_t dblk; + char *buf; + u_int size, *rsize; +{ + volatile u_int *ptmapp; + struct disklabel *lp; + u_int i, j, pfnum, mapnr, nsize; + volatile int hej; + + if (vax_cputype != VAX_8200) { + ptmapp = ((u_int *)ra->ubaddr) + 512; + + pfnum = (u_int)buf >> VAX_PGSHIFT; + + 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 + uda.uda_cmd.mscp_seq.seq_buffer = ((u_int)buf); + + lp = &ralabel; + uda.uda_cmd.mscp_seq.seq_lbn = + 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 + command(M_OP_READ); + + *rsize = size; + return 0; +} diff --git a/sys/arch/vax/stand/boot/rom.c b/sys/arch/vax/stand/boot/rom.c new file mode 100644 index 00000000000..8e36badc906 --- /dev/null +++ b/sys/arch/vax/stand/boot/rom.c @@ -0,0 +1,124 @@ +/* $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. + * 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. + */ + +#include "sys/param.h" +#include "sys/reboot.h" +#include "sys/disklabel.h" + +#include "lib/libsa/stand.h" +#include "lib/libsa/ufs.h" + +#include "../include/pte.h" +#include "../include/sid.h" +#include "../include/mtpr.h" +#include "../include/reg.h" +#include "../include/rpb.h" + +#include "data.h" +#include "vaxstand.h" + +extern unsigned *bootregs; +extern struct rpb *rpb; + +struct rom_softc { + int part; + int unit; +}; + +int romstrategy(), romopen(); +struct disklabel romlabel; +struct rom_softc rom_softc; +char io_buf[DEV_BSIZE]; + +romopen(f, adapt, ctlr, unit, part) + struct open_file *f; + int ctlr, unit, part; +{ + char *msg; + struct disklabel *lp = &romlabel; + volatile struct rom_softc *rsc = &rom_softc; + int i,err; + + bootregs[11] = XXRPB; + rpb = (void*)XXRPB; + bqo = (void*)rpb->iovec; + + if (rpb->unit > 0 && (rpb->unit % 100) == 0) { + printf ("changing rpb->unit from %d ", rpb->unit); + rpb->unit /= 100; + printf ("to %d\n", rpb->unit); + } + + bzero(lp, sizeof(struct disklabel)); + rsc->unit = unit; + rsc->part = part; + + err = romstrategy(rsc, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); + if (err) { + printf("reading disklabel: %s\n",strerror(err)); + return 0; + } + msg = getdisklabel(io_buf+LABELOFFSET, lp); + if (msg) + printf("getdisklabel: %s\n",msg); + f->f_devdata = (void*)rsc; + return(0); +} + +romstrategy (rsc, func, dblk, size, buf, rsize) + struct rom_softc *rsc; + int func; + daddr_t dblk; + char *buf; + int size, *rsize; +{ + struct disklabel *lp; + int block; + + lp = &romlabel; + block = dblk + lp->d_partitions[rsc->part].p_offset; + if (rsc->unit >= 0 && rsc->unit < 10) + rpb->unit = rsc->unit; + + if (func == F_WRITE) + romwrite_uvax(block, size, buf, bootregs); + else + romread_uvax(block, size, buf, bootregs); + + *rsize = size; + return 0; +} + diff --git a/sys/arch/vax/stand/boot/tmscp.c b/sys/arch/vax/stand/boot/tmscp.c new file mode 100644 index 00000000000..5dbd5aef582 --- /dev/null +++ b/sys/arch/vax/stand/boot/tmscp.c @@ -0,0 +1,204 @@ +/* $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. + * + * 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 */ + +#define NRSP 0 /* Kludge */ +#define NCMD 0 /* Kludge */ + +#include "sys/param.h" +#include "sys/disklabel.h" + +#include "lib/libsa/stand.h" + +#include "../include/pte.h" +#include "arch/vax/mscp/mscp.h" +#include "arch/vax/mscp/mscpreg.h" + +#include "vaxstand.h" + +static command(int,int); + +/* + * These routines for TMSCP tape standalone boot is very simple, + * assuming a lots of thing like that we only working at one tape at + * a time, no separate routines for uba driver etc.. + * This code is directly copied from ra disk driver. + */ + +struct ra_softc { + int udaddr; + int ubaddr; + int unit; +}; + +static 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 { + 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; + int ctlr, unit, part; +{ + char *msg; + extern u_int tmsaddr; + volatile struct ra_softc *ra=&ra_softc; + 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)ubaaddr[adapt]; + ra->unit=unit; + udacsr=(void*)ra->udaddr; + 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); + + /* + * Init of this tmscp ctlr. + */ + udacsr->udaip=0; /* Start init */ + while((udacsr->udasa&MP_STEP1) == 0); + udacsr->udasa=0x8000; + while((udacsr->udasa&MP_STEP2) == 0); + johan=(((u_int)ubauda)&0xffff)+8; + udacsr->udasa=johan; + while((udacsr->udasa&MP_STEP3) == 0); + udacsr->udasa=3; + while((udacsr->udasa&MP_STEP4) == 0); + udacsr->udasa=0x0001; + + uda.uda_ca.ca_rspdsc=(int)&ubauda->uda_rsp.mscp_cmdref; + uda.uda_ca.ca_cmddsc=(int)&ubauda->uda_cmd.mscp_cmdref; + uda.uda_cmd.mscp_un.un_seq.seq_addr = (long *)&uda.uda_ca.ca_cmddsc; + uda.uda_rsp.mscp_un.un_seq.seq_addr = (long *)&uda.uda_ca.ca_rspdsc; + uda.uda_cmd.mscp_vcid = 1; + uda.uda_cmd.mscp_un.un_sccc.sccc_ctlrflags = 0; + + command(M_OP_SETCTLRC, 0); + uda.uda_cmd.mscp_unit=ra->unit; + command(M_OP_ONLINE, 0); + + if (part) { + uda.uda_cmd.mscp_un.un_seq.seq_buffer = part; + command(M_OP_POS, 0); + uda.uda_cmd.mscp_un.un_seq.seq_buffer = 0; + } + + f->f_devdata=(void *)ra; + return(0); +} + +static +command(cmd, arg) +{ + volatile int hej; + + uda.uda_cmd.mscp_opcode = cmd; + uda.uda_cmd.mscp_modifier = arg; + + uda.uda_cmd.mscp_msglen = MSCP_MSGLEN; + 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; + hej = udacsr->udaip; + while (uda.uda_ca.ca_rspdsc < 0) { + if (uda.uda_ca.ca_cmdint) + uda.uda_ca.ca_cmdint = 0; + } + +} + +tmscpstrategy(ra, func, dblk, size, buf, rsize) + struct ra_softc *ra; + int func; + daddr_t dblk; + char *buf; + u_int size, *rsize; +{ + u_int i,j,pfnum, mapnr, nsize, bn, cn, sn, tn; + volatile struct udadevice *udadev=(void*)ra->udaddr; + volatile u_int *ptmapp = (u_int *)ra->ubaddr + 512; + volatile int hej; + + pfnum=(u_int)buf>>VAX_PGSHIFT; + + for(mapnr=0, nsize=size;(nsize+VAX_NBPG)>0;nsize-=VAX_NBPG) + ptmapp[mapnr++]=PG_V|pfnum++; + + /* + * First position tape. Remember where we are. + */ + if (dblk < curblock) { + uda.uda_cmd.mscp_seq.seq_bytecount = curblock - dblk; + command(M_OP_POS, 12); /* 12 == step block backward */ + } else { + uda.uda_cmd.mscp_seq.seq_bytecount = dblk - curblock; + command(M_OP_POS, 4); /* 4 == step block forward */ + } + curblock = size/512 + dblk; + + /* + * Read in the number of blocks we need. + * Why doesn't read of multiple blocks work????? + */ + for (i = 0 ; i < size/512 ; i++) { + uda.uda_cmd.mscp_seq.seq_lbn = 1; + uda.uda_cmd.mscp_seq.seq_bytecount = 512; + uda.uda_cmd.mscp_seq.seq_buffer = + (((u_int)buf) & 0x1ff) + i * 512; + uda.uda_cmd.mscp_unit = ra->unit; + command(M_OP_READ, 0); + } + + *rsize=size; + return 0; +} diff --git a/sys/arch/vax/stand/bootxx.c b/sys/arch/vax/stand/bootxx.c deleted file mode 100644 index 5cdc2246964..00000000000 --- a/sys/arch/vax/stand/bootxx.c +++ /dev/null @@ -1,441 +0,0 @@ -/* $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 $ */ -/*- - * 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 "sys/disklabel.h" - -#include "lib/libsa/stand.h" -#include "lib/libsa/ufs.h" - -#include "../include/pte.h" -#include "../include/sid.h" -#include "../include/mtpr.h" -#include "../include/reg.h" -#include "../include/rpb.h" - -#include "../mba/mbareg.h" -#include "../mba/hpreg.h" - -#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 - -int romstrategy(), romopen(); -int command(int, int); - -/* - * 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; -unsigned opendev, boothowto, bootset, memsz; - -extern unsigned *bootregs; -extern struct rpb *rpb; - -/* - * The boot block are used by 11/750, 8200, MicroVAX II/III, VS2000, - * VS3100/??, VS4000 and VAX6000/???, and only when booting from disk. - */ -Xmain() -{ - int io; - char *scbb; - char *new; - char *hej = "/boot"; - - switch (vax_cputype) { - - case VAX_TYP_UV2: - case VAX_TYP_CVAX: - case VAX_TYP_RIGEL: - case VAX_TYP_NVAX: - case VAX_TYP_SOC: - /* - * now relocate rpb/bqo (which are used by ROM-routines) - */ - rpb = (void*)XXRPB; - bcopy ((void*)bootregs[11], rpb, 512); - rpb->rpb_base = rpb; - bqo = (void*)(512+(int)rpb); - bcopy ((void*)rpb->iovec, bqo, rpb->iovecsz); - rpb->iovec = (int)bqo; - bootregs[11] = (int)rpb; - bootdev = rpb->devtyp; - memsz = rpb->pfncnt << 9; - - break; - case VAX_8200: - case VAX_750: - bootdev = bootregs[10]; - memsz = 0; - - 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; -} - -getbootdev() -{ - int i, adaptor, controller, unit, partition, retval; - - adaptor = controller = unit = partition = 0; - - 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 */ - break; - - - case VAX_TYP_8SS: - case VAX_TYP_750: - controller = 0; /* XXX Actually massbuss can be on 3 ctlr's */ - unit = bootregs[3]; - break; - } - - switch (B_TYPE(bootdev)) { - case BDEV_HP: /* massbuss boot */ - adaptor = (bootregs[1] & 0x6000) >> 17; - break; - - case BDEV_UDA: /* UDA50 boot */ - if (vax_cputype == VAX_750) - adaptor = (bootregs[1] & 0x40000 ? 0 : 1); - break; - - 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; - - 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), -}; - -int ndevs = (sizeof(devsw) / sizeof(devsw[0])); - -struct fs_ops file_system[] = { - {ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat} -}; - -int nfsys = (sizeof(file_system) / sizeof(struct fs_ops)); - -struct disklabel lp; -int part_off = 0; /* offset into partition holding /boot */ -volatile struct uda { - struct mscp_1ca uda_ca; /* communications area */ - struct mscp uda_rsp; /* response packets */ - struct mscp uda_cmd; /* command packets */ -} uda; -volatile struct udadevice *csr; - -devopen(f, fname, file) - struct open_file *f; - const char *fname; - char **file; -{ - char *msg; - int i, err, off; - char line[64]; - - f->f_dev = &devsw[0]; - *file = (char *)fname; - - /* - * On uVAX we need to init [T]MSCP ctlr to be able to use it. - */ - if (vax_cputype == VAX_TYP_UV2 || vax_cputype == VAX_TYP_CVAX) { - switch (bootdev) { - case BDEV_UDA: /* MSCP */ - case BDEV_TK: /* TMSCP */ - csr = (struct udadevice *)rpb->csrphy; - - csr->udaip = 0; /* Start init */ - while((csr->udasa & MP_STEP1) == 0); - csr->udasa = 0x8000; - while((csr->udasa & MP_STEP2) == 0); - csr->udasa = (short)(((u_int)&uda)&0xffff) + 8; - while((csr->udasa & MP_STEP3) == 0); - csr->udasa = 0x10; - while((csr->udasa & MP_STEP4) == 0); - csr->udasa = 0x0001; - - uda.uda_ca.ca_rspdsc = - (int) &uda.uda_rsp.mscp_cmdref; - uda.uda_ca.ca_cmddsc = - (int) &uda.uda_cmd.mscp_cmdref; - if (bootdev == BDEV_TK) - uda.uda_cmd.mscp_vcid = 1; - command(M_OP_SETCTLRC, 0); - uda.uda_cmd.mscp_unit = rpb->unit; - command(M_OP_ONLINE, 0); - } - } - - /* - * the disklabel _shall_ be at address LABELOFFSET + RELOC in - * phys memory now, no need at all to reread it again. - * 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); - } - return 0; -} - -command(cmd, arg) -{ - volatile int hej; - - uda.uda_cmd.mscp_opcode = cmd; - uda.uda_cmd.mscp_modifier = arg; - - uda.uda_cmd.mscp_msglen = MSCP_MSGLEN; - 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; - hej = csr->udaip; - while (uda.uda_ca.ca_rspdsc < 0); - -} - -int curblock = 0; - -romstrategy(sc, func, dblk, size, buf, rsize) - void *sc; - int func; - daddr_t dblk; - char *buf; - int size, *rsize; -{ - int i; - int block = dblk; - int nsize = size; - - switch (vax_cputype) { - /* - * case VAX_TYP_UV2: - * case VAX_TYP_CVAX: - * case VAX_TYP_RIGEL: - */ - default: - switch (bootdev) { - - case BDEV_UDA: /* MSCP */ - uda.uda_cmd.mscp_seq.seq_lbn = dblk; - uda.uda_cmd.mscp_seq.seq_bytecount = size; - uda.uda_cmd.mscp_seq.seq_buffer = (int)buf; - uda.uda_cmd.mscp_unit = rpb->unit; - command(M_OP_READ, 0); - break; - - case BDEV_TK: /* TMSCP */ - if (dblk < curblock) { - uda.uda_cmd.mscp_seq.seq_bytecount = - curblock - dblk; - command(M_OP_POS, 12); - } else { - uda.uda_cmd.mscp_seq.seq_bytecount = - dblk - curblock; - command(M_OP_POS, 4); - } - curblock = size/512 + dblk; - for (i = 0 ; i < size/512 ; i++) { - uda.uda_cmd.mscp_seq.seq_lbn = 1; - uda.uda_cmd.mscp_seq.seq_bytecount = 512; - uda.uda_cmd.mscp_seq.seq_buffer = - (int)buf + i * 512; - uda.uda_cmd.mscp_unit = rpb->unit; - command(M_OP_READ, 0); - } - break; - case BDEV_RD: - case BDEV_ST: - case BDEV_SD: - - default: - romread_uvax(block, size, buf, bootregs); - break; - - } - break; - - case VAX_8200: - case VAX_750: - if (bootdev != BDEV_HP) { - while (size > 0) { - while ((read750(block, bootregs) & 0x01) == 0) - printf("Retrying read bn# %d\n", block); - bcopy(0, buf, 512); - size -= 512; - buf += 512; - block++; - } - } else - hpread(block, size, buf); - break; - } - - *rsize = nsize; - return 0; -} - -hpread(block, size, buf) - char *buf; -{ - volatile struct mba_regs *mr = (void *) bootregs[1]; - volatile struct hp_drv *hd = (void*)&mr->mba_md[bootregs[3]]; - struct disklabel *dp = &lp; - u_int pfnum, nsize, mapnr, bn, cn, sn, tn; - - pfnum = (u_int) buf >> PGSHIFT; - - for (mapnr = 0, nsize = size; (nsize + NBPG) > 0; nsize -= NBPG) - *(int *)&mr->mba_map[mapnr++] = PG_V | pfnum++; - mr->mba_var = ((u_int) buf & PGOFSET); - mr->mba_bc = (~size) + 1; - bn = block; - cn = bn / dp->d_secpercyl; - sn = bn % dp->d_secpercyl; - tn = sn / dp->d_nsectors; - sn = sn % dp->d_nsectors; - hd->hp_dc = cn; - hd->hp_da = (tn << 8) | sn; - hd->hp_cs1 = HPCS_READ; - while (mr->mba_sr & MBASR_DTBUSY); - if (mr->mba_sr & MBACR_ABORT){ - return 1; - } - return 0; -} diff --git a/sys/arch/vax/stand/common/romread.s b/sys/arch/vax/stand/common/romread.s new file mode 100644 index 00000000000..749a70bae2d --- /dev/null +++ b/sys/arch/vax/stand/common/romread.s @@ -0,0 +1,94 @@ +/* $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. + * 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. + */ + + /* All bugs are subject to removal without further notice */ + + + +#include "../include/asm.h" + +/* + * read750 (int block, int *regs) + */ +ENTRY(read750, 0xFFE) + movl 8(ap), r8 + movl 4(r8), r1 + movl 8(r8), r2 + movl 12(r8), r3 + movl 24(r8), r6 + clrl r5 + movl 4(ap), r8 + pushl $0 + movl $0, 4(sp) + movl fp, 0xf0000 # ragge ??? + jsb (r6) + movl 0xf0000, fp + ret + +/* + * romread_uvax (int lbn, int size, void *buf, int *regs) + */ +ENTRY(romread_uvax, 0xFFE) + movl 16(ap), r11 # array of bootregs + movl 44(r11), r11 # restore boot-contents of r11 (rpb) + movl 52(r11), r7 # load iovec/bqo into r7 + addl3 (r7), r7, r6 # load qio into r6 + pushl r11 # base of rpb + pushl $0 # virtual-flag + pushl $33 # read-logical-block + pushl 4(ap) # lbn to start reading + pushl 8(ap) # number of bytes to read + pushl 12(ap) # buffer-address + calls $6, (r6) # call the qio-routine + ret # r0 holds the result + +/* + * romwrite_uvax (int lbn, int size, void *buf, int *regs) + */ +ENTRY(romwrite_uvax, 0xFFE) + movl 16(ap), r11 # array of bootregs + movl 44(r11), r11 # restore boot-contents of r11 (rpb) + movl 52(r11), r7 # load iovec/bqo into r7 + addl3 (r7), r7, r6 # load qio into r6 + pushl r11 # base of rpb + pushl $0 # virtual-flag + pushl $32 # write-logical-block + pushl 4(ap) # lbn to start reading + pushl 8(ap) # number of bytes to read + pushl 12(ap) # buffer-address + calls $6, (r6) # call the qio-routine + ret # r0 holds the result + diff --git a/sys/arch/vax/stand/common/srt0.s b/sys/arch/vax/stand/common/srt0.s new file mode 100644 index 00000000000..350c47394a5 --- /dev/null +++ b/sys/arch/vax/stand/common/srt0.s @@ -0,0 +1,89 @@ +/* $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. + * + * 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 "../include/asm.h" +/* + * Auto-moving startup code for standalone programs. Can be loaded + * (almost) anywhere in memory but moves itself to the position + * it is linked for. Must be started at first position, recommended + * is phys addr 0 (boot loads programs at 0, but starts them at the + * position set in a.out header. + */ + +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 + + movl r8, _memsz # If we come from disk, save memsize + cmpl ap, $-1 # Check if we are net-booted. XXX - kludge + beql 2f # jump if not + ashl $9,76(r11),_memsz # got memsize from rpb + movzbl 102(r11), r10 # Get bootdev from rpb. + movzwl 48(r11), r11 # Get howto + +2: movl $_start, sp # Probably safe place for stack + subl2 $52, sp # do not overwrite saved boot-registers + + subl3 $_start, $_edata, r0 + movab _start, r1 + movl $_start, 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, _Xmain # Were here! + halt # no return + +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/common/str.s b/sys/arch/vax/stand/common/str.s new file mode 100644 index 00000000000..b2f93510ec7 --- /dev/null +++ b/sys/arch/vax/stand/common/str.s @@ -0,0 +1,147 @@ +/* $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. + * + * 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. + */ + +/* + * Small versions of the most common functions not using any + * emulated instructions. + */ + +#include "asm.h" + +/* + * atoi() used in devopen. + */ +ENTRY(atoi, 0); + movl 4(ap),r1 + clrl r0 + +2: movzbl (r1)+,r2 + cmpb r2,$48 + blss 1f + cmpb r2,$57 + bgtr 1f + subl2 $48,r2 + mull2 $10,r0 + addl2 r2,r0 + brb 2b +1: ret + +/* + * index() small and easy. + * doesnt work if we search for null. + */ +ENTRY(index, 0); + movq 4(ap),r0 +1: cmpb (r0), r1 + beql 2f + tstb (r0)+ + bneq 1b + clrl r0 +2: ret + +/* + * cmpc3 is emulated on MVII. + */ +ENTRY(bcmp, 0); + movl 4(ap), r2 + movl 8(ap), r1 + movl 12(ap), r0 +2: cmpb (r2)+, (r1)+ + bneq 1f + decl r0 + bneq 2b +1: ret + +/* + * Is movc3/movc5 emulated on any CPU? I dont think so; use them here. + */ +ENTRY(bzero,0); + movc5 $0,*4(ap),$0,8(ap),*4(ap) + ret + +ENTRY(bcopy,0); + movc3 12(ap), *4(ap), *8(ap) + ret + +ENTRY(strlen, 0); + movl 4(ap), r0 +1: tstb (r0)+ + bneq 1b + decl r0 + subl2 4(ap), r0 + ret + +ENTRY(strncmp, 0) + movl 12(ap), r3 + brb 5f + +ENTRY(strcmp, 0) + movl $250, r3 # max string len to compare +5: movl 4(ap), r2 + movl 8(ap), r1 + movl $1, r0 + +2: cmpb (r2),(r1)+ + bneq 1f # something differ + tstb (r2)+ + beql 4f # continue, strings unequal + decl r3 # max string len encountered? + bneq 2b + +4: clrl r0 # We are done, strings equal. + ret + +1: bgtr 3f + mnegl r0, r0 +3: ret + +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/common/vaxstand.h b/sys/arch/vax/stand/common/vaxstand.h new file mode 100644 index 00000000000..86cdb8bffdc --- /dev/null +++ b/sys/arch/vax/stand/common/vaxstand.h @@ -0,0 +1,59 @@ +/* $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. + * + * 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 */ + + +#define MAXNMBA 8 /* Massbussadapters */ +#define MAXNUBA 8 /* Unibusadapters */ +#define MAXMBAU 8 /* Units on an mba */ + +/* Variables used in autoconf */ +extern int nmba, nuba, nbi, nsbi, nuda; +extern int *ubaaddr, *mbaaddr, *udaaddr, *uioaddr, *biaddr; +extern int cpunumber, howto; +extern dev_t bootdev; + +/* devsw type definitions, used in bootxx and conf */ +#define SADEV(name,strategy,open,close,ioctl) \ + { (char *)name, \ + (int(*)(void *, int ,daddr_t , size_t, void *, size_t *))strategy, \ + (int(*)(struct open_file *, ...))open, \ + (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/conf.c b/sys/arch/vax/stand/conf.c deleted file mode 100644 index 952d3060a70..00000000000 --- a/sys/arch/vax/stand/conf.c +++ /dev/null @@ -1,102 +0,0 @@ -/* $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 $ */ -/* - * 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 - -#include "lib/libsa/stand.h" -#include "lib/libsa/ufs.h" -#include "lib/libsa/nfs.h" - -#include "vaxstand.h" - -int raopen(), rastrategy(); -int hpopen(), hpstrategy(); -int ctuopen(), ctustrategy(); -int tmscpopen(), tmscpstrategy(); -int romopen(), romstrategy(); -int mfmopen(), mfmstrategy(); -int sdopen(), sdstrategy(); -int netopen(), netstrategy(), netclose(); - -struct devsw devsw[]={ - SADEV("hp",hpstrategy, hpopen, nullsys, noioctl), - SADEV("qe",netstrategy, netopen, netclose, noioctl), /* DEQNA */ - SADEV("ctu",ctustrategy, ctuopen, nullsys, noioctl), - SADEV("ra",rastrategy, raopen, nullsys, noioctl), - 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("le",netstrategy, netopen, netclose, noioctl), /* LANCE */ -}; - -int cnvtab[] = { - BDEV_HP, - BDEV_QE, - BDEV_CNSL, - BDEV_UDA, - BDEV_TK, - -1, - BDEV_RD, - BDEV_SD, - BDEV_ST, - BDEV_LE, -}; - -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[] = { - { nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat }, -}; - -int nfsys = (sizeof(file_system) / sizeof(struct fs_ops)); - -extern struct netif_driver qe_driver; -extern struct netif_driver le_driver; - -struct netif_driver *netif_drivers[] = { -/* &qe_driver, */ - &le_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/stand/consio.c deleted file mode 100644 index c9791416bfa..00000000000 --- a/sys/arch/vax/stand/consio.c +++ /dev/null @@ -1,218 +0,0 @@ -/* $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 $ */ -/* - * 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 "../vax/gencons.h" - -#include "../include/mtpr.h" -#include "../include/sid.h" -#include "../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; - -int pr_putchar __P((int c)); /* putchar() using mtpr/mfpr */ -int pr_getchar __P((void)); - -int rom_putchar __P((int c)); /* putchar() using ROM routines */ -int rom_getchar __P((void)); - -static int rom_putc; /* ROM-address of put-routine */ -static int rom_getc; /* ROM-address of get-routine */ - -putchar(c) - int c; -{ - (*put_fp)(c); - if (c == 10) - (*put_fp)(13); /* CR/LF */ -} - -getchar() -{ - int c; - - do - c = (*get_fp)() & 0177; - while (c == 17 || c == 19); /* ignore XON/XOFF */ - return c; -} - - -/* - * 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() -{ - 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; - } - - /* - * According to the vax_boardtype (vax_cputype is not specific - * enough to do that) we decide which method/routines to use - * for console I/O. - * mtpr/mfpr are restricted to serial consoles, ROM-based routines - * support both serial and graphical consoles. - * We default to mtpr routines; so that we don't crash if - * it isn't a supported system. - */ - 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; - 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; - rom_putc = 0x20040058; /* 537133144 */ - rom_getc = 0x20040044; /* 537133124 */ - break; -#ifdef notdef - case VAX_BTYP_630: - case VAX_BTYP_650: - case VAX_BTYP_9CC: - case VAX_BTYP_60: - put_fp = pr_putchar; - get_fp = pr_getchar; - break -#endif - } - return; -} - -/* - * putchar() using MTPR - */ -pr_putchar(c) - int c; -{ - int timeout = 1<<15; /* don't hang the machine! */ - while ((mfpr(PR_TXCS) & GC_RDY) == 0) /* Wait until xmit ready */ - if (--timeout < 0) - break; - mtpr(c, PR_TXDB); /* xmit character */ -} - -/* - * getchar() using MFPR - */ -pr_getchar() -{ - while ((mfpr(PR_RXCS) & GC_DON) == 0); /* wait for char */ - return (mfpr(PR_RXDB)); /* now get it */ -} - -/* - * int rom_putchar (int c) ==> putchar() using ROM-routines - */ -asm(" - .globl _rom_putchar - _rom_putchar: - .word 0x04 # save-mask: R2 - movl 4(ap), r2 # move argument to R2 - jsb *_rom_putc # write it - ret # that's all -"); - - -/* - * int rom_getchar (void) ==> getchar() using ROM-routines - */ -asm(" - .globl _rom_getchar - _rom_getchar: - .word 0x02 # save-mask: R1 - loop: # do { - jsb *_rom_getc # call the getc-routine - tstl r0 # check if char ready - beql loop # } while (R0 == 0) - movl r1, r0 # R1 holds char - ret # we're done -"); - -_rtt() -{ - printf("rtt\n"); -bo: goto bo; -} 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 - -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; idv_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; idv_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/ctu.c b/sys/arch/vax/stand/ctu.c deleted file mode 100644 index 8e5ec6160a7..00000000000 --- a/sys/arch/vax/stand/ctu.c +++ /dev/null @@ -1,182 +0,0 @@ -/* $OpenBSD: ctu.c,v 1.2 1997/05/29 00:04:20 niklas Exp $ */ -/* $NetBSD: ctu.c,v 1.1 1996/02/17 18:23:20 ragge Exp $ */ -/* - * Copyright (c) 1996 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. - */ - -/* - * Standalone device driver for 11/750 Console TU58. - * It can only handle reads, and doesn't calculate checksum. - */ - -#include - -#include - -#include -#include - -enum tu_state { - SC_INIT, - SC_READY, - SC_SEND_CMD, - SC_GET_RESP, -}; - -volatile struct tu_softc { - enum tu_state sc_state; - char sc_rsp[15]; /* Should be struct rsb; but don't work */ - u_char *sc_xfptr; /* Current char to xfer */ - int sc_nbytes; /* Number of bytes to xfer */ - int sc_xbytes; /* Number of xfer'd bytes */ - int sc_bbytes; /* Number of xfer'd bytes this block */ -} tu_sc; - -void ctutintr __P(()); -void cturintr __P(()); - -int -ctuopen(f, adapt, ctlr, unit, part) - struct open_file *f; - int ctlr, unit, part; -{ - - tu_sc.sc_state = SC_INIT; - - mtpr(RSP_TYP_INIT, PR_CSTD); - cturintr(); - tu_sc.sc_state = SC_READY; - return 0; - -} - -int -ctustrategy(ra, func, dblk, size, buf, rsize) - struct ra_softc *ra; - int func; - daddr_t dblk; - char *buf; - u_int size, *rsize; -{ - int s; - - struct rsp *rsp = (struct rsp *)tu_sc.sc_rsp; - - tu_sc.sc_xfptr = buf; - tu_sc.sc_nbytes = size; - tu_sc.sc_xbytes = tu_sc.sc_bbytes = 0; - - rsp->rsp_typ = RSP_TYP_COMMAND; - rsp->rsp_sz = 012; - rsp->rsp_op = RSP_OP_READ; - rsp->rsp_mod = 0; - rsp->rsp_drv = 0; - rsp->rsp_sw = rsp->rsp_xx1 = rsp->rsp_xx2 = 0; - rsp->rsp_cnt = tu_sc.sc_nbytes; - rsp->rsp_blk = dblk; - rsp->rsp_sum = ctu_cksum(rsp, 6); - tu_sc.sc_state = SC_SEND_CMD; - while (tu_sc.sc_state != SC_GET_RESP) - ctutintr(); - while (tu_sc.sc_state != SC_READY) - cturintr(); - *rsize = size; - return 0; -} - -void -cturintr() -{ - int status; - - while ((mfpr(PR_CSRS) & 0x80) == 0) - ; - - status = mfpr(PR_CSRD); - - switch (tu_sc.sc_state) { - - case SC_INIT: - break; - - case SC_GET_RESP: - if (tu_sc.sc_xbytes == tu_sc.sc_nbytes) { - tu_sc.sc_bbytes++; - if (tu_sc.sc_bbytes == 146) - tu_sc.sc_state = SC_READY; - break; - } - tu_sc.sc_bbytes++; - if (tu_sc.sc_bbytes < 3) /* Data header */ - break; - if (tu_sc.sc_bbytes == 132) { /* Finished */ - tu_sc.sc_bbytes = 0; - break; - } - if (tu_sc.sc_bbytes == 131) /* First checksum */ - break; - tu_sc.sc_xfptr[tu_sc.sc_xbytes++] = status; - break; - - } - -} - -void -ctutintr() -{ - int c; - - while ((mfpr(PR_CSTS) & 0x80) == 0) - ; - - c = tu_sc.sc_rsp[tu_sc.sc_xbytes++] & 0xff; - mtpr(c, PR_CSTD); - if (tu_sc.sc_xbytes > 13) { - tu_sc.sc_state = SC_GET_RESP; - tu_sc.sc_xbytes = 0; - } -} - -ctu_cksum(buf, words) - unsigned short *buf; - int words; -{ - int i, cksum; - - for (i = cksum = 0; i < words; i++) - cksum += buf[i]; - -hej: if (cksum > 65535) { - cksum = (cksum & 65535) + (cksum >> 16); - goto hej; - } - return cksum; -} diff --git a/sys/arch/vax/stand/data.h b/sys/arch/vax/stand/data.h deleted file mode 100644 index e8d92478098..00000000000 --- a/sys/arch/vax/stand/data.h +++ /dev/null @@ -1,75 +0,0 @@ -/* $OpenBSD: data.h,v 1.2 1997/05/29 00:04:21 niklas Exp $ */ -/* $NetBSD: data.h,v 1.4 1995/09/16 15:58:57 ragge Exp $ */ -/* - * Copyright (c) 1995 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. - */ - - /* All bugs are subject to removal without further notice */ - - - -extern unsigned *bootregs; - -/* - * rpb->iovec gives pointer to this structure. - * - * bqo->unit_init() is used to initialize the controller, - * bqo->qio() is used to read from boot-device - */ - -struct bqo { - long qio; /* 4 QIO entry */ - long map; /* 4 Mapping entry */ - long select; /* 4 Selection entry */ - long drivrname; /* 4 Offset to driver name */ - short version; /* 2 Version number of VMB */ - short vercheck; /* 2 Check field */ - /* offset: 20 */ - long reselect; /* 4 Reselection entry */ - long move; /* 4 Move driver entry */ - long unit_init; /* 4 Unit initialization entry */ - long auxdrname; /* 4 Offset to auxiliary driver name */ - long umr_dis; /* 4 UNIBUS Map Registers to disable */ - /* offset: 40 */ - long ucode; /* 4 Absolute address of booting microcode */ - long unit_disc; /* 4 Unit disconnecting entry */ - long devname; /* 4 Offset to boot device name */ - long umr_tmpl; /* 4 UNIBUS map register template */ - /* offset: 60 */ - /* - * the rest is unknown / unneccessary ... - */ - long xxx[6]; /* 24 -- total: 84 bytes */ -}; - -extern struct bqo *bqo; diff --git a/sys/arch/vax/stand/devopen.c b/sys/arch/vax/stand/devopen.c deleted file mode 100644 index a34e7895207..00000000000 --- a/sys/arch/vax/stand/devopen.c +++ /dev/null @@ -1,145 +0,0 @@ -/* $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 $ */ -/* - * Copyright (c) 1997 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. - */ - -#include - -#include "lib/libsa/stand.h" -#include "samachdep.h" -#include "vaxstand.h" - -unsigned int opendev; - -int -devopen(f, fname, file) - struct open_file *f; - const char *fname; - char **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; - - dev = B_TYPE(bootdev); - ctlr = B_CONTROLLER(bootdev); - unit = B_UNIT(bootdev); - part = B_PARTITION(bootdev); - adapt = B_ADAPTOR(bootdev); - - for (i = 0, dp = 0; i < ndevs; i++) - if (cnvtab[i] == dev) - dp = devsw + i; - - x = 0; - if ((s = index(fname, '('))) { - *s++ = 0; - - for (i = 0, dp = devsw; i < ndevs; i++, dp++) - if (dp->dv_name && strcmp(dp->dv_name, fname) == 0) - break; - - if (i == ndevs) { - printf("No such device - Configured devices are:\n"); - for (dp = devsw, i = 0; i < ndevs; i++, dp++) - if (dp->dv_name) - printf(" %s", dp->dv_name); - printf("\n"); - return -1; - } - dev = cnvtab[i]; - if ((c = index(s, ')')) == 0) - goto usage; - - *c++ = 0; - - if (*s) do { - a[x++] = atoi(s); - while (*s >= '0' && *s <= '9') - s++; - - if (*s != ',' && *s != 0) - goto usage; - } while (*s++); - - if (x) - part = a[x - 1]; - if (x > 1) - unit = a[x - 2]; - if (x > 2) - ctlr = a[x - 3]; - if (x > 3) - adapt = a[0]; - *file = c; - } 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; - } - - } -#endif - - if (!dp->dv_open) - return(ENODEV); - f->f_dev = dp; - - 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); - - return i; - -usage: - printf("usage: dev(adapter,controller,unit,partition)file -asd\n"); - return -1; -} 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 - 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 \".\n\n"); - break; - case ('q'): - case ('Q'): - default: - break; - } - } while (*indata != 'q' && *indata != 'Q'); - goto igen; -} diff --git a/sys/arch/vax/stand/hp.c b/sys/arch/vax/stand/hp.c deleted file mode 100644 index 80d5d8ac56b..00000000000 --- a/sys/arch/vax/stand/hp.c +++ /dev/null @@ -1,166 +0,0 @@ -/* $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 $ */ -/* - * 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 "sys/disklabel.h" - -#include "lib/libsa/stand.h" - -#include "../include/pte.h" -#include "../include/macros.h" - -#include "../mba/mbareg.h" -#include "../mba/hpreg.h" - -#include "vaxstand.h" - -/* - * These routines for HP disk standalone boot is wery simple, - * assuming a lots of thing like that we only working at one hp disk - * a time, no separate routines for mba driver etc.. - * But it works :) - */ - -struct hp_softc { - int adapt; - int ctlr; - int unit; - int part; -}; - -struct disklabel hplabel; -struct hp_softc hp_softc; -char io_buf[DEV_BSIZE]; -daddr_t part_offset; - -hpopen(f, adapt, ctlr, unit, part) - struct open_file *f; - int ctlr, unit, part; -{ - struct disklabel *lp; - struct hp_softc *hs; - volatile struct mba_regs *mr; - volatile struct hp_drv *hd; - char *msg; - int i,err; - - lp = &hplabel; - hs = &hp_softc; - mr = (void *)mbaaddr[ctlr]; - hd = (void *)&mr->mba_md[unit]; - - if (adapt > nsbi) return(EADAPT); - if (ctlr > nmba) return(ECTLR); - if (unit > MAXMBAU) return(EUNIT); - - bzero(lp, sizeof(struct disklabel)); - - lp->d_secpercyl = 32; - lp->d_nsectors = 32; - hs->adapt = adapt; - hs->ctlr = ctlr; - hs->unit = unit; - hs->part = part; - - /* Set volume valid and 16 bit format; only done once */ - mr->mba_cr = MBACR_INIT; - hd->hp_cs1 = HPCS_PA; - hd->hp_of = HPOF_FMT; - - err = hpstrategy(hs, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); - if (err) { - printf("reading disklabel: %s\n", strerror(err)); - return 0; - } - - msg = getdisklabel(io_buf + LABELOFFSET, lp); - if (msg) - printf("getdisklabel: %s\n", msg); - - f->f_devdata = (void *)hs; - return 0; -} - -hpstrategy(hs, func, dblk, size, buf, rsize) - struct hp_softc *hs; - daddr_t dblk; - u_int size, *rsize; - char *buf; - int func; -{ - volatile struct mba_regs *mr; - volatile struct hp_drv *hd; - struct disklabel *lp; - unsigned int i, pfnum, mapnr, nsize, bn, cn, sn, tn; - - mr = (void *)mbaaddr[hs->ctlr]; - hd = (void *)&mr->mba_md[hs->unit]; - lp = &hplabel; - - pfnum = (u_int)buf >> PGSHIFT; - - for(mapnr = 0, nsize = size; (nsize + NBPG) > 0; nsize -= NBPG) - *(int *)&mr->mba_map[mapnr++] = PG_V | pfnum++; - - mr->mba_var = ((u_int)buf & PGOFSET); - mr->mba_bc = (~size) + 1; - bn = dblk + lp->d_partitions[hs->part].p_offset; - - if (bn) { - cn = bn / lp->d_secpercyl; - sn = bn % lp->d_secpercyl; - tn = sn / lp->d_nsectors; - sn = sn % lp->d_nsectors; - } else - cn = sn = tn = 0; - - hd->hp_dc = cn; - hd->hp_da = (tn << 8) | sn; - if (func == F_WRITE) - hd->hp_cs1 = HPCS_WRITE; - else - hd->hp_cs1 = HPCS_READ; - - while (mr->mba_sr & MBASR_DTBUSY) - ; - - if (mr->mba_sr & MBACR_ABORT) - return 1; - - *rsize = size; - - return 0; -} diff --git a/sys/arch/vax/stand/if_le.c b/sys/arch/vax/stand/if_le.c deleted file mode 100644 index 7a223edfa54..00000000000 --- a/sys/arch/vax/stand/if_le.c +++ /dev/null @@ -1,283 +0,0 @@ -/* $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 $ */ -/* - * Copyright (c) 1997 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. - */ - -/* - * Standalone routine for MicroVAX LANCE chip. - */ - -#include -#include - -#include -#include - -#include - -#include - -#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??? - */ -#define TLEN 1 -#define NTBUF (1 << TLEN) -#define RLEN 3 -#define NRBUF (1 << RLEN) -#define BUFSIZE 1518 - -#define QW_ALLOC(x) ((alloc((x) + 7) + 7) & ~7) - -int le_probe(), le_match(), le_get(), le_put(); -void le_init(); - -struct netif_stats le_stats; - -struct netif_dif le_ifs[] = { -/* dif_unit dif_nsel dif_stats dif_private */ -{ 0, 1, &le_stats, }, -}; - -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, -}; - -/* - * Init block & buffer descriptors according to DEC system - * specification documentation. - */ -struct initblock { - short ib_mode; - char ib_padr[6]; /* Ethernet address */ - int ib_ladrf1; - int ib_ladrf2; - int ib_rdr; /* Receive address */ - int ib_tdr; /* Transmit address */ -} *initblock = NULL; - -struct nireg { - volatile short ni_rdp; /* data port */ - volatile short ni_pad0; - volatile short ni_rap; /* register select port */ -} *nireg = (struct nireg *)0x200e0000; - - -volatile struct buffdesc { - int bd_adrflg; - short bd_bcnt; - short bd_mcnt; -} *rdesc, *tdesc; - -/* Flags in the address field */ -#define BR_OWN 0x80000000 -#define BR_ERR 0x40000000 -#define BR_FRAM 0x20000000 -#define BR_OFLO 0x10000000 -#define BR_CRC 0x08000000 -#define BR_BUFF 0x04000000 -#define BR_STP 0x02000000 -#define BR_ENP 0x01000000 - -#define BT_OWN 0x80000000 -#define BT_ERR 0x40000000 -#define BT_MORE 0x10000000 -#define BT_ONE 0x08000000 -#define BT_DEF 0x04000000 -#define BT_STP 0x02000000 -#define BT_ENP 0x01000000 - -int next_rdesc, next_tdesc; - -#define LEWRCSR(port, val) { \ - nireg->ni_rap = (port); \ - nireg->ni_rdp = (val); \ -} - -#define LERDCSR(port) \ - (nireg->ni_rap = port, nireg->ni_rdp) - -int -le_match(nif, machdep_hint) - struct netif *nif; - void *machdep_hint; -{ - return strcmp(machdep_hint, "le") == 0; -} - -le_probe(nif, machdep_hint) - struct netif *nif; - void *machdep_hint; -{ - return 0; -} - -void -le_init(desc, machdep_hint) - struct iodesc *desc; - void *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; - - 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; - - initblock = (void *)alloc(sizeof(struct initblock)); - 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); - initblock->ib_rdr = (RLEN << 29) | (int)rdesc; - (int)tdesc = QW_ALLOC(sizeof(struct buffdesc) * NTBUF); - initblock->ib_tdr = (TLEN << 29) | (int)tdesc; - - for (i = 0; i < NRBUF; i++) { - rdesc[i].bd_adrflg = alloc(BUFSIZE) | BR_OWN; - rdesc[i].bd_bcnt = -BUFSIZE; - rdesc[i].bd_mcnt = 0; - } - - for (i = 0; i < NTBUF; i++) { - tdesc[i].bd_adrflg = alloc(BUFSIZE); - tdesc[i].bd_bcnt = 0xf000; - tdesc[i].bd_mcnt = 0; - } - } - - LEWRCSR(LE_CSR1, (int)initblock & 0xffff); - LEWRCSR(LE_CSR2, ((int)initblock >> 16) & 0xff); - - LEWRCSR(LE_CSR0, LE_C0_INIT); - - to = 100000; - while (to--) - if (LERDCSR(LE_CSR0) & LE_C0_IDON) - break; - - LEWRCSR(LE_CSR0, LE_C0_INEA | LE_C0_STRT | LE_C0_IDON); -} - -int -le_get(desc, pkt, maxlen, timeout) - struct iodesc *desc; - void *pkt; - int maxlen; - time_t timeout; -{ - int csr, len; - volatile int to = 100000 * timeout; - -retry: - if (to-- == 0) - return 0; - - csr = LERDCSR(LE_CSR0); - LEWRCSR(LE_CSR0, csr & (LE_C0_BABL|LE_C0_MISS|LE_C0_MERR|LE_C0_RINT)); - - if (rdesc[next_rdesc].bd_adrflg & BR_OWN) - goto retry; - - if (rdesc[next_rdesc].bd_adrflg & BR_ERR) - len = 0; - else { - if ((len = rdesc[next_rdesc].bd_mcnt - 4) > maxlen) - len = maxlen; - - bcopy((void *)(rdesc[next_rdesc].bd_adrflg&0xffffff),pkt,len); - } - - rdesc[next_rdesc].bd_mcnt = 0; - rdesc[next_rdesc].bd_adrflg |= BR_OWN; - if (++next_rdesc >= NRBUF) - next_rdesc = 0; - - if (len == 0) - goto retry; - return len; -} - -int -le_put(desc, pkt, len) - struct iodesc *desc; - void *pkt; - int len; -{ - volatile int to = 100000; - int csr; - -retry: - if (--to == 0) - return -1; - - csr = LERDCSR(LE_CSR0); - LEWRCSR(LE_CSR0, csr & (LE_C0_MISS|LE_C0_CERR|LE_C0_TINT)); - - if (tdesc[next_tdesc].bd_adrflg & BT_OWN) - goto retry; - - bcopy(pkt, (void *)(tdesc[next_tdesc].bd_adrflg & 0xffffff), 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; - - LEWRCSR(LE_CSR0, LE_C0_TDMD); - - to = 100000; - while (((LERDCSR(LE_CSR0) & LE_C0_TINT) == 0) && --to) - ; - - LEWRCSR(LE_CSR0, LE_C0_TINT); - if (++next_tdesc >= NTBUF) - next_tdesc = 0; - - if (to) - return len; - - return -1; -} 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/mfm.c b/sys/arch/vax/stand/mfm.c deleted file mode 100644 index 20465089651..00000000000 --- a/sys/arch/vax/stand/mfm.c +++ /dev/null @@ -1,655 +0,0 @@ -/* $OpenBSD: mfm.c,v 1.4 1998/05/13 07:30:23 niklas Exp $ */ -/* $NetBSD: mfm.c,v 1.2 1997/03/15 13:04:28 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. - */ - -/* - * ToDo: - * - * - insert appropriate delays for diskette-drive where needed - * - allow more than one sector per diskette-read - * - check for and handle bad sectors - * - ??? - */ - -#include "sys/param.h" -#include "sys/reboot.h" -#include "sys/disklabel.h" - -#include "lib/libsa/stand.h" -#include "lib/libsa/ufs.h" - -#include "../include/pte.h" -#include "../include/sid.h" -#include "../include/mtpr.h" -#include "../include/reg.h" -#include "../include/rpb.h" - -#include "ka410.h" -#include "../vsa/hdc9224.h" - -#include "data.h" -#include "vaxstand.h" - -#define MAX_WAIT (1000*1000) /* # of loop-instructions in seconds */ - -struct mfm_softc { - int part; - int unit; -}; - -int mfmstrategy(), mfmopen(); -struct disklabel mfmlabel; -struct mfm_softc mfm_softc; -char io_buf[DEV_BSIZE]; - -/* - * These should probably be somewhere else, but ka410 is the only - * one with mfm disks anyway... - */ -volatile unsigned char *ka410_intreq = (void*)0x2008000f; -volatile unsigned char *ka410_intclr = (void*)0x2008000f; -volatile unsigned char *ka410_intmsk = (void*)0x2008000c; - -static volatile struct hdc9224_DKCreg *dkc = (void *) 0x200c0000; -static volatile struct hdc9224_UDCreg sreg; /* input */ -static volatile struct hdc9224_UDCreg creg; /* output */ - -/* - * we have to wait 0.7 usec between two accesses to any of the - * dkc-registers, on a VS2000 with 1 MIPS, this is roughly one - * instruction. Thus the loop-overhead will be enough... - */ -static int -sreg_read() -{ - int i; - char *p; - - dkc->dkc_cmd = 0x40; /* set internal counter to zero */ - p = (void *) &sreg; - for (i = 0; i < 10; i++) - *p++ = dkc->dkc_reg; /* dkc_reg auto-increments */ -} - -static int -creg_write() -{ - int i; - char *p; - - dkc->dkc_cmd = 0x40; /* set internal counter to zero */ - p = (void *) &creg; - for (i = 0; i < 10; i++) - dkc->dkc_reg = *p++; /* dkc_reg auto-increments */ -} - -/* - * floppies are handled in a quite strange way by this controller... - * - * before reading/writing a sector from/to floppy, we use the SEEK/READ_ID - * command to place the head at the desired location. Then we wait some - * time before issueing the real command in order to let the drive become - * ready... - */ -int -mfm_rxprepare() -{ - int error; - - error = mfm_command(DKC_CMD_SEEKREADID | 0x04); /* step=1, verify=0 */ - if (error) { - printf("error while stepping to position %d/%d/%x. Retry...\n", - creg.udc_dsect, creg.udc_dhead, creg.udc_dcyl); - error = mfm_command(DKC_CMD_SEEKREADID | 0x04); - } - return error; -} - -int -mfm_rxselect(unit) - int unit; -{ - int error; - - /* - * bring "creg" in some known-to-work state and - * select the drive with the DRIVE SELECT command. - */ - creg.udc_dma7 = 0; - creg.udc_dma15 = 0; - creg.udc_dma23 = 0; - creg.udc_dsect = 1; /* sectors are numbered 1..15 !!! */ - creg.udc_dhead = 0; - creg.udc_dcyl = 0; - creg.udc_scnt = 0; - - creg.udc_rtcnt = UDC_RC_RX33READ; - creg.udc_mode = UDC_MD_RX33; - creg.udc_term = UDC_TC_FDD; - - /* - * this is ... - */ - error = mfm_command(DKC_CMD_DRSEL_RX33 | unit); - - if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 0)) { - printf("\nfloppy-drive not ready (new floppy inserted?)\n\n"); - - creg.udc_rtcnt &= ~UDC_RC_INVRDY; /* clear INVRDY-flag */ - error = mfm_command(DKC_CMD_DRSEL_RX33 | unit); - if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 0)) { - printf("diskette not ready(1): %x/%x\n", - error, sreg.udc_dstat); - printf("floppy-drive offline?\n"); - return (-1); - } - if (sreg.udc_dstat & UDC_DS_TRK00) - error = mfm_command(DKC_CMD_STEPIN_FDD); - else - error = mfm_command(DKC_CMD_STEPOUT_FDD); - - /* - * now ready should be 0, cause INVRDY is not set - * (retrying a command makes this fail...) - */ - if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 1)) { - printf("diskette not ready(2): %x/%x\n", - error, sreg.udc_dstat); - } - creg.udc_rtcnt |= UDC_RC_INVRDY; - error = mfm_command(DKC_CMD_DRSEL_RX33 | unit); - - if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 0)) { - printf("diskette not ready(3): %x/%x\n", - error, sreg.udc_dstat); - printf("no floppy inserted or floppy-door open\n"); - return (-1); - } - printf("floppy-drive reselected.\n"); - } - return (error); -} - -int -mfm_rdselect(unit) - int unit; -{ - int error; - - /* - * bring "creg" in some known-to-work state and - * select the drive with the DRIVE SELECT command. - */ - creg.udc_dma7 = 0; - creg.udc_dma15 = 0; - creg.udc_dma23 = 0; - creg.udc_dsect = 0; /* sectors are numbered 0..16 */ - creg.udc_dhead = 0; - creg.udc_dcyl = 0; - creg.udc_scnt = 0; - - creg.udc_rtcnt = UDC_RC_HDD_READ; - creg.udc_mode = UDC_MD_HDD; - creg.udc_term = UDC_TC_HDD; - - error = mfm_command(DKC_CMD_DRSEL_HDD | unit); - - return (error); -} - -static int mfm_retry = 0; - -int -mfm_command(cmd) - int cmd; -{ - int termcode, ready, i; - - creg_write(); /* write command-registers */ - *ka410_intclr = INTR_DC; - dkc->dkc_cmd = cmd; /* issue command */ - for (i = 0; i < MAX_WAIT; i++) { - if (*ka410_intreq & INTR_DC) /* wait for interrupt */ - break; - } - if ((*ka410_intreq & INTR_DC) == 0) - printf("timeout in mfm_command...\n"); - - sreg_read(); /* read status-registers */ - - if (dkc->dkc_stat == (DKC_ST_DONE | DKC_TC_SUCCESS)) - return (0); - - if (sreg.udc_cstat & UDC_CS_ECCERR) { - printf( -"\nspurious(?) ECC/CRC error at s%d/t%d/c%d [s%d/t%d/c%d(%d)]\n", - sreg.udc_csect, sreg.udc_chead, sreg.udc_ccyl, - creg.udc_dsect, creg.udc_dhead, creg.udc_dcyl,creg.udc_scnt); - if (sreg.udc_csect != creg.udc_dsect + creg.udc_scnt - 1) { - printf("DMA: %x %x %x [%x]\n", - sreg.udc_dma23, sreg.udc_dma15, - sreg.udc_dma7, 512 * (sreg.udc_csect - - creg.udc_dsect)); - creg.udc_scnt = creg.udc_scnt - - (sreg.udc_csect - creg.udc_dsect) - 1; - creg.udc_dsect = sreg.udc_csect + 1; - creg.udc_dma23 = sreg.udc_dma23; - creg.udc_dma15 = sreg.udc_dma15 + 2; - creg.udc_dma7 = 0; - printf("Retry starting from s%d/t%d/c%d (%d). ", - creg.udc_dsect, creg.udc_dhead, creg.udc_dcyl, - creg.udc_scnt); - } - goto retry; - } - termcode = (dkc->dkc_stat & DKC_ST_TERMCOD) >> 3; - ready = sreg.udc_dstat & UDC_DS_READY; - - printf("cmd:0x%x: termcode=0x%x, status=0x%x, cstat=0x%x, dstat=0x%x\n", - cmd, termcode, dkc->dkc_stat, sreg.udc_cstat, sreg.udc_dstat); - - if (dkc->dkc_stat & DKC_ST_BADSECT) - printf("bad sector found: s%d/t%d/c%d\n", creg.udc_dsect, - creg.udc_dhead, creg.udc_dcyl); -retry: - if ((mfm_retry == 0) && (sreg.udc_cstat & UDC_CS_RETREQ)) { - mfm_retry = 1; - printf("Retrying... "); - mfm_command(cmd); - printf("Retry done.\n"); - mfm_retry = 0; - } - return ((dkc->dkc_stat & DKC_ST_TERMCOD) >> 3); -} - -/* - * on-disk geometry block - */ -#define _aP __attribute__ ((packed)) /* force byte-alignment */ - -volatile struct mfm_xbn { - char mbz[10];/* 10 bytes of zero */ - long xbn_count _aP; /* number of XBNs */ - long dbn_count _aP; /* number of DBNs */ - long lbn_count _aP; /* number of LBNs (Logical-Block-Numbers) */ - long rbn_count _aP; /* number of RBNs (Replacement-Block-Numbers) */ - short nspt; /* number of sectors per track */ - short ntracks;/* number of tracks */ - short ncylinders; /* number of cylinders */ - short precomp;/* first cylinder for write precompensation */ - short reduced;/* first cylinder for reduced write current */ - short seek_rate; /* seek rate or zero for buffered - * seeks */ - short crc_eec;/* 0 if CRC is being used or 1 if ECC is - * being used */ - short rct; /* "replacement control table" (RCT) */ - short rct_ncopies; /* number of copies of the RCT */ - long media_id _aP; /* media identifier */ - short interleave; /* sector-to-sector interleave */ - short headskew; /* head-to-head skew */ - short cylskew;/* cylinder-to-cylinder skew */ - short gap0_size; /* size of GAP 0 in the MFM format */ - short gap1_size; /* size of GAP 1 in the MFM format */ - short gap2_size; /* size of GAP 2 in the MFM format */ - short gap3_size; /* size of GAP 3 in the MFM format */ - short sync_value; /* sync value used to start a track - * when formatting */ - char reserved[32]; /* reserved for use by the RQDX1/2/3 - * formatter */ - short serial_number; /* serial number */ - char fill[412]; /* Filler bytes to the end of the - * block */ - short checksum; /* checksum over the XBN */ -} mfm_xbn; - -#ifdef verbose -display_xbn(p) - struct mfm_xbn *p; -{ - printf("**DiskData** XBNs: %d, DBNs: %d, LBNs: %d, RBNs: %d\n", - p->xbn_count, p->dbn_count, p->lbn_count, p->rbn_count); - printf("sect/track: %d, tracks: %d, cyl: %d, precomp/reduced: %d/%d\n", - p->nspt, p->ntracks, p->ncylinders, p->precomp, p->reduced); - printf("seek-rate: %d, crc/eec: %s, RCT: %d, RCT-copies: %d\n", - p->seek_rate, p->crc_eec ? "EEC" : "CRC", p->rct, p->rct_ncopies); - printf("media-ID: 0x%x, interleave: %d, headskew: %d, cylskew: %d\n", - &p->media_id, p->interleave, p->headskew, p->cylskew); - printf("gap0: %d, gap1: %d, gap2: %d, gap3: %d, sync-value: %d\n", - p->gap0_size, p->gap1_size, p->gap2_size, p->gap3_size, - p->sync_value); - printf("serial: %d, checksum: %d, size: %d, reserved: %32c\n", - p->serial_number, p->checksum, sizeof(*p), p->reserved); -} -#endif - -mfmopen(f, adapt, ctlr, unit, part) - struct open_file *f; - int ctlr, unit, part; -{ - char *msg; - struct disklabel *lp = &mfmlabel; - volatile struct mfm_softc *msc = &mfm_softc; - int i, err; - - bzero(lp, sizeof(struct disklabel)); - msc->unit = unit; - msc->part = part; - - err = mfmstrategy(msc, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); - if (err) { - printf("reading disklabel: %s\n", strerror(err)); - return 0; - } - msg = getdisklabel(io_buf + LABELOFFSET, lp); - if (msg) - printf("getdisklabel: %s\n", msg); - - f->f_devdata = (void *) msc; - - { - int k; - unsigned char *ucp; - struct mfm_xbn *xp; - - /* mfmstrategy(msc, F_READ, -16, 8192, io_buf, &i); */ - mfmstrategy(msc, F_READ, -16, DEV_BSIZE, io_buf, &i); -#ifdef verbose - printf("dumping raw disk-block #0:\n"); - ucp = io_buf; - for (k = 0; k < 128; k++) { - if (ucp[k] < 0x10) - printf("0"); - printf("%x ", ucp[k]); - if (k % 8 == 7) - printf(" "); - if (k % 16 == 15) - printf("\n"); - } - printf("\n"); - - xp = (void *) io_buf; - display_xbn(xp); - printf("\n"); -#endif - } - - if (unit == 2) { /* floppy! */ - if (lp->d_ntracks != 2) { -#ifdef verbose - printf("changing number of tracks from %d to %d.\n", - lp->d_ntracks, 2); -#endif - lp->d_ntracks = 2; - } - } else { /* hard-disk */ - unsigned short *usp = (void *) io_buf; -#ifdef verbose - printf("label says: s/t/c = %d/%d/%d\n", - lp->d_nsectors, lp->d_ntracks, lp->d_ncylinders); -#endif - if (lp->d_nsectors != usp[13]) { -#ifdef verbose - printf("changing number of sectors from %d to %d.\n", - lp->d_nsectors, usp[13]); -#endif - lp->d_nsectors = usp[13]; - } - if (lp->d_ntracks != usp[14]) { -#ifdef verbose - printf("changing number of heads/tracks from %d to %d.\n", - lp->d_ntracks, usp[14]); -#endif - lp->d_ntracks = usp[14]; - } - if (lp->d_ncylinders != usp[15]) { -#ifdef verbose - printf("changing number of cylinders from %d to %d.\n", - lp->d_ncylinders, usp[15]); -#endif - lp->d_ncylinders = usp[15]; - } - lp->d_secpercyl = lp->d_nsectors * lp->d_ntracks; - } - - return (0); -} - -mfm_rxstrategy(msc, func, dblk, size, buf, rsize) - struct mfm_softc *msc; - int func; - daddr_t dblk; - char *buf; - int size, *rsize; -{ - struct disklabel *lp; - int block, sect, head, cyl, scount, i, cmd, res, sval; - - lp = &mfmlabel; - block = (dblk < 0 ? 0 : dblk + lp->d_partitions[msc->part].p_offset); - - mfm_rxselect(msc->unit); - - /* - * if label is empty, assume RX33 - */ - if (lp->d_nsectors == 0) - lp->d_nsectors = 15; - if (lp->d_ntracks == 0) - lp->d_ntracks = 2; - if (lp->d_secpercyl == 0) - lp->d_secpercyl = 30; - - bzero((void *) 0x200D0000, size); - scount = size / 512; - - while (scount) { - /* - * prepare drive/operation parameter - */ - cyl = block / lp->d_secpercyl; - sect = block % lp->d_secpercyl; - head = sect / lp->d_nsectors; - sect = sect % lp->d_nsectors; - - /* - * *rsize = 512; /* one sector after the other - * ... - */ - *rsize = 512 * min(scount, lp->d_nsectors - sect); - - /* - * now initialize the register values ... - */ - creg.udc_dma7 = 0; - creg.udc_dma15 = 0; - creg.udc_dma23 = 0; - - creg.udc_dsect = sect + 1; /* sectors are numbered 1..15 - * !!! */ - head |= (cyl >> 4) & 0x70; - creg.udc_dhead = head; - creg.udc_dcyl = cyl; - - creg.udc_scnt = *rsize / 512; - - if (func == F_WRITE) { - creg.udc_rtcnt = UDC_RC_RX33WRT; - creg.udc_mode = UDC_MD_RX33; - creg.udc_term = UDC_TC_FDD; - - mfm_rxprepare(); - /* copy from buf */ - bcopy(buf, (void *) 0x200D0000, *rsize); - res = mfm_command(DKC_CMD_WRITE_RX33); - } else { - creg.udc_rtcnt = UDC_RC_RX33READ; - creg.udc_mode = UDC_MD_RX33; - creg.udc_term = UDC_TC_FDD; - - mfm_rxprepare(); - /* clear disk buffer */ - bzero((void *) 0x200D0000, *rsize); - res = mfm_command(DKC_CMD_READ_RX33); - /* copy to buf */ - bcopy((void *) 0x200D0000, buf, *rsize); - } - - scount -= *rsize / 512; - block += *rsize / 512; - buf += *rsize; - } - - *rsize = size; - return 0; -} - -mfm_rdstrategy(msc, func, dblk, size, buf, rsize) - struct mfm_softc *msc; - int func; - daddr_t dblk; - char *buf; - int size, *rsize; -{ - struct disklabel *lp; - int block, sect, head, cyl, scount, i, cmd, res, sval; - - lp = &mfmlabel; - block = (dblk < 0 ? 0 : dblk + lp->d_partitions[msc->part].p_offset); - - /* - * if label is empty, assume RD32 (XXX this must go away!!!) - */ - if (lp->d_nsectors == 0) - lp->d_nsectors = 17; - if (lp->d_ntracks == 0) - lp->d_ntracks = 6; - if (lp->d_secpercyl == 0) - lp->d_secpercyl = 102; - - mfm_rdselect(msc->unit); - - bzero((void *) 0x200D0000, size); - scount = size / 512; - - while (scount) { - /* - * prepare drive/operation parameter - */ - cyl = block / lp->d_secpercyl; - sect = block % lp->d_secpercyl; - head = sect / lp->d_nsectors; - sect = sect % lp->d_nsectors; - - if (dblk < 0) { -#ifdef verbose - printf("using raw diskblock-data!\n"); - printf("block %d, dblk %d ==> cyl %d, head %d, sect %d\n", - block, dblk, cyl, sect, head); -#endif - } else - cyl += 1; /* first cylinder is reserved for - * controller! */ - - *rsize = 512 * min(scount, lp->d_nsectors - sect); - /* - * now re-initialize the register values ... - */ - creg.udc_dma7 = 0; - creg.udc_dma15 = 0; - creg.udc_dma23 = 0; - - creg.udc_dsect = sect; - head |= (cyl >> 4) & 0x70; - creg.udc_dhead = head; - creg.udc_dcyl = cyl; - - creg.udc_scnt = *rsize / 512; - - if (func == F_WRITE) { - creg.udc_rtcnt = UDC_RC_HDD_WRT; - creg.udc_mode = UDC_MD_HDD; - creg.udc_term = UDC_TC_HDD; - cmd = DKC_CMD_WRITE_HDD; - - bcopy(buf, (void *) 0x200D0000, *rsize); - res = mfm_command(cmd); - } else { - creg.udc_rtcnt = UDC_RC_HDD_READ; - creg.udc_mode = UDC_MD_HDD; - creg.udc_term = UDC_TC_HDD; - cmd = DKC_CMD_READ_HDD; - - bzero((void *) 0x200D0000, *rsize); - res = mfm_command(cmd); - bcopy((void *) 0x200D0000, buf, *rsize); - } - - scount -= *rsize / 512; - block += *rsize / 512; - buf += *rsize; - } - - /* - * unselect the drive ... - */ - mfm_command(DKC_CMD_DRDESELECT); - - *rsize = size; - return 0; -} - -int -mfmstrategy(msc, func, dblk, size, buf, rsize) - struct mfm_softc *msc; - int func; - daddr_t dblk; - char *buf; - int size, *rsize; -{ - int res = -1; - - switch (msc->unit) { - case 0: - case 1: - res = mfm_rdstrategy(msc, func, dblk, size, buf, rsize); - break; - case 2: - res = mfm_rxstrategy(msc, func, dblk, size, buf, rsize); - break; - default: - printf("invalid unit %d in mfmstrategy()\n"); - } - return (res); -} diff --git a/sys/arch/vax/stand/netio.c b/sys/arch/vax/stand/netio.c deleted file mode 100644 index 99c58e02615..00000000000 --- a/sys/arch/vax/stand/netio.c +++ /dev/null @@ -1,245 +0,0 @@ -/* $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 $ */ - -/* - * Copyright (c) 1995, 1996 Jason R. Thorpe - * Copyright (c) 1995 Gordon W. Ross - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * 4. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Gordon W. Ross - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * This module implements a "raw device" interface suitable for - * use by the stand-alone I/O library NFS code. This interface - * does not support any "block" access, and exists only for the - * purpose of initializing the network interface, getting boot - * parameters, and performing the NFS mount. - * - * At open time, this does: - * - * find interface - netif_open() - * RARP for IP address - rarp_getipaddress() - * RPC/bootparams - callrpc(d, RPC_BOOTPARAMS, ...) - * RPC/mountd - nfs_mount(sock, ip, path) - * - * the root file handle from mountd is saved in a global - * for use by the NFS open code (NFS/lookup). - */ - -#include -#include -#include -#include -#include -#include - -#include "stand.h" -#include "samachdep.h" -#include "net.h" -#include "netif.h" -#include "bootparam.h" -#include "nfs.h" - -extern int nfs_root_node[]; /* XXX - get from nfs_mount() */ - -struct in_addr myip, rootip, gateip; -n_long netmask; -char rootpath[FNAME_SIZE]; - -int netdev_sock = -1; -static int open_count; - -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. - */ -int -netopen(f, devname) - struct open_file *f; - char *devname; /* Device part of file name (or NULL). */ -{ - int error = 0; - - /* On first open, do netif open, mount, etc. */ - if (open_count == 0) { - /* Find network interface. */ - if ((netdev_sock = netif_open(devname)) < 0) - return (error=ENXIO); - if ((error = netmountroot(f, devname)) != 0) - return (error); - } - open_count++; - f->f_devdata = nfs_root_node; - return (error); -} - -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); - f->f_devdata = NULL; -} - -int -netstrategy(devdata, func, dblk, size, v_buf, rsize) - void *devdata; - int func; - daddr_t dblk; - size_t size; - void *v_buf; - size_t *rsize; -{ - - *rsize = size; - return EIO; -} - -int -netmountroot(f, devname) - struct open_file *f; - char *devname; /* Device part of file name (or NULL). */ -{ - int error; - struct iodesc *d; - - if (netio_ask) { - get_my_ip: - printf("My IP address? "); - bzero(input_line, sizeof(input_line)); - gets(input_line); - if ((myip.s_addr = inet_addr(input_line)) == - htonl(INADDR_NONE)) { - printf("invalid IP address: %s\n", input_line); - goto get_my_ip; - } - - get_my_netmask: - printf("My netmask? "); - bzero(input_line, sizeof(input_line)); - gets(input_line); - if ((netmask = inet_addr(input_line)) == - htonl(INADDR_NONE)) { - printf("invalid netmask: %s\n", input_line); - goto get_my_netmask; - } - - get_my_gateway: - printf("My gateway? "); - bzero(input_line, sizeof(input_line)); - gets(input_line); - if ((gateip.s_addr = inet_addr(input_line)) == - htonl(INADDR_NONE)) { - printf("invalid IP address: %s\n", input_line); - goto get_my_gateway; - } - - get_server_ip: - printf("Server IP address? "); - bzero(input_line, sizeof(input_line)); - gets(input_line); - if ((rootip.s_addr = inet_addr(input_line)) == - htonl(INADDR_NONE)) { - printf("invalid IP address: %s\n", input_line); - goto get_server_ip; - } - - get_server_path: - printf("Server path? "); - bzero(rootpath, sizeof(rootpath)); - gets(rootpath); - if (rootpath[0] == '\0' || rootpath[0] == '\n') - goto get_server_path; - - if ((d = socktodesc(netdev_sock)) == NULL) - return (EMFILE); - - d->myip = myip; - - goto do_nfs_mount; - } - - /* - * Get info for NFS boot: our IP address, our hostname, - * server IP address, and our root path on the server. - * There are two ways to do this: The old, Sun way, - * and the more modern, BOOTP way. (RFC951, RFC1048) - */ - -#ifdef SUN_BOOTPARAMS - /* Get boot info using RARP and Sun bootparams. */ - - /* Get our IP address. (rarp.c) */ - if (rarp_getipaddress(netdev_sock) == -1) - return (errno); - - printf("boot: client IP address: %s\n", inet_ntoa(myip)); - - /* Get our hostname, server IP address. */ - if (bp_whoami(netdev_sock)) - return (errno); - - printf("boot: client name: %s\n", hostname); - - /* Get the root pathname. */ - if (bp_getfile(netdev_sock, "root", &rootip, rootpath)) - return (errno); - -#else - - /* Get boot info using BOOTP way. (RFC951, RFC1048) */ - bootp(netdev_sock); - - printf("Using 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"); - -#endif /* SUN_BOOTPARAMS */ - - printf("root addr=%s path=%s\n", inet_ntoa(rootip), rootpath); - - do_nfs_mount: - /* Get the NFS file handle (mount). */ - error = nfs_mount(netdev_sock, rootip, rootpath); - - return (error); -} diff --git a/sys/arch/vax/stand/ra.c b/sys/arch/vax/stand/ra.c deleted file mode 100644 index c349d2ec463..00000000000 --- a/sys/arch/vax/stand/ra.c +++ /dev/null @@ -1,232 +0,0 @@ -/* $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 $ */ -/* - * 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}. - * 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 */ - -#define NRSP 1 /* Kludge */ -#define NCMD 1 /* Kludge */ - -#include "sys/param.h" -#include "sys/disklabel.h" - -#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 "../mscp/mscp.h" -#include "../mscp/mscpreg.h" - -#include "../bi/bireg.h" -#include "../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 - * a time, no separate routines for uba driver etc.. - * This code is foolish and should need a cleanup. - * But it works :) - */ - -struct ra_softc { - int udaddr; - int ubaddr; - int part; - int unit; - unsigned short *ra_ip; - unsigned short *ra_sa; - unsigned short *ra_sw; -}; - -volatile struct uda { - struct mscp_1ca uda_ca; /* communications area */ - struct mscp uda_rsp; /* response packets */ - struct mscp uda_cmd; /* command packets */ -} uda; - -volatile struct uda *ubauda; -volatile struct udadevice *udacsr; -struct disklabel ralabel; -struct ra_softc ra_softc; -char io_buf[DEV_BSIZE]; - -raopen(f, adapt, ctlr, unit, part) - struct open_file *f; - int 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; - - bzero(lp, sizeof(struct disklabel)); - ra->unit = unit; - ra->part = part; - if (vax_cputype != VAX_8200) { - if (adapt > nuba) - return(EADAPT); - if (ctlr > nuda) - return(ECTLR); - nisse = (u_int *)&mr->uba_map[0]; - nisse[494] = PG_V | (((u_int)&uda) >> 9); - nisse[495] = nisse[494] + 1; - udacsr = (void*)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->udaddr = uioaddr[adapt] + udaaddr[ctlr]; - ra->ubaddr = (int)mr; - *ra->ra_ip = 0; /* Start init */ - } else { - struct bi_node *bi = (void *)biaddr[adapt]; - struct kdb_regs *kb = (void *)&bi[ctlr]; - volatile int i = 10000; - - ra->ra_ip = &kb->kdb_ip; - ra->ra_sa = &kb->kdb_sa; - ra->ra_sw = &kb->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; - while (i--) /* Need delay??? */ - ; - kb->kdb_bi.bi_ber = ~(BIBER_MBZ|BIBER_NMR|BIBER_UPEN);/* ??? */ - ubauda = &uda; - } - - /* Init of this uda */ - while ((*ra->ra_sa & MP_STEP1) == 0) - ; - - *ra->ra_sw = 0x8000; - while ((*ra->ra_sa & MP_STEP2) == 0) - ; - - *ra->ra_sw = johan; - while ((*ra->ra_sa & MP_STEP3) == 0) - ; - - *ra->ra_sw = johan2; - while ((*ra->ra_sa & MP_STEP4) == 0) - ; - - *ra->ra_sw = 0x0001; - uda.uda_ca.ca_rspdsc = (int)&ubauda->uda_rsp.mscp_cmdref; - uda.uda_ca.ca_cmddsc = (int)&ubauda->uda_cmd.mscp_cmdref; - - command(M_OP_SETCTLRC); - uda.uda_cmd.mscp_unit = ra->unit; - command(M_OP_ONLINE); - - err = rastrategy(ra,F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); - if(err){ - printf("reading disklabel: %s\n",strerror(err)); - return 0; - } - - msg = getdisklabel(io_buf+LABELOFFSET, lp); - if (msg) - printf("getdisklabel: %s\n", msg); - f->f_devdata = (void *)ra; - return(0); -} - -static -command(cmd) -{ - volatile int hej; - - uda.uda_cmd.mscp_opcode = cmd; - uda.uda_cmd.mscp_msglen = MSCP_MSGLEN; - 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; - hej = *ra_softc.ra_ip; - while(uda.uda_ca.ca_rspdsc<0) - ; - -} - -rastrategy(ra, func, dblk, size, buf, rsize) - struct ra_softc *ra; - int func; - daddr_t dblk; - 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]; - - pfnum = (u_int)buf >> PGSHIFT; - - for(mapnr = 0, nsize = size; (nsize + NBPG) > 0; nsize -= NBPG) - ptmapp[mapnr++] = PG_V | pfnum++; - uda.uda_cmd.mscp_seq.seq_buffer = ((u_int)buf) & 0x1ff; - } else - uda.uda_cmd.mscp_seq.seq_buffer = ((u_int)buf); - - lp = &ralabel; - uda.uda_cmd.mscp_seq.seq_lbn = - dblk + lp->d_partitions[ra->part].p_offset; - uda.uda_cmd.mscp_seq.seq_bytecount = size; - uda.uda_cmd.mscp_unit = ra->unit; - if (func == F_WRITE) - command(M_OP_WRITE); - else - command(M_OP_READ); - - *rsize = size; - return 0; -} diff --git a/sys/arch/vax/stand/rom.c b/sys/arch/vax/stand/rom.c deleted file mode 100644 index 1e14e6049a4..00000000000 --- a/sys/arch/vax/stand/rom.c +++ /dev/null @@ -1,124 +0,0 @@ -/* $OpenBSD: rom.c,v 1.3 1998/05/13 07:30:26 niklas Exp $ */ -/* $NetBSD: rom.c,v 1.1 1996/08/02 11:22:21 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. - */ - -#include "sys/param.h" -#include "sys/reboot.h" -#include "sys/disklabel.h" - -#include "lib/libsa/stand.h" -#include "lib/libsa/ufs.h" - -#include "../include/pte.h" -#include "../include/sid.h" -#include "../include/mtpr.h" -#include "../include/reg.h" -#include "../include/rpb.h" - -#include "data.h" -#include "vaxstand.h" - -extern unsigned *bootregs; -extern struct rpb *rpb; - -struct rom_softc { - int part; - int unit; -}; - -int romstrategy(), romopen(); -struct disklabel romlabel; -struct rom_softc rom_softc; -char io_buf[DEV_BSIZE]; - -romopen(f, adapt, ctlr, unit, part) - struct open_file *f; - int ctlr, unit, part; -{ - char *msg; - struct disklabel *lp = &romlabel; - volatile struct rom_softc *rsc = &rom_softc; - int i,err; - - bootregs[11] = XXRPB; - rpb = (void*)XXRPB; - bqo = (void*)rpb->iovec; - - if (rpb->unit > 0 && (rpb->unit % 100) == 0) { - printf ("changing rpb->unit from %d ", rpb->unit); - rpb->unit /= 100; - printf ("to %d\n", rpb->unit); - } - - bzero(lp, sizeof(struct disklabel)); - rsc->unit = unit; - rsc->part = part; - - err = romstrategy(rsc, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); - if (err) { - printf("reading disklabel: %s\n",strerror(err)); - return 0; - } - msg = getdisklabel(io_buf+LABELOFFSET, lp); - if (msg) - printf("getdisklabel: %s\n",msg); - f->f_devdata = (void*)rsc; - return(0); -} - -romstrategy (rsc, func, dblk, size, buf, rsize) - struct rom_softc *rsc; - int func; - daddr_t dblk; - char *buf; - int size, *rsize; -{ - struct disklabel *lp; - int block; - - lp = &romlabel; - block = dblk + lp->d_partitions[rsc->part].p_offset; - if (rsc->unit >= 0 && rsc->unit < 10) - rpb->unit = rsc->unit; - - if (func == F_WRITE) - romwrite_uvax(block, size, buf, bootregs); - else - romread_uvax(block, size, buf, bootregs); - - *rsize = size; - return 0; -} - diff --git a/sys/arch/vax/stand/romread.s b/sys/arch/vax/stand/romread.s deleted file mode 100644 index 41cb4e2d33d..00000000000 --- a/sys/arch/vax/stand/romread.s +++ /dev/null @@ -1,94 +0,0 @@ -/* $OpenBSD: romread.s,v 1.3 1997/05/29 00:04:24 niklas Exp $ */ -/* $NetBSD: romread.s,v 1.4 1996/08/02 11:22:24 ragge Exp $ */ -/* - * Copyright (c) 1995 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. - */ - - /* All bugs are subject to removal without further notice */ - - - -#include "../include/asm.h" - -/* - * read750 (int block, int *regs) - */ -ENTRY(read750, 0xFFE) - movl 8(ap), r8 - movl 4(r8), r1 - movl 8(r8), r2 - movl 12(r8), r3 - movl 24(r8), r6 - clrl r5 - movl 4(ap), r8 - pushl $0 - movl $0, 4(sp) - movl fp, 0xf0000 # ragge ??? - jsb (r6) - movl 0xf0000, fp - ret - -/* - * romread_uvax (int lbn, int size, void *buf, int *regs) - */ -ENTRY(romread_uvax, 0xFFE) - movl 16(ap), r11 # array of bootregs - movl 44(r11), r11 # restore boot-contents of r11 (rpb) - movl 52(r11), r7 # load iovec/bqo into r7 - addl3 (r7), r7, r6 # load qio into r6 - pushl r11 # base of rpb - pushl $0 # virtual-flag - pushl $33 # read-logical-block - pushl 4(ap) # lbn to start reading - pushl 8(ap) # number of bytes to read - pushl 12(ap) # buffer-address - calls $6, (r6) # call the qio-routine - ret # r0 holds the result - -/* - * romwrite_uvax (int lbn, int size, void *buf, int *regs) - */ -ENTRY(romwrite_uvax, 0xFFE) - movl 16(ap), r11 # array of bootregs - movl 44(r11), r11 # restore boot-contents of r11 (rpb) - movl 52(r11), r7 # load iovec/bqo into r7 - addl3 (r7), r7, r6 # load qio into r6 - pushl r11 # base of rpb - pushl $0 # virtual-flag - pushl $32 # write-logical-block - pushl 4(ap) # lbn to start reading - pushl 8(ap) # number of bytes to read - pushl 12(ap) # buffer-address - calls $6, (r6) # call the qio-routine - ret # r0 holds the result - 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 ", 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 -#include -#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<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/srt0.s b/sys/arch/vax/stand/srt0.s deleted file mode 100644 index f96bc035eb1..00000000000 --- a/sys/arch/vax/stand/srt0.s +++ /dev/null @@ -1,85 +0,0 @@ -/* $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 $ */ -/* - * 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 */ - - -/* - * Auto-moving startup code for standalone programs. Can be loaded - * (almost) anywhere in memory but moves itself to the position - * it is linked for. Must be started at first position, recommended - * is phys addr 0 (boot loads programs at 0, but starts them at the - * position set in a.out header. - */ - -start0: .set start0,0 # passing -e start0 to ld gives OK start addr - .globl start0 - -_start: .globl _start - nop;nop; # If we get called by calls, or something - - movl r8, _memsz # If we come from disk, save memsize - cmpl ap, $-1 # Check if we are net-booted. XXX - kludge - beql 2f # jump if not - ashl $9,76(r11),_memsz # got memsize from rpb - movzbl 102(r11), r10 # Get bootdev from rpb. - movzwl 48(r11), r11 # Get howto - -2: movl $_start, sp # Probably safe place for stack - subl2 $52, sp # do not overwrite saved boot-registers - - subl3 $_start, $_edata, r0 - moval _start, r1 - subl3 $_start, $_end, r2 - movl $_start, r3 - movc5 r0, (r1), $0, r2, (r3) - 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 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) - - .globl _memsz -_memsz: .long 0x0 diff --git a/sys/arch/vax/stand/start.s b/sys/arch/vax/stand/start.s deleted file mode 100644 index 61f75d87ba4..00000000000 --- a/sys/arch/vax/stand/start.s +++ /dev/null @@ -1,191 +0,0 @@ -/* $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 $ */ -/* - * Copyright (c) 1995 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. - */ - - /* All bugs are subject to removal without further notice */ - - -#define _LOCORE - -#include "sys/disklabel.h" - -#include "../include/mtpr.h" -#include "../include/asm.h" - -_start: .globl _start # this is the symbolic name for the start - # of code to be relocated. We can use this - # to get the actual/real adress (pc-rel) - # or to get the relocated address (abs). - -.org 0x00 # uVAX booted from TK50 starts here - brb from_0x00 # continue behind dispatch-block - -.org 0x02 # information used by uVAX-ROM - .byte (LABELOFFSET + d_end_)/2 # offset in words to identification area - .byte 1 # this byte must be 1 - .word 0 # logical block number (word swapped) - .word 0 # of the secondary image - -.org 0x08 # - brb from_0x08 # skip ... - -.org 0x0A # uVAX booted from disk starts here - brb from_0x0A # skip ... - -.org 0x0C # 11/750 & 8200 starts here - brw cont_750 - - -from_0x00: # uVAX from TK50 -from_0x0A: # uVAX from disk - brw start_uvax # all(?) uVAXen continue there - -from_0x08: # What comes here??? - halt - -.org LABELOFFSET - 6 -regmask: .word 0x0fff # using a variable saves 3 bytes !!! -bootinfo: .long 0x0 # another 3 bytes if within byte-offset - -# the complete area reserved for label -# must be empty (i.e. filled with zeroes). -# disklabel(8) checks that before installing -# the bootblocks over existing label. - -/* - * Parameter block for uVAX boot. - */ -#define VOLINFO 0 /* 1=single-sided 81=double-sided volumes */ -#define SISIZE 16 /* size in blocks of secondary image */ -#define SILOAD 0 /* load offset (usually 0) from the default */ -#define SIOFF 0x0A /* byte offset into secondary image */ - -.org LABELOFFSET + d_end_ - .byte 0x18 # must be 0x18 - .byte 0x00 # must be 0x00 (MBZ) - .byte 0x00 # any value - .byte 0xFF - (0x18 + 0x00 + 0x00) - /* 4th byte holds 1s' complement of sum of previous 3 bytes */ - - .byte 0x00 # must be 0x00 (MBZ) - .byte VOLINFO - .byte 0x00 # any value - .byte 0x00 # any value - - .long SISIZE # size in blocks of secondary image - .long SILOAD # load offset (usually 0) - .long SIOFF # byte offset into secondary image - .long (SISIZE + SILOAD + SIOFF) # sum of previous 3 - -/* - * After bootblock (LBN0) has been loaded into the first page - * of good memory by 11/750's ROM-code (transfer address - * of bootblock-code is: base of good memory + 0x0C) registers - * are initialized as: - * R0: type of boot-device - * 0: Massbus device - * 1: RK06/RK07 - * 2: RL02 - * 17: UDA50 - * 35: TK50 - * 64: TU58 - * R1: (UBA) address of UNIBUS I/O-page - * (MBA) address of boot device's adapter - * R2: (UBA) address of the boot device's CSR - * (MBA) controller number of boot device - * R6: address of driver subroutine in ROM - * - * cont_750 reads in LBN1-15 for further execution. - */ - .align 2 -cont_750: - movl r0,r10 - movl r5, ap # ap not used here - clrl r5 - clrl r4 - movl $_start,sp -1: incl r4 - movl r4,r8 - addl2 $0x200,r5 - cmpl $16,r4 - beql 2f - pushl r5 - jsb (r6) - blbs r0,1b -2: movl r10, r0 - movl r11, r5 - brw start_all - - -start_uvax: - mtpr $0, $PR_MAPEN # Turn off MM, please. - movl $_start, sp - movl 48(r11), ap - brb start_all - -/* - * start_all: stack already at RELOC, we save registers, move ourself - * to RELOC and loads boot. - */ -start_all: - pushr $0xfff # save all regs, used later. - - subl3 $_start, $_edata, r0 # get size of text+data (w/o bss) - moval _start, r1 # get actual base-address of code - subl3 $_start, $_end, r2 # get complete size (incl. bss) - movl $_start, r3 # get relocated base-address of code - movc5 r0, (r1), $0, r2, (r3) # copy code to new location - - movl $relocated, -(sp) # return-address on top of stack - rsb # can be replaced with new address -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 ... - -/* - * hoppabort() is called when jumping to the newly loaded program. - */ -ENTRY(hoppabort, 0) - movl 4(ap),r6 - movl 8(ap),r11 - movl 0xc(ap),r10 - movl _memsz, r8 - mnegl $1, ap # Hack to figure out boot device. - jmp 2(r6) -# calls $0,(r6) - halt diff --git a/sys/arch/vax/stand/str.s b/sys/arch/vax/stand/str.s deleted file mode 100644 index 8b393d5ddb3..00000000000 --- a/sys/arch/vax/stand/str.s +++ /dev/null @@ -1,133 +0,0 @@ -/* $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 $ */ -/* - * Copyright (c) 1996 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. - */ - -/* - * Small versions of the most common functions not using any - * emulated instructions. - */ - -#include "../include/asm.h" - -/* - * atoi() used in devopen. - */ -ENTRY(atoi, 0); - movl 4(ap),r1 - clrl r0 - -2: movzbl (r1)+,r2 - cmpb r2,$48 - blss 1f - cmpb r2,$57 - bgtr 1f - subl2 $48,r2 - mull2 $10,r0 - addl2 r2,r0 - brb 2b -1: ret - -/* - * index() small and easy. - * doesnt work if we search for null. - */ -ENTRY(index, 0); - movq 4(ap),r0 -1: cmpb (r0), r1 - beql 2f - tstb (r0)+ - bneq 1b - clrl r0 -2: ret - -/* - * cmpc3 is emulated on MVII. - */ -ENTRY(bcmp, 0); - movl 4(ap), r2 - movl 8(ap), r1 - movl 12(ap), r0 -2: cmpb (r2)+, (r1)+ - bneq 1f - decl r0 - bneq 2b -1: ret - -/* - * 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) - ret - -ENTRY(bcopy,0); - movl 4(ap), r0 - movl 8(ap), r1 - movl 12(ap), r2 - movc3 r2, (r0), (r1) - ret - -ENTRY(strlen, 0); - movl 4(ap), r0 -1: tstb (r0)+ - bneq 1b - decl r0 - subl2 4(ap), r0 - ret - -#if 0 -ENTRY(strncmp, 0) - movl 12(ap), r3 - brb 5f - -ENTRY(strcmp, 0) - movl $250, r3 # max string len to compare -5: movl 4(ap), r2 - movl 8(ap), r1 - movl $1, r0 - -2: cmpb (r2),(r1)+ - bneq 1f # something differ - tstb (r2)+ - beql 4f # continue, strings unequal - decl r3 # max string len encountered? - bneq 2b - -4: clrl r0 # We are done, strings equal. - ret - -1: bgtr 3f - mnegl r0, r0 -3: ret -#endif 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/tmscp.c b/sys/arch/vax/stand/tmscp.c deleted file mode 100644 index 90ca7e9fa48..00000000000 --- a/sys/arch/vax/stand/tmscp.c +++ /dev/null @@ -1,203 +0,0 @@ -/* $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 $ */ -/* - * 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}. - * 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 */ - -#define NRSP 0 /* Kludge */ -#define NCMD 0 /* Kludge */ - -#include "sys/param.h" -#include "sys/disklabel.h" - -#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 "vaxstand.h" - -static command(int,int); - -/* - * These routines for TMSCP tape standalone boot is very simple, - * assuming a lots of thing like that we only working at one tape at - * a time, no separate routines for uba driver etc.. - * This code is directly copied from ra disk driver. - */ - -struct ra_softc { - int udaddr; - int ubaddr; - int unit; -}; - -static volatile struct uda { - struct mscp_1ca uda_ca; /* communications area */ - struct mscp uda_rsp; /* response packets */ - struct mscp uda_cmd; /* command packets */ -} uda; - -static volatile struct uda *ubauda; -static volatile struct udadevice *udacsr; -static struct ra_softc ra_softc; - -tmscpopen(f, adapt, ctlr, unit, part) - struct open_file *f; - int 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; - - if(adapt>nuba) return(EADAPT); - if(ctlr>nuda) return(ECTLR); - ra->udaddr=uioaddr[adapt]+tmsaddr; - ra->ubaddr=(int)mr; - ra->unit=unit; - udacsr=(void*)ra->udaddr; - nisse=(u_int *)&mr->uba_map[0]; - nisse[494]=PG_V|(((u_int)&uda)>>9); - nisse[495]=nisse[494]+1; - ubauda=(void*)0x3dc00+(((u_int)(&uda))&0x1ff); - - /* - * Init of this tmscp ctlr. - */ - udacsr->udaip=0; /* Start init */ - while((udacsr->udasa&MP_STEP1) == 0); - udacsr->udasa=0x8000; - while((udacsr->udasa&MP_STEP2) == 0); - johan=(((u_int)ubauda)&0xffff)+8; - udacsr->udasa=johan; - while((udacsr->udasa&MP_STEP3) == 0); - udacsr->udasa=3; - while((udacsr->udasa&MP_STEP4) == 0); - udacsr->udasa=0x0001; - - uda.uda_ca.ca_rspdsc=(int)&ubauda->uda_rsp.mscp_cmdref; - uda.uda_ca.ca_cmddsc=(int)&ubauda->uda_cmd.mscp_cmdref; - uda.uda_cmd.mscp_un.un_seq.seq_addr = (long *)&uda.uda_ca.ca_cmddsc; - uda.uda_rsp.mscp_un.un_seq.seq_addr = (long *)&uda.uda_ca.ca_rspdsc; - uda.uda_cmd.mscp_vcid = 1; - uda.uda_cmd.mscp_un.un_sccc.sccc_ctlrflags = 0; - - command(M_OP_SETCTLRC, 0); - uda.uda_cmd.mscp_unit=ra->unit; - command(M_OP_ONLINE, 0); - - if (part) { - uda.uda_cmd.mscp_un.un_seq.seq_buffer = part; - command(M_OP_POS, 0); - uda.uda_cmd.mscp_un.un_seq.seq_buffer = 0; - } - - f->f_devdata=(void *)ra; - return(0); -} - -static -command(cmd, arg) -{ - volatile int hej; - - uda.uda_cmd.mscp_opcode = cmd; - uda.uda_cmd.mscp_modifier = arg; - - uda.uda_cmd.mscp_msglen = MSCP_MSGLEN; - 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; - hej = udacsr->udaip; - while (uda.uda_ca.ca_rspdsc < 0) { - if (uda.uda_ca.ca_cmdint) - uda.uda_ca.ca_cmdint = 0; - } - -} - -static int curblock = 0; - -tmscpstrategy(ra, func, dblk, size, buf, rsize) - struct ra_softc *ra; - int func; - daddr_t dblk; - char *buf; - 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 int hej; - - pfnum=(u_int)buf>>PGSHIFT; - - for(mapnr=0, nsize=size;(nsize+NBPG)>0;nsize-=NBPG) - ptmapp[mapnr++]=PG_V|pfnum++; - - /* - * First position tape. Remember where we are. - */ - if (dblk < curblock) { - uda.uda_cmd.mscp_seq.seq_bytecount = curblock - dblk; - command(M_OP_POS, 12); /* 12 == step block backward */ - } else { - uda.uda_cmd.mscp_seq.seq_bytecount = dblk - curblock; - command(M_OP_POS, 4); /* 4 == step block forward */ - } - curblock = size/512 + dblk; - - /* - * Read in the number of blocks we need. - * Why doesn't read of multiple blocks work????? - */ - for (i = 0 ; i < size/512 ; i++) { - uda.uda_cmd.mscp_seq.seq_lbn = 1; - uda.uda_cmd.mscp_seq.seq_bytecount = 512; - uda.uda_cmd.mscp_seq.seq_buffer = - (((u_int)buf) & 0x1ff) + i * 512; - uda.uda_cmd.mscp_unit = ra->unit; - command(M_OP_READ, 0); - } - - *rsize=size; - return 0; -} diff --git a/sys/arch/vax/stand/vaxstand.h b/sys/arch/vax/stand/vaxstand.h deleted file mode 100644 index ad2ec8d7598..00000000000 --- a/sys/arch/vax/stand/vaxstand.h +++ /dev/null @@ -1,53 +0,0 @@ -/* $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 $ */ -/* - * 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 */ - - -#define MAXNMBA 8 /* Massbussadapters */ -#define MAXNUBA 8 /* Unibusadapters */ -#define MAXMBAU 8 /* Units on an mba */ - -/* Variables used in autoconf */ -extern int nmba, nuba, nbi, nsbi, nuda; -extern int *ubaaddr, *mbaaddr, *udaaddr, *uioaddr, *biaddr; -extern int cpunumber; - -/* devsw type definitions, used in bootxx and conf */ -#define SADEV(name,strategy,open,close,ioctl) \ - { (char *)name, \ - (int(*)(void *, int ,daddr_t , size_t, void *, size_t *))strategy, \ - (int(*)(struct open_file *, ...))open, \ - (int(*)(struct open_file *))close, \ - (int(*)(struct open_file *,u_long, void *))ioctl} - -char *index(); 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 diff --git a/sys/arch/vax/stand/xxboot/bootxx.c b/sys/arch/vax/stand/xxboot/bootxx.c new file mode 100644 index 00000000000..3a1d48fab9f --- /dev/null +++ b/sys/arch/vax/stand/xxboot/bootxx.c @@ -0,0 +1,448 @@ +/* $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. + * + * 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 "sys/disklabel.h" + +#include "lib/libsa/stand.h" +#include "lib/libsa/ufs.h" + +#include "../include/pte.h" +#include "../include/sid.h" +#include "../include/mtpr.h" +#include "../include/reg.h" +#include "../include/rpb.h" + +#include "../mba/mbareg.h" +#include "../mba/hpreg.h" + +#define NRSP 1 /* Kludge */ +#define NCMD 1 /* Kludge */ + +#include "../mscp/mscp.h" +#include "../mscp/mscpreg.h" + +#include "vaxstand.h" + + +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 dev_t devtype, bootdev; +unsigned opendev, boothowto, bootset, memsz; + +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, + * VS3100/??, VS4000 and VAX6000/???, and only when booting from disk. + */ +Xmain() +{ + int io; + char *scbb; + char *new, *bqo; + char *hej = "/boot"; + + vax_cputype = (mfpr(PR_SID) >> 24) & 0xFF; + + /* + */ + switch (vax_cputype) { + case VAX_TYP_UV2: + case VAX_TYP_CVAX: + case VAX_TYP_RIGEL: + case VAX_TYP_NVAX: + case VAX_TYP_SOC: + /* + * now relocate rpb/bqo (which are used by ROM-routines) + */ + rpb = (void*)XXRPB; + bcopy ((void*)bootregs[11], rpb, 512); + rpb->rpb_base = rpb; + bqo = (void*)(512+(int)rpb); + bcopy ((void*)rpb->iovec, bqo, rpb->iovecsz); + rpb->iovec = (int)bqo; + bootregs[11] = (int)rpb; + bootdev = rpb->devtyp; + memsz = rpb->pfncnt << 9; + break; + case VAX_8200: + case VAX_750: + bootdev = bootregs[10]; + memsz = 0; + break; + default: + asm("halt"); + } + + bootset = getbootdev(); + + io = open(hej, 0); + + read(io, (void *)0x10000, 0x10000); + bcopy((void *) 0x10000, 0, 0xffff); + hoppabort(32, boothowto, bootset); + asm("halt"); +} + +getbootdev() +{ + int i, adaptor, controller, unit, partition, retval; + + adaptor = controller = unit = partition = 0; + + switch (vax_cputype) { + case VAX_TYP_UV2: + case VAX_TYP_CVAX: + case VAX_TYP_RIGEL: + 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 = bootregs[1]; + unit = bootregs[3]; + break; + } + + switch (B_TYPE(bootdev)) { + case BDEV_HP: /* massbuss boot */ + adaptor = (bootregs[1] & 0x6000) >> 17; + break; + + case BDEV_UDA: /* UDA50 boot */ + if (vax_cputype == VAX_750) + adaptor = (bootregs[1] & 0x40000 ? 0 : 1); + break; + + case BDEV_TK: /* TK50 boot */ + case BDEV_CNSL: /* Console storage boot */ + case BDEV_RD: /* RD/RX on HDC9224 (MV2000) */ + case BDEV_ST: /* SCSI-tape on NCR5380 (MV2000) */ + case BDEV_SD: /* SCSI-disk on NCR5380 (3100/76) */ + break; + + case BDEV_KDB: /* DSA disk on KDB50 (VAXBI VAXen) */ + bootdev = (bootdev & ~B_TYPEMASK) | BDEV_UDA; + break; + + default: + boothowto |= (RB_SINGLE | RB_ASKNAME); + } + return MAKEBOOTDEV(bootdev, adaptor, controller, unit, partition); +} + +/* + * 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 +tar_open(path, f) + char *path; + struct open_file *f; +{ + char *buf = alloc(512); + + 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; +} + +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) + struct open_file *f; + const char *fname; + char **file; +{ + extern char start; + char *msg; + int i, err, off; + char line[64]; + + f->f_dev = &devsw[0]; + *file = (char *)fname; + + /* + * On uVAX we need to init [T]MSCP ctlr to be able to use it. + */ + if (vax_cputype == VAX_TYP_UV2 || vax_cputype == VAX_TYP_CVAX) { + switch (bootdev) { + case BDEV_UDA: /* MSCP */ + case BDEV_TK: /* TMSCP */ + csr = (struct udadevice *)rpb->csrphy; + + csr->udaip = 0; /* Start init */ + while((csr->udasa & MP_STEP1) == 0); + csr->udasa = 0x8000; + while((csr->udasa & MP_STEP2) == 0); + csr->udasa = (short)(((u_int)&uda)&0xffff) + 8; + while((csr->udasa & MP_STEP3) == 0); + csr->udasa = 0x10; + while((csr->udasa & MP_STEP4) == 0); + csr->udasa = 0x0001; + + uda.uda_ca.ca_rspdsc = + (int) &uda.uda_rsp.mscp_cmdref; + uda.uda_ca.ca_cmddsc = + (int) &uda.uda_cmd.mscp_cmdref; + if (bootdev == BDEV_TK) + uda.uda_cmd.mscp_vcid = 1; + command(M_OP_SETCTLRC, 0); + uda.uda_cmd.mscp_unit = rpb->unit; + command(M_OP_ONLINE, 0); + } + } + + /* + * the disklabel _shall_ be at address LABELOFFSET + RELOC in + * phys memory now, no need at all to reread it again. + * Actually disklabel is only needed when using hp disks, + * but it doesn't hurt to always get it. + */ + getdisklabel(LABELOFFSET + &start, &lp); + return 0; +} + +command(cmd, arg) +{ + volatile int hej; + + uda.uda_cmd.mscp_opcode = cmd; + uda.uda_cmd.mscp_modifier = arg; + + uda.uda_cmd.mscp_msglen = MSCP_MSGLEN; + 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; + hej = csr->udaip; + while (uda.uda_ca.ca_rspdsc < 0); + +} + +int curblock = 0; + +romstrategy(sc, func, dblk, size, buf, rsize) + void *sc; + int func; + daddr_t dblk; + size_t size; + void *buf; + size_t *rsize; +{ + int i; + int block = dblk; + int nsize = size; + + switch (vax_cputype) { + /* + * case VAX_TYP_UV2: + * case VAX_TYP_CVAX: + * case VAX_TYP_RIGEL: + */ + default: + switch (bootdev) { + + case BDEV_UDA: /* MSCP */ + uda.uda_cmd.mscp_seq.seq_lbn = dblk; + uda.uda_cmd.mscp_seq.seq_bytecount = size; + uda.uda_cmd.mscp_seq.seq_buffer = (int)buf; + uda.uda_cmd.mscp_unit = rpb->unit; + command(M_OP_READ, 0); + break; + + case BDEV_TK: /* TMSCP */ + if (dblk < curblock) { + uda.uda_cmd.mscp_seq.seq_bytecount = + curblock - dblk; + command(M_OP_POS, 12); + } else { + uda.uda_cmd.mscp_seq.seq_bytecount = + dblk - curblock; + command(M_OP_POS, 4); + } + curblock = size/512 + dblk; + for (i = 0 ; i < size/512 ; i++) { + uda.uda_cmd.mscp_seq.seq_lbn = 1; + uda.uda_cmd.mscp_seq.seq_bytecount = 512; + uda.uda_cmd.mscp_seq.seq_buffer = + (int)buf + i * 512; + uda.uda_cmd.mscp_unit = rpb->unit; + command(M_OP_READ, 0); + } + break; + case BDEV_RD: + case BDEV_ST: + case BDEV_SD: + + default: + romread_uvax(block, size, buf, bootregs); + break; + + } + break; + + case VAX_8200: + case VAX_750: + if (bootdev != BDEV_HP) { + while (size > 0) { + while ((read750(block, bootregs) & 0x01) == 0){ + } + bcopy(0, buf, 512); + size -= 512; + buf += 512; + block++; + } + } else + hpread(block, size, buf); + break; + } + + if (rsize) + *rsize = nsize; + return 0; +} + +hpread(block, size, buf) + char *buf; +{ + volatile struct mba_regs *mr = (void *) bootregs[1]; + volatile struct hp_drv *hd = (void*)&mr->mba_md[bootregs[3]]; + struct disklabel *dp = &lp; + u_int pfnum, nsize, mapnr, bn, cn, sn, tn; + + pfnum = (u_int) buf >> PGSHIFT; + + for (mapnr = 0, nsize = size; (nsize + NBPG) > 0; nsize -= NBPG) + *(int *)&mr->mba_map[mapnr++] = PG_V | pfnum++; + mr->mba_var = ((u_int) buf & PGOFSET); + mr->mba_bc = (~size) + 1; + bn = block; + cn = bn / dp->d_secpercyl; + sn = bn % dp->d_secpercyl; + tn = sn / dp->d_nsectors; + sn = sn % dp->d_nsectors; + hd->hp_dc = cn; + hd->hp_da = (tn << 8) | sn; + hd->hp_cs1 = HPCS_READ; + while (mr->mba_sr & MBASR_DTBUSY); + if (mr->mba_sr & MBACR_ABORT){ + return 1; + } + 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/xxboot/start.s b/sys/arch/vax/stand/xxboot/start.s new file mode 100644 index 00000000000..d20753cf901 --- /dev/null +++ b/sys/arch/vax/stand/xxboot/start.s @@ -0,0 +1,200 @@ +/* $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. + * + * 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. + */ + + /* All bugs are subject to removal without further notice */ + + +#define _LOCORE + +#include "sys/disklabel.h" + +#include "../include/mtpr.h" +#include "../include/asm.h" + +_start: .globl _start # this is the symbolic name for the start + # of code to be relocated. We can use this + # to get the actual/real adress (pc-rel) + # or to get the relocated address (abs). + +.org 0x00 # uVAX booted from TK50 starts here + brb from_0x00 # continue behind dispatch-block + +.org 0x02 # information used by uVAX-ROM + .byte (LABELOFFSET + d_end_)/2 # offset in words to identification area + .byte 1 # this byte must be 1 + .word 0 # logical block number (word swapped) + .word 0 # of the secondary image + +.org 0x08 # + brb from_0x08 # skip ... + +.org 0x0A # uVAX booted from disk starts here + brb from_0x0A # skip ... + +.org 0x0C # 11/750 & 8200 starts here + brw cont_750 + + +from_0x00: # uVAX from TK50 +from_0x0A: # uVAX from disk + brw start_uvax # all(?) uVAXen continue there + +from_0x08: # What comes here??? + halt + +.org LABELOFFSET - 6 +regmask: .word 0x0fff # using a variable saves 3 bytes !!! +bootinfo: .long 0x0 # another 3 bytes if within byte-offset + +# the complete area reserved for label +# must be empty (i.e. filled with zeroes). +# disklabel(8) checks that before installing +# the bootblocks over existing label. + +/* + * Parameter block for uVAX boot. + */ +#define VOLINFO 0 /* 1=single-sided 81=double-sided volumes */ +#define SISIZE 16 /* size in blocks of secondary image */ +#define SILOAD 0 /* load offset (usually 0) from the default */ +#define SIOFF 0x0A /* byte offset into secondary image */ + +.org LABELOFFSET + d_end_ + .byte 0x18 # must be 0x18 + .byte 0x00 # must be 0x00 (MBZ) + .byte 0x00 # any value + .byte 0xFF - (0x18 + 0x00 + 0x00) + /* 4th byte holds 1s' complement of sum of previous 3 bytes */ + + .byte 0x00 # must be 0x00 (MBZ) + .byte VOLINFO + .byte 0x00 # any value + .byte 0x00 # any value + + .long SISIZE # size in blocks of secondary image + .long SILOAD # load offset (usually 0) + .long SIOFF # byte offset into secondary image + .long (SISIZE + SILOAD + SIOFF) # sum of previous 3 + +/* + * After bootblock (LBN0) has been loaded into the first page + * of good memory by 11/750's ROM-code (transfer address + * of bootblock-code is: base of good memory + 0x0C) registers + * are initialized as: + * R0: type of boot-device + * 0: Massbus device + * 1: RK06/RK07 + * 2: RL02 + * 17: UDA50 + * 35: TK50 + * 64: TU58 + * R1: (UBA) address of UNIBUS I/O-page + * (MBA) address of boot device's adapter + * R2: (UBA) address of the boot device's CSR + * (MBA) controller number of boot device + * R6: address of driver subroutine in ROM + * + * cont_750 reads in LBN1-15 for further execution. + */ + .align 2 +cont_750: + movl r0,r10 + movl r5, ap # ap not used here + clrl r5 + clrl r4 + movl $_start,sp +1: incl r4 + movl r4,r8 + addl2 $0x200,r5 + cmpl $16,r4 + beql 2f + pushl r5 + jsb (r6) + blbs r0,1b +2: movl r10, r0 + movl r11, r5 + brw start_all + + +start_uvax: + mtpr $0, $PR_MAPEN # Turn off MM, please. + movl $_start, sp + movl 48(r11), ap + brb start_all + +/* + * start_all: stack already at RELOC, we save registers, move ourself + * to RELOC and loads boot. + */ +start_all: + pushr $0xfff # save all regs, used later. + + subl3 $_start, $_edata, r0 # get size of text+data (w/o bss) + moval _start, r1 # get actual base-address of code + subl3 $_start, $_end, r2 # get complete size (incl. bss) + movl $_start, r3 # get relocated base-address of code + movc5 r0, (r1), $0, r2, (r3) # copy code to new location + + movl $relocated, -(sp) # return-address on top of stack + rsb # can be replaced with new address +relocated: # now relocation is done !!! + movl sp, _bootregs + movl ap, _boothowto + calls $0, _Xmain # call Xmain (gcc workaround)which is + halt # not intended to return ... + +/* + * hoppabort() is called when jumping to the newly loaded program. + */ +ENTRY(hoppabort, 0) + movl 4(ap),r6 + movl 8(ap),r11 + movl 0xc(ap),r10 + movl _memsz, r8 + mnegl $1, ap # Hack to figure out boot device. + 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 -- cgit v1.2.3