bus.h revision 1.8
1/* $NetBSD: bus.h,v 1.8 1999/03/23 21:29:05 drochner Exp $ */ 2 3/*- 4 * Copyright (c) 1996, 1997, 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#ifndef _PMAX_BUS_H_ 41#define _PMAX_BUS_H_ 42 43#include <mips/locore.h> 44 45/* 46 * Utility macros; do not use outside this file. 47 */ 48#define __PB_TYPENAME_PREFIX(BITS) ___CONCAT(u_int,BITS) 49#define __PB_TYPENAME(BITS) ___CONCAT(__PB_TYPENAME_PREFIX(BITS),_t) 50 51/* 52 * Bus address and size types 53 */ 54typedef u_long bus_addr_t; 55typedef u_long bus_size_t; 56 57/* 58 * Access methods for bus resources and address space. 59 */ 60typedef int bus_space_tag_t; 61typedef u_long bus_space_handle_t; 62 63/* 64 * int bus_space_map __P((bus_space_tag_t t, bus_addr_t addr, 65 * bus_size_t size, int flags, bus_space_handle_t *bshp)); 66 * 67 * Map a region of bus space. 68 */ 69 70#define BUS_SPACE_MAP_CACHEABLE 0x01 71#define BUS_SPACE_MAP_LINEAR 0x02 72 73int bus_space_map __P((bus_space_tag_t, bus_addr_t, bus_size_t, 74 int, bus_space_handle_t *)); 75 76/* 77 * void bus_space_unmap __P((bus_space_tag_t t, 78 * bus_space_handle_t bsh, bus_size_t size)); 79 * 80 * Unmap a region of bus space. 81 */ 82 83void bus_space_unmap __P((bus_space_tag_t, bus_space_handle_t, bus_size_t)); 84 85/* 86 * int bus_space_subregion __P((bus_space_tag_t t, 87 * bus_space_handle_t bsh, bus_size_t offset, bus_size_t size, 88 * bus_space_handle_t *nbshp)); 89 * 90 * Get a new handle for a subregion of an already-mapped area of bus space. 91 */ 92 93int bus_space_subregion __P((bus_space_tag_t t, bus_space_handle_t bsh, 94 bus_size_t offset, bus_size_t size, bus_space_handle_t *nbshp)); 95 96/* 97 * int bus_space_alloc __P((bus_space_tag_t t, bus_addr_t, rstart, 98 * bus_addr_t rend, bus_size_t size, bus_size_t align, 99 * bus_size_t boundary, int flags, bus_addr_t *addrp, 100 * bus_space_handle_t *bshp)); 101 * 102 * Allocate a region of bus space. 103 */ 104 105int bus_space_alloc __P((bus_space_tag_t t, bus_addr_t rstart, 106 bus_addr_t rend, bus_size_t size, bus_size_t align, 107 bus_size_t boundary, int cacheable, bus_addr_t *addrp, 108 bus_space_handle_t *bshp)); 109 110/* 111 * int bus_space_free __P((bus_space_tag_t t, 112 * bus_space_handle_t bsh, bus_size_t size)); 113 * 114 * Free a region of bus space. 115 */ 116 117void bus_space_free __P((bus_space_tag_t t, bus_space_handle_t bsh, 118 bus_size_t size)); 119 120/* 121 * u_intN_t bus_space_read_N __P((bus_space_tag_t tag, 122 * bus_space_handle_t bsh, bus_size_t offset)); 123 * 124 * Read a 1, 2, 4, or 8 byte quantity from bus space 125 * described by tag/handle/offset. 126 */ 127 128#define bus_space_read_1(t, h, o) \ 129 (wbflush(), /* XXX */ \ 130 (void) t, (*(volatile u_int8_t *)((h) + (o)))) 131 132#define bus_space_read_2(t, h, o) \ 133 (wbflush(), /* XXX */ \ 134 (void) t, (*(volatile u_int16_t *)((h) + (o)))) 135 136#define bus_space_read_4(t, h, o) \ 137 (wbflush(), /* XXX */ \ 138 (void) t, (*(volatile u_int32_t *)((h) + (o)))) 139 140#if 0 /* Cause a link error for bus_space_read_8 */ 141#define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!! 142#endif 143 144/* 145 * void bus_space_read_multi_N __P((bus_space_tag_t tag, 146 * bus_space_handle_t bsh, bus_size_t offset, 147 * u_intN_t *addr, size_t count)); 148 * 149 * Read `count' 1, 2, 4, or 8 byte quantities from bus space 150 * described by tag/handle/offset and copy into buffer provided. 151 */ 152 153#define __PMAX_bus_space_read_multi(BYTES,BITS) \ 154static __inline void __CONCAT(bus_space_read_multi_,BYTES) \ 155 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, \ 156 __PB_TYPENAME(BITS) *, size_t)); \ 157 \ 158static __inline void \ 159__CONCAT(bus_space_read_multi_,BYTES)(t, h, o, a, c) \ 160 bus_space_tag_t t; \ 161 bus_space_handle_t h; \ 162 bus_size_t o; \ 163 __PB_TYPENAME(BITS) *a; \ 164 size_t c; \ 165{ \ 166 \ 167 while (c--) \ 168 *a++ = __CONCAT(bus_space_read_,BYTES)(t, h, o); \ 169} 170 171__PMAX_bus_space_read_multi(1,8) 172__PMAX_bus_space_read_multi(2,16) 173__PMAX_bus_space_read_multi(4,32) 174 175#if 0 /* Cause a link error for bus_space_read_multi_8 */ 176#define bus_space_read_multi_8 !!! bus_space_read_multi_8 unimplemented !!! 177#endif 178 179#undef __PMAX_bus_space_read_multi 180 181/* 182 * void bus_space_read_region_N __P((bus_space_tag_t tag, 183 * bus_space_handle_t bsh, bus_size_t offset, 184 * u_intN_t *addr, size_t count)); 185 * 186 * Read `count' 1, 2, 4, or 8 byte quantities from bus space 187 * described by tag/handle and starting at `offset' and copy into 188 * buffer provided. 189 */ 190 191#define __PMAX_bus_space_read_region(BYTES,BITS) \ 192static __inline void __CONCAT(bus_space_read_region_,BYTES) \ 193 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, \ 194 __PB_TYPENAME(BITS) *, size_t)); \ 195 \ 196static __inline void \ 197__CONCAT(bus_space_read_region_,BYTES)(t, h, o, a, c) \ 198 bus_space_tag_t t; \ 199 bus_space_handle_t h; \ 200 bus_size_t o; \ 201 __PB_TYPENAME(BITS) *a; \ 202 size_t c; \ 203{ \ 204 \ 205 while (c--) { \ 206 *a++ = __CONCAT(bus_space_read_,BYTES)(t, h, o); \ 207 o += BYTES; \ 208 } \ 209} 210 211__PMAX_bus_space_read_region(1,8) 212__PMAX_bus_space_read_region(2,16) 213__PMAX_bus_space_read_region(4,32) 214 215#if 0 /* Cause a link error for bus_space_read_region_8 */ 216#define bus_space_read_region_8 !!! bus_space_read_region_8 unimplemented !!! 217#endif 218 219#undef __PMAX_bus_space_read_region 220 221/* 222 * void bus_space_write_N __P((bus_space_tag_t tag, 223 * bus_space_handle_t bsh, bus_size_t offset, 224 * u_intN_t value)); 225 * 226 * Write the 1, 2, 4, or 8 byte value `value' to bus space 227 * described by tag/handle/offset. 228 */ 229 230#define bus_space_write_1(t, h, o, v) \ 231do { \ 232 (void) t; \ 233 *(volatile u_int8_t *)((h) + (o)) = (v); \ 234 wbflush(); /* XXX */ \ 235} while (0) 236 237#define bus_space_write_2(t, h, o, v) \ 238do { \ 239 (void) t; \ 240 *(volatile u_int16_t *)((h) + (o)) = (v); \ 241 wbflush(); /* XXX */ \ 242} while (0) 243 244#define bus_space_write_4(t, h, o, v) \ 245do { \ 246 (void) t; \ 247 *(volatile u_int32_t *)((h) + (o)) = (v); \ 248 wbflush(); /* XXX */ \ 249} while (0) 250 251#if 0 /* Cause a link error for bus_space_write_8 */ 252#define bus_space_write_8 !!! bus_space_write_8 not implemented !!! 253#endif 254 255/* 256 * void bus_space_write_multi_N __P((bus_space_tag_t tag, 257 * bus_space_handle_t bsh, bus_size_t offset, 258 * const u_intN_t *addr, size_t count)); 259 * 260 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer 261 * provided to bus space described by tag/handle/offset. 262 */ 263 264#define __PMAX_bus_space_write_multi(BYTES,BITS) \ 265static __inline void __CONCAT(bus_space_write_multi_,BYTES) \ 266 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, \ 267 __PB_TYPENAME(BITS) *, size_t)); \ 268 \ 269static __inline void \ 270__CONCAT(bus_space_write_multi_,BYTES)(t, h, o, a, c) \ 271 bus_space_tag_t t; \ 272 bus_space_handle_t h; \ 273 bus_size_t o; \ 274 __PB_TYPENAME(BITS) *a; \ 275 size_t c; \ 276{ \ 277 \ 278 while (c--) \ 279 __CONCAT(bus_space_write_,BYTES)(t, h, o, *a++); \ 280} 281 282__PMAX_bus_space_write_multi(1,8) 283__PMAX_bus_space_write_multi(2,16) 284__PMAX_bus_space_write_multi(4,32) 285 286#if 0 /* Cause a link error for bus_space_write_8 */ 287#define bus_space_write_multi_8(t, h, o, a, c) \ 288 !!! bus_space_write_multi_8 unimplimented !!! 289#endif 290 291#undef __PMAX_bus_space_write_multi 292 293/* 294 * void bus_space_write_region_N __P((bus_space_tag_t tag, 295 * bus_space_handle_t bsh, bus_size_t offset, 296 * const u_intN_t *addr, size_t count)); 297 * 298 * Write `count' 1, 2, 4, or 8 byte quantities from the buffer provided 299 * to bus space described by tag/handle starting at `offset'. 300 */ 301 302#define __PMAX_bus_space_write_region(BYTES,BITS) \ 303static __inline void __CONCAT(bus_space_write_region_,BYTES) \ 304 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, \ 305 __PB_TYPENAME(BITS) *, size_t)); \ 306 \ 307static __inline void \ 308__CONCAT(bus_space_write_region_,BYTES)(t, h, o, a, c) \ 309 bus_space_tag_t t; \ 310 bus_space_handle_t h; \ 311 bus_size_t o; \ 312 __PB_TYPENAME(BITS) *a; \ 313 size_t c; \ 314{ \ 315 \ 316 while (c--) { \ 317 __CONCAT(bus_space_write_,BYTES)(t, h, o, *a++); \ 318 o += BYTES; \ 319 } \ 320} 321 322__PMAX_bus_space_write_region(1,8) 323__PMAX_bus_space_write_region(2,16) 324__PMAX_bus_space_write_region(4,32) 325 326#if 0 /* Cause a link error for bus_space_write_region_8 */ 327#define bus_space_write_region_8 \ 328 !!! bus_space_write_region_8 unimplemented !!! 329#endif 330 331#undef __PMAX_bus_space_write_region 332 333/* 334 * void bus_space_set_multi_N __P((bus_space_tag_t tag, 335 * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val, 336 * size_t count)); 337 * 338 * Write the 1, 2, 4, or 8 byte value `val' to bus space described 339 * by tag/handle/offset `count' times. 340 */ 341 342#define __PMAX_bus_space_set_multi(BYTES,BITS) \ 343static __inline void __CONCAT(bus_space_set_multi_,BYTES) \ 344 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, \ 345 __PB_TYPENAME(BITS), size_t)); \ 346 \ 347static __inline void \ 348__CONCAT(bus_space_set_multi_,BYTES)(t, h, o, v, c) \ 349 bus_space_tag_t t; \ 350 bus_space_handle_t h; \ 351 bus_size_t o; \ 352 __PB_TYPENAME(BITS) v; \ 353 size_t c; \ 354{ \ 355 \ 356 while (c--) \ 357 __CONCAT(bus_space_write_,BYTES)(t, h, o, v); \ 358} 359 360__PMAX_bus_space_set_multi(1,8) 361__PMAX_bus_space_set_multi(2,16) 362__PMAX_bus_space_set_multi(4,32) 363 364#if 0 /* Cause a link error for bus_space_set_multi_8 */ 365#define bus_space_set_multi_8 \ 366 !!! bus_space_set_multi_8 unimplemented !!! 367#endif 368 369#undef __PMAX_bus_space_set_multi 370 371/* 372 * void bus_space_set_region_N __P((bus_space_tag_t tag, 373 * bus_space_handle_t bsh, bus_size_t offset, u_intN_t val, 374 * size_t count)); 375 * 376 * Write `count' 1, 2, 4, or 8 byte value `val' to bus space described 377 * by tag/handle starting at `offset'. 378 */ 379 380#define __PMAX_bus_space_set_region(BYTES,BITS) \ 381static __inline void __CONCAT(bus_space_set_region_,BYTES) \ 382 __P((bus_space_tag_t, bus_space_handle_t, bus_size_t, \ 383 __PB_TYPENAME(BITS), size_t)); \ 384 \ 385static __inline void \ 386__CONCAT(bus_space_set_region_,BYTES)(t, h, o, v, c) \ 387 bus_space_tag_t t; \ 388 bus_space_handle_t h; \ 389 bus_size_t o; \ 390 __PB_TYPENAME(BITS) v; \ 391 size_t c; \ 392{ \ 393 \ 394 while (c--) { \ 395 __CONCAT(bus_space_write_,BYTES)(t, h, o, v); \ 396 o += BYTES; \ 397 } \ 398} 399 400__PMAX_bus_space_set_region(1,8) 401__PMAX_bus_space_set_region(2,16) 402__PMAX_bus_space_set_region(4,32) 403 404#if 0 /* Cause a link error for bus_space_set_region_8 */ 405#define bus_space_set_region_8 \ 406 !!! bus_space_set_region_8 unimplemented !!! 407#endif 408 409#undef __PMAX_bus_space_set_region 410 411/* 412 * void bus_space_copy_region_N __P((bus_space_tag_t tag, 413 * bus_space_handle_t bsh1, bus_size_t off1, 414 * bus_space_handle_t bsh2, bus_size_t off2, 415 * bus_size_t count)); 416 * 417 * Copy `count' 1, 2, 4, or 8 byte values from bus space starting 418 * at tag/bsh1/off1 to bus space starting at tag/bsh2/off2. 419 */ 420 421#define __PMAX_copy_region(BYTES) \ 422static __inline void __CONCAT(bus_space_copy_region_,BYTES) \ 423 __P((bus_space_tag_t, \ 424 bus_space_handle_t bsh1, bus_size_t off1, \ 425 bus_space_handle_t bsh2, bus_size_t off2, \ 426 bus_size_t count)); \ 427 \ 428static __inline void \ 429__CONCAT(bus_space_copy_region_,BYTES)(t, h1, o1, h2, o2, c) \ 430 bus_space_tag_t t; \ 431 bus_space_handle_t h1, h2; \ 432 bus_size_t o1, o2, c; \ 433{ \ 434 bus_size_t o; \ 435 \ 436 if ((h1 + o1) >= (h2 + o2)) { \ 437 /* src after dest: copy forward */ \ 438 for (o = 0; c != 0; c--, o += BYTES) \ 439 __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \ 440 __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \ 441 } else { \ 442 /* dest after src: copy backwards */ \ 443 for (o = (c - 1) * BYTES; c != 0; c--, o -= BYTES) \ 444 __CONCAT(bus_space_write_,BYTES)(t, h2, o2 + o, \ 445 __CONCAT(bus_space_read_,BYTES)(t, h1, o1 + o)); \ 446 } \ 447} 448 449__PMAX_copy_region(1) 450__PMAX_copy_region(2) 451__PMAX_copy_region(4) 452 453#if 0 /* Cause a link error for bus_space_copy_region_8 */ 454#define bus_space_copy_region_8 \ 455 !!! bus_space_copy_region_8 unimplemented !!! 456#endif 457 458#undef __PMAX_copy_region 459 460/* 461 * Bus read/write barrier methods. 462 * 463 * void bus_space_barrier __P((bus_space_tag_t tag, 464 * bus_space_handle_t bsh, bus_size_t offset, 465 * bus_size_t len, int flags)); 466 * 467 * On the MIPS, we just flush the write buffer. 468 */ 469#define bus_space_barrier(t, h, o, l, f) \ 470 ((void)((void)(t), (void)(h), (void)(o), (void)(l), (void)(f)), \ 471 wbflush()) 472#define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */ 473#define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */ 474 475#undef __PB_TYPENAME_PREFIX 476#undef __PB_TYPENAME 477 478#define BUS_SPACE_ALIGNED_POINTER(p, t) ALIGNED_POINTER(p, t) 479 480/* 481 * Flags used in various bus DMA methods. 482 */ 483#define BUS_DMA_WAITOK 0x00 /* safe to sleep (pseudo-flag) */ 484#define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */ 485#define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */ 486#define BUS_DMA_COHERENT 0x04 /* hint: map memory DMA coherent */ 487#define BUS_DMA_BUS1 0x10 /* placeholders for bus functions... */ 488#define BUS_DMA_BUS2 0x20 489#define BUS_DMA_BUS3 0x40 490#define BUS_DMA_BUS4 0x80 491 492#define PMAX_DMAMAP_COHERENT 0x100 /* no cache flush necessary on sync */ 493 494/* Forwards needed by prototypes below. */ 495struct mbuf; 496struct uio; 497 498/* 499 * Operations performed by bus_dmamap_sync(). 500 */ 501#define BUS_DMASYNC_PREREAD 0x01 /* pre-read synchronization */ 502#define BUS_DMASYNC_POSTREAD 0x02 /* post-read synchronization */ 503#define BUS_DMASYNC_PREWRITE 0x04 /* pre-write synchronization */ 504#define BUS_DMASYNC_POSTWRITE 0x08 /* post-write synchronization */ 505 506typedef struct pmax_bus_dma_tag *bus_dma_tag_t; 507typedef struct pmax_bus_dmamap *bus_dmamap_t; 508 509/* 510 * bus_dma_segment_t 511 * 512 * Describes a single contiguous DMA transaction. Values 513 * are suitable for programming into DMA registers. 514 */ 515struct pmax_bus_dma_segment { 516 bus_addr_t ds_addr; /* DMA address */ 517 bus_size_t ds_len; /* length of transfer */ 518 bus_addr_t _ds_vaddr; /* virtual address, 0 if invalid */ 519}; 520typedef struct pmax_bus_dma_segment bus_dma_segment_t; 521 522/* 523 * bus_dma_tag_t 524 * 525 * A machine-dependent opaque type describing the implementation of 526 * DMA for a given bus. 527 */ 528 529struct pmax_bus_dma_tag { 530 /* 531 * DMA mapping methods. 532 */ 533 int (*_dmamap_create) __P((bus_dma_tag_t, bus_size_t, int, 534 bus_size_t, bus_size_t, int, bus_dmamap_t *)); 535 void (*_dmamap_destroy) __P((bus_dma_tag_t, bus_dmamap_t)); 536 int (*_dmamap_load) __P((bus_dma_tag_t, bus_dmamap_t, void *, 537 bus_size_t, struct proc *, int)); 538 int (*_dmamap_load_mbuf) __P((bus_dma_tag_t, bus_dmamap_t, 539 struct mbuf *, int)); 540 int (*_dmamap_load_uio) __P((bus_dma_tag_t, bus_dmamap_t, 541 struct uio *, int)); 542 int (*_dmamap_load_raw) __P((bus_dma_tag_t, bus_dmamap_t, 543 bus_dma_segment_t *, int, bus_size_t, int)); 544 void (*_dmamap_unload) __P((bus_dma_tag_t, bus_dmamap_t)); 545 void (*_dmamap_sync) __P((bus_dma_tag_t, bus_dmamap_t, 546 bus_addr_t, bus_size_t, int)); 547 548 /* 549 * DMA memory utility functions. 550 */ 551 int (*_dmamem_alloc) __P((bus_dma_tag_t, bus_size_t, bus_size_t, 552 bus_size_t, bus_dma_segment_t *, int, int *, int)); 553 void (*_dmamem_free) __P((bus_dma_tag_t, 554 bus_dma_segment_t *, int)); 555 int (*_dmamem_map) __P((bus_dma_tag_t, bus_dma_segment_t *, 556 int, size_t, caddr_t *, int)); 557 void (*_dmamem_unmap) __P((bus_dma_tag_t, caddr_t, size_t)); 558 int (*_dmamem_mmap) __P((bus_dma_tag_t, bus_dma_segment_t *, 559 int, int, int, int)); 560}; 561 562#define bus_dmamap_create(t, s, n, m, b, f, p) \ 563 (*(t)->_dmamap_create)((t), (s), (n), (m), (b), (f), (p)) 564#define bus_dmamap_destroy(t, p) \ 565 (*(t)->_dmamap_destroy)((t), (p)) 566#define bus_dmamap_load(t, m, b, s, p, f) \ 567 (*(t)->_dmamap_load)((t), (m), (b), (s), (p), (f)) 568#define bus_dmamap_load_mbuf(t, m, b, f) \ 569 (*(t)->_dmamap_load_mbuf)((t), (m), (b), (f)) 570#define bus_dmamap_load_uio(t, m, u, f) \ 571 (*(t)->_dmamap_load_uio)((t), (m), (u), (f)) 572#define bus_dmamap_load_raw(t, m, sg, n, s, f) \ 573 (*(t)->_dmamap_load_raw)((t), (m), (sg), (n), (s), (f)) 574#define bus_dmamap_unload(t, p) \ 575 (*(t)->_dmamap_unload)((t), (p)) 576#define bus_dmamap_sync(t, p, o, l, ops) \ 577 (*(t)->_dmamap_sync)((t), (p), (o), (l), (ops)) 578 579#define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \ 580 (*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f)) 581#define bus_dmamem_free(t, sg, n) \ 582 (*(t)->_dmamem_free)((t), (sg), (n)) 583#define bus_dmamem_map(t, sg, n, s, k, f) \ 584 (*(t)->_dmamem_map)((t), (sg), (n), (s), (k), (f)) 585#define bus_dmamem_unmap(t, k, s) \ 586 (*(t)->_dmamem_unmap)((t), (k), (s)) 587#define bus_dmamem_mmap(t, sg, n, o, p, f) \ 588 (*(t)->_dmamem_mmap)((t), (sg), (n), (o), (p), (f)) 589 590/* 591 * bus_dmamap_t 592 * 593 * Describes a DMA mapping. 594 */ 595struct pmax_bus_dmamap { 596 /* 597 * PRIVATE MEMBERS: not for use my machine-independent code. 598 */ 599 bus_size_t _dm_size; /* largest DMA transfer mappable */ 600 int _dm_segcnt; /* number of segs this map can map */ 601 bus_size_t _dm_maxsegsz; /* largest possible segment */ 602 bus_size_t _dm_boundary; /* don't cross this */ 603 int _dm_flags; /* misc. flags */ 604 605 /* 606 * PUBLIC MEMBERS: these are used by machine-independent code. 607 */ 608 bus_size_t dm_mapsize; /* size of the mapping */ 609 int dm_nsegs; /* # valid segments in mapping */ 610 bus_dma_segment_t dm_segs[1]; /* segments; variable length */ 611}; 612 613#ifdef _PMAX_BUS_DMA_PRIVATE 614int _bus_dmamap_create __P((bus_dma_tag_t, bus_size_t, int, bus_size_t, 615 bus_size_t, int, bus_dmamap_t *)); 616void _bus_dmamap_destroy __P((bus_dma_tag_t, bus_dmamap_t)); 617int _bus_dmamap_load __P((bus_dma_tag_t, bus_dmamap_t, void *, 618 bus_size_t, struct proc *, int)); 619int _bus_dmamap_load_mbuf __P((bus_dma_tag_t, bus_dmamap_t, 620 struct mbuf *, int)); 621int _bus_dmamap_load_uio __P((bus_dma_tag_t, bus_dmamap_t, 622 struct uio *, int)); 623int _bus_dmamap_load_raw __P((bus_dma_tag_t, bus_dmamap_t, 624 bus_dma_segment_t *, int, bus_size_t, int)); 625void _bus_dmamap_unload __P((bus_dma_tag_t, bus_dmamap_t)); 626void _bus_dmamap_sync __P((bus_dma_tag_t, bus_dmamap_t, bus_addr_t, 627 bus_size_t, int)); 628 629int _bus_dmamem_alloc __P((bus_dma_tag_t tag, bus_size_t size, 630 bus_size_t alignment, bus_size_t boundary, 631 bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags)); 632void _bus_dmamem_free __P((bus_dma_tag_t tag, bus_dma_segment_t *segs, 633 int nsegs)); 634int _bus_dmamem_map __P((bus_dma_tag_t tag, bus_dma_segment_t *segs, 635 int nsegs, size_t size, caddr_t *kvap, int flags)); 636void _bus_dmamem_unmap __P((bus_dma_tag_t tag, caddr_t kva, 637 size_t size)); 638int _bus_dmamem_mmap __P((bus_dma_tag_t tag, bus_dma_segment_t *segs, 639 int nsegs, int off, int prot, int flags)); 640 641int _bus_dmamem_alloc_range __P((bus_dma_tag_t tag, bus_size_t size, 642 bus_size_t alignment, bus_size_t boundary, 643 bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags, 644 vaddr_t low, vaddr_t high)); 645 646extern struct pmax_bus_dma_tag pmax_default_bus_dma_tag; 647#endif /* _PMAX_BUS_DMA_PRIVATE */ 648 649#endif /* _PMAX_BUS_H_ */ 650