Next | Prev | Up | Top | Contents | Index
Transferring Data Through a uio_t Object
A uio_t object defines a list of one or more segments in the address space of the kernel or a user process (see "Structure uio_t"). The kernel supplies three functions for transferring data based on a uio_t, and these are summarized in Table 9-8.
Functions Moving Data Using uio_t
Function | Header Files | Can Sleep? | Purpose |
---|
uiomove(D3) | ddi.h | Y | Copy data using uio_t. |
ureadc(D3) | ddi.h | Y | Copy a character to space described by uio_t. |
uwritec(D3) | ddi.h | Y | Return a character from space described by uio_t. |
The uiomove() function moves multiple bytes between a buffer in kernel virtual space--typically, a buffer owned by the driver--and the space or spaces described by a uio_t. The function takes a byte count and a direction flag as arguments, and uses the most efficient mechanism for copying.
The ureadc() and uwritec() functions transfer only a single byte. You would use them when transferring data a byte at a time by PIO. When moving more than a few bytes, uiomove() is faster.
All of these functions modify the uio_t to reflect the transfer of data:
- uio_resid is decremented by the amount moved
- In the iovec_t for the current segment, iov_base is incremented and iov_len is decremented
- As segments are used up, uio_iov is incremented and uio_iovcnt is decremented
The result is that the state of the uio_t always reflects the number of bytes remaining to transfer. When the pfxread() or pfxwrite() entry point returns, the kernel uses the finsl value of ui_resid to compute the count returned to the read() or write() function call.
Next | Prev | Up | Top | Contents | Index