xref: /openbsd/sys/arch/hppa/include/bus.h (revision b0002153)
1 /*	$OpenBSD: bus.h,v 1.32 2017/05/08 00:27:45 dlg 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 #define	BUS_DMA_64BIT		0x2000	/* device handles 64bit dva */
303 
304 /* Forwards needed by prototypes below. */
305 struct mbuf;
306 struct proc;
307 struct uio;
308 
309 /* Operations performed by bus_dmamap_sync().  */
310 #define BUS_DMASYNC_POSTREAD	0x01
311 #define BUS_DMASYNC_POSTWRITE	0x02
312 #define BUS_DMASYNC_PREREAD	0x04
313 #define BUS_DMASYNC_PREWRITE	0x08
314 
315 typedef const struct hppa_bus_dma_tag	*bus_dma_tag_t;
316 typedef struct hppa_bus_dmamap	*bus_dmamap_t;
317 
318 /*
319  *	bus_dma_segment_t
320  *
321  *	Describes a single contiguous DMA transaction.  Values
322  *	are suitable for programming into DMA registers.
323  */
324 struct hppa_bus_dma_segment {
325 	vaddr_t		_ds_va;		/* needed for syncing */
326 
327 	bus_addr_t	ds_addr;	/* DMA address */
328 	bus_size_t	ds_len;		/* length of transfer */
329 };
330 typedef struct hppa_bus_dma_segment	bus_dma_segment_t;
331 
332 /*
333  *	bus_dma_tag_t
334  *
335  *	A machine-dependent opaque type describing the implementation of
336  *	DMA for a given bus.
337  */
338 
339 struct hppa_bus_dma_tag {
340 	void	*_cookie;		/* cookie used in the guts */
341 
342 	/*
343 	 * DMA mapping methods.
344 	 */
345 	int	(*_dmamap_create)(void *, bus_size_t, int,
346 		    bus_size_t, bus_size_t, int, bus_dmamap_t *);
347 	void	(*_dmamap_destroy)(void *, bus_dmamap_t);
348 	int	(*_dmamap_load)(void *, bus_dmamap_t, void *,
349 		    bus_size_t, struct proc *, int);
350 	int	(*_dmamap_load_mbuf)(void *, bus_dmamap_t,
351 		    struct mbuf *, int);
352 	int	(*_dmamap_load_uio)(void *, bus_dmamap_t,
353 		    struct uio *, int);
354 	int	(*_dmamap_load_raw)(void *, bus_dmamap_t,
355 		    bus_dma_segment_t *, int, bus_size_t, int);
356 	void	(*_dmamap_unload)(void *, bus_dmamap_t);
357 	void	(*_dmamap_sync)(void *, bus_dmamap_t, bus_addr_t,
358 		    bus_size_t, int);
359 
360 	/*
361 	 * DMA memory utility functions.
362 	 */
363 	int	(*_dmamem_alloc)(void *, bus_size_t, bus_size_t,
364 		    bus_size_t, bus_dma_segment_t *, int, int *, int);
365 	void	(*_dmamem_free)(void *, bus_dma_segment_t *, int);
366 	int	(*_dmamem_map)(void *, bus_dma_segment_t *,
367 		    int, size_t, caddr_t *, int);
368 	void	(*_dmamem_unmap)(void *, caddr_t, size_t);
369 	paddr_t	(*_dmamem_mmap)(void *, bus_dma_segment_t *,
370 		    int, off_t, int, int);
371 };
372 
373 #define	bus_dmamap_create(t, s, n, m, b, f, p)			\
374 	(*(t)->_dmamap_create)((t)->_cookie, (s), (n), (m), (b), (f), (p))
375 #define	bus_dmamap_destroy(t, p)				\
376 	(*(t)->_dmamap_destroy)((t)->_cookie, (p))
377 #define	bus_dmamap_load(t, m, b, s, p, f)			\
378 	(*(t)->_dmamap_load)((t)->_cookie, (m), (b), (s), (p), (f))
379 #define	bus_dmamap_load_mbuf(t, m, b, f)			\
380 	(*(t)->_dmamap_load_mbuf)((t)->_cookie, (m), (b), (f))
381 #define	bus_dmamap_load_uio(t, m, u, f)				\
382 	(*(t)->_dmamap_load_uio)((t)->_cookie, (m), (u), (f))
383 #define	bus_dmamap_load_raw(t, m, sg, n, s, f)			\
384 	(*(t)->_dmamap_load_raw)((t)->_cookie, (m), (sg), (n), (s), (f))
385 #define	bus_dmamap_unload(t, p)					\
386 	(*(t)->_dmamap_unload)((t)->_cookie, (p))
387 #define	bus_dmamap_sync(t, p, a, l, o)				\
388 	(void)((t)->_dmamap_sync ?				\
389 	    (*(t)->_dmamap_sync)((t)->_cookie, (p), (a), (l), (o)) : (void)0)
390 
391 #define	bus_dmamem_alloc(t, s, a, b, sg, n, r, f)		\
392 	(*(t)->_dmamem_alloc)((t)->_cookie, (s), (a), (b), (sg), (n), (r), (f))
393 #define	bus_dmamem_free(t, sg, n)				\
394 	(*(t)->_dmamem_free)((t)->_cookie, (sg), (n))
395 #define	bus_dmamem_map(t, sg, n, s, k, f)			\
396 	(*(t)->_dmamem_map)((t)->_cookie, (sg), (n), (s), (k), (f))
397 #define	bus_dmamem_unmap(t, k, s)				\
398 	(*(t)->_dmamem_unmap)((t)->_cookie, (k), (s))
399 #define	bus_dmamem_mmap(t, sg, n, o, p, f)			\
400 	(*(t)->_dmamem_mmap)((t)->_cookie, (sg), (n), (o), (p), (f))
401 
402 /*
403  *	bus_dmamap_t
404  *
405  *	Describes a DMA mapping.
406  */
407 struct hppa_bus_dmamap {
408 	/*
409 	 * PRIVATE MEMBERS: not for use by machine-independent code.
410 	 */
411 	bus_size_t	_dm_size;	/* largest DMA transfer mappable */
412 	int		_dm_segcnt;	/* number of segs this map can map */
413 	bus_size_t	_dm_maxsegsz;	/* largest possible segment */
414 	bus_size_t	_dm_boundary;	/* don't cross this */
415 	int		_dm_flags;	/* misc. flags */
416 
417 	void		*_dm_cookie;	/* cookie for bus-specific functions */
418 
419 	/*
420 	 * PUBLIC MEMBERS: these are used by machine-independent code.
421 	 */
422 	bus_size_t	dm_mapsize;	/* size of the mapping */
423 	int		dm_nsegs;	/* # valid segments in mapping */
424 	bus_dma_segment_t dm_segs[1];	/* segments; variable length */
425 };
426 
427 #endif /* _MACHINE_BUS_H_ */
428