]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/sparc64/include/bus_dma.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.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_phys)(bus_dma_tag_t dmat, bus_dmamap_t map,
82             vm_paddr_t buf, bus_size_t buflen, int flags,
83             bus_dma_segment_t *segs, int *segp);
84         int     (*dm_dmamap_load_buffer)(bus_dma_tag_t dmat, bus_dmamap_t map,
85             void *buf, bus_size_t buflen, struct pmap *pmap, int flags,
86             bus_dma_segment_t *segs, int *segp);
87         void    (*dm_dmamap_waitok)(bus_dma_tag_t dmat, bus_dmamap_t map,
88             struct memdesc *mem, bus_dmamap_callback_t *callback,
89             void *callback_arg);
90         bus_dma_segment_t *(*dm_dmamap_complete)(bus_dma_tag_t dmat,
91             bus_dmamap_t map, bus_dma_segment_t *segs, int nsegs, int error);
92         void    (*dm_dmamap_unload)(bus_dma_tag_t, bus_dmamap_t);
93         void    (*dm_dmamap_sync)(bus_dma_tag_t, bus_dmamap_t,
94             bus_dmasync_op_t);
95         int     (*dm_dmamem_alloc)(bus_dma_tag_t, void **, int, bus_dmamap_t *);
96         void    (*dm_dmamem_free)(bus_dma_tag_t, void *, bus_dmamap_t);
97 };
98
99 /*
100  * bus_dma_tag_t
101  *
102  * A machine-dependent opaque type describing the implementation of
103  * DMA for a given bus.
104  */
105 struct bus_dma_tag {
106         void            *dt_cookie;             /* cookie used in the guts */
107         bus_dma_tag_t   dt_parent;
108         bus_size_t      dt_alignment;
109         bus_size_t      dt_boundary;
110         bus_addr_t      dt_lowaddr;
111         bus_addr_t      dt_highaddr;
112         bus_dma_filter_t        *dt_filter;
113         void            *dt_filterarg;
114         bus_size_t      dt_maxsize;
115         int             dt_nsegments;
116         bus_size_t      dt_maxsegsz;
117         int             dt_flags;
118         int             dt_ref_count;
119         int             dt_map_count;
120         bus_dma_lock_t  *dt_lockfunc;
121         void *          *dt_lockfuncarg;
122         bus_dma_segment_t *dt_segments;
123
124         struct bus_dma_methods  *dt_mt;
125 };
126
127 #define bus_dmamap_create(t, f, p)                                      \
128         ((t)->dt_mt->dm_dmamap_create((t), (f), (p)))
129 #define bus_dmamap_destroy(t, p)                                        \
130         ((t)->dt_mt->dm_dmamap_destroy((t), (p)))
131 #define _bus_dmamap_load_phys(t, m, b, l, f, s, sp)                     \
132         ((t)->dt_mt->dm_dmamap_load_phys((t), (m), (b), (l),            \
133             (f), (s), (sp)))
134 #define _bus_dmamap_load_buffer(t, m, b, l, p, f, s, sp)                \
135         ((t)->dt_mt->dm_dmamap_load_buffer((t), (m), (b), (l), (p),     \
136             (f), (s), (sp)))
137 #define _bus_dmamap_waitok(t, m, mem, c, ca)                            \
138         ((t)->dt_mt->dm_dmamap_waitok((t), (m), (mem), (c), (ca)))
139 #define _bus_dmamap_complete(t, m, s, n, e)                             \
140         ((t)->dt_mt->dm_dmamap_complete((t), (m), (s), (n), (e)))
141 #define bus_dmamap_unload(t, p)                                         \
142         ((t)->dt_mt->dm_dmamap_unload((t), (p)))
143 #define bus_dmamap_sync(t, m, op)                                       \
144         ((t)->dt_mt->dm_dmamap_sync((t), (m), (op)))
145 #define bus_dmamem_alloc(t, v, f, m)                                    \
146         ((t)->dt_mt->dm_dmamem_alloc((t), (v), (f), (m)))
147 #define bus_dmamem_free(t, v, m)                                        \
148         ((t)->dt_mt->dm_dmamem_free((t), (v), (m)))
149
150 #endif /* !_SPARC64_BUS_DMA_H_ */