summaryrefslogtreecommitdiff
path: root/sys/arch/vax/bi
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/vax/bi')
-rw-r--r--sys/arch/vax/bi/bi.c148
-rw-r--r--sys/arch/vax/bi/bireg.h245
-rw-r--r--sys/arch/vax/bi/bivar.h59
-rw-r--r--sys/arch/vax/bi/kdb.c313
-rw-r--r--sys/arch/vax/bi/kdbreg.h64
5 files changed, 829 insertions, 0 deletions
diff --git a/sys/arch/vax/bi/bi.c b/sys/arch/vax/bi/bi.c
new file mode 100644
index 00000000000..cfb0171ee76
--- /dev/null
+++ b/sys/arch/vax/bi/bi.c
@@ -0,0 +1,148 @@
+/* $NetBSD: bi.c,v 1.4 1996/10/13 03:34:44 christos Exp $ */
+/*
+ * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed at Ludd, University of
+ * Lule}, Sweden and its contributors.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+
+/*
+ * VAXBI specific routines.
+ */
+/*
+ * TODO
+ * handle BIbus errors more gracefully.
+ */
+
+#include <sys/param.h>
+#include <sys/device.h>
+
+#include <machine/mtpr.h>
+#include <machine/nexus.h>
+#include <machine/cpu.h>
+
+#include <arch/vax/bi/bireg.h>
+#include <arch/vax/bi/bivar.h>
+
+static int bi_match __P((struct device *, void *, void *));
+static void bi_attach __P((struct device *, struct device *, void*));
+static int bi_print __P((void *, const char *));
+
+struct cfdriver bi_cd = {
+ NULL, "bi", DV_DULL
+};
+
+struct cfattach bi_ca = {
+ sizeof(struct bi_softc), bi_match, bi_attach
+};
+
+struct bi_list bi_list[] = {
+ {BIDT_MS820, 1, "ms820"},
+ {BIDT_DRB32, 0, "drb32"},
+ {BIDT_DWBUA, 0, "dwbua"},
+ {BIDT_KLESI, 0, "klesi"},
+ {BIDT_KA820, 1, "ka820"},
+ {BIDT_DB88, 0, "db88"},
+ {BIDT_CIBCA, 0, "cibca"},
+ {BIDT_DMB32, 0, "dmb32"},
+ {BIDT_CIBCI, 0, "cibci"},
+ {BIDT_KA800, 0, "ka800"},
+ {BIDT_KDB50, 0, "kdb50"},
+ {BIDT_DWMBA, 0, "dwmba"},
+ {BIDT_KFBTA, 0, "kfbta"},
+ {BIDT_DEBNK, 0, "debnk"},
+ {BIDT_DEBNA, 0, "debna"},
+ {0,0,0}
+};
+
+int
+bi_print(aux, name)
+ void *aux;
+ const char *name;
+{
+ struct bi_attach_args *ba = aux;
+ struct bi_list *bl;
+
+ if (name) {
+ for (bl = &bi_list[0]; bl->bl_nr; bl++)
+ if (bl->bl_nr == ba->ba_node->biic.bi_dtype) {
+ printf(bl->bl_name);
+ break;
+ }
+ if (bl->bl_nr == 0)
+ printf("unknown device 0x%x",
+ ba->ba_node->biic.bi_dtype);
+ printf(" at %s", name);
+ }
+ printf(" node %d", ba->ba_nodenr);
+ return bl->bl_havedriver ? UNCONF : UNSUPP;
+}
+
+int
+bi_match(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
+{
+ struct bp_conf *bp = aux;
+
+ if (strcmp(bp->type, "bi"))
+ return 0;
+ return 1;
+}
+
+void
+bi_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct bp_conf *bp = aux;
+ struct bi_softc *bi = (void *)self;
+ struct bi_node *binode;
+ struct bi_attach_args ba;
+ int nodenr;
+
+ printf("\n");
+ binode = bi->bi_base = (struct bi_node *)bp->bp_addr;
+
+ ba.ba_intcpu = 1 << mastercpu;
+ for (nodenr = 0; nodenr < NNODEBI; nodenr++) {
+ if (badaddr((caddr_t)&binode[nodenr], 4))
+ continue;
+
+ ba.ba_node = &binode[nodenr];
+ ba.ba_nodenr = nodenr;
+ config_found(self, &ba, bi_print);
+ }
+}
+
+void
+bi_buserr()
+{
+ panic("bi_buserr");
+}
diff --git a/sys/arch/vax/bi/bireg.h b/sys/arch/vax/bi/bireg.h
new file mode 100644
index 00000000000..1663e168d95
--- /dev/null
+++ b/sys/arch/vax/bi/bireg.h
@@ -0,0 +1,245 @@
+/* $NetBSD: bireg.h,v 1.1 1996/07/19 14:26:53 ragge Exp $ */
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)bireg.h 7.3 (Berkeley) 6/28/90
+ */
+
+/*
+ * VAXBI node definitions.
+ */
+
+/*
+ * BI node addresses
+ */
+#define BI_BASE(bi) (0x20000000 + (bi) * 0x2000000)
+#define MAXNBI 16 /* Spec says there can be 16 anyway */
+#define NNODEBI 16 /* 16 nodes per BI */
+
+#define BI_PROBE 0x80000 /* CPU on 8200, NBIA on 8800 */
+/*
+ * BI nodes all start with BI interface registers (those on the BIIC chip).
+ * These are followed with interface-specific registers.
+ *
+ * NB: This structure does NOT include the four GPRs (not anymore!)
+ */
+struct biiregs {
+ u_short bi_dtype; /* device type */
+ u_short bi_revs; /* revisions */
+ u_long bi_csr; /* control and status register */
+ u_long bi_ber; /* bus error register */
+ u_long bi_eintrcsr; /* error interrupt control register */
+ u_long bi_intrdes; /* interrupt destination register */
+ /* the rest are not required for all nodes */
+ u_long bi_ipintrmsk; /* IP interrupt mask register */
+ u_long bi_fipsdes; /* Force-Bit IPINTR/STOP destination reg */
+ u_long bi_ipintrsrc; /* IPINTR source register */
+ u_long bi_sadr; /* starting address register */
+ u_long bi_eadr; /* ending address register */
+ u_long bi_bcicsr; /* BCI control and status register */
+ u_long bi_wstat; /* write status register */
+ u_long bi_fipscmd; /* Force-Bit IPINTR/STOP command reg */
+ u_long bi_xxx1[3]; /* unused */
+ u_long bi_uintrcsr; /* user interface interrupt control reg */
+ u_long bi_xxx2[43]; /* unused */
+/* although these are on the BIIC, their interpretation varies */
+/* u_long bi_gpr[4]; */ /* general purpose registers */
+};
+
+/*
+ * A generic BI node.
+ */
+struct bi_node {
+ struct biiregs biic; /* interface */
+ u_long bi_xxx[1988]; /* pad to 8K */
+};
+
+/*
+ * A cpu node.
+ */
+struct bi_cpu {
+ struct biiregs biic; /* interface chip */
+ u_long bi_gpr[4]; /* gprs (unused) */
+ u_long bi_sosr; /* slave only status register */
+ u_long bi_xxx[63]; /* pad */
+ u_long bi_rxcd; /* receive console data register */
+};
+
+/* device types */
+#define BIDT_MS820 0x0001 /* MS820 memory board */
+#define BIDT_DRB32 0x0101 /* DRB32 Supercomputer gateway */
+#define BIDT_DWBUA 0x0102 /* DWBUA Unibus adapter */
+#define BIDT_KLESI 0x0103 /* KLESI-B adapter */
+#define BIDT_KA820 0x0105 /* KA820 cpu */
+#define BIDT_DB88 0x0106 /* DB88 adapter */
+#define BIDT_CIBCA 0x0108 /* Computer Interconnect adapter */
+#define BIDT_DMB32 0x0109 /* DMB32 adapter */
+#define BIDT_CIBCI 0x010b /* Computer Interconnect adapter (old) */
+#define BIDT_KA800 0x010c /* KA800 slave processor */
+#define BIDT_KDB50 0x010e /* KDB50 disk controller */
+#define BIDT_DWMBA 0x2107 /* XMI - BI adapter */
+#define BIDT_KFBTA 0x410d /* RD/RX disk controller */
+#define BIDT_DEBNK 0x410e /* BI Ethernet (Lance) + TK50 */
+#define BIDT_DEBNA 0x410f /* BI Ethernet (Lance) adapter */
+
+/* bits in bi_csr */
+#define BICSR_IREV(x) ((u_char)((x) >> 24)) /* VAXBI interface rev */
+#define BICSR_TYPE(x) ((u_char)((x) >> 16)) /* BIIC type */
+#define BICSR_HES 0x8000 /* hard error summary */
+#define BICSR_SES 0x4000 /* soft error summary */
+#define BICSR_INIT 0x2000 /* initialise node */
+#define BICSR_BROKE 0x1000 /* broke */
+#define BICSR_STS 0x0800 /* self test status */
+#define BICSR_NRST 0x0400 /* node reset */
+#define BICSR_UWP 0x0100 /* unlock write pending */
+#define BICSR_HEIE 0x0080 /* hard error interrupt enable */
+#define BICSR_SEIE 0x0040 /* soft error interrupt enable */
+#define BICSR_ARB_MASK 0x0030 /* mask to get arbitration codes */
+#define BICSR_ARB_NONE 0x0030 /* no arbitration */
+#define BICSR_ARB_LOG 0x0020 /* low priority */
+#define BICSR_ARB_HIGH 0x0010 /* high priority */
+#define BICSR_ARB_RR 0x0000 /* round robin */
+#define BICSR_NODEMASK 0x000f /* node ID */
+
+#define BICSR_BITS \
+"\20\20HES\17SES\16INIT\15BROKE\14STS\13NRST\11UWP\10HEIE\7SEIE"
+
+/* bits in bi_ber */
+#define BIBER_MBZ 0x8000fff0
+#define BIBER_NMR 0x40000000 /* no ack to multi-responder command */
+#define BIBER_MTCE 0x20000000 /* master transmit check error */
+#define BIBER_CTE 0x10000000 /* control transmit error */
+#define BIBER_MPE 0x08000000 /* master parity error */
+#define BIBER_ISE 0x04000000 /* interlock sequence error */
+#define BIBER_TDF 0x02000000 /* transmitter during fault */
+#define BIBER_IVE 0x01000000 /* ident vector error */
+#define BIBER_CPE 0x00800000 /* command parity error */
+#define BIBER_SPE 0x00400000 /* slave parity error */
+#define BIBER_RDS 0x00200000 /* read data substitute */
+#define BIBER_RTO 0x00100000 /* retry timeout */
+#define BIBER_STO 0x00080000 /* stall timeout */
+#define BIBER_BTO 0x00040000 /* bus timeout */
+#define BIBER_NEX 0x00020000 /* nonexistent address */
+#define BIBER_ICE 0x00010000 /* illegal confirmation error */
+#define BIBER_UPEN 0x00000008 /* user parity enable */
+#define BIBER_IPE 0x00000004 /* ID parity error */
+#define BIBER_CRD 0x00000002 /* corrected read data */
+#define BIBER_NPE 0x00000001 /* null bus parity error */
+#define BIBER_HARD 0x4fff0000
+
+#define BIBER_BITS \
+"\20\37NMR\36MTCE\35CTE\34MPE\33ISE\32TDF\31IVE\30CPE\
+\27SPE\26RDS\25RTO\24STO\23BTO\22NEX\21ICE\4UPEN\3IPE\2CRD\1NPE"
+
+/* bits in bi_eintrcsr */
+#define BIEIC_INTRAB 0x01000000 /* interrupt abort */
+#define BIEIC_INTRC 0x00800000 /* interrupt complete */
+#define BIEIC_INTRSENT 0x00200000 /* interrupt command sent */
+#define BIEIC_INTRFORCE 0x00100000 /* interrupt force */
+#define BIEIC_LEVELMASK 0x000f0000 /* mask for interrupt levels */
+#define BIEIC_IPL17 0x00080000 /* ipl 0x17 */
+#define BIEIC_IPL16 0x00040000 /* ipl 0x16 */
+#define BIEIC_IPL15 0x00020000 /* ipl 0x15 */
+#define BIEIC_IPL14 0x00010000 /* ipl 0x14 */
+#define BIEIC_VECMASK 0x00003ffc /* vector mask for error intr */
+
+/* bits in bi_intrdes */
+#define BIDEST_MASK 0x0000ffff /* one bit per node to be intr'ed */
+
+/* bits in bi_ipintrmsk */
+#define BIIPINTR_MASK 0xffff0000 /* one per node to allow to ipintr */
+
+/* bits in bi_fipsdes */
+#define BIFIPSD_MASK 0x0000ffff
+
+/* bits in bi_ipintrsrc */
+#define BIIPSRC_MASK 0xffff0000
+
+/* sadr and eadr are simple addresses */
+
+/* bits in bi_bcicsr */
+#define BCI_BURSTEN 0x00020000 /* burst mode enable */
+#define BCI_IPSTOP_FRC 0x00010000 /* ipintr/stop force */
+#define BCI_MCASTEN 0x00008000 /* multicast space enable */
+#define BCI_BCASTEN 0x00004000 /* broadcast enable */
+#define BCI_STOPEN 0x00002000 /* stop enable */
+#define BCI_RSRVDEN 0x00001000 /* reserved enable */
+#define BCI_IDENTEN 0x00000800 /* ident enable */
+#define BCI_INVALEN 0x00000400 /* inval enable */
+#define BCI_WINVEN 0x00000200 /* write invalidate enable */
+#define BCI_UINTEN 0x00000100 /* user interface csr space enable */
+#define BCI_BIICEN 0x00000080 /* BIIC csr space enable */
+#define BCI_INTEN 0x00000040 /* interrupt enable */
+#define BCI_IPINTEN 0x00000020 /* ipintr enable */
+#define BCI_PIPEEN 0x00000010 /* pipeline NXT enable */
+#define BCI_RTOEVEN 0x00000008 /* read timeout EV enable */
+
+#define BCI_BITS \
+"\20\22BURSTEN\21IPSTOP_FRC\20MCASTEN\
+\17BCASTEN\16STOPEN\15RSRVDEN\14IDENTEN\13INVALEN\12WINVEN\11UINTEN\
+\10BIICEN\7INTEN\6IPINTEN\5PIPEEN\4RTOEVEN"
+
+/* bits in bi_wstat */
+#define BIW_GPR3 0x80000000 /* gpr 3 was written */
+#define BIW_GPR2 0x40000000 /* gpr 2 was written */
+#define BIW_GPR1 0x20000000 /* gpr 1 was written */
+#define BIW_GPR0 0x10000000 /* gpr 0 was written */
+
+/* bits in force-bit ipintr/stop command register 8/
+#define BIFIPSC_CMDMASK 0x0000f000 /* command */
+#define BIFIPSC_MIDEN 0x00000800 /* master ID enable */
+
+/* bits in bi_uintcsr */
+#define BIUI_INTAB 0xf0000000 /* interrupt abort level */
+#define BIUI_INTC 0x0f000000 /* interrupt complete bits */
+#define BIUI_SENT 0x00f00000 /* interrupt sent bits */
+#define BIUI_FORCE 0x000f0000 /* force interrupt level */
+#define BIUI_EVECEN 0x00008000 /* external vector enable */
+#define BIUI_VEC 0x00003ffc /* interrupt vector */
+
+/* tell if a bi device is a slave (hence has SOSR) */
+#define BIDT_ISSLAVE(x) (((x) & 0x7f00) == 0)
+
+/* bits in bi_sosr */
+#define BISOSR_MEMSIZE 0x1ffc0000 /* memory size */
+#define BISOSR_BROKE 0x00001000 /* broke */
+
+/* bits in bi_rxcd */
+#define BIRXCD_BUSY2 0x80000000 /* busy 2 */
+#define BIRXCD_NODE2 0x0f000000 /* node id 2 */
+#define BIRXCD_CHAR2 0x00ff0000 /* character 2 */
+#define BIRXCD_BUSY1 0x00008000 /* busy 1 */
+#define BIRXCD_NODE1 0x00000f00 /* node id 1 */
+#define BIRXCD_CHAR1 0x000000ff /* character 1 */
diff --git a/sys/arch/vax/bi/bivar.h b/sys/arch/vax/bi/bivar.h
new file mode 100644
index 00000000000..bb6d3972cfb
--- /dev/null
+++ b/sys/arch/vax/bi/bivar.h
@@ -0,0 +1,59 @@
+/* $NetBSD: bivar.h,v 1.1 1996/07/19 14:26:54 ragge Exp $ */
+/*
+ * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed at Ludd, University of
+ * Lule}, Sweden and its contributors.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+
+/*
+ * per-BI-adapter state.
+ */
+struct bi_softc {
+ struct device bi_dev;
+ struct bi_node *bi_base;
+};
+
+/*
+ * Struct used for autoconfiguration; attaching of BI nodes.
+ */
+struct bi_attach_args {
+ struct bi_node *ba_node;
+ int ba_nodenr;
+ int ba_intcpu; /* Mask of which cpus to interrupt */
+};
+
+/*
+ * BI node list.
+ */
+struct bi_list {
+ u_short bl_nr; /* Unit ID# */
+ u_short bl_havedriver; /* Have device driver */
+ char *bl_name; /* DEC name */
+};
diff --git a/sys/arch/vax/bi/kdb.c b/sys/arch/vax/bi/kdb.c
new file mode 100644
index 00000000000..13f8f4f8f74
--- /dev/null
+++ b/sys/arch/vax/bi/kdb.c
@@ -0,0 +1,313 @@
+/* $NetBSD: kdb.c,v 1.5 1997/01/11 11:34:39 ragge Exp $ */
+/*
+ * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed at Ludd, University of
+ * Lule}, Sweden and its contributors.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * KDB50 disk device driver
+ */
+/*
+ * TODO
+ * Implement node reset routine.
+ * Nices hardware error handling.
+ */
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/buf.h>
+#include <sys/device.h>
+#include <sys/proc.h>
+#include <sys/malloc.h>
+
+#include <vm/vm.h>
+#include <vm/vm_kern.h>
+
+#include <machine/sid.h>
+#include <machine/pte.h>
+#include <machine/pcb.h>
+#include <machine/trap.h>
+#include <machine/scb.h>
+
+#include <vax/bi/bireg.h>
+#include <vax/bi/bivar.h>
+#include <vax/bi/kdbreg.h>
+
+#include <vax/mscp/mscp.h>
+#include <vax/mscp/mscpvar.h>
+#include <vax/mscp/mscpreg.h>
+
+#define b_forw b_hash.le_next
+/*
+ * Software status, per controller.
+ */
+struct kdb_softc {
+ struct device sc_dev; /* Autoconfig info */
+ struct ivec_dsp sc_ivec; /* Interrupt vector handler */
+ struct mscp_pack sc_kdb; /* Struct for kdb communication */
+ struct mscp_softc *sc_softc; /* MSCP info (per mscpvar.h) */
+ struct kdb_regs *sc_kr; /* KDB controller registers */
+ struct mscp *sc_mscp; /* Keep pointer to active mscp */
+};
+
+int kdbmatch __P((struct device *, void *, void *));
+void kdbattach __P((struct device *, struct device *, void *));
+void kdbreset __P((int));
+void kdbintr __P((int));
+void kdbctlrdone __P((struct device *, int));
+int kdbprint __P((void *, const char *));
+void kdbsaerror __P((struct device *, int));
+int kdbgo __P((struct device *, struct buf *));
+
+struct cfdriver kdb_cd = {
+ NULL, "kdb", DV_DULL
+};
+
+struct cfattach kdb_ca = {
+ sizeof(struct kdb_softc), kdbmatch, kdbattach
+};
+
+/*
+ * More driver definitions, for generic MSCP code.
+ */
+struct mscp_ctlr kdb_mscp_ctlr = {
+ kdbctlrdone,
+ kdbgo,
+ kdbsaerror,
+};
+
+int
+kdbprint(aux, name)
+ void *aux;
+ const char *name;
+{
+ if (name)
+ printf("%s: mscpbus", name);
+ return UNCONF;
+}
+
+/*
+ * Poke at a supposed KDB to see if it is there.
+ */
+int
+kdbmatch(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
+{
+ struct cfdata *cf = match;
+ struct bi_attach_args *ba = aux;
+
+ if (ba->ba_node->biic.bi_dtype != BIDT_KDB50)
+ return 0;
+
+ if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != ba->ba_nodenr)
+ return 0;
+
+ return 1;
+}
+
+void
+kdbattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct kdb_softc *sc = (void *)self;
+ struct bi_attach_args *ba = aux;
+ struct mscp_attach_args ma;
+ extern struct ivec_dsp idsptch;
+ volatile int i = 10000;
+
+ printf("\n");
+ bcopy(&idsptch, &sc->sc_ivec, sizeof(struct ivec_dsp));
+ scb->scb_nexvec[1][ba->ba_nodenr] = &sc->sc_ivec;
+ sc->sc_ivec.hoppaddr = kdbintr;
+ sc->sc_ivec.pushlarg = self->dv_unit;
+ sc->sc_kr = (void *)ba->ba_node;
+
+ bzero(&sc->sc_kdb, sizeof (struct mscp_pack));
+
+ ma.ma_mc = &kdb_mscp_ctlr;
+ ma.ma_type = MSCPBUS_DISK|MSCPBUS_KDB;
+ ma.ma_uuda = (struct mscp_pack *)kvtophys(&sc->sc_kdb);
+ ma.ma_uda = &sc->sc_kdb;
+ ma.ma_ip = &sc->sc_kr->kdb_ip;
+ ma.ma_sa = &sc->sc_kr->kdb_sa;
+ ma.ma_sw = &sc->sc_kr->kdb_sw;
+ ma.ma_softc = &sc->sc_softc;
+ ma.ma_ivec = (int)&scb->scb_nexvec[1][ba->ba_nodenr] - (int)scb;
+ ma.ma_ctlrnr = ba->ba_nodenr;
+ sc->sc_kr->kdb_bi.bi_csr |= BICSR_NRST;
+ while (i--) /* Need delay??? */
+ ;
+ sc->sc_kr->kdb_bi.bi_intrdes = ba->ba_intcpu;
+ sc->sc_kr->kdb_bi.bi_bcicsr |= BCI_STOPEN | BCI_IDENTEN | BCI_UINTEN |
+ BCI_INTEN;
+ sc->sc_kr->kdb_bi.bi_uintrcsr = ma.ma_ivec;
+ config_found(&sc->sc_dev, &ma, kdbprint);
+}
+
+int
+kdbgo(usc, bp)
+ struct device *usc;
+ struct buf *bp;
+{
+ struct kdb_softc *sc = (void *)usc;
+ struct mscp_softc *mi = sc->sc_softc;
+ struct mscp *mp = (void *)bp->b_actb;
+ struct pcb *pcb;
+ pt_entry_t *pte;
+ int pfnum, npf, o, i;
+ unsigned info = 0;
+ caddr_t addr;
+
+ o = (int)bp->b_un.b_addr & PGOFSET;
+ npf = btoc(bp->b_bcount + o) + 1;
+ addr = bp->b_un.b_addr;
+
+ /*
+ * Get a pointer to the pte pointing out the first virtual address.
+ * Use different ways in kernel and user space.
+ */
+ if ((bp->b_flags & B_PHYS) == 0) {
+ pte = kvtopte(addr);
+ } else {
+ pcb = bp->b_proc->p_vmspace->vm_pmap.pm_pcb;
+ pte = uvtopte(addr, pcb);
+ }
+
+ /*
+ * When we are doing DMA to user space, be sure that all pages
+ * we want to transfer to is mapped. WHY DO WE NEED THIS???
+ * SHOULDN'T THEY ALWAYS BE MAPPED WHEN DOING THIS???
+ */
+ for (i = 0; i < (npf - 1); i++) {
+ if ((pte + i)->pg_pfn == 0) {
+ int rv;
+ rv = vm_fault(&bp->b_proc->p_vmspace->vm_map,
+ (unsigned)addr + i * NBPG,
+ VM_PROT_READ|VM_PROT_WRITE, FALSE);
+ if (rv)
+ panic("KDB DMA to nonexistent page, %d", rv);
+ }
+ }
+ /*
+ * pte's for userspace isn't necessary positioned
+ * in consecutive physical pages. We check if they
+ * are, otherwise we need to copy the pte's to a
+ * physically contigouos page area.
+ * XXX some copying here may be unneccessary. Subject to fix.
+ */
+ if (bp->b_flags & B_PHYS) {
+ int i = kvtophys(pte);
+ unsigned k;
+
+ if (trunc_page(i) != trunc_page(kvtophys(pte) + npf * 4)) {
+ info = (unsigned)malloc(2 * NBPG, M_DEVBUF, M_WAITOK);
+ k = (info + PGOFSET) & ~PGOFSET;
+ bcopy(pte, (void *)k, NBPG);
+ i = kvtophys(k);
+ }
+ mp->mscp_seq.seq_mapbase = i;
+ } else
+ mp->mscp_seq.seq_mapbase = (unsigned)pte;
+ mscp_dgo(mi, KDB_MAP | o, info, bp);
+ return 1;
+}
+
+void
+kdbsaerror(usc, doreset)
+ struct device *usc;
+ int doreset;
+{
+ struct kdb_softc *sc = (void *)usc;
+ register int code = sc->sc_kr->kdb_sa;
+
+ if ((code & MP_ERR) == 0)
+ return;
+ printf("%s: controller error, sa=0x%x\n", sc->sc_dev.dv_xname, code);
+ /* What to do now??? */
+}
+
+/*
+ * Interrupt routine. Depending on the state of the controller,
+ * continue initialisation, or acknowledge command and response
+ * interrupts, and process responses.
+ */
+void
+kdbintr(ctlr)
+ int ctlr;
+{
+ struct kdb_softc *sc = kdb_cd.cd_devs[ctlr];
+ struct uba_softc *uh;
+ struct mscp_pack *ud;
+
+ if (sc->sc_kr->kdb_sa & MP_ERR) { /* ctlr fatal error */
+ kdbsaerror(&sc->sc_dev, 1);
+ return;
+ }
+ mscp_intr(sc->sc_softc);
+}
+
+#ifdef notyet
+/*
+ * The KDB50 has been reset. Reinitialise the controller
+ * and requeue outstanding I/O.
+ */
+void
+kdbreset(ctlr)
+ int ctlr;
+{
+ register struct kdb_softc *sc;
+
+ sc = kdb_cd.cd_devs[ctlr];
+ printf(" kdb%d", ctlr);
+
+
+ /* reset queues and requeue pending transfers */
+ mscp_requeue(sc->sc_softc);
+
+ /*
+ * If it fails to initialise we will notice later and
+ * try again (and again...). Do not call kdbstart()
+ * here; it will be done after the controller finishes
+ * initialisation.
+ */
+ if (kdbinit(sc))
+ printf(" (hung)");
+}
+#endif
+
+void
+kdbctlrdone(usc, info)
+ struct device *usc;
+ int info;
+{
+ if (info)
+ free((void *)info, NBPG * 2);
+}
diff --git a/sys/arch/vax/bi/kdbreg.h b/sys/arch/vax/bi/kdbreg.h
new file mode 100644
index 00000000000..95ed9548093
--- /dev/null
+++ b/sys/arch/vax/bi/kdbreg.h
@@ -0,0 +1,64 @@
+/* $NetBSD: kdbreg.h,v 1.1 1996/07/19 14:26:56 ragge Exp $ */
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)kdbreg.h 7.3 (Berkeley) 6/28/90
+ */
+
+/*
+ * The KDB50 registers are embedded inside the bi interface
+ * general-purpose registers.
+ */
+struct kdb_regs {
+ struct biiregs kdb_bi;
+ short kdb_xxx; /* first half of GPR 0 unused */
+ short kdb_ip; /* initialisation and polling */
+ short kdb_sa; /* status & address (r/o half) */
+ short kdb_sw; /* status & address (w/o half) */
+};
+
+#define KDBSR_BITS \
+"\20\20ERR\17STEP4\16STEP3\15STEP2\14STEP1\13oldNV\12oldQB\11DI\10IE\1GO"
+
+/*
+ * Asserting KDB_MAP in values placed in mscp_seq.seq_buffer tells
+ * the KDB to use mscp_seq.seq_mapbase as a set of PTEs and seq_buffer
+ * as an offset value. Hence we need no mappings; the KDB50 reads
+ * the hardware page tables directly. (Without KDB_MAP, seq_bufer
+ * represents the physical memory address instead, and seq_mapbase is
+ * unused.)
+ */
+#define KDB_MAP 0x80000000
+#define KDB_PHYS 0 /* pseudo flag */