Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/pdp10/dev Simple ebus, Massbus adapter and Massbus ...



details:   https://anonhg.NetBSD.org/src/rev/84586c39ef2d
branches:  trunk
changeset: 550736:84586c39ef2d
user:      ragge <ragge%NetBSD.org@localhost>
date:      Tue Aug 19 10:51:57 2003 +0000

description:
Simple ebus, Massbus adapter and Massbus disk drivers.
The Massbus disk drivers should be merged with the vax Massbus disk drivers
when the 4.4BSD Massbus code gets free.

diffstat:

 sys/arch/pdp10/dev/ebus.c  |   81 +++++++
 sys/arch/pdp10/dev/ebus.h  |   32 ++
 sys/arch/pdp10/dev/hp.c    |  505 +++++++++++++++++++++++++++++++++++++++++++++
 sys/arch/pdp10/dev/hpreg.h |  125 +++++++++++
 sys/arch/pdp10/dev/rh.c    |  306 +++++++++++++++++++++++++++
 sys/arch/pdp10/dev/rhreg.h |  135 ++++++++++++
 sys/arch/pdp10/dev/rhvar.h |  117 ++++++++++
 7 files changed, 1301 insertions(+), 0 deletions(-)

diffs (truncated from 1329 to 300 lines):

diff -r ce6e23867ac2 -r 84586c39ef2d sys/arch/pdp10/dev/ebus.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/pdp10/dev/ebus.c Tue Aug 19 10:51:57 2003 +0000
@@ -0,0 +1,81 @@
+/*     $NetBSD: ebus.c,v 1.1 2003/08/19 10:51:57 ragge Exp $   */
+/*
+ * Copyright (c) 2003 Anders Magnusson (ragge%ludd.luth.se@localhost).
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * 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 <machine/bus.h>
+
+#include <pdp10/dev/ebus.h>
+
+static int
+ebus_print(void *aux, const char *n)
+{
+       struct ebus_attach_args *ea = aux;
+
+       printf(" csr %o", ea->ea_ioh);
+       return UNCONF;
+}
+
+static int
+ebus_match(struct device *parent, struct cfdata *cf, void *aux)
+{
+#ifdef notyet
+       if (cputype != TYPE_KL)
+               return 0;
+#endif
+       return 1;
+}
+
+static int
+ebus_search(struct device *parent, struct cfdata *cf, void *aux)
+{
+       struct ebus_attach_args ea;
+       int rv;
+
+       ea.ea_iot = 0;
+       ea.ea_ioh = cf->cf_loc[0];
+       rv = config_match(parent, cf, &ea);
+       if (rv == 0)
+               return 0;
+       config_attach(parent, cf, &ea, ebus_print);
+       return 1;
+}
+
+static void
+ebus_attach(struct device *parent, struct device *self, void *aux)
+{
+       printf("\n");
+
+       config_search(ebus_search, self, NULL);
+}
+
+struct cfattach ebus_ca = {
+       sizeof(struct device), ebus_match, ebus_attach,
+};
diff -r ce6e23867ac2 -r 84586c39ef2d sys/arch/pdp10/dev/ebus.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/pdp10/dev/ebus.h Tue Aug 19 10:51:57 2003 +0000
@@ -0,0 +1,32 @@
+/*     $NetBSD: ebus.h,v 1.1 2003/08/19 10:51:57 ragge Exp $   */
+/*
+ * Copyright (c) 2003 Anders Magnusson (ragge%ludd.luth.se@localhost).
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * 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.
+ */
+
+struct ebus_attach_args {
+       bus_space_tag_t ea_iot;
+       bus_space_handle_t ea_ioh;
+};
diff -r ce6e23867ac2 -r 84586c39ef2d sys/arch/pdp10/dev/hp.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/pdp10/dev/hp.c   Tue Aug 19 10:51:57 2003 +0000
@@ -0,0 +1,505 @@
+/*     $NetBSD: hp.c,v 1.1 2003/08/19 10:51:57 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.
+ */
+
+/*
+ * Simple device driver routine for massbuss disks.
+ * TODO:
+ *  Fix support for Standard DEC BAD144 bad block forwarding.
+ *  Be able to to handle soft/hard transfer errors.
+ *  Handle non-data transfer interrupts.
+ *  Autoconfiguration of disk drives 'on the fly'.
+ *  Handle disk media changes.
+ *  Dual-port operations should be supported.
+ */
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/disklabel.h>
+#include <sys/disk.h>
+#include <sys/dkio.h>
+#include <sys/buf.h>
+#include <sys/stat.h>
+#include <sys/ioccom.h>
+#include <sys/fcntl.h>
+#include <sys/syslog.h>
+#include <sys/reboot.h>
+#include <sys/conf.h>
+#include <sys/event.h>
+
+#include <machine/bus.h>
+#include <machine/io.h>
+
+#include <pdp10/dev/rhvar.h>
+#include <pdp10/dev/rhreg.h>
+#include <pdp10/dev/hpreg.h>
+
+#include "ioconf.h"
+#include "locators.h"
+
+struct hp_softc {
+       struct  device  sc_dev;
+       struct  disk sc_disk;
+       bus_space_tag_t sc_iot;
+       bus_space_handle_t sc_ioh;
+       int sc_unit;
+       struct  rh_device sc_md;        /* Common struct used by mbaqueue. */
+       int     sc_wlabel;              /* Disklabel area is writable */
+};
+
+int     hpmatch(struct device *, struct cfdata *, void *);
+void    hpattach(struct device *, struct device *, void *);
+void   hpstart(struct rh_device *);
+int    hpattn(struct rh_device *);
+int    hpfinish(struct rh_device *, int, int *);
+
+CFATTACH_DECL(hp, sizeof(struct hp_softc), hpmatch, hpattach, NULL, NULL);
+
+dev_type_open(hpopen);
+dev_type_close(hpclose);
+dev_type_read(hpread);
+dev_type_write(hpwrite);
+dev_type_ioctl(hpioctl);
+dev_type_strategy(hpstrategy);
+dev_type_size(hpsize);
+
+const struct bdevsw hp_bdevsw = {
+       hpopen, hpclose, hpstrategy, hpioctl, nulldump, hpsize, D_DISK
+};
+
+const struct cdevsw hp_cdevsw = {
+       hpopen, hpclose, hpread, hpwrite, hpioctl,
+       nostop, notty, nopoll, nommap, nokqfilter, D_DISK
+};
+
+
+#define HP_WCSR(reg, val) \
+       DATAO(sc->sc_ioh, ((reg) << 30) | (sc->sc_unit << 18) | \
+           RH20_DATAO_LR | (val))
+#define HP_RCSR(reg, val) \
+       DATAO(sc->sc_ioh, ((reg) << 30) | (sc->sc_unit << 18)); \
+       DATAI(sc->sc_ioh, (val))
+
+static struct hpsizes {
+       int type, sectrk, trkcyl, cylunit;
+} hpsizes[] = {
+       { RH_DT_RP04, 20, 19, 400, },
+       { RH_DT_RP05, 20, 19, 400, },
+       { RH_DT_RP06, 20, 19, 800, },
+       { RH_DT_RP07, 43, 32, 629, },
+       { RH_DT_RM03, 30, 5,  820, },
+       { RH_DT_RM05, 30, 19, 400, },
+       { 0, },
+};
+
+static void
+hpfakelabel(int type, char *name, struct disklabel *dl)
+{
+       int i;
+
+       for (i = 0; hpsizes[i].type; i++)
+               if (hpsizes[i].type == type)
+                       break;
+       if (hpsizes[i].type == 0)
+               return;
+       dl->d_magic2 = dl->d_magic = DISKMAGIC;
+       dl->d_type  = DTYPE_SMD;
+       strcpy(dl->d_typename, name);
+       dl->d_secsize = DEV_BSIZE;
+       dl->d_nsectors = hpsizes[i].sectrk;
+       dl->d_ntracks = hpsizes[i].trkcyl;
+       dl->d_ncylinders = hpsizes[i].cylunit;
+       dl->d_secpercyl = hpsizes[i].sectrk * hpsizes[i].trkcyl;
+       dl->d_secperunit = hpsizes[i].sectrk * hpsizes[i].trkcyl *
+           hpsizes[i].cylunit;
+       dl->d_rpm = 3600;
+       dl->d_interleave = 1;
+       dl->d_partitions[2].p_offset = 0;
+       dl->d_partitions[2].p_size = dl->d_secperunit;
+       dl->d_npartitions = 3;
+}
+
+/*
+ * Check if this is a disk drive; done by checking type from mbaattach.
+ */
+int
+hpmatch(struct device *parent, struct cfdata *cf, void *aux)
+{
+       struct  rh_attach_args *ma = aux;
+
+       if (cf->cf_loc[RHCF_DRIVE] != RHCF_DRIVE_DEFAULT &&
+           cf->cf_loc[RHCF_DRIVE] != ma->ma_unit)
+               return 0;
+
+       if (ma->ma_devtyp != MB_RP)
+               return 0;
+
+       return 1;
+}
+
+/*
+ * Disk drive found; fake a disklabel and try to read the real one.
+ * If the on-disk label can't be read; we lose.
+ */
+void
+hpattach(struct device *parent, struct device *self, void *aux)
+{
+       struct  hp_softc *sc = (void *)self;



Home | Main Index | Thread Index | Old Index