summaryrefslogtreecommitdiff
path: root/sys/arch/vax/vsa
diff options
context:
space:
mode:
authorBrandon Creighton <bjc@cvs.openbsd.org>2000-04-27 02:34:51 +0000
committerBrandon Creighton <bjc@cvs.openbsd.org>2000-04-27 02:34:51 +0000
commit204e11e3802aa3e6340311c7f842be2205fcd3e0 (patch)
tree5b1fb513b23c0c50d5495f04e12cc8b8e66866b8 /sys/arch/vax/vsa
parent56644002c5cb52c79e4f6d8eadc328882f24df33 (diff)
forgot these, oops
Diffstat (limited to 'sys/arch/vax/vsa')
-rw-r--r--sys/arch/vax/vsa/dz_ibus.c332
-rw-r--r--sys/arch/vax/vsa/if_le_vsbus.c247
-rw-r--r--sys/arch/vax/vsa/if_ze_vsbus.c127
-rw-r--r--sys/arch/vax/vsa/smg.c525
4 files changed, 1231 insertions, 0 deletions
diff --git a/sys/arch/vax/vsa/dz_ibus.c b/sys/arch/vax/vsa/dz_ibus.c
new file mode 100644
index 00000000000..24a54fa15c8
--- /dev/null
+++ b/sys/arch/vax/vsa/dz_ibus.c
@@ -0,0 +1,332 @@
+/* $OpenBSD: dz_ibus.c,v 1.1 2000/04/27 02:34:50 bjc Exp $ */
+/* $NetBSD: dz_ibus.c,v 1.15 1999/08/27 17:50:42 ragge Exp $ */
+/*
+ * Copyright (c) 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}, Sweden and its contributors.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+
+#include <sys/param.h>
+#include <sys/proc.h>
+#include <sys/systm.h>
+#include <sys/ioctl.h>
+#include <sys/tty.h>
+#include <sys/file.h>
+#include <sys/conf.h>
+#include <sys/device.h>
+#include <sys/reboot.h>
+
+#include <dev/cons.h>
+
+#include <machine/mtpr.h>
+#include <machine/sid.h>
+#include <machine/uvax.h>
+#include <machine/vsbus.h>
+#include <machine/cpu.h>
+#include <machine/scb.h>
+
+#include <machine/../vax/gencons.h>
+
+#include "../qbus/dzreg.h"
+#include "../qbus/dzvar.h"
+
+#include "lkc.h"
+
+static int dz_vsbus_match __P((struct device *, struct cfdata *, void *));
+static void dz_vsbus_attach __P((struct device *, struct device *, void *));
+static int dz_print __P((void *, const char *));
+
+static vaddr_t dz_regs; /* Used for console */
+
+struct cfattach dz_vsbus_ca = {
+ sizeof(struct dz_softc), (cfmatch_t)dz_vsbus_match, dz_vsbus_attach
+};
+
+#define REG(name) short name; short X##name##X;
+static volatile struct ss_dz {/* base address of DZ-controller: 0x200A0000 */
+ REG(csr); /* 00 Csr: control/status register */
+ REG(rbuf); /* 04 Rbuf/Lpr: receive buffer/line param reg. */
+ REG(tcr); /* 08 Tcr: transmit console register */
+ REG(tdr); /* 0C Msr/Tdr: modem status reg/transmit data reg */
+ REG(lpr0); /* 10 Lpr0: */
+ REG(lpr1); /* 14 Lpr0: */
+ REG(lpr2); /* 18 Lpr0: */
+ REG(lpr3); /* 1C Lpr0: */
+} *dz;
+#undef REG
+
+cons_decl(dz);
+
+int
+dz_print(aux, name)
+ void *aux;
+ const char *name;
+{
+ if (name)
+ printf ("lkc at %s", name);
+ return (UNCONF);
+}
+
+static int
+dz_vsbus_match(parent, cf, aux)
+ struct device *parent;
+ struct cfdata *cf;
+ void *aux;
+{
+ struct vsbus_attach_args *va = aux;
+ struct ss_dz *dzP;
+ short i;
+ unsigned int n;
+
+ dzP = (struct ss_dz *)va->va_addr;
+ i = dzP->tcr;
+ dzP->csr = DZ_CSR_MSE|DZ_CSR_TXIE;
+ dzP->tcr = 0;
+ DELAY(1000);
+ dzP->tcr = 1;
+ DELAY(100000);
+ dzP->csr = DZ_CSR_MSE;
+ DELAY(1000);
+ dzP->tcr = 0;
+
+ va->va_ivec = dzxint;
+
+ /* If the device doesn't exist, no interrupt has been generated */
+
+ return 1;
+}
+
+static void
+dz_vsbus_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct dz_softc *sc = (void *)self;
+ struct vsbus_softc *vsc = (struct vsbus_softc *)parent;
+ struct vsbus_attach_args *va = aux;
+
+ /*
+ * XXX - This is evil and ugly, but...
+ * due to the nature of how bus_space_* works on VAX, this will
+ * be perfectly good until everything is converted.
+ */
+ sc->sc_ioh = dz_regs;
+ sc->sc_dr.dr_csr = 0;
+ sc->sc_dr.dr_rbuf = 4;
+ sc->sc_dr.dr_dtr = 9;
+ sc->sc_dr.dr_break = 13;
+ sc->sc_dr.dr_tbuf = 12;
+ sc->sc_dr.dr_tcr = 8;
+ sc->sc_dr.dr_dcd = 13;
+ sc->sc_dr.dr_ring = 13;
+
+ sc->sc_type = DZ_DZV;
+
+ vsc->sc_mask |= 1 << (va->va_maskno);
+ vsc->sc_mask |= (1 << (va->va_maskno-1));
+
+ sc->sc_dsr = 0x0f; /* XXX check if VS has modem ctrl bits */
+ scb_vecalloc(va->va_cvec, dzxint, sc, SCB_ISTACK);
+ scb_vecalloc(va->va_cvec - 4, dzrint, sc, SCB_ISTACK);
+ printf("\n%s: 4 lines", self->dv_xname);
+
+ dzattach(sc);
+
+ if (((vax_confdata & 0x80) == 0) ||/* workstation, have lkc */
+ (vax_boardtype == VAX_BTYP_48))
+ if (cn_tab->cn_pri > CN_NORMAL) /* Passed cnsl detect */
+ config_found(self, 0, dz_print);
+}
+
+int
+dzcngetc(dev)
+ dev_t dev;
+{
+ int c = 0;
+ int mino = minor(dev);
+ u_short rbuf;
+
+ do {
+ while ((dz->csr & 0x80) == 0)
+ ; /* Wait for char */
+ rbuf = dz->rbuf;
+ if (((rbuf >> 8) & 3) != mino)
+ continue;
+ c = rbuf & 0x7f;
+ } while (c == 17 || c == 19); /* ignore XON/XOFF */
+
+ if (c == 13)
+ c = 10;
+
+ return (c);
+}
+
+#define DZMAJOR 1
+
+void
+dzcnprobe(cndev)
+ struct consdev *cndev;
+{
+ extern vaddr_t iospace;
+ int diagcons;
+ paddr_t ioaddr = 0x200A0000;
+
+ switch (vax_boardtype) {
+ case VAX_BTYP_410:
+ case VAX_BTYP_420:
+ case VAX_BTYP_43:
+ diagcons = (vax_confdata & 0x20 ? 3 : 0);
+ break;
+
+ case VAX_BTYP_46:
+ case VAX_BTYP_48:
+ diagcons = (vax_confdata & 0x100 ? 3 : 0);
+ break;
+
+ case VAX_BTYP_49:
+ ioaddr = 0x25000000;
+ diagcons = 3;
+ break;
+
+ default:
+ cndev->cn_pri = CN_DEAD;
+ return;
+ }
+ if (diagcons)
+ cndev->cn_pri = CN_REMOTE;
+ else
+ cndev->cn_pri = CN_NORMAL;
+ cndev->cn_dev = makedev(DZMAJOR, diagcons);
+ dz_regs = iospace;
+ ioaccess(iospace, ioaddr, 1);
+}
+
+void
+dzcninit(cndev)
+ struct consdev *cndev;
+{
+ dz = (void*)dz_regs;
+
+ dz->csr = 0; /* Disable scanning until initting is done */
+ dz->tcr = (1 << minor(cndev->cn_dev)); /* Turn on xmitter */
+ dz->csr = 0x20; /* Turn scanning back on */
+}
+
+void
+dzcnputc(dev,ch)
+ dev_t dev;
+ int ch;
+{
+ register int timeout = 1<<15; /* don't hang the machine! */
+ register int s;
+ int mino = minor(dev);
+ u_short tcr;
+
+ if (mfpr(PR_MAPEN) == 0)
+ return;
+
+ /*
+ * If we are past boot stage, dz* will interrupt,
+ * therefore we block.
+ */
+ s = splhigh();
+ tcr = dz->tcr; /* remember which lines to scan */
+ dz->tcr = (1 << mino);
+
+ while ((dz->csr & 0x8000) == 0) /* Wait until ready */
+ if (--timeout < 0)
+ break;
+ dz->tdr = ch; /* Put the character */
+ timeout = 1<<15;
+ while ((dz->csr & 0x8000) == 0) /* Wait until ready */
+ if (--timeout < 0)
+ break;
+
+ dz->tcr = tcr;
+ splx(s);
+}
+
+void
+dzcnpollc(dev, pollflag)
+ dev_t dev;
+ int pollflag;
+{
+ static u_char mask;
+
+ if (pollflag)
+ mask = vsbus_setmask(0);
+ else
+ vsbus_setmask(mask);
+}
+
+#if NLKC
+cons_decl(lkc);
+
+void
+lkccninit(cndev)
+ struct consdev *cndev;
+{
+ dz = (void*)dz_regs;
+
+ dz->csr = 0; /* Disable scanning until initting is done */
+ dz->tcr = 1; /* Turn off all but line 0's xmitter */
+ dz->rbuf = 0x1c18; /* XXX */
+ dz->csr = 0x20; /* Turn scanning back on */
+}
+
+int
+lkccngetc(dev)
+ dev_t dev;
+{
+ int lkc_decode(int);
+ int c;
+#if 0
+ u_char mask;
+
+
+ mask = vsbus_setmask(0); /* save old state */
+#endif
+
+loop:
+ while ((dz->csr & 0x80) == 0)
+ ; /* Wait for char */
+
+ c = lkc_decode(dz->rbuf & 255);
+ if (c < 1)
+ goto loop;
+
+#if 0
+ vsbus_clrintr(0x80); /* XXX */
+ vsbus_setmask(mask);
+#endif
+
+ return (c);
+}
+#endif
diff --git a/sys/arch/vax/vsa/if_le_vsbus.c b/sys/arch/vax/vsa/if_le_vsbus.c
new file mode 100644
index 00000000000..08901588b70
--- /dev/null
+++ b/sys/arch/vax/vsa/if_le_vsbus.c
@@ -0,0 +1,247 @@
+/* $OpenBSD: if_le_vsbus.c,v 1.1 2000/04/27 02:34:50 bjc Exp $ */
+/* $NetBSD: if_le_vsbus.c,v 1.2 1999/08/27 20:05:08 ragge Exp $ */
+
+/*-
+ * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*-
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Ralph Campbell and Rick Macklem.
+ *
+ * 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.
+ *
+ * @(#)if_le.c 8.2 (Berkeley) 11/16/93
+ */
+
+#include "bpfilter.h"
+
+#include <sys/param.h>
+#include <sys/syslog.h>
+#include <sys/socket.h>
+#include <sys/device.h>
+#include <sys/reboot.h>
+
+#include <vm/vm.h>
+#include <vm/vm_kern.h>
+
+#include <net/if.h>
+#include <net/if_media.h>
+
+#ifdef INET
+#include <netinet/in.h>
+#endif
+#include <netinet/if_ether.h>
+
+#include <machine/cpu.h>
+#include <machine/sid.h>
+#include <machine/bus.h>
+#include <machine/scb.h>
+#include <machine/rpb.h>
+#include <machine/vsbus.h>
+
+#include <dev/ic/am7990reg.h>
+#include <dev/ic/am7990var.h>
+#include <dev/tc/if_levar.h>
+
+int le_vsbus_match __P((struct device *, struct cfdata *, void *));
+void le_vsbus_attach __P((struct device *, struct device *, void *));
+static void lewrcsr __P((struct am7990_softc *, u_int16_t, u_int16_t));
+static u_int16_t lerdcsr __P((struct am7990_softc *, u_int16_t));
+
+struct cfattach le_vsbus_ca = {
+ sizeof(struct le_softc), (cfmatch_t)le_vsbus_match, le_vsbus_attach
+};
+
+void
+lewrcsr(sc, port, val)
+ struct am7990_softc *sc;
+ u_int16_t port, val;
+{
+ struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
+
+ ler1->ler1_rap = port;
+ ler1->ler1_rdp = val;
+}
+
+u_int16_t
+lerdcsr(sc, port)
+ struct am7990_softc *sc;
+ u_int16_t port;
+{
+ struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
+
+ ler1->ler1_rap = port;
+ return ler1->ler1_rdp;
+}
+
+int
+le_vsbus_match(parent, cf, aux)
+ struct device *parent;
+ struct cfdata *cf;
+ void *aux;
+{
+ struct vsbus_attach_args *va = aux;
+ volatile short *rdp, *rap;
+
+ if (vax_boardtype == VAX_BTYP_49)
+ return 0;
+ rdp = (short *)va->va_addr;
+ rap = rdp + 2;
+
+ /* Make sure the chip is stopped. */
+ *rap = LE_CSR0;
+ *rdp = LE_C0_STOP;
+ DELAY(100);
+ *rdp = LE_C0_INIT|LE_C0_INEA;
+
+ /* Wait for initialization to finish. */
+ DELAY(100000);
+ va->va_ivec = vsbus_intr; /* we do our own scb stuff */
+
+ /* Should have interrupted by now */
+ if (*rdp & LE_C0_IDON)
+ return 1;
+ return 0;
+}
+
+void
+le_vsbus_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct vsbus_attach_args *va = aux;
+ struct le_softc *sc = (void *)self;
+ struct vsbus_softc *vsc = (struct vsbus_softc *)parent;
+ bus_dma_segment_t seg;
+ int *lance_addr;
+ int i, err, rseg;
+ struct lereg1 *ler1;
+
+ ler1 = sc->sc_r1 = (void *)vax_map_physmem(NI_BASE, 1);
+
+ /* Prettier printout */
+ printf("\n%s", self->dv_xname);
+
+ /*
+ * MD functions.
+ */
+ sc->sc_am7990.sc_rdcsr = lerdcsr;
+ sc->sc_am7990.sc_wrcsr = lewrcsr;
+ sc->sc_am7990.sc_nocarrier = NULL;
+
+ scb_vecalloc(va->va_cvec, (void (*)(void *)) am7990_intr, sc, SCB_ISTACK);
+ /*
+ * Allocate a (DMA-safe) block for all descriptors and buffers.
+ */
+
+#define ALLOCSIZ (64 * 1024)
+ err = bus_dmamem_alloc(va->va_dmat, ALLOCSIZ, NBPG, 0,
+ &seg, 1, &rseg, BUS_DMA_NOWAIT);
+ if (err) {
+ printf(": unable to alloc buffer block: err %d\n", err);
+ return;
+ }
+ err = bus_dmamem_map(va->va_dmat, &seg, rseg, ALLOCSIZ,
+ (caddr_t *)&sc->sc_am7990.sc_mem,
+ BUS_DMA_NOWAIT|BUS_DMA_COHERENT);
+ if (err) {
+ printf(": unable to map buffer block: err %d\n", err);
+ bus_dmamem_free(va->va_dmat, &seg, rseg);
+ return;
+ }
+ sc->sc_am7990.sc_addr =
+ (paddr_t)sc->sc_am7990.sc_mem & 0xffffff;
+ sc->sc_am7990.sc_memsize = ALLOCSIZ;
+
+ sc->sc_am7990.sc_conf3 = 0;
+ sc->sc_am7990.sc_hwinit = NULL;
+ sc->sc_am7990.sc_copytodesc = am7990_copytobuf_contig;
+ sc->sc_am7990.sc_copyfromdesc = am7990_copyfrombuf_contig;
+ sc->sc_am7990.sc_copytobuf = am7990_copytobuf_contig;
+ sc->sc_am7990.sc_copyfrombuf = am7990_copyfrombuf_contig;
+ sc->sc_am7990.sc_zerobuf = am7990_zerobuf_contig;
+
+ /*
+ * Get the ethernet address out of rom
+ */
+ lance_addr = (int *)vax_map_physmem(NI_ADDR, 1);
+ for (i = 0; i < 6; i++)
+ sc->sc_am7990.sc_arpcom.ac_enaddr[i] = (u_char)lance_addr[i];
+ vax_unmap_physmem((vaddr_t)lance_addr, 1);
+
+ bcopy(self->dv_xname, sc->sc_am7990.sc_arpcom.ac_if.if_xname,
+ IFNAMSIZ);
+ am7990_config(&sc->sc_am7990);
+
+ /*
+ * Register this device as boot device if we booted from it.
+ * This will fail if there are more than one le in a machine,
+ * fortunately there may be only one.
+ */
+ if (B_TYPE(bootdev) == BDEV_LE)
+ booted_from = self;
+
+ vsc->sc_mask |= 1 << (va->va_maskno-1);
+}
diff --git a/sys/arch/vax/vsa/if_ze_vsbus.c b/sys/arch/vax/vsa/if_ze_vsbus.c
new file mode 100644
index 00000000000..64414a4e448
--- /dev/null
+++ b/sys/arch/vax/vsa/if_ze_vsbus.c
@@ -0,0 +1,127 @@
+/* $OpenBSD: if_ze_vsbus.c,v 1.1 2000/04/27 02:34:50 bjc Exp $ */
+/* $NetBSD: if_ze_vsbus.c,v 1.2 2000/01/24 02:40:35 matt Exp $ */
+/*
+ * Copyright (c) 1999 Ludd, University of Lule}, Sweden. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed at Ludd, University of
+ * Lule}, Sweden and its contributors.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <sys/device.h>
+#include <sys/systm.h>
+#include <sys/sockio.h>
+
+#include <net/if.h>
+#include <net/if_dl.h>
+
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+
+#if NBPFILTER > 0
+#include <net/bpf.h>
+#include <net/bpfdesc.h>
+#endif
+
+#include <machine/bus.h>
+#include <machine/vsbus.h>
+#include <machine/cpu.h>
+#include <machine/scb.h>
+#include <machine/sid.h>
+
+#include <arch/vax/if/sgecreg.h>
+#include <arch/vax/if/sgecvar.h>
+
+/*
+ * Adresses.
+ */
+#define SGECADDR 0x20008000
+#define NISA_ROM 0x27800000
+#define SGECVEC 0x108
+
+static int zematch __P((struct device *, void *, void *));
+static void zeattach __P((struct device *, struct device *, void *));
+
+struct cfattach ze_vsbus_ca = {
+ sizeof(struct ze_softc), zematch, zeattach
+};
+
+/*
+ * Check for present SGEC.
+ */
+int
+zematch(parent, cf, aux)
+ struct device *parent;
+ void *cf;
+ void *aux;
+{
+ /*
+ * Should some more intelligent checking be done???
+ * Should for sure force an interrupt instead...
+ */
+ if (vax_boardtype != VAX_BTYP_49)
+ return 0;
+
+ /* Fool the interrupt system. */
+ scb_fake(SGECVEC, 0x15);
+ return 12;
+}
+
+/*
+ * Interface exists: make available by filling in network interface
+ * record. System will initialize the interface when it is ready
+ * to accept packets.
+ */
+void
+zeattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct ze_softc *sc = (struct ze_softc *)self;
+ struct vsbus_attach_args *va = aux;
+ int *ea, i;
+
+ /*
+ * Map in SGEC registers.
+ */
+ sc->sc_ioh = vax_map_physmem(SGECADDR, 1);
+ sc->sc_iot = 0; /* :-) */
+ sc->sc_dmat = va->va_dmat;
+
+ sc->sc_intvec = SGECVEC;
+ scb_vecalloc(va->va_cvec, (void (*)(void *)) sgec_intr, sc, SCB_ISTACK);
+
+ /*
+ * Map in, read and release ethernet rom address.
+ */
+ ea = (int *)vax_map_physmem(NISA_ROM, 1);
+ for (i = 0; i < ETHER_ADDR_LEN; i++)
+ sc->sc_ac.ac_enaddr[i] = ea[i] & 0377;
+ vax_unmap_physmem((vaddr_t)ea, 1);
+
+ sgec_attach(sc);
+}
diff --git a/sys/arch/vax/vsa/smg.c b/sys/arch/vax/vsa/smg.c
new file mode 100644
index 00000000000..9c25ca4c312
--- /dev/null
+++ b/sys/arch/vax/vsa/smg.c
@@ -0,0 +1,525 @@
+/* $OpenBSD: smg.c,v 1.1 2000/04/27 02:34:50 bjc Exp $ */
+/* $NetBSD: smg.c,v 1.21 2000/03/23 06:46:44 thorpej Exp $ */
+/*
+ * Copyright (c) 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}, Sweden and its contributors.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/systm.h>
+#include <sys/callout.h>
+#include <sys/time.h>
+#include <sys/malloc.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+
+#include <dev/cons.h>
+
+#include <dev/wscons/wsdisplayvar.h>
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wscons_callbacks.h>
+
+#include <machine/vsbus.h>
+#include <machine/sid.h>
+#include <machine/cpu.h>
+#include <machine/ka420.h>
+
+#include "lkc.h"
+
+#define SM_COLS 128 /* char width of screen */
+#define SM_ROWS 57 /* rows of char on screen */
+#define SM_CHEIGHT 15 /* lines a char consists of */
+#define SM_NEXTROW (SM_COLS * SM_CHEIGHT)
+
+static int smg_match __P((struct device *, struct cfdata *, void *));
+static void smg_attach __P((struct device *, struct device *, void *));
+
+struct smg_softc {
+ struct device ss_dev;
+};
+
+struct cfattach smg_ca = {
+ sizeof(struct smg_softc), smg_match, smg_attach,
+};
+
+static void smg_cursor __P((void *, int, int, int));
+static int smg_mapchar __P((void *, int, unsigned int *));
+static void smg_putchar __P((void *, int, int, u_int, long));
+static void smg_copycols __P((void *, int, int, int,int));
+static void smg_erasecols __P((void *, int, int, int, long));
+static void smg_copyrows __P((void *, int, int, int));
+static void smg_eraserows __P((void *, int, int, long));
+static int smg_alloc_attr __P((void *, int, int, int, long *));
+
+const struct wsdisplay_emulops smg_emulops = {
+ smg_cursor,
+ smg_mapchar,
+ smg_putchar,
+ smg_copycols,
+ smg_erasecols,
+ smg_copyrows,
+ smg_eraserows,
+ smg_alloc_attr
+};
+
+const struct wsscreen_descr smg_stdscreen = {
+ "128x57", SM_COLS, SM_ROWS,
+ &smg_emulops,
+ 8, SM_CHEIGHT,
+ WSSCREEN_UNDERLINE|WSSCREEN_REVERSE,
+};
+
+const struct wsscreen_descr *_smg_scrlist[] = {
+ &smg_stdscreen,
+};
+
+const struct wsscreen_list smg_screenlist = {
+ sizeof(_smg_scrlist) / sizeof(struct wsscreen_descr *),
+ _smg_scrlist,
+};
+
+static caddr_t sm_addr;
+
+extern char q_font[];
+#define QCHAR(c) (c < 32 ? 32 : (c > 127 ? c - 66 : c - 32))
+#define QFONT(c,line) q_font[QCHAR(c) * 15 + line]
+#define SM_ADDR(row, col, line) \
+ sm_addr[col + (row * SM_CHEIGHT * SM_COLS) + line * SM_COLS]
+
+
+static int smg_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
+static int smg_mmap __P((void *, off_t, int));
+static int smg_alloc_screen __P((void *, const struct wsscreen_descr *,
+ void **, int *, int *, long *));
+static void smg_free_screen __P((void *, void *));
+static int smg_show_screen __P((void *, void *, int,
+ void (*) (void *, int, int), void *));
+static void smg_crsr_blink __P((void *));
+
+const struct wsdisplay_accessops smg_accessops = {
+ smg_ioctl,
+ smg_mmap,
+ smg_alloc_screen,
+ smg_free_screen,
+ smg_show_screen,
+ 0 /* load_font */
+};
+
+struct smg_screen {
+ int ss_curx;
+ int ss_cury;
+ u_char ss_image[SM_ROWS][SM_COLS]; /* Image of current screen */
+ u_char ss_attr[SM_ROWS][SM_COLS]; /* Reversed etc... */
+};
+
+static struct smg_screen smg_conscreen;
+static struct smg_screen *curscr;
+
+static struct callout smg_cursor_ch = CALLOUT_INITIALIZER;
+
+int
+smg_match(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+ struct vsbus_attach_args *va = aux;
+ volatile short *curcmd;
+ volatile short *cfgtst;
+ short tmp, tmp2;
+
+ if (vax_boardtype == VAX_BTYP_49)
+ return 0;
+
+ curcmd = (short *)va->va_addr;
+ cfgtst = (short *)vax_map_physmem(VS_CFGTST, 1);
+ /*
+ * Try to find the cursor chip by testing the flip-flop.
+ * If nonexistent, no glass tty.
+ */
+ curcmd[0] = 0x7fff;
+ DELAY(300000);
+ tmp = cfgtst[0];
+ curcmd[0] = 0x8000;
+ DELAY(300000);
+ tmp2 = cfgtst[0];
+ vax_unmap_physmem((vaddr_t)cfgtst, 1);
+
+ if (tmp2 != tmp)
+ return 20; /* Using periodic interrupt */
+ else
+ return 0;
+}
+
+void
+smg_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct wsemuldisplaydev_attach_args aa;
+
+ printf("\n");
+ sm_addr = (caddr_t)vax_map_physmem(SMADDR, (SMSIZE/VAX_NBPG));
+ if (sm_addr == 0) {
+ printf("%s: Couldn't alloc graphics memory.\n", self->dv_xname);
+ return;
+ }
+ curscr = &smg_conscreen;
+ aa.console = !(vax_confdata & 0x20);
+ aa.scrdata = &smg_screenlist;
+ aa.accessops = &smg_accessops;
+ callout_reset(&smc_cursor_ch, hz / 2, smg_crsr_blink, NULL);
+
+ config_found(self, &aa, wsemuldisplaydevprint);
+}
+
+static u_char *cursor;
+static int cur_on;
+
+static void
+smg_crsr_blink(arg)
+ void *arg;
+{
+ if (cur_on)
+ *cursor ^= 255;
+ callout_reset(&smg_cursor_ch, hz / 2, smg_crsr_blink, NULL);
+}
+
+void
+smg_cursor(id, on, row, col)
+ void *id;
+ int on, row, col;
+{
+ struct smg_screen *ss = id;
+
+ if (ss == curscr) {
+ SM_ADDR(ss->ss_cury, ss->ss_curx, 14) =
+ QFONT(ss->ss_image[ss->ss_cury][ss->ss_curx], 14);
+ cursor = &SM_ADDR(row, col, 14);
+ if ((cur_on = on))
+ *cursor ^= 255;
+ }
+ ss->ss_curx = col;
+ ss->ss_cury = row;
+}
+
+int
+smg_mapchar(id, uni, index)
+ void *id;
+ int uni;
+ unsigned int *index;
+{
+ if (uni < 256) {
+ *index = uni;
+ return (5);
+ }
+ *index = ' ';
+ return (0);
+}
+
+static void
+smg_putchar(id, row, col, c, attr)
+ void *id;
+ int row, col;
+ u_int c;
+ long attr;
+{
+ struct smg_screen *ss = id;
+ int i;
+
+ c &= 0xff;
+
+ ss->ss_image[row][col] = c;
+ ss->ss_attr[row][col] = attr;
+ if (ss != curscr)
+ return;
+ for (i = 0; i < 15; i++) {
+ unsigned char ch = QFONT(c, i);
+
+ SM_ADDR(row, col, i) = (attr & WSATTR_REVERSE ? ~ch : ch);
+
+ }
+ if (attr & WSATTR_UNDERLINE)
+ SM_ADDR(row, col, 14) ^= SM_ADDR(row, col, 14);
+}
+
+/*
+ * copies columns inside a row.
+ */
+static void
+smg_copycols(id, row, srccol, dstcol, ncols)
+ void *id;
+ int row, srccol, dstcol, ncols;
+{
+ struct smg_screen *ss = id;
+ int i;
+
+ bcopy(&ss->ss_image[row][srccol], &ss->ss_image[row][dstcol], ncols);
+ bcopy(&ss->ss_attr[row][srccol], &ss->ss_attr[row][dstcol], ncols);
+ if (ss != curscr)
+ return;
+ for (i = 0; i < SM_CHEIGHT; i++)
+ bcopy(&SM_ADDR(row,srccol, i), &SM_ADDR(row, dstcol, i),ncols);
+}
+
+/*
+ * Erases a bunch of chars inside one row.
+ */
+static void
+smg_erasecols(id, row, startcol, ncols, fillattr)
+ void *id;
+ int row, startcol, ncols;
+ long fillattr;
+{
+ struct smg_screen *ss = id;
+ int i;
+
+ bzero(&ss->ss_image[row][startcol], ncols);
+ bzero(&ss->ss_attr[row][startcol], ncols);
+ if (ss != curscr)
+ return;
+ for (i = 0; i < SM_CHEIGHT; i++)
+ bzero(&SM_ADDR(row, startcol, i), ncols);
+}
+
+static void
+smg_copyrows(id, srcrow, dstrow, nrows)
+ void *id;
+ int srcrow, dstrow, nrows;
+{
+ struct smg_screen *ss = id;
+ int frows;
+
+ bcopy(&ss->ss_image[srcrow][0], &ss->ss_image[dstrow][0],
+ nrows * SM_COLS);
+ bcopy(&ss->ss_attr[srcrow][0], &ss->ss_attr[dstrow][0],
+ nrows * SM_COLS);
+ if (ss != curscr)
+ return;
+ if (nrows > 25) {
+ frows = nrows >> 1;
+ if (srcrow > dstrow) {
+ bcopy(&sm_addr[(srcrow * SM_NEXTROW)],
+ &sm_addr[(dstrow * SM_NEXTROW)],
+ frows * SM_NEXTROW);
+ bcopy(&sm_addr[((srcrow + frows) * SM_NEXTROW)],
+ &sm_addr[((dstrow + frows) * SM_NEXTROW)],
+ (nrows - frows) * SM_NEXTROW);
+ } else {
+ bcopy(&sm_addr[((srcrow + frows) * SM_NEXTROW)],
+ &sm_addr[((dstrow + frows) * SM_NEXTROW)],
+ (nrows - frows) * SM_NEXTROW);
+ bcopy(&sm_addr[(srcrow * SM_NEXTROW)],
+ &sm_addr[(dstrow * SM_NEXTROW)],
+ frows * SM_NEXTROW);
+ }
+ } else
+ bcopy(&sm_addr[(srcrow * SM_NEXTROW)],
+ &sm_addr[(dstrow * SM_NEXTROW)], nrows * SM_NEXTROW);
+}
+
+static void
+smg_eraserows(id, startrow, nrows, fillattr)
+ void *id;
+ int startrow, nrows;
+ long fillattr;
+{
+ struct smg_screen *ss = id;
+ int frows;
+
+ bzero(&ss->ss_image[startrow][0], nrows * SM_COLS);
+ bzero(&ss->ss_attr[startrow][0], nrows * SM_COLS);
+ if (ss != curscr)
+ return;
+ if (nrows > 25) {
+ frows = nrows >> 1;
+ bzero(&sm_addr[(startrow * SM_NEXTROW)], frows * SM_NEXTROW);
+ bzero(&sm_addr[((startrow + frows) * SM_NEXTROW)],
+ (nrows - frows) * SM_NEXTROW);
+ } else
+ bzero(&sm_addr[(startrow * SM_NEXTROW)], nrows * SM_NEXTROW);
+}
+
+static int
+smg_alloc_attr(id, fg, bg, flags, attrp)
+ void *id;
+ int fg, bg;
+ int flags;
+ long *attrp;
+{
+ *attrp = flags;
+ return 0;
+}
+
+int
+smg_ioctl(v, cmd, data, flag, p)
+ void *v;
+ u_long cmd;
+ caddr_t data;
+ int flag;
+ struct proc *p;
+{
+ struct wsdisplay_fbinfo fb;
+
+ switch (cmd) {
+ case WSDISPLAYIO_GTYPE:
+ *(u_int *)data = WSDISPLAY_TYPE_PM_MONO;
+ break;
+
+ case WSDISPLAYIO_GINFO:
+ fb.height = 864;
+ fb.width = 1024;
+ return copyout(&fb, data, sizeof(struct wsdisplay_fbinfo));
+
+
+ default:
+ return -1;
+ }
+ return 0;
+}
+
+static int
+smg_mmap(v, offset, prot)
+ void *v;
+ off_t offset;
+ int prot;
+{
+ if (offset >= SMSIZE || offset < 0)
+ return -1;
+ return (SMADDR + offset) >> PGSHIFT;
+}
+
+int
+smg_alloc_screen(v, type, cookiep, curxp, curyp, defattrp)
+ void *v;
+ const struct wsscreen_descr *type;
+ void **cookiep;
+ int *curxp, *curyp;
+ long *defattrp;
+{
+ *cookiep = malloc(sizeof(struct smg_screen), M_DEVBUF, M_WAITOK);
+ bzero(*cookiep, sizeof(struct smg_screen));
+ *curxp = *curyp = *defattrp = 0;
+ return 0;
+}
+
+void
+smg_free_screen(v, cookie)
+ void *v;
+ void *cookie;
+{
+}
+
+int
+smg_show_screen(v, cookie, waitok, cb, cbarg)
+ void *v;
+ void *cookie;
+ int waitok;
+ void (*cb) __P((void *, int, int));
+ void *cbarg;
+{
+ struct smg_screen *ss = cookie;
+ int row, col, line;
+
+ if (ss == curscr)
+ return (0);
+
+ for (row = 0; row < SM_ROWS; row++)
+ for (line = 0; line < SM_CHEIGHT; line++) {
+ for (col = 0; col < SM_COLS; col++) {
+ u_char s, c = ss->ss_image[row][col];
+
+ if (c < 32)
+ c = 32;
+ s = QFONT(c, line);
+ if (ss->ss_attr[row][col] & WSATTR_REVERSE)
+ s ^= 255;
+ SM_ADDR(row, col, line) = s;
+ }
+ if (ss->ss_attr[row][col] & WSATTR_UNDERLINE)
+ SM_ADDR(row, col, line) = 255;
+ }
+ cursor = &sm_addr[(ss->ss_cury * SM_CHEIGHT * SM_COLS) + ss->ss_curx +
+ ((SM_CHEIGHT - 1) * SM_COLS)];
+ curscr = ss;
+ return (0);
+}
+
+cons_decl(smg);
+
+#define WSCONSOLEMAJOR 68
+
+void
+smgcninit(cndev)
+ struct consdev *cndev;
+{
+ extern void lkccninit __P((struct consdev *));
+ extern int lkccngetc __P((dev_t));
+ /* Clear screen */
+ memset(sm_addr, 0, 128*864);
+
+ curscr = &smg_conscreen;
+ wsdisplay_cnattach(&smg_stdscreen, &smg_conscreen, 0, 0, 0);
+ cn_tab->cn_pri = CN_INTERNAL;
+#if 0
+ lkccninit(cndev);
+ wsdisplay_set_cons_kbd(lkccngetc, nullcnpollc);
+#endif
+}
+
+/*
+ * Called very early to setup the glass tty as console.
+ * Because it's called before the VM system is inited, virtual memory
+ * for the framebuffer can be stolen directly without disturbing anything.
+ */
+void
+smgcnprobe(cndev)
+ struct consdev *cndev;
+{
+ extern vaddr_t virtual_avail;
+
+ switch (vax_boardtype) {
+ case VAX_BTYP_410:
+ case VAX_BTYP_420:
+ case VAX_BTYP_43:
+ if ((vax_confdata & KA420_CFG_L3CON) ||
+ (vax_confdata & KA420_CFG_MULTU))
+ break; /* doesn't use graphics console */
+ sm_addr = (caddr_t)virtual_avail;
+ virtual_avail += SMSIZE;
+ ioaccess((vaddr_t)sm_addr, SMADDR, (SMSIZE/VAX_NBPG));
+ cndev->cn_pri = CN_INTERNAL;
+ cndev->cn_dev = makedev(WSCONSOLEMAJOR, 0);
+ break;
+
+ default:
+ break;
+ }
+}