1 /* $NetBSD: bus.h,v 1.7 1999/01/06 04:18:53 nisimura 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 73 int 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 83 void 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 93 int 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 105 int 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 117 void 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) \ 154 static __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 \ 158 static __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) \ 192 static __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 \ 196 static __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) \ 231 do { \ 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) \ 238 do { \ 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) \ 245 do { \ 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) \ 265 static __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 \ 269 static __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) \ 303 static __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 \ 307 static __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) \ 343 static __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 \ 347 static __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) \ 381 static __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 \ 385 static __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) \ 422 static __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 \ 428 static __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 /* 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