diff options
-rw-r--r-- | sys/alpha/alpha/busdma_machdep.c | 44 | ||||
-rw-r--r-- | sys/alpha/include/bus.h | 3 |
2 files changed, 42 insertions, 5 deletions
diff --git a/sys/alpha/alpha/busdma_machdep.c b/sys/alpha/alpha/busdma_machdep.c index dad249f..a669d70 100644 --- a/sys/alpha/alpha/busdma_machdep.c +++ b/sys/alpha/alpha/busdma_machdep.c @@ -637,18 +637,16 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dmat, struct thread *td, int flags, vm_offset_t *lastaddrp, + bus_dma_segment_t *segs, int *segp, int first) { - bus_dma_segment_t *segs; bus_size_t sgsize; bus_addr_t curaddr, lastaddr, baddr, bmask; vm_offset_t vaddr = (vm_offset_t)buf; int seg; pmap_t pmap; - segs = dmat->segments; - if (td != NULL) pmap = vmspace_pmap(td->td_proc->p_vmspace); else @@ -745,7 +743,7 @@ bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, error = _bus_dmamap_load_buffer(dmat, m->m_data, m->m_len, NULL, flags, &lastaddr, - &nsegs, first); + dmat->segments, &nsegs, first); first = 0; } } @@ -763,6 +761,41 @@ bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, return (error); } +int +bus_dmamap_load_mbuf_sg(bus_dma_tag_t dmat, bus_dmamap_t map, + struct mbuf *m0, bus_dma_segment_t *segs, + int *nsegs, int flags) +{ + int error; + + KASSERT(dmat->lowaddr >= ptoa(Maxmem) || map != NULL, + ("bus_dmamap_load_mbuf: No support for bounce pages!")); + M_ASSERTPKTHDR(m0); + + *nsegs = 0; + error = 0; + if (m0->m_pkthdr.len <= dmat->maxsize) { + int first = 1; + bus_addr_t lastaddr = 0; + struct mbuf *m; + + for (m = m0; m != NULL && error == 0; m = m->m_next) { + if (m->m_len > 0) { + error = _bus_dmamap_load_buffer(dmat, + m->m_data, m->m_len, + NULL, flags, &lastaddr, + segs, nsegs, first); + first = 0; + } + } + ++*nsegs; + } else { + error = EINVAL; + } + + return (error); +} + /* * Like _bus_dmamap_load(), but for uios. */ @@ -804,7 +837,8 @@ bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map, if (minlen > 0) { error = _bus_dmamap_load_buffer(dmat, addr, minlen, - td, flags, &lastaddr, &nsegs, first); + td, flags, &lastaddr, dmat->segments, + &nsegs, first); first = 0; resid -= minlen; diff --git a/sys/alpha/include/bus.h b/sys/alpha/include/bus.h index 5246ba1..1122e26 100644 --- a/sys/alpha/include/bus.h +++ b/sys/alpha/include/bus.h @@ -639,6 +639,9 @@ int bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, struct mbuf *mbuf, bus_dmamap_callback2_t *callback, void *callback_arg, int flags); +int bus_dmamap_load_mbuf_sg(bus_dma_tag_t dmat, bus_dmamap_t map, + struct mbuf *mbuf, bus_dma_segment_t *segs, + int *nsegs, int flags); /* * Like bus_dmamap_load but for uios. Note the use of the * bus_dmamap_callback2_t interface. |