2 .\" Copyright 1989 AT&T
3 .\" Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH BIODONE 9F "Jan 16, 2006"
9 biodone \- release buffer after buffer I/O transfer and notify blocked threads
13 #include <sys/types.h>
18 \fBvoid\fR \fBbiodone\fR(\fBstruct buf *\fR\fIbp\fR);
24 Architecture independent level 1 (DDI/DKI).
32 Pointer to a \fBbuf\fR(9S) structure.
38 The \fBbiodone()\fR function notifies blocked processes waiting for the\fB
39 I/O\fR to complete, sets the \fBB_DONE\fR flag in the \fBb_flags\fR field of
40 the \fBbuf\fR(9S) structure, and releases the buffer if the \fBI/O\fR is
41 asynchronous. \fBbiodone()\fR is called by either the driver interrupt or
42 \fBstrategy\fR(9E) routines when a buffer \fBI/O\fR request is complete.
45 The \fBbiodone()\fR function provides the capability to call a completion
46 routine if \fIbp\fR describes a kernel buffer. The address of the routine is
47 specified in the \fBb_iodone\fR field of the \fBbuf\fR(9S) structure. If such a
48 routine is specified, \fBbiodone()\fR calls it and returns without performing
49 any other actions. Otherwise, it performs the steps above.
53 The \fBbiodone()\fR function can be called from user, interrupt, or kernel
58 Generally, the first validation test performed by any block device
59 \fBstrategy\fR(9E) routine is a check for an end-of-file (\fBEOF\fR) condition.
60 The \fBstrategy\fR(9E) routine is responsible for determining an \fBEOF\fR
61 condition when the device is accessed directly. If a \fBread\fR(2) request is
62 made for one block beyond the limits of the device (line 10), it will report an
63 \fBEOF\fR condition. Otherwise, if the request is outside the limits of the
64 device, the routine will report an error condition. In either case, report the
65 \fBI/O\fR operation as complete (line 27).
69 1 #define RAMDNBLK 1000 /* Number of blocks in RAM disk */
70 2 #define RAMDBSIZ 512 /* Number of bytes per block */
71 3 char ramdblks[RAMDNBLK][RAMDBSIZ]; /* Array containing RAM disk */
74 6 ramdstrategy(struct buf *bp)
76 8 daddr_t blkno = bp->b_blkno; /* get block number */
78 10 if ((blkno < 0) || (blkno >= RAMDNBLK)) {
80 12 * If requested block is outside RAM disk
81 13 * limits, test for EOF which could result
82 14 * from a direct (physio) request.
84 16 if ((blkno == RAMDNBLK) && (bp->b_flags & B_READ)) {
86 18 * If read is for block beyond RAM disk
87 19 * limits, mark EOF condition.
89 21 bp->b_resid = bp->b_bcount; /* compute return value */
91 23 } else { /* I/O attempt is beyond */
92 24 bp->b_error = ENXIO; /* limits of RAM disk */
93 25 bp->b_flags |= B_ERROR; /* return error */
95 27 biodone(bp); /* mark I/O complete (B_DONE) */
97 29 * Wake any processes awaiting this I/O
98 30 * or release buffer for asynchronous
99 31 * (B_ASYNC) request.
110 \fBread\fR(2), \fBstrategy\fR(9E), \fBbiowait\fR(9F), \fBddi_add_intr\fR(9F),
111 \fBdelay\fR(9F), \fBtimeout\fR(9F), \fBuntimeout\fR(9F), \fBbuf\fR(9S)
114 \fIWriting Device Drivers\fR
118 After calling \fBbiodone()\fR, \fIbp\fR is no longer available to be referred
119 to by the driver. If the driver makes any reference to \fIbp\fR after calling
120 \fBbiodone()\fR, a panic may result.
124 Drivers that use the \fBb_iodone\fR field of the \fBbuf\fR(9S) structure to
125 specify a substitute completion routine should save the value of \fBb_iodone\fR
126 before changing it, and then restore the old value before calling
127 \fBbiodone()\fR to release the buffer.