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