Next: Device Write, Previous: Device Close, Up: Device Interface
The function
device_readreads 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_SUCCESSif some data was successfully read,D_WOULD_BLOCKif no data is currently available andD_NOWAITis specified, andD_NO_SUCH_DEVICEif device does not denote a device port.
The
device_read_inbandfunction works as thedevice_readfunction, except that the data is returned “in-line” in the reply IPC message (see Memory).
This is the asynchronous form of the
device_readfunction.device_read_requestperforms 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_replymessage 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_SUCCESSis returned.
The
device_read_request_inbandandds_device_read_reply_inbandfunctions work as thedevice_read_requestandds_device_read_replyfunctions, except that the data is returned “in-line” in the reply IPC message (see Memory).