1 /* $OpenBSD: bus.h,v 1.6 2014/05/24 21:11:01 miod Exp $ */ 2 3 /* 4 * Copyright (c) 2003-2004 Opsycon AB Sweden. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 #ifndef _MACHINE_BUS_H_ 28 #define _MACHINE_BUS_H_ 29 30 #ifdef __STDC__ 31 #define CAT(a,b) a##b 32 #define CAT3(a,b,c) a##b##c 33 #else 34 #define CAT(a,b) a/**/b 35 #define CAT3(a,b,c) a/**/b/**/c 36 #endif 37 38 /* 39 * Bus access types. 40 */ 41 struct mips_bus_space; 42 typedef u_long bus_addr_t; 43 typedef u_long bus_size_t; 44 typedef u_long bus_space_handle_t; 45 typedef struct mips_bus_space *bus_space_tag_t; 46 47 struct mips_bus_space { 48 bus_addr_t bus_base; 49 void *bus_private; 50 u_int8_t (*_space_read_1)(bus_space_tag_t , bus_space_handle_t, 51 bus_size_t); 52 void (*_space_write_1)(bus_space_tag_t , bus_space_handle_t, 53 bus_size_t, u_int8_t); 54 u_int16_t (*_space_read_2)(bus_space_tag_t , bus_space_handle_t, 55 bus_size_t); 56 void (*_space_write_2)(bus_space_tag_t , bus_space_handle_t, 57 bus_size_t, u_int16_t); 58 u_int32_t (*_space_read_4)(bus_space_tag_t , bus_space_handle_t, 59 bus_size_t); 60 void (*_space_write_4)(bus_space_tag_t , bus_space_handle_t, 61 bus_size_t, u_int32_t); 62 u_int64_t (*_space_read_8)(bus_space_tag_t , bus_space_handle_t, 63 bus_size_t); 64 void (*_space_write_8)(bus_space_tag_t , bus_space_handle_t, 65 bus_size_t, u_int64_t); 66 void (*_space_read_raw_2)(bus_space_tag_t, bus_space_handle_t, 67 bus_addr_t, u_int8_t *, bus_size_t); 68 void (*_space_write_raw_2)(bus_space_tag_t, bus_space_handle_t, 69 bus_addr_t, const u_int8_t *, bus_size_t); 70 void (*_space_read_raw_4)(bus_space_tag_t, bus_space_handle_t, 71 bus_addr_t, u_int8_t *, bus_size_t); 72 void (*_space_write_raw_4)(bus_space_tag_t, bus_space_handle_t, 73 bus_addr_t, const u_int8_t *, bus_size_t); 74 void (*_space_read_raw_8)(bus_space_tag_t, bus_space_handle_t, 75 bus_addr_t, u_int8_t *, bus_size_t); 76 void (*_space_write_raw_8)(bus_space_tag_t, bus_space_handle_t, 77 bus_addr_t, const u_int8_t *, bus_size_t); 78 int (*_space_map)(bus_space_tag_t , bus_addr_t, 79 bus_size_t, int, bus_space_handle_t *); 80 void (*_space_unmap)(bus_space_tag_t, bus_space_handle_t, 81 bus_size_t); 82 int (*_space_subregion)(bus_space_tag_t, bus_space_handle_t, 83 bus_size_t, bus_size_t, bus_space_handle_t *); 84 void * (*_space_vaddr)(bus_space_tag_t, bus_space_handle_t); 85 paddr_t (*_space_mmap)(bus_space_tag_t, bus_addr_t, off_t, 86 int, int); 87 }; 88 89 #define bus_space_read_1(t, h, o) (*(t)->_space_read_1)((t), (h), (o)) 90 #define bus_space_read_2(t, h, o) (*(t)->_space_read_2)((t), (h), (o)) 91 #define bus_space_read_4(t, h, o) (*(t)->_space_read_4)((t), (h), (o)) 92 #define bus_space_read_8(t, h, o) (*(t)->_space_read_8)((t), (h), (o)) 93 94 #define bus_space_write_1(t, h, o, v) (*(t)->_space_write_1)((t), (h), (o), (v)) 95 #define bus_space_write_2(t, h, o, v) (*(t)->_space_write_2)((t), (h), (o), (v)) 96 #define bus_space_write_4(t, h, o, v) (*(t)->_space_write_4)((t), (h), (o), (v)) 97 #define bus_space_write_8(t, h, o, v) (*(t)->_space_write_8)((t), (h), (o), (v)) 98 99 #define bus_space_read_raw_multi_2(t, h, a, b, l) \ 100 (*(t)->_space_read_raw_2)((t), (h), (a), (b), (l)) 101 #define bus_space_read_raw_multi_4(t, h, a, b, l) \ 102 (*(t)->_space_read_raw_4)((t), (h), (a), (b), (l)) 103 #define bus_space_read_raw_multi_8(t, h, a, b, l) \ 104 (*(t)->_space_read_raw_8)((t), (h), (a), (b), (l)) 105 106 #define bus_space_write_raw_multi_2(t, h, a, b, l) \ 107 (*(t)->_space_write_raw_2)((t), (h), (a), (b), (l)) 108 #define bus_space_write_raw_multi_4(t, h, a, b, l) \ 109 (*(t)->_space_write_raw_4)((t), (h), (a), (b), (l)) 110 #define bus_space_write_raw_multi_8(t, h, a, b, l) \ 111 (*(t)->_space_write_raw_8)((t), (h), (a), (b), (l)) 112 113 #define bus_space_map(t, o, s, c, p) (*(t)->_space_map)((t), (o), (s), (c), (p)) 114 #define bus_space_unmap(t, h, s) (*(t)->_space_unmap)((t), (h), (s)) 115 #define bus_space_subregion(t, h, o, s, p) \ 116 (*(t)->_space_subregion)((t), (h), (o), (s), (p)) 117 118 #define BUS_SPACE_MAP_CACHEABLE 0x01 119 #define BUS_SPACE_MAP_LINEAR 0x02 120 #define BUS_SPACE_MAP_PREFETCHABLE 0x04 121 122 #define bus_space_vaddr(t, h) (*(t)->_space_vaddr)((t), (h)) 123 #define bus_space_mmap(t, a, o, p, f) \ 124 (*(t)->_space_mmap)((t), (a), (o), (p), (f)) 125 126 /*----------------------------------------------------------------------------*/ 127 #define bus_space_read_multi(n,m) \ 128 static __inline void \ 129 CAT(bus_space_read_multi_,n)(bus_space_tag_t bst, bus_space_handle_t bsh, \ 130 bus_size_t o, CAT3(u_int,m,_t) *x, size_t cnt) \ 131 { \ 132 while (cnt--) \ 133 *x++ = CAT(bus_space_read_,n)(bst, bsh, o); \ 134 } 135 136 bus_space_read_multi(1,8) 137 bus_space_read_multi(2,16) 138 bus_space_read_multi(4,32) 139 bus_space_read_multi(8,64) 140 141 /*----------------------------------------------------------------------------*/ 142 #define bus_space_read_region(n,m) \ 143 static __inline void \ 144 CAT(bus_space_read_region_,n)(bus_space_tag_t bst, bus_space_handle_t bsh, \ 145 bus_addr_t ba, CAT3(u_int,m,_t) *x, size_t cnt) \ 146 { \ 147 while (cnt--) \ 148 *x++ = CAT(bus_space_read_,n)(bst, bsh, ba++); \ 149 } 150 151 bus_space_read_region(1,8) 152 bus_space_read_region(2,16) 153 bus_space_read_region(4,32) 154 bus_space_read_region(8,64) 155 156 /*----------------------------------------------------------------------------*/ 157 #define bus_space_read_raw_region(n,m) \ 158 static __inline void \ 159 CAT(bus_space_read_raw_region_,n)(bus_space_tag_t bst, \ 160 bus_space_handle_t bsh, \ 161 bus_addr_t ba, u_int8_t *x, size_t cnt) \ 162 { \ 163 cnt >>= ((n) >> 1); \ 164 while (cnt--) { \ 165 CAT(bus_space_read_raw_multi_,n)(bst, bsh, ba, x, (n)); \ 166 ba += (n); \ 167 x += (n); \ 168 } \ 169 } 170 171 bus_space_read_raw_region(2,16) 172 bus_space_read_raw_region(4,32) 173 bus_space_read_raw_region(8,64) 174 175 /*----------------------------------------------------------------------------*/ 176 #define bus_space_write_multi(n,m) \ 177 static __inline void \ 178 CAT(bus_space_write_multi_,n)(bus_space_tag_t bst, bus_space_handle_t bsh, \ 179 bus_size_t o, const CAT3(u_int,m,_t) *x, size_t cnt) \ 180 { \ 181 while (cnt--) { \ 182 CAT(bus_space_write_,n)(bst, bsh, o, *x++); \ 183 } \ 184 } 185 186 bus_space_write_multi(1,8) 187 bus_space_write_multi(2,16) 188 bus_space_write_multi(4,32) 189 bus_space_write_multi(8,64) 190 191 /*----------------------------------------------------------------------------*/ 192 #define bus_space_write_region(n,m) \ 193 static __inline void \ 194 CAT(bus_space_write_region_,n)(bus_space_tag_t bst, bus_space_handle_t bsh, \ 195 bus_addr_t ba, const CAT3(u_int,m,_t) *x, size_t cnt) \ 196 { \ 197 while (cnt--) { \ 198 CAT(bus_space_write_,n)(bst, bsh, ba, *x++); \ 199 ba += sizeof(x); \ 200 } \ 201 } 202 203 bus_space_write_region(1,8) 204 bus_space_write_region(2,16) 205 bus_space_write_region(4,32) 206 bus_space_write_region(8,64) 207 208 /*----------------------------------------------------------------------------*/ 209 #define bus_space_write_raw_region(n,m) \ 210 static __inline void \ 211 CAT(bus_space_write_raw_region_,n)(bus_space_tag_t bst, \ 212 bus_space_handle_t bsh, \ 213 bus_addr_t ba, const u_int8_t *x, size_t cnt) \ 214 { \ 215 cnt >>= ((n) >> 1); \ 216 while (cnt--) { \ 217 CAT(bus_space_write_raw_multi_,n)(bst, bsh, ba, x, (n)); \ 218 ba += (n); \ 219 x += (n); \ 220 } \ 221 } 222 223 bus_space_write_raw_region(2,16) 224 bus_space_write_raw_region(4,32) 225 bus_space_write_raw_region(8,64) 226 227 /*----------------------------------------------------------------------------*/ 228 #define bus_space_set_region(n,m) \ 229 static __inline void \ 230 CAT(bus_space_set_region_,n)(bus_space_tag_t bst, bus_space_handle_t bsh, \ 231 bus_addr_t ba, CAT3(u_int,m,_t) x, size_t cnt) \ 232 { \ 233 while (cnt--) { \ 234 CAT(bus_space_write_,n)(bst, bsh, ba, x); \ 235 ba += sizeof(x); \ 236 } \ 237 } 238 239 bus_space_set_region(1,8) 240 bus_space_set_region(2,16) 241 bus_space_set_region(4,32) 242 bus_space_set_region(8,64) 243 244 /*----------------------------------------------------------------------------*/ 245 static __inline void 246 bus_space_copy_1(void *v, bus_space_handle_t h1, bus_size_t o1, 247 bus_space_handle_t h2, bus_size_t o2, bus_size_t c) 248 { 249 char *s = (char *)(h1 + o1); 250 char *d = (char *)(h2 + o2); 251 252 while (c--) 253 *d++ = *s++; 254 } 255 256 257 static __inline void 258 bus_space_copy_2(void *v, bus_space_handle_t h1, bus_size_t o1, 259 bus_space_handle_t h2, bus_size_t o2, bus_size_t c) 260 { 261 short *s = (short *)(h1 + o1); 262 short *d = (short *)(h2 + o2); 263 264 while (c--) 265 *d++ = *s++; 266 } 267 268 static __inline void 269 bus_space_copy_4(void *v, bus_space_handle_t h1, bus_size_t o1, 270 bus_space_handle_t h2, bus_size_t o2, bus_size_t c) 271 { 272 int *s = (int *)(h1 + o1); 273 int *d = (int *)(h2 + o2); 274 275 while (c--) 276 *d++ = *s++; 277 } 278 279 static __inline void 280 bus_space_copy_8(void *v, bus_space_handle_t h1, bus_size_t o1, 281 bus_space_handle_t h2, bus_size_t o2, bus_size_t c) 282 { 283 int64_t *s = (int64_t *)(h1 + o1); 284 int64_t *d = (int64_t *)(h2 + o2); 285 286 while (c--) 287 *d++ = *s++; 288 } 289 290 int generic_space_map(bus_space_tag_t, bus_addr_t, bus_size_t, int, 291 bus_space_handle_t *); 292 void generic_space_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t); 293 int generic_space_region(bus_space_tag_t, bus_space_handle_t, bus_size_t, 294 bus_size_t, bus_space_handle_t *); 295 void *generic_space_vaddr(bus_space_tag_t, bus_space_handle_t); 296 uint8_t generic_space_read_1(bus_space_tag_t, bus_space_handle_t, bus_size_t); 297 uint16_t generic_space_read_2(bus_space_tag_t, bus_space_handle_t, bus_size_t); 298 uint32_t generic_space_read_4(bus_space_tag_t, bus_space_handle_t, bus_size_t); 299 uint64_t generic_space_read_8(bus_space_tag_t, bus_space_handle_t, bus_size_t); 300 void generic_space_read_raw_2(bus_space_tag_t, bus_space_handle_t, 301 bus_addr_t, uint8_t *, bus_size_t); 302 void generic_space_write_1(bus_space_tag_t, bus_space_handle_t, bus_size_t, 303 uint8_t); 304 void generic_space_write_2(bus_space_tag_t, bus_space_handle_t, bus_size_t, 305 uint16_t); 306 void generic_space_write_4(bus_space_tag_t, bus_space_handle_t, bus_size_t, 307 uint32_t); 308 void generic_space_write_8(bus_space_tag_t, bus_space_handle_t, bus_size_t, 309 uint64_t); 310 void generic_space_write_raw_2(bus_space_tag_t, bus_space_handle_t, 311 bus_addr_t, const uint8_t *, bus_size_t); 312 void generic_space_read_raw_4(bus_space_tag_t, bus_space_handle_t, 313 bus_addr_t, uint8_t *, bus_size_t); 314 void generic_space_write_raw_4(bus_space_tag_t, bus_space_handle_t, 315 bus_addr_t, const uint8_t *, bus_size_t); 316 void generic_space_read_raw_8(bus_space_tag_t, bus_space_handle_t, 317 bus_addr_t, uint8_t *, bus_size_t); 318 void generic_space_write_raw_8(bus_space_tag_t, bus_space_handle_t, 319 bus_addr_t, const uint8_t *, bus_size_t); 320 paddr_t generic_space_mmap(bus_space_tag_t, bus_addr_t, off_t, int, int); 321 322 /*----------------------------------------------------------------------------*/ 323 /* 324 * Bus read/write barrier methods. 325 * 326 * void bus_space_barrier(bus_space_tag_t tag, 327 * bus_space_handle_t bsh, bus_size_t offset, 328 * bus_size_t len, int flags); 329 * 330 */ 331 static inline void 332 bus_space_barrier(bus_space_tag_t t, bus_space_handle_t h, bus_size_t offset, 333 bus_size_t length, int flags) 334 { 335 __asm__ volatile ("sync" ::: "memory"); 336 } 337 #define BUS_SPACE_BARRIER_READ 0x01 /* force read barrier */ 338 #define BUS_SPACE_BARRIER_WRITE 0x02 /* force write barrier */ 339 340 #define BUS_DMA_WAITOK 0x0000 341 #define BUS_DMA_NOWAIT 0x0001 342 #define BUS_DMA_ALLOCNOW 0x0002 343 #define BUS_DMA_COHERENT 0x0008 344 #define BUS_DMA_BUS1 0x0010 /* placeholders for bus functions... */ 345 #define BUS_DMA_BUS2 0x0020 346 #define BUS_DMA_BUS3 0x0040 347 #define BUS_DMA_BUS4 0x0080 348 #define BUS_DMA_READ 0x0100 /* mapping is device -> memory only */ 349 #define BUS_DMA_WRITE 0x0200 /* mapping is memory -> device only */ 350 #define BUS_DMA_STREAMING 0x0400 /* hint: sequential, unidirectional */ 351 #define BUS_DMA_ZERO 0x0800 /* zero memory in dmamem_alloc */ 352 #define BUS_DMA_NOCACHE 0x1000 353 354 /* Forwards needed by prototypes below. */ 355 struct mbuf; 356 struct proc; 357 struct uio; 358 359 #define BUS_DMASYNC_POSTREAD 0x0001 360 #define BUS_DMASYNC_POSTWRITE 0x0002 361 #define BUS_DMASYNC_PREREAD 0x0004 362 #define BUS_DMASYNC_PREWRITE 0x0008 363 364 typedef struct machine_bus_dma_tag *bus_dma_tag_t; 365 typedef struct machine_bus_dmamap *bus_dmamap_t; 366 367 /* 368 * bus_dma_segment_t 369 * 370 * Describes a single contiguous DMA transaction. Values 371 * are suitable for programming into DMA registers. 372 */ 373 struct machine_bus_dma_segment { 374 bus_addr_t ds_addr; /* DMA address */ 375 bus_size_t ds_len; /* length of transfer */ 376 377 paddr_t _ds_paddr; /* CPU address */ 378 vaddr_t _ds_vaddr; /* CPU address */ 379 }; 380 typedef struct machine_bus_dma_segment bus_dma_segment_t; 381 382 /* 383 * bus_dma_tag_t 384 * 385 * A machine-dependent opaque type describing the implementation of 386 * DMA for a given bus. 387 */ 388 389 struct machine_bus_dma_tag { 390 void *_cookie; /* cookie used in the guts */ 391 392 /* 393 * DMA mapping methods. 394 */ 395 int (*_dmamap_create)(bus_dma_tag_t , bus_size_t, int, 396 bus_size_t, bus_size_t, int, bus_dmamap_t *); 397 void (*_dmamap_destroy)(bus_dma_tag_t , bus_dmamap_t); 398 int (*_dmamap_load)(bus_dma_tag_t , bus_dmamap_t, void *, 399 bus_size_t, struct proc *, int); 400 int (*_dmamap_load_mbuf)(bus_dma_tag_t , bus_dmamap_t, 401 struct mbuf *, int); 402 int (*_dmamap_load_uio)(bus_dma_tag_t , bus_dmamap_t, 403 struct uio *, int); 404 int (*_dmamap_load_raw)(bus_dma_tag_t , bus_dmamap_t, 405 bus_dma_segment_t *, int, bus_size_t, int); 406 int (*_dmamap_load_buffer)(bus_dma_tag_t, bus_dmamap_t, void *, 407 bus_size_t, struct proc *, int, paddr_t *, int *, int); 408 void (*_dmamap_unload)(bus_dma_tag_t , bus_dmamap_t); 409 void (*_dmamap_sync)(bus_dma_tag_t , bus_dmamap_t, 410 bus_addr_t, bus_size_t, int); 411 412 /* 413 * DMA memory utility functions. 414 */ 415 int (*_dmamem_alloc)(bus_dma_tag_t, bus_size_t, bus_size_t, 416 bus_size_t, bus_dma_segment_t *, int, int *, int); 417 void (*_dmamem_free)(bus_dma_tag_t, bus_dma_segment_t *, int); 418 int (*_dmamem_map)(bus_dma_tag_t, bus_dma_segment_t *, 419 int, size_t, caddr_t *, int); 420 void (*_dmamem_unmap)(bus_dma_tag_t, caddr_t, size_t); 421 paddr_t (*_dmamem_mmap)(bus_dma_tag_t, bus_dma_segment_t *, 422 int, off_t, int, int); 423 424 /* 425 * internal memory address translation information. 426 */ 427 bus_addr_t (*_pa_to_device)(paddr_t); 428 paddr_t (*_device_to_pa)(bus_addr_t); 429 bus_addr_t _dma_mask; 430 }; 431 432 #define bus_dmamap_create(t, s, n, m, b, f, p) \ 433 (*(t)->_dmamap_create)((t), (s), (n), (m), (b), (f), (p)) 434 #define bus_dmamap_destroy(t, p) \ 435 (*(t)->_dmamap_destroy)((t), (p)) 436 #define bus_dmamap_load(t, m, b, s, p, f) \ 437 (*(t)->_dmamap_load)((t), (m), (b), (s), (p), (f)) 438 #define bus_dmamap_load_mbuf(t, m, b, f) \ 439 (*(t)->_dmamap_load_mbuf)((t), (m), (b), (f)) 440 #define bus_dmamap_load_uio(t, m, u, f) \ 441 (*(t)->_dmamap_load_uio)((t), (m), (u), (f)) 442 #define bus_dmamap_load_raw(t, m, sg, n, s, f) \ 443 (*(t)->_dmamap_load_raw)((t), (m), (sg), (n), (s), (f)) 444 #define bus_dmamap_unload(t, p) \ 445 (*(t)->_dmamap_unload)((t), (p)) 446 #define bus_dmamap_sync(t, p, a, l, o) \ 447 (void)((t)->_dmamap_sync ? \ 448 (*(t)->_dmamap_sync)((t), (p), (a), (l), (o)) : (void)0) 449 450 #define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \ 451 (*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f)) 452 #define bus_dmamem_free(t, sg, n) \ 453 (*(t)->_dmamem_free)((t), (sg), (n)) 454 #define bus_dmamem_map(t, sg, n, s, k, f) \ 455 (*(t)->_dmamem_map)((t), (sg), (n), (s), (k), (f)) 456 #define bus_dmamem_unmap(t, k, s) \ 457 (*(t)->_dmamem_unmap)((t), (k), (s)) 458 #define bus_dmamem_mmap(t, sg, n, o, p, f) \ 459 (*(t)->_dmamem_mmap)((t), (sg), (n), (o), (p), (f)) 460 461 int _dmamap_create(bus_dma_tag_t, bus_size_t, int, 462 bus_size_t, bus_size_t, int, bus_dmamap_t *); 463 void _dmamap_destroy(bus_dma_tag_t, bus_dmamap_t); 464 int _dmamap_load(bus_dma_tag_t, bus_dmamap_t, void *, 465 bus_size_t, struct proc *, int); 466 int _dmamap_load_mbuf(bus_dma_tag_t, bus_dmamap_t, struct mbuf *, int); 467 int _dmamap_load_uio(bus_dma_tag_t, bus_dmamap_t, struct uio *, int); 468 int _dmamap_load_raw(bus_dma_tag_t, bus_dmamap_t, 469 bus_dma_segment_t *, int, bus_size_t, int); 470 int _dmamap_load_buffer(bus_dma_tag_t, bus_dmamap_t, void *, 471 bus_size_t, struct proc *, int, paddr_t *, int *, int); 472 void _dmamap_unload(bus_dma_tag_t, bus_dmamap_t); 473 void _dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_addr_t, 474 bus_size_t, int); 475 476 int _dmamem_alloc(bus_dma_tag_t, bus_size_t, bus_size_t, 477 bus_size_t, bus_dma_segment_t *, int, int *, int); 478 void _dmamem_free(bus_dma_tag_t, bus_dma_segment_t *, int); 479 int _dmamem_map(bus_dma_tag_t, bus_dma_segment_t *, 480 int, size_t, caddr_t *, int); 481 void _dmamem_unmap(bus_dma_tag_t, caddr_t, size_t); 482 paddr_t _dmamem_mmap(bus_dma_tag_t, bus_dma_segment_t *, int, off_t, int, int); 483 int _dmamem_alloc_range(bus_dma_tag_t, bus_size_t, bus_size_t, bus_size_t, 484 bus_dma_segment_t *, int, int *, int, paddr_t, paddr_t); 485 486 /* 487 * bus_dmamap_t 488 * 489 * Describes a DMA mapping. 490 */ 491 struct machine_bus_dmamap { 492 /* 493 * PRIVATE MEMBERS: not for use by machine-independent code. 494 */ 495 bus_size_t _dm_size; /* largest DMA transfer mappable */ 496 int _dm_segcnt; /* number of segs this map can map */ 497 bus_size_t _dm_maxsegsz; /* largest possible segment */ 498 bus_size_t _dm_boundary; /* don't cross this */ 499 int _dm_flags; /* misc. flags */ 500 501 void *_dm_cookie; /* cookie for bus-specific functions */ 502 503 /* 504 * PUBLIC MEMBERS: these are used by machine-independent code. 505 */ 506 bus_size_t dm_mapsize; /* size of the mapping */ 507 int dm_nsegs; /* # valid segments in mapping */ 508 bus_dma_segment_t dm_segs[1]; /* segments; variable length */ 509 }; 510 511 #endif /* _MACHINE_BUS_H_ */ 512