busdma_machdep-v4.c (140680) | busdma_machdep-v4.c (140682) |
---|---|
1/*- 2 * Copyright (c) 2004 Olivier Houchard 3 * Copyright (c) 2002 Peter Grehan 4 * Copyright (c) 1997, 1998 Justin T. Gibbs. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 15 unchanged lines hidden (view full) --- 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * From i386/busdma_machdep.c,v 1.26 2002/04/19 22:58:09 alfred 29 */ 30 31#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2004 Olivier Houchard 3 * Copyright (c) 2002 Peter Grehan 4 * Copyright (c) 1997, 1998 Justin T. Gibbs. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 15 unchanged lines hidden (view full) --- 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * From i386/busdma_machdep.c,v 1.26 2002/04/19 22:58:09 alfred 29 */ 30 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: head/sys/arm/arm/busdma_machdep.c 140680 2005-01-23 21:39:23Z cognet $"); | 32__FBSDID("$FreeBSD: head/sys/arm/arm/busdma_machdep.c 140682 2005-01-23 22:07:33Z cognet $"); |
33 34/* 35 * MacPPC bus dma support routines 36 */ 37 38#define _ARM32_BUS_DMA_PRIVATE 39#include <sys/param.h> 40#include <sys/systm.h> --- 342 unchanged lines hidden (view full) --- 383 } 384 dmat->map_count--; 385 free(map, M_DEVBUF); 386 CTR2(KTR_BUSDMA, "bus_dmamem_free: tag %p flags 0x%x", dmat, 387 dmat->flags); 388} 389 390/* | 33 34/* 35 * MacPPC bus dma support routines 36 */ 37 38#define _ARM32_BUS_DMA_PRIVATE 39#include <sys/param.h> 40#include <sys/systm.h> --- 342 unchanged lines hidden (view full) --- 383 } 384 dmat->map_count--; 385 free(map, M_DEVBUF); 386 CTR2(KTR_BUSDMA, "bus_dmamem_free: tag %p flags 0x%x", dmat, 387 dmat->flags); 388} 389 390/* |
391 * Map the buffer buf into bus space using the dmamap map. 392 */ 393int 394bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf, 395 bus_size_t buflen, bus_dmamap_callback_t *callback, 396 void *callback_arg, int flags) 397{ 398 vm_offset_t lastaddr = 0; 399 int error, nsegs = -1; 400#ifdef __GNUC__ 401 bus_dma_segment_t dm_segments[dmat->nsegments]; 402#else 403 bus_dma_segment_t dm_segments[BUS_DMAMAP_NSEGS]; 404#endif 405 406 map->flags &= ~DMAMAP_TYPE_MASK; 407 map->flags |= DMAMAP_LINEAR|DMAMAP_COHERENT; 408 map->buffer = buf; 409 map->len = buflen; 410 error = bus_dmamap_load_buffer(dmat, 411 dm_segments, map, buf, buflen, kernel_pmap, 412 flags, &lastaddr, &nsegs); 413 if (error) 414 (*callback)(callback_arg, NULL, 0, error); 415 else 416 (*callback)(callback_arg, dm_segments, nsegs + 1, error); 417 418 CTR4(KTR_BUSDMA, "bus_dmamap_load: tag %p tag flags 0x%x error %d " 419 "nsegs %d", dmat, dmat->flags, nsegs + 1, error); 420 421 return (0); 422} 423 424/* | |
425 * Utility function to load a linear buffer. lastaddrp holds state 426 * between invocations (for multiple-buffer loads). segp contains 427 * the starting segment on entrance, and the ending segment on exit. 428 * first indicates if this is the first invocation of this function. 429 */ 430static int __inline 431bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dma_segment_t *segs, 432 bus_dmamap_t map, void *buf, bus_size_t buflen, struct pmap *pmap, --- 119 unchanged lines hidden (view full) --- 552 * Did we fit? 553 */ 554 if (buflen != 0) 555 error = EFBIG; /* XXX better return value here? */ 556 return (error); 557} 558 559/* | 391 * Utility function to load a linear buffer. lastaddrp holds state 392 * between invocations (for multiple-buffer loads). segp contains 393 * the starting segment on entrance, and the ending segment on exit. 394 * first indicates if this is the first invocation of this function. 395 */ 396static int __inline 397bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dma_segment_t *segs, 398 bus_dmamap_t map, void *buf, bus_size_t buflen, struct pmap *pmap, --- 119 unchanged lines hidden (view full) --- 518 * Did we fit? 519 */ 520 if (buflen != 0) 521 error = EFBIG; /* XXX better return value here? */ 522 return (error); 523} 524 525/* |
526 * Map the buffer buf into bus space using the dmamap map. 527 */ 528int 529bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf, 530 bus_size_t buflen, bus_dmamap_callback_t *callback, 531 void *callback_arg, int flags) 532{ 533 vm_offset_t lastaddr = 0; 534 int error, nsegs = -1; 535#ifdef __GNUC__ 536 bus_dma_segment_t dm_segments[dmat->nsegments]; 537#else 538 bus_dma_segment_t dm_segments[BUS_DMAMAP_NSEGS]; 539#endif 540 541 map->flags &= ~DMAMAP_TYPE_MASK; 542 map->flags |= DMAMAP_LINEAR|DMAMAP_COHERENT; 543 map->buffer = buf; 544 map->len = buflen; 545 error = bus_dmamap_load_buffer(dmat, 546 dm_segments, map, buf, buflen, kernel_pmap, 547 flags, &lastaddr, &nsegs); 548 if (error) 549 (*callback)(callback_arg, NULL, 0, error); 550 else 551 (*callback)(callback_arg, dm_segments, nsegs + 1, error); 552 553 CTR4(KTR_BUSDMA, "bus_dmamap_load: tag %p tag flags 0x%x error %d " 554 "nsegs %d", dmat, dmat->flags, nsegs + 1, error); 555 556 return (0); 557} 558 559/* |
|
560 * Like bus_dmamap_load(), but for mbufs. 561 */ 562int 563bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, struct mbuf *m0, 564 bus_dmamap_callback2_t *callback, void *callback_arg, 565 int flags) 566{ 567#ifdef __GNUC__ --- 214 unchanged lines hidden --- | 560 * Like bus_dmamap_load(), but for mbufs. 561 */ 562int 563bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, struct mbuf *m0, 564 bus_dmamap_callback2_t *callback, void *callback_arg, 565 int flags) 566{ 567#ifdef __GNUC__ --- 214 unchanged lines hidden --- |