The
physio() is a helper function typically called from character device read and write routines to start I/O on a user process buffer. It calls back on the provided
strategy routine one or more times to complete the transfer described by
uio. The maximum amount of data to transfer with each call to
strategy is determined by the
minphys routine.
Since
uio normally describes user space addresses,
physio() needs to lock the appropriate data area into memory before each transaction with
strategy (see
uvm_vslock(9) and
uvm_vsunlock(9)). The
physio() function always awaits the completion of the entire requested transfer before returning, unless an error condition is detected earlier. In all cases, the buffer passed in
bp is locked (marked as “busy”) for the duration of the entire transfer.
A break-down of the arguments follows:
strategy
The device strategy routine to call for each chunk of data to initiate device I/O.
bp
The buffer to use with the strategy routine. The buffer flags will have B_BUSY, B_PHYS, and B_RAW set when passed to the strategy routine. If NULL, a buffer is allocated from a system pool.
dev
The device number identifying the device to interact with.
flags
Direction of transfer; the only valid settings are B_READ or B_WRITE.
minphys
A device specific routine called to determine the maximum transfer size that the device's strategy routine can handle.
uio
The description of the entire transfer as requested by the user process. Currently, the results of passing a uio structure with the ‘uio_segflg' set to anything other than UIO_USERSPACE, are undefined.