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