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