]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - sys/sparc64/include/bus_dma.h
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.git] / sys / sparc64 / include / bus_dma.h
1 /*-
2  * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to The NetBSD Foundation
6  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
7  * NASA Ames Research Center.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  */
30 /*
31  * Copyright (c) 1997-1999 Eduardo E. Horvath. All rights reserved.
32  * Copyright (c) 1996 Charles M. Hannum.  All rights reserved.
33  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
34  *
35  * Redistribution and use in source and binary forms, with or without
36  * modification, are permitted provided that the following conditions
37  * are met:
38  * 1. Redistributions of source code must retain the above copyright
39  *    notice, this list of conditions and the following disclaimer.
40  * 2. Redistributions in binary form must reproduce the above copyright
41  *    notice, this list of conditions and the following disclaimer in the
42  *    documentation and/or other materials provided with the distribution.
43  * 3. All advertising materials mentioning features or use of this software
44  *    must display the following acknowledgement:
45  *      This product includes software developed by Christopher G. Demetriou
46  *      for the NetBSD Project.
47  * 4. The name of the author may not be used to endorse or promote products
48  *    derived from this software without specific prior written permission
49  *
50  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
51  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
52  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
53  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
54  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
55  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
56  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
57  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
58  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
59  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
60  *
61  *      from: NetBSD: bus.h,v 1.58 2008/04/28 20:23:36 martin Exp
62  *      and
63  *      from: FreeBSD: src/sys/alpha/include/bus.h,v 1.9 2001/01/09
64  *
65  * $FreeBSD$
66  */
67
68 #ifndef _SPARC64_BUS_DMA_H
69 #define _SPARC64_BUS_DMA_H
70
71 #include <sys/bus_dma.h>
72
73 /* DMA support */
74
75 /*
76  * Method table for a bus_dma_tag.
77  */
78 struct bus_dma_methods {
79         int     (*dm_dmamap_create)(bus_dma_tag_t, int, bus_dmamap_t *);
80         int     (*dm_dmamap_destroy)(bus_dma_tag_t, bus_dmamap_t);
81         int     (*dm_dmamap_load)(bus_dma_tag_t, bus_dmamap_t, void *,
82             bus_size_t, bus_dmamap_callback_t *, void *, int);
83         int     (*dm_dmamap_load_mbuf)(bus_dma_tag_t, bus_dmamap_t,
84             struct mbuf *, bus_dmamap_callback2_t *, void *, int);
85         int     (*dm_dmamap_load_mbuf_sg)(bus_dma_tag_t, bus_dmamap_t,
86             struct mbuf *, bus_dma_segment_t *segs, int *nsegs, int);
87         int     (*dm_dmamap_load_uio)(bus_dma_tag_t, bus_dmamap_t, struct uio *,
88             bus_dmamap_callback2_t *, void *, int);
89         void    (*dm_dmamap_unload)(bus_dma_tag_t, bus_dmamap_t);
90         void    (*dm_dmamap_sync)(bus_dma_tag_t, bus_dmamap_t,
91             bus_dmasync_op_t);
92         int     (*dm_dmamem_alloc)(bus_dma_tag_t, void **, int, bus_dmamap_t *);
93         void    (*dm_dmamem_free)(bus_dma_tag_t, void *, bus_dmamap_t);
94 };
95
96 /*
97  * bus_dma_tag_t
98  *
99  * A machine-dependent opaque type describing the implementation of
100  * DMA for a given bus.
101  */
102 struct bus_dma_tag {
103         void            *dt_cookie;             /* cookie used in the guts */
104         bus_dma_tag_t   dt_parent;
105         bus_size_t      dt_alignment;
106         bus_size_t      dt_boundary;
107         bus_addr_t      dt_lowaddr;
108         bus_addr_t      dt_highaddr;
109         bus_dma_filter_t        *dt_filter;
110         void            *dt_filterarg;
111         bus_size_t      dt_maxsize;
112         int             dt_nsegments;
113         bus_size_t      dt_maxsegsz;
114         int             dt_flags;
115         int             dt_ref_count;
116         int             dt_map_count;
117         bus_dma_lock_t  *dt_lockfunc;
118         void *          *dt_lockfuncarg;
119         bus_dma_segment_t *dt_segments;
120
121         struct bus_dma_methods  *dt_mt;
122 };
123
124 #define bus_dmamap_create(t, f, p)                                      \
125         ((t)->dt_mt->dm_dmamap_create((t), (f), (p)))
126 #define bus_dmamap_destroy(t, p)                                        \
127         ((t)->dt_mt->dm_dmamap_destroy((t), (p)))
128 #define bus_dmamap_load(t, m, p, s, cb, cba, f)                         \
129         ((t)->dt_mt->dm_dmamap_load((t), (m), (p), (s), (cb), (cba), (f)))
130 #define bus_dmamap_load_mbuf(t, m, mb, cb, cba, f)                      \
131         ((t)->dt_mt->dm_dmamap_load_mbuf((t), (m), (mb), (cb), (cba), (f)))
132 #define bus_dmamap_load_mbuf_sg(t, m, mb, segs, nsegs, f)               \
133         ((t)->dt_mt->dm_dmamap_load_mbuf_sg((t), (m), (mb), (segs), (nsegs), (f)))
134 #define bus_dmamap_load_uio(t, m, ui, cb, cba, f)                       \
135         ((t)->dt_mt->dm_dmamap_load_uio((t), (m), (ui), (cb), (cba), (f)))
136 #define bus_dmamap_unload(t, p)                                         \
137         ((t)->dt_mt->dm_dmamap_unload((t), (p)))
138 #define bus_dmamap_sync(t, m, op)                                       \
139         ((t)->dt_mt->dm_dmamap_sync((t), (m), (op)))
140 #define bus_dmamem_alloc(t, v, f, m)                                    \
141         ((t)->dt_mt->dm_dmamem_alloc((t), (v), (f), (m)))
142 #define bus_dmamem_free(t, v, m)                                        \
143         ((t)->dt_mt->dm_dmamem_free((t), (v), (m)))
144
145 #endif /* !_SPARC64_BUS_DMA_H_ */