Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/hpcmips Rewrite bus stuff with method table in the ...



details:   https://anonhg.NetBSD.org/src/rev/47c99620427d
branches:  trunk
changeset: 517729:47c99620427d
user:      takemura <takemura%NetBSD.org@localhost>
date:      Sun Nov 18 08:19:39 2001 +0000

description:
Rewrite bus stuff with method table in the bus tags.

diffstat:

 sys/arch/hpcmips/conf/files.hpcmips          |     3 +-
 sys/arch/hpcmips/dev/plumohci.c              |    59 +-
 sys/arch/hpcmips/dev/plumpcmcia.c            |     8 +-
 sys/arch/hpcmips/hpcmips/bus_dma.c           |   205 ++-
 sys/arch/hpcmips/hpcmips/bus_space.c         |   450 +++++++-
 sys/arch/hpcmips/hpcmips/bus_space_notimpl.c |   112 ++
 sys/arch/hpcmips/hpcmips/mainbus.c           |     7 +-
 sys/arch/hpcmips/include/bus.h               |  1390 ++++++++++++++++---------
 sys/arch/hpcmips/include/bus_dma_hpcmips.h   |    76 +
 sys/arch/hpcmips/include/bus_machdep.h       |    70 +
 sys/arch/hpcmips/include/bus_space_hpcmips.h |    56 +
 sys/arch/hpcmips/include/bus_types.h         |    43 +
 sys/arch/hpcmips/isa/isa_machdep.c           |    26 +-
 sys/arch/hpcmips/tx/txcsbus.c                |    13 +-
 sys/arch/hpcmips/vr/vr.c                     |     5 +-
 15 files changed, 1807 insertions(+), 716 deletions(-)

diffs (truncated from 3335 to 300 lines):

diff -r 9b329cc9770c -r 47c99620427d sys/arch/hpcmips/conf/files.hpcmips
--- a/sys/arch/hpcmips/conf/files.hpcmips       Sun Nov 18 08:16:15 2001 +0000
+++ b/sys/arch/hpcmips/conf/files.hpcmips       Sun Nov 18 08:19:39 2001 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.hpcmips,v 1.61 2001/09/17 17:03:44 uch Exp $
+#      $NetBSD: files.hpcmips,v 1.62 2001/11/18 08:19:39 takemura Exp $
 
 # maxpartitions must be first item in files.${ARCH}.
 maxpartitions 8
@@ -53,6 +53,7 @@
 file   arch/hpcmips/hpcmips/autoconf.c
 file   arch/hpcmips/hpcmips/bus_dma.c
 file   arch/hpcmips/hpcmips/bus_space.c
+file   arch/hpcmips/hpcmips/bus_space_notimpl.c
 file   arch/hpcmips/hpcmips/conf.c
 file   arch/hpcmips/hpcmips/interrupt.c
 file   arch/hpcmips/hpcmips/machdep.c
diff -r 9b329cc9770c -r 47c99620427d sys/arch/hpcmips/dev/plumohci.c
--- a/sys/arch/hpcmips/dev/plumohci.c   Sun Nov 18 08:16:15 2001 +0000
+++ b/sys/arch/hpcmips/dev/plumohci.c   Sun Nov 18 08:19:39 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: plumohci.c,v 1.4 2001/09/15 12:47:06 uch Exp $ */
+/*     $NetBSD: plumohci.c,v 1.5 2001/11/18 08:19:39 takemura Exp $ */
 
 /*-
  * Copyright (c) 2000 UCHIYAMA Yasushi
@@ -45,8 +45,8 @@
 #include <sys/mbuf.h>
 #include <uvm/uvm_extern.h>
 
-#define _HPCMIPS_BUS_DMA_PRIVATE
 #include <machine/bus.h>
+#include <machine/bus_dma_hpcmips.h>
 
 #include <dev/usb/usb.h>
 #include <dev/usb/usbdi.h>
@@ -75,21 +75,26 @@
     int, size_t, caddr_t *, int);
 void __plumohci_dmamem_unmap(bus_dma_tag_t, caddr_t, size_t);
 
-struct hpcmips_bus_dma_tag plumohci_bus_dma_tag = {
-       _bus_dmamap_create,
-       _bus_dmamap_destroy,
-       _bus_dmamap_load,
-       _bus_dmamap_load_mbuf,
-       _bus_dmamap_load_uio,
-       _bus_dmamap_load_raw,
-       _bus_dmamap_unload,
-       __plumohci_dmamap_sync,
-       __plumohci_dmamem_alloc,
-       __plumohci_dmamem_free,
-       __plumohci_dmamem_map,
-       __plumohci_dmamem_unmap,
-       _bus_dmamem_mmap,
-       NULL
+struct bus_dma_tag_hpcmips plumohci_bus_dma_tag = {
+       {
+               NULL,
+               {
+                       _hpcmips_bd_map_create,
+                       _hpcmips_bd_map_destroy,
+                       _hpcmips_bd_map_load,
+                       _hpcmips_bd_map_load_mbuf,
+                       _hpcmips_bd_map_load_uio,
+                       _hpcmips_bd_map_load_raw,
+                       _hpcmips_bd_map_unload,
+                       __plumohci_dmamap_sync,
+                       __plumohci_dmamem_alloc,
+                       __plumohci_dmamem_free,
+                       __plumohci_dmamem_map,
+                       __plumohci_dmamem_unmap,
+                       _hpcmips_bd_mem_mmap,
+               },
+       },
+       NULL,
 };
 
 struct plumohci_shm {
@@ -128,8 +133,8 @@
        usbd_status r;
 
        sc->sc.iot = pa->pa_iot;
-       sc->sc.sc_bus.dmatag = &plumohci_bus_dma_tag;
-       sc->sc.sc_bus.dmatag->_dmamap_chipset_v = sc;
+       sc->sc.sc_bus.dmatag = &plumohci_bus_dma_tag.bdt;
+       plumohci_bus_dma_tag._dmamap_chipset_v = sc;
 
        /* Map I/O space */
        if (bus_space_map(sc->sc.iot, PLUM_OHCI_REGBASE, OHCI_PAGE_SIZE, 
@@ -199,9 +204,10 @@
  */
 
 void
-__plumohci_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset,
+__plumohci_dmamap_sync(bus_dma_tag_t tx, bus_dmamap_t map, bus_addr_t offset,
     bus_size_t len, int ops)
 {
+       struct bus_dma_tag_hpcmips *t = (struct bus_dma_tag_hpcmips *)tx;
        struct plumohci_softc *sc = t->_dmamap_chipset_v;
 
        /*
@@ -212,10 +218,11 @@
 }
 
 int
-__plumohci_dmamem_alloc(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment,
-    bus_size_t boundary, bus_dma_segment_t *segs, int nsegs, int *rsegs,
-    int flags)
+__plumohci_dmamem_alloc(bus_dma_tag_t tx, bus_size_t size,
+    bus_size_t alignment, bus_size_t boundary, bus_dma_segment_t *segs,
+    int nsegs, int *rsegs, int flags)
 {
+       struct bus_dma_tag_hpcmips *t = (struct bus_dma_tag_hpcmips *)tx;
        struct plumohci_softc *sc = t->_dmamap_chipset_v;
        struct plumohci_shm *ps;
        bus_space_handle_t bsh;
@@ -254,8 +261,9 @@
 }
 
 void
-__plumohci_dmamem_free(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs)
+__plumohci_dmamem_free(bus_dma_tag_t tx, bus_dma_segment_t *segs, int nsegs)
 {
+       struct bus_dma_tag_hpcmips *t = (struct bus_dma_tag_hpcmips *)tx;
        struct plumohci_softc *sc = t->_dmamap_chipset_v;
        struct plumohci_shm *ps;
 
@@ -276,9 +284,10 @@
 }
 
 int
-__plumohci_dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs,
+__plumohci_dmamem_map(bus_dma_tag_t tx, bus_dma_segment_t *segs, int nsegs,
     size_t size, caddr_t *kvap, int flags)
 {
+       struct bus_dma_tag_hpcmips *t = (struct bus_dma_tag_hpcmips *)tx;
        struct plumohci_softc *sc = t->_dmamap_chipset_v;
        struct plumohci_shm *ps;
 
diff -r 9b329cc9770c -r 47c99620427d sys/arch/hpcmips/dev/plumpcmcia.c
--- a/sys/arch/hpcmips/dev/plumpcmcia.c Sun Nov 18 08:16:15 2001 +0000
+++ b/sys/arch/hpcmips/dev/plumpcmcia.c Sun Nov 18 08:19:39 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: plumpcmcia.c,v 1.7 2001/09/15 12:47:06 uch Exp $ */
+/*     $NetBSD: plumpcmcia.c,v 1.8 2001/11/18 08:19:39 takemura Exp $ */
 
 /*
  * Copyright (c) 1999, 2000 UCHIYAMA Yasushi. All rights reserved.
@@ -39,6 +39,7 @@
 
 #include <machine/bus.h>
 #include <machine/config_hook.h>
+#include <machine/bus_space_hpcmips.h>
 
 #include <dev/pcmcia/pcmciareg.h>
 #include <dev/pcmcia/pcmciavar.h>
@@ -373,7 +374,8 @@
 
        pcmhp->memt = ph->ph_memt;
        /* Address offset from MEM area base */
-       pcmhp->addr = pcmhp->memh - ph->ph_membase - ph->ph_memt->t_base;
+       pcmhp->addr = pcmhp->memh - ph->ph_membase - 
+           ((struct bus_space_tag_hpcmips*)ph->ph_memt)->base;
        pcmhp->size = size;
        pcmhp->realsize = realsize;
 
@@ -531,7 +533,7 @@
                }
                /* Address offset from IO area base */
                pcihp->addr = pcihp->ioh - ph->ph_iobase - 
-                   ph->ph_iot->t_base;
+                   ((struct bus_space_tag_hpcmips*)ph->ph_iot)->base;
                pcihp->flags = PCMCIA_IO_ALLOCATED;
                DPRINTF(("(allocated) %#x+%#x\n", (unsigned)pcihp->addr,
                    (unsigned)size));
diff -r 9b329cc9770c -r 47c99620427d sys/arch/hpcmips/hpcmips/bus_dma.c
--- a/sys/arch/hpcmips/hpcmips/bus_dma.c        Sun Nov 18 08:16:15 2001 +0000
+++ b/sys/arch/hpcmips/hpcmips/bus_dma.c        Sun Nov 18 08:19:39 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_dma.c,v 1.13 2001/11/14 18:15:18 thorpej Exp $     */
+/*     $NetBSD: bus_dma.c,v 1.14 2001/11/18 08:19:39 takemura Exp $    */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -45,10 +45,10 @@
 #include <uvm/uvm_extern.h>
 #include <mips/cache.h>
 
-#define _HPCMIPS_BUS_DMA_PRIVATE
 #include <machine/bus.h>
+#include <machine/bus_dma_hpcmips.h>
 
-static int _bus_dmamap_load_buffer(bus_dmamap_t, void *, bus_size_t,
+static int _hpcmips_bd_map_load_buffer(bus_dmamap_t, void *, bus_size_t,
     struct proc *, int, vaddr_t *, int *, int);
 
 paddr_t        kvtophys(vaddr_t);      /* XXX */
@@ -56,21 +56,26 @@
 /*
  * The default DMA tag for all busses on the hpcmips
  */
-struct hpcmips_bus_dma_tag hpcmips_default_bus_dma_tag = {
-       _bus_dmamap_create,
-       _bus_dmamap_destroy,
-       _bus_dmamap_load,
-       _bus_dmamap_load_mbuf,
-       _bus_dmamap_load_uio,
-       _bus_dmamap_load_raw,
-       _bus_dmamap_unload,
-       _bus_dmamap_sync,
-       _bus_dmamem_alloc,
-       _bus_dmamem_free,
-       _bus_dmamem_map,
-       _bus_dmamem_unmap,
-       _bus_dmamem_mmap,
-       NULL
+struct bus_dma_tag_hpcmips hpcmips_default_bus_dma_tag = {
+       {
+               NULL,
+               {
+                       _hpcmips_bd_map_create,
+                       _hpcmips_bd_map_destroy,
+                       _hpcmips_bd_map_load,
+                       _hpcmips_bd_map_load_mbuf,
+                       _hpcmips_bd_map_load_uio,
+                       _hpcmips_bd_map_load_raw,
+                       _hpcmips_bd_map_unload,
+                       _hpcmips_bd_map_sync,
+                       _hpcmips_bd_mem_alloc,
+                       _hpcmips_bd_mem_free,
+                       _hpcmips_bd_mem_map,
+                       _hpcmips_bd_mem_unmap,
+                       _hpcmips_bd_mem_mmap,
+               },
+       },
+       NULL,
 };
 
 /*
@@ -78,42 +83,43 @@
  * DMA map creation functions.
  */
 int
-_bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
+_hpcmips_bd_map_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
     bus_size_t maxsegsz, bus_size_t boundary, int flags, bus_dmamap_t *dmamp)
 {
-       struct hpcmips_bus_dmamap *map;
+       struct bus_dmamap_hpcmips *map;
        void *mapstore;
        size_t mapsize;
 
        /*
         * Allcoate and initialize the DMA map.  The end of the map
-        * is a variable-sized array of segments, so we allocate enough
+        * has two variable-sized array of segments, so we allocate enough
         * room for them in one shot.
         *
         * Note we don't preserve the WAITOK or NOWAIT flags.  Preservation
         * of ALLOCNOW notifes others that we've reserved these resources,
         * and they are not to be freed.
-        *
-        * The bus_dmamap_t includes one bus_dma_segment_t, hence
-        * the (nsegments - 1).
         */
-       mapsize = sizeof(struct hpcmips_bus_dmamap) +
-           (sizeof(bus_dma_segment_t) * (nsegments - 1));
+       mapsize = sizeof(struct bus_dmamap_hpcmips) +
+           sizeof(struct bus_dma_segment_hpcmips) * (nsegments - 1) +
+           sizeof(bus_dma_segment_t) * nsegments;
        if ((mapstore = malloc(mapsize, M_DMAMAP,
            (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL)
                return (ENOMEM);
 
        bzero(mapstore, mapsize);
-       map = (struct hpcmips_bus_dmamap *)mapstore;
+       map = (struct bus_dmamap_hpcmips *)mapstore;
        map->_dm_size = size;
        map->_dm_segcnt = nsegments;
        map->_dm_maxsegsz = maxsegsz;
        map->_dm_boundary = boundary;
        map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
-       map->dm_mapsize = 0;            /* no valid mappings */
-       map->dm_nsegs = 0;
+       map->bdm.dm_mapsize = 0;        /* no valid mappings */
+       map->bdm.dm_nsegs = 0;
+       map->bdm.dm_segs = (bus_dma_segment_t *)((char *)mapstore +
+           sizeof(struct bus_dmamap_hpcmips) +
+           sizeof(struct bus_dma_segment_hpcmips) * (nsegments - 1));
 
-       *dmamp = map;
+       *dmamp = &map->bdm;
        return (0);
 }
 
@@ -122,7 +128,7 @@
  * DMA map destruction functions.
  */
 void
-_bus_dmamap_destroy(bus_dma_tag_t t, bus_dmamap_t map)



Home | Main Index | Thread Index | Old Index