1uio(9S) Data Structures for Drivers uio(9S)
2
3
4
6 uio - scatter/gather I/O request structure
7
9 #include <sys/uio.h>
10
11
13 Architecture independent level 1 (DDI/DKI)
14
16 A uio structure describes an I/O request that can be broken up into
17 different data storage areas (scatter/gather I/O). A request is a list
18 of iovec structures (base-length pairs) indicating where in user space
19 or kernel space the I/O data is to be read or written.
20
21
22 The contents of uio structures passed to the driver through the entry
23 points should not be written by the driver. The uiomove(9F) function
24 takes care of all overhead related to maintaining the state of the uio
25 structure.
26
27
28 uio structures allocated by the driver should be initialized to zero
29 before use, by bzero(9F), kmem_zalloc(9F), or an equivalent.
30
32 iovec_t *uio_iov; /* pointer to start of iovec */
33 /* list for uio struc. */
34 int uio_iovcnt; /* number of iovecs in list */
35 off_t uio_offset; /* 32-bit offset into file where
36 /* data is xferred. See NOTES. */
37 offset_t uio_loffset; /* 64-bit offset into file where */
38 /* data is xferred. See NOTES. */
39 uio_seg_t uio_segflg; /* ID's type of I/O transfer: */
40 /* UIO_SYSSPACE: kernel <-> kernel */
41 /* UIO_USERSPACE: kernel <-> user */
42 uint16_t uio_fmode; /* file mode flags (not driver setable) */
43 daddr_t uio_limit; /* 32-bit ulimit for file (max. block */
44 /* offset). not driver setable. */
45 /* See NOTES. */
46 diskaddr_t uio_llimit; /* 64-bit ulimit for file (max. block */
47 /* offset). not driver setable. */
48 /* See NOTES */
49 ssize_t uio_resid; /* residual count */
50
51
52
53 The uio_iov member is a pointer to the beginning of the iovec(9S) list
54 for the uio. When the uio structure is passed to the driver through an
55 entry point, the driver should not set uio_iov. When the uio struc‐
56 ture is created by the driver, uio_iov should be initialized by the
57 driver and not written to afterward.
58
60 aread(9E), awrite(9E), read(9E), write(9E), bzero(9F), kmem_zalloc(9F),
61 uiomove(9F), cb_ops(9S), iovec(9S)
62
63
64 Writing Device Drivers
65
67 Only one structure, uio_offset or uio_loffset, should be interpreted by
68 the driver. Which field the driver interprets is dependent upon the
69 settings in the cb_ops(9S) structure.
70
71
72 Only one structure, uio_limit or uio_llimit, should be interpreted by
73 the driver. Which field the driver interprets is dependent upon the
74 settings in the cb_ops(9S) structure.
75
76
77 When performing I/O on a seekable device, the driver should not modify
78 either the uio_offset or the uio_loffset field of the uio structure.
79 I/O to such a device is constrained by the maximum offset value. When
80 performing I/O on a device on which the concept of position has no rel‐
81 evance, the driver may preserve the uio_offset or uio_loffset, perform
82 the I/O operation, then restore the uio_offset or uio_loffset to the
83 field's initial value. I/O performed to a device in this manner is not
84 constrained.
85
86
87
88SunOS 5.11 26Mar 2009 uio(9S)