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