|
|
#include <sys/types.h> #include <sys/buf.h> #include <sys/ddi.h>void biodone(buf_t *bp);
If a driver (or the kernel) had specified an iodone handler
by initializing the b_iodone
member of the
buf(D4)
structure
to the address of a function,
that function is called with the single argument,
bp.
Then
biodone( )
returns.
If a b_iodone
handler had not been specified,
biodone( )
marks the buffer as completed.
Then, if the B_ASYNC flag is set,
the buffer is released back to the system.
If the B_ASYNC flag is not set,
any processes waiting for the I/O to complete using
biowait(D3)
are unblocked (awakened).
If the buffer was allocated with the
getrbuf(D3)
function,
the driver must have specified a b_iodone
handler.
This example is for DDI drivers prior to version 8.
For DDI 8,
use the
biostart(D2)
entry point rather than
strategy( ).
biostart( )
does not need to check for end-of-media
because the kernel handles this using the size value
returned by the DI_SIZE parameter from
devinfo(D2),
unless the device does not support DI_SIZE.
1 #define RAMDNBLK 1000 /* Number of blocks in RAM disk */ 2 #define RAMDBSIZ 512 /* Number of bytes per block */ 3 char ramdblks[RAMDNBLK][RAMDBSIZ]; /* Array containing RAM disk */4 ramdstrategy(bp) 5 struct buf *bp; 6 { 7 daddr_t blkno = bp->b_blkno;
8 if ((blkno < 0) || (blkno >= RAMDNBLK)) { 9 if ((blkno == RAMDNBLK) && (bp->b_flags & B_READ)) { 10 bp->b_resid = bp->b_bcount; /* nothing read */ 11 } else { 12 bioerror(bp, ENXIO); 13 } 14 biodone(bp); 15 return; 16 } . . .
DDI versions 1, 2, and 4 do not support the bioerror(D3) function. Drivers written for these versions can use the following code to replace the call to bioerror( ) in line 12 of the example above:
bp->b_error = ENXIO; bp->b_flags |= B_ERROR;