Next: Device Write, Previous: Device Close, Up: Device Interface
The function
device_read
reads bytes_wanted bytes from device, and stores them in a buffer allocated withvm_allocate
, which address is returned in data. The caller must deallocated it if it is no longer needed. The number of bytes actually returned is stored in data_count.If mode is
D_NOWAIT
, the operation does not block. Otherwise mode should be 0. recnum is the record number to be read, its meaning is device specific.The function returns
D_SUCCESS
if some data was successfully read,D_WOULD_BLOCK
if no data is currently available andD_NOWAIT
is specified, andD_NO_SUCH_DEVICE
if device does not denote a device port.
The
device_read_inband
function works as thedevice_read
function, except that the data is returned “in-line” in the reply IPC message (see Memory).
This is the asynchronous form of the
device_read
function.device_read_request
performs the read request. The meaning for the parameters is as indevice_read
. Additionally, the caller has to supply a reply port to which theds_device_read_reply
message is sent by the kernel when the read has been performed. The return value of the read operation is stored in return_code.As neither function receives a reply message, only message transmission errors apply. If no error occurs,
KERN_SUCCESS
is returned.
The
device_read_request_inband
andds_device_read_reply_inband
functions work as thedevice_read_request
andds_device_read_reply
functions, except that the data is returned “in-line” in the reply IPC message (see Memory).