diff options
Diffstat (limited to 'sys/arch/sparc64/dev')
-rw-r--r-- | sys/arch/sparc64/dev/iommu.c | 109 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/iommuvar.h | 39 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/psycho.c | 167 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/sbus.c | 141 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/schizo.c | 141 |
5 files changed, 151 insertions, 446 deletions
diff --git a/sys/arch/sparc64/dev/iommu.c b/sys/arch/sparc64/dev/iommu.c index 16515e36747..2ee311b4a4e 100644 --- a/sys/arch/sparc64/dev/iommu.c +++ b/sys/arch/sparc64/dev/iommu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iommu.c,v 1.30 2003/06/11 03:07:41 henric Exp $ */ +/* $OpenBSD: iommu.c,v 1.31 2003/06/11 03:16:12 henric Exp $ */ /* $NetBSD: iommu.c,v 1.47 2002/02/08 20:03:45 eeh Exp $ */ /* @@ -556,17 +556,26 @@ iommu_strbuf_flush_done(struct iommu_map_state *ims) /* * IOMMU DVMA operations, common to SBUS and PCI. */ + +#define BUS_DMA_FIND_PARENT(t, fn) \ + if (t->_parent == NULL) \ + panic("null bus_dma parent (" #fn ")"); \ + for (t = t->_parent; t->fn == NULL; t = t->_parent) \ + if (t->_parent == NULL) \ + panic("no bus_dma " #fn " located"); + int -iommu_dvmamap_create(bus_dma_tag_t t, struct iommu_state *is, - struct strbuf_ctl *sb, bus_size_t size, int nsegments, bus_size_t maxsegsz, - bus_size_t boundary, int flags, bus_dmamap_t *dmamap) +iommu_dvmamap_create(bus_dma_tag_t t, bus_dma_tag_t t0, struct strbuf_ctl *sb, + bus_size_t size, int nsegments, bus_size_t maxsegsz, bus_size_t boundary, + int flags, bus_dmamap_t *dmamap) { int ret; bus_dmamap_t map; struct iommu_map_state *ims; - ret = bus_dmamap_create(t->_parent, size, nsegments, maxsegsz, - boundary, flags, &map); + BUS_DMA_FIND_PARENT(t, _dmamap_create); + ret = (*t->_dmamap_create)(t, t0, size, nsegments, maxsegsz, boundary, + flags, &map); if (ret) return (ret); @@ -574,32 +583,40 @@ iommu_dvmamap_create(bus_dma_tag_t t, struct iommu_state *is, ims = iommu_iomap_create(nsegments); if (ims == NULL) { - bus_dmamap_destroy(t->_parent, map); + bus_dmamap_destroy(t0, map); return (ENOMEM); } ims->ims_sb = sb; map->_dm_cookie = ims; + +#ifdef DIAGNOSTIC + if (ims->ims_sb == NULL) + panic("iommu_dvmamap_create: null sb"); + if (ims->ims_sb->sb_iommu == NULL) + panic("iommu_dvmamap_create: null iommu"); +#endif *dmamap = map; return (0); } void -iommu_dvmamap_destroy(bus_dma_tag_t t, bus_dmamap_t map) +iommu_dvmamap_destroy(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map) { /* * The specification (man page) requires a loaded * map to be unloaded before it is destroyed. */ if (map->dm_nsegs) - bus_dmamap_unload(t, map); + bus_dmamap_unload(t0, map); if (map->_dm_cookie) iommu_iomap_destroy(map->_dm_cookie); map->_dm_cookie = NULL; - bus_dmamap_destroy(t->_parent, map); + BUS_DMA_FIND_PARENT(t, _dmamap_destroy); + (*t->_dmamap_destroy)(t, t0, map); } /* @@ -612,7 +629,7 @@ iommu_dvmamap_destroy(bus_dma_tag_t t, bus_dmamap_t map) * up to the page size and then divide by the page size)... */ int -iommu_dvmamap_load(bus_dma_tag_t t, struct iommu_state *is, bus_dmamap_t map, +iommu_dvmamap_load(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map, void *buf, bus_size_t buflen, struct proc *p, int flags) { int s; @@ -620,6 +637,7 @@ iommu_dvmamap_load(bus_dma_tag_t t, struct iommu_state *is, bus_dmamap_t map, bus_size_t sgsize; u_long dvmaddr, sgstart, sgend; bus_size_t align, boundary; + struct iommu_state *is; struct iommu_map_state *ims = map->_dm_cookie; pmap_t pmap; @@ -627,6 +645,13 @@ iommu_dvmamap_load(bus_dma_tag_t t, struct iommu_state *is, bus_dmamap_t map, if (ims == NULL) panic("iommu_dvmamap_load: null map state"); #endif +#ifdef DEBUG + if (ims->ims_sb == NULL) + panic("iommu_dvmamap_load: null sb"); + if (ims->ims_sb->sb_iommu == NULL) + panic("iommu_dvmamap_load: null iommu"); +#endif /* DEBUG */ + is = ims->ims_sb->sb_iommu; if (map->dm_nsegs) { /* @@ -636,7 +661,7 @@ iommu_dvmamap_load(bus_dma_tag_t t, struct iommu_state *is, bus_dmamap_t map, #ifdef DIAGNOSTIC panic("iommu_dvmamap_load: map still in use"); #endif - bus_dmamap_unload(t, map); + bus_dmamap_unload(t0, map); } /* @@ -812,9 +837,8 @@ iommu_dvmamap_load(bus_dma_tag_t t, struct iommu_state *is, bus_dmamap_t map, * the dvma map). */ int -iommu_dvmamap_load_raw(bus_dma_tag_t t, struct iommu_state *is, - bus_dmamap_t map, bus_dma_segment_t *segs, int nsegs, int flags, - bus_size_t size) +iommu_dvmamap_load_raw(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map, + bus_dma_segment_t *segs, int nsegs, bus_size_t size, int flags) { int i, s; int left; @@ -822,19 +846,27 @@ iommu_dvmamap_load_raw(bus_dma_tag_t t, struct iommu_state *is, bus_size_t sgsize; bus_size_t boundary, align; u_long dvmaddr, sgstart, sgend; + struct iommu_state *is; struct iommu_map_state *ims = map->_dm_cookie; #ifdef DIAGNOSTIC if (ims == NULL) panic("iommu_dvmamap_load_raw: null map state"); #endif +#ifdef DEBUG + if (ims->ims_sb == NULL) + panic("iommu_dvmamap_load_raw: null sb"); + if (ims->ims_sb->sb_iommu == NULL) + panic("iommu_dvmamap_load_raw: null iommu"); +#endif /* DEBUG */ + is = ims->ims_sb->sb_iommu; if (map->dm_nsegs) { /* Already in use?? */ #ifdef DIAGNOSTIC panic("iommu_dvmamap_load_raw: map still in use"); #endif - bus_dmamap_unload(t, map); + bus_dmamap_unload(t0, map); } /* @@ -1228,13 +1260,25 @@ iommu_dvmamap_load_mlist(bus_dma_tag_t t, struct iommu_state *is, * Unload a dvmamap. */ void -iommu_dvmamap_unload(bus_dma_tag_t t, struct iommu_state *is, bus_dmamap_t map) +iommu_dvmamap_unload(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map) { + struct iommu_state *is; struct iommu_map_state *ims = map->_dm_cookie; bus_addr_t dvmaddr = map->_dm_dvmastart; bus_size_t sgsize = map->_dm_dvmasize; int error, s; +#ifdef DEBUG + if (ims == NULL) + panic("iommu_dvmamap_unload: null map state"); + if (ims->ims_sb == NULL) + panic("iommu_dvmamap_unload: null sb"); + if (ims->ims_sb->sb_iommu == NULL) + panic("iommu_dvmamap_unload: null iommu"); +#endif /* DEBUG */ + + is = ims->ims_sb->sb_iommu; + /* Flush the iommu */ #ifdef DEBUG if (dvmaddr == 0) { @@ -1423,19 +1467,26 @@ iommu_dvmamap_print_map(bus_dma_tag_t t, struct iommu_state *is, } void -iommu_dvmamap_sync(bus_dma_tag_t t, struct iommu_state *is, bus_dmamap_t map, +iommu_dvmamap_sync(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map, bus_addr_t offset, bus_size_t len, int ops) { + struct iommu_state *is; struct iommu_map_state *ims = map->_dm_cookie; struct strbuf_ctl *sb; bus_size_t count; int i, needsflush = 0; -#ifdef DIAGNOSTIC +#ifdef DEBUG if (ims == NULL) panic("iommu_dvmamap_sync: null map state"); -#endif + if (ims->ims_sb == NULL) + panic("iommu_dvmamap_sync: null sb"); + if (ims->ims_sb->sb_iommu == NULL) + panic("iommu_dvmamap_sync: null iommu"); +#endif /* DEBUG */ + sb = ims->ims_sb; + is = sb->sb_iommu; if ((ims->ims_flags & IOMMU_MAP_STREAM) == 0 || (len == 0)) return; @@ -1513,7 +1564,7 @@ iommu_dvmamap_sync_range(struct strbuf_ctl *sb, vaddr_t va, bus_size_t len) } int -iommu_dvmamem_alloc(bus_dma_tag_t t, struct iommu_state *is, bus_size_t size, +iommu_dvmamem_alloc(bus_dma_tag_t t, bus_dma_tag_t t0, bus_size_t size, bus_size_t alignment, bus_size_t boundary, bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags) { @@ -1522,18 +1573,20 @@ iommu_dvmamem_alloc(bus_dma_tag_t t, struct iommu_state *is, bus_size_t size, "bound %llx segp %p flags %d\n", (unsigned long long)size, (unsigned long long)alignment, (unsigned long long)boundary, segs, flags)); - return (bus_dmamem_alloc(t->_parent, size, alignment, boundary, + BUS_DMA_FIND_PARENT(t, _dmamem_alloc); + return ((*t->_dmamem_alloc)(t, t0, size, alignment, boundary, segs, nsegs, rsegs, flags | BUS_DMA_DVMA)); } void -iommu_dvmamem_free(bus_dma_tag_t t, struct iommu_state *is, - bus_dma_segment_t *segs, int nsegs) +iommu_dvmamem_free(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dma_segment_t *segs, + int nsegs) { DPRINTF(IDB_BUSDMA, ("iommu_dvmamem_free: segp %p nsegs %d\n", segs, nsegs)); - bus_dmamem_free(t->_parent, segs, nsegs); + BUS_DMA_FIND_PARENT(t, _dmamem_free); + (*t->_dmamem_free)(t, t0, segs, nsegs); } /* @@ -1541,8 +1594,8 @@ iommu_dvmamem_free(bus_dma_tag_t t, struct iommu_state *is, * Check the flags to see whether we're streaming or coherent. */ int -iommu_dvmamem_map(bus_dma_tag_t t, struct iommu_state *is, - bus_dma_segment_t *segs, int nsegs, size_t size, caddr_t *kvap, int flags) +iommu_dvmamem_map(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dma_segment_t *segs, + int nsegs, size_t size, caddr_t *kvap, int flags) { struct vm_page *m; vaddr_t va; @@ -1602,7 +1655,7 @@ iommu_dvmamem_map(bus_dma_tag_t t, struct iommu_state *is, * Unmap DVMA mappings from kernel */ void -iommu_dvmamem_unmap(bus_dma_tag_t t, struct iommu_state *is, caddr_t kva, +iommu_dvmamem_unmap(bus_dma_tag_t t, bus_dma_tag_t t0, caddr_t kva, size_t size) { diff --git a/sys/arch/sparc64/dev/iommuvar.h b/sys/arch/sparc64/dev/iommuvar.h index f2726150aa0..d64d35b8c32 100644 --- a/sys/arch/sparc64/dev/iommuvar.h +++ b/sys/arch/sparc64/dev/iommuvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: iommuvar.h,v 1.8 2003/03/06 08:26:08 henric Exp $ */ +/* $OpenBSD: iommuvar.h,v 1.9 2003/06/11 03:16:12 henric Exp $ */ /* $NetBSD: iommuvar.h,v 1.9 2001/10/07 20:30:41 eeh Exp $ */ /* @@ -117,27 +117,24 @@ void iommu_reset(struct iommu_state *); paddr_t iommu_extract(struct iommu_state *, vaddr_t); int64_t iommu_lookup_tte(struct iommu_state *, vaddr_t); int64_t iommu_fetch_tte(struct iommu_state *, paddr_t); -int iommu_dvmamap_create(bus_dma_tag_t, struct iommu_state *, - struct strbuf_ctl *, bus_size_t, int, bus_size_t, bus_size_t, - int, bus_dmamap_t *); -void iommu_dvmamap_destroy(bus_dma_tag_t, bus_dmamap_t); -int iommu_dvmamap_load(bus_dma_tag_t, struct iommu_state *, - bus_dmamap_t, void *, bus_size_t, struct proc *, int); -void iommu_dvmamap_unload(bus_dma_tag_t, struct iommu_state *, - bus_dmamap_t); -int iommu_dvmamap_load_raw(bus_dma_tag_t, struct iommu_state *, - bus_dmamap_t, bus_dma_segment_t *, int, int, bus_size_t); -void iommu_dvmamap_sync(bus_dma_tag_t, struct iommu_state *, bus_dmamap_t, +/* bus_dma_tag_t implementation functions */ +int iommu_dvmamap_create(bus_dma_tag_t, bus_dma_tag_t, struct strbuf_ctl *, + bus_size_t, int, bus_size_t, bus_size_t, int, bus_dmamap_t *); +void iommu_dvmamap_destroy(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t); +int iommu_dvmamap_load(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, void *, + bus_size_t, struct proc *, int); +void iommu_dvmamap_unload(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t); +int iommu_dvmamap_load_raw(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, + bus_dma_segment_t *, int, bus_size_t, int); +void iommu_dvmamap_sync(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, bus_addr_t, bus_size_t, int); -int iommu_dvmamem_alloc(bus_dma_tag_t, struct iommu_state *, - bus_size_t, bus_size_t, bus_size_t, bus_dma_segment_t *, - int, int *, int); -void iommu_dvmamem_free(bus_dma_tag_t, struct iommu_state *, - bus_dma_segment_t *, int); -int iommu_dvmamem_map(bus_dma_tag_t, struct iommu_state *, - bus_dma_segment_t *, int, size_t, caddr_t *, int); -void iommu_dvmamem_unmap(bus_dma_tag_t, struct iommu_state *, - caddr_t, size_t); +int iommu_dvmamem_alloc(bus_dma_tag_t, bus_dma_tag_t, bus_size_t, + bus_size_t, bus_size_t, bus_dma_segment_t *, int, int *, int); +void iommu_dvmamem_free(bus_dma_tag_t, bus_dma_tag_t, bus_dma_segment_t *, + int); +int iommu_dvmamem_map(bus_dma_tag_t, bus_dma_tag_t, bus_dma_segment_t *, + int, size_t, caddr_t *, int); +void iommu_dvmamem_unmap(bus_dma_tag_t, bus_dma_tag_t, caddr_t, size_t); #define IOMMUREG_READ(is, reg) \ bus_space_read_8((is)->is_bustag, \ diff --git a/sys/arch/sparc64/dev/psycho.c b/sys/arch/sparc64/dev/psycho.c index ac3ffe903e9..20524916018 100644 --- a/sys/arch/sparc64/dev/psycho.c +++ b/sys/arch/sparc64/dev/psycho.c @@ -1,4 +1,4 @@ -/* $OpenBSD: psycho.c,v 1.35 2003/06/04 23:26:12 henric Exp $ */ +/* $OpenBSD: psycho.c,v 1.36 2003/06/11 03:16:12 henric Exp $ */ /* $NetBSD: psycho.c,v 1.39 2001/10/07 20:30:41 eeh Exp $ */ /* @@ -103,24 +103,10 @@ int _psycho_bus_map(bus_space_tag_t, bus_space_tag_t, bus_addr_t, void *psycho_intr_establish(bus_space_tag_t, bus_space_tag_t, int, int, int, int (*)(void *), void *); -int psycho_dmamap_create(bus_dma_tag_t, bus_dma_tag_t, bus_size_t, int, bus_size_t, - bus_size_t, int, bus_dmamap_t *); -void psycho_dvmamap_destroy(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t); -int psycho_dmamap_load(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, void *, - bus_size_t, struct proc *, int); -void psycho_dmamap_unload(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t); -int psycho_dmamap_load_raw(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, - bus_dma_segment_t *, int, bus_size_t, int); -void psycho_dmamap_sync(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, bus_addr_t, - bus_size_t, int); +int psycho_dmamap_create(bus_dma_tag_t, bus_dma_tag_t, bus_size_t, int, + bus_size_t, bus_size_t, int, bus_dmamap_t *); void psycho_sabre_dvmamap_sync(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, bus_size_t, bus_size_t, int); -int psycho_dmamem_alloc(bus_dma_tag_t, bus_dma_tag_t, bus_size_t, bus_size_t, bus_size_t, - bus_dma_segment_t *, int, int *, int); -void psycho_dmamem_free(bus_dma_tag_t, bus_dma_tag_t, bus_dma_segment_t *, int); -int psycho_dmamem_map(bus_dma_tag_t, bus_dma_tag_t, bus_dma_segment_t *, int, size_t, - caddr_t *, int); -void psycho_dmamem_unmap(bus_dma_tag_t, bus_dma_tag_t, caddr_t, size_t); void psycho_map_psycho(struct psycho_softc *, int, bus_addr_t, bus_size_t, bus_addr_t, bus_size_t); int psycho_intr_map(struct pci_attach_args *, pci_intr_handle_t *); @@ -220,7 +206,7 @@ psycho_match(struct device *parent, void *match, void *aux) } /* - * SUNW,psycho initialisation .. + * SUNW,psycho initialization ... * - find the per-psycho registers * - figure out the IGN. * - find our partner psycho @@ -486,11 +472,11 @@ psycho_attach(struct device *parent, struct device *self, void *aux) printf("STC0 subregion failed\n"); sb->sb_flush = 0; } - - /* Point out iommu at the strbuf_ctl. */ - sc->sc_is->is_sb[0] = sb; } + /* Point out iommu at the strbuf_ctl. */ + sc->sc_is->is_sb[0] = &pp->pp_sb; + psycho_iommu_init(sc, 2); sc->sc_configtag = psycho_alloc_config_tag(sc->sc_psycho_this); @@ -528,6 +514,9 @@ psycho_attach(struct device *parent, struct device *self, void *aux) sc->sc_is->is_sb[1] = sb; } + /* Point out iommu at the strbuf_ctl. */ + sc->sc_is->is_sb[1] = &pp->pp_sb; + iommu_reset(sc->sc_is); } @@ -921,19 +910,20 @@ psycho_alloc_dma_tag(struct psycho_pbm *pp) bzero(dt, sizeof *dt); dt->_cookie = pp; dt->_parent = pdt; - dt->_dmamap_create = psycho_dmamap_create; - dt->_dmamap_destroy = psycho_dvmamap_destroy; - dt->_dmamap_load = psycho_dmamap_load; - dt->_dmamap_load_raw = psycho_dmamap_load_raw; - dt->_dmamap_unload = psycho_dmamap_unload; + dt->_dmamap_create = psycho_dmamap_create; + dt->_dmamap_destroy = iommu_dvmamap_destroy; + dt->_dmamap_load = iommu_dvmamap_load; + dt->_dmamap_load_raw = iommu_dvmamap_load_raw; + dt->_dmamap_unload = iommu_dvmamap_unload; if (sc->sc_mode == PSYCHO_MODE_PSYCHO) - dt->_dmamap_sync = psycho_dmamap_sync; + dt->_dmamap_sync = iommu_dvmamap_sync; else dt->_dmamap_sync = psycho_sabre_dvmamap_sync; - dt->_dmamem_alloc = psycho_dmamem_alloc; - dt->_dmamem_free = psycho_dmamem_free; - dt->_dmamem_map = psycho_dmamem_map; - dt->_dmamem_unmap = psycho_dmamem_unmap; + dt->_dmamem_alloc = iommu_dvmamem_alloc; + dt->_dmamem_free = iommu_dvmamem_free; + dt->_dmamem_map = iommu_dvmamem_map; + dt->_dmamem_unmap = iommu_dvmamem_unmap; + return (dt); } @@ -1212,79 +1202,9 @@ psycho_dmamap_create(bus_dma_tag_t t, bus_dma_tag_t t0, bus_size_t size, bus_dmamap_t *dmamp) { struct psycho_pbm *pp = t->_cookie; - struct psycho_softc *sc = pp->pp_sc; - - return (iommu_dvmamap_create(t0, sc->sc_is, &pp->pp_sb, size, - nsegments, maxsegsz, boundary, flags, dmamp)); -} - -void -psycho_dvmamap_destroy(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map) -{ - iommu_dvmamap_destroy(t0, map); -} - -int -psycho_dmamap_load(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map, - void *buf, bus_size_t buflen, struct proc *p, int flags) -{ - struct psycho_pbm *pp = t->_cookie; - struct psycho_softc *sc = pp->pp_sc; - - if (pp->pp_sb.sb_flush == NULL) - flags &= ~BUS_DMA_STREAMING; - - return (iommu_dvmamap_load(t0, sc->sc_is, map, buf, buflen, p, flags)); -} - -void -psycho_dmamap_unload(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map) -{ - struct psycho_pbm *pp = t->_cookie; - struct psycho_softc *sc = pp->pp_sc; - - iommu_dvmamap_unload(t0, sc->sc_is, map); -} - -int -psycho_dmamap_load_raw(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map, - bus_dma_segment_t *segs, int nsegs, bus_size_t size, int flags) -{ - struct psycho_pbm *pp = t->_cookie; - struct psycho_softc *sc = pp->pp_sc; - if (pp->pp_sb.sb_flush == NULL) - flags &= ~BUS_DMA_STREAMING; - - return (iommu_dvmamap_load_raw(t0, sc->sc_is, map, segs, nsegs, flags, - size)); -} - -void -psycho_dmamap_sync(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map, bus_addr_t offset, - bus_size_t len, int ops) -{ - struct psycho_pbm *pp = t->_cookie; - struct psycho_softc *sc = pp->pp_sc; - - if (t->_parent == NULL) - panic("psycho_dmamap_sync: no parent"); - - for (t = t->_parent; t->_dmamap_sync == NULL; t = t->_parent) - if (t == NULL) - panic("psycho_dmamap_sync: can't find implementation"); - - if (ops & (BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)) { - /* Flush the CPU then the IOMMU */ - (*t->_dmamap_sync)(t, t0, map, offset, len, - ops); - iommu_dvmamap_sync(t0, sc->sc_is, map, offset, len, ops); - } - if (ops & (BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)) { - /* Flush the IOMMU then the CPU */ - iommu_dvmamap_sync(t0, sc->sc_is, map, offset, len, ops); - (*t->_dmamap_sync)(t, t0, map, offset, len, ops); - } + return (iommu_dvmamap_create(t, t0, &pp->pp_sb, size, nsegments, + maxsegsz, boundary, flags, dmamp)); } void @@ -1301,44 +1221,3 @@ psycho_sabre_dvmamap_sync(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map, membar(MemIssue); } -int -psycho_dmamem_alloc(bus_dma_tag_t t, bus_dma_tag_t t0, bus_size_t size, bus_size_t alignment, - bus_size_t boundary, bus_dma_segment_t *segs, int nsegs, int *rsegs, - int flags) -{ - struct psycho_pbm *pp = t->_cookie; - struct psycho_softc *sc = pp->pp_sc; - - return (iommu_dvmamem_alloc(t0, sc->sc_is, size, alignment, boundary, - segs, nsegs, rsegs, flags)); -} - -void -psycho_dmamem_free(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dma_segment_t *segs, int nsegs) -{ - struct psycho_pbm *pp = t->_cookie; - struct psycho_softc *sc = pp->pp_sc; - - iommu_dvmamem_free(t0, sc->sc_is, segs, nsegs); -} - -int -psycho_dmamem_map(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dma_segment_t *segs, int nsegs, - size_t size, caddr_t *kvap, int flags) -{ - struct psycho_pbm *pp = t->_cookie; - struct psycho_softc *sc = pp->pp_sc; - - return (iommu_dvmamem_map - (t0, sc->sc_is, segs, nsegs, size, kvap, flags)); -} - -void -psycho_dmamem_unmap(bus_dma_tag_t t, bus_dma_tag_t t0, caddr_t kva, size_t size) -{ - struct psycho_pbm *pp = t->_cookie; - struct psycho_softc *sc = pp->pp_sc; - - iommu_dvmamem_unmap(t0, sc->sc_is, kva, size); -} - diff --git a/sys/arch/sparc64/dev/sbus.c b/sys/arch/sparc64/dev/sbus.c index b398aab5cf0..c06e3760eba 100644 --- a/sys/arch/sparc64/dev/sbus.c +++ b/sys/arch/sparc64/dev/sbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sbus.c,v 1.17 2003/06/02 23:27:55 millert Exp $ */ +/* $OpenBSD: sbus.c,v 1.18 2003/06/11 03:16:12 henric Exp $ */ /* $NetBSD: sbus.c,v 1.46 2001/10/07 20:30:41 eeh Exp $ */ /*- @@ -174,23 +174,6 @@ extern struct cfdriver sbus_cd; */ int sbus_dmamap_create(bus_dma_tag_t, bus_dma_tag_t, bus_size_t, int, bus_size_t, bus_size_t, int, bus_dmamap_t *); -void sbus_dmamap_destroy(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t); -int sbus_dmamap_load(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, void *, - bus_size_t, struct proc *, int); -void sbus_dmamap_unload(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t); -int sbus_dmamap_load_raw(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, - bus_dma_segment_t *, int, bus_size_t, int); -void sbus_dmamap_sync(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, bus_addr_t, - bus_size_t, int); -int sbus_dmamem_alloc(bus_dma_tag_t, bus_dma_tag_t tag, bus_size_t size, - bus_size_t alignment, bus_size_t boundary, bus_dma_segment_t *segs, - int nsegs, int *rsegs, int flags); -void sbus_dmamem_free(bus_dma_tag_t, bus_dma_tag_t tag, - bus_dma_segment_t *segs, int nsegs); -int sbus_dmamem_map(bus_dma_tag_t, bus_dma_tag_t tag, bus_dma_segment_t *segs, - int nsegs, size_t size, caddr_t *kvap, int flags); -void sbus_dmamem_unmap(bus_dma_tag_t, bus_dma_tag_t tag, caddr_t kva, - size_t size); /* * Child devices receive the Sbus interrupt level in their attach @@ -321,7 +304,7 @@ sbus_attach(struct device *parent, struct device *self, void *aux) sc->sc_sb.sb_flush = &sc->sc_flush; sc->sc_sb.sb_bustag = sc->sc_bustag; } else - sc->sc_is.is_sb[0] = NULL; + sc->sc_sb.sb_flush = NULL; /* give us a nice name.. */ name = (char *)malloc(32, M_DEVBUF, M_NOWAIT); @@ -808,16 +791,16 @@ sbus_alloc_dmatag(struct sbus_softc *sc) sdt->_cookie = sc; sdt->_parent = psdt; - sdt->_dmamap_create = sbus_dmamap_create; - sdt->_dmamap_destroy = sbus_dmamap_destroy; - sdt->_dmamap_load = sbus_dmamap_load; - sdt->_dmamap_load_raw = sbus_dmamap_load_raw; - sdt->_dmamap_unload = sbus_dmamap_unload; - sdt->_dmamap_sync = sbus_dmamap_sync; - sdt->_dmamem_alloc = sbus_dmamem_alloc; - sdt->_dmamem_free = sbus_dmamem_free; - sdt->_dmamem_map = sbus_dmamem_map; - sdt->_dmamem_unmap = sbus_dmamem_unmap; + sdt->_dmamap_create = sbus_dmamap_create; + sdt->_dmamap_destroy = iommu_dvmamap_destroy; + sdt->_dmamap_load = iommu_dvmamap_load; + sdt->_dmamap_load_raw = iommu_dvmamap_load_raw; + sdt->_dmamap_unload = iommu_dvmamap_unload; + sdt->_dmamap_sync = iommu_dvmamap_sync; + sdt->_dmamem_alloc = iommu_dvmamem_alloc; + sdt->_dmamem_free = iommu_dvmamem_free; + sdt->_dmamem_map = iommu_dvmamem_map; + sdt->_dmamem_unmap = iommu_dvmamem_unmap; sc->sc_dmatag = sdt; return (sdt); } @@ -829,103 +812,7 @@ sbus_dmamap_create(bus_dma_tag_t t, bus_dma_tag_t t0, bus_size_t size, { struct sbus_softc *sc = t->_cookie; - return (iommu_dvmamap_create(t0, &sc->sc_is, &sc->sc_sb, size, - nsegments, maxsegsz, boundary, flags, dmamp)); + return (iommu_dvmamap_create(t, t0, &sc->sc_sb, size, nsegments, + maxsegsz, boundary, flags, dmamp)); } -void -sbus_dmamap_destroy(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map) -{ - iommu_dvmamap_destroy(t0, map); -} - -int -sbus_dmamap_load(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map, - void *buf, bus_size_t buflen, struct proc *p, int flags) -{ - struct sbus_softc *sc = t->_cookie; - - return (iommu_dvmamap_load(t0, &sc->sc_is, map, buf, buflen, - p, flags)); -} - -int -sbus_dmamap_load_raw(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map, - bus_dma_segment_t *segs, int nsegs, bus_size_t size, int flags) -{ - struct sbus_softc *sc = t->_cookie; - - return (iommu_dvmamap_load_raw(t0, &sc->sc_is, map, segs, - nsegs, flags, size)); -} - -void -sbus_dmamap_unload(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map) -{ - struct sbus_softc *sc = t->_cookie; - - iommu_dvmamap_unload(t0, &sc->sc_is, map); -} - -void -sbus_dmamap_sync(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map, - bus_addr_t offset, bus_size_t len, int ops) -{ - struct sbus_softc *sc = t->_cookie; - - if (t->_parent == NULL) - panic("sbus_dmamap_sync: no parent"); - - for (t = t->_parent; t->_dmamap_sync == NULL; t = t->_parent) - if (t == NULL) - panic("sbus_dmamap_sync: can't find implementation"); - - if (ops & (BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE)) { - /* Flush the CPU then the IOMMU */ - (*t->_dmamap_sync)(t, t0, map, offset, len, ops); - iommu_dvmamap_sync(t0, &sc->sc_is, map, offset, len, ops); - } - if (ops & (BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE)) { - /* Flush the IOMMU then the CPU */ - iommu_dvmamap_sync(t0, &sc->sc_is, map, offset, len, ops); - (*t->_dmamap_sync)(t, t0, map, offset, len, ops); - } -} - -int -sbus_dmamem_alloc(bus_dma_tag_t t, bus_dma_tag_t t0, bus_size_t size, - bus_size_t alignment, bus_size_t boundary, bus_dma_segment_t *segs, - int nsegs, int *rsegs, int flags) -{ - struct sbus_softc *sc = t->_cookie; - - return (iommu_dvmamem_alloc(t0, &sc->sc_is, size, alignment, boundary, - segs, nsegs, rsegs, flags)); -} - -void -sbus_dmamem_free(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dma_segment_t *segs, - int nsegs) -{ - struct sbus_softc *sc = t->_cookie; - - iommu_dvmamem_free(t0, &sc->sc_is, segs, nsegs); -} - -int -sbus_dmamem_map(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dma_segment_t *segs, - int nsegs, size_t size, caddr_t *kvap, int flags) -{ - struct sbus_softc *sc = t->_cookie; - - return (iommu_dvmamem_map(t0, &sc->sc_is, segs, nsegs, size, - kvap, flags)); -} - -void -sbus_dmamem_unmap(bus_dma_tag_t t, bus_dma_tag_t t0, caddr_t kva, size_t size) -{ - struct sbus_softc *sc = t->_cookie; - - iommu_dvmamem_unmap(t0, &sc->sc_is, kva, size); -} diff --git a/sys/arch/sparc64/dev/schizo.c b/sys/arch/sparc64/dev/schizo.c index b338caa75e1..b810b820fb1 100644 --- a/sys/arch/sparc64/dev/schizo.c +++ b/sys/arch/sparc64/dev/schizo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: schizo.c,v 1.14 2003/06/03 01:41:42 jason Exp $ */ +/* $OpenBSD: schizo.c,v 1.15 2003/06/11 03:16:12 henric Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) @@ -87,20 +87,6 @@ paddr_t _schizo_bus_mmap(bus_space_tag_t, bus_space_tag_t, bus_addr_t, off_t, in int schizo_dmamap_create(bus_dma_tag_t, bus_dma_tag_t, bus_size_t, int, bus_size_t, bus_size_t, int, bus_dmamap_t *); -void schizo_dmamap_destroy(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t); -int schizo_dmamap_load(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, void *, - bus_size_t, struct proc *, int); -void schizo_dmamap_unload(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t); -int schizo_dmamap_load_raw(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, - bus_dma_segment_t *, int, bus_size_t, int); -void schizo_dmamap_sync(bus_dma_tag_t, bus_dma_tag_t, bus_dmamap_t, bus_addr_t, - bus_size_t, int); -int schizo_dmamem_alloc(bus_dma_tag_t, bus_dma_tag_t, bus_size_t, bus_size_t, - bus_size_t, bus_dma_segment_t *, int, int *, int); -void schizo_dmamem_free(bus_dma_tag_t, bus_dma_tag_t, bus_dma_segment_t *, int); -int schizo_dmamem_map(bus_dma_tag_t, bus_dma_tag_t, bus_dma_segment_t *, int, - size_t, caddr_t *, int); -void schizo_dmamem_unmap(bus_dma_tag_t, bus_dma_tag_t, caddr_t, size_t); int schizo_match(struct device *parent, void *match, void *aux) @@ -243,7 +229,7 @@ schizo_init_iommu(struct schizo_softc *sc, struct schizo_pbm *pbm) offsetof(struct schizo_pbm_regs, strbuf), sizeof(struct iommu_strbuf), &is->is_sb[0]->sb_sb)) { panic("schizo: unable to create streaming buffer handle"); - is->is_sb[0]->sb_flush = 0; + is->is_sb[0]->sb_flush = NULL; } #if 1 @@ -252,6 +238,7 @@ schizo_init_iommu(struct schizo_softc *sc, struct schizo_pbm *pbm) STRBUFREG(strbuf_ctl), bus_space_read_8(is->is_bustag, is->is_sb[0]->sb_sb, STRBUFREG(strbuf_ctl)) & ~STRBUF_EN); + is->is_sb[0]->sb_flush = NULL; #endif name = (char *)malloc(32, M_DEVBUF, M_NOWAIT); @@ -335,16 +322,16 @@ schizo_alloc_dma_tag(struct schizo_pbm *pbm) bzero(dt, sizeof(*dt)); dt->_cookie = pbm; dt->_parent = pdt; - dt->_dmamap_create = schizo_dmamap_create; - dt->_dmamap_destroy = schizo_dmamap_destroy; - dt->_dmamap_load = schizo_dmamap_load; - dt->_dmamap_load_raw = schizo_dmamap_load_raw; - dt->_dmamap_unload = schizo_dmamap_unload; - dt->_dmamap_sync = schizo_dmamap_sync; - dt->_dmamem_alloc = schizo_dmamem_alloc; - dt->_dmamem_free = schizo_dmamem_free; - dt->_dmamem_map = schizo_dmamem_map; - dt->_dmamem_unmap = schizo_dmamem_unmap; + dt->_dmamap_create = schizo_dmamap_create; + dt->_dmamap_destroy = iommu_dvmamap_destroy; + dt->_dmamap_load = iommu_dvmamap_load; + dt->_dmamap_load_raw = iommu_dvmamap_load_raw; + dt->_dmamap_unload = iommu_dvmamap_unload; + dt->_dmamap_sync = iommu_dvmamap_sync; + dt->_dmamem_alloc = iommu_dvmamem_alloc; + dt->_dmamem_free = iommu_dvmamem_free; + dt->_dmamem_map = iommu_dvmamem_map; + dt->_dmamem_unmap = iommu_dvmamem_unmap; return (dt); } @@ -370,106 +357,8 @@ schizo_dmamap_create(bus_dma_tag_t t, bus_dma_tag_t t0, bus_size_t size, { struct schizo_pbm *sp = t->_cookie; - return (iommu_dvmamap_create(t0, &sp->sp_is, &sp->sp_sb, size, - nsegments, maxsegsz, boundary, flags, dmamp)); -} - -void -schizo_dmamap_destroy(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map) -{ - iommu_dvmamap_destroy(t0, map); -} - -int -schizo_dmamap_load(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map, - void *buf, bus_size_t buflen, struct proc *p, int flags) -{ - struct schizo_pbm *pbm = t->_cookie; - - return (iommu_dvmamap_load(t0, &pbm->sp_is, map, buf, buflen, p, - flags)); -} - -void -schizo_dmamap_unload(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map) -{ - struct schizo_pbm *pbm = t->_cookie; - - iommu_dvmamap_unload(t0, &pbm->sp_is, map); -} - -int -schizo_dmamap_load_raw(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map, - bus_dma_segment_t *segs, int nsegs, bus_size_t size, int flags) -{ - struct schizo_pbm *pbm = t->_cookie; - - return (iommu_dvmamap_load_raw(t0, &pbm->sp_is, map, segs, nsegs, - flags, size)); -} - -void -schizo_dmamap_sync(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map, - bus_addr_t offset, bus_size_t len, int ops) -{ - struct schizo_pbm *pbm = t->_cookie; - - if (t->_parent == NULL) - panic("schizo_dmamap_sync: no parent"); - - for (t = t->_parent; t->_dmamap_sync == NULL; t = t->_parent) - if (t == NULL) - panic("schizo_dmamap_sync: can't find implementation"); - - - if (ops & (BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)) { - /* Flush the CPU then the IOMMU */ - (*t->_dmamap_sync)(t, t0, map, offset, len, ops); - iommu_dvmamap_sync(t0, &pbm->sp_is, map, offset, len, ops); - } - if (ops & (BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)) { - /* Flush the IOMMU then the CPU */ - iommu_dvmamap_sync(t0, &pbm->sp_is, map, offset, len, ops); - (*t->_dmamap_sync)(t, t0, map, offset, len, ops); - } -} - -int -schizo_dmamem_alloc(bus_dma_tag_t t, bus_dma_tag_t t0, bus_size_t size, - bus_size_t alignment, bus_size_t boundary, bus_dma_segment_t *segs, - int nsegs, int *rsegs, int flags) -{ - struct schizo_pbm *pbm = t->_cookie; - - return (iommu_dvmamem_alloc(t0, &pbm->sp_is, size, alignment, boundary, - segs, nsegs, rsegs, flags)); -} - -void -schizo_dmamem_free(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dma_segment_t *segs, - int nsegs) -{ - struct schizo_pbm *pbm = t->_cookie; - - iommu_dvmamem_free(t0, &pbm->sp_is, segs, nsegs); -} - -int -schizo_dmamem_map(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dma_segment_t *segs, - int nsegs, size_t size, caddr_t *kvap, int flags) -{ - struct schizo_pbm *pbm = t->_cookie; - - return (iommu_dvmamem_map(t0, &pbm->sp_is, segs, nsegs, size, - kvap, flags)); -} - -void -schizo_dmamem_unmap(bus_dma_tag_t t, bus_dma_tag_t t0, caddr_t kva, size_t size) -{ - struct schizo_pbm *pbm = t->_cookie; - - iommu_dvmamem_unmap(t0, &pbm->sp_is, kva, size); + return (iommu_dvmamap_create(t, t0, &sp->sp_sb, size, nsegments, + maxsegsz, boundary, flags, dmamp)); } int |