Writing a User-Level Device Drive
17-2
Return Value
The driver’s aread routine returns EUD_NOERROR if the operation is successfully
queued. It returns the appropriate user-level device driver error code if an error occurs (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 aread routine are
presented as follows:
int
dev_aread(dev_desc, udbuf, count, req_id)
int dev_desc;
udbuf_t *udbuf;
int count, *req_id;
{
Verify device is ready for I/O and routine arguments are valid.
Allocate an I/O request data structure (the I/O request data structure
is internal to the user-level device driver and is used to hold the
status of this request).
Write physical address of the user buffer to the device’s address
register.
Write the transfer count to the device’s count register.
Mark the I/O request active.
Initiate the I/O request.
Provide an identifier for the request to the caller.
Return success status.
}
The awrite Routine 17
The driver’s awrite routine allows a user process to perform an asynchronous write of
data to the device.
Specification
int xx
_awrite(
dev_desc
,
buff_desc
,
count
,
req_id)
int dev_desc
;
udbuf_t *buff_desc
;
int count
;
int *req_id
;
Comments to this Manuals