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