1 /* $NetBSD: bus.h,v 1.12 1997/10/01 08:25:15 fvdl Exp $ */
4 * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
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.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
41 * Copyright (c) 1996 Charles M. Hannum. All rights reserved.
42 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
47 * 1. Redistributions of source code must retain the above copyright
48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 * 3. All advertising materials mentioning features or use of this software
53 * must display the following acknowledgement:
54 * This product includes software developed by Christopher G. Demetriou
55 * for the NetBSD Project.
56 * 4. The name of the author may not be used to endorse or promote products
57 * derived from this software without specific prior written permission
59 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
60 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
61 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
62 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
63 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
64 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
65 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
66 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
67 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
68 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
76 * Bus address and size types
78 typedef u_int64_t bus_addr_t;
79 typedef u_int64_t bus_size_t;
80 typedef struct alpha_busspace *bus_space_tag_t;
81 typedef u_int32_t bus_space_handle_t;
83 #define BUS_SPACE_MAXSIZE_24BIT 0xFFFFFF
84 #define BUS_SPACE_MAXSIZE_32BIT 0xFFFFFFFF
85 #define BUS_SPACE_MAXSIZE (64 * 1024) /* Maximum supported size */
86 #define BUS_SPACE_MAXADDR_24BIT 0xFFFFFF
87 #define BUS_SPACE_MAXADDR_32BIT 0xFFFFFFFF
88 /* The largest address space known so far is 40 bits */
89 #define BUS_SPACE_MAXADDR 0xFFFFFFFFFUL
91 #define BUS_SPACE_UNRESTRICTED (~0UL)
94 * Unmap a region of device bus space.
97 static __inline void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
101 bus_space_unmap(bus_space_tag_t t __unused, bus_space_handle_t bsh __unused,
102 bus_size_t size __unused)
108 * Get a new handle for a subregion of an already-mapped area of bus space.
111 static __inline int bus_space_subregion(bus_space_tag_t t,
112 bus_space_handle_t bsh,
113 bus_size_t offset, bus_size_t size,
114 bus_space_handle_t *nbshp);
117 bus_space_subregion(bus_space_tag_t t __unused, bus_space_handle_t bsh,
118 bus_size_t offset, bus_size_t size __unused,
119 bus_space_handle_t *nbshp)
122 *nbshp = bsh + offset;
127 struct alpha_busspace;
129 struct alpha_busspace_ops {
130 u_int8_t (*abo_read_1)(struct alpha_busspace *space, size_t offset);
131 u_int16_t (*abo_read_2)(struct alpha_busspace *space, size_t offset);
132 u_int32_t (*abo_read_4)(struct alpha_busspace *space, size_t offset);
134 void (*abo_read_multi_1)(struct alpha_busspace *space,
136 u_int8_t *addr, size_t count);
137 void (*abo_read_multi_2)(struct alpha_busspace *space,
139 u_int16_t *addr, size_t count);
140 void (*abo_read_multi_4)(struct alpha_busspace *space,
142 u_int32_t *addr, size_t count);
144 void (*abo_read_region_1)(struct alpha_busspace *space,
146 u_int8_t *addr, size_t count);
147 void (*abo_read_region_2)(struct alpha_busspace *space,
149 u_int16_t *addr, size_t count);
150 void (*abo_read_region_4)(struct alpha_busspace *space,
152 u_int32_t *addr, size_t count);
154 void (*abo_write_1)(struct alpha_busspace *space, size_t offset,
156 void (*abo_write_2)(struct alpha_busspace *space, size_t offset,
158 void (*abo_write_4)(struct alpha_busspace *space, size_t offset,
161 void (*abo_write_multi_1)(struct alpha_busspace *space,
163 const u_int8_t *addr, size_t count);
164 void (*abo_write_multi_2)(struct alpha_busspace *space,
166 const u_int16_t *addr, size_t count);
167 void (*abo_write_multi_4)(struct alpha_busspace *space,
169 const u_int32_t *addr, size_t count);
171 void (*abo_write_region_1)(struct alpha_busspace *space,
173 const u_int8_t *addr, size_t count);
174 void (*abo_write_region_2)(struct alpha_busspace *space,
176 const u_int16_t *addr, size_t count);
177 void (*abo_write_region_4)(struct alpha_busspace *space,
179 const u_int32_t *addr, size_t count);
181 void (*abo_set_multi_1)(struct alpha_busspace *space, size_t offset,
182 u_int8_t value, size_t count);
183 void (*abo_set_multi_2)(struct alpha_busspace *space, size_t offset,
184 u_int16_t value, size_t count);
185 void (*abo_set_multi_4)(struct alpha_busspace *space, size_t offset,
186 u_int32_t value, size_t count);
188 void (*abo_set_region_1)(struct alpha_busspace *space,
190 u_int8_t value, size_t count);
191 void (*abo_set_region_2)(struct alpha_busspace *space,
193 u_int16_t value, size_t count);
194 void (*abo_set_region_4)(struct alpha_busspace *space,
196 u_int32_t value, size_t count);
198 void (*abo_copy_region_1)(struct alpha_busspace *space,
199 size_t offset1, size_t offset2,
201 void (*abo_copy_region_2)(struct alpha_busspace *space,
202 size_t offset1, size_t offset2,
204 void (*abo_copy_region_4)(struct alpha_busspace *space,
205 size_t offset1, size_t offset2,
208 void (*abo_barrier)(struct alpha_busspace *space, size_t offset,
209 size_t len, int flags);
212 struct alpha_busspace {
213 struct alpha_busspace_ops *ab_ops;
216 /* Back-compat functions for old ISA drivers */
218 extern struct alpha_busspace *busspace_isa_io;
219 extern struct alpha_busspace *busspace_isa_mem;
221 #define inb(o) bus_space_read_1(busspace_isa_io, o, 0)
222 #define inw(o) bus_space_read_2(busspace_isa_io, o, 0)
223 #define inl(o) bus_space_read_4(busspace_isa_io, o, 0)
224 #define outb(o, v) bus_space_write_1(busspace_isa_io, o, 0, v)
225 #define outw(o, v) bus_space_write_2(busspace_isa_io, o, 0, v)
226 #define outl(o, v) bus_space_write_4(busspace_isa_io, o, 0, v)
228 #define readb(o) bus_space_read_1(busspace_isa_mem, o, 0)
229 #define readw(o) bus_space_read_2(busspace_isa_mem, o, 0)
230 #define readl(o) bus_space_read_4(busspace_isa_mem, o, 0)
231 #define writeb(o, v) bus_space_write_1(busspace_isa_mem, o, 0, v)
232 #define writew(o, v) bus_space_write_2(busspace_isa_mem, o, 0, v)
233 #define writel(o, v) bus_space_write_4(busspace_isa_mem, o, 0, v)
235 #define insb(o, a, c) bus_space_read_multi_1(busspace_isa_io, o, 0, \
237 #define insw(o, a, c) bus_space_read_multi_2(busspace_isa_io, o, 0, \
239 #define insl(o, a, c) bus_space_read_multi_4(busspace_isa_io, o, 0, \
242 #define outsb(o, a, c) bus_space_write_multi_1(busspace_isa_io, o, 0, \
244 #define outsw(o, a, c) bus_space_write_multi_2(busspace_isa_io, o, 0, \
246 #define outsl(o, a, c) bus_space_write_multi_4(busspace_isa_io, o, 0, \
249 #define memcpy_fromio(d, s, c) \
250 bus_space_read_region_1(busspace_isa_mem, s, 0, d, c)
251 #define memcpy_toio(d, s, c) \
252 bus_space_write_region_1(busspace_isa_mem, d, 0, s, c)
253 #define memcpy_io(d, s, c) \
254 bus_space_copy_region_1(busspace_isa_mem, s, 0, d, 0, c)
255 #define memset_io(d, v, c) \
256 bus_space_set_region_1(busspace_isa_mem, d, 0, v, c)
257 #define memsetw_io(d, v, c) \
258 bus_space_set_region_2(busspace_isa_mem, d, 0, v, c)
261 memsetw(void *d, int val, size_t size)
269 void busspace_generic_read_multi_1(struct alpha_busspace *space,
271 u_int8_t *addr, size_t count);
272 void busspace_generic_read_multi_2(struct alpha_busspace *space,
274 u_int16_t *addr, size_t count);
275 void busspace_generic_read_multi_4(struct alpha_busspace *space,
277 u_int32_t *addr, size_t count);
278 void busspace_generic_read_region_1(struct alpha_busspace *space,
280 u_int8_t *addr, size_t count);
281 void busspace_generic_read_region_2(struct alpha_busspace *space,
283 u_int16_t *addr, size_t count);
284 void busspace_generic_read_region_4(struct alpha_busspace *space,
286 u_int32_t *addr, size_t count);
287 void busspace_generic_write_multi_1(struct alpha_busspace *space,
289 const u_int8_t *addr, size_t count);
290 void busspace_generic_write_multi_2(struct alpha_busspace *space,
292 const u_int16_t *addr, size_t count);
293 void busspace_generic_write_multi_4(struct alpha_busspace *space,
295 const u_int32_t *addr, size_t count);
296 void busspace_generic_write_region_1(struct alpha_busspace *space,
298 const u_int8_t *addr, size_t count);
299 void busspace_generic_write_region_2(struct alpha_busspace *space,
301 const u_int16_t *addr, size_t count);
302 void busspace_generic_write_region_4(struct alpha_busspace *space,
304 const u_int32_t *addr, size_t count);
305 void busspace_generic_set_multi_1(struct alpha_busspace *space,
307 u_int8_t value, size_t count);
308 void busspace_generic_set_multi_2(struct alpha_busspace *space,
310 u_int16_t value, size_t count);
311 void busspace_generic_set_multi_4(struct alpha_busspace *space,
313 u_int32_t value, size_t count);
314 void busspace_generic_set_region_1(struct alpha_busspace *space,
316 u_int8_t value, size_t count);
317 void busspace_generic_set_region_2(struct alpha_busspace *space,
319 u_int16_t value, size_t count);
320 void busspace_generic_set_region_4(struct alpha_busspace *space,
322 u_int32_t value, size_t count);
323 void busspace_generic_copy_region_1(struct alpha_busspace *space,
327 void busspace_generic_copy_region_2(struct alpha_busspace *space,
331 void busspace_generic_copy_region_4(struct alpha_busspace *space,
335 void busspace_generic_barrier(struct alpha_busspace *space,
336 size_t offset, size_t len,
339 #define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */
340 #define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */
342 #define bus_space_read_1(t, h, o) \
343 (t)->ab_ops->abo_read_1(t, (h)+(o))
344 #define bus_space_read_2(t, h, o) \
345 (t)->ab_ops->abo_read_2(t, (h)+(o))
346 #define bus_space_read_4(t, h, o) \
347 (t)->ab_ops->abo_read_4(t, (h)+(o))
348 #define bus_space_read_multi_1(t, h, o, a, c) \
349 (t)->ab_ops->abo_read_multi_1(t, (h)+(o), a, c)
350 #define bus_space_read_multi_2(t, h, o, a, c) \
351 (t)->ab_ops->abo_read_multi_2(t, (h)+(o), a, c)
352 #define bus_space_read_multi_4(t, h, o, a, c) \
353 (t)->ab_ops->abo_read_multi_4(t, (h)+(o), a, c)
354 #define bus_space_read_region_1(t, h, o, a, c) \
355 (t)->ab_ops->abo_read_region_1(t, (h)+(o), a, c)
356 #define bus_space_read_region_2(t, h, o, a, c) \
357 (t)->ab_ops->abo_read_region_2(t, (h)+(o), a, c)
358 #define bus_space_read_region_4(t, h, o, a, c) \
359 (t)->ab_ops->abo_read_region_4(t, (h)+(o), a, c)
361 #define bus_space_write_1(t, h, o, v) \
362 (t)->ab_ops->abo_write_1(t, (h)+(o), v)
363 #define bus_space_write_2(t, h, o, v) \
364 (t)->ab_ops->abo_write_2(t, (h)+(o), v)
365 #define bus_space_write_4(t, h, o, v) \
366 (t)->ab_ops->abo_write_4(t, (h)+(o), v)
367 #define bus_space_write_multi_1(t, h, o, a, c) \
368 (t)->ab_ops->abo_write_multi_1(t, (h)+(o), a, c)
369 #define bus_space_write_multi_2(t, h, o, a, c) \
370 (t)->ab_ops->abo_write_multi_2(t, (h)+(o), a, c)
371 #define bus_space_write_multi_4(t, h, o, a, c) \
372 (t)->ab_ops->abo_write_multi_4(t, (h)+(o), a, c)
373 #define bus_space_write_region_1(t, h, o, a, c) \
374 (t)->ab_ops->abo_write_region_1(t, (h)+(o), a, c)
375 #define bus_space_write_region_2(t, h, o, a, c) \
376 (t)->ab_ops->abo_write_region_2(t, (h)+(o), a, c)
377 #define bus_space_write_region_4(t, h, o, a, c) \
378 (t)->ab_ops->abo_write_region_4(t, (h)+(o), a, c)
379 #define bus_space_set_multi_1(t, h, o, v, c) \
380 (t)->ab_ops->abo_set_multi_1(t, (h)+(o), v, c)
381 #define bus_space_set_multi_2(t, h, o, v, c) \
382 (t)->ab_ops->abo_set_multi_2(t, (h)+(o), v, c)
383 #define bus_space_set_multi_4(t, h, o, v, c) \
384 (t)->ab_ops->abo_set_multi_4(t, (h)+(o), v, c)
385 #define bus_space_set_region_1(t, h, o, v, c) \
386 (t)->ab_ops->abo_set_region_1(t, (h)+(o), v, c)
387 #define bus_space_set_region_2(t, h, o, v, c) \
388 (t)->ab_ops->abo_set_region_2(t, (h)+(o), v, c)
389 #define bus_space_set_region_4(t, h, o, v, c) \
390 (t)->ab_ops->abo_set_region_4(t, (h)+(o), v, c)
392 #define bus_space_copy_region_1(t, h1, o1, h2, o2, c) \
393 (t)->ab_ops->abo_copy_region_1(t, (h1)+(o1), (h2)+(o2), c)
394 #define bus_space_copy_region_2(t, h1, o1, h2, o2, c) \
395 (t)->ab_ops->abo_copy_region_2(t, (h1)+(o1), (h2)+(o2), c)
396 #define bus_space_copy_region_4(t, h1, o1, h2, o2, c) \
397 (t)->ab_ops->abo_copy_region_4(t, (h1)+(o1), (h2)+(o2), c)
399 #define bus_space_barrier(t, h, o, l, f) \
400 (t)->ab_ops->abo_barrier(t, (h)+(o), l, f)
403 * Stream accesses are the same as normal accesses on alpha; there are no
404 * supported bus systems with an endianess different from the host one.
406 #define bus_space_read_stream_1(t, h, o) bus_space_read_1((t), (h), (o))
407 #define bus_space_read_stream_2(t, h, o) bus_space_read_2((t), (h), (o))
408 #define bus_space_read_stream_4(t, h, o) bus_space_read_4((t), (h), (o))
410 #define bus_space_read_multi_stream_1(t, h, o, a, c) \
411 bus_space_read_multi_1((t), (h), (o), (a), (c))
412 #define bus_space_read_multi_stream_2(t, h, o, a, c) \
413 bus_space_read_multi_2((t), (h), (o), (a), (c))
414 #define bus_space_read_multi_stream_4(t, h, o, a, c) \
415 bus_space_read_multi_4((t), (h), (o), (a), (c))
417 #define bus_space_write_stream_1(t, h, o, v) \
418 bus_space_write_1((t), (h), (o), (v))
419 #define bus_space_write_stream_2(t, h, o, v) \
420 bus_space_write_2((t), (h), (o), (v))
421 #define bus_space_write_stream_4(t, h, o, v) \
422 bus_space_write_4((t), (h), (o), (v))
424 #define bus_space_write_multi_stream_1(t, h, o, a, c) \
425 bus_space_write_multi_1((t), (h), (o), (a), (c))
426 #define bus_space_write_multi_stream_2(t, h, o, a, c) \
427 bus_space_write_multi_2((t), (h), (o), (a), (c))
428 #define bus_space_write_multi_stream_4(t, h, o, a, c) \
429 bus_space_write_multi_4((t), (h), (o), (a), (c))
431 #define bus_space_set_multi_stream_1(t, h, o, v, c) \
432 bus_space_set_multi_1((t), (h), (o), (v), (c))
433 #define bus_space_set_multi_stream_2(t, h, o, v, c) \
434 bus_space_set_multi_2((t), (h), (o), (v), (c))
435 #define bus_space_set_multi_stream_4(t, h, o, v, c) \
436 bus_space_set_multi_4((t), (h), (o), (v), (c))
438 #define bus_space_read_region_stream_1(t, h, o, a, c) \
439 bus_space_read_region_1((t), (h), (o), (a), (c))
440 #define bus_space_read_region_stream_2(t, h, o, a, c) \
441 bus_space_read_region_2((t), (h), (o), (a), (c))
442 #define bus_space_read_region_stream_4(t, h, o, a, c) \
443 bus_space_read_region_4((t), (h), (o), (a), (c))
445 #define bus_space_write_region_stream_1(t, h, o, a, c) \
446 bus_space_write_region_1((t), (h), (o), (a), (c))
447 #define bus_space_write_region_stream_2(t, h, o, a, c) \
448 bus_space_write_region_2((t), (h), (o), (a), (c))
449 #define bus_space_write_region_stream_4(t, h, o, a, c) \
450 bus_space_write_region_4((t), (h), (o), (a), (c))
452 #define bus_space_set_region_stream_1(t, h, o, v, c) \
453 bus_space_set_region_1((t), (h), (o), (v), (c))
454 #define bus_space_set_region_stream_2(t, h, o, v, c) \
455 bus_space_set_region_2((t), (h), (o), (v), (c))
456 #define bus_space_set_region_stream_4(t, h, o, v, c) \
457 bus_space_set_region_4((t), (h), (o), (v), (c))
459 #define bus_space_copy_region_stream_1(t, h1, o1, h2, o2, c) \
460 bus_space_copy_region_1((t), (h1), (o1), (h2), (o2), (c))
461 #define bus_space_copy_region_stream_2(t, h1, o1, h2, o2, c) \
462 bus_space_copy_region_2((t), (h1), (o1), (h2), (o2), (c))
463 #define bus_space_copy_region_stream_4(t, h1, o1, h2, o2, c) \
464 bus_space_copy_region_4((t), (h1), (o1), (h2), (o2), (c))
467 * Flags used in various bus DMA methods.
469 #define BUS_DMA_WAITOK 0x00 /* safe to sleep (pseudo-flag) */
470 #define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */
471 #define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */
472 #define BUS_DMAMEM_NOSYNC 0x04 /* map memory to not require sync */
473 #define BUS_DMA_ISA 0x10 /* map memory for ISA dma */
474 #define BUS_DMA_BUS2 0x20 /* placeholders for bus functions... */
475 #define BUS_DMA_BUS3 0x40
476 #define BUS_DMA_BUS4 0x80
478 /* Forwards needed by prototypes below. */
485 * Operations performed by bus_dmamap_sync().
489 BUS_DMASYNC_POSTREAD,
490 BUS_DMASYNC_PREWRITE,
491 BUS_DMASYNC_POSTWRITE
497 * A machine-dependent opaque type describing the characteristics
498 * of how to perform DMA mappings. This structure encapsultes
499 * information concerning address and alignment restrictions, number
500 * of S/G segments, amount of data per S/G segment, etc.
502 typedef struct bus_dma_tag *bus_dma_tag_t;
507 * DMA mapping instance information.
509 typedef struct bus_dmamap *bus_dmamap_t;
514 * Describes a single contiguous DMA transaction. Values
515 * are suitable for programming into DMA registers.
517 typedef struct bus_dma_segment {
518 bus_addr_t ds_addr; /* DMA address */
519 bus_size_t ds_len; /* length of transfer */
523 * A function that returns 1 if the address cannot be accessed by
524 * a device and 0 if it can be.
526 typedef int bus_dma_filter_t(void *, bus_addr_t);
529 * Allocate a device specific dma_tag encapsulating the constraints of
530 * the parent tag in addition to other restrictions specified:
532 * alignment: alignment for segments.
533 * boundary: Boundary that segments cannot cross.
534 * lowaddr: Low restricted address that cannot appear in a mapping.
535 * highaddr: High restricted address that cannot appear in a mapping.
536 * filtfunc: An optional function to further test if an address
537 * within the range of lowaddr and highaddr cannot appear
539 * filtfuncarg: An argument that will be passed to filtfunc in addition
540 * to the address to test.
541 * maxsize: Maximum mapping size supported by this tag.
542 * nsegments: Number of discontinuities allowed in maps.
543 * maxsegsz: Maximum size of a segment in the map.
544 * flags: Bus DMA flags.
545 * dmat: A pointer to set to a valid dma tag should the return
546 * value of this function indicate success.
548 /* XXX Should probably allow specification of alignment */
549 int bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignemnt,
550 bus_size_t boundary, bus_addr_t lowaddr,
551 bus_addr_t highaddr, bus_dma_filter_t *filtfunc,
552 void *filtfuncarg, bus_size_t maxsize, int nsegments,
553 bus_size_t maxsegsz, int flags, bus_dma_tag_t *dmat);
555 int bus_dma_tag_destroy(bus_dma_tag_t dmat);
558 * Allocate a handle for mapping from kva/uva/physical
559 * address space into bus device space.
561 int bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp);
564 * Destroy a handle for mapping from kva/uva/physical
565 * address space into bus device space.
567 int bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map);
570 * Allocate a piece of memory that can be efficiently mapped into
571 * bus device space based on the constraints lited in the dma tag.
572 * A dmamap to for use with dmamap_load is also allocated.
574 int bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
578 * Free a piece of memory and it's allociated dmamap, that was allocated
579 * via bus_dmamem_alloc.
581 void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map);
584 * A function that processes a successfully loaded dma map or an error
585 * from a delayed load map.
587 typedef void bus_dmamap_callback_t(void *, bus_dma_segment_t *, int, int);
590 * Map the buffer buf into bus space using the dmamap map.
592 int bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
593 bus_size_t buflen, bus_dmamap_callback_t *callback,
594 void *callback_arg, int flags);
597 * Like bus_dmamap_callback but includes map size in bytes. This is
598 * defined as a separate interface to maintain compatiiblity for users
599 * of bus_dmamap_callback_t--at some point these interfaces should be merged.
601 typedef void bus_dmamap_callback2_t(void *, bus_dma_segment_t *, int, bus_size_t, int);
603 * Like bus_dmamap_load but for mbufs. Note the use of the
604 * bus_dmamap_callback2_t interface.
606 int bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map,
608 bus_dmamap_callback2_t *callback, void *callback_arg,
611 * Like bus_dmamap_load but for uios. Note the use of the
612 * bus_dmamap_callback2_t interface.
614 int bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map,
616 bus_dmamap_callback2_t *callback, void *callback_arg,
620 * Perform a syncronization operation on the given map.
622 void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t);
623 #define bus_dmamap_sync(dmat, dmamap, op) \
624 if ((dmamap) != NULL) \
625 _bus_dmamap_sync(dmat, dmamap, op)
628 * Release the mapping held by map.
630 void _bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map);
631 #define bus_dmamap_unload(dmat, dmamap) \
632 if ((dmamap) != NULL) \
633 _bus_dmamap_unload(dmat, dmamap)
635 #endif /* _ALPHA_BUS_H_ */