xref: /titanic_41/usr/src/uts/common/sys/uio.h (revision 1ae0874509b6811fdde1dfd46f0d93fd09867a3f)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 /*
31  * University Copyright- Copyright (c) 1982, 1986, 1988
32  * The Regents of the University of California
33  * All Rights Reserved
34  *
35  * University Acknowledgment- Portions of this document are derived from
36  * software developed by the University of California, Berkeley, and its
37  * contributors.
38  */
39 
40 #ifndef _SYS_UIO_H
41 #define	_SYS_UIO_H
42 
43 #pragma ident	"%Z%%M%	%I%	%E% SMI"
44 
45 #include <sys/feature_tests.h>
46 
47 #ifdef	__cplusplus
48 extern "C" {
49 #endif
50 
51 #include <sys/types.h>
52 
53 /*
54  * I/O parameter information.  A uio structure describes the I/O which
55  * is to be performed by an operation.  Typically the data movement will
56  * be performed by a routine such as uiomove(), which updates the uio
57  * structure to reflect what was done.
58  */
59 
60 #if	defined(_XPG4_2)
61 typedef struct iovec {
62 	void	*iov_base;
63 	size_t	iov_len;
64 } iovec_t;
65 #else
66 typedef struct iovec {
67 	caddr_t	iov_base;
68 #if defined(_LP64)
69 	size_t	iov_len;
70 #else
71 	long	iov_len;
72 #endif
73 } iovec_t;
74 #endif	/* defined(_XPG4_2) */
75 
76 #if defined(_SYSCALL32)
77 
78 /* Kernel's view of user ILP32 iovec struct */
79 
80 typedef	struct iovec32 {
81 	caddr32_t	iov_base;
82 	int32_t		iov_len;
83 } iovec32_t;
84 
85 #endif	/* _SYSCALL32 */
86 
87 #if 	!defined(_XPG4_2) || defined(__EXTENSIONS__)
88 /*
89  * Segment flag values.
90  */
91 typedef enum uio_seg { UIO_USERSPACE, UIO_SYSSPACE, UIO_USERISPACE } uio_seg_t;
92 
93 typedef struct uio {
94 	iovec_t		*uio_iov;	/* pointer to array of iovecs */
95 	int		uio_iovcnt;	/* number of iovecs */
96 	lloff_t		_uio_offset;	/* file offset */
97 	uio_seg_t	uio_segflg;	/* address space (kernel or user) */
98 	uint16_t	uio_fmode;	/* file mode flags */
99 	uint16_t	uio_extflg;	/* extended flags */
100 	lloff_t		_uio_limit;	/* u-limit (maximum byte offset) */
101 	ssize_t		uio_resid;	/* residual count */
102 } uio_t;
103 
104 #define	uio_loffset	_uio_offset._f
105 #if !defined(_LP64)
106 #define	uio_offset	_uio_offset._p._l
107 #else
108 #define	uio_offset	uio_loffset
109 #endif
110 
111 #define	uio_llimit	_uio_limit._f
112 #if !defined(_LP64)
113 #define	uio_limit	_uio_limit._p._l
114 #else
115 #define	uio_limit	uio_llimit
116 #endif
117 
118 /*
119  * I/O direction.
120  */
121 typedef enum uio_rw { UIO_READ, UIO_WRITE } uio_rw_t;
122 
123 /*
124  * uio_extflg: extended flags
125  *
126  * NOTE: This flag will be used in uiomove to determine if non-temporal
127  * access, ie, access bypassing caches, should be used.  Filesystems that
128  * don't initialize this field could experience suboptimal performance due to
129  * the random data the field contains.
130  */
131 #define	UIO_COPY_DEFAULT	0x0000	/* no special options to copy */
132 #define	UIO_COPY_CACHED		0x0001	/* copy should not bypass caches */
133 
134 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
135 
136 #if	defined(_KERNEL)
137 
138 int	uiomove(void *, size_t, enum uio_rw, uio_t *);
139 int	ureadc(int, uio_t *);	/* should be errno_t in future */
140 int	uwritec(struct uio *);
141 void	uioskip(uio_t *, size_t);
142 int	uiodup(uio_t *, uio_t *, iovec_t *, int);
143 
144 #else	/* defined(_KERNEL) */
145 
146 #if 	defined(__STDC__)
147 
148 extern ssize_t readv(int, const struct iovec *, int);
149 extern ssize_t writev(int, const struct iovec *, int);
150 
151 #else	/* defined(__STDC__) */
152 
153 extern ssize_t readv();
154 extern ssize_t writev();
155 
156 #endif	/* defined(__STDC__) */
157 
158 #endif	/* defined(_KERNEL) */
159 
160 #ifdef	__cplusplus
161 }
162 #endif
163 
164 #endif	/* _SYS_UIO_H */
165