DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
DDI: 8 sample driver

samp_biostart entry point routine

The biostart(D2) entry point routine is a new entry point for DDI 8 that replaces the read( ), write( ), and strategy( ) entry points that are used in older driver interfaces. It handles all read and write operations as well as I/O completion handling for non-STREAMS drivers whether or not the I/O operation uses the buffer cache.

The biostart( ) routine uses a buf(D4) header to manage all I/O operations whether or not they use the buffer cache. This driver also uses the uio(D4) structure, so the pointer to the uio structure must be written to the b_un.b_uio member of the buf structure.

ASSERT( ) statements verify that the channel is valid, that the b_addrtype value allows for UIO operations, and that the amount of data to be transferred can fit within the boundaries of the device size.

The code then calls the samp_start_io( ) subordinate driver routine to verify that the instance is available for an I/O operation. If the instance is suspended, the driver should wait for the state to be set to ACTIVE or REMOVED; if the state is REMOVED, the driver should return EIO. samp_start_io( ) returns 0 on success; if any other value is returned, the code calls the bioerror(D3) and biodone(D3) functions to mark the buf structure for the error condition so that the user process is notified of the error, release the buffer, and unblock all processes that were waiting for this operation.

One of the peculiarities of the CMOS RAM device which this driver supports is that it has a read-only portion at the beginning. Checking the SAMP_MINWRITE variable that is set at the beginning of the driver ensures that no data is written into this read-only portion of the device.

The read and write operations are coded separately, with each calling a subordinate driver subroutine to do the actual I/O operation. The read operation checks for the B_READ flag; if it is not set, this is a write operation and execution falls through to that code. samp_read_cmos( ) and sampl_write_cmos( ) read or write from the AT CMOS RAM, then the code calls either the ureadc(D3) or uwritec(D3) function to copy the data to a location specified by the uio(D4) structure. If ureadc( ) or uwritec( ) fails, the code calls bioerror( ) to mark the error condition in the buffer header; execution falls through to the biodone( ) function at the end of the code to unblock any processes that are waiting for this operation.


© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005