bus.h revision 1.1.2.3 1 /* $NetBSD: bus.h,v 1.1.2.3 1999/02/13 17:51:43 minoura Exp $ */
2
3 /*-
4 * Copyright (c) 1998 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 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the NetBSD
22 * Foundation, Inc. and its contributors.
23 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40 /*
41 * bus_space(9) and bus_dma(9) interface for NetBSD/x68k.
42 */
43
44 #ifndef _X68K_BUS_H_
45 #define _X68K_BUS_H_
46
47 /*
48 * Bus address and size types
49 */
50 typedef u_long bus_addr_t;
51 typedef u_long bus_size_t;
52 typedef u_long bus_space_handle_t;
53
54 /*
55 * Bus space descripter
56 */
57 typedef struct x68k_bus_space *bus_space_tag_t;
58
59 struct x68k_bus_space {
60 #if 0
61 enum {
62 X68K_INTIO_BUS,
63 X68K_PCI_BUS,
64 X68K_NEPTUNE_BUS
65 } x68k_bus_type;
66 #endif
67
68 int (*x68k_bus_space_map) __P((
69 bus_space_tag_t,
70 bus_addr_t,
71 bus_size_t,
72 int, /* flags */
73 bus_space_handle_t *));
74 void (*x68k_bus_space_unmap) __P((
75 bus_space_tag_t,
76 bus_space_handle_t,
77 bus_size_t));
78 int (*x68k_bus_space_subregion) __P((
79 bus_space_tag_t,
80 bus_space_handle_t,
81 bus_size_t, /* offset */
82 bus_size_t, /* size */
83 bus_space_handle_t *));
84
85 int (*x68k_bus_space_alloc) __P((
86 bus_space_tag_t,
87 bus_addr_t, /* reg_start */
88 bus_addr_t, /* reg_end */
89 bus_size_t,
90 bus_size_t, /* alignment */
91 bus_size_t, /* boundary */
92 int, /* flags */
93 bus_addr_t *,
94 bus_space_handle_t *));
95 void (*x68k_bus_space_free) __P((
96 bus_space_tag_t,
97 bus_space_handle_t,
98 bus_size_t));
99
100 #if 0
101 void (*x68k_bus_space_barrier) __P((
102 bus_space_tag_t,
103 bus_space_handle_t,
104 bus_size_t, /* offset */
105 bus_size_t, /* length */
106 int)); /* flags */
107 #endif
108
109 u_int8_t (*x68k_bus_space_read_1) __P((
110 bus_space_tag_t,
111 bus_space_handle_t,
112 bus_size_t)); /* offset */
113 u_int16_t (*x68k_bus_space_read_2) __P((
114 bus_space_tag_t,
115 bus_space_handle_t,
116 bus_size_t)); /* offset */
117 u_int32_t (*x68k_bus_space_read_4) __P((
118 bus_space_tag_t,
119 bus_space_handle_t,
120 bus_size_t)); /* offset */
121
122 void (*x68k_bus_space_read_multi_1) __P((
123 bus_space_tag_t,
124 bus_space_handle_t,
125 bus_size_t, /* offset */
126 u_int8_t *,
127 bus_size_t)); /* count */
128 void (*x68k_bus_space_read_multi_2) __P((
129 bus_space_tag_t,
130 bus_space_handle_t,
131 bus_size_t, /* offset */
132 u_int16_t *,
133 bus_size_t)); /* count */
134 void (*x68k_bus_space_read_multi_4) __P((
135 bus_space_tag_t,
136 bus_space_handle_t,
137 bus_size_t, /* offset */
138 u_int32_t *,
139 bus_size_t)); /* count */
140
141 void (*x68k_bus_space_read_region_1) __P((
142 bus_space_tag_t,
143 bus_space_handle_t,
144 bus_size_t, /* offset */
145 u_int8_t *,
146 bus_size_t)); /* count */
147 void (*x68k_bus_space_read_region_2) __P((
148 bus_space_tag_t,
149 bus_space_handle_t,
150 bus_size_t, /* offset */
151 u_int16_t *,
152 bus_size_t)); /* count */
153 void (*x68k_bus_space_read_region_4) __P((
154 bus_space_tag_t,
155 bus_space_handle_t,
156 bus_size_t, /* offset */
157 u_int32_t *,
158 bus_size_t)); /* count */
159
160 void (*x68k_bus_space_write_1) __P((
161 bus_space_tag_t,
162 bus_space_handle_t,
163 bus_size_t, /* offset */
164 u_int8_t));
165 void (*x68k_bus_space_write_2) __P((
166 bus_space_tag_t,
167 bus_space_handle_t,
168 bus_size_t, /* offset */
169 u_int16_t));
170 void (*x68k_bus_space_write_4) __P((
171 bus_space_tag_t,
172 bus_space_handle_t,
173 bus_size_t, /* offset */
174 u_int32_t));
175
176 void (*x68k_bus_space_write_multi_1) __P((
177 bus_space_tag_t,
178 bus_space_handle_t,
179 bus_size_t, /* offset */
180 u_int8_t *,
181 bus_size_t)); /* count */
182 void (*x68k_bus_space_write_multi_2) __P((
183 bus_space_tag_t,
184 bus_space_handle_t,
185 bus_size_t, /* offset */
186 u_int16_t *,
187 bus_size_t)); /* count */
188 void (*x68k_bus_space_write_multi_4) __P((
189 bus_space_tag_t,
190 bus_space_handle_t,
191 bus_size_t, /* offset */
192 u_int32_t *,
193 bus_size_t)); /* count */
194
195 void (*x68k_bus_space_write_region_1) __P((
196 bus_space_tag_t,
197 bus_space_handle_t,
198 bus_size_t, /* offset */
199 u_int8_t *,
200 bus_size_t)); /* count */
201 void (*x68k_bus_space_write_region_2) __P((
202 bus_space_tag_t,
203 bus_space_handle_t,
204 bus_size_t, /* offset */
205 u_int16_t *,
206 bus_size_t)); /* count */
207 void (*x68k_bus_space_write_region_4) __P((
208 bus_space_tag_t,
209 bus_space_handle_t,
210 bus_size_t, /* offset */
211 u_int32_t *,
212 bus_size_t)); /* count */
213
214 void (*x68k_bus_space_set_region_1) __P((
215 bus_space_tag_t,
216 bus_space_handle_t,
217 bus_size_t, /* offset */
218 u_int8_t,
219 bus_size_t)); /* count */
220 void (*x68k_bus_space_set_region_2) __P((
221 bus_space_tag_t,
222 bus_space_handle_t,
223 bus_size_t, /* offset */
224 u_int16_t,
225 bus_size_t)); /* count */
226 void (*x68k_bus_space_set_region_4) __P((
227 bus_space_tag_t,
228 bus_space_handle_t,
229 bus_size_t, /* offset */
230 u_int32_t,
231 bus_size_t)); /* count */
232
233 void (*x68k_bus_space_copy_region_1) __P((
234 bus_space_tag_t,
235 bus_space_handle_t, /* srchandle */
236 bus_size_t, /* srcoffset */
237 bus_space_handle_t, /* dsthandle */
238 bus_size_t, /* dstoffset */
239 bus_size_t)); /* count */
240 void (*x68k_bus_space_copy_region_2) __P((
241 bus_space_tag_t,
242 bus_space_handle_t, /* srchandle */
243 bus_size_t, /* srcoffset */
244 bus_space_handle_t, /* dsthandle */
245 bus_size_t, /* dstoffset */
246 bus_size_t)); /* count */
247 void (*x68k_bus_space_copy_region_4) __P((
248 bus_space_tag_t,
249 bus_space_handle_t, /* srchandle */
250 bus_size_t, /* srcoffset */
251 bus_space_handle_t, /* dsthandle */
252 bus_size_t, /* dstoffset */
253 bus_size_t)); /* count */
254
255 struct device *x68k_bus_device;
256 };
257
258 int x68k_bus_space_alloc __P((bus_space_tag_t, bus_addr_t, bus_addr_t, bus_size_t, bus_size_t, bus_size_t, int, bus_addr_t *, bus_space_handle_t *));
259 void x68k_bus_space_free __P((bus_space_tag_t, bus_space_handle_t, bus_size_t));
260
261 u_int8_t x68k_bus_space_read_1 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t));
262 u_int16_t x68k_bus_space_read_2 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t));
263 u_int32_t x68k_bus_space_read_4 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t));
264
265 void x68k_bus_space_read_multi_1 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int8_t *, bus_size_t));
266 void x68k_bus_space_read_multi_2 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t *, bus_size_t));
267 void x68k_bus_space_read_multi_4 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t *, bus_size_t));
268
269 void x68k_bus_space_read_region_1 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int8_t *, bus_size_t));
270 void x68k_bus_space_read_region_2 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t *, bus_size_t));
271 void x68k_bus_space_read_region_4 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t *, bus_size_t));
272
273 void x68k_bus_space_write_1 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int8_t));
274 void x68k_bus_space_write_2 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t));
275 void x68k_bus_space_write_4 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t));
276
277 void x68k_bus_space_write_multi_1 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int8_t *, bus_size_t));
278 void x68k_bus_space_write_multi_2 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t *, bus_size_t));
279 void x68k_bus_space_write_multi_4 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t *, bus_size_t));
280
281 void x68k_bus_space_write_region_1 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int8_t *, bus_size_t));
282 void x68k_bus_space_write_region_2 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t *, bus_size_t));
283 void x68k_bus_space_write_region_4 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t *, bus_size_t));
284
285 void x68k_bus_space_set_region_1 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int8_t, bus_size_t));
286 void x68k_bus_space_set_region_2 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int16_t, bus_size_t));
287 void x68k_bus_space_set_region_4 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, u_int32_t, bus_size_t));
288
289 void x68k_bus_space_copy_region_1 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, bus_space_handle_t, bus_size_t, bus_size_t));
290 void x68k_bus_space_copy_region_2 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, bus_space_handle_t, bus_size_t, bus_size_t));
291 void x68k_bus_space_copy_region_4 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, bus_space_handle_t, bus_size_t, bus_size_t));
292
293 /*
294 * bus_space(9) interface
295 */
296
297 #define bus_space_map(t,a,s,f,h) \
298 ((*((t)->x68k_bus_space_map)) ((t),(a),(s),(f),(h)))
299 #define bus_space_unmap(t,h,s) \
300 ((*((t)->x68k_bus_space_unmap)) ((t),(h),(s)))
301 #define bus_space_subregion(t,h,o,s,p) \
302 ((*((t)->x68k_bus_space_subregion)) ((t),(h),(o),(s),(p)))
303 #define BUS_SPACE_MAP_CACHEABLE 0x0001
304 #define BUS_SPACE_MAP_LINEAR 0x0002
305 /*
306 * For simpler hadware, many x68k devices are mapped with shifted address
307 * i.e. only on even or odd addresses.
308 */
309 #define BUS_SPACE_MAP_SHIFTED 0x1001
310
311 #define bus_space_alloc(t,rs,re,s,a,b,f,r,h) \
312 ((*((t)->x68k_bus_space_alloc)) ((t),(rs),(re),(s),(a),(b),(f),(r),(h)))
313 #define bus_space_free(t,h,s) \
314 ((*((t)->x68k_bus_space_free)) ((t),(h),(s)))
315
316 /*
317 * Note: the 680x0 does not currently require barriers, but we must
318 * provide the flags to MI code.
319 */
320 #define bus_space_barrier(t, h, o, l, f) \
321 ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)))
322 #define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
323 #define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
324
325 #define bus_space_read_1(t,h,o) \
326 ((*((t)->x68k_bus_space_read_1)) ((t),(h),(o)))
327 #define bus_space_read_2(t,h,o) \
328 ((*((t)->x68k_bus_space_read_2)) ((t),(h),(o)))
329 #define bus_space_read_4(t,h,o) \
330 ((*((t)->x68k_bus_space_read_4)) ((t),(h),(o)))
331
332 #define bus_space_read_multi_1(t,h,o,p,c) \
333 ((*((t)->x68k_bus_space_read_multi_1)) ((t),(h),(o),(p),(c)))
334 #define bus_space_read_multi_2(t,h,o,p,c) \
335 ((*((t)->x68k_bus_space_read_multi_2)) ((t),(h),(o),(p),(c)))
336 #define bus_space_read_multi_4(t,h,o,p,c) \
337 ((*((t)->x68k_bus_space_read_multi_4)) ((t),(h),(o),(p),(c)))
338
339 #define bus_space_read_region_1(t,h,o,p,c) \
340 ((*((t)->x68k_bus_space_read_region_1)) ((t),(h),(o),(p),(c)))
341 #define bus_space_read_region_2(t,h,o,p,c) \
342 ((*((t)->x68k_bus_space_read_region_2)) ((t),(h),(o),(p),(c)))
343 #define bus_space_read_region_4(t,h,o,p,c) \
344 ((*((t)->x68k_bus_space_read_region_4)) ((t),(h),(o),(p),(c)))
345
346 #define bus_space_write_1(t,h,o,v) \
347 ((*((t)->x68k_bus_space_write_1)) ((t),(h),(o),(v)))
348 #define bus_space_write_2(t,h,o,v) \
349 ((*((t)->x68k_bus_space_write_2)) ((t),(h),(o),(v)))
350 #define bus_space_write_4(t,h,o,v) \
351 ((*((t)->x68k_bus_space_write_4)) ((t),(h),(o),(v)))
352
353 #define bus_space_write_multi_1(t,h,o,p,c) \
354 ((*((t)->x68k_bus_space_write_multi_1)) ((t),(h),(o),(p),(c)))
355 #define bus_space_write_multi_2(t,h,o,p,c) \
356 ((*((t)->x68k_bus_space_write_multi_2)) ((t),(h),(o),(p),(c)))
357 #define bus_space_write_multi_4(t,h,o,p,c) \
358 ((*((t)->x68k_bus_space_write_multi_4)) ((t),(h),(o),(p),(c)))
359
360 #define bus_space_write_region_1(t,h,o,p,c) \
361 ((*((t)->x68k_bus_space_write_region_1)) ((t),(h),(o),(p),(c)))
362 #define bus_space_write_region_2(t,h,o,p,c) \
363 ((*((t)->x68k_bus_space_write_region_2)) ((t),(h),(o),(p),(c)))
364 #define bus_space_write_region_4(t,h,o,p,c) \
365 ((*((t)->x68k_bus_space_write_region_4)) ((t),(h),(o),(p),(c)))
366
367 #define bus_space_set_region_1(t,h,o,v,c) \
368 ((*((t)->x68k_bus_space_set_region_1)) ((t),(h),(o),(v),(c)))
369 #define bus_space_set_region_2(t,h,o,v,c) \
370 ((*((t)->x68k_bus_space_set_region_2)) ((t),(h),(o),(v),(c)))
371 #define bus_space_set_region_4(t,h,o,v,c) \
372 ((*((t)->x68k_bus_space_set_region_4)) ((t),(h),(o),(v),(c)))
373
374 #define bus_space_copy_region_1(t,sh,so,dh,do,c) \
375 ((*((t)->x68k_bus_space_copy_region_1)) ((t),(sh),(so),(dh),(do),(c)))
376 #define bus_space_copy_region_2(t,sh,so,dh,do,c) \
377 ((*((t)->x68k_bus_space_copy_region_2)) ((t),(sh),(so),(dh),(do),(c)))
378 #define bus_space_copy_region_4(t,sh,so,dh,do,c) \
379 ((*((t)->x68k_bus_space_copy_region_4)) ((t),(sh),(so),(dh),(do),(c)))
380
381
382 /*
383 * DMA segment
384 */
385 struct x68k_bus_dma_segment {
386 bus_addr_t ds_addr;
387 bus_size_t ds_len;
388 };
389 typedef struct x68k_bus_dma_segment bus_dma_segment_t;
390
391 /*
392 * DMA descriptor
393 */
394 /* Forwards needed by prototypes below. */
395 struct mbuf;
396 struct uio;
397
398 typedef struct x68k_bus_dma *bus_dma_tag_t;
399 typedef struct x68k_bus_dmamap *bus_dmamap_t;
400 struct x68k_bus_dma {
401 /*
402 * The `bounce threshold' is checked while we are loading
403 * the DMA map. If the physical address of the segment
404 * exceeds the threshold, an error will be returned. The
405 * caller can then take whatever action is necessary to
406 * bounce the transfer. If this value is 0, it will be
407 * ignored.
408 */
409 bus_addr_t _bounce_thresh;
410
411 /*
412 * DMA mapping methods.
413 */
414 int (*x68k_dmamap_create) __P((bus_dma_tag_t, bus_size_t, int,
415 bus_size_t, bus_size_t, int, bus_dmamap_t *));
416 void (*x68k_dmamap_destroy) __P((bus_dma_tag_t, bus_dmamap_t));
417 int (*x68k_dmamap_load) __P((bus_dma_tag_t, bus_dmamap_t, void *,
418 bus_size_t, struct proc *, int));
419 int (*x68k_dmamap_load_mbuf) __P((bus_dma_tag_t, bus_dmamap_t,
420 struct mbuf *, int));
421 int (*x68k_dmamap_load_uio) __P((bus_dma_tag_t, bus_dmamap_t,
422 struct uio *, int));
423 int (*x68k_dmamap_load_raw) __P((bus_dma_tag_t, bus_dmamap_t,
424 bus_dma_segment_t *, int, bus_size_t, int));
425 void (*x68k_dmamap_unload) __P((bus_dma_tag_t, bus_dmamap_t));
426 void (*x68k_dmamap_sync) __P((bus_dma_tag_t, bus_dmamap_t,
427 bus_addr_t, bus_size_t, int));
428
429 /*
430 * DMA memory utility functions.
431 */
432 int (*x68k_dmamem_alloc) __P((bus_dma_tag_t, bus_size_t, bus_size_t,
433 bus_size_t, bus_dma_segment_t *, int, int *, int));
434 void (*x68k_dmamem_free) __P((bus_dma_tag_t,
435 bus_dma_segment_t *, int));
436 int (*x68k_dmamem_map) __P((bus_dma_tag_t, bus_dma_segment_t *,
437 int, size_t, caddr_t *, int));
438 void (*x68k_dmamem_unmap) __P((bus_dma_tag_t, caddr_t, size_t));
439 int (*x68k_dmamem_mmap) __P((bus_dma_tag_t, bus_dma_segment_t *,
440 int, int, int, int));
441 };
442
443 /*
444 * bus_dmamap_t
445 *
446 * Describes a DMA mapping.
447 */
448 struct x68k_bus_dmamap {
449 /*
450 * PRIVATE MEMBERS: not for use my machine-independent code.
451 */
452 bus_size_t x68k_dm_size; /* largest DMA transfer mappable */
453 int x68k_dm_segcnt; /* number of segs this map can map */
454 bus_size_t x68k_dm_maxsegsz; /* largest possible segment */
455 bus_size_t x68k_dm_boundary; /* don't cross this */
456 bus_addr_t x68k_dm_bounce_thresh; /* bounce threshold */
457 int x68k_dm_flags; /* misc. flags */
458
459 void *x68k_dm_cookie; /* cookie for bus-specific functions */
460
461 /*
462 * PUBLIC MEMBERS: these are used by machine-independent code.
463 */
464 bus_size_t dm_mapsize; /* size of the mapping */
465 int dm_nsegs; /* # valid segments in mapping */
466 bus_dma_segment_t dm_segs[1]; /* segments; variable length */
467 };
468
469 int x68k_bus_dmamap_create __P((bus_dma_tag_t, bus_size_t, int, bus_size_t,
470 bus_size_t, int, bus_dmamap_t *));
471 void x68k_bus_dmamap_destroy __P((bus_dma_tag_t, bus_dmamap_t));
472 int x68k_bus_dmamap_load __P((bus_dma_tag_t, bus_dmamap_t, void *,
473 bus_size_t, struct proc *, int));
474 int x68k_bus_dmamap_load_mbuf __P((bus_dma_tag_t, bus_dmamap_t,
475 struct mbuf *, int));
476 int x68k_bus_dmamap_load_uio __P((bus_dma_tag_t, bus_dmamap_t,
477 struct uio *, int));
478 int x68k_bus_dmamap_load_raw __P((bus_dma_tag_t, bus_dmamap_t,
479 bus_dma_segment_t *, int, bus_size_t, int));
480 void x68k_bus_dmamap_unload __P((bus_dma_tag_t, bus_dmamap_t));
481 void x68k_bus_dmamap_sync __P((bus_dma_tag_t, bus_dmamap_t, bus_addr_t,
482 bus_size_t, int));
483
484 int x68k_bus_dmamem_alloc __P((bus_dma_tag_t tag, bus_size_t size,
485 bus_size_t alignment, bus_size_t boundary,
486 bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags));
487 void x68k_bus_dmamem_free __P((bus_dma_tag_t tag, bus_dma_segment_t *segs,
488 int nsegs));
489 int x68k_bus_dmamem_map __P((bus_dma_tag_t tag, bus_dma_segment_t *segs,
490 int nsegs, size_t size, caddr_t *kvap, int flags));
491 void x68k_bus_dmamem_unmap __P((bus_dma_tag_t tag, caddr_t kva,
492 size_t size));
493 int x68k_bus_dmamem_mmap __P((bus_dma_tag_t tag, bus_dma_segment_t *segs,
494 int nsegs, int off, int prot, int flags));
495
496 int x68k_bus_dmamap_load_buffer __P((bus_dmamap_t, void *,
497 bus_size_t buflen, struct proc *, int, paddr_t *, int *, int));
498 int x68k_bus_dmamem_alloc_range __P((bus_dma_tag_t tag, bus_size_t size,
499 bus_size_t alignment, bus_size_t boundary,
500 bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags,
501 paddr_t low, paddr_t high));
502
503 #define bus_dmamap_create(t,s,n,m,b,f,p) \
504 ((*((t)->x68k_dmamap_create)) ((t),(s),(n),(m),(b),(f),(p)))
505 #define bus_dmamap_destroy(t,p) \
506 ((*((t)->x68k_dmamap_destroy)) ((t),(p)))
507 #define bus_dmamap_load(t,m,b,s,p,f) \
508 ((*((t)->x68k_dmamap_load)) ((t),(m),(b),(s),(p),(f)))
509 #define bus_dmamap_load_mbuf(t,m,b,f) \
510 ((*((t)->x68k_dmamap_load_mbuf)) ((t),(m),(b),(f)))
511 #define bus_dmamap_load_uio(t,m,u,f) \
512 ((*((t)->x68k_dmamap_load_uio)) ((t),(m),(u),(f)))
513 #define bus_dmamap_load_raw(t,m,sg,n,s,f) \
514 ((*((t)->x68k_dmamap_load_raw)) ((t),(m),(sg),(n),(s),(f)))
515 #define bus_dmamap_unload(t,p) \
516 ((*((t)->x68k_dmamap_unload)) ((t),(p)))
517 #define bus_dmamap_sync(t,p,o,l,ops) \
518 ((*((t)->x68k_dmamap_sync)) ((t),(p),(o),(l),(ops)))
519
520 #define bus_dmamem_alloc(t,s,a,b,sg,n,r,f) \
521 ((*((t)->x68k_dmamem_alloc)) ((t),(s),(a),(b),(sg),(n),(r),(f)))
522 #define bus_dmamem_free(t,sg,n) \
523 ((*((t)->x68k_dmamem_free)) ((t),(sg),(n)))
524 #define bus_dmamem_map(t,sg,n,s,k,f) \
525 ((*((t)->x68k_dmamem_map)) ((t),(sg),(n),(s),(k),(f)))
526 #define bus_dmamem_unmap(t,k,s) \
527 ((*((t)->x68k_dmamem_unmap)) ((t),(k),(s)))
528 #define bus_dmamem_mmap(t,sg,n,o,p,f) \
529 ((*((t)->x68k_dmamem_mmap)) ((t),(sg),(n),(o),(p),(f)))
530
531 /*
532 * Flags used in various bus DMA methods.
533 */
534 #define BUS_DMA_WAITOK 0x00 /* safe to sleep (pseudo-flag) */
535 #define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */
536 #define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */
537 #define BUS_DMA_COHERENT 0x04 /* hint: map memory DMA coherent */
538 #define BUS_DMA_BUS1 0x10 /* placeholders for bus functions... */
539 #define BUS_DMA_BUS2 0x20
540 #define BUS_DMA_BUS3 0x40
541 #define BUS_DMA_BUS4 0x80
542
543 /*
544 * Operations performed by bus_dmamap_sync().
545 */
546 #define BUS_DMASYNC_PREREAD 0x01 /* pre-read synchronization */
547 #define BUS_DMASYNC_POSTREAD 0x02 /* post-read synchronization */
548 #define BUS_DMASYNC_PREWRITE 0x04 /* pre-write synchronization */
549 #define BUS_DMASYNC_POSTWRITE 0x08 /* post-write synchronization */
550
551 #endif /* _X68K_BUS_H_ */
552