dma_pageio(D3DK) —
.IX \f4dma_pageio\fP(D3DK)
NAME
dma_pageio − break up an I/O request into manageable units
SYNOPSIS
#include <sys/buf.h>
void dma_pageio(int (∗strat)(), buf_t ∗bp);
ARGUMENTS
strat Address of the strategy(D2DK) routine to call to complete the I/O transfer.
bp Pointer to the buffer header structure.
DESCRIPTION
dma_pageio breaks up a data transfer request from physiock(D3DK) into units of contiguous memory. This function enhances the capabilities of the direct memory access controller (DMAC). .IX DMA (Direct Memory Access)
.IX Direct Memory Access (DMA)
RETURN VALUE
None.
LEVEL
Base Only.
NOTES
Can sleep.
Driver-defined basic locks and read/write locks may not be held across calls to this function.
Driver defined sleep locks may be held across calls to this function.
When the transfer completes, any allocated buffers are freed.
The interrupt priority level is not maintained across calls to dma_pageio.
SEE ALSO
read(D2DK), strategy(D2DK), write(D2DK), physiock(D3DK), buf(D4DK)
EXAMPLE
The following example shows how dma_pageio is used when reading or writing disk data. The driver’s read(D2DK) and write(D4DK) entry points use physiock to check the validity of the I/O and perform the data transfer. The strategy(D2DK) routine passed to physiock just calls dma_pageio to perform the data transfer one page at a time.
1 struct dsize {
2daddr_t nblocks;/∗ number of blocks in disk slice ∗/
3int cyloff;/∗ starting cylinder # of slice ∗/
4 } my_sizes[2] = {
520448, 21,/∗ slice 0 = cyl 21-305 ∗/
621888, 1/∗ slice 1 = cyl 1-305 ∗/
7 };
8 int
9 my_read(dev, uiop, crp)
10dev_t dev;
11uio_t ∗uiop;
12cred_t ∗crp;
13 {
14register int nblks;
15nblks = my_sizes[getminor(dev)].nblocks;
16return(physiock(my_breakup, 0, dev, B_READ, nblks, uiop));
17 }
18 int
19 my_write(dev, uiop, crp)
20dev_t dev;
21uio_t ∗uiop;
22cred_t ∗crp;
23 {
24register int nblks;
25nblks = my_sizes[getminor(dev)].nblocks;
26return(physiock(my_breakup, 0, dev, B_WRITE, nblks, uiop));
27 }
28 static void
29 my_breakup(bp)
30register buf_t ∗bp;
31 {
32dma_pageio(my_strategy, bp);
33 }
.IX \f4buf\fP(D4DK), example
.IX \f4dma_pageio\fP(D3DK), example
.IX \f4getminor\fP(D3DK), example
.IX \f4physiock\fP(D3DK), example
DDI