Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/vax/boot/boot Standalone device driver for DEBNx (n...
details: https://anonhg.NetBSD.org/src/rev/fdfb481505ce
branches: trunk
changeset: 487952:fdfb481505ce
user: ragge <ragge%NetBSD.org@localhost>
date: Thu Jun 15 19:53:23 2000 +0000
description:
Standalone device driver for DEBNx (ni) ethernet controllers.
diffstat:
sys/arch/vax/boot/boot/Makefile | 4 +-
sys/arch/vax/boot/boot/conf.c | 4 +-
sys/arch/vax/boot/boot/if_ni.c | 533 ++++++++++++++++++++++++++++++++++++++
sys/arch/vax/boot/boot/vaxstand.h | 4 +-
4 files changed, 541 insertions(+), 4 deletions(-)
diffs (truncated from 596 to 300 lines):
diff -r 20d25a12bbb3 -r fdfb481505ce sys/arch/vax/boot/boot/Makefile
--- a/sys/arch/vax/boot/boot/Makefile Thu Jun 15 19:49:37 2000 +0000
+++ b/sys/arch/vax/boot/boot/Makefile Thu Jun 15 19:53:23 2000 +0000
@@ -1,11 +1,11 @@
-# $NetBSD: Makefile,v 1.9 2000/06/11 23:30:35 matt Exp $
+# $NetBSD: Makefile,v 1.10 2000/06/15 19:53:23 ragge Exp $
S= ${.CURDIR}/../../../..
PROG= boot
NOMAN= 1
WARNS?= 1
-DEVS= hp.c ctu.c ra.c mfm.c if_qe.c if_le.c if_ze.c if_de.c
+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 str.s ${DEVS} findcpu.c
diff -r 20d25a12bbb3 -r fdfb481505ce sys/arch/vax/boot/boot/conf.c
--- a/sys/arch/vax/boot/boot/conf.c Thu Jun 15 19:49:37 2000 +0000
+++ b/sys/arch/vax/boot/boot/conf.c Thu Jun 15 19:53:23 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: conf.c,v 1.9 2000/05/26 20:18:57 ragge 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.
@@ -63,6 +63,7 @@
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[] = {
@@ -79,6 +80,7 @@
BDEV_ZE,
BDEV_RL,
BDEV_DE,
+ BDEV_NI,
};
int ndevs = (sizeof(devsw)/sizeof(devsw[0]));
diff -r 20d25a12bbb3 -r fdfb481505ce sys/arch/vax/boot/boot/if_ni.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/vax/boot/boot/if_ni.c Thu Jun 15 19:53:23 2000 +0000
@@ -0,0 +1,533 @@
+/* $NetBSD: if_ni.c,v 1.1 2000/06/15 19:53:23 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 <net/if_ether.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.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 <dev/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 <dev/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 & ~(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;
Home |
Main Index |
Thread Index |
Old Index