Go to the first, previous, next, last section, table of contents.


Device Read

Function: kern_return_t device_read (mach_port_t device, dev_mode_t mode, recnum_t recnum, int bytes_wanted, io_buf_ptr_t *data, mach_msg_type_number_t *data_count)
The function device_read reads bytes_wanted bytes from device, and stores them in a buffer allocated with vm_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 and D_NOWAIT is specified, and D_NO_SUCH_DEVICE if device does not denote a device port.

Function: kern_return_t device_read_inband (mach_port_t device, dev_mode_t mode, recnum_t recnum, int bytes_wanted, io_buf_ptr_inband_t *data, mach_msg_type_number_t *data_count)
The device_read_inband function works as the device_read function, except that the data is returned "inband" in the reply IPC message.

Function: kern_return_t device_read_request (mach_port_t device, mach_port_t reply_port, dev_mode_t mode, recnum_t recnum, int bytes_wanted)
Function: kern_return_t ds_device_read_reply (mach_port_t reply_port, kern_return_t return_code, io_buf_ptr_t data, mach_msg_type_number_t data_count)
This is the asynchronous form of the device_read function. device_read_request performs the read request. The meaning for the parameters is as in device_read. Additionally, the caller has to supply a reply port to which the ds_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.

Function: kern_return_t device_read_request_inband (mach_port_t device, mach_port_t reply_port, dev_mode_t mode, recnum_t recnum, int bytes_wanted)
Function: kern_return_t ds_device_read_reply_inband (mach_port_t reply_port, kern_return_t return_code, io_buf_ptr_t data, mach_msg_type_number_t data_count)
The device_read_request_inband and ds_device_read_reply_inband functions work as the device_read_request and ds_device_read_reply functions, except that the data is returned "inband" in the reply IPC message.


Go to the first, previous, next, last section, table of contents.