Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc64 whole bunch of changes:
details: https://anonhg.NetBSD.org/src/rev/3288ab2bcad1
branches: trunk
changeset: 485233:3288ab2bcad1
user: mrg <mrg%NetBSD.org@localhost>
date: Sat Apr 22 17:05:59 2000 +0000
description:
whole bunch of changes:
- merge IOMMU DVMA code from sbus/psycho into iommu.c. this code was
identical and a few minor inconsistencies had crept in. this way
keeps them all in sync.
- with this code gone from psycho, merge the psycho.c and psycho_bus.c
files. same with ebus/ebus_bus.c. delete the _bus.c files.
- add a _ds_boundary member to the dma segment structure, so that later
dma mappings can find this value.
- set _ds_boundary in machdep.c:_bus_dmamem_alloc().
- kill much dead code.
diffstat:
sys/arch/sparc64/conf/files.sparc64 | 4 +-
sys/arch/sparc64/dev/ebus.c | 295 ++++++++++++-
sys/arch/sparc64/dev/ebus_bus.c | 789 ---------------------------------
sys/arch/sparc64/dev/iommu.c | 424 ++++++++++++++++-
sys/arch/sparc64/dev/iommuvar.h | 18 +-
sys/arch/sparc64/dev/psycho.c | 466 +++++++++++++++++++-
sys/arch/sparc64/dev/psycho_bus.c | 860 ------------------------------------
sys/arch/sparc64/dev/sbus.c | 338 +------------
sys/arch/sparc64/include/bus.h | 9 +-
sys/arch/sparc64/sparc64/machdep.c | 4 +-
10 files changed, 1207 insertions(+), 2000 deletions(-)
diffs (truncated from 3553 to 300 lines):
diff -r 83b9e456e56b -r 3288ab2bcad1 sys/arch/sparc64/conf/files.sparc64
--- a/sys/arch/sparc64/conf/files.sparc64 Sat Apr 22 17:05:07 2000 +0000
+++ b/sys/arch/sparc64/conf/files.sparc64 Sat Apr 22 17:05:59 2000 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.sparc64,v 1.27 2000/04/15 03:08:12 mrg Exp $
+# $NetBSD: files.sparc64,v 1.28 2000/04/22 17:05:59 mrg Exp $
# @(#)files.sparc64 8.1 (Berkeley) 7/19/93
# sparc64-specific configuration info
@@ -20,7 +20,6 @@
attach psycho at mainbus
include "dev/pci/files.pci"
file arch/sparc64/dev/psycho.c psycho
-file arch/sparc64/dev/psycho_bus.c psycho
file arch/sparc64/dev/pci_machdep.c psycho
# IOMMU is for both
@@ -37,7 +36,6 @@
device ebus {[addr = -1]}: pcibus
attach ebus at pci
file arch/sparc64/dev/ebus.c ebus
-file arch/sparc64/dev/ebus_bus.c ebus
# network devices MII bus
include "dev/mii/files.mii"
diff -r 83b9e456e56b -r 3288ab2bcad1 sys/arch/sparc64/dev/ebus.c
--- a/sys/arch/sparc64/dev/ebus.c Sat Apr 22 17:05:07 2000 +0000
+++ b/sys/arch/sparc64/dev/ebus.c Sat Apr 22 17:05:59 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ebus.c,v 1.7 2000/04/15 03:08:13 mrg Exp $ */
+/* $NetBSD: ebus.c,v 1.8 2000/04/22 17:06:01 mrg Exp $ */
/*
* Copyright (c) 1999, 2000 Matthew R. Green
@@ -28,17 +28,27 @@
* SUCH DAMAGE.
*/
+#include "opt_ddb.h"
+
/*
* UltraSPARC 5 and beyond ebus support.
+ *
+ * note that this driver is far from complete:
+ * - ebus2 dma code is completely unwritten
+ * - interrupt establish code is completely unwritten
+ * - bus map code is written and appears to work
*/
#undef DEBUG
#define DEBUG
#ifdef DEBUG
-#define EDB_PROM 0x1
-#define EDB_CHILD 0x2
-#define EDB_INTRMAP 0x4
+#define EDB_PROM 0x01
+#define EDB_CHILD 0x02
+#define EDB_INTRMAP 0x04
+#define EDB_BUSMAP 0x08
+#define EDB_BUSDMA 0x10
+#define EDB_INTR 0x20
int ebus_debug = 0;
#define DPRINTF(l, s) do { if (ebus_debug & l) printf s; } while (0)
#else
@@ -48,8 +58,14 @@
#include <sys/param.h>
#include <sys/conf.h>
#include <sys/device.h>
+#include <sys/errno.h>
+#include <sys/extent.h>
#include <sys/malloc.h>
#include <sys/systm.h>
+#include <sys/time.h>
+
+#include <vm/vm.h>
+#include <vm/vm_kern.h>
#define _SPARC_BUS_DMA_PRIVATE
#include <machine/bus.h>
@@ -59,8 +75,13 @@
#include <dev/pci/pcireg.h>
#include <dev/pci/pcidevs.h>
+#include <sparc64/dev/iommureg.h>
+#include <sparc64/dev/iommuvar.h>
+#include <sparc64/dev/psychoreg.h>
+#include <sparc64/dev/psychovar.h>
#include <sparc64/dev/ebusreg.h>
#include <sparc64/dev/ebusvar.h>
+#include <sparc64/sparc64/cache.h>
int ebus_match __P((struct device *, struct cfdata *, void *));
void ebus_attach __P((struct device *, struct device *, void *));
@@ -76,6 +97,29 @@
void ebus_find_ino __P((struct ebus_softc *, struct ebus_attach_args *));
int ebus_find_node __P((struct ebus_softc *, struct pci_attach_args *));
+/*
+ * here are our bus space and bus dma routines.
+ */
+static int ebus_bus_mmap __P((bus_space_tag_t, bus_type_t, bus_addr_t,
+ int, bus_space_handle_t *));
+static int _ebus_bus_map __P((bus_space_tag_t, bus_type_t, bus_addr_t,
+ bus_size_t, int, vaddr_t,
+ bus_space_handle_t *));
+static void *ebus_intr_establish __P((bus_space_tag_t, int, int,
+ int (*) __P((void *)), void *));
+
+static int ebus_dmamap_load __P((bus_dma_tag_t, bus_dmamap_t, void *,
+ bus_size_t, struct proc *, int));
+static void ebus_dmamap_unload __P((bus_dma_tag_t, bus_dmamap_t));
+static void ebus_dmamap_sync __P((bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
+ bus_size_t, int));
+int ebus_dmamem_alloc __P((bus_dma_tag_t, bus_size_t, bus_size_t, bus_size_t,
+ bus_dma_segment_t *, int, int *, int));
+void ebus_dmamem_free __P((bus_dma_tag_t, bus_dma_segment_t *, int));
+int ebus_dmamem_map __P((bus_dma_tag_t, bus_dma_segment_t *, int, size_t,
+ caddr_t *, int));
+void ebus_dmamem_unmap __P((bus_dma_tag_t, caddr_t, size_t));
+
int
ebus_match(parent, match, aux)
struct device *parent;
@@ -336,3 +380,246 @@
/* damn! */
return (0);
}
+
+/*
+ * bus space and bus dma below here
+ */
+bus_space_tag_t
+ebus_alloc_bus_tag(sc, type)
+ struct ebus_softc *sc;
+ int type;
+{
+ bus_space_tag_t bt;
+
+ bt = (bus_space_tag_t)
+ malloc(sizeof(struct sparc_bus_space_tag), M_DEVBUF, M_NOWAIT);
+ if (bt == NULL)
+ panic("could not allocate ebus bus tag");
+
+ bzero(bt, sizeof *bt);
+ bt->cookie = sc;
+ bt->parent = sc->sc_bustag;
+ bt->type = type;
+ bt->sparc_bus_map = _ebus_bus_map;
+ bt->sparc_bus_mmap = ebus_bus_mmap;
+ bt->sparc_intr_establish = ebus_intr_establish;
+ return (bt);
+}
+
+/* XXX? */
+bus_dma_tag_t
+ebus_alloc_dma_tag(sc, pdt)
+ struct ebus_softc *sc;
+ bus_dma_tag_t pdt;
+{
+ bus_dma_tag_t dt;
+
+ dt = (bus_dma_tag_t)
+ malloc(sizeof(struct sparc_bus_dma_tag), M_DEVBUF, M_NOWAIT);
+ if (dt == NULL)
+ panic("could not allocate ebus dma tag");
+
+ bzero(dt, sizeof *dt);
+ dt->_cookie = sc;
+ dt->_parent = pdt;
+#define PCOPY(x) dt->x = pdt->x
+ PCOPY(_dmamap_create);
+ PCOPY(_dmamap_destroy);
+ dt->_dmamap_load = ebus_dmamap_load;
+ PCOPY(_dmamap_load_mbuf);
+ PCOPY(_dmamap_load_uio);
+ PCOPY(_dmamap_load_raw);
+ dt->_dmamap_unload = ebus_dmamap_unload;
+ dt->_dmamap_sync = ebus_dmamap_sync;
+ dt->_dmamem_alloc = ebus_dmamem_alloc;
+ dt->_dmamem_free = ebus_dmamem_free;
+ dt->_dmamem_map = ebus_dmamem_map;
+ dt->_dmamem_unmap = ebus_dmamem_unmap;
+ PCOPY(_dmamem_mmap);
+#undef PCOPY
+ return (dt);
+}
+
+/*
+ * bus space support. <sparc64/dev/psychoreg.h> has a discussion
+ * about PCI physical addresses, which also applies to ebus.
+ */
+static int
+_ebus_bus_map(t, btype, offset, size, flags, vaddr, hp)
+ bus_space_tag_t t;
+ bus_type_t btype;
+ bus_addr_t offset;
+ bus_size_t size;
+ int flags;
+ vaddr_t vaddr;
+ bus_space_handle_t *hp;
+{
+ struct ebus_softc *sc = t->cookie;
+ bus_addr_t hi, lo;
+ int i;
+
+ DPRINTF(EDB_BUSMAP, ("\n_ebus_bus_map: type %d off %016llx sz %x flags %d va %p", (int)t->type, (u_int64_t)offset, (int)size, (int)flags, vaddr));
+
+ hi = offset >> 32UL;
+ lo = offset & 0xffffffff;
+ DPRINTF(EDB_BUSMAP, (" (hi %08x lo %08x)", (u_int)hi, (u_int)lo));
+ for (i = 0; i < sc->sc_nrange; i++) {
+ bus_addr_t pciaddr;
+
+ if (hi != sc->sc_range[i].child_hi)
+ continue;
+ if (lo < sc->sc_range[i].child_lo ||
+ (lo + size) > (sc->sc_range[i].child_lo + sc->sc_range[i].size))
+ continue;
+
+ pciaddr = ((bus_addr_t)sc->sc_range[i].phys_mid << 32UL) |
+ sc->sc_range[i].phys_lo;
+ pciaddr += lo;
+ DPRINTF(EDB_BUSMAP, ("\n_ebus_bus_map: mapping paddr offset %qx pciaddr %qx\n",
+ offset, pciaddr));
+ /* pass it onto the psycho */
+ return (bus_space_map2(sc->sc_bustag, t->type, pciaddr,
+ size, flags, vaddr, hp));
+ }
+ DPRINTF(EDB_BUSMAP, (": FAILED\n"));
+ return (EINVAL);
+}
+
+static int
+ebus_bus_mmap(t, btype, paddr, flags, hp)
+ bus_space_tag_t t;
+ bus_type_t btype;
+ bus_addr_t paddr;
+ int flags;
+ bus_space_handle_t *hp;
+{
+ bus_addr_t offset = paddr;
+ struct ebus_softc *sc = t->cookie;
+ int i;
+
+ for (i = 0; i < sc->sc_nrange; i++) {
+ bus_addr_t paddr = ((bus_addr_t)sc->sc_range[i].child_hi << 32) |
+ sc->sc_range[i].child_lo;
+
+ if (offset != paddr)
+ continue;
+
+ DPRINTF(EDB_BUSMAP, ("\n_ebus_bus_mmap: mapping paddr %qx\n", paddr));
+ return (bus_space_mmap(sc->sc_bustag, 0, paddr,
+ flags, hp));
+ }
+
+ return (-1);
+}
+
+/*
+ * install an interrupt handler for a PCI device
+ */
+void *
+ebus_intr_establish(t, level, flags, handler, arg)
+ bus_space_tag_t t;
+ int level;
+ int flags;
+ int (*handler) __P((void *));
+ void *arg;
+{
+
+ /* XXX */
+ return (0);
+}
+
+/*
+ * bus dma support
+ */
+int
+ebus_dmamap_load(t, map, buf, buflen, p, flags)
+ bus_dma_tag_t t;
+ bus_dmamap_t map;
+ void *buf;
+ bus_size_t buflen;
+ struct proc *p;
+ int flags;
+{
+ struct ebus_softc *sc = t->_cookie;
+
+ return (iommu_dvmamap_load(t, &sc->sc_parent->sc_is, map, buf, buflen,
+ p, flags));
+}
+
+void
+ebus_dmamap_unload(t, map)
+ bus_dma_tag_t t;
+ bus_dmamap_t map;
+{
+ struct ebus_softc *sc = t->_cookie;
Home |
Main Index |
Thread Index |
Old Index