Specifications

Writing a User-Level Device Drive
r
17-29
Return Value
The driver’s acheck routine returns EUD_NOERROR if the specified asynchronous I/O
operation has been completed. It returns EUD_INPROGRESS if the operation has not been
completed (see “Overview of the Device Configuration Program” on page 17-14 for a
listing of the error codes as defined in <userdriv.h>).
Example specification and pseudo code for a user-level driver’s acheck routine are
presented as follows:
int
dev_acheck(dev_desc, req_id, count)
int dev_desc;
int req_id;
int *count;
{
Get I/O request data structure associated with the req_id.
IF interrupts not enabled
Check device for completion status.
IF not complete THEN return I/O IN PROGRESS error.
Calculate transfer count and place it in the count parameter.
ELSE
Check the request data structure to see if the
request has completed.
IF not complete THEN return I/O IN PROGRESS error.
Get transfer count from request data structure and
place it in the count parameter.
ENDIF
Free I/O request data structure.
Return success status.
}
The await Routine 17
The driver’s await routine allows a user process to wait for a pending asynchronous I/O
operation to be completed. To support an await routine, you need to have interrupt
support. Typically the await routine blocks via a call to server_block(2); the
interrupt-handling routine wakes waiters via a call to server_wake1(2) or
server_wakevec(2). (See the server_block(2) system manual page for
information on handling timeouts and signals while waiting for an I/O operation to com-
plete.)
Specification
int xx_await(dev_desc
,
req_id
,
count)
int dev_desc
;
int req_id
;
int *count
;