diff options
author | Hugh Graham <hugh@cvs.openbsd.org> | 2002-06-11 09:36:25 +0000 |
---|---|---|
committer | Hugh Graham <hugh@cvs.openbsd.org> | 2002-06-11 09:36:25 +0000 |
commit | 10ca5e5818bb80e596db244327a2663b6703bb18 (patch) | |
tree | c7ac330b34d73ea4e0c78d17a9eed0a3b6df63aa /sys/arch/vax/boot | |
parent | 180b34af9885b092bee0f67c5b2ac8577d972cfe (diff) |
New boot code, mostly from ragge's work in NetBSD.
Some header syncing and a couple network drivers came along for the ride.
Assembly files have been renamed from .s to .S to facilitate diffs.
Kernel is backwards compat - with manual interaction.
OpenBSD features have been preserved.
Diffstat (limited to 'sys/arch/vax/boot')
29 files changed, 2613 insertions, 1520 deletions
diff --git a/sys/arch/vax/boot/Makefile.inc b/sys/arch/vax/boot/Makefile.inc index 1df25851203..bbe032e06d2 100644 --- a/sys/arch/vax/boot/Makefile.inc +++ b/sys/arch/vax/boot/Makefile.inc @@ -1,12 +1,11 @@ -# $OpenBSD: Makefile.inc,v 1.2 2000/10/04 04:03:10 bjc Exp $ -# $NetBSD: Makefile.inc,v 1.2 1999/07/18 05:55:45 abs Exp $ +# $OpenBSD: Makefile.inc,v 1.3 2002/06/11 09:36:23 hugh Exp $ +# $NetBSD: Makefile.inc,v 1.6 2002/02/24 01:04:23 matt Exp $ -XXRPB=0x354240 RELOC=0x39F000 .PATH: ${.CURDIR}/../../vax ${.CURDIR}/../common -CPPFLAGS+=-I${.CURDIR}/../../../../ -I${.CURDIR}/../../ -I${.CURDIR}/../common -I${.CURDIR}/../../include -CPPFLAGS+=-DXXRPB=${XXRPB} -DRELOC=${RELOC} +CPPFLAGS+=-I. -I${.CURDIR}/../../../../ -I${.CURDIR}/../../ -I${.CURDIR}/../common -I${.CURDIR}/../../include +CPPFLAGS+=-DRELOC=${RELOC} # Private handling of assembler files. .s.o: diff --git a/sys/arch/vax/boot/boot/Makefile b/sys/arch/vax/boot/boot/Makefile index 49f3c3cb072..b48472504f1 100644 --- a/sys/arch/vax/boot/boot/Makefile +++ b/sys/arch/vax/boot/boot/Makefile @@ -1,23 +1,27 @@ -# $OpenBSD: Makefile,v 1.3 2002/02/14 20:45:31 deraadt Exp $ -# $NetBSD: Makefile,v 1.4 1999/05/23 21:58:19 ragge Exp $ +# $OpenBSD: Makefile,v 1.4 2002/06/11 09:36:23 hugh Exp $ +# $NetBSD: Makefile,v 1.27 2002/04/07 07:00:25 matt Exp $ S!= cd ${.CURDIR}/../../../../; pwd +NOMAN= # defined + +.include <bsd.own.mk> -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 +WARNS?= 1 +DEVS= hp.c ctu.c ra.c mfm.c if_qe.c if_le.c if_ze.c if_de.c if_ni.c +SRCS= srt0.S boot.c devopen.c conf.c autoconf.c netio.c rom.c romread.S \ + urem.s udiv.s consio.c consio2.S str.S ${DEVS} findcpu.c + +CLEANFILES+=${PROG} ${PROG}.sym +CPPFLAGS+=-DSUPPORT_BOOTPARAMS -DSUPPORT_DHCP -D_STANDALONE \ + -DNO_MID_CHECK #CPPFLAGS+=-DBOOTP_DEBUG -DNETIF_DEBUG -DETHER_DEBUG -DNFS_DEBUG -DDEV_DEBUG \ -# -DRPC_DEBUG -DRARP_DEBUG -DPARANOID -DSUPPORT_BOOTP -BINDIR= /usr/mdec +# -DRPC_DEBUG -DRARP_DEBUG -DPARANOID + +BINDIR=/usr/mdec +#SA_AS= library +#SAMISCMAKEFLAGS=SA_USE_CREAD=yes SA_INCLUDE_NET=yes SA_USE_LOADFILE=yes SA_ZLIB= yes SAREL= .include "${S}/lib/libsa/Makefile.inc" @@ -32,15 +36,36 @@ LIBZ= ${ZLIB} #.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} +.if ${MACHINE} == "vax" +.PHONY: machine-links +beforedepend: machine-links +machine-links: + @rm -f machine && ln -s ${S}/arch/${MACHINE}/include machine + @rm -f ${MACHINE_ARCH} && ln -s ${S}/arch/${MACHINE_ARCH}/include ${MACHINE_ARCH} +.NOPATH: machine ${MACHINE_ARCH} +CLEANFILES+= machine ${MACHINE_ARCH} +.endif + +#.if ${OBJECT_FMT} == "ELF" +#START=start +#.else +START=nisse +#.endif + +${PROG}: machine-links ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} + ${LD} -N -Ttext ${RELOC} -e ${START} -o ${PROG}.sym -Llib/sa -L. ${OBJS} \ + ${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN} + /usr/sbin/mopa.out ${PROG}.sym ${PROG}.mop + /bin/cp ${PROG}.sym ${PROG} + /usr/bin/strip ${PROG} + /usr/bin/size ${PROG} clean:: rm -f a.out [Ee]rrs mklog core *.core ${PROG} ${OBJS} ${LOBJS} \ ${CLEANFILES} +#install: +# ${INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 555 \ +# ${PROG} ${DESTDIR}${MDEC_DIR}/${PROG} + .include <bsd.prog.mk> diff --git a/sys/arch/vax/boot/boot/autoconf.c b/sys/arch/vax/boot/boot/autoconf.c index d3fe75802ce..00a2db03583 100644 --- a/sys/arch/vax/boot/boot/autoconf.c +++ b/sys/arch/vax/boot/boot/autoconf.c @@ -1,5 +1,5 @@ -/* $OpenBSD: autoconf.c,v 1.7 2002/03/09 03:36:33 hugh Exp $ */ -/* $NetBSD: autoconf.c,v 1.5 1999/08/23 19:09:27 ragge Exp $ */ +/* $OpenBSD: autoconf.c,v 1.8 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: autoconf.c,v 1.19 2002/06/01 15:33:22 ragge Exp $ */ /* * Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -34,112 +34,65 @@ -#include "sys/param.h" +#include <sys/param.h> + +#include <lib/libsa/stand.h> + #include "../../include/mtpr.h" #include "../../include/sid.h" +#include "../../include/intr.h" +#include "../../include/rpb.h" #include "../../include/scb.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) +void autoconf(void); +void findcpu(void); +void consinit(void); +void scbinit(void); +int getsecs(void); +void scb_stray(void *); +void longjmp(int *, int); +void rtimer(void *); + +long *bootregs; /* - * 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. + * Do some initial setup. Also create a fake RPB for net-booted machines + * that don't have an in-prom VMB. */ +void autoconf() { - extern int memsz; int copyrpb = 1; + int fromnet = (bootregs[12] != -1); findcpu(); /* Configures CPU variables */ consinit(); /* Allow us to print out things */ scbinit(); /* Fix interval clock etc */ +#ifdef DEV_DEBUG + printf("Register contents:\n"); + for (copyrpb = 0; copyrpb < 13; copyrpb++) + printf("r%d: %lx\n", copyrpb, bootregs[copyrpb]); +#endif 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: + case VAX_BTYP_9CC: + case VAX_BTYP_9RR: + case VAX_BTYP_1202: + if (fromnet == 0) + break; copyrpb = 0; - memsz = 0; - nbi = 1; - biaddr = bi8200; - bioaddr = bio8200; + bootrpb.devtyp = bootregs[0]; + bootrpb.adpphy = bootregs[1]; + bootrpb.csrphy = bootregs[2]; + bootrpb.unit = bootregs[3]; + bootrpb.rpb_bootr5 = bootregs[5]; + bootrpb.pfncnt = 0; break; case VAX_BTYP_46: @@ -153,15 +106,18 @@ autoconf() map[i] = 0x80000000 | i; }break; - case VAX_BTYP_410: - case VAX_BTYP_420: - case VAX_BTYP_43: - case VAX_BTYP_49: - case VAX_BTYP_1301: - case VAX_BTYP_1303: - case VAX_BTYP_1305: break; } + + if (copyrpb) { + struct rpb *prpb = (struct rpb *)bootregs[11]; + bcopy((caddr_t)prpb, &bootrpb, sizeof(struct rpb)); + if (prpb->iovec) { + bootrpb.iovec = (int)alloc(prpb->iovecsz); + bcopy((caddr_t)prpb->iovec, (caddr_t)bootrpb.iovec, + prpb->iovecsz); + } + } } /* @@ -170,25 +126,34 @@ autoconf() volatile int tickcnt; +int getsecs() { - volatile int loop; - int todr; - return tickcnt/100; } -void scb_stray(), rtimer(); struct ivec_dsp **scb; struct ivec_dsp *scb_vec; +extern struct ivec_dsp idsptch; +extern int jbuf[10]; + +static void +mcheck(void *arg) +{ + int off, *mfp = (int *)&arg; + + off = (mfp[7]/4 + 8); + printf("Machine check, pc=%x, psl=%x\n", mfp[off], mfp[off+1]); + longjmp(jbuf, 1); +} /* * Init the SCB and set up a handler for all vectors in the lower space, * to detect unwanted interrupts. */ +void scbinit() { - extern int timer; int i; /* @@ -211,18 +176,19 @@ scbinit() scb_vec[i].ev = NULL; } scb_vec[0xc0/4].hoppaddr = rtimer; + scb_vec[4/4].hoppaddr = mcheck; - mtpr(-10000, PR_NICR); /* Load in count register */ + if (vax_boardtype != VAX_BTYP_VXT) + mtpr(-10000, PR_NICR); /* Load in count register */ mtpr(0x800000d1, PR_ICCS); /* Start clock and enable interrupt */ mtpr(20, PR_IPL); } -extern int jbuf[10]; extern int sluttid, senast, skip; void -rtimer() +rtimer(void *arg) { mtpr(31, PR_IPL); tickcnt++; @@ -230,29 +196,40 @@ rtimer() if (skip) return; if ((vax_boardtype == VAX_BTYP_46) || - (vax_boardtype == VAX_BTYP_48) || - (vax_boardtype == VAX_BTYP_49)) { + (vax_boardtype == VAX_BTYP_48) || + (vax_boardtype == VAX_BTYP_49)) { int nu = sluttid - getsecs(); if (senast != nu) { mtpr(20, PR_IPL); - longjmp(jbuf); + longjmp(jbuf, 1); } } } +#ifdef __ELF__ +#define IDSPTCH "idsptch" +#define EIDSPTCH "eidsptch" +#define CMN_IDSPTCH "cmn_idsptch" +#else +#define IDSPTCH "_idsptch" +#define EIDSPTCH "_eidsptch" +#define CMN_IDSPTCH "_cmn_idsptch" +#endif + asm(" + .text .align 2 - .globl _idsptch, _eidsptch -_idsptch: + .globl " IDSPTCH ", " EIDSPTCH " +" IDSPTCH ": pushr $0x3f .word 0x9f16 - .long _cmn_idsptch + .long " CMN_IDSPTCH " .long 0 .long 0 .long 0 -_eidsptch: +" EIDSPTCH ": -_cmn_idsptch: +" CMN_IDSPTCH ": movl (sp)+,r0 pushl 4(r0) calls $1,*(r0) @@ -265,8 +242,7 @@ _cmn_idsptch: * This function must _not_ save any registers (in the reg save mask). */ void -scb_stray(arg) - int arg; +scb_stray(void *arg) { static int vector, ipl; @@ -274,4 +250,3 @@ scb_stray(arg) vector = (int) arg; printf("stray interrupt: vector 0x%x, ipl %d\n", vector, ipl); } - diff --git a/sys/arch/vax/boot/boot/boot.c b/sys/arch/vax/boot/boot/boot.c index 5b18de3404f..dd5a4756e98 100644 --- a/sys/arch/vax/boot/boot/boot.c +++ b/sys/arch/vax/boot/boot/boot.c @@ -1,5 +1,5 @@ -/* $OpenBSD: boot.c,v 1.9 2002/02/13 02:42:20 deraadt Exp $ */ -/* $NetBSD: boot.c,v 1.4 1999/10/23 14:42:22 ragge Exp $ */ +/* $OpenBSD: boot.c,v 1.10 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: boot.c,v 1.18 2002/05/31 15:58:26 ragge Exp $ */ /*- * Copyright (c) 1982, 1986 The Regents of the University of California. * All rights reserved. @@ -35,13 +35,18 @@ * @(#)boot.c 7.15 (Berkeley) 5/4/91 */ -#include "sys/param.h" -#include "sys/reboot.h" -#include "rpb.h" +#include <sys/param.h> +#include <sys/reboot.h> #include "lib/libsa/stand.h" +#ifdef notyet +#include "lib/libsa/loadfile.h" +#include "lib/libkern/libkern.h" +#endif #define V750UCODE(x) ((x>>8)&255) +#include "machine/rpb.h" + #include "vaxstand.h" /* @@ -51,16 +56,20 @@ */ char line[100]; -int devtype, bootdev, howto, debug; +int bootdev, debug; extern unsigned opendev; -extern unsigned *bootregs; -struct rpb *rpb; -void usage(), boot(), halt(); +void usage(char *), boot(char *), halt(char *); +void Xmain(void); +void autoconf(void); +int getsecs(void); +int setjmp(int *); +int testkey(void); +void loadpcs(void); -struct vals { +const struct vals { char *namn; - void (*func)(); + void (*func)(char *); char *info; } val[] = { {"?", usage, "Show this help menu"}, @@ -70,34 +79,37 @@ struct vals { {0, 0}, }; -char *filer[] = { - "bsd", - "bsd.gz", - "bsd.old", - 0, +static struct { + char name[12]; + int quiet; +} filelist[] = { + { "bsd", 0 }, + { "bsd.old", 0 }, + { "bsd.vax", 1 }, + { "bsd.gz", 0 }, + { "", 0 }, }; int jbuf[10]; -int sluttid, senast, skip; +int sluttid, senast, skip, askname; +struct rpb bootrpb; -Xmain() +void +Xmain(void) { - int io, type, filindex = 0; + int io; int j, nu; - volatile int askname; - - /* make sure the rpb is out of the way so it does not get trampled; - * this will be the case if booting from net - */ +#ifdef noyet + u_long marks[MARK_MAX]; +#endif + extern const char bootprog_rev[], bootprog_date[]; - rpb = (struct rpb *)bootregs[11]; - bootdev = rpb->devtyp; - io=0; + io = 0; skip = 1; autoconf(); - askname = howto & RB_ASKNAME; - printf("\n\r>> OpenBSD/vax boot [%s %s] <<\n", __DATE__, __TIME__); + askname = bootrpb.rpb_bootr5 & RB_ASKNAME; + printf("\n\r>> OpenBSD/vax boot [%s] [%s] <<\n", "1.9", __DATE__); printf(">> Press enter to autoboot now, or any other key to abort: "); sluttid = getsecs() + 5; senast = 0; @@ -122,25 +134,46 @@ Xmain() skip = 1; printf("\n"); + if (setjmp(jbuf)) + askname = 1; + /* 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 0 - if (testkey()) - break; + int fileindex; + for (fileindex = 0; filelist[fileindex].name[0] != '\0'; + fileindex++) { +#ifdef notyet + int err; #endif + errno = 0; + if (!filelist[fileindex].quiet) + printf("> boot %s\n", filelist[fileindex].name); + exec(filelist[fileindex].name, 0, 0); +#ifdef notyet + marks[MARK_START] = 0; + err = loadfile(filelist[fileindex].name, marks, + LOAD_KERNEL|COUNT_KERNEL); + if (err == 0) { + machdep_start((char *)marks[MARK_ENTRY], + marks[MARK_NSYM], + (void *)marks[MARK_START], + (void *)marks[MARK_SYM], + (void *)marks[MARK_END]); } +#endif + if (!filelist[fileindex].quiet) + printf("%s: boot failed: %s\n", + filelist[fileindex].name, strerror(errno)); +#if 0 /* Will hang VAX 4000 machines */ + if (testkey()) + break; +#endif + } } /* If any key pressed, go to conversational boot */ for (;;) { - struct vals *v = &val[0]; + const struct vals *v = &val[0]; char *c, *d; printf("> "); @@ -165,21 +198,23 @@ Xmain() (*v->func)(d); else printf("Unknown command: %s\n", c); - } } void -halt() +halt(char *hej) { asm("halt"); } void -boot(arg) - char *arg; +boot(char *arg) { char *fn = "bsd"; + int howto, fl, err; +#ifdef notyet + u_long marks[MARK_MAX]; +#endif if (arg) { while (*arg == ' ') @@ -195,10 +230,12 @@ boot(arg) goto load; } if (*arg != '-') { -fail: printf("usage: boot [filename] [-asd]\n"); +fail: printf("usage: boot [filename] [-acsd]\n"); return; } + howto = 0; + while (*++arg) { if (*arg == 'a') howto |= RB_ASKNAME; @@ -211,8 +248,21 @@ fail: printf("usage: boot [filename] [-asd]\n"); else goto fail; } + bootrpb.rpb_bootr5 = howto; + } +load: + exec(fn, 0, 0); +#ifdef notyet + marks[MARK_START] = 0; + err = loadfile(fn, marks, LOAD_KERNEL|COUNT_KERNEL); + if (err == 0) { + machdep_start((char *)marks[MARK_ENTRY], + marks[MARK_NSYM], + (void *)marks[MARK_START], + (void *)marks[MARK_SYM], + (void *)marks[MARK_END]); } -load: exec(fn, 0, 0); +#endif printf("Boot failed: %s\n", strerror(errno)); } @@ -230,12 +280,13 @@ load: exec(fn, 0, 0); #define extzv(one, two, three,four) \ ({ \ - asm __volatile (" extzv %0,%3,%1,(%2)+" \ + asm __volatile (" extzv %0,%3,(%1),(%2)+" \ : \ - : "g"(one),"g"(two),"r"(three),"g"(four)); \ + : "g"(one),"g"(two),"g"(three),"g"(four)); \ }) +void loadpcs() { static int pcsdone = 0; @@ -310,9 +361,9 @@ loadpcs() } void -usage() +usage(char *hej) { - struct vals *v = &val[0]; + const struct vals *v = &val[0]; printf("Commands:\n"); while (v->namn) { diff --git a/sys/arch/vax/boot/boot/conf.c b/sys/arch/vax/boot/boot/conf.c index a5a21df6d33..c08626642ec 100644 --- a/sys/arch/vax/boot/boot/conf.c +++ b/sys/arch/vax/boot/boot/conf.c @@ -1,5 +1,5 @@ -/* $OpenBSD: conf.c,v 1.2 2000/10/04 04:36:29 bjc Exp $ */ -/* $NetBSD: conf.c,v 1.3 1999/10/23 14:42:21 ragge Exp $ */ +/* $OpenBSD: conf.c,v 1.3 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: conf.c,v 1.10 2000/06/15 19:53:23 ragge Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -38,34 +38,33 @@ #include "../../include/rpb.h" +#include "lib/libkern/libkern.h" + #include "lib/libsa/stand.h" #include "lib/libsa/ufs.h" #include "lib/libsa/nfs.h" +#include "lib/libsa/cd9660.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(); +static int nostrategy(void *, int, daddr_t, size_t, void *, size_t *); struct devsw devsw[]={ SADEV("hp",hpstrategy, hpopen, nullsys, noioctl), - SADEV("qe",netstrategy, netopen, netclose, noioctl), /* DEQNA */ + SADEV("qe",nostrategy, qeopen, qeclose, noioctl), /* DEQNA */ SADEV("ctu",ctustrategy, ctuopen, nullsys, noioctl), SADEV("ra",rastrategy, raopen, nullsys, noioctl), - SADEV("mt",tmscpstrategy, tmscpopen, nullsys, noioctl), + SADEV("mt",rastrategy, raopen, nullsys, noioctl), SADEV("rom",romstrategy, romopen, nullsys, noioctl), - SADEV("rd",mfmstrategy, mfmopen, nullsys, noioctl), + SADEV("hd",mfmstrategy, mfmopen, nullsys, noioctl), SADEV("sd",romstrategy, romopen, nullsys, noioctl), - SADEV("sd",romstrategy, romopen, nullsys, noioctl), /* SDN */ + SADEV("sd",romstrategy, romopen, nullsys, noioctl), /* SDN */ SADEV("st",nullsys, nullsys, nullsys, noioctl), - SADEV("le",netstrategy, netopen, netclose, noioctl), /* LANCE */ - SADEV("ze",netstrategy, netopen, netclose, noioctl), /* SGEC */ + SADEV("le",nostrategy, leopen, leclose, noioctl), /* LANCE */ + SADEV("ze",nostrategy, zeopen, zeclose, noioctl), /* SGEC */ + SADEV("rl",romstrategy, romopen, nullsys, noioctl), + SADEV("de",nostrategy, deopen, declose, noioctl), /* DEUNA */ + SADEV("ni",nostrategy, niopen, nullsys, noioctl), /* DEBNA */ }; int cnvtab[] = { @@ -81,6 +80,9 @@ int cnvtab[] = { BDEV_ST, BDEV_LE, BDEV_ZE, + BDEV_RL, + BDEV_DE, + BDEV_NI, }; int ndevs = (sizeof(devsw)/sizeof(devsw[0])); @@ -88,18 +90,17 @@ 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 }, + { cd9660_open, cd9660_close, cd9660_read, cd9660_write, + cd9660_seek, cd9660_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])); - +int +nostrategy(void *f, int func, daddr_t dblk, + size_t size, void *buf, size_t *rsize) +{ + *rsize = size; + bzero(buf, size); + return 0; +} diff --git a/sys/arch/vax/boot/boot/consio.c b/sys/arch/vax/boot/boot/consio.c index 39775324c5b..ddfb19c8c5b 100644 --- a/sys/arch/vax/boot/boot/consio.c +++ b/sys/arch/vax/boot/boot/consio.c @@ -1,5 +1,5 @@ -/* $OpenBSD: consio.c,v 1.3 2002/03/14 01:26:47 millert Exp $ */ -/* $NetBSD: consio.c,v 1.11 2000/07/19 00:58:24 matt Exp $ */ +/* $OpenBSD: consio.c,v 1.4 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: consio.c,v 1.13 2002/05/24 21:40:59 ragge Exp $ */ /* * Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -41,68 +41,66 @@ #include "mtpr.h" #include "sid.h" #include "rpb.h" +#include "ka630.h" #include "data.h" void setup(void); -unsigned *bootregs; -extern struct rpb *rpb; -struct bqo *bqo; - -static int (*put_fp)(int) = NULL; +static void (*put_fp)(int) = NULL; static int (*get_fp)(void) = NULL; static int (*test_fp)(void) = NULL; -/* Also added such a thing for KA53 - MK-991208 */ -unsigned char *ka53_conspage; -void ka53_consinit(void); - -int ka53_rom_putchar(int c); -int ka53_rom_getchar(void); -int ka53_rom_testchar(void); - -int pr_putchar(int c); /* putchar() using mtpr/mfpr */ +void pr_putchar(int c); /* putchar() using mtpr/mfpr */ int pr_getchar(void); int pr_testchar(void); -int rom_putchar(int c); /* putchar() using ROM routines */ +void rom_putchar(int c); /* putchar() using ROM routines */ int rom_getchar(void); int rom_testchar(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 +int rom_putc; /* ROM-address of put-routine */ +int rom_getc; /* ROM-address of get-routine */ + /* Pointer to KA630 console page, initialized by ka630_consinit */ -unsigned char *ka630_conspage; +unsigned char *ka630_conspage; + /* Function that initializes things for KA630 ROM console I/O */ -void ka630_consinit(void); +void ka630_consinit __P((void)); + /* Functions that use KA630 ROM for console I/O */ -int ka630_rom_putchar(int c); -int ka630_rom_getchar(void); -int ka630_rom_testchar(void); +void ka630_rom_putchar __P((int c)); +int ka630_rom_getchar __P((void)); +int ka630_rom_testchar __P((void)); -putchar(c) - int c; +/* Also added such a thing for KA53 - MK-991208 */ +unsigned char *ka53_conspage; +void ka53_consinit(void); + +void ka53_rom_putchar(int c); +int ka53_rom_getchar(void); +int ka53_rom_testchar(void); + +void vxt_putchar(int c); +int vxt_getchar(void); +int vxt_testchar(void); + +void putchar(int); +int getchar(void); +int testkey(void); +void consinit(void); +void _rtt(void); + +void +putchar(int c) { (*put_fp)(c); if (c == 10) (*put_fp)(13); /* CR/LF */ } -getchar() +int +getchar(void) { int c; @@ -114,7 +112,8 @@ getchar() return c; } -testkey() +int +testkey(void) { return (*test_fp)(); } @@ -124,7 +123,7 @@ testkey() * initializes data which are globally used and is called before main(). */ void -consinit() +consinit(void) { put_fp = pr_putchar; /* Default */ get_fp = pr_getchar; @@ -141,14 +140,6 @@ consinit() */ switch (vax_boardtype) { - case VAX_BTYP_690: - 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: @@ -159,9 +150,15 @@ consinit() rom_getc = 0x20040044; /* 537133124 */ break; + case VAX_BTYP_VXT: + put_fp = vxt_putchar; + get_fp = vxt_getchar; + test_fp = vxt_testchar; + break; + case VAX_BTYP_630: - ka630_consinit(); - break; + ka630_consinit(); + break; case VAX_BTYP_46: case VAX_BTYP_48: @@ -193,144 +190,82 @@ consinit() /* * putchar() using MTPR */ -pr_putchar(c) - int c; +void +pr_putchar(int c) { - int timeout = 1<<15; /* don't hang the machine! */ - while ((mfpr(PR_TXCS) & GC_RDY) == 0) /* Wait until xmit ready */ + int timeout = 1<<15; /* don't hang the machine! */ + + /* + * On KA88 we may get C-S/C-Q from the console. + * Must obey it. + */ + while (mfpr(PR_RXCS) & GC_DON) { + if ((mfpr(PR_RXDB) & 0x7f) == 19) { + while (1) { + while ((mfpr(PR_RXCS) & GC_DON) == 0) + ; + if ((mfpr(PR_RXDB) & 0x7f) == 17) + break; + } + } + } + + while ((mfpr(PR_TXCS) & GC_RDY) == 0) /* Wait until xmit ready */ if (--timeout < 0) break; - mtpr(c, PR_TXDB); /* xmit character */ + mtpr(c, PR_TXDB); /* xmit character */ } /* * getchar() using MFPR */ -pr_getchar() +int +pr_getchar(void) { - while ((mfpr(PR_RXCS) & GC_DON) == 0); /* wait for char */ + while ((mfpr(PR_RXCS) & GC_DON) == 0) + ; /* wait for char */ return (mfpr(PR_RXDB)); /* now get it */ } -pr_testchar() +int +pr_testchar(void) { 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() +void ka630_consinit(void) { - register short *NVR; - register int i; + short *NVR; + int i; - /* Find the console page */ - NVR = (short *) NVR_ADRS; + /* Find the console page */ + NVR = (short *) KA630_NVR_ADRS; - i = *NVR++ & 0xFF; - i |= (*NVR++ & 0xFF) << 8; - i |= (*NVR++ & 0xFF) << 16; - i |= (*NVR++ & 0xFF) << 24; + i = *NVR++ & 0xFF; + i |= (*NVR++ & 0xFF) << 8; + i |= (*NVR++ & 0xFF) << 16; + i |= (*NVR++ & 0xFF) << 24; - ka630_conspage = (char *) i; + ka630_conspage = (char *) i; - /* Go to last row to minimize confusion */ + /* 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 */ + /* 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 -"); -/* * void ka53_consinit (void) ==> initialize KA53 ROM console I/O */ void ka53_consinit(void) @@ -342,46 +277,33 @@ void ka53_consinit(void) test_fp = ka53_rom_testchar; } -/* - * int ka53_rom_getchar (void) ==> getchar() using ROM-routines - */ +static volatile int *vxtregs = (int *)0x200A0000; -asm(" - .globl _ka53_rom_getchar - _ka53_rom_getchar: - .word 0x0802 # r1, r11 - movl _ka53_conspage, r11 # load location of console page -1: jsb *0x64(r11) # test for char - blbc r0, 1b # while r0 is 0 - jsb *0x6c(r11) # get char - ret -"); - -asm(" - .globl _ka53_rom_testchar - _ka53_rom_testchar: - .word 0x8 # r3 - movl _ka53_conspage, r3 - jsb *0x64(r3) - blbc r0, 1f - jsb *0x6c(r3) # get it -1: ret -"); - -/* - * int ka53_rom_putchar (int c) ==> putchar() using ROM-routines - */ +#define CH_SR 1 +#define CH_DAT 3 +#define SR_TX_RDY 0x04 +#define SR_RX_RDY 0x01 -asm(" - .globl _ka53_rom_putchar - _ka53_rom_putchar: - .word 0x0802 # r1, r11 - movl _ka53_conspage, r11 -1: jsb *0x20(r11) # ready to write? - blbc r0, 1b # keep going if r0 == 0 - movl 4(ap), r1 # char is in r1 - jsb *0x24(r11) # output char - ret -"); +void +vxt_putchar(int c) +{ + while ((vxtregs[CH_SR] & SR_TX_RDY) == 0) + ; + vxtregs[CH_DAT] = c; +} +int +vxt_getchar(void) +{ + while ((vxtregs[CH_SR] & SR_RX_RDY) == 0) + ; + return vxtregs[CH_DAT]; +} +int +vxt_testchar(void) +{ + if ((vxtregs[CH_SR] & SR_RX_RDY) == 0) + return 0; + return vxtregs[CH_DAT]; +} diff --git a/sys/arch/vax/boot/boot/consio2.S b/sys/arch/vax/boot/boot/consio2.S new file mode 100644 index 00000000000..a8a279e7d87 --- /dev/null +++ b/sys/arch/vax/boot/boot/consio2.S @@ -0,0 +1,128 @@ +/* $OpenBSD: consio2.S,v 1.1 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: consio2.S,v 1.1 2002/02/24 01:04:24 matt 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. + */ + +#include <machine/asm.h> + +/* + * int rom_putchar (int c) ==> putchar() using ROM-routines + */ +ENTRY(rom_putchar, 0x0004) # save-mask: R2 + movl 4(ap), r2 # move argument to R2 + jsb *_C_LABEL(rom_putc) # write it + ret # that is all + + +/* + * int rom_getchar (void) ==> getchar() using ROM-routines + */ +ENTRY(rom_getchar, 0x0002) # save-mask: R1 +loop: # do { + jsb *_C_LABEL(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 are done + +ENTRY(rom_testchar, 0) + mnegl $1,r0 + jsb *_C_LABEL(rom_getc) + tstl r0 + beql 1f + movl r1,r0 +1: ret + +ENTRY(_rtt, 0) + halt + + +/* + * int ka630_rom_getchar (void) ==> getchar() using ROM-routines on KA630 + */ +ENTRY(ka630_rom_getchar, 0x0802) # save-mask: R1, R11 + movl _C_LABEL(ka630_conspage),r11 # load location of console page +1: # do { + jsb *0x1C(r11) # call the getc-routine (KA630_GETC) + blbc r0,1b # } while (R0 == 0) + movl r1,r0 # R1 holds char + ret # we are done + +ENTRY(ka630_rom_testchar, 0) + movl _C_LABEL(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 + */ +ENTRY(ka630_rom_putchar, 0x802) # save-mask: R1, R11 + movl _C_LABEL(ka630_conspage),r11 + # load location of console page +1: # do { + jsb *0x20(r11) # is rom ready? (KA630_PUTC_POLL) + blbc r0,1b # } while (R0 == 0) + movl 4(ap),r1 # R1 holds char + jsb *0x24(r11) # output character (KA630_PUTC) + ret # we are done + +/* + * int ka53_rom_getchar (void) ==> getchar() using ROM-routines on KA53 + */ +ENTRY(ka53_rom_getchar, 0x0802) # save-mask: R1, R11 + movl _C_LABEL(ka53_conspage),r11 + # load location of console page +1: # do { + jsb *0x64(r11) # test for char + blbc r0,1b # } while (R0 == 0) + jsb *0x6c(r11) # get the char + ret # we are done + +ENTRY(ka53_rom_testchar, 0) + movl _C_LABEL(ka53_conspage),r3 + jsb *0x64(r3) + blbc r0,1f + jsb *0x6c(r3) # get the char +1: ret + +/* + * int ka53_rom_putchar (int c) ==> putchar() using ROM-routines on KA53 + */ +ENTRY(ka53_rom_putchar, 0x0802) # save-mask: R1, R11 + movl _C_LABEL(ka53_conspage),r11 + # load location of console page +1: # do { + jsb *0x20(r11) # is rom ready? + blbc r0,1b # } whi le (R0 == 0) + movl 4(ap),r1 # R1 holds char + jsb *0x24(r11) # output character + ret # we are done diff --git a/sys/arch/vax/boot/boot/ctu.c b/sys/arch/vax/boot/boot/ctu.c index acdd35a7c70..b8a9b863faf 100644 --- a/sys/arch/vax/boot/boot/ctu.c +++ b/sys/arch/vax/boot/boot/ctu.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ctu.c,v 1.2 2002/03/14 01:26:47 millert Exp $ */ -/* $NetBSD: ctu.c,v 1.1 1996/02/17 18:23:20 ragge Exp $ */ +/* $OpenBSD: ctu.c,v 1.3 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: ctu.c,v 1.3 2000/05/20 13:30:03 ragge Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -43,6 +43,10 @@ #include <machine/mtpr.h> #include <machine/rsp.h> +#include "vaxstand.h" + +static short ctu_cksum(unsigned short *, int); + enum tu_state { SC_INIT, SC_READY, @@ -78,15 +82,13 @@ ctuopen(f, adapt, ctlr, unit, part) } int -ctustrategy(ra, func, dblk, size, buf, rsize) - struct ra_softc *ra; +ctustrategy(f, func, dblk, size, buf, rsize) + void *f; int func; daddr_t dblk; - char *buf; - u_int size, *rsize; + void *buf; + size_t size, *rsize; { - int s; - struct rsp *rsp = (struct rsp *)tu_sc.sc_rsp; tu_sc.sc_xfptr = buf; @@ -101,7 +103,7 @@ ctustrategy(ra, func, dblk, size, buf, rsize) 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); + rsp->rsp_sum = ctu_cksum((u_short *)rsp, 6); tu_sc.sc_state = SC_SEND_CMD; while (tu_sc.sc_state != SC_GET_RESP) ctutintr(); @@ -144,7 +146,9 @@ cturintr() break; tu_sc.sc_xfptr[tu_sc.sc_xbytes++] = status; break; - + case SC_READY: + case SC_SEND_CMD: + break; } } @@ -165,6 +169,7 @@ ctutintr() } } +short ctu_cksum(buf, words) unsigned short *buf; int words; diff --git a/sys/arch/vax/boot/boot/data.h b/sys/arch/vax/boot/boot/data.h index 9098d501d70..e91bfaf789d 100644 --- a/sys/arch/vax/boot/boot/data.h +++ b/sys/arch/vax/boot/boot/data.h @@ -1,5 +1,5 @@ -/* $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 $ */ +/* $OpenBSD: data.h,v 1.2 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: data.h,v 1.3 2001/07/26 15:05:09 wiz Exp $ */ /* * Copyright (c) 1995 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -38,8 +38,6 @@ -extern unsigned *bootregs; - /* * rpb->iovec gives pointer to this structure. * @@ -67,7 +65,7 @@ struct bqo { long umr_tmpl; /* 4 UNIBUS map register template */ /* offset: 60 */ /* - * the rest is unknown / unneccessary ... + * the rest is unknown / unnecessary ... */ long xxx[6]; /* 24 -- total: 84 bytes */ }; diff --git a/sys/arch/vax/boot/boot/devopen.c b/sys/arch/vax/boot/boot/devopen.c index dac5993df30..5cb9ade2994 100644 --- a/sys/arch/vax/boot/boot/devopen.c +++ b/sys/arch/vax/boot/boot/devopen.c @@ -1,5 +1,5 @@ -/* $OpenBSD: devopen.c,v 1.2 2000/10/04 04:09:01 bjc Exp $ */ -/* $NetBSD: devopen.c,v 1.2 1999/06/30 18:30:42 ragge Exp $ */ +/* $OpenBSD: devopen.c,v 1.3 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: devopen.c,v 1.10 2002/05/24 21:40:59 ragge Exp $ */ /* * Copyright (c) 1997 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -31,14 +31,20 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <sys/reboot.h> - #include "lib/libsa/stand.h" + +#include "machine/rpb.h" +#include "machine/sid.h" +#include "machine/pte.h" +#define VAX780 1 +#include "machine/ka750.h" + +#include "arch/vax/bi/bireg.h" + #include "vaxstand.h" -#include "rpb.h" -unsigned int opendev; -extern struct rpb *rpb; +int atoi(char *); +int nexaddr, csrbase; int devopen(f, fname, file) @@ -46,21 +52,33 @@ devopen(f, fname, file) const char *fname; char **file; { - int dev, ctlr, unit, part, adapt, i, a[4], x; + int dev, unit, ctlr, part, adapt, i, a[4], x; + int *mapregs; struct devsw *dp; extern int cnvtab[]; - char *s, *c, *u; + char *s, *c; + + part = 0; + + /* + * Adaptor and controller are normally zero (or uninteresting), + * but we need to do some conversion here anyway (if it's a + * manual boot, but that's checked by the device driver). + * Set them to -1 to tell if it's a set number or default. + */ + dev = bootrpb.devtyp; + unit = bootrpb.unit; + adapt = ctlr = -1; - dev = rpb->devtyp; - unit = rpb->unit; - adapt = ctlr = part = 0; + if (dev == BDEV_KDB) + dev = BDEV_UDA; /* use the same driver */ for (i = 0, dp = 0; i < ndevs; i++) if (cnvtab[i] == dev) dp = devsw + i; x = 0; - if ((s = index(fname, '('))) { + if ((s = index((char *)fname, '('))) { *s++ = 0; for (i = 0, dp = devsw; i < ndevs; i++, dp++) @@ -99,29 +117,87 @@ devopen(f, fname, file) if (x > 3) adapt = a[0]; *file = c; - - x = 1; } else { *file = (char *)fname; c = (char *)fname; } - if (!dp->dv_open) + if (!dp->dv_open) { + printf("Can't open device type %d\n", dev); return(ENODEV); + } f->f_dev = dp; - - 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); - - if(x == 0) { - dev = rpb->devtyp; /* dv_open may have modified rpb */ - unit = rpb->unit; + bootrpb.unit = unit; + bootrpb.devtyp = dev; + + nexaddr = bootrpb.adpphy; + switch (vax_boardtype) { + case VAX_BTYP_750: + csrbase = (nexaddr == 0xf30000 ? 0xffe000 : 0xfbe000); + if (adapt < 0) + break; + nexaddr = (NEX750 + NEXSIZE * adapt); + csrbase = (adapt == 8 ? 0xffe000 : 0xfbe000); + break; + case VAX_BTYP_780: + case VAX_BTYP_790: + csrbase = 0x2007e000 + 0x40000 * ((nexaddr & 0x1e000) >> 13); + if (adapt < 0) + break; + nexaddr = ((int)NEX780 + NEXSIZE * adapt); + csrbase = 0x2007e000 + 0x40000 * adapt; + break; + case VAX_BTYP_9CC: /* 6000/200 */ + case VAX_BTYP_9RR: /* 6000/400 */ + case VAX_BTYP_1202: /* 6000/500 */ + csrbase = 0; + if (ctlr < 0) + ctlr = bootrpb.adpphy & 15; + if (adapt < 0) + adapt = (bootrpb.adpphy >> 4) & 15; + nexaddr = BI_BASE(adapt, ctlr); + break; + + case VAX_BTYP_8000: + case VAX_BTYP_8800: + case VAX_BTYP_8PS: + csrbase = 0; /* _may_ be a KDB */ + nexaddr = bootrpb.csrphy; + if (ctlr < 0) + break; + if (adapt < 0) + nexaddr = (nexaddr & 0xff000000) + BI_NODE(ctlr); + else + nexaddr = BI_BASE(adapt, ctlr); + break; + case VAX_BTYP_610: + nexaddr = 0; /* No map regs */ + csrbase = 0x20000000; + break; + + case VAX_BTYP_VXT: + nexaddr = 0; + csrbase = bootrpb.csrphy; + break; + default: + nexaddr = 0; /* No map regs */ + csrbase = 0x20000000; + /* Always map in the lowest 4M on qbus-based machines */ + mapregs = (void *)0x20088000; + if (bootrpb.adpphy == 0x20087800) + for (i = 0; i < 8192; i++) + mapregs[i] = PG_V | i; + break; } - opendev = MAKEBOOTDEV(dev, adapt, ctlr, unit, part); - return i; +#ifdef DEV_DEBUG + printf("rpb.type %d rpb.unit %d rpb.csr %lx rpb.adp %lx\n", + bootrpb.devtyp, bootrpb.unit, bootrpb.csrphy, bootrpb.adpphy); + printf("adapter %d ctlr %d unit %d part %d\n", adapt, ctlr, unit, part); + printf("nexaddr %x csrbase %x\n", nexaddr, csrbase); +#endif + + return (*dp->dv_open)(f, adapt, ctlr, unit, part); usage: printf("usage: dev(adapter,controller,unit,partition)file -asd\n"); diff --git a/sys/arch/vax/boot/boot/hp.c b/sys/arch/vax/boot/boot/hp.c index 30f29ae1101..a45e4ae3687 100644 --- a/sys/arch/vax/boot/boot/hp.c +++ b/sys/arch/vax/boot/boot/hp.c @@ -1,5 +1,5 @@ -/* $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 $ */ +/* $OpenBSD: hp.c,v 1.2 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: hp.c,v 1.5 2000/07/19 00:58:25 matt Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -40,7 +40,11 @@ #include "lib/libsa/stand.h" #include "../include/pte.h" -/*#include "../include/macros.h"*/ +#include "../include/rpb.h" +#include "../include/sid.h" +#define VAX780 1 +struct proc; +#include "../include/ka750.h" #include "../mba/mbareg.h" #include "../mba/hpreg.h" @@ -54,113 +58,97 @@ * 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; +static struct disklabel hplabel; +static char io_buf[DEV_BSIZE]; +static int dpart; +static int adpadr, unitadr; + +#define MBA_WCSR(reg, val) \ + ((void)(*(volatile u_int32_t *)((adpadr) + (reg)) = (val))); +#define MBA_RCSR(reg) \ + (*(volatile u_int32_t *)((adpadr) + (reg))) +#define HP_WCSR(reg, val) \ + ((void)(*(volatile u_int32_t *)((unitadr) + (reg)) = (val))); +#define HP_RCSR(reg) \ + (*(volatile u_int32_t *)((unitadr) + (reg))) + +int +hpopen(struct open_file *f, int adapt, int ctlr, int unit, int 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)); + int err; + size_t i; + + if (askname == 0) { /* Take info from RPB */ + adpadr = bootrpb.adpphy; + unitadr = adpadr + MUREG(bootrpb.unit, 0); + } else { + adpadr = nexaddr; + unitadr = adpadr + MUREG(unit, 0); + bootrpb.adpphy = adpadr; + bootrpb.unit = unit; + } + bzero(&hplabel, sizeof(struct disklabel)); - lp->d_secpercyl = 32; - lp->d_nsectors = 32; - hs->adapt = adapt; - hs->ctlr = ctlr; - hs->unit = unit; - hs->part = part; + hplabel.d_secpercyl = 32; + hplabel.d_nsectors = 32; /* 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; + MBA_WCSR(MBA_CR, MBACR_INIT); + HP_WCSR(HP_CS1, HPCS_PA); + HP_WCSR(HP_OF, HPOF_FMT); - err = hpstrategy(hs, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); + err = hpstrategy(0, 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); + msg = getdisklabel(io_buf + LABELOFFSET, &hplabel); 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; +int +hpstrategy(void *f, int func, daddr_t dblk, + size_t size, void *buf, size_t *rsize) { - 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; + unsigned int pfnum, mapnr, nsize, bn, cn, sn, tn; 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++; + for(mapnr = 0, nsize = size; (nsize + VAX_NBPG) > 0; + nsize -= VAX_NBPG, mapnr++, pfnum++) + MBA_WCSR(MAPREG(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; + MBA_WCSR(MBA_VAR, ((u_int)buf & VAX_PGOFSET)); + MBA_WCSR(MBA_BC, (~size) + 1); + bn = dblk + hplabel.d_partitions[dpart].p_offset; if (bn) { - cn = bn / lp->d_secpercyl; - sn = bn % lp->d_secpercyl; - tn = sn / lp->d_nsectors; - sn = sn % lp->d_nsectors; + cn = bn / hplabel.d_secpercyl; + sn = bn % hplabel.d_secpercyl; + tn = sn / hplabel.d_nsectors; + sn = sn % hplabel.d_nsectors; } else cn = sn = tn = 0; - hd->hp_dc = cn; - hd->hp_da = (tn << 8) | sn; + HP_WCSR(HP_DC, cn); + HP_WCSR(HP_DA, (tn << 8) | sn); +#ifdef notdef if (func == F_WRITE) - hd->hp_cs1 = HPCS_WRITE; + HP_WCSR(HP_CS1, HPCS_WRITE); else - hd->hp_cs1 = HPCS_READ; +#endif + HP_WCSR(HP_CS1, HPCS_READ); - while (mr->mba_sr & MBASR_DTBUSY) + while (MBA_RCSR(MBA_SR) & MBASR_DTBUSY) ; - if (mr->mba_sr & MBACR_ABORT) + if (MBA_RCSR(MBA_SR) & MBACR_ABORT) return 1; - - *rsize = size; + *rsize = size; return 0; } diff --git a/sys/arch/vax/boot/boot/if_de.c b/sys/arch/vax/boot/boot/if_de.c new file mode 100644 index 00000000000..b48d816c75f --- /dev/null +++ b/sys/arch/vax/boot/boot/if_de.c @@ -0,0 +1,290 @@ +/* $OpenBSD: if_de.c,v 1.1 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: if_de.c,v 1.2 2002/05/24 21:41:40 ragge Exp $ */ + +/* + * Copyright (c) 2000 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 the DEUNA Ethernet controller. + */ + +#include <sys/param.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/queue.h> + +#include <net/if.h> + +#include <netinet/in.h> +#include <netinet/in_systm.h> +#include <netinet/if_ether.h> + +#include <lib/libsa/netif.h> +#include <lib/libsa/stand.h> + +#include <arch/vax/qbus/if_dereg.h> + +#include "arch/vax/include/sid.h" +#include "arch/vax/include/rpb.h" +#include "arch/vax/include/pte.h" + +#include "vaxstand.h" + +static int de_get(struct iodesc *, void *, size_t, time_t); +static int de_put(struct iodesc *, void *, size_t); +static void dewait(char *); + +struct netif_driver de_driver = { + 0, 0, 0, 0, de_get, de_put, +}; + +#define NRCV 8 /* allocate 8 receive descriptors */ +#define NXMT 4 /* and 4 transmit - must be >1 */ + +struct de_cdata { + /* the following structures are always mapped in */ + struct de_pcbb dc_pcbb; /* port control block */ + struct de_ring dc_xrent[NXMT]; /* transmit ring entrys */ + struct de_ring dc_rrent[NRCV]; /* receive ring entrys */ + struct de_udbbuf dc_udbbuf; /* UNIBUS data buffer */ + char dc_rbuf[NRCV][ETHER_MAX_LEN]; + char dc_xbuf[NXMT][ETHER_MAX_LEN]; + /* end mapped area */ +}; + +static volatile struct de_cdata *dc, *pdc; +static volatile char *addr; +static int crx, ctx; +#define DE_WCSR(csr, val) *(volatile u_short *)(addr + (csr)) = (val) +#define DE_WLOW(val) *(volatile u_char *)(addr + DE_PCSR0) = (val) +#define DE_WHIGH(val) *(volatile u_char *)(addr + DE_PCSR0 + 1) = (val) +#define DE_RCSR(csr) *(volatile u_short *)(addr + (csr)) +#define LOWORD(x) ((u_int)(x) & 0xffff) +#define HIWORD(x) (((u_int)(x) >> 16) & 0x3) +#define dereg(x) ((x) & 017777) + +int +deopen(struct open_file *f, int adapt, int ctlr, int unit, int part) +{ + int i, cdata, *map, npgs; + char eaddr[6]; + + /* point to the device in memory */ + if (askname == 0) /* Override if autoboot */ + addr = (char *)bootrpb.csrphy; + else { + addr = (char *)csrbase + dereg(0174510); + bootrpb.csrphy = (int)addr; + } +#ifdef DEV_DEBUG + printf("deopen: csrbase %x addr %p nexaddr %x\n", + csrbase, addr, nexaddr); +#endif + /* reset the device and wait for completion */ + DE_WCSR(DE_PCSR0, 0); + {volatile int j = 100; while (--j);} + DE_WCSR(DE_PCSR0, PCSR0_RSET); + dewait("reset"); + + /* Map in the control structures and buffers */ + dc = alloc(sizeof(struct de_cdata)); + (int)pdc = (int)dc & VAX_PGOFSET; + map = (int *)nexaddr + 512; + npgs = (sizeof(struct de_cdata) >> VAX_PGSHIFT) + 1; + cdata = (int)dc >> VAX_PGSHIFT; + for (i = 0; i < npgs; i++) { + map[i] = PG_V | (cdata + i); + } + + bzero((char *)dc, sizeof(struct de_cdata)); + + /* Tell the DEUNA about our PCB */ + DE_WCSR(DE_PCSR2, LOWORD(pdc)); + DE_WCSR(DE_PCSR3, HIWORD(pdc)); + DE_WLOW(CMD_GETPCBB); + dewait("pcbb"); + + /* Get our address */ + dc->dc_pcbb.pcbb0 = FC_RDPHYAD; + DE_WLOW(CMD_GETCMD); + dewait("read physaddr"); + bcopy((char *)&dc->dc_pcbb.pcbb2, eaddr, 6); + + /* Create and link the descriptors */ + for (i=0; i < NRCV; i++) { + volatile struct de_ring *rp = &dc->dc_rrent[i]; + + rp->r_lenerr = 0; + rp->r_segbl = LOWORD(&pdc->dc_rbuf[i][0]); + rp->r_segbh = HIWORD(&pdc->dc_rbuf[i][0]); + rp->r_flags = RFLG_OWN; + rp->r_slen = ETHER_MAX_LEN; + } + for (i=0; i < NXMT; i++) { + volatile struct de_ring *rp = &dc->dc_xrent[i]; + + rp->r_segbl = LOWORD(&pdc->dc_xbuf[i][0]); + rp->r_segbh = HIWORD(&pdc->dc_xbuf[i][0]); + rp->r_tdrerr = 0; + rp->r_flags = 0; + } + crx = ctx = 0; + + /* set the transmit and receive ring header addresses */ + dc->dc_pcbb.pcbb0 = FC_WTRING; + dc->dc_pcbb.pcbb2 = LOWORD(&pdc->dc_udbbuf); + dc->dc_pcbb.pcbb4 = HIWORD(&pdc->dc_udbbuf); + + dc->dc_udbbuf.b_tdrbl = LOWORD(&pdc->dc_xrent[0]); + dc->dc_udbbuf.b_tdrbh = HIWORD(&pdc->dc_xrent[0]); + dc->dc_udbbuf.b_telen = sizeof (struct de_ring) / sizeof(u_int16_t); + dc->dc_udbbuf.b_trlen = NXMT; + dc->dc_udbbuf.b_rdrbl = LOWORD(&pdc->dc_rrent[0]); + dc->dc_udbbuf.b_rdrbh = HIWORD(&pdc->dc_rrent[0]); + dc->dc_udbbuf.b_relen = sizeof (struct de_ring) / sizeof(u_int16_t); + dc->dc_udbbuf.b_rrlen = NRCV; + + DE_WLOW(CMD_GETCMD); + dewait("wtring"); + + dc->dc_pcbb.pcbb0 = FC_WTMODE; + dc->dc_pcbb.pcbb2 = MOD_DRDC|MOD_TPAD|MOD_HDX; + DE_WLOW(CMD_GETCMD); + dewait("wtmode"); + + DE_WLOW(CMD_START); + dewait("start"); + + DE_WLOW(CMD_PDMD); + dewait("initpoll"); + /* Should be running by now */ + + net_devinit(f, &de_driver, eaddr); + + return 0; +} + +int +de_get(struct iodesc *desc, void *pkt, size_t maxlen, time_t timeout) +{ + volatile int to = 100000 * timeout; + int len, csr0; + + if ((csr0 = DE_RCSR(DE_PCSR0)) & PCSR0_INTR) + DE_WHIGH(csr0 >> 8); +retry: + if (to-- == 0) + return 0; + + if (dc->dc_rrent[crx].r_flags & RFLG_OWN) + goto retry; + + if (dc->dc_rrent[crx].r_flags & RFLG_ERRS) + len = 0; + else + len = dc->dc_rrent[crx].r_lenerr & RERR_MLEN; + + if (len > maxlen) + len = maxlen; + if (len) + bcopy((char *)&dc->dc_rbuf[crx][0], pkt, len); + + dc->dc_rrent[crx].r_flags = RFLG_OWN; + dc->dc_rrent[crx].r_lenerr = 0; +#ifdef DEV_DEBUG + printf("Got packet: len %d idx %d maxlen %ld\n", len, crx, maxlen); +#endif + if (++crx == NRCV) + crx = 0; + + if (len == 0) + goto retry; + return len; +} + + +int +de_put(struct iodesc *desc, void *pkt, size_t len) +{ + volatile int to = 100000; + int csr0; + + if ((csr0 = DE_RCSR(DE_PCSR0)) & PCSR0_INTR) + DE_WHIGH(csr0 >> 8); +#ifdef DEV_DEBUG + printf("de_put: len %ld\n", len); +#endif +retry: + if (to-- == 0) + return -1; + + if (dc->dc_xrent[ctx].r_flags & RFLG_OWN) + goto retry; + + bcopy(pkt, (char *)&dc->dc_xbuf[ctx][0], len); + + dc->dc_xrent[ctx].r_slen = len; + dc->dc_xrent[ctx].r_tdrerr = 0; + dc->dc_xrent[ctx].r_flags = XFLG_OWN|XFLG_STP|XFLG_ENP; + + DE_WLOW(CMD_PDMD); + dewait("start"); + + if (++ctx == NXMT) + ctx = 0; + return len; +} + +int +declose(struct open_file *f) +{ + DE_WCSR(DE_PCSR0, PCSR0_RSET); + dewait("close"); + return 0; +} + +void +dewait(char *fn) +{ + int csr0; + +#ifdef DEV_DEBUG + printf("dewait: %s...", fn); +#endif + while ((DE_RCSR(DE_PCSR0) & PCSR0_INTR) == 0) + ; + csr0 = DE_RCSR(DE_PCSR0); + DE_WHIGH(csr0 >> 8); +#ifdef DEV_DEBUG + if (csr0 & PCSR0_PCEI) + printf("failed! CSR0 %x", csr0); + else + printf("done"); + printf(", PCSR1 %x\n", DE_RCSR(DE_PCSR1)); +#endif +} diff --git a/sys/arch/vax/boot/boot/if_le.c b/sys/arch/vax/boot/boot/if_le.c index 31fb9f756b1..2c32d88948c 100644 --- a/sys/arch/vax/boot/boot/if_le.c +++ b/sys/arch/vax/boot/boot/if_le.c @@ -1,5 +1,5 @@ -/* $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 $ */ +/* $OpenBSD: if_le.c,v 1.2 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: if_le.c,v 1.6 2000/05/20 13:30:03 ragge Exp $ */ /* * Copyright (c) 1997, 1999 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -47,13 +47,17 @@ #include <netinet/if_ether.h> #include <../include/sid.h> +#include <../include/rpb.h> #include <lib/libsa/netif.h> +#include <lib/libsa/stand.h> #include <dev/ic/am7990reg.h> +#include "vaxstand.h" + /* - * The following are incorrect. Why doesn't DEC follow its own specs??? + * Buffer sizes. */ #define TLEN 1 #define NTBUF (1 << TLEN) @@ -62,23 +66,16 @@ #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; +#define QW_ALLOC(x) (((int)alloc((x) + 7) + 7) & ~7) -struct netif_dif le_ifs[] = { -/* dif_unit dif_nsel dif_stats dif_private */ -{ 0, 1, &le_stats, }, -}; - -struct netif_stats le_stats; +static int le_get(struct iodesc *, void *, size_t, time_t); +static int le_put(struct iodesc *, void *, size_t); +static void copyout(void *from, int dest, int len); +static void copyin(int src, void *to, int len); struct netif_driver le_driver = { - "le", le_match, le_probe, le_init, le_get, le_put, le_end, le_ifs, 1, + 0, 0, 0, 0, le_get, le_put, }; /* @@ -98,7 +95,7 @@ struct nireg { volatile u_short ni_rdp; /* data port */ volatile short ni_pad0; volatile short ni_rap; /* register select port */ -} *nireg = (struct nireg *)0x200e0000; +} *nireg; volatile struct buffdesc { @@ -138,27 +135,11 @@ int next_rdesc, next_tdesc; (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; +leopen(struct open_file *f, int adapt, int ctlr, int unit, int part) { - int stat, i, *ea; + int i, *ea; volatile int to = 100000; + u_char eaddr[6]; next_rdesc = next_tdesc = 0; @@ -170,7 +151,12 @@ le_init(desc, machdep_hint) } else { *(int *)0x20080014 = 0; /* Be sure we do DMA in low 16MB */ ea = (void *)0x20090000; /* XXX ethernetadressen */ + nireg = (void *)0x200e0000; } + if (askname == 0) /* Override if autoboot */ + nireg = (void *)bootrpb.csrphy; + else /* Tell kernel from where we booted */ + bootrpb.csrphy = (int)nireg; if (vax_boardtype == VAX_BTYP_43) addoff = 0x28000000; @@ -182,12 +168,13 @@ igen: ; for (i = 0; i < 6; i++) - desc->myea[i] = ea[i] & 0377; + eaddr[i] = ea[i] & 0377; if (initblock == NULL) { - initblock = (void *)QW_ALLOC(sizeof(struct initblock)) + addoff; + (void *)initblock = + (char *)QW_ALLOC(sizeof(struct initblock)) + addoff; initblock->ib_mode = LE_MODE_NORMAL; - bcopy(desc->myea, initblock->ib_padr, 6); + bcopy(eaddr, initblock->ib_padr, 6); initblock->ib_ladrf1 = 0; initblock->ib_ladrf2 = 0; @@ -210,7 +197,7 @@ igen: rdesc[i].bd_mcnt = 0; } if (kopiera) - copyout(rdesc, (int)rdesc - (int)initblock, + copyout((void *)rdesc, (int)rdesc - (int)initblock, sizeof(struct buffdesc) * NRBUF); for (i = 0; i < NTBUF; i++) { @@ -221,7 +208,7 @@ igen: tdesc[i].bd_mcnt = 0; } if (kopiera) - copyout(tdesc, (int)tdesc - (int)initblock, + copyout((void *)tdesc, (int)tdesc - (int)initblock, sizeof(struct buffdesc) * NTBUF); } @@ -246,14 +233,13 @@ igen: } LEWRCSR(LE_CSR0, LE_C0_INEA | LE_C0_STRT | LE_C0_IDON); + + net_devinit(f, &le_driver, eaddr); + return 0; } int -le_get(desc, pkt, maxlen, timeout) - struct iodesc *desc; - void *pkt; - int maxlen; - time_t timeout; +le_get(struct iodesc *desc, void *pkt, size_t maxlen, time_t timeout) { int csr, len; volatile int to = 100000 * timeout; @@ -267,7 +253,7 @@ retry: if (kopiera) copyin((int)&rdesc[next_rdesc] - (int)initblock, - &rdesc[next_rdesc], sizeof(struct buffdesc)); + (void *)&rdesc[next_rdesc], sizeof(struct buffdesc)); if (rdesc[next_rdesc].bd_adrflg & BR_OWN) goto retry; @@ -281,14 +267,14 @@ retry: copyin((rdesc[next_rdesc].bd_adrflg&0xffffff), pkt, len); else - bcopy((void *)(rdesc[next_rdesc].bd_adrflg&0xffffff) + + bcopy((char *)(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] - + copyout((void *)&rdesc[next_rdesc], (int)&rdesc[next_rdesc] - (int)initblock, sizeof(struct buffdesc)); if (++next_rdesc >= NRBUF) next_rdesc = 0; @@ -300,10 +286,7 @@ retry: } int -le_put(desc, pkt, len) - struct iodesc *desc; - void *pkt; - int len; +le_put(struct iodesc *desc, void *pkt, size_t len) { volatile int to = 100000; int csr; @@ -317,21 +300,21 @@ retry: if (kopiera) copyin((int)&tdesc[next_tdesc] - (int)initblock, - &tdesc[next_tdesc], sizeof(struct buffdesc)); + (void *)&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) + + bcopy(pkt, (char *)(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] - + copyout((void *)&tdesc[next_tdesc], (int)&tdesc[next_tdesc] - (int)initblock, sizeof(struct buffdesc)); LEWRCSR(LE_CSR0, LE_C0_TDMD); @@ -350,17 +333,18 @@ retry: return -1; } -void -le_end() +int +leclose(struct open_file *f) { LEWRCSR(LE_CSR0, LE_C0_STOP); + + return 0; } void -copyout(from, dest, len) - short *from; - int dest, len; +copyout(void *f, int dest, int len) { + short *from = f; short *toaddr; toaddr = (short *)0x20120000 + dest; @@ -373,10 +357,9 @@ copyout(from, dest, len) } void -copyin(src, to, len) - short *to; - int src, len; +copyin(int src, void *f, int len) { + short *to = f; short *fromaddr; fromaddr = (short *)0x20120000 + src; diff --git a/sys/arch/vax/boot/boot/if_ni.c b/sys/arch/vax/boot/boot/if_ni.c new file mode 100644 index 00000000000..76f3477eb65 --- /dev/null +++ b/sys/arch/vax/boot/boot/if_ni.c @@ -0,0 +1,534 @@ +/* $OpenBSD: if_ni.c,v 1.1 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: if_ni.c,v 1.2 2000/07/10 10:40:38 ragge Exp $ */ +/* + * Copyright (c) 2000 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 DEBNA Ethernet controller. + */ + +#include <sys/param.h> +#include <sys/types.h> +#include <sys/queue.h> +#include <sys/socket.h> + +#include <net/if.h> + +#include <netinet/in.h> +#include <netinet/in_systm.h> +#include <netinet/if_ether.h> + +#include <../include/sid.h> +#include <../include/rpb.h> +#include <../include/pte.h> +#include <../include/macros.h> +#include <../include/mtpr.h> +#include <../include/scb.h> + +#include <lib/libkern/libkern.h> + +#include <lib/libsa/netif.h> +#include <lib/libsa/stand.h> +#include <lib/libsa/net.h> + +#include <arch/vax/bi/bireg.h> + +#include "vaxstand.h" + +#undef NIDEBUG +/* + * Tunable buffer parameters. Good idea to have them as power of 8; then + * they will fit into a logical VAX page. + */ +#define NMSGBUF 8 /* Message queue entries */ +#define NTXBUF 16 /* Transmit queue entries */ +#define NTXFRAGS 1 /* Number of transmit buffer fragments */ +#define NRXBUF 24 /* Receive queue entries */ +#define NBDESCS (NTXBUF + NRXBUF) +#define NQUEUES 3 /* RX + TX + MSG */ +#define PKTHDR 18 /* Length of (control) packet header */ +#define RXADD 18 /* Additional length of receive datagram */ +#define TXADD 18 /* "" transmit "" */ +#define MSGADD 134 /* "" message "" */ + +#include <arch/vax/bi/if_nireg.h> + + +#define SPTSIZ 16384 /* 8MB */ +#define roundpg(x) (((int)x + VAX_PGOFSET) & ~VAX_PGOFSET) +#define ALLOC(x) \ + allocbase;xbzero((caddr_t)allocbase,x);allocbase+=roundpg(x); +#define nipqb (&gvppqb->nc_pqb) +#define gvp gvppqb +#define NI_WREG(csr, val) *(volatile long *)(niaddr + (csr)) = (val) +#define NI_RREG(csr) *(volatile long *)(niaddr + (csr)) +#define DELAY(x) {volatile int i = x * 3;while (--i);} +#define WAITREG(csr,val) while (NI_RREG(csr) & val); + +static int ni_get(struct iodesc *, void *, size_t, time_t); +static int ni_put(struct iodesc *, void *, size_t); + +static int *syspte, allocbase, niaddr; +static struct ni_gvppqb *gvppqb; +static struct ni_fqb *fqb; +static struct ni_bbd *bbd; +static char enaddr[6]; +static int beenhere = 0; + +struct netif_driver ni_driver = { + 0, 0, 0, 0, ni_get, ni_put, +}; + +static void +xbzero(char *a, int s) +{ + while (s--) + *a++ = 0; +} + +static int +failtest(int reg, int mask, int test, char *str) +{ + int i = 100; + + do { + DELAY(100000); + } while (((NI_RREG(reg) & mask) != test) && --i); + + if (i == 0) { + printf("ni: %s\n", str); + return 1; + } + return 0; +} + +static int +INSQTI(void *e, void *h) +{ + int ret; + + while ((ret = insqti(e, h)) == ILCK_FAILED) + ; + return ret; +} + +static void * +REMQHI(void *h) +{ + void *ret; + + while ((ret = remqhi(h)) == (void *)ILCK_FAILED) + ; + return ret; +} + +static void +puton(void *pkt, void *q, int args) +{ + INSQTI(pkt, q); + + WAITREG(NI_PCR, PCR_OWN); + NI_WREG(NI_PCR, args); + WAITREG(NI_PCR, PCR_OWN); +} + +static void +remput(void *fq, void *pq, int args) +{ + struct ni_dg *data; + int res; + + while ((data = REMQHI(fq)) == 0) + ; + + res = INSQTI(data, pq); + if (res == Q_EMPTY) { + WAITREG(NI_PCR, PCR_OWN); + NI_WREG(NI_PCR, args); + } +} + +static void +insput(void *elem, void *q, int args) +{ + int res; + + res = INSQTI(elem, q); + if (res == Q_EMPTY) { + WAITREG(NI_PCR, PCR_OWN); + NI_WREG(NI_PCR, args); + } +} + +int +niopen(struct open_file *f, int adapt, int ctlr, int unit, int part) +{ + struct ni_dg *data; + struct ni_msg *msg; + struct ni_ptdb *ptdb; + int i, va, res; + + if (beenhere++ && askname == 0) + return 0; + + niaddr = nexaddr & ~(BI_NODESIZE - 1); + bootrpb.csrphy = niaddr; + if (adapt >= 0) + bootrpb.adpphy = adapt; + /* + * We need a bunch of memory, take it from our load + * address plus 1M. + */ + allocbase = RELOC + 1024 * 1024; + /* + * First create a SPT for the first 8MB of physmem. + */ + syspte = (int *)ALLOC(SPTSIZ*4); + for (i = 0; i < SPTSIZ; i++) + syspte[i] = PG_V|PG_RW|i; + + + gvppqb = (struct ni_gvppqb *)ALLOC(sizeof(struct ni_gvppqb)); + fqb = (struct ni_fqb *)ALLOC(sizeof(struct ni_fqb)); + bbd = (struct ni_bbd *)ALLOC(sizeof(struct ni_bbd) * NBDESCS); + + /* Init the PQB struct */ + nipqb->np_spt = nipqb->np_gpt = (int)syspte; + nipqb->np_sptlen = nipqb->np_gptlen = SPTSIZ; + nipqb->np_vpqb = (u_int32_t)gvp; + nipqb->np_bvplvl = 1; + nipqb->np_vfqb = (u_int32_t)fqb; + nipqb->np_vbdt = (u_int32_t)bbd; + nipqb->np_nbdr = NBDESCS; + + /* Free queue block */ + nipqb->np_freeq = NQUEUES; + fqb->nf_mlen = PKTHDR+MSGADD; + fqb->nf_dlen = PKTHDR+TXADD; + fqb->nf_rlen = PKTHDR+RXADD; +#ifdef NIDEBUG + printf("niopen: syspte %p gvp %p fqb %p bbd %p\n", + syspte, gvppqb, fqb, bbd); +#endif + + NI_WREG(BIREG_VAXBICSR, NI_RREG(BIREG_VAXBICSR) | BICSR_NRST); + DELAY(500000); + i = 20; + while ((NI_RREG(BIREG_VAXBICSR) & BICSR_BROKE) && --i) + DELAY(500000); +#ifdef NIDEBUG + if (i == 0) { + printf("ni: BROKE bit set after reset\n"); + return 1; + } +#endif + /* Check state */ + if (failtest(NI_PSR, PSR_STATE, PSR_UNDEF, "not undefined state")) + return 1; + + /* Clear owner bits */ + NI_WREG(NI_PSR, NI_RREG(NI_PSR) & ~PSR_OWN); + NI_WREG(NI_PCR, NI_RREG(NI_PCR) & ~PCR_OWN); + + /* kick off init */ + NI_WREG(NI_PCR, (int)gvppqb | PCR_INIT | PCR_OWN); + while (NI_RREG(NI_PCR) & PCR_OWN) + DELAY(100000); + + /* Check state */ + if (failtest(NI_PSR, PSR_INITED, PSR_INITED, "failed initialize")) + return 1; + + NI_WREG(NI_PSR, NI_RREG(NI_PSR) & ~PSR_OWN); + WAITREG(NI_PCR, PCR_OWN); + NI_WREG(NI_PCR, PCR_OWN|PCR_ENABLE); + WAITREG(NI_PCR, PCR_OWN); + WAITREG(NI_PSR, PSR_OWN); + + /* Check state */ + if (failtest(NI_PSR, PSR_STATE, PSR_ENABLED, "failed enable")) + return 1; + + NI_WREG(NI_PSR, NI_RREG(NI_PSR) & ~PSR_OWN); + +#ifdef NIDEBUG + printf("Set up message free queue\n"); +#endif + + /* Set up message free queue */ + va = ALLOC(NMSGBUF * 512); + for (i = 0; i < NMSGBUF; i++) { + msg = (void *)(va + i * 512); + + res = INSQTI(msg, &fqb->nf_mforw); + } + WAITREG(NI_PCR, PCR_OWN); + NI_WREG(NI_PCR, PCR_FREEQNE|PCR_MFREEQ|PCR_OWN); + WAITREG(NI_PCR, PCR_OWN); + +#ifdef NIDEBUG + printf("Set up xmit queue\n"); +#endif + + /* Set up xmit queue */ + va = ALLOC(NTXBUF * 512); + for (i = 0; i < NTXBUF; i++) { + struct ni_dg *data; + + data = (void *)(va + i * 512); + data->nd_status = 0; + data->nd_len = TXADD; + data->nd_ptdbidx = 1; + data->nd_opcode = BVP_DGRAM; + data->bufs[0]._offset = 0; + data->bufs[0]._key = 1; + data->nd_cmdref = allocbase; + bbd[i].nb_key = 1; + bbd[i].nb_status = 0; + bbd[i].nb_pte = (int)&syspte[allocbase>>9]; + allocbase += 2048; + data->bufs[0]._index = i; + + res = INSQTI(data, &fqb->nf_dforw); + } + WAITREG(NI_PCR, PCR_OWN); + NI_WREG(NI_PCR, PCR_FREEQNE|PCR_DFREEQ|PCR_OWN); + WAITREG(NI_PCR, PCR_OWN); + +#ifdef NIDEBUG + printf("recv buffers\n"); +#endif + + /* recv buffers */ + va = ALLOC(NRXBUF * 512); + for (i = 0; i < NRXBUF; i++) { + struct ni_dg *data; + struct ni_bbd *bd; + int idx; + + data = (void *)(va + i * 512); + data->nd_cmdref = allocbase; + data->nd_len = RXADD; + data->nd_opcode = BVP_DGRAMRX; + data->nd_ptdbidx = 2; + data->bufs[0]._key = 1; + + idx = NTXBUF + i; + bd = &bbd[idx]; + bd->nb_pte = (int)&syspte[allocbase>>9]; + allocbase += 2048; + bd->nb_len = 2048; + bd->nb_status = NIBD_VALID; + bd->nb_key = 1; + data->bufs[0]._offset = 0; + data->bufs[0]._len = bd->nb_len; + data->bufs[0]._index = idx; + + res = INSQTI(data, &fqb->nf_rforw); + } + WAITREG(NI_PCR, PCR_OWN); + NI_WREG(NI_PCR, PCR_FREEQNE|PCR_RFREEQ|PCR_OWN); + WAITREG(NI_PCR, PCR_OWN); + +#ifdef NIDEBUG + printf("Set initial parameters\n"); +#endif + + /* Set initial parameters */ + msg = REMQHI(&fqb->nf_mforw); + + msg->nm_opcode = BVP_MSG; + msg->nm_status = 0; + msg->nm_len = sizeof(struct ni_param) + 6; + msg->nm_opcode2 = NI_WPARAM; + ((struct ni_param *)&msg->nm_text[0])->np_flags = NP_PAD; + + puton(msg, &gvp->nc_forw0, PCR_CMDQNE|PCR_CMDQ0|PCR_OWN); + + + while ((data = REMQHI(&gvp->nc_forwr)) == 0) + ; + + msg = (struct ni_msg *)data; +#ifdef NIDEBUG + if (msg->nm_opcode2 != NI_WPARAM) { + printf("ni: wrong response code %d\n", msg->nm_opcode2); + insput(data, &fqb->nf_mforw, PCR_FREEQNE|PCR_MFREEQ|PCR_OWN); + } +#endif + bcopy(((struct ni_param *)&msg->nm_text[0])->np_dpa, + enaddr, ETHER_ADDR_LEN); + insput(data, &fqb->nf_mforw, PCR_FREEQNE|PCR_MFREEQ|PCR_OWN); + +#ifdef NIDEBUG + printf("Clear counters\n"); +#endif + + /* Clear counters */ + msg = REMQHI(&fqb->nf_mforw); + msg->nm_opcode = BVP_MSG; + msg->nm_status = 0; + msg->nm_len = sizeof(struct ni_param) + 6; + msg->nm_opcode2 = NI_RCCNTR; + + puton(msg, &gvp->nc_forw0, PCR_CMDQNE|PCR_CMDQ0|PCR_OWN); + remput(&gvp->nc_forwr, &fqb->nf_mforw, PCR_FREEQNE|PCR_MFREEQ|PCR_OWN); + +#ifdef NIDEBUG + printf("Enable transmit logic\n"); +#endif + + /* Enable transmit logic */ + msg = REMQHI(&fqb->nf_mforw); + + msg->nm_opcode = BVP_MSG; + msg->nm_status = 0; + msg->nm_len = 18; + msg->nm_opcode2 = NI_STPTDB; + ptdb = (struct ni_ptdb *)&msg->nm_text[0]; + bzero(ptdb, sizeof(struct ni_ptdb)); + ptdb->np_index = 1; + ptdb->np_fque = 1; + + puton(msg, &gvp->nc_forw0, PCR_CMDQNE|PCR_CMDQ0|PCR_OWN); + remput(&gvp->nc_forwr, &fqb->nf_mforw, PCR_FREEQNE|PCR_MFREEQ|PCR_OWN); + +#ifdef NIDEBUG + printf("ni: hardware address %s\n", ether_sprintf(enaddr)); + printf("Setting receive parameters\n"); +#endif + msg = REMQHI(&fqb->nf_mforw); + ptdb = (struct ni_ptdb *)&msg->nm_text[0]; + bzero(ptdb, sizeof(struct ni_ptdb)); + msg->nm_opcode = BVP_MSG; + msg->nm_len = 18; + ptdb->np_index = 2; + ptdb->np_fque = 2; + msg->nm_opcode2 = NI_STPTDB; + ptdb->np_type = ETHERTYPE_IP; + ptdb->np_flags = PTDB_UNKN|PTDB_BDC; + memset(ptdb->np_mcast[0], 0xff, ETHER_ADDR_LEN); + ptdb->np_adrlen = 1; + msg->nm_len += 8; + insput(msg, &gvp->nc_forw0, PCR_CMDQNE|PCR_CMDQ0|PCR_OWN); + remput(&gvp->nc_forwr, &fqb->nf_mforw, PCR_FREEQNE|PCR_MFREEQ|PCR_OWN); + +#ifdef NIDEBUG + printf("finished\n"); +#endif + + net_devinit(f, &ni_driver, enaddr); + return 0; +} + +int +ni_get(struct iodesc *desc, void *pkt, size_t maxlen, time_t timeout) +{ + struct ni_dg *data; + struct ni_bbd *bd; + int nsec = getsecs() + timeout; + int len, idx; + +loop: while ((data = REMQHI(&gvp->nc_forwr)) == 0 && (nsec > getsecs())) + ; + + if (nsec <= getsecs()) + return 0; + + switch (data->nd_opcode) { + case BVP_DGRAMRX: + idx = data->bufs[0]._index; + bd = &bbd[idx]; + len = data->bufs[0]._len; + if (len > maxlen) + len = maxlen; + bcopy((caddr_t)data->nd_cmdref, pkt, len); + bd->nb_pte = (int)&syspte[data->nd_cmdref>>9]; + data->bufs[0]._len = bd->nb_len = 2048; + data->bufs[0]._offset = 0; + data->bufs[0]._key = 1; + bd->nb_status = NIBD_VALID; + bd->nb_key = 1; + data->nd_len = RXADD; + data->nd_status = 0; + insput(data, &fqb->nf_rforw, + PCR_FREEQNE|PCR_RFREEQ|PCR_OWN); + return len; + + case BVP_DGRAM: + insput(data, &fqb->nf_dforw, PCR_FREEQNE|PCR_DFREEQ|PCR_OWN); + break; + default: + insput(data, &fqb->nf_mforw, PCR_FREEQNE|PCR_MFREEQ|PCR_OWN); + break; + } + + NI_WREG(NI_PSR, NI_RREG(NI_PSR) & ~(PSR_OWN|PSR_RSQ)); + goto loop; +} + +int +ni_put(struct iodesc *desc, void *pkt, size_t len) +{ + struct ni_dg *data; + struct ni_bbd *bdp; + + data = REMQHI(&fqb->nf_dforw); +#ifdef NIDEBUG + if (data == 0) { + printf("ni_put: driver problem, data == 0\n"); + return -1; + } +#endif + bdp = &bbd[(data->bufs[0]._index & 0x7fff)]; + bdp->nb_status = NIBD_VALID; + bdp->nb_len = (len < 64 ? 64 : len); + bcopy(pkt, (caddr_t)data->nd_cmdref, len); + data->bufs[0]._offset = 0; + data->bufs[0]._len = bdp->nb_len; + data->nd_opcode = BVP_DGRAM; + data->nd_pad3 = 1; + data->nd_ptdbidx = 1; + data->nd_len = 18; + insput(data, &gvp->nc_forw0, PCR_CMDQNE|PCR_CMDQ0|PCR_OWN); + return len; +} + +int +niclose(struct open_file *f) +{ + if (beenhere) { + WAITREG(NI_PCR, PCR_OWN); + NI_WREG(NI_PCR, PCR_OWN|PCR_SHUTDOWN); + WAITREG(NI_PCR, PCR_OWN); + } + return 0; +} diff --git a/sys/arch/vax/boot/boot/if_qe.c b/sys/arch/vax/boot/boot/if_qe.c index a1c1c248907..36a6b30d376 100644 --- a/sys/arch/vax/boot/boot/if_qe.c +++ b/sys/arch/vax/boot/boot/if_qe.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_qe.c,v 1.2 2002/03/14 03:16:02 millert Exp $ */ -/* $NetBSD: if_qe.c,v 1.2 1999/06/30 18:19:26 ragge Exp $ */ +/* $OpenBSD: if_qe.c,v 1.3 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: if_qe.c,v 1.3 2000/05/20 13:30:03 ragge Exp $ */ /* * Copyright (c) 1998 Roar Thronæs. All rights reserved. @@ -39,116 +39,103 @@ #include <netinet/in_systm.h> #include <lib/libsa/netif.h> +#include <lib/libsa/stand.h> #include <arch/vax/if/if_qereg.h> -int qe_probe(), qe_match(), qe_get(), qe_put(); -void qe_init(), qe_end(); +#include "../include/rpb.h" -struct netif_stats qe_stats; +#include "vaxstand.h" -struct netif_dif qe_ifs[] = { -/* dif_unit dif_nsel dif_stats dif_private */ -{ 0, 1, &qe_stats, }, -}; - -struct netif_stats qe_stats; +static int qe_get(struct iodesc *desc, void *pkt, size_t, time_t timeout); +static int qe_put(struct iodesc *desc, void *pkt, size_t); +static void qe_init(u_char *eaddr); struct netif_driver qe_driver = { - "qe", qe_match, qe_probe, qe_init, qe_get, qe_put, qe_end, qe_ifs, 1, + 0, 0, 0, 0, qe_get, qe_put, }; -#define PG_V 0x80000000 -#define QBAMAP 0x20088000 +#define NRCV 1 /* Receive descriptors */ +#define NXMT 1 /* Transmit descriptors */ -#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 */ -#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 */ +static 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 */ -}; +} qe_softc; -static volatile struct qe_softc *sc; +static struct qe_softc *sc = &qe_softc; static int addr; #define QE_WCSR(csr, val) \ - (*((volatile u_short *)(addr + (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) + *((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) +#define qereg(x) ((x) & 017777) int -qe_match(nif, machdep_hint) - struct netif *nif; - void *machdep_hint; -{ - return strcmp(machdep_hint, "qe") == 0; -} +qeopen(struct open_file *f, int adapt, int ctlr, int unit, int part) { + u_char eaddr[6]; + + if (askname == 0) + addr = bootrpb.csrphy; /* Autoboot; use RPB instead */ + else { + addr = 0x20000000; + if (unit == 0) + addr += qereg(0774440); /* XQA0 */ + else if (unit == 1) + addr += qereg(0174460); /* XQB0 */ + else + return ECTLR; + } -int -qe_probe(nif, machdep_hint) - struct netif *nif; - void *machdep_hint; -{ + qe_init(eaddr); + + net_devinit(f, &qe_driver, eaddr); return 0; } void -qe_init(desc, machdep_hint) - struct iodesc *desc; - void *machdep_hint; +qe_init(u_char *eaddr) { - 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); + 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); + 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); + 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); + eaddr[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); + 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->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[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[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); @@ -164,8 +151,8 @@ qe_init(desc, machdep_hint) 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_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; @@ -176,8 +163,8 @@ qe_init(desc, machdep_hint) 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_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; @@ -192,12 +179,7 @@ qe_init(desc, machdep_hint) } int -qe_get(desc, pkt, maxlen, timeout) - struct iodesc *desc; - void *pkt; - int maxlen; - time_t timeout; -{ +qe_get(struct iodesc *desc, void *pkt, size_t maxlen, time_t timeout) { int len, j; retry: @@ -215,10 +197,10 @@ retry: if (sc->rring[0].qe_status1 & 0xc000) goto fail; - if (len == 0) + if (len == 0) goto retry; - bcopy((void *)sc->qein,pkt,len); + bcopy((void*)sc->qein,pkt,len); end: @@ -236,17 +218,13 @@ fail: len = -1; } int -qe_put(desc, pkt, len) - struct iodesc *desc; - void *pkt; - int len; -{ +qe_put(struct iodesc *desc, void *pkt, size_t 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; + bcopy(pkt, (char *)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)); @@ -255,22 +233,27 @@ qe_put(desc, pkt, len) ; if ((QE_RCSR(QE_CSR_CSR) & QE_XMIT_INT) == 0) { - qe_init(desc,0); + char eaddr[6]; + + qe_init(eaddr); 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); + char eaddr[6]; + + qe_init(eaddr); return -1; } return len; } -void -qe_end(nif) - struct netif *nif; +int +qeclose(struct open_file *nif) { QE_WCSR(QE_CSR_CSR, QE_RESET); QE_WCSR(QE_CSR_CSR, QE_RCSR(QE_CSR_CSR) & ~QE_RESET); + + return 0; } diff --git a/sys/arch/vax/boot/boot/if_ze.c b/sys/arch/vax/boot/boot/if_ze.c index 3f88decb7c6..a58081d38d0 100644 --- a/sys/arch/vax/boot/boot/if_ze.c +++ b/sys/arch/vax/boot/boot/if_ze.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_ze.c,v 1.3 2002/03/31 01:10:36 hugh Exp $ */ -/* $NetBSD: if_ze.c,v 1.5 1999/08/23 19:09:27 ragge Exp $ */ +/* $OpenBSD: if_ze.c,v 1.4 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: if_ze.c,v 1.12 2002/05/27 16:54:18 ragge Exp $ */ /* * Copyright (c) 1998 James R. Maynard III. All rights reserved. * @@ -42,39 +42,33 @@ #include <netinet/in_systm.h> #include <netinet/if_ether.h> -#include <lib/libkern/libkern.h> #include <lib/libsa/netif.h> #include <lib/libsa/stand.h> +#include <lib/libsa/net.h> #include <arch/vax/if/sgecreg.h> #include "arch/vax/include/sid.h" +#include "arch/vax/include/rpb.h" -int ze_probe(), ze_match(), ze_get(), ze_put(); -void ze_init(), ze_end(); +#include "vaxstand.h" -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; +static int ze_get(struct iodesc *, void *, size_t, time_t); +static int ze_put(struct iodesc *, void *, size_t); #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, + 0, 0, 0, 0, ze_get, ze_put, }; #define NRCV 8 /* allocate 8 receive descriptors */ -#define NXMT 5 /* and 5 transmit - must be >1 */ +#define NXMT 4 /* and 4 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)) +#define OW_ALLOC(x) ((void *)((int)((int)alloc((x) + 15) + 15) & ~15)) static volatile struct zedevice *addr; @@ -83,33 +77,17 @@ 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; +zeopen(struct open_file *f, int adapt, int ctlr, int unit, int part) { u_long nicsr0_work, *nisa_rom; - int i; - u_char *saved_buf; struct ze_tdes *ze_setup_tdes_list; + int i; /* point to the device in memory */ - addr = (struct zedevice *)0x20008000; + if (askname == 0) /* Override if autoboot */ + addr = (struct zedevice *)bootrpb.csrphy; + else + addr = (struct zedevice *)0x20008000; /* reset the device and wait for completion */ addr->ze_nicsr6 = ZE_NICSR6_MBO | ZE_NICSR6_RE; @@ -117,6 +95,7 @@ ze_init(desc, machdep_hint) ; if (addr->ze_nicsr5 & ZE_NICSR5_SF) { printf("SGEC self-test failed...\n"); + return 1; } /* Get our Ethernet address */ @@ -124,6 +103,10 @@ ze_init(desc, machdep_hint) nisa_rom = (u_long *)0x27800000; for (i=0; i<ETHER_ADDR_LEN; i++) ze_myaddr[i] = nisa_rom[i] & 0377; + } else if (vax_boardtype == VAX_BTYP_VXT) { + nisa_rom = (u_long *)0x200c4000; + for (i=0; i<ETHER_ADDR_LEN; i++) + ze_myaddr[i] = nisa_rom[i] & 0xff; } else { nisa_rom = (u_long *)0x20084000; for (i=0; i<ETHER_ADDR_LEN; i++) @@ -132,7 +115,7 @@ ze_init(desc, machdep_hint) else ze_myaddr[i] = (nisa_rom[i] & 0x0000ff00) >> 8; } - bcopy(ze_myaddr,desc->myea,ETHER_ADDR_LEN); + printf("SGEC: Ethernet address %s\n", ether_sprintf(ze_myaddr)); /* initialize SGEC operating mode */ /* disable interrupts here */ @@ -198,13 +181,16 @@ ze_init(desc, machdep_hint) addr->ze_nicsr6 |= ZE_NICSR6_SR; /* And away-y-y we go! */ + + net_devinit(f, &ze_driver, ze_myaddr); + return 0; } int ze_get(desc, pkt, maxlen, timeout) struct iodesc *desc; void *pkt; - int maxlen; + size_t maxlen; time_t timeout; { int timeout_ctr=100000*timeout, len, rdes; @@ -260,7 +246,7 @@ int ze_put(desc, pkt, len) struct iodesc *desc; void *pkt; - int len; + size_t len; { int timeout=100000; @@ -289,7 +275,7 @@ ze_put(desc, pkt, len) /* Wait for the frame to be sent, but not too long. */ timeout = 100000; - while ((addr->ze_nicsr5 & ZE_NICSR5_TI == 0) && (--timeout>0)) + while (((addr->ze_nicsr5 & ZE_NICSR5_TI) == 0) && (--timeout>0)) ; /* Reset the transmitter interrupt pending flag. */ @@ -300,8 +286,10 @@ ze_put(desc, pkt, len) return -1; } -void -ze_end() +int +zeclose(struct open_file *f) { addr->ze_nicsr6 = ZE_NICSR6_RE; + + return 0; } diff --git a/sys/arch/vax/boot/boot/mfm.c b/sys/arch/vax/boot/boot/mfm.c index 2e22bda7139..761104bd8c1 100644 --- a/sys/arch/vax/boot/boot/mfm.c +++ b/sys/arch/vax/boot/boot/mfm.c @@ -1,5 +1,5 @@ -/* $OpenBSD: mfm.c,v 1.2 2002/03/14 03:16:02 millert Exp $ */ -/* $NetBSD: mfm.c,v 1.2 1997/03/15 13:04:28 ragge Exp $ */ +/* $OpenBSD: mfm.c,v 1.3 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: mfm.c,v 1.4 2001/07/26 22:55:13 wiz Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -69,29 +69,36 @@ struct mfm_softc { int unit; }; -int mfmstrategy(), mfmopen(); -struct disklabel mfmlabel; -struct mfm_softc mfm_softc; -char io_buf[DEV_BSIZE]; +static struct disklabel mfmlabel; +static struct mfm_softc mfm_softc; +static 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; +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 */ +static void sreg_read(void); +static void creg_write(void); +static int mfm_rxprepare(void); +static int mfm_command(int cmd); +static int mfm_rxselect(int unit); +static int mfm_rdselect(int unit); +static int mfm_rxstrategy(void *f, int func, daddr_t dblk, size_t size, void *buf, size_t *rsize); +static int mfm_rdstrategy(void *f, int func, daddr_t dblk, size_t size, void *buf, size_t *rsize); /* * 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 +static void sreg_read() { int i; @@ -103,7 +110,7 @@ sreg_read() *p++ = dkc->dkc_reg; /* dkc_reg auto-increments */ } -static int +static void creg_write() { int i; @@ -120,7 +127,7 @@ creg_write() * * 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 + * time before issuing the real command in order to let the drive become * ready... */ int @@ -138,8 +145,7 @@ mfm_rxprepare() } int -mfm_rxselect(unit) - int unit; +mfm_rxselect(int unit) { int error; @@ -164,12 +170,12 @@ mfm_rxselect(unit) */ error = mfm_command(DKC_CMD_DRSEL_RX33 | unit); - if ((error != 0) || (sreg.udc_dstat & UDC_DS_READY == 0)) { + 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)) { + 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"); @@ -184,14 +190,14 @@ mfm_rxselect(unit) * 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)) { + 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)) { + 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"); @@ -203,8 +209,7 @@ mfm_rxselect(unit) } int -mfm_rdselect(unit) - int unit; +mfm_rdselect(int unit) { int error; @@ -232,8 +237,7 @@ mfm_rdselect(unit) static int mfm_retry = 0; int -mfm_command(cmd) - int cmd; +mfm_command(int cmd) { int termcode, ready, i; @@ -354,14 +358,16 @@ display_xbn(p) } #endif +int 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; + struct mfm_softc *msc = &mfm_softc; + int err; + size_t i; bzero(lp, sizeof(struct disklabel)); msc->unit = unit; @@ -379,12 +385,14 @@ mfmopen(f, adapt, ctlr, unit, part) f->f_devdata = (void *) msc; { +#ifdef verbose int k; unsigned char *ucp; struct mfm_xbn *xp; +#endif /* mfmstrategy(msc, F_READ, -16, 8192, io_buf, &i); */ - mfmstrategy(msc, F_READ, -16, DEV_BSIZE, io_buf, &i); + mfmstrategy(msc, F_READ, -16, 512, io_buf, &i); #ifdef verbose printf("dumping raw disk-block #0:\n"); ucp = io_buf; @@ -446,15 +454,11 @@ mfmopen(f, adapt, ctlr, unit, part) return (0); } -mfm_rxstrategy(msc, func, dblk, size, buf, rsize) - struct mfm_softc *msc; - int func; - daddr_t dblk; - char *buf; - int size, *rsize; -{ +int +mfm_rxstrategy(void *f, int func, daddr_t dblk, size_t size, void *buf, size_t *rsize) { + struct mfm_softc *msc = f; struct disklabel *lp; - int block, sect, head, cyl, scount, i, cmd, res, sval; + int block, sect, head, cyl, scount, res; lp = &mfmlabel; block = (dblk < 0 ? 0 : dblk + lp->d_partitions[msc->part].p_offset); @@ -484,7 +488,7 @@ mfm_rxstrategy(msc, func, dblk, size, buf, rsize) sect = sect % lp->d_nsectors; /* - * *rsize = 512; /* one sector after the other + * *rsize = 512; one sector after the other * ... */ *rsize = 512 * min(scount, lp->d_nsectors - sect); @@ -528,22 +532,18 @@ mfm_rxstrategy(msc, func, dblk, size, buf, rsize) scount -= *rsize / 512; block += *rsize / 512; - buf += *rsize; + (char *)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; -{ +int +mfm_rdstrategy(void *f, int func, daddr_t dblk, size_t size, void *buf, size_t *rsize) { + struct mfm_softc *msc = f; struct disklabel *lp; - int block, sect, head, cyl, scount, i, cmd, res, sval; + int block, sect, head, cyl, scount, cmd, res; lp = &mfmlabel; block = (dblk < 0 ? 0 : dblk + lp->d_partitions[msc->part].p_offset); @@ -618,7 +618,7 @@ mfm_rdstrategy(msc, func, dblk, size, buf, rsize) scount -= *rsize / 512; block += *rsize / 512; - buf += *rsize; + (char *)buf += *rsize; } /* @@ -631,25 +631,26 @@ mfm_rdstrategy(msc, func, dblk, size, buf, rsize) } int -mfmstrategy(msc, func, dblk, size, buf, rsize) - struct mfm_softc *msc; +mfmstrategy(f, func, dblk, size, buf, rsize) + void *f; int func; daddr_t dblk; - char *buf; - int size, *rsize; + void *buf; + size_t size, *rsize; { + struct mfm_softc *msc = f; int res = -1; switch (msc->unit) { case 0: case 1: - res = mfm_rdstrategy(msc, func, dblk, size, buf, rsize); + res = mfm_rdstrategy(f, func, dblk, size, buf, rsize); break; case 2: - res = mfm_rxstrategy(msc, func, dblk, size, buf, rsize); + res = mfm_rxstrategy(f, func, dblk, size, buf, rsize); break; default: - printf("invalid unit %d in mfmstrategy()\n"); + printf("invalid unit %d in mfmstrategy()\n", msc->unit); } return (res); } diff --git a/sys/arch/vax/boot/boot/netio.c b/sys/arch/vax/boot/boot/netio.c index 116e28f2c9c..8a3f5e798c9 100644 --- a/sys/arch/vax/boot/boot/netio.c +++ b/sys/arch/vax/boot/boot/netio.c @@ -1,5 +1,5 @@ -/* $OpenBSD: netio.c,v 1.3 2002/03/14 01:26:47 millert Exp $ */ -/* $NetBSD: netio.c,v 1.4 1999/06/30 18:38:03 ragge Exp $ */ +/* $OpenBSD: netio.c,v 1.4 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: netio.c,v 1.6 2000/05/26 20:16:46 ragge Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -53,7 +53,7 @@ * 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 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 @@ -69,7 +69,7 @@ /* * This module implements a "raw device" interface suitable for - * use by the stand-alone I/O library NFS code. This interface + * 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. @@ -79,7 +79,7 @@ * find interface - netif_open() * RARP for IP address - rarp_getipaddress() * RPC/bootparams - callrpc(d, RPC_BOOTPARAMS, ...) - * RPC/mountd - nfs_mount(sock, ip, path) + * 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). @@ -97,133 +97,34 @@ #include "lib/libsa/netif.h" #include "lib/libsa/bootparam.h" #include "lib/libsa/nfs.h" +#include "lib/libsa/bootp.h" -extern int nfs_root_node[]; /* XXX - get from nfs_mount() */ +#include "vaxstand.h" -struct in_addr myip, rootip, gateip; -n_long netmask; -char rootpath[FNAME_SIZE]; +static struct iodesc desc; +static int inited = 0; -int netdev_sock = -1; -static int open_count; - -int netio_ask = 0; /* default to bootparam, can override */ - -static char input_line[100]; - -int netmountroot(struct open_file *, char *); - -/* - * 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; -{ - if(--open_count == 0) - netif_close(netdev_sock); - f->f_devdata = NULL; - return 0; -} - -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; +struct iodesc * +socktodesc(sock) { - - *rsize = size; - return EIO; + return &desc; } 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; - } +net_devinit(struct open_file *f, struct netif_driver *drv, u_char *eaddr) { + static struct netif best_if; + struct iodesc *s; + int r; - 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; - } + if (inited) + return 0; + /* find a free socket */ + s = &desc; - 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; - } + bzero(s, sizeof(*s)); + best_if.nif_driver = drv; + s->io_netif = &best_if; + bcopy(eaddr, s->myea, 6); /* * Get info for NFS boot: our IP address, our hostname, @@ -236,17 +137,12 @@ netmountroot(f, devname) /* Get boot info using BOOTP way. (RFC951, RFC1048) */ printf("Trying BOOTP\n"); - bootp(netdev_sock); + bootp(0); 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"); + printf("myip: %s (%s)\n", hostname, inet_ntoa(myip)); } else #endif /* SUPPORT_BOOTP */ @@ -255,28 +151,43 @@ netmountroot(f, devname) /* Get boot info using RARP and Sun bootparams. */ printf("Trying BOOTPARAMS\n"); - /* Get our IP address. (rarp.c) */ - if (rarp_getipaddress(netdev_sock) == -1) + /* Get our IP address. (rarp.c) */ + if (rarp_getipaddress(0) == -1) return (errno); printf("boot: client IP address: %s\n", inet_ntoa(myip)); /* Get our hostname, server IP address. */ - if (bp_whoami(netdev_sock)) + if (bp_whoami(0)) return (errno); printf("boot: client name: %s\n", hostname); /* Get the root pathname. */ - if (bp_getfile(netdev_sock, "root", &rootip, rootpath)) + if (bp_getfile(0, "root", &rootip, rootpath)) return (errno); #endif } printf("root addr=%s path=%s\n", inet_ntoa(rootip), rootpath); + f->f_devdata = s; - do_nfs_mount: /* Get the NFS file handle (mount). */ - error = nfs_mount(netdev_sock, rootip, rootpath); + r = nfs_mount(0, rootip, rootpath); + if (r) + return r; + + inited = 1; + return 0; +} - return (error); +ssize_t +netif_put(struct iodesc *desc, void *pkt, size_t len) +{ + return (*desc->io_netif->nif_driver->netif_put)(desc, pkt, len); +} + +ssize_t +netif_get(struct iodesc *desc, void *pkt, size_t len, time_t timo) +{ + return (*desc->io_netif->nif_driver->netif_get)(desc, pkt, len, timo); } diff --git a/sys/arch/vax/boot/boot/ra.c b/sys/arch/vax/boot/boot/ra.c index a0eeaa4cfb0..0bb3f748b21 100644 --- a/sys/arch/vax/boot/boot/ra.c +++ b/sys/arch/vax/boot/boot/ra.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ra.c,v 1.2 2002/03/14 03:16:02 millert Exp $ */ -/* $NetBSD: ra.c,v 1.4 1999/08/07 11:19:04 ragge Exp $ */ +/* $OpenBSD: ra.c,v 1.3 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: ra.c,v 1.11 2002/06/04 15:13:55 ragge Exp $ */ /* * Copyright (c) 1995 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -41,7 +41,7 @@ #include "lib/libsa/stand.h" #include "../include/pte.h" -#include "../include/sid.h" +#include "../include/rpb.h" #include "arch/vax/mscp/mscp.h" #include "arch/vax/mscp/mscpreg.h" @@ -51,9 +51,7 @@ #include "vaxstand.h" -static command(int); - - +static void command(int, int); /* * These routines for RA disk standalone boot is wery simple, @@ -63,70 +61,80 @@ static command(int); * 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 */ +static 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]; +static struct disklabel ralabel; +static char io_buf[DEV_BSIZE]; +static int dpart, dunit, remap, is_tmscp, curblock; +static volatile u_short *ra_ip, *ra_sa, *ra_sw; +static volatile u_int *mapregs; -raopen(f, adapt, ctlr, unit, part) - struct open_file *f; - int ctlr, unit, part; +int +raopen(struct open_file *f, int adapt, int ctlr, int unit, int part) { - char *msg; - struct disklabel *lp = &ralabel; - volatile struct ra_softc *ra = &ra_softc; - volatile u_int *nisse; + static volatile struct uda *ubauda; unsigned short johan, johan2; - int i,err, udacsr; + size_t i; + int err; + char *msg; #ifdef DEV_DEBUG printf("raopen: adapter %d ctlr %d unit %d part %d\n", adapt, ctlr, unit, part); + printf("raopen: csrbase %x nexaddr %x\n", csrbase, nexaddr); #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); + bzero(&ralabel, sizeof(struct disklabel)); + bzero((void *)&uda, sizeof(struct uda)); + if (bootrpb.devtyp == BDEV_TK) + is_tmscp = 1; + dunit = unit; + dpart = part; + if (ctlr < 0) + ctlr = 0; + remap = csrbase && nexaddr; + curblock = 0; + if (csrbase) { /* On a uda-alike adapter */ + if (askname == 0) { + csrbase = bootrpb.csrphy; + dunit = bootrpb.unit; + nexaddr = bootrpb.adpphy; + } else + csrbase += (ctlr ? 000334 : 012150); + ra_ip = (short *)csrbase; + ra_sa = ra_sw = (short *)csrbase + 1; + if (nexaddr) { /* have map registers */ + mapregs = (int *)nexaddr + 512; + mapregs[494] = PG_V | (((u_int)&uda) >> 9); + mapregs[495] = mapregs[494] + 1; + (char *)ubauda = (char *)0x3dc00 + + (((u_int)(&uda))&0x1ff); + } else + ubauda = &uda; 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 */ + johan2 = (((u_int)ubauda) >> 16) & 077; + *ra_ip = 0; /* Start init */ + bootrpb.csrphy = csrbase; } else { - paddr_t kdaddr = (paddr_t)biaddr[adapt] + BI_NODE(ctlr); + paddr_t kdaddr; 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); + if (askname == 0) { + nexaddr = bootrpb.csrphy; + dunit = bootrpb.unit; + } else { + nexaddr = (bootrpb.csrphy & ~(BI_NODESIZE - 1)) + KDB_IP; + bootrpb.csrphy = nexaddr; + } + + kdaddr = nexaddr & ~(BI_NODESIZE - 1); + ra_ip = (short *)(kdaddr + KDB_IP); + ra_sa = (short *)(kdaddr + KDB_SA); + 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); @@ -138,45 +146,70 @@ raopen(f, adapt, ctlr, unit, part) ubauda = &uda; } +#ifdef DEV_DEBUG + printf("start init\n"); +#endif /* Init of this uda */ - while ((*ra->ra_sa & MP_STEP1) == 0) + while ((*ra_sa & MP_STEP1) == 0) ; #ifdef DEV_DEBUG printf("MP_STEP1..."); #endif - *ra->ra_sw = 0x8000; - while ((*ra->ra_sa & MP_STEP2) == 0) + *ra_sw = 0x8000; + while ((*ra_sa & MP_STEP2) == 0) ; #ifdef DEV_DEBUG printf("MP_STEP2..."); #endif - *ra->ra_sw = johan; - while ((*ra->ra_sa & MP_STEP3) == 0) + *ra_sw = johan; + while ((*ra_sa & MP_STEP3) == 0) ; #ifdef DEV_DEBUG printf("MP_STEP3..."); #endif - *ra->ra_sw = johan2; - while ((*ra->ra_sa & MP_STEP4) == 0) + *ra_sw = johan2; + while ((*ra_sa & MP_STEP4) == 0) ; #ifdef DEV_DEBUG printf("MP_STEP4\n"); #endif - *ra->ra_sw = 0x0001; + *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; + if (is_tmscp) { + 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); - uda.uda_cmd.mscp_unit = ra->unit; - command(M_OP_ONLINE); + command(M_OP_SETCTLRC, 0); + uda.uda_cmd.mscp_unit = dunit; + command(M_OP_ONLINE, 0); + if (is_tmscp) { + if (part) { +#ifdef DEV_DEBUG + printf("Repos of tape..."); +#endif + 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; +#ifdef DEV_DEBUG + printf("Done!\n"); +#endif + } + return 0; + } #ifdef DEV_DEBUG printf("reading disklabel\n"); #endif - err = rastrategy(ra,F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); + err = rastrategy(0, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); if(err){ printf("reading disklabel: %s\n",strerror(err)); return 0; @@ -185,19 +218,21 @@ raopen(f, adapt, ctlr, unit, part) #ifdef DEV_DEBUG printf("getting disklabel\n"); #endif - msg = getdisklabel(io_buf+LABELOFFSET, lp); + msg = getdisklabel(io_buf+LABELOFFSET, &ralabel); if (msg) printf("getdisklabel: %s\n", msg); - f->f_devdata = (void *)ra; return(0); } -static -command(cmd) +static void +command(int cmd, int arg) { - volatile int hej; + volatile short hej; + int to; + +igen: uda.uda_cmd.mscp_opcode = cmd; + uda.uda_cmd.mscp_modifier = arg; - 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; @@ -205,51 +240,87 @@ command(cmd) #ifdef DEV_DEBUG printf("sending cmd %x...", cmd); #endif - hej = *ra_softc.ra_ip; - while(uda.uda_ca.ca_rspdsc<0) - ; + hej = *ra_ip; + to = 10000000; + while (uda.uda_ca.ca_rspdsc < 0) { +// if (uda.uda_ca.ca_cmdint) +// uda.uda_ca.ca_cmdint = 0; + if (--to < 0) { +#ifdef DEV_DEBUG + printf("timing out, retry\n"); +#endif + goto igen; + } + } #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; +int +rastrategy(void *f, int func, daddr_t dblk, + size_t size, void *buf, size_t *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; + u_int pfnum, mapnr, nsize; +#ifdef DEV_DEBUG + printf("rastrategy: buf %p remap %d is_tmscp %d\n", + buf, remap, is_tmscp); +#endif + if (remap) { pfnum = (u_int)buf >> VAX_PGSHIFT; for(mapnr = 0, nsize = size; (nsize + VAX_NBPG) > 0; nsize -= VAX_NBPG) - ptmapp[mapnr++] = PG_V | pfnum++; + mapregs[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 (is_tmscp) { + int i; + + /* + * 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 = dunit; + command(M_OP_READ, 0); + } + } else { + + uda.uda_cmd.mscp_seq.seq_lbn = + dblk + ralabel.d_partitions[dpart].p_offset; + uda.uda_cmd.mscp_seq.seq_bytecount = size; + uda.uda_cmd.mscp_unit = dunit; #ifdef DEV_DEBUG - printf("rastrategy: blk 0x%lx count %lx unit %lx\n", - uda.uda_cmd.mscp_seq.seq_lbn, size, ra->unit); + printf("rastrategy: blk 0x%lx count %lx unit %x\n", + uda.uda_cmd.mscp_seq.seq_lbn, size, dunit); +#endif +#ifdef notdef + if (func == F_WRITE) + command(M_OP_WRITE, 0); + else #endif - if (func == F_WRITE) - command(M_OP_WRITE); - else - command(M_OP_READ); + command(M_OP_READ, 0); + } *rsize = size; return 0; diff --git a/sys/arch/vax/boot/boot/rom.c b/sys/arch/vax/boot/boot/rom.c index 2d3f0c3a6b5..f6fb3a7b271 100644 --- a/sys/arch/vax/boot/boot/rom.c +++ b/sys/arch/vax/boot/boot/rom.c @@ -1,5 +1,5 @@ -/* $OpenBSD: rom.c,v 1.3 2002/03/14 03:16:02 millert Exp $ */ -/* $NetBSD: rom.c,v 1.1 1996/08/02 11:22:21 ragge Exp $ */ +/* $OpenBSD: rom.c,v 1.4 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: rom.c,v 1.3 2000/07/19 00:58:25 matt Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -50,42 +50,32 @@ #include "data.h" #include "vaxstand.h" -extern unsigned *bootregs; -extern struct rpb *rpb; +static struct disklabel romlabel; +static char io_buf[DEV_BSIZE]; +static struct bqo *bqo; +static int dpart, dunit; -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; +int +romopen(struct open_file *f, int adapt, int ctlr, int unit, int part) { char *msg; struct disklabel *lp = &romlabel; - volatile struct rom_softc *rsc = &rom_softc; - int i,err; + size_t i; + int err; - bootregs[11] = XXRPB; - bqo = (void *)rpb->iovec; + bqo = (void *)bootrpb.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); + if (bootrpb.unit > 0 && (bootrpb.unit % 100) == 0) { + printf ("changing bootrpb.unit from %d ", bootrpb.unit); + bootrpb.unit /= 100; + printf ("to %d\n", bootrpb.unit); } bzero(lp, sizeof(struct disklabel)); - rsc->unit = unit; - rsc->part = part; + dunit = unit; + dpart = part; - err = romstrategy(rsc, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); + err = romstrategy(0, F_READ, LABELSECTOR, DEV_BSIZE, io_buf, &i); if (err) { printf("reading disklabel: %s\n",strerror(err)); return 0; @@ -93,29 +83,33 @@ romopen(f, adapt, ctlr, unit, part) 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; +int romwrite_uvax(int, int, void *, struct rpb *); +int romread_uvax(int, int, void *, struct rpb *); + +int +romstrategy (f, func, dblk, size, buf, rsize) + void *f; + int func; daddr_t dblk; - char *buf; - int size, *rsize; + size_t size; + void *buf; + size_t *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; + block = dblk + lp->d_partitions[dpart].p_offset; + if (dunit >= 0 && dunit < 10) + bootrpb.unit = dunit; if (func == F_WRITE) - romwrite_uvax(block, size, buf, bootregs); + romwrite_uvax(block, size, buf, &bootrpb); else - romread_uvax(block, size, buf, bootregs); + romread_uvax(block, size, buf, &bootrpb); *rsize = size; return 0; diff --git a/sys/arch/vax/boot/boot/tmscp.c b/sys/arch/vax/boot/boot/tmscp.c index ec0f185a01c..ff466c8c15b 100644 --- a/sys/arch/vax/boot/boot/tmscp.c +++ b/sys/arch/vax/boot/boot/tmscp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmscp.c,v 1.2 2002/03/14 03:16:02 millert Exp $ */ +/* $OpenBSD: tmscp.c,v 1.3 2002/06/11 09:36:23 hugh Exp $ */ /* $NetBSD: tmscp.c,v 1.3 1999/06/30 18:19:26 ragge Exp $ */ /* * Copyright (c) 1995 Ludd, University of Lule}, Sweden. @@ -95,11 +95,11 @@ tmscpopen(f, adapt, ctlr, unit, part) ra->udaddr=uioaddr[adapt]+tmsaddr; ra->ubaddr=(int)ubaaddr[adapt]; ra->unit=unit; - udacsr=(void *)ra->udaddr; + 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); + ubauda=(void*)0x3dc00+(((u_int)(&uda))&0x1ff); /* * Init of this tmscp ctlr. @@ -165,7 +165,7 @@ tmscpstrategy(ra, func, dblk, size, buf, rsize) u_int size, *rsize; { u_int i,j,pfnum, mapnr, nsize, bn, cn, sn, tn; - volatile struct udadevice *udadev=(void *)ra->udaddr; + volatile struct udadevice *udadev=(void*)ra->udaddr; volatile u_int *ptmapp = (u_int *)ra->ubaddr + 512; volatile int hej; diff --git a/sys/arch/vax/boot/boot/vaxstand.h b/sys/arch/vax/boot/boot/vaxstand.h new file mode 100644 index 00000000000..8d48a376189 --- /dev/null +++ b/sys/arch/vax/boot/boot/vaxstand.h @@ -0,0 +1,85 @@ +/* $OpenBSD: vaxstand.h,v 1.1 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: vaxstand.h,v 1.5 2000/06/15 19:53:23 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. + */ + +/* Variables used in autoconf */ +extern int askname; +extern struct rpb bootrpb; +extern int csrbase, nexaddr; + +/* 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 + */ +#ifndef min +#define min(x,y) (x < y ? x : y) +#endif /* min */ + +struct netif_driver; + +char *index(char *, int); +int net_devinit(struct open_file *f, struct netif_driver *drv, u_char *eaddr); + +/* device calls */ +int raopen(struct open_file *, int, int, int, int), + rastrategy(void *, int, daddr_t, size_t, void *, size_t *); +int hpopen(struct open_file *, int, int, int, int), + hpstrategy(void *, int, daddr_t, size_t, void *, size_t *); +int ctuopen(struct open_file *, int, int, int, int), + ctustrategy(void *, int, daddr_t, size_t, void *, size_t *); +int tmscpopen(struct open_file *, int, int, int, int), + tmscpstrategy(void *, int, daddr_t, size_t, void *, size_t *); +int romopen(struct open_file *, int, int, int, int), + romstrategy(void *, int, daddr_t, size_t, void *, size_t *); +int mfmopen(struct open_file *, int, int, int, int), + mfmstrategy(void *, int, daddr_t, size_t, void *, size_t *); +int sdopen(struct open_file *), + sdstrategy(void *, int, daddr_t, size_t, void *, size_t *); +int leopen(struct open_file *, int, int, int, int), + leclose(struct open_file *); +int qeopen(struct open_file *, int, int, int, int), + qeclose(struct open_file *); +int zeopen(struct open_file *, int, int, int, int), + zeclose(struct open_file *); +int deopen(struct open_file *, int, int, int, int), + declose(struct open_file *); +int niopen(struct open_file *, int, int, int, int), + niclose(struct open_file *); +int netopen(struct open_file *), netclose(struct open_file *); + diff --git a/sys/arch/vax/boot/boot/version b/sys/arch/vax/boot/boot/version new file mode 100644 index 00000000000..4e5f4b0b4c1 --- /dev/null +++ b/sys/arch/vax/boot/boot/version @@ -0,0 +1,31 @@ +$OpenBSD: version,v 1.1 2002/06/11 09:36:23 hugh Exp $ +$NetBSD: version,v 1.4 2001/11/09 19:53:15 scw Exp $ + +NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this +file is important - make sure the entries are appended on end, last item +is taken as the current. + +1.0: Initial import. +1.1: Bunch of small fixes to make boot work on most VAXen. +1.2: Use common routines to identify cpu type. + Set up a SCB to be able to handle clock interrupts in the boot program. + Now timer countdown should work on all types of vaxen. +1.3: Unify the ra and tmscp driver. + Standalone driver for the Digital Equipment Unibus Network Adapter + (DEUNA). This allows 11/750 owners to install from a single TU58 + cassette. + Adopt to the RPB changes. Complete change of how network devices are + handled. No more hacks to find bus addresses. +1.5: Standalone device driver for DEBNx (ni) ethernet controllers. +1.6: Add support for VAX 6000 + VAX 8000. Tweak console routines. + Create a fake RPB if either netbooted (on machine without RPB) or + loaded from console storage (without VMB intervention). +1.7: Add support for loading a 2nd stage boot in either a.out or ELF. + Add support for loading a 2nd stage boot directly to it's desired + address if possible. + Cleanup use of u_int/size_t. +1.8: Switch to loadfile instead of exec. Now we can load a.out or ELF + kernels. +1.9: Support verbose/quiet boot. +1.10: loadfile() update: ELF symbols no longer need backward seeks. +1.11: loadfile() update to avoid backwards seeks for ELF Program Headers. diff --git a/sys/arch/vax/boot/common/romread.s b/sys/arch/vax/boot/common/romread.S index 749a70bae2d..4de1e0a90f8 100644 --- a/sys/arch/vax/boot/common/romread.s +++ b/sys/arch/vax/boot/common/romread.S @@ -1,5 +1,5 @@ -/* $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 $ */ +/* $OpenBSD: romread.S,v 1.1 2002/06/11 09:36:23 hugh Exp $ */ +/* $NetBSD: romread.S,v 1.1 2002/02/24 01:04:25 matt Exp $ */ /* * Copyright (c) 1995 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -59,36 +59,34 @@ ENTRY(read750, 0xFFE) ret /* - * romread_uvax (int lbn, int size, void *buf, int *regs) + * romread_uvax (int lbn, int size, void *buf, struct rpb *rpb) */ 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 + movl 16(ap),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 + ret # %r0 holds the result /* - * romwrite_uvax (int lbn, int size, void *buf, int *regs) + * romwrite_uvax (int lbn, int size, void *buf, struct rpb *rpb) */ 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 + movl 16(ap), 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 + ret # %r0 holds the result diff --git a/sys/arch/vax/boot/common/srt0.s b/sys/arch/vax/boot/common/srt0.S index fb5dabecf6d..8ff71c5a35c 100644 --- a/sys/arch/vax/boot/common/srt0.s +++ b/sys/arch/vax/boot/common/srt0.S @@ -1,5 +1,5 @@ -/* $OpenBSD: srt0.s,v 1.2 2000/10/04 04:09:01 bjc Exp $ */ -/* $NetBSD: srt0.s,v 1.2 1999/05/23 21:58:19 ragge Exp $ */ +/* $OpenBSD: srt0.S,v 1.1 2002/06/11 09:36:24 hugh Exp $ */ +/* $NetBSD: srt0.S,v 1.2 2002/03/31 00:11:14 matt Exp $ */ /* * Copyright (c) 1994 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -33,6 +33,7 @@ /* All bugs are subject to removal without further notice */ #include "../include/asm.h" + /* * Auto-moving startup code for standalone programs. Can be loaded * (almost) anywhere in memory but moves itself to the position @@ -41,45 +42,44 @@ * 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 - ashl $9,76(r11),_memsz # got memsize from rpb - movzwl 48(r11), r10 # Get howto + .globl nisse # pass -e nisse to ld gives OK start addr + .set nisse,0 -2: movl $_start, sp # Probably safe place for stack - pushr $0x1fff +ALTENTRY(start) + nop;nop; + movl $_C_LABEL(start), sp # Probably safe place for stack + pushr $0x1fff # save for later usage - 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å. + subl3 $_C_LABEL(start), $_C_LABEL(edata), r0 + movab _C_LABEL(start), r1 # get where we are + movl $_C_LABEL(start), r3 # get where we want to be + cmpl r1,r3 # are we where we want to be? + beql relocated # already relocated, skip copy + movc3 r0,(r1),(r3) # copy + subl3 $_C_LABEL(edata), $_C_LABEL(end), r2 + movc5 $0,(r3),$0,r2,(r3) # Zero bss - 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,_howto # howto also... - movl sp, _bootregs - calls $0, _Xmain # Were here! + movpsl -(sp) + pushl $relocated + rei +relocated: # now relocation is done !!! + movl sp,_C_LABEL(bootregs) # *bootregs + calls $0, _C_LABEL(Xmain) # Were here! halt # no return ENTRY(machdep_start, 0) + calls $0,_C_LABEL(niclose) # Evil hack to shutdown DEBNA. 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 + movl 20(ap), r9 # end of symbol table + pushl 8(ap) # number of symbols + pushl 16(ap) # start of symbols + movab _C_LABEL(bootrpb),r10 # get RPB address + pushl r10 # argument for new boot + ashl $9,76(r10),r8 # memory size (COMPAT) + movl $3,r11 # ask boot (COMPAT) + clrl r10 # no boot dev (COMPAT) - .globl _memsz -_memsz: .long 0x0 + calls $3,(r6) + halt diff --git a/sys/arch/vax/boot/common/str.s b/sys/arch/vax/boot/common/str.S index e45ab28ea67..e88cb9ca9ce 100644 --- a/sys/arch/vax/boot/common/str.s +++ b/sys/arch/vax/boot/common/str.S @@ -1,5 +1,5 @@ -/* $OpenBSD: str.s,v 1.2 2000/05/01 00:12:02 bjc Exp $ */ -/* $NetBSD: str.s,v 1.1 1999/03/06 16:36:06 ragge Exp $ */ +/* $OpenBSD: str.S,v 1.1 2002/06/11 09:36:24 hugh Exp $ */ +/* $NetBSD: str.S,v 1.1 2002/02/24 01:04:25 matt Exp $ */ /* * Copyright (c) 1996 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -41,7 +41,7 @@ /* * atoi() used in devopen. */ -ENTRY(atoi, 0); +ENTRY(atoi, 0) movl 4(ap),r1 clrl r0 @@ -60,7 +60,7 @@ ENTRY(atoi, 0); * index() small and easy. * doesnt work if we search for null. */ -ENTRY(index, 0); +ENTRY(index, 0) movq 4(ap),r0 1: cmpb (r0), r1 beql 2f @@ -72,7 +72,7 @@ ENTRY(index, 0); /* * cmpc3 is emulated on MVII. */ -ENTRY(bcmp, 0); +ENTRY(bcmp, 0) movl 4(ap), r2 movl 8(ap), r1 movl 12(ap), r0 @@ -85,15 +85,15 @@ ENTRY(bcmp, 0); /* * Is movc3/movc5 emulated on any CPU? I dont think so; use them here. */ -ENTRY(bzero,0); +ENTRY(bzero,0) movc5 $0,*4(ap),$0,8(ap),*4(ap) ret -ENTRY(bcopy,0); +ENTRY(bcopy,0) movc3 12(ap), *4(ap), *8(ap) ret -ENTRY(strlen, 0); +ENTRY(strlen, 0) movl 4(ap), r0 1: tstb (r0)+ bneq 1b @@ -139,7 +139,7 @@ ENTRY(strncpy, 0) ENTRY(strcat, 0) pushl 4(ap) - calls $1,_strlen + calls $1,_C_LABEL(strlen) addl2 4(ap),r0 movl 8(ap),r1 1: movb (r1)+,(r0)+ @@ -147,18 +147,19 @@ ENTRY(strcat, 0) ret ENTRY(setjmp, 0) - movl 4(ap), r0 - movl 8(fp), (r0) - movl 12(fp), 4(r0) - movl 16(fp), 8(r0) - addl3 fp,$28,12(r0) - clrl r0 - ret + movl 4(ap), r0 + movl 8(fp), (r0) + movl 12(fp), 4(r0) + movl 16(fp), 8(r0) + addl3 fp,$28,12(r0) + clrl r0 + ret ENTRY(longjmp, 0) - movl 4(ap), r1 - movl 8(ap), r0 - movl (r1), ap - movl 4(r1), fp - movl 12(r1), sp - jmp *8(r1) + movl 4(ap), r1 + movl 8(ap), r0 + movl (r1), ap + movl 4(r1), fp + movl 12(r1), sp + jmp *8(r1) + diff --git a/sys/arch/vax/boot/xxboot/Makefile b/sys/arch/vax/boot/xxboot/Makefile index 9c69452e26c..d3aac85b173 100644 --- a/sys/arch/vax/boot/xxboot/Makefile +++ b/sys/arch/vax/boot/xxboot/Makefile @@ -1,37 +1,57 @@ -# $OpenBSD: Makefile,v 1.3 2002/03/10 06:52:16 hugh Exp $ -# $NetBSD: Makefile,v 1.2 1999/10/23 14:40:39 ragge Exp $ +# $OpenBSD: Makefile,v 1.4 2002/06/11 09:36:24 hugh Exp $ +# $NetBSD: Makefile,v 1.12 2002/02/24 01:04:25 matt Exp $ -S=${.CURDIR}/../../../../ +S= ${.CURDIR}/../../../../ PROG= xxboot LINKS= ${BINDIR}/xxboot ${BINDIR}/raboot LINKS+= ${BINDIR}/xxboot ${BINDIR}/hdboot LINKS+= ${BINDIR}/xxboot ${BINDIR}/sdboot LINKS+= ${BINDIR}/xxboot ${BINDIR}/hpboot +WARNS?= 1 -SRCS= start.s bootxx.c romread.s urem.s udiv.s str.s +SRCS= start.S bootxx.c romread.S str.S urem.s udiv.s STRIPFLAG= CPPFLAGS+=-D_STANDALONE -DLIBSA_NO_FD_CHECKING -DLIBSA_NO_RAW_ACCESS \ -DLIBSA_NO_TWIDDLE -DLIBSA_SINGLE_DEVICE=rom \ - -DLIBSA_SINGLE_FILESYSTEM=ufs + -DLIBSA_NO_COMPAT_UFS \ + -DLIBSA_NO_FS_SYMLINK -DLIBSA_NO_FS_CLOSE \ + -DLIBSA_NO_FS_WRITE -DLIBSA_NO_FS_SEEK \ + -DNEED_UFS BINDIR= /usr/mdec -NOMAN= 1 +NOMAN= # defined + +CFLAGS= -Os SAREL= 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 +#KERN_AS=library +#.include "${S}/lib/libkern/Makefile.inc" +#LIBKERN=${KERNLIB} + +.if ${MACHINE} == "vax" +.PHONY: machine-links +beforedepend: machine-links +machine-links: + @[ -h machine ] || ln -s ${S}/arch/${MACHINE}/include machine + @[ -h ${MACHINE_ARCH} ] || ln -s ${S}/arch/${MACHINE_ARCH}/include ${MACHINE_ARCH} +.NOPATH: machine ${MACHINE_ARCH} +CLEANFILES+= machine ${MACHINE_ARCH} +.endif + +${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} +${PROG}: ${OBJS} ${LIBSA} ${LIBKERN} + ${LD} -N -Ttext 100000 -o ${PROG}.out ${OBJS} ${LIBSA} ${LIBKERN} + /usr/bin/strip ${PROG}.out + /usr/bin/size ${PROG}.out + /bin/dd if=${PROG}.out of=${PROG} bs=32 skip=1 clean:: rm -f a.out [Ee]rrs mklog core *.core ${PROG} ${OBJS} ${LOBJS} \ - ${CLEANFILES} + ${CLEANFILES} .include <bsd.prog.mk> diff --git a/sys/arch/vax/boot/xxboot/bootxx.c b/sys/arch/vax/boot/xxboot/bootxx.c index 30007379ea1..7c57b7267fa 100644 --- a/sys/arch/vax/boot/xxboot/bootxx.c +++ b/sys/arch/vax/boot/xxboot/bootxx.c @@ -1,5 +1,6 @@ -/* $OpenBSD: bootxx.c,v 1.4 2002/03/14 03:16:02 millert Exp $ */ -/* $NetBSD: bootxx.c,v 1.2 1999/10/23 14:40:38 ragge Exp $ */ +/* $OpenBSD: bootxx.c,v 1.5 2002/06/11 09:36:24 hugh Exp $ */ +/* $NetBSD: bootxx.c,v 1.16 2002/03/29 05:45:08 matt Exp $ */ + /*- * Copyright (c) 1982, 1986 The Regents of the University of California. * All rights reserved. @@ -38,167 +39,149 @@ #include "sys/param.h" #include "sys/reboot.h" #include "sys/disklabel.h" +#include "sys/exec.h" +#include "sys/exec_elf.h" #include "lib/libsa/stand.h" #include "lib/libsa/ufs.h" +#include "lib/libsa/cd9660.h" -#include "../include/pte.h" -#include "../include/sid.h" -#include "../include/mtpr.h" -#include "../include/reg.h" -#include "../include/rpb.h" +#include "machine/pte.h" +#include "machine/sid.h" +#include "machine/mtpr.h" +#include "machine/reg.h" +#include "machine/rpb.h" +#include "../vax/gencons.h" #include "../mba/mbareg.h" #include "../mba/hpreg.h" #define NRSP 1 /* Kludge */ #define NCMD 1 /* Kludge */ +#define LIBSA_TOO_OLD -#include "../mscp/mscp.h" -#include "../mscp/mscpreg.h" - -#include "vaxstand.h" +#include "arch/vax/mscp/mscp.h" +#include "arch/vax/mscp/mscpreg.h" -struct rom_softc { - int part; - int unit; -} rom_softc; +#include "../boot/data.h" -int romstrategy(void *, int, daddr_t, size_t, void *, size_t *); -int romopen(struct open_file *, int, int, int, int); - -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 devsw devsw[] = { - SADEV("rom", romstrategy, romopen, nullsys, noioctl), -}; -int ndevs = (sizeof(devsw)/sizeof(devsw[0])); - -int command(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. - */ +#define RF_PROTECTED_SECTORS 64 /* XXX refer to <.../rf_optnames.h> */ -volatile dev_t devtype, bootdev; -unsigned opendev, boothowto, bootset, memsz; +void Xmain(void); +void hoppabort(int); +void romread_uvax(int lbn, int size, void *buf, struct rpb *rpb); +void hpread(int block); +int read750(int block, int *regs); +int unit_init(int, struct rpb *, int); struct open_file file; unsigned *bootregs; struct rpb *rpb; +struct bqo *bqo; int vax_cputype; +int vax_load_failure; +struct udadevice {u_short udaip;u_short udasa;}; +volatile struct udadevice *csr; +static int moved; + +extern int from; +#define FROM750 1 +#define FROMMV 2 +#define FROMVMB 4 /* * The boot block are used by 11/750, 8200, MicroVAX II/III, VS2000, * VS3100/??, VS4000 and VAX6000/???, and only when booting from disk. */ +void Xmain() { + union { + struct exec aout; + Elf32_Ehdr elf; + } hdr; int io; - char *scbb; - char *new, *bqo; - char *hej = "/boot"; + u_long entry; vax_cputype = (mfpr(PR_SID) >> 24) & 0xFF; - + moved = 0; /* */ - switch (vax_cputype) { - case VAX_TYP_UV2: - case VAX_TYP_CVAX: - case VAX_TYP_RIGEL: - case VAX_TYP_NVAX: - case VAX_TYP_MARIAH: - case VAX_TYP_SOC: + rpb = (void *)0xf0000; /* Safe address right now */ + bqo = (void *)0xf1000; + if (from == FROMMV) { /* * 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, XXRPB, 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_MARIAH: - case VAX_TYP_RIGEL: - if (rpb->devtyp == BDEV_SD || rpb->devtyp == BDEV_SDN) { - unit = rpb->unit / 100; - controller = (rpb->csrphy & 0x100 ? 1 : 0); - } else { - controller = ((rpb->csrphy & 017777) == 0xDC)?1:0; - unit = rpb->unit; /* DUC, DUD? */ + bcopy ((void *)bootregs[11], rpb, sizeof(struct rpb)); + bcopy ((void*)rpb->iovec, bqo, rpb->iovecsz); +#if 0 + if (rpb->devtyp == BDEV_SDN) + rpb->devtyp = BDEV_SD; /* XXX until driver fixed */ +#endif + } else { + bzero(rpb, sizeof(struct rpb)); + rpb->devtyp = bootregs[0]; + rpb->unit = bootregs[3]; + rpb->rpb_bootr5 = bootregs[5]; + rpb->csrphy = bootregs[2]; + rpb->adpphy = bootregs[1]; /* BI node on 8200 */ + if (rpb->devtyp != BDEV_HP && vax_cputype == VAX_TYP_750) + rpb->adpphy = + (bootregs[1] == 0xffe000 ? 0xf30000 : 0xf32000); + } + rpb->rpb_base = rpb; + rpb->iovec = (int)bqo; + + io = open("/boot.vax", 0); + if (io < 0) + io = open("/boot", 0); + if (io < 0) + asm("movl $0xbeef1, r0; halt"); + + read(io, (void *)&hdr.aout, sizeof(hdr.aout)); + if (N_GETMAGIC(hdr.aout) == OMAGIC && N_GETMID(hdr.aout) == MID_VAX) { + vax_load_failure++; + entry = hdr.aout.a_entry; + if (entry < sizeof(hdr.aout)) + entry = sizeof(hdr.aout); + read(io, (void *) entry, hdr.aout.a_text + hdr.aout.a_data); + memset((void *) (entry + hdr.aout.a_text + hdr.aout.a_data), + 0, hdr.aout.a_bss); + } else if (memcmp(hdr.elf.e_ident, ELFMAG, SELFMAG) == 0) { + Elf32_Phdr ph; + size_t off = sizeof(hdr.elf); + vax_load_failure += 2; + read(io, (caddr_t)(&hdr.elf) + sizeof(hdr.aout), + sizeof(hdr.elf) - sizeof(hdr.aout)); + if (hdr.elf.e_machine != EM_VAX || hdr.elf.e_type != ET_EXEC + || hdr.elf.e_phnum != 1) + goto die; + vax_load_failure++; + entry = hdr.elf.e_entry; + if (hdr.elf.e_phoff != sizeof(hdr.elf)) + goto die; + vax_load_failure++; + read(io, &ph, sizeof(ph)); + off += sizeof(ph); + if (ph.p_type != PT_LOAD) + goto die; + vax_load_failure++; + while (off < ph.p_offset) { + u_int32_t tmp; + read(io, &tmp, sizeof(tmp)); + off += sizeof(tmp); } - break; - - case VAX_TYP_8SS: - case VAX_TYP_750: - controller = bootregs[1]; - unit = bootregs[3]; - break; + read(io, (void *) ph.p_paddr, ph.p_filesz); + memset((void *) (ph.p_paddr + ph.p_filesz), 0, + ph.p_memsz - ph.p_filesz); + } else { + goto die; } - - 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) */ - case BDEV_SDN: /* SCSI disk on NCR53C94 */ - 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); + hoppabort(entry); +die: + asm("movl $0xbeef2, r0; halt"); } /* @@ -207,6 +190,51 @@ getbootdev() * - Can only load file "boot". * - Must be the first file on tape. */ +struct fs_ops file_system[] = { +#ifdef NEED_UFS + { ufs_open, 0, ufs_read, 0, 0, ufs_stat }, +#endif +#ifdef NEED_CD9660 + { cd9660_open, 0, cd9660_read, 0, 0, cd9660_stat }, +#endif +#ifdef NEED_USTARFS + { ustarfs_open, 0, ustarfs_read, 0, 0, ustarfs_stat }, +#endif +}; + +int nfsys = (sizeof(file_system) / sizeof(struct fs_ops)); + +#ifdef LIBSA_TOO_OLD +#include "../boot/vaxstand.h" + +struct rom_softc { + int part; + int unit; +} rom_softc; + +int romstrategy(void *, int, daddr_t, size_t, void *, size_t *); +int romopen(struct open_file *, int, int, int, int); +struct devsw devsw[] = { + SADEV("rom", romstrategy, romopen, nullsys, noioctl), +}; +int ndevs = (sizeof(devsw)/sizeof(devsw[0])); + +int +romopen(f, adapt, ctlr, unit, part) + struct open_file *f; + int adapt, ctlr, unit, part; +{ + rom_softc.unit = unit; + rom_softc.part = part; + + f->f_devdata = (void *)&rom_softc; + + return 0; +} + +#endif + +#if 0 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); @@ -233,101 +261,68 @@ tar_read(f, buf, size, resid) { romstrategy(0, 0, (8192+512), size, buf, 0); *resid = size; + return 0; /* XXX */ } +#endif -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; +int 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]; - struct devsw *dp; +#ifdef LIBSA_TOO_OLD + int i; + struct devsw *dp; f->f_dev = &devsw[0]; +#endif *file = (char *)fname; + if (from == FROM750) + return 0; /* - * On uVAX we need to init [T]MSCP ctlr to be able to use it. + * Reinit the VMB boot device. */ - if (vax_cputype == VAX_TYP_UV2 || vax_cputype == VAX_TYP_CVAX) { - switch (bootdev) { - case BDEV_UDA: /* MSCP */ - case BDEV_TK: /* TMSCP */ + if (bqo->unit_init && (moved++ == 0)) { + int initfn; + + initfn = rpb->iovec + bqo->unit_init; + if (rpb->devtyp == BDEV_UDA || rpb->devtyp == BDEV_TK) { + /* + * This reset do not seem to be done in the + * ROM routines, so we have to do it manually. + */ 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); + csr->udaip = 0; + while ((csr->udasa & MP_STEP1) == 0) + ; } + /* + * AP (R12) have a pointer to the VMB argument list, + * wanted by bqo->unit_init. + */ + unit_init(initfn, rpb, bootregs[12]); } - - /* - * 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); - - /* currently only one dev in devsw; this must change if we add more */ - dp = devsw; - i = 0; - if(dp != NULL && dp->dv_open != NULL) { - i = (*dp->dv_open)(f, B_ADAPTOR(bootdev), B_CONTROLLER(bootdev), - B_UNIT(bootdev), B_PARTITION(bootdev)); - } - - return i; -} - -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); - +#ifdef LIBSA_TOO_OLD_FOO + /* currently only one dev in devsw; this must change if we add more */ + dp = devsw; + i = 0; + if(dp != NULL && dp->dv_open != NULL) { + i = (*dp->dv_open)(f, B_ADAPTOR(bootdev), B_CONTROLLER(bootdev), + B_UNIT(bootdev), B_PARTITION(bootdev)); + } + + return i; +#else + return 0; +#endif } -int curblock = 0; +extern struct disklabel romlabel; +int romstrategy(sc, func, dblk, size, buf, rsize) void *sc; int func; @@ -336,77 +331,31 @@ romstrategy(sc, func, dblk, size, buf, rsize) void *buf; size_t *rsize; { - struct rom_softc *romsc = sc; - 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 (B_TYPE(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); + if (romlabel.d_magic == DISKMAGIC && romlabel.d_magic2 == DISKMAGIC) { + if (romlabel.d_npartitions > 1) { + block += romlabel.d_partitions[0].p_offset; + if (romlabel.d_partitions[0].p_fstype == FS_RAID) { + block += RF_PROTECTED_SECTORS; } - 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_SDN: /* XXX others too eventually */ - case BDEV_SD: /* XXX others too eventually */ - if(romsc != NULL) - block += lp.d_partitions[romsc->part].p_offset; - case BDEV_RD: - case BDEV_ST: - - default: - romread_uvax(block, size, buf, bootregs); - break; + } + } + if (from == FROMMV) { + romread_uvax(block, size, buf, rpb); + } else /* if (from == FROM750) */ { + while (size > 0) { + if (rpb->devtyp == BDEV_HP) + hpread(block); + else + read750(block, bootregs); + bcopy(0, buf, 512); + size -= 512; + (char *)buf += 512; + block++; } - 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) @@ -414,50 +363,66 @@ romstrategy(sc, func, dblk, size, buf, rsize) return 0; } -int -romopen(f, adapt, ctlr, unit, part) - struct open_file *f; - int adapt, ctlr, unit, part; -{ - rom_softc.unit = unit; - rom_softc.part = part; - - f->f_devdata = (void *)&rom_softc; - - return 0; -} +/* + * The 11/750 boot ROM for Massbus disks doesn't seen to have layout info + * for all RP disks (not RP07 at least) so therefore a very small and dumb + * device driver is used. It assumes that there is a label on the disk + * already that has valid layout info. If there is no label, we can't boot + * anyway. + */ + +#define MBA_WCSR(reg, val) \ + ((void)(*(volatile u_int32_t *)((adpadr) + (reg)) = (val))); +#define MBA_RCSR(reg) \ + (*(volatile u_int32_t *)((adpadr) + (reg))) +#define HP_WCSR(reg, val) \ + ((void)(*(volatile u_int32_t *)((unitadr) + (reg)) = (val))); +#define HP_RCSR(reg) \ + (*(volatile u_int32_t *)((unitadr) + (reg))) -hpread(block, size, buf) - char *buf; +void +hpread(int bn) { - 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; + int adpadr = bootregs[1]; + int unitadr = adpadr + MUREG(bootregs[3], 0); + u_int cn, sn, tn; + struct disklabel *dp; + extern char start; + + dp = (struct disklabel *)(LABELOFFSET + &start); + MBA_WCSR(MAPREG(0), PG_V); + + MBA_WCSR(MBA_VAR, 0); + MBA_WCSR(MBA_BC, (~512) + 1); +#ifdef __GNUC__ + /* + * Avoid four subroutine calls by using hardware division. + */ + asm("clrl %r1;" + "movl %3,%r0;" + "ediv %4,%r0,%0,%1;" + "movl %1,%r0;" + "ediv %5,%r0,%2,%1" + : "=g"(cn),"=g"(sn),"=g"(tn) + : "g"(bn),"g"(dp->d_secpercyl),"g"(dp->d_nsectors) + : "r0","r1","cc"); +#else 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; +#endif + HP_WCSR(HP_DC, cn); + HP_WCSR(HP_DA, (tn << 8) | sn); + HP_WCSR(HP_CS1, HPCS_READ); + + while (MBA_RCSR(MBA_SR) & MBASR_DTBUSY) + ; + return; } extern char end[]; -static char *top = (char *)end; +static char *top = (char*)end; void * alloc(size) @@ -481,3 +446,31 @@ romclose(f) { return 0; } + +#ifdef USE_PRINTF +void +putchar(int ch) +{ + /* + * On KA88 we may get C-S/C-Q from the console. + * Must obey it. + */ + while (mfpr(PR_RXCS) & GC_DON) { + if ((mfpr(PR_RXDB) & 0x7f) == 19) { + while (1) { + while ((mfpr(PR_RXCS) & GC_DON) == 0) + ; + if ((mfpr(PR_RXDB) & 0x7f) == 17) + break; + } + } + } + + while ((mfpr(PR_TXCS) & GC_RDY) == 0) + ; + mtpr(0, PR_TXCS); + mtpr(ch & 0377, PR_TXDB); + if (ch == 10) + putchar(13); +} +#endif diff --git a/sys/arch/vax/boot/xxboot/start.s b/sys/arch/vax/boot/xxboot/start.S index f39ecafab62..309b53f308e 100644 --- a/sys/arch/vax/boot/xxboot/start.s +++ b/sys/arch/vax/boot/xxboot/start.S @@ -1,5 +1,5 @@ -/* $OpenBSD: start.s,v 1.3 2000/11/25 21:33:08 hugh Exp $ */ -/* $NetBSD: start.s,v 1.2 1999/10/23 14:40:38 ragge Exp $ */ +/* $OpenBSD: start.S,v 1.1 2002/06/11 09:36:24 hugh Exp $ */ +/* $NetBSD: start.S,v 1.1 2002/02/24 01:04:26 matt Exp $ */ /* * Copyright (c) 1995 Ludd, University of Lule}, Sweden. * All rights reserved. @@ -17,8 +17,8 @@ * 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. + * 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 * @@ -37,15 +37,17 @@ /* All bugs are subject to removal without further notice */ -#define _LOCORE +#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 +_C_LABEL(_start): +_C_LABEL(start): + .globl _C_LABEL(start) # this is the symbolic name for the start + .globl _C_LABEL(_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). @@ -53,7 +55,7 @@ _start: .globl _start # this is the symbolic name for the start 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 0xff # 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 @@ -61,38 +63,53 @@ _start: .globl _start # this is the symbolic name for the start .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 + movzbl $1,_C_LABEL(from)# We booted from "old" rom. 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 + brw start_uvax # all uVAXen continue there -.org LABELOFFSET - 6 -regmask: .word 0x0fff # using a variable saves 3 bytes !!! -bootinfo: .long 0x0 # another 3 bytes if within byte-offset +from_0x08: # Any machine from VMB + movzbl $4,_C_LABEL(from) # Booted from full VMB + brw start_vmb # 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. +.org LABELOFFSET + .globl _C_LABEL(romlabel) +_C_LABEL(romlabel): + .long 0 + +.org LABELOFFSET + d_end_ +start_vmb: + /* + * Read in block 1-15. + */ + 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 $1 # lbn to start reading + pushl $7680 # number of bytes to read + pushab start_uvax # buffer-address + calls $6, (r6) # call the qio-routine + brw start_uvax + /* * 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 */ +#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 0x260 /* byte offset into secondary image */ -.org LABELOFFSET + d_end_ +.org 0x1fe .byte 0x18 # must be 0x18 .byte 0x00 # must be 0x00 (MBZ) .byte 0x00 # any value @@ -106,15 +123,21 @@ bootinfo: .long 0x0 # another 3 bytes if within byte-offset .long SISIZE # size in blocks of secondary image .long SILOAD # load offset (usually 0) - .long SIOFF # byte offset into secondary image + .long SIOFF # byte offset into secondary image .long (SISIZE + SILOAD + SIOFF) # sum of previous 3 + + .align 2 + .globl _C_LABEL(from) +_C_LABEL(from): + .long 0 + /* * 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 + * R0: type of boot-device * 0: Massbus device * 1: RK06/RK07 * 2: RL02 @@ -123,35 +146,39 @@ bootinfo: .long 0x0 # another 3 bytes if within byte-offset * 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 + * 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 - 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 - - .org 0x300 + movl $_C_LABEL(start), sp # move stack to avoid clobbering the code + pushr $0x131 # save clobbered registers + clrl r4 # %r4 == # of blocks transferred + movab _C_LABEL(start),r5 # %r5 have base address for next transfer + pushl r5 # ...on stack also (Why?) +1: incl r4 # increment block count + movl r4,r8 # LBN is in %r8 for rom routine + addl2 $0x200,r5 # Increase address for next read + cmpl $16,r4 # read 15 blocks? + beql 2f # Yep + movl r5,(sp) # move address to stack also + jsb (r6) # read 512 bytes + blbs r0,1b # jump if read succeeded + halt # otherwise die... +2: tstl (sp)+ # remove boring arg from stack + popr $0x131 # restore clobbered registers + brw start_all # Ok, continue... + +/* uVAX main entry is at the start of the second disk block. This is + * needed for multi-arch CD booting where multiple architecture need + * to shove stuff in boot block 0. + */ + .org 0x260 # uVAX booted from disk starts here start_uvax: - mtpr $0, $PR_MAPEN # Turn off MM, please. - movl $_start, sp + movzbl $2,_C_LABEL(from) # Booted from subset-VMB brb start_all /* @@ -159,20 +186,23 @@ start_uvax: * to RELOC and loads boot. */ start_all: + movl $_C_LABEL(start), sp # move stack to a better pushr $0x1fff # 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 + subl3 $_C_LABEL(start), $_C_LABEL(edata), r0 + # get size of text+data (w/o bss) + moval _C_LABEL(start), r1 # get actual base-address of code + subl3 $_C_LABEL(start), $_C_LABEL(end), r2 + # get complete size (incl. bss) + movl $_C_LABEL(start), r3 # get relocated base-address of code movc5 r0, (r1), $0, r2, (r3) # copy code to new location - jsb 1f -1: movl $relocated, (sp) # return-address on top of stack - rsb # can be replaced with new address + movpsl -(sp) + movl $relocated, -(sp) # return-address on top of stack + rei # can be replaced with new address relocated: # now relocation is done !!! - movl sp, _bootregs - calls $0, _Xmain # call Xmain (gcc workaround)which is + movl sp, _C_LABEL(bootregs) + calls $0, _C_LABEL(Xmain) # call Xmain (gcc workaround)which is halt # not intended to return ... /* @@ -180,20 +210,32 @@ relocated: # now relocation is done !!! */ 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) + movl _C_LABEL(rpb),r11 + mnegl $1,ap # Hack to figure out boot device. + movpsl -(sp) + pushab 2(r6) + mnegl $1,_C_LABEL(vax_load_failure) + rei +# calls $0,(r6) halt +ENTRY(unit_init, R6|R7|R8|R9|R10|R11) + mfpr $17,r7 # Wanted bu KDB + movl 4(ap),r0 # init routine address + movl 8(ap),r9 # RPB in %r9 + movl 12(ap),r1 # VMB argument list + callg (r1),(r0) + ret + # A bunch of functions unwanted in boot blocks. ENTRY(getchar, 0) halt +#ifndef USE_PRINTF ENTRY(putchar, 0) ret +#endif + ENTRY(panic, 0) halt |