xref: /netbsd-src/sys/arch/mips/include/bus_dma_funcs.h (revision 4ada7c5071c8e87a40147f062f3da288321fc61f)
1 /* $NetBSD: bus_dma_funcs.h,v 1.1 2011/07/01 17:28:55 dyoung Exp $ */
2 
3 /*-
4  * Copyright (c) 1997, 1998, 2000, 2001 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9  * NASA Ames Research Center.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 /*
34  * Copyright (c) 1996 Carnegie-Mellon University.
35  * All rights reserved.
36  *
37  * Author: Chris G. Demetriou
38  *
39  * Permission to use, copy, modify and distribute this software and
40  * its documentation is hereby granted, provided that both the copyright
41  * notice and this permission notice appear in all copies of the
42  * software, derivative works or modified versions, and any portions
43  * thereof, and that both notices appear in supporting documentation.
44  *
45  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
46  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
47  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
48  *
49  * Carnegie Mellon requests users of this software to return to
50  *
51  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
52  *  School of Computer Science
53  *  Carnegie Mellon University
54  *  Pittsburgh PA 15213-3890
55  *
56  * any improvements or extensions that they make and grant Carnegie the
57  * rights to redistribute these changes.
58  */
59 
60 #ifndef _MIPS_BUS_DMA_FUNCS_H_
61 #define	_MIPS_BUS_DMA_FUNCS_H_
62 
63 #ifdef _KERNEL
64 /*
65  * Bus DMA methods.
66  */
67 
68 /* Forwards needed by prototypes below. */
69 struct mbuf;
70 struct uio;
71 
72 #define	bus_dmamap_create(t, s, n, m, b, f, p)			\
73 	(*(t)->_dmamap_ops.dmamap_create)((t), (s), (n), (m), (b), (f), (p))
74 #define	bus_dmamap_destroy(t, p)				\
75 	(*(t)->_dmamap_ops.dmamap_destroy)((t), (p))
76 #define	bus_dmamap_load(t, m, b, s, p, f)			\
77 	(*(t)->_dmamap_ops.dmamap_load)((t), (m), (b), (s), (p), (f))
78 #define	bus_dmamap_load_mbuf(t, m, b, f)			\
79 	(*(t)->_dmamap_ops.dmamap_load_mbuf)((t), (m), (b), (f))
80 #define	bus_dmamap_load_uio(t, m, u, f)				\
81 	(*(t)->_dmamap_ops.dmamap_load_uio)((t), (m), (u), (f))
82 #define	bus_dmamap_load_raw(t, m, sg, n, s, f)			\
83 	(*(t)->_dmamap_ops.dmamap_load_raw)((t), (m), (sg), (n), (s), (f))
84 #define	bus_dmamap_unload(t, p)					\
85 	(*(t)->_dmamap_ops.dmamap_unload)((t), (p))
86 #define	bus_dmamap_sync(t, p, o, l, ops)			\
87 	(*(t)->_dmamap_ops.dmamap_sync)((t), (p), (o), (l), (ops))
88 
89 #define	bus_dmamem_alloc(t, s, a, b, sg, n, r, f)		\
90 	(*(t)->_dmamem_ops.dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f))
91 #define	bus_dmamem_free(t, sg, n)				\
92 	(*(t)->_dmamem_ops.dmamem_free)((t), (sg), (n))
93 #define	bus_dmamem_map(t, sg, n, s, k, f)			\
94 	(*(t)->_dmamem_ops.dmamem_map)((t), (sg), (n), (s), (k), (f))
95 #define	bus_dmamem_unmap(t, k, s)				\
96 	(*(t)->_dmamem_ops.dmamem_unmap)((t), (k), (s))
97 #define	bus_dmamem_mmap(t, sg, n, o, p, f)			\
98 	(*(t)->_dmamem_ops.dmamem_mmap)((t), (sg), (n), (o), (p), (f))
99 
100 #define	bus_dmatag_subregion(t, mna, mxa, nt, f)			\
101 	(*(t)->_dmatag_ops.dmatag_subregion)((t), (mna), (mxa), (nt), (f))
102 #define	bus_dmatag_destroy(t)					\
103 	(*(t)->_dmatag_ops.dmatag_destroy)((t))
104 
105 #ifdef _MIPS_BUS_DMA_PRIVATE
106 
107 int	_bus_dmamap_create(bus_dma_tag_t, bus_size_t, int, bus_size_t,
108 	    bus_size_t, int, bus_dmamap_t *);
109 void	_bus_dmamap_destroy(bus_dma_tag_t, bus_dmamap_t);
110 
111 int	_bus_dmamap_load(bus_dma_tag_t, bus_dmamap_t, void *, bus_size_t,
112 	    struct proc *, int);
113 int	_bus_dmamap_load_mbuf(bus_dma_tag_t, bus_dmamap_t, struct mbuf *, int);
114 int	_bus_dmamap_load_uio(bus_dma_tag_t, bus_dmamap_t, struct uio *, int);
115 int	_bus_dmamap_load_raw(bus_dma_tag_t, bus_dmamap_t, bus_dma_segment_t *,
116 	    int, bus_size_t, int);
117 
118 void	_bus_dmamap_unload(bus_dma_tag_t, bus_dmamap_t);
119 void	_bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_addr_t, bus_size_t,
120 	    int);
121 
122 int	_bus_dmamem_alloc(bus_dma_tag_t tag, bus_size_t size,
123 	    bus_size_t alignment, bus_size_t boundary,
124 	    bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags);
125 int	_bus_dmamem_alloc_range(bus_dma_tag_t tag, bus_size_t size,
126 	    bus_size_t alignment, bus_size_t boundary,
127 	    bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags,
128 	    paddr_t low, paddr_t high);
129 void	_bus_dmamem_free(bus_dma_tag_t tag, bus_dma_segment_t *segs,
130 	    int nsegs);
131 int	_bus_dmamem_map(bus_dma_tag_t tag, bus_dma_segment_t *segs,
132 	    int nsegs, size_t size, void **kvap, int flags);
133 void	_bus_dmamem_unmap(bus_dma_tag_t tag, void *kva,
134 	    size_t size);
135 paddr_t	_bus_dmamem_mmap(bus_dma_tag_t tag, bus_dma_segment_t *segs,
136 	    int nsegs, off_t off, int prot, int flags);
137 
138 int	_bus_dmatag_subregion(bus_dma_tag_t, bus_addr_t, bus_addr_t,
139 	    bus_dma_tag_t *, int);
140 void	_bus_dmatag_destroy(bus_dma_tag_t);
141 
142 #endif /* _MIPS_BUS_DMA_PRIVATE */
143 
144 #endif /* _KERNEL */
145 
146 #endif /* _MIPS_BUS_DMA_FUNCS_H_ */
147