17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*17169044Sbrutus * Common Development and Distribution License (the "License"). 6*17169044Sbrutus * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*17169044Sbrutus * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 277c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* 307c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 317c478bd9Sstevel@tonic-gate * The Regents of the University of California 327c478bd9Sstevel@tonic-gate * All Rights Reserved 337c478bd9Sstevel@tonic-gate * 347c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 357c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 367c478bd9Sstevel@tonic-gate * contributors. 377c478bd9Sstevel@tonic-gate */ 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifndef _SYS_UIO_H 407c478bd9Sstevel@tonic-gate #define _SYS_UIO_H 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h> 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #ifdef __cplusplus 477c478bd9Sstevel@tonic-gate extern "C" { 487c478bd9Sstevel@tonic-gate #endif 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate #include <sys/types.h> 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate /* 537c478bd9Sstevel@tonic-gate * I/O parameter information. A uio structure describes the I/O which 547c478bd9Sstevel@tonic-gate * is to be performed by an operation. Typically the data movement will 557c478bd9Sstevel@tonic-gate * be performed by a routine such as uiomove(), which updates the uio 567c478bd9Sstevel@tonic-gate * structure to reflect what was done. 577c478bd9Sstevel@tonic-gate */ 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate #if defined(_XPG4_2) 607c478bd9Sstevel@tonic-gate typedef struct iovec { 617c478bd9Sstevel@tonic-gate void *iov_base; 627c478bd9Sstevel@tonic-gate size_t iov_len; 637c478bd9Sstevel@tonic-gate } iovec_t; 647c478bd9Sstevel@tonic-gate #else 657c478bd9Sstevel@tonic-gate typedef struct iovec { 667c478bd9Sstevel@tonic-gate caddr_t iov_base; 677c478bd9Sstevel@tonic-gate #if defined(_LP64) 687c478bd9Sstevel@tonic-gate size_t iov_len; 697c478bd9Sstevel@tonic-gate #else 707c478bd9Sstevel@tonic-gate long iov_len; 717c478bd9Sstevel@tonic-gate #endif 727c478bd9Sstevel@tonic-gate } iovec_t; 737c478bd9Sstevel@tonic-gate #endif /* defined(_XPG4_2) */ 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate /* Kernel's view of user ILP32 iovec struct */ 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate typedef struct iovec32 { 807c478bd9Sstevel@tonic-gate caddr32_t iov_base; 817c478bd9Sstevel@tonic-gate int32_t iov_len; 827c478bd9Sstevel@tonic-gate } iovec32_t; 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate #if !defined(_XPG4_2) || defined(__EXTENSIONS__) 877c478bd9Sstevel@tonic-gate /* 887c478bd9Sstevel@tonic-gate * Segment flag values. 897c478bd9Sstevel@tonic-gate */ 907c478bd9Sstevel@tonic-gate typedef enum uio_seg { UIO_USERSPACE, UIO_SYSSPACE, UIO_USERISPACE } uio_seg_t; 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate typedef struct uio { 937c478bd9Sstevel@tonic-gate iovec_t *uio_iov; /* pointer to array of iovecs */ 947c478bd9Sstevel@tonic-gate int uio_iovcnt; /* number of iovecs */ 957c478bd9Sstevel@tonic-gate lloff_t _uio_offset; /* file offset */ 967c478bd9Sstevel@tonic-gate uio_seg_t uio_segflg; /* address space (kernel or user) */ 977c478bd9Sstevel@tonic-gate uint16_t uio_fmode; /* file mode flags */ 987c478bd9Sstevel@tonic-gate uint16_t uio_extflg; /* extended flags */ 997c478bd9Sstevel@tonic-gate lloff_t _uio_limit; /* u-limit (maximum byte offset) */ 1007c478bd9Sstevel@tonic-gate ssize_t uio_resid; /* residual count */ 1017c478bd9Sstevel@tonic-gate } uio_t; 1027c478bd9Sstevel@tonic-gate 103*17169044Sbrutus /* 104*17169044Sbrutus * Extended uio_t uioa_t used for asynchronous uio. 105*17169044Sbrutus * 106*17169044Sbrutus * Note: UIOA_IOV_MAX is defined and used as it is in "fs/vncalls.c" 107*17169044Sbrutus * as there isn't a formal definition of IOV_MAX for the kernel. 108*17169044Sbrutus */ 109*17169044Sbrutus #define UIOA_IOV_MAX 16 110*17169044Sbrutus 111*17169044Sbrutus typedef struct uioa_page_s { /* locked uio_iov state */ 112*17169044Sbrutus int uioa_pfncnt; /* count of pfn_t(s) in *uioa_ppp */ 113*17169044Sbrutus void **uioa_ppp; /* page_t or pfn_t arrary */ 114*17169044Sbrutus caddr_t uioa_base; /* address base */ 115*17169044Sbrutus size_t uioa_len; /* span length */ 116*17169044Sbrutus } uioa_page_t; 117*17169044Sbrutus 118*17169044Sbrutus typedef struct uioa_s { 119*17169044Sbrutus iovec_t *uio_iov; /* pointer to array of iovecs */ 120*17169044Sbrutus int uio_iovcnt; /* number of iovecs */ 121*17169044Sbrutus lloff_t _uio_offset; /* file offset */ 122*17169044Sbrutus uio_seg_t uio_segflg; /* address space (kernel or user) */ 123*17169044Sbrutus uint16_t uio_fmode; /* file mode flags */ 124*17169044Sbrutus uint16_t uio_extflg; /* extended flags */ 125*17169044Sbrutus lloff_t _uio_limit; /* u-limit (maximum byte offset) */ 126*17169044Sbrutus ssize_t uio_resid; /* residual count */ 127*17169044Sbrutus /* 128*17169044Sbrutus * uioa extended members. 129*17169044Sbrutus */ 130*17169044Sbrutus uint32_t uioa_state; /* state of asynch i/o */ 131*17169044Sbrutus uioa_page_t *uioa_lcur; /* pointer into uioa_locked[] */ 132*17169044Sbrutus void **uioa_lppp; /* pointer into lcur->uioa_ppp[] */ 133*17169044Sbrutus void *uioa_hwst[4]; /* opaque hardware state */ 134*17169044Sbrutus uioa_page_t uioa_locked[UIOA_IOV_MAX]; /* Per iov locked pages */ 135*17169044Sbrutus } uioa_t; 136*17169044Sbrutus 137*17169044Sbrutus #define UIOA_ALLOC 0x0001 /* allocated but not yet initialized */ 138*17169044Sbrutus #define UIOA_INIT 0x0002 /* initialized but not yet enabled */ 139*17169044Sbrutus #define UIOA_ENABLED 0x0004 /* enabled, asynch i/o active */ 140*17169044Sbrutus #define UIOA_FINI 0x0008 /* finished waiting for uioafini() */ 141*17169044Sbrutus 142*17169044Sbrutus #define UIOA_CLR (~0x000F) /* clear mutually exclusive bits */ 143*17169044Sbrutus 144*17169044Sbrutus #define UIOA_POLL 0x0010 /* need dcopy_poll() */ 145*17169044Sbrutus 1467c478bd9Sstevel@tonic-gate #define uio_loffset _uio_offset._f 1477c478bd9Sstevel@tonic-gate #if !defined(_LP64) 1487c478bd9Sstevel@tonic-gate #define uio_offset _uio_offset._p._l 1497c478bd9Sstevel@tonic-gate #else 1507c478bd9Sstevel@tonic-gate #define uio_offset uio_loffset 1517c478bd9Sstevel@tonic-gate #endif 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate #define uio_llimit _uio_limit._f 1547c478bd9Sstevel@tonic-gate #if !defined(_LP64) 1557c478bd9Sstevel@tonic-gate #define uio_limit _uio_limit._p._l 1567c478bd9Sstevel@tonic-gate #else 1577c478bd9Sstevel@tonic-gate #define uio_limit uio_llimit 1587c478bd9Sstevel@tonic-gate #endif 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate /* 1617c478bd9Sstevel@tonic-gate * I/O direction. 1627c478bd9Sstevel@tonic-gate */ 1637c478bd9Sstevel@tonic-gate typedef enum uio_rw { UIO_READ, UIO_WRITE } uio_rw_t; 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gate /* 1667c478bd9Sstevel@tonic-gate * uio_extflg: extended flags 1677c478bd9Sstevel@tonic-gate * 1687c478bd9Sstevel@tonic-gate * NOTE: This flag will be used in uiomove to determine if non-temporal 1697c478bd9Sstevel@tonic-gate * access, ie, access bypassing caches, should be used. Filesystems that 1707c478bd9Sstevel@tonic-gate * don't initialize this field could experience suboptimal performance due to 1717c478bd9Sstevel@tonic-gate * the random data the field contains. 172*17169044Sbrutus * 173*17169044Sbrutus * NOTE: This flag is also used by uioasync callers to pass an extended 174*17169044Sbrutus * uio_t (uioa_t), to uioasync enabled consumers. Unlike above all 175*17169044Sbrutus * consumers of a uioa_t require the uio_extflg to be initialized. 1767c478bd9Sstevel@tonic-gate */ 1777c478bd9Sstevel@tonic-gate #define UIO_COPY_DEFAULT 0x0000 /* no special options to copy */ 1787c478bd9Sstevel@tonic-gate #define UIO_COPY_CACHED 0x0001 /* copy should not bypass caches */ 1797c478bd9Sstevel@tonic-gate 180*17169044Sbrutus #define UIO_ASYNC 0x0002 /* uio_t is really a uioa_t */ 181*17169044Sbrutus 182*17169044Sbrutus /* 183*17169044Sbrutus * Global uioasync capability shadow state. 184*17169044Sbrutus */ 185*17169044Sbrutus typedef struct uioasync_s { 186*17169044Sbrutus boolean_t enabled; /* Is uioasync enabled? */ 187*17169044Sbrutus size_t mincnt; /* Minimum byte count for use of */ 188*17169044Sbrutus } uioasync_t; 189*17169044Sbrutus 1907c478bd9Sstevel@tonic-gate #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */ 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate #if defined(_KERNEL) 1937c478bd9Sstevel@tonic-gate 1947c478bd9Sstevel@tonic-gate int uiomove(void *, size_t, enum uio_rw, uio_t *); 1957c478bd9Sstevel@tonic-gate int ureadc(int, uio_t *); /* should be errno_t in future */ 1967c478bd9Sstevel@tonic-gate int uwritec(struct uio *); 1977c478bd9Sstevel@tonic-gate void uioskip(uio_t *, size_t); 1987c478bd9Sstevel@tonic-gate int uiodup(uio_t *, uio_t *, iovec_t *, int); 1997c478bd9Sstevel@tonic-gate 200*17169044Sbrutus int uioamove(void *, size_t, enum uio_rw, uioa_t *); 201*17169044Sbrutus int uioainit(uio_t *, uioa_t *); 202*17169044Sbrutus int uioafini(uio_t *, uioa_t *); 203*17169044Sbrutus extern uioasync_t uioasync; 204*17169044Sbrutus 2057c478bd9Sstevel@tonic-gate #else /* defined(_KERNEL) */ 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate #if defined(__STDC__) 2087c478bd9Sstevel@tonic-gate 2097c478bd9Sstevel@tonic-gate extern ssize_t readv(int, const struct iovec *, int); 2107c478bd9Sstevel@tonic-gate extern ssize_t writev(int, const struct iovec *, int); 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate #else /* defined(__STDC__) */ 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate extern ssize_t readv(); 2157c478bd9Sstevel@tonic-gate extern ssize_t writev(); 2167c478bd9Sstevel@tonic-gate 2177c478bd9Sstevel@tonic-gate #endif /* defined(__STDC__) */ 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate #endif /* defined(_KERNEL) */ 2207c478bd9Sstevel@tonic-gate 2217c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2227c478bd9Sstevel@tonic-gate } 2237c478bd9Sstevel@tonic-gate #endif 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate #endif /* _SYS_UIO_H */ 226