Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/amiga Add z3rambd driver, it allows using Zorro III...



details:   https://anonhg.NetBSD.org/src/rev/1b936e14fea3
branches:  trunk
changeset: 782902:1b936e14fea3
user:      rkujawa <rkujawa%NetBSD.org@localhost>
date:      Sun Nov 25 23:33:55 2012 +0000

description:
Add z3rambd driver, it allows using Zorro III RAM boards as block devices.
This makes sense in machines equipped with RAM on accelerator boards, where
difference between accelerator RAM and Zorro III RAM is significant. Hacks
were needed in amiga_init.c and zbus.c, but they are only enabled if this
driver is present in kernel. Otherwise user will get the usual behaviour.

diffstat:

 sys/arch/amiga/amiga/amiga_init.c |   10 +-
 sys/arch/amiga/conf/files.amiga   |    6 +-
 sys/arch/amiga/dev/z3rambd.c      |  174 ++++++++++++++++++++++++++++++++++++++
 sys/arch/amiga/dev/zbus.c         |   11 +-
 4 files changed, 195 insertions(+), 6 deletions(-)

diffs (271 lines):

diff -r fae19ba44383 -r 1b936e14fea3 sys/arch/amiga/amiga/amiga_init.c
--- a/sys/arch/amiga/amiga/amiga_init.c Sun Nov 25 23:04:51 2012 +0000
+++ b/sys/arch/amiga/amiga/amiga_init.c Sun Nov 25 23:33:55 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: amiga_init.c,v 1.127 2012/07/09 19:23:45 rkujawa Exp $ */
+/*     $NetBSD: amiga_init.c,v 1.128 2012/11/25 23:33:55 rkujawa Exp $ */
 
 /*
  * Copyright (c) 1994 Michael L. Hitch
@@ -35,10 +35,11 @@
 #include "opt_p5ppc68kboard.h"
 #include "opt_devreload.h"
 #include "opt_m68k_arch.h"
+#include "z3rambd.h"
 #include "ser.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amiga_init.c,v 1.127 2012/07/09 19:23:45 rkujawa Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amiga_init.c,v 1.128 2012/11/25 23:33:55 rkujawa Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -335,7 +336,10 @@
                if (cd->rom.manid == 8512 && 
                    (cd->rom.prodid == 100 || cd->rom.prodid == 110)) 
                        RELOC(ZBUSAVAIL, u_int) += m68k_round_page(0x1400000);
-
+#if NZ3RAMBD > 0
+               if ( (cd->rom.manid == 3643) && (cd->rom.prodid == 32) ) 
+               { } else
+#endif
                if (bd_type != ERT_ZORROIII &&
                    (bd_type != ERT_ZORROII || isztwopa(cd->addr)))
                        continue;       /* It's not Z2 or Z3 I/O board */
diff -r fae19ba44383 -r 1b936e14fea3 sys/arch/amiga/conf/files.amiga
--- a/sys/arch/amiga/conf/files.amiga   Sun Nov 25 23:04:51 2012 +0000
+++ b/sys/arch/amiga/conf/files.amiga   Sun Nov 25 23:33:55 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.amiga,v 1.165 2012/11/19 23:43:08 rkujawa Exp $
+#      $NetBSD: files.amiga,v 1.166 2012/11/25 23:33:56 rkujawa Exp $
 
 # maxpartitions must be first item in files.${ARCH}.newconf
 maxpartitions 16                       # NOTE THAT AMIGA IS SPECIAL!
@@ -551,6 +551,10 @@
 include        "dev/i2o/files.i2o"
 include        "dev/pci/files.pci"
 
+device z3rambd: altmemdev
+attach z3rambd at zbus
+file   arch/amiga/dev/z3rambd.c        z3rambd needs-flag
+
 include "arch/amiga/clockport/files.clockport"
 
 include        "arch/amiga/conf/majors.amiga"
diff -r fae19ba44383 -r 1b936e14fea3 sys/arch/amiga/dev/z3rambd.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/amiga/dev/z3rambd.c      Sun Nov 25 23:33:55 2012 +0000
@@ -0,0 +1,174 @@
+/*     $NetBSD: z3rambd.c,v 1.1 2012/11/25 23:33:56 rkujawa Exp $ */
+
+/*-
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Radoslaw Kujawa.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: z3rambd.c,v 1.1 2012/11/25 23:33:56 rkujawa Exp $");
+
+/*
+ * Z3 RAM virtual block device. Supports ZorRAM so far.
+ */
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/socket.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+
+#include <machine/cpu.h>
+
+#include <amiga/dev/zbusvar.h>
+
+#include <dev/altmem/altmemvar.h>
+
+static int     z3rambd_match(device_t, cfdata_t , void *);
+static void    z3rambd_attach(device_t, device_t, void *);
+
+static int     z3rambd_altmem_print(void *, const char *);
+
+static void    z3rambd_altmem_strategy(void *, struct buf *);
+static size_t  z3rambd_altmem_getsize(void *);
+
+static const struct altmem_memops z3rambd_altmem_memops = {
+       .getsize = z3rambd_altmem_getsize,
+       .strategy = z3rambd_altmem_strategy
+};
+
+struct z3rambd_softc {
+       device_t                sc_dev;
+
+       size_t                  sc_size;
+
+       struct bus_space_tag    sc_bst;
+
+       bus_space_tag_t         sc_iot;
+       bus_space_handle_t      sc_ioh;
+
+       void                    *sc_va;
+};
+
+CFATTACH_DECL_NEW(z3rambd, sizeof(struct z3rambd_softc),
+    z3rambd_match, z3rambd_attach, NULL, NULL);
+
+#define ZORRO_MANID_E3B                3643
+#define ZORRO_PRODID_ZORRAM    32
+
+int
+z3rambd_match(device_t parent, cfdata_t cf, void *aux)
+{
+       struct zbus_args *zap;
+       zap = aux;
+
+       if (zap->manid == ZORRO_MANID_E3B) 
+               if (zap->prodid == ZORRO_PRODID_ZORRAM)
+                       return 100;
+
+       return 0; 
+}
+
+void
+z3rambd_attach(device_t parent, device_t self, void *aux)
+{
+       struct z3rambd_softc *sc;
+       struct zbus_args *zap;
+       struct altmem_attach_args aaa;
+
+       sc = device_private(self);
+       sc->sc_dev = self; 
+       zap = aux;
+
+       sc->sc_bst.base = (bus_addr_t)zap->va;  
+       sc->sc_bst.absm = &amiga_bus_stride_1;
+       sc->sc_iot = &sc->sc_bst;
+
+       /* XXX: duh, size of the board does not necessarily equal mem size */
+       sc->sc_size = zap->size;
+
+       aprint_normal(": AmigaKit ZorRAM\n");
+
+       if (bus_space_map(sc->sc_iot, 0, sc->sc_size, 0,
+           &sc->sc_ioh)) {
+               aprint_error_dev(sc->sc_dev, "can't map the RAM\n");
+       }
+
+       sc->sc_va = bus_space_vaddr(sc->sc_iot, sc->sc_ioh);
+
+       aaa.cookie = sc;
+       aaa.memops = &z3rambd_altmem_memops;    
+       config_found_ia(self, "altmemdev", &aaa, z3rambd_altmem_print);
+}
+
+static int
+z3rambd_altmem_print(void *aux, const char *pnp)
+{
+       if (pnp)
+               aprint_normal("altmem at %s", pnp);
+
+       return UNCONF;
+}
+
+/* XXX: should be rewritten using bus_space_read_region? */
+static void
+z3rambd_altmem_strategy(void *aux, struct buf *bp)
+{
+       struct z3rambd_softc *sc = aux;
+       void *addr;
+       size_t off, bpos;
+       int s;
+
+       bpos = 0;
+
+       bp->b_resid = bp->b_bcount;
+       off = bp->b_blkno << DEV_BSHIFT;
+
+       s = splbio();
+
+       addr = (char *)((char*)sc->sc_va + off);
+#ifdef Z3RAMBD_DEBUG
+       aprint_normal_dev(sc->sc_dev,"stratetgy at %x %x\n", (bus_addr_t) addr,
+           (bus_addr_t) kvtop(addr));
+#endif /* Z3RAMBD_DEBUG */
+
+       if (bp->b_flags & B_READ)
+               memcpy((char *)bp->b_data, addr, bp->b_resid);
+       else
+               memcpy(addr, (char *)bp->b_data, bp->b_resid);
+
+       splx(s);
+}
+
+static size_t
+z3rambd_altmem_getsize(void *aux)
+{
+       struct z3rambd_softc *sc = aux;
+       return sc->sc_size;
+}
+
diff -r fae19ba44383 -r 1b936e14fea3 sys/arch/amiga/dev/zbus.c
--- a/sys/arch/amiga/dev/zbus.c Sun Nov 25 23:04:51 2012 +0000
+++ b/sys/arch/amiga/dev/zbus.c Sun Nov 25 23:33:55 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: zbus.c,v 1.71 2012/11/25 19:52:05 christos Exp $ */
+/*     $NetBSD: zbus.c,v 1.72 2012/11/25 23:33:56 rkujawa Exp $ */
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zbus.c,v 1.71 2012/11/25 19:52:05 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zbus.c,v 1.72 2012/11/25 23:33:56 rkujawa Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -44,6 +44,8 @@
 #include <amiga/amiga/device.h>
 #include <amiga/dev/zbusvar.h>
 
+#include "z3rambd.h"
+
 struct aconfdata {
        const char *name;
        int manid;
@@ -326,6 +328,11 @@
                if (amiga_realconfig == 0 && pcp >= epcp)
                        continue;
 
+#if NZ3RAMBD > 0
+               if ((cdp->rom.manid == 3643) && (cdp->rom.prodid == 32))
+               { }
+               else 
+#endif /* NZ3RAMBD */
                /*
                 * check if it's a Zorro II or III board and not linked into
                 * MemList (i.e. not a memory board)



Home | Main Index | Thread Index | Old Index