xref: /openbsd-src/sys/arch/hppa/include/bus.h (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1 /*	$OpenBSD: bus.h,v 1.31 2011/11/14 14:29:53 deraadt Exp $	*/
2 
3 /*
4  * Copyright (c) 1998-2004 Michael Shalayeff
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
20  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
25  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26  * THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _MACHINE_BUS_H_
30 #define _MACHINE_BUS_H_
31 
32 #include <machine/cpufunc.h>
33 
34 /* addresses in bus space */
35 typedef u_long bus_addr_t;
36 typedef u_long bus_size_t;
37 
38 /* access methods for bus space */
39 typedef u_long bus_space_handle_t;
40 
41 struct hppa_bus_space_tag {
42 	void *hbt_cookie;
43 
44 	int  (*hbt_map)(void *v, bus_addr_t addr, bus_size_t size,
45 		    int flags, bus_space_handle_t *bshp);
46 	void (*hbt_unmap)(void *v, bus_space_handle_t bsh, bus_size_t size);
47 	int  (*hbt_subregion)(void *v, bus_space_handle_t bsh,
48 		    bus_size_t offset, bus_size_t size,
49 		    bus_space_handle_t *nbshp);
50 	int  (*hbt_alloc)(void *v, bus_addr_t rstart, bus_addr_t rend,
51 		    bus_size_t size, bus_size_t align, bus_size_t boundary,
52 		    int flags, bus_addr_t *addrp, bus_space_handle_t *bshp);
53 	void (*hbt_free)(void *, bus_space_handle_t, bus_size_t);
54 	void (*hbt_barrier)(void *v, bus_space_handle_t h,
55 		    bus_size_t o, bus_size_t l, int op);
56 	void *(*hbt_vaddr)(void *v, bus_space_handle_t h);
57 
58 	u_int8_t  (*hbt_r1)(void *, bus_space_handle_t, bus_size_t);
59 	u_int16_t (*hbt_r2)(void *, bus_space_handle_t, bus_size_t);
60 	u_int32_t (*hbt_r4)(void *, bus_space_handle_t, bus_size_t);
61 	u_int64_t (*hbt_r8)(void *, bus_space_handle_t, bus_size_t);
62 
63 	void (*hbt_w1)(void *, bus_space_handle_t, bus_size_t, u_int8_t);
64 	void (*hbt_w2)(void *, bus_space_handle_t, bus_size_t, u_int16_t);
65 	void (*hbt_w4)(void *, bus_space_handle_t, bus_size_t, u_int32_t);
66 	void (*hbt_w8)(void *, bus_space_handle_t, bus_size_t, u_int64_t);
67 
68 	void (*hbt_rm_1)(void *v, bus_space_handle_t h,
69 	      bus_size_t o, u_int8_t *a, bus_size_t c);
70 	void (*hbt_rm_2)(void *v, bus_space_handle_t h,
71 	      bus_size_t o, u_int16_t *a, bus_size_t c);
72 	void (*hbt_rm_4)(void *v, bus_space_handle_t h,
73 	      bus_size_t o, u_int32_t *a, bus_size_t c);
74 	void (*hbt_rm_8)(void *v, bus_space_handle_t h,
75 	      bus_size_t o, u_int64_t *a, bus_size_t c);
76 
77 	void (*hbt_wm_1)(void *v, bus_space_handle_t h, bus_size_t o,
78 	      const u_int8_t *a, bus_size_t c);
79 	void (*hbt_wm_2)(void *v, bus_space_handle_t h, bus_size_t o,
80 	      const u_int16_t *a, bus_size_t c);
81 	void (*hbt_wm_4)(void *v, bus_space_handle_t h, bus_size_t o,
82 	      const u_int32_t *a, bus_size_t c);
83 	void (*hbt_wm_8)(void *v, bus_space_handle_t h, bus_size_t o,
84 	      const u_int64_t *a, bus_size_t c);
85 
86 	void (*hbt_sm_1)(void *v, bus_space_handle_t h, bus_size_t o,
87 	      u_int8_t  vv, bus_size_t c);
88 	void (*hbt_sm_2)(void *v, bus_space_handle_t h, bus_size_t o,
89 	      u_int16_t vv, bus_size_t c);
90 	void (*hbt_sm_4)(void *v, bus_space_handle_t h, bus_size_t o,
91 	      u_int32_t vv, bus_size_t c);
92 	void (*hbt_sm_8)(void *v, bus_space_handle_t h, bus_size_t o,
93 	      u_int64_t vv, bus_size_t c);
94 
95 	void (*hbt_rrm_2)(void *v, bus_space_handle_t h,
96 	       bus_size_t o, u_int8_t *a, bus_size_t c);
97 	void (*hbt_rrm_4)(void *v, bus_space_handle_t h,
98 	       bus_size_t o, u_int8_t *a, bus_size_t c);
99 	void (*hbt_rrm_8)(void *v, bus_space_handle_t h,
100 	       bus_size_t o, u_int8_t *a, bus_size_t c);
101 
102 	void (*hbt_wrm_2)(void *v, bus_space_handle_t h,
103 	       bus_size_t o, const u_int8_t *a, bus_size_t c);
104 	void (*hbt_wrm_4)(void *v, bus_space_handle_t h,
105 	       bus_size_t o, const u_int8_t *a, bus_size_t c);
106 	void (*hbt_wrm_8)(void *v, bus_space_handle_t h,
107 	       bus_size_t o, const u_int8_t *a, bus_size_t c);
108 
109 	void (*hbt_rr_1)(void *v, bus_space_handle_t h,
110 	      bus_size_t o, u_int8_t *a, bus_size_t c);
111 	void (*hbt_rr_2)(void *v, bus_space_handle_t h,
112 	      bus_size_t o, u_int16_t *a, bus_size_t c);
113 	void (*hbt_rr_4)(void *v, bus_space_handle_t h,
114 	      bus_size_t o, u_int32_t *a, bus_size_t c);
115 	void (*hbt_rr_8)(void *v, bus_space_handle_t h,
116 	      bus_size_t o, u_int64_t *a, bus_size_t c);
117 
118 	void (*hbt_wr_1)(void *v, bus_space_handle_t h,
119 	      bus_size_t o, const u_int8_t *a, bus_size_t c);
120 	void (*hbt_wr_2)(void *v, bus_space_handle_t h,
121 	      bus_size_t o, const u_int16_t *a, bus_size_t c);
122 	void (*hbt_wr_4)(void *v, bus_space_handle_t h,
123 	      bus_size_t o, const u_int32_t *a, bus_size_t c);
124 	void (*hbt_wr_8)(void *v, bus_space_handle_t h,
125 	      bus_size_t o, const u_int64_t *a, bus_size_t c);
126 
127 	void (*hbt_rrr_2)(void *v, bus_space_handle_t h,
128 	       bus_size_t o, u_int8_t *a, bus_size_t c);
129 	void (*hbt_rrr_4)(void *v, bus_space_handle_t h,
130 	       bus_size_t o, u_int8_t *a, bus_size_t c);
131 	void (*hbt_rrr_8)(void *v, bus_space_handle_t h,
132 	       bus_size_t o, u_int8_t *a, bus_size_t c);
133 
134 	void (*hbt_wrr_2)(void *v, bus_space_handle_t h,
135 	       bus_size_t o, const u_int8_t *a, bus_size_t c);
136 	void (*hbt_wrr_4)(void *v, bus_space_handle_t h,
137 	       bus_size_t o, const u_int8_t *a, bus_size_t c);
138 	void (*hbt_wrr_8)(void *v, bus_space_handle_t h,
139 	       bus_size_t o, const u_int8_t *a, bus_size_t c);
140 
141 	void (*hbt_sr_1)(void *v, bus_space_handle_t h,
142 	       bus_size_t o, u_int8_t vv, bus_size_t c);
143 	void (*hbt_sr_2)(void *v, bus_space_handle_t h,
144 	       bus_size_t o, u_int16_t vv, bus_size_t c);
145 	void (*hbt_sr_4)(void *v, bus_space_handle_t h,
146 	       bus_size_t o, u_int32_t vv, bus_size_t c);
147 	void (*hbt_sr_8)(void *v, bus_space_handle_t h,
148 	       bus_size_t o, u_int64_t vv, bus_size_t c);
149 
150 	void (*hbt_cp_1)(void *v, bus_space_handle_t h1, bus_size_t o1,
151 	      bus_space_handle_t h2, bus_size_t o2, bus_size_t c);
152 	void (*hbt_cp_2)(void *v, bus_space_handle_t h1, bus_size_t o1,
153 	      bus_space_handle_t h2, bus_size_t o2, bus_size_t c);
154 	void (*hbt_cp_4)(void *v, bus_space_handle_t h1, bus_size_t o1,
155 	      bus_space_handle_t h2, bus_size_t o2, bus_size_t c);
156 	void (*hbt_cp_8)(void *v, bus_space_handle_t h1, bus_size_t o1,
157 	      bus_space_handle_t h2, bus_size_t o2, bus_size_t c);
158 };
159 typedef const struct hppa_bus_space_tag *bus_space_tag_t;
160 extern const struct hppa_bus_space_tag hppa_bustag;
161 
162 /* flags for bus space map functions */
163 #define	BUS_SPACE_MAP_CACHEABLE		0x0001
164 #define	BUS_SPACE_MAP_LINEAR		0x0002
165 #define	BUS_SPACE_MAP_READONLY		0x0004
166 #define	BUS_SPACE_MAP_PREFETCHABLE	0x0008
167 
168 /* bus access routines */
169 
170 #define	bus_space_map(t,a,c,ca,hp) \
171 	(((t)->hbt_map)((t)->hbt_cookie,(a),(c),(ca),(hp)))
172 #define	bus_space_unmap(t,h,c) \
173 	(((t)->hbt_unmap)((t)->hbt_cookie,(h),(c)))
174 #define	bus_space_subregion(t,h,o,c,hp) \
175 	(((t)->hbt_subregion)((t)->hbt_cookie,(h),(o),(c),(hp)))
176 #define	bus_space_alloc(t,b,e,c,al,bn,ca,ap,hp) \
177 	(((t)->hbt_alloc)((t)->hbt_cookie,(b),(e),(c),(al),(bn),(ca),(ap),(hp)))
178 #define	bus_space_free(t,h,c) \
179 	(((t)->hbt_free)((t)->hbt_cookie,(h),(c)))
180 
181 #define	bus_space_read_1(t,h,o) (((t)->hbt_r1)((t)->hbt_cookie,(h),(o)))
182 #define	bus_space_read_2(t,h,o) (((t)->hbt_r2)((t)->hbt_cookie,(h),(o)))
183 #define	bus_space_read_4(t,h,o) (((t)->hbt_r4)((t)->hbt_cookie,(h),(o)))
184 #define	bus_space_read_8(t,h,o) (((t)->hbt_r8)((t)->hbt_cookie,(h),(o)))
185 
186 #define	bus_space_write_1(t,h,o,v) (((t)->hbt_w1)((t)->hbt_cookie,(h),(o),(v)))
187 #define	bus_space_write_2(t,h,o,v) (((t)->hbt_w2)((t)->hbt_cookie,(h),(o),(v)))
188 #define	bus_space_write_4(t,h,o,v) (((t)->hbt_w4)((t)->hbt_cookie,(h),(o),(v)))
189 #define	bus_space_write_8(t,h,o,v) (((t)->hbt_w8)((t)->hbt_cookie,(h),(o),(v)))
190 
191 #define	bus_space_read_multi_1(t,h,o,a,c) \
192 	(((t)->hbt_rm_1)((t)->hbt_cookie, (h), (o), (a), (c)))
193 #define	bus_space_read_multi_2(t,h,o,a,c) \
194 	(((t)->hbt_rm_2)((t)->hbt_cookie, (h), (o), (a), (c)))
195 #define	bus_space_read_multi_4(t,h,o,a,c) \
196 	(((t)->hbt_rm_4)((t)->hbt_cookie, (h), (o), (a), (c)))
197 #define	bus_space_read_multi_8(t,h,o,a,c) \
198 	(((t)->hbt_rm_8)((t)->hbt_cookie, (h), (o), (a), (c)))
199 
200 #define	bus_space_write_multi_1(t,h,o,a,c) \
201 	(((t)->hbt_wm_1)((t)->hbt_cookie, (h), (o), (a), (c)))
202 #define	bus_space_write_multi_2(t,h,o,a,c) \
203 	(((t)->hbt_wm_2)((t)->hbt_cookie, (h), (o), (a), (c)))
204 #define	bus_space_write_multi_4(t,h,o,a,c) \
205 	(((t)->hbt_wm_4)((t)->hbt_cookie, (h), (o), (a), (c)))
206 #define	bus_space_write_multi_8(t,h,o,a,c) \
207 	(((t)->hbt_wm_8)((t)->hbt_cookie, (h), (o), (a), (c)))
208 
209 #define	bus_space_set_multi_1(t,h,o,v,c) \
210 	(((t)->hbt_sm_1)((t)->hbt_cookie, (h), (o), (v), (c)))
211 #define	bus_space_set_multi_2(t,h,o,v,c) \
212 	(((t)->hbt_sm_2)((t)->hbt_cookie, (h), (o), (v), (c)))
213 #define	bus_space_set_multi_4(t,h,o,v,c) \
214 	(((t)->hbt_sm_4)((t)->hbt_cookie, (h), (o), (v), (c)))
215 #define	bus_space_set_multi_8(t,h,o,v,c) \
216 	(((t)->hbt_sm_8)((t)->hbt_cookie, (h), (o), (v), (c)))
217 
218 #define	bus_space_read_raw_multi_2(t, h, o, a, c) \
219 	(((t)->hbt_rrm_2)((t)->hbt_cookie, (h), (o), (a), (c)))
220 #define	bus_space_read_raw_multi_4(t, h, o, a, c) \
221 	(((t)->hbt_rrm_4)((t)->hbt_cookie, (h), (o), (a), (c)))
222 #define	bus_space_read_raw_multi_8(t, h, o, a, c) \
223 	(((t)->hbt_rrm_8)((t)->hbt_cookie, (h), (o), (a), (c)))
224 
225 #define	bus_space_write_raw_multi_2(t, h, o, a, c) \
226 	(((t)->hbt_wrm_2)((t)->hbt_cookie, (h), (o), (a), (c)))
227 #define	bus_space_write_raw_multi_4(t, h, o, a, c) \
228 	(((t)->hbt_wrm_4)((t)->hbt_cookie, (h), (o), (a), (c)))
229 #define	bus_space_write_raw_multi_8(t, h, o, a, c) \
230 	(((t)->hbt_wrm_8)((t)->hbt_cookie, (h), (o), (a), (c)))
231 
232 #define	bus_space_read_region_1(t, h, o, a, c) \
233 	(((t)->hbt_rr_1)((t)->hbt_cookie, (h), (o), (a), (c)))
234 #define	bus_space_read_region_2(t, h, o, a, c) \
235 	(((t)->hbt_rr_2)((t)->hbt_cookie, (h), (o), (a), (c)))
236 #define	bus_space_read_region_4(t, h, o, a, c) \
237 	(((t)->hbt_rr_4)((t)->hbt_cookie, (h), (o), (a), (c)))
238 #define	bus_space_read_region_8(t, h, o, a, c) \
239 	(((t)->hbt_rr_8)((t)->hbt_cookie, (h), (o), (a), (c)))
240 
241 #define	bus_space_write_region_1(t, h, o, a, c) \
242 	(((t)->hbt_wr_1)((t)->hbt_cookie, (h), (o), (a), (c)))
243 #define	bus_space_write_region_2(t, h, o, a, c) \
244 	(((t)->hbt_wr_2)((t)->hbt_cookie, (h), (o), (a), (c)))
245 #define	bus_space_write_region_4(t, h, o, a, c) \
246 	(((t)->hbt_wr_4)((t)->hbt_cookie, (h), (o), (a), (c)))
247 #define	bus_space_write_region_8(t, h, o, a, c) \
248 	(((t)->hbt_wr_8)((t)->hbt_cookie, (h), (o), (a), (c)))
249 
250 #define	bus_space_read_raw_region_2(t, h, o, a, c) \
251 	(((t)->hbt_rrr_2)((t)->hbt_cookie, (h), (o), (a), (c)))
252 #define	bus_space_read_raw_region_4(t, h, o, a, c) \
253 	(((t)->hbt_rrr_4)((t)->hbt_cookie, (h), (o), (a), (c)))
254 #define	bus_space_read_raw_region_8(t, h, o, a, c) \
255 	(((t)->hbt_rrr_8)((t)->hbt_cookie, (h), (o), (a), (c)))
256 
257 #define	bus_space_write_raw_region_2(t, h, o, a, c) \
258 	(((t)->hbt_wrr_2)((t)->hbt_cookie, (h), (o), (a), (c)))
259 #define	bus_space_write_raw_region_4(t, h, o, a, c) \
260 	(((t)->hbt_wrr_4)((t)->hbt_cookie, (h), (o), (a), (c)))
261 #define	bus_space_write_raw_region_8(t, h, o, a, c) \
262 	(((t)->hbt_wrr_8)((t)->hbt_cookie, (h), (o), (a), (c)))
263 
264 #define	bus_space_set_region_1(t, h, o, v, c) \
265 	(((t)->hbt_sr_1)((t)->hbt_cookie, (h), (o), (v), (c)))
266 #define	bus_space_set_region_2(t, h, o, v, c) \
267 	(((t)->hbt_sr_2)((t)->hbt_cookie, (h), (o), (v), (c)))
268 #define	bus_space_set_region_4(t, h, o, v, c) \
269 	(((t)->hbt_sr_4)((t)->hbt_cookie, (h), (o), (v), (c)))
270 #define	bus_space_set_region_8(t, h, o, v, c) \
271 	(((t)->hbt_sr_8)((t)->hbt_cookie, (h), (o), (v), (c)))
272 
273 #define	bus_space_copy_1(t, h1, o1, h2, o2, c) \
274 	(((t)->hbt_cp_1)((t)->hbt_cookie, (h1), (o1), (h2), (o2), (c)))
275 #define	bus_space_copy_2(t, h1, o1, h2, o2, c) \
276 	(((t)->hbt_cp_2)((t)->hbt_cookie, (h1), (o1), (h2), (o2), (c)))
277 #define	bus_space_copy_4(t, h1, o1, h2, o2, c) \
278 	(((t)->hbt_cp_4)((t)->hbt_cookie, (h1), (o1), (h2), (o2), (c)))
279 #define	bus_space_copy_8(t, h1, o1, h2, o2, c) \
280 	(((t)->hbt_cp_8)((t)->hbt_cookie, (h1), (o1), (h2), (o2), (c)))
281 
282 #define	BUS_SPACE_BARRIER_READ	0x01
283 #define	BUS_SPACE_BARRIER_WRITE	0x02
284 
285 #define	bus_space_barrier(t,h,o,l,op) \
286 	((t)->hbt_barrier((t)->hbt_cookie, (h), (o), (l), (op)))
287 #define	bus_space_vaddr(t,h) \
288 	((t)->hbt_vaddr((t)->hbt_cookie, (h)))
289 
290 #define	BUS_DMA_WAITOK		0x0000	/* safe to sleep (pseudo-flag) */
291 #define	BUS_DMA_NOWAIT		0x0001	/* not safe to sleep */
292 #define	BUS_DMA_ALLOCNOW	0x0002	/* perform resource allocation now */
293 #define	BUS_DMA_COHERENT	0x0004	/* hint: map memory DMA coherent */
294 #define	BUS_DMA_BUS1		0x0020	/* placeholders for bus functions... */
295 #define	BUS_DMA_BUS2		0x0040
296 #define	BUS_DMA_BUS3		0x0080
297 #define	BUS_DMA_BUS4		0x0100
298 #define	BUS_DMA_STREAMING	0x0200	/* hint: sequential, unidirectional */
299 #define	BUS_DMA_READ		0x0400	/* mapping is device -> memory only */
300 #define	BUS_DMA_WRITE		0x0800	/* mapping is memory -> device only */
301 #define	BUS_DMA_ZERO		0x1000	/* zero memory in dmamem_alloc */
302 
303 /* Forwards needed by prototypes below. */
304 struct mbuf;
305 struct proc;
306 struct uio;
307 
308 /* Operations performed by bus_dmamap_sync().  */
309 #define BUS_DMASYNC_POSTREAD	0x01
310 #define BUS_DMASYNC_POSTWRITE	0x02
311 #define BUS_DMASYNC_PREREAD	0x04
312 #define BUS_DMASYNC_PREWRITE	0x08
313 
314 typedef const struct hppa_bus_dma_tag	*bus_dma_tag_t;
315 typedef struct hppa_bus_dmamap	*bus_dmamap_t;
316 
317 /*
318  *	bus_dma_segment_t
319  *
320  *	Describes a single contiguous DMA transaction.  Values
321  *	are suitable for programming into DMA registers.
322  */
323 struct hppa_bus_dma_segment {
324 	vaddr_t		_ds_va;		/* needed for syncing */
325 
326 	bus_addr_t	ds_addr;	/* DMA address */
327 	bus_size_t	ds_len;		/* length of transfer */
328 };
329 typedef struct hppa_bus_dma_segment	bus_dma_segment_t;
330 
331 /*
332  *	bus_dma_tag_t
333  *
334  *	A machine-dependent opaque type describing the implementation of
335  *	DMA for a given bus.
336  */
337 
338 struct hppa_bus_dma_tag {
339 	void	*_cookie;		/* cookie used in the guts */
340 
341 	/*
342 	 * DMA mapping methods.
343 	 */
344 	int	(*_dmamap_create)(void *, bus_size_t, int,
345 		    bus_size_t, bus_size_t, int, bus_dmamap_t *);
346 	void	(*_dmamap_destroy)(void *, bus_dmamap_t);
347 	int	(*_dmamap_load)(void *, bus_dmamap_t, void *,
348 		    bus_size_t, struct proc *, int);
349 	int	(*_dmamap_load_mbuf)(void *, bus_dmamap_t,
350 		    struct mbuf *, int);
351 	int	(*_dmamap_load_uio)(void *, bus_dmamap_t,
352 		    struct uio *, int);
353 	int	(*_dmamap_load_raw)(void *, bus_dmamap_t,
354 		    bus_dma_segment_t *, int, bus_size_t, int);
355 	void	(*_dmamap_unload)(void *, bus_dmamap_t);
356 	void	(*_dmamap_sync)(void *, bus_dmamap_t, bus_addr_t,
357 		    bus_size_t, int);
358 
359 	/*
360 	 * DMA memory utility functions.
361 	 */
362 	int	(*_dmamem_alloc)(void *, bus_size_t, bus_size_t,
363 		    bus_size_t, bus_dma_segment_t *, int, int *, int);
364 	void	(*_dmamem_free)(void *, bus_dma_segment_t *, int);
365 	int	(*_dmamem_map)(void *, bus_dma_segment_t *,
366 		    int, size_t, caddr_t *, int);
367 	void	(*_dmamem_unmap)(void *, caddr_t, size_t);
368 	paddr_t	(*_dmamem_mmap)(void *, bus_dma_segment_t *,
369 		    int, off_t, int, int);
370 };
371 
372 #define	bus_dmamap_create(t, s, n, m, b, f, p)			\
373 	(*(t)->_dmamap_create)((t)->_cookie, (s), (n), (m), (b), (f), (p))
374 #define	bus_dmamap_destroy(t, p)				\
375 	(*(t)->_dmamap_destroy)((t)->_cookie, (p))
376 #define	bus_dmamap_load(t, m, b, s, p, f)			\
377 	(*(t)->_dmamap_load)((t)->_cookie, (m), (b), (s), (p), (f))
378 #define	bus_dmamap_load_mbuf(t, m, b, f)			\
379 	(*(t)->_dmamap_load_mbuf)((t)->_cookie, (m), (b), (f))
380 #define	bus_dmamap_load_uio(t, m, u, f)				\
381 	(*(t)->_dmamap_load_uio)((t)->_cookie, (m), (u), (f))
382 #define	bus_dmamap_load_raw(t, m, sg, n, s, f)			\
383 	(*(t)->_dmamap_load_raw)((t)->_cookie, (m), (sg), (n), (s), (f))
384 #define	bus_dmamap_unload(t, p)					\
385 	(*(t)->_dmamap_unload)((t)->_cookie, (p))
386 #define	bus_dmamap_sync(t, p, a, l, o)				\
387 	(void)((t)->_dmamap_sync ?				\
388 	    (*(t)->_dmamap_sync)((t)->_cookie, (p), (a), (l), (o)) : (void)0)
389 
390 #define	bus_dmamem_alloc(t, s, a, b, sg, n, r, f)		\
391 	(*(t)->_dmamem_alloc)((t)->_cookie, (s), (a), (b), (sg), (n), (r), (f))
392 #define	bus_dmamem_free(t, sg, n)				\
393 	(*(t)->_dmamem_free)((t)->_cookie, (sg), (n))
394 #define	bus_dmamem_map(t, sg, n, s, k, f)			\
395 	(*(t)->_dmamem_map)((t)->_cookie, (sg), (n), (s), (k), (f))
396 #define	bus_dmamem_unmap(t, k, s)				\
397 	(*(t)->_dmamem_unmap)((t)->_cookie, (k), (s))
398 #define	bus_dmamem_mmap(t, sg, n, o, p, f)			\
399 	(*(t)->_dmamem_mmap)((t)->_cookie, (sg), (n), (o), (p), (f))
400 
401 /*
402  *	bus_dmamap_t
403  *
404  *	Describes a DMA mapping.
405  */
406 struct hppa_bus_dmamap {
407 	/*
408 	 * PRIVATE MEMBERS: not for use by machine-independent code.
409 	 */
410 	bus_size_t	_dm_size;	/* largest DMA transfer mappable */
411 	int		_dm_segcnt;	/* number of segs this map can map */
412 	bus_size_t	_dm_maxsegsz;	/* largest possible segment */
413 	bus_size_t	_dm_boundary;	/* don't cross this */
414 	int		_dm_flags;	/* misc. flags */
415 
416 	void		*_dm_cookie;	/* cookie for bus-specific functions */
417 
418 	/*
419 	 * PUBLIC MEMBERS: these are used by machine-independent code.
420 	 */
421 	bus_size_t	dm_mapsize;	/* size of the mapping */
422 	int		dm_nsegs;	/* # valid segments in mapping */
423 	bus_dma_segment_t dm_segs[1];	/* segments; variable length */
424 };
425 
426 #endif /* _MACHINE_BUS_H_ */
427