Print this page
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/sys/uio.h
+++ new/usr/src/uts/common/sys/uio.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
23 23 *
24 24 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
25 25 * Use is subject to license terms.
26 26 *
27 27 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
28 28 * Copyright (c) 2015, Joyent, Inc. All rights reserved.
29 29 */
30 30
31 31 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
32 32 /* All Rights Reserved */
33 33
34 34 /*
35 35 * University Copyright- Copyright (c) 1982, 1986, 1988
36 36 * The Regents of the University of California
37 37 * All Rights Reserved
38 38 *
39 39 * University Acknowledgment- Portions of this document are derived from
40 40 * software developed by the University of California, Berkeley, and its
41 41 * contributors.
42 42 */
43 43
44 44 #ifndef _SYS_UIO_H
45 45 #define _SYS_UIO_H
46 46
47 47 #include <sys/feature_tests.h>
48 48
49 49 #ifdef __cplusplus
50 50 extern "C" {
51 51 #endif
52 52
53 53 #include <sys/types.h>
54 54
55 55 /*
56 56 * I/O parameter information. A uio structure describes the I/O which
57 57 * is to be performed by an operation. Typically the data movement will
58 58 * be performed by a routine such as uiomove(), which updates the uio
59 59 * structure to reflect what was done.
60 60 */
61 61
62 62 #if defined(_XPG4_2)
63 63 typedef struct iovec {
64 64 void *iov_base;
65 65 size_t iov_len;
66 66 } iovec_t;
67 67 #else
68 68 typedef struct iovec {
69 69 caddr_t iov_base;
70 70 #if defined(_LP64)
71 71 size_t iov_len;
72 72 #else
73 73 long iov_len;
74 74 #endif
75 75 } iovec_t;
76 76 #endif /* defined(_XPG4_2) */
77 77
78 78 #if defined(_SYSCALL32)
79 79
80 80 /* Kernel's view of user ILP32 iovec struct */
81 81
82 82 typedef struct iovec32 {
83 83 caddr32_t iov_base;
84 84 int32_t iov_len;
85 85 } iovec32_t;
86 86
87 87 #endif /* _SYSCALL32 */
88 88
89 89 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
90 90 /*
91 91 * Segment flag values.
92 92 */
93 93 typedef enum uio_seg { UIO_USERSPACE, UIO_SYSSPACE, UIO_USERISPACE } uio_seg_t;
94 94
95 95 typedef struct uio {
96 96 iovec_t *uio_iov; /* pointer to array of iovecs */
97 97 int uio_iovcnt; /* number of iovecs */
98 98 lloff_t _uio_offset; /* file offset */
99 99 uio_seg_t uio_segflg; /* address space (kernel or user) */
100 100 uint16_t uio_fmode; /* file mode flags */
101 101 uint16_t uio_extflg; /* extended flags */
102 102 lloff_t _uio_limit; /* u-limit (maximum byte offset) */
103 103 ssize_t uio_resid; /* residual count */
104 104 } uio_t;
105 105
106 106 /*
107 107 * Extended uio_t uioa_t used for asynchronous uio.
108 108 *
109 109 * Note: UIOA_IOV_MAX is defined and used as it is in "fs/vncalls.c"
110 110 * as there isn't a formal definition of IOV_MAX for the kernel.
111 111 */
112 112 #define UIOA_IOV_MAX 16
113 113
114 114 typedef struct uioa_page_s { /* locked uio_iov state */
115 115 int uioa_pfncnt; /* count of pfn_t(s) in *uioa_ppp */
116 116 void **uioa_ppp; /* page_t or pfn_t arrary */
117 117 caddr_t uioa_base; /* address base */
118 118 size_t uioa_len; /* span length */
119 119 } uioa_page_t;
120 120
121 121 typedef struct uioa_s {
122 122 iovec_t *uio_iov; /* pointer to array of iovecs */
123 123 int uio_iovcnt; /* number of iovecs */
124 124 lloff_t _uio_offset; /* file offset */
125 125 uio_seg_t uio_segflg; /* address space (kernel or user) */
126 126 uint16_t uio_fmode; /* file mode flags */
127 127 uint16_t uio_extflg; /* extended flags */
128 128 lloff_t _uio_limit; /* u-limit (maximum byte offset) */
129 129 ssize_t uio_resid; /* residual count */
130 130 /*
131 131 * uioa extended members.
132 132 */
133 133 uint32_t uioa_state; /* state of asynch i/o */
134 134 ssize_t uioa_mbytes; /* bytes that have been uioamove()ed */
135 135 uioa_page_t *uioa_lcur; /* pointer into uioa_locked[] */
136 136 void **uioa_lppp; /* pointer into lcur->uioa_ppp[] */
137 137 void *uioa_hwst[4]; /* opaque hardware state */
138 138 uioa_page_t uioa_locked[UIOA_IOV_MAX]; /* Per iov locked pages */
139 139 } uioa_t;
140 140
141 141 /*
142 142 * uio extensions
143 143 *
144 144 * PSARC 2009/478: Copy Reduction Interfaces
145 145 */
146 146 typedef enum xuio_type {
147 147 UIOTYPE_ASYNCIO,
148 148 UIOTYPE_ZEROCOPY,
149 149 UIOTYPE_PEEKSIZE
150 150 } xuio_type_t;
151 151
152 152 typedef struct xuio {
153 153 uio_t xu_uio; /* Embedded UIO structure */
154 154
155 155 /* Extended uio fields */
156 156 enum xuio_type xu_type; /* What kind of uio structure? */
157 157 union {
158 158 /* Async I/O Support, intend to replace uioa_t. */
159 159 struct {
160 160 uint32_t xu_a_state; /* state of async i/o */
161 161 /* bytes that have been uioamove()ed */
162 162 ssize_t xu_a_mbytes;
163 163 uioa_page_t *xu_a_lcur; /* pointer into uioa_locked[] */
164 164 /* pointer into lcur->uioa_ppp[] */
165 165 void **xu_a_lppp;
166 166 void *xu_a_hwst[4]; /* opaque hardware state */
167 167 /* Per iov locked pages */
168 168 uioa_page_t xu_a_locked[UIOA_IOV_MAX];
169 169 } xu_aio;
170 170
171 171 /*
172 172 * Copy Reduction Support -- facilate loaning / returning of
173 173 * filesystem cache buffers.
174 174 */
175 175 struct {
176 176 int xu_zc_rw; /* read or write buffer */
177 177 void *xu_zc_priv; /* fs specific */
178 178 } xu_zc;
179 179
180 180 /*
181 181 * Peek Size Support -- facilitate peeking at the size of a
182 182 * waiting message on a socket.
183 183 */
184 184 struct {
185 185 ssize_t xu_ps_size; /* size of waiting msg */
186 186 boolean_t xu_ps_set; /* was size calculated? */
187 187 } xu_ps;
188 188 } xu_ext;
189 189 } xuio_t;
190 190
191 191 #define XUIO_XUZC_PRIV(xuio) xuio->xu_ext.xu_zc.xu_zc_priv
192 192 #define XUIO_XUZC_RW(xuio) xuio->xu_ext.xu_zc.xu_zc_rw
193 193
194 194 #define UIOA_ALLOC 0x0001 /* allocated but not yet initialized */
195 195 #define UIOA_INIT 0x0002 /* initialized but not yet enabled */
196 196 #define UIOA_ENABLED 0x0004 /* enabled, asynch i/o active */
197 197 #define UIOA_FINI 0x0008 /* finished waiting for uioafini() */
198 198
199 199 #define UIOA_CLR (~0x000F) /* clear mutually exclusive bits */
200 200
201 201 #define UIOA_POLL 0x0010 /* need dcopy_poll() */
202 202
203 203 #define uio_loffset _uio_offset._f
204 204 #if !defined(_LP64)
205 205 #define uio_offset _uio_offset._p._l
206 206 #else
207 207 #define uio_offset uio_loffset
208 208 #endif
209 209
210 210 #define uio_llimit _uio_limit._f
211 211 #if !defined(_LP64)
212 212 #define uio_limit _uio_limit._p._l
213 213 #else
214 214 #define uio_limit uio_llimit
215 215 #endif
216 216
217 217 /*
218 218 * I/O direction.
219 219 */
220 220 typedef enum uio_rw { UIO_READ, UIO_WRITE } uio_rw_t;
221 221
222 222 /*
223 223 * uio_extflg: extended flags
224 224 *
225 225 * NOTE: This flag will be used in uiomove to determine if non-temporal
226 226 * access, ie, access bypassing caches, should be used. Filesystems that
227 227 * don't initialize this field could experience suboptimal performance due to
228 228 * the random data the field contains.
229 229 *
230 230 * NOTE: This flag is also used by uioasync callers to pass an extended
231 231 * uio_t (uioa_t), to uioasync enabled consumers. Unlike above all
232 232 * consumers of a uioa_t require the uio_extflg to be initialized.
233 233 */
234 234 #define UIO_COPY_DEFAULT 0x0000 /* no special options to copy */
235 235 #define UIO_COPY_CACHED 0x0001 /* copy should not bypass caches */
236 236
237 237 #define UIO_ASYNC 0x0002 /* uio_t is really a uioa_t */
238 238 #define UIO_XUIO 0x0004 /* Structure is xuio_t */
239 239
240 240 /*
241 241 * Global uioasync capability shadow state.
242 242 */
243 243 typedef struct uioasync_s {
244 244 boolean_t enabled; /* Is uioasync enabled? */
245 245 size_t mincnt; /* Minimum byte count for use of */
246 246 } uioasync_t;
247 247
248 248 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
249 249
250 250 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
251 251
252 252 int uiomove(void *, size_t, enum uio_rw, uio_t *);
253 253 void uio_prefaultpages(ssize_t, uio_t *);
254 254 int uiocopy(void *, size_t, enum uio_rw, uio_t *, size_t *);
255 255 int ureadc(int, uio_t *); /* should be errno_t in future */
256 256 int uwritec(struct uio *);
257 257 void uioskip(uio_t *, size_t);
258 258 int uiodup(uio_t *, uio_t *, iovec_t *, int);
259 259
260 260 int uioamove(void *, size_t, enum uio_rw, uioa_t *);
261 261 int uioainit(uio_t *, uioa_t *);
262 262 int uioafini(uio_t *, uioa_t *);
263 263 extern uioasync_t uioasync;
264 264
265 265 #else /* defined(_KERNEL) */
266 266
267 267 extern ssize_t readv(int, const struct iovec *, int);
268 268 extern ssize_t writev(int, const struct iovec *, int);
269 269
270 270 /*
271 271 * When in the large file compilation environment,
272 272 * map preadv/pwritev to their 64 bit offset versions
273 273 */
274 274 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
275 275 #ifdef __PRAGMA_REDEFINE_EXTNAME
276 276 #pragma redefine_extname preadv preadv64
277 277 #pragma redefine_extname pwritev pwritev64
278 278 #else /* __PRAGMA_REDEFINE_EXTNAME */
279 279 #define preadv preadv64
280 280 #define pwritev pwritev64
281 281 #endif /* __PRAGMA_REDEFINE_EXTNAME */
282 282 #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */
283 283
284 284 /* In the LP64 compilation environment, the APIs are already large file */
285 285 #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
286 286 #ifdef __PRAGMA_REDEFINE_EXTNAME
287 287 #pragma redefine_extname preadv64 preadv
288 288 #pragma redefine_extname pwritev64 pwritev
289 289 #else /* __PRAGMA_REDEFINE_EXTNAME */
290 290 #define preadv64 preadv
291 291 #define pwritev64 pwritev
292 292 #endif /* __PRAGMA_REDEFINE_EXTNAME */
293 293 #endif /* _LP64 && _LARGEFILE64_SOURCE */
294 294
295 295 extern ssize_t preadv(int, const struct iovec *, int, off_t);
296 296 extern ssize_t pwritev(int, const struct iovec *, int, off_t);
297 297
298 298 /*
299 299 * preadv64 and pwritev64 should be defined when:
300 300 * - Using the transitional compilation environment, and not
301 301 * the large file compilation environment.
302 302 */
303 303 #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
304 304 !defined(__PRAGMA_REDEFINE_EXTNAME))
305 305 extern ssize_t preadv64(int, const struct iovec *, int, off64_t);
306 306 extern ssize_t pwritev64(int, const struct iovec *, int, off64_t);
307 307 #endif /* _LARGEFILE64_SOURCE */
308 308
309 309 #endif /* defined(_KERNEL) */
310 310
311 311 #ifdef __cplusplus
312 312 }
313 313 #endif
314 314
315 315 #endif /* _SYS_UIO_H */
|
↓ open down ↓ |
315 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX