1143598Sscottl/*- 2143598Sscottl * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc. 3143598Sscottl * All rights reserved. 4143598Sscottl * 5143598Sscottl * This code is derived from software contributed to The NetBSD Foundation 6143598Sscottl * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 7143598Sscottl * NASA Ames Research Center. 8143598Sscottl * 9143598Sscottl * Redistribution and use in source and binary forms, with or without 10143598Sscottl * modification, are permitted provided that the following conditions 11143598Sscottl * are met: 12143598Sscottl * 1. Redistributions of source code must retain the above copyright 13143598Sscottl * notice, this list of conditions and the following disclaimer. 14143598Sscottl * 2. Redistributions in binary form must reproduce the above copyright 15143598Sscottl * notice, this list of conditions and the following disclaimer in the 16143598Sscottl * documentation and/or other materials provided with the distribution. 17143598Sscottl * 18143598Sscottl * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19143598Sscottl * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20143598Sscottl * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21143598Sscottl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22143598Sscottl * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23143598Sscottl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24143598Sscottl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25143598Sscottl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26143598Sscottl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27143598Sscottl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28143598Sscottl * POSSIBILITY OF SUCH DAMAGE. 29143598Sscottl */ 30143598Sscottl/* 31143598Sscottl * Copyright (c) 1997-1999 Eduardo E. Horvath. All rights reserved. 32143598Sscottl * Copyright (c) 1996 Charles M. Hannum. All rights reserved. 33143598Sscottl * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. 34143598Sscottl * 35143598Sscottl * Redistribution and use in source and binary forms, with or without 36143598Sscottl * modification, are permitted provided that the following conditions 37143598Sscottl * are met: 38143598Sscottl * 1. Redistributions of source code must retain the above copyright 39143598Sscottl * notice, this list of conditions and the following disclaimer. 40143598Sscottl * 2. Redistributions in binary form must reproduce the above copyright 41143598Sscottl * notice, this list of conditions and the following disclaimer in the 42143598Sscottl * documentation and/or other materials provided with the distribution. 43143598Sscottl * 3. All advertising materials mentioning features or use of this software 44143598Sscottl * must display the following acknowledgement: 45143598Sscottl * This product includes software developed by Christopher G. Demetriou 46143598Sscottl * for the NetBSD Project. 47143598Sscottl * 4. The name of the author may not be used to endorse or promote products 48143598Sscottl * derived from this software without specific prior written permission 49143598Sscottl * 50143598Sscottl * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 51143598Sscottl * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 52143598Sscottl * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 53143598Sscottl * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 54143598Sscottl * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 55143598Sscottl * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 56143598Sscottl * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 57143598Sscottl * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 58143598Sscottl * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 59143598Sscottl * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 60143598Sscottl * 61219567Smarius * from: NetBSD: bus.h,v 1.58 2008/04/28 20:23:36 martin Exp 62143598Sscottl * and 63143598Sscottl * from: FreeBSD: src/sys/alpha/include/bus.h,v 1.9 2001/01/09 64143598Sscottl * 65143598Sscottl * $FreeBSD$ 66143598Sscottl */ 67143598Sscottl 68143598Sscottl#ifndef _SPARC64_BUS_DMA_H 69143598Sscottl#define _SPARC64_BUS_DMA_H 70143598Sscottl 71143598Sscottl#include <sys/bus_dma.h> 72143598Sscottl 73143598Sscottl/* DMA support */ 74143598Sscottl 75143598Sscottl/* 76143598Sscottl * Method table for a bus_dma_tag. 77143598Sscottl */ 78143598Sscottlstruct bus_dma_methods { 79143598Sscottl int (*dm_dmamap_create)(bus_dma_tag_t, int, bus_dmamap_t *); 80143598Sscottl int (*dm_dmamap_destroy)(bus_dma_tag_t, bus_dmamap_t); 81251874Sscottl int (*dm_dmamap_load_phys)(bus_dma_tag_t dmat, bus_dmamap_t map, 82251874Sscottl vm_paddr_t buf, bus_size_t buflen, int flags, 83251874Sscottl bus_dma_segment_t *segs, int *segp); 84251874Sscottl int (*dm_dmamap_load_buffer)(bus_dma_tag_t dmat, bus_dmamap_t map, 85251874Sscottl void *buf, bus_size_t buflen, struct pmap *pmap, int flags, 86251874Sscottl bus_dma_segment_t *segs, int *segp); 87251874Sscottl void (*dm_dmamap_waitok)(bus_dma_tag_t dmat, bus_dmamap_t map, 88251874Sscottl struct memdesc *mem, bus_dmamap_callback_t *callback, 89251874Sscottl void *callback_arg); 90251874Sscottl bus_dma_segment_t *(*dm_dmamap_complete)(bus_dma_tag_t dmat, 91251874Sscottl bus_dmamap_t map, bus_dma_segment_t *segs, int nsegs, int error); 92143598Sscottl void (*dm_dmamap_unload)(bus_dma_tag_t, bus_dmamap_t); 93143598Sscottl void (*dm_dmamap_sync)(bus_dma_tag_t, bus_dmamap_t, 94143598Sscottl bus_dmasync_op_t); 95143598Sscottl int (*dm_dmamem_alloc)(bus_dma_tag_t, void **, int, bus_dmamap_t *); 96143598Sscottl void (*dm_dmamem_free)(bus_dma_tag_t, void *, bus_dmamap_t); 97143598Sscottl}; 98143598Sscottl 99143598Sscottl/* 100143598Sscottl * bus_dma_tag_t 101143598Sscottl * 102143598Sscottl * A machine-dependent opaque type describing the implementation of 103143598Sscottl * DMA for a given bus. 104143598Sscottl */ 105143598Sscottlstruct bus_dma_tag { 106143598Sscottl void *dt_cookie; /* cookie used in the guts */ 107143598Sscottl bus_dma_tag_t dt_parent; 108143598Sscottl bus_size_t dt_alignment; 109143598Sscottl bus_size_t dt_boundary; 110143598Sscottl bus_addr_t dt_lowaddr; 111143598Sscottl bus_addr_t dt_highaddr; 112143598Sscottl bus_dma_filter_t *dt_filter; 113143598Sscottl void *dt_filterarg; 114143598Sscottl bus_size_t dt_maxsize; 115143598Sscottl int dt_nsegments; 116143598Sscottl bus_size_t dt_maxsegsz; 117143598Sscottl int dt_flags; 118143598Sscottl int dt_ref_count; 119143598Sscottl int dt_map_count; 120143598Sscottl bus_dma_lock_t *dt_lockfunc; 121143598Sscottl void * *dt_lockfuncarg; 122143598Sscottl bus_dma_segment_t *dt_segments; 123143598Sscottl 124143598Sscottl struct bus_dma_methods *dt_mt; 125143598Sscottl}; 126143598Sscottl 127143598Sscottl#define bus_dmamap_create(t, f, p) \ 128143598Sscottl ((t)->dt_mt->dm_dmamap_create((t), (f), (p))) 129143598Sscottl#define bus_dmamap_destroy(t, p) \ 130143598Sscottl ((t)->dt_mt->dm_dmamap_destroy((t), (p))) 131251874Sscottl#define _bus_dmamap_load_phys(t, m, b, l, f, s, sp) \ 132251874Sscottl ((t)->dt_mt->dm_dmamap_load_phys((t), (m), (b), (l), \ 133251874Sscottl (f), (s), (sp))) 134251874Sscottl#define _bus_dmamap_load_buffer(t, m, b, l, p, f, s, sp) \ 135251874Sscottl ((t)->dt_mt->dm_dmamap_load_buffer((t), (m), (b), (l), (p), \ 136251874Sscottl (f), (s), (sp))) 137251874Sscottl#define _bus_dmamap_waitok(t, m, mem, c, ca) \ 138251874Sscottl ((t)->dt_mt->dm_dmamap_waitok((t), (m), (mem), (c), (ca))) 139251874Sscottl#define _bus_dmamap_complete(t, m, s, n, e) \ 140251874Sscottl ((t)->dt_mt->dm_dmamap_complete((t), (m), (s), (n), (e))) 141143598Sscottl#define bus_dmamap_unload(t, p) \ 142143598Sscottl ((t)->dt_mt->dm_dmamap_unload((t), (p))) 143143598Sscottl#define bus_dmamap_sync(t, m, op) \ 144143598Sscottl ((t)->dt_mt->dm_dmamap_sync((t), (m), (op))) 145143598Sscottl#define bus_dmamem_alloc(t, v, f, m) \ 146143598Sscottl ((t)->dt_mt->dm_dmamem_alloc((t), (v), (f), (m))) 147143598Sscottl#define bus_dmamem_free(t, v, m) \ 148143598Sscottl ((t)->dt_mt->dm_dmamem_free((t), (v), (m))) 149143598Sscottl 150143598Sscottl#endif /* !_SPARC64_BUS_DMA_H_ */ 151