1*1eaf0ac3Slogwang /*- 2*1eaf0ac3Slogwang * Copyright (c) 1982, 1986, 1993, 1994 3*1eaf0ac3Slogwang * The Regents of the University of California. All rights reserved. 4*1eaf0ac3Slogwang * 5*1eaf0ac3Slogwang * Redistribution and use in source and binary forms, with or without 6*1eaf0ac3Slogwang * modification, are permitted provided that the following conditions 7*1eaf0ac3Slogwang * are met: 8*1eaf0ac3Slogwang * 1. Redistributions of source code must retain the above copyright 9*1eaf0ac3Slogwang * notice, this list of conditions and the following disclaimer. 10*1eaf0ac3Slogwang * 2. Redistributions in binary form must reproduce the above copyright 11*1eaf0ac3Slogwang * notice, this list of conditions and the following disclaimer in the 12*1eaf0ac3Slogwang * documentation and/or other materials provided with the distribution. 13*1eaf0ac3Slogwang * 4. Neither the name of the University nor the names of its contributors 14*1eaf0ac3Slogwang * may be used to endorse or promote products derived from this software 15*1eaf0ac3Slogwang * without specific prior written permission. 16*1eaf0ac3Slogwang * 17*1eaf0ac3Slogwang * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18*1eaf0ac3Slogwang * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19*1eaf0ac3Slogwang * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20*1eaf0ac3Slogwang * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21*1eaf0ac3Slogwang * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22*1eaf0ac3Slogwang * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23*1eaf0ac3Slogwang * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24*1eaf0ac3Slogwang * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25*1eaf0ac3Slogwang * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26*1eaf0ac3Slogwang * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27*1eaf0ac3Slogwang * SUCH DAMAGE. 28*1eaf0ac3Slogwang * 29*1eaf0ac3Slogwang * @(#)uio.h 8.5 (Berkeley) 2/22/94 30*1eaf0ac3Slogwang * $FreeBSD$ 31*1eaf0ac3Slogwang */ 32*1eaf0ac3Slogwang 33*1eaf0ac3Slogwang #ifndef _SYS_UIO_H_ 34*1eaf0ac3Slogwang #define _SYS_UIO_H_ 35*1eaf0ac3Slogwang 36*1eaf0ac3Slogwang #include <sys/cdefs.h> 37*1eaf0ac3Slogwang #include <sys/_types.h> 38*1eaf0ac3Slogwang #include <sys/_iovec.h> 39*1eaf0ac3Slogwang 40*1eaf0ac3Slogwang #ifndef _SSIZE_T_DECLARED 41*1eaf0ac3Slogwang typedef __ssize_t ssize_t; 42*1eaf0ac3Slogwang #define _SSIZE_T_DECLARED 43*1eaf0ac3Slogwang #endif 44*1eaf0ac3Slogwang 45*1eaf0ac3Slogwang #ifndef _OFF_T_DECLARED 46*1eaf0ac3Slogwang typedef __off_t off_t; 47*1eaf0ac3Slogwang #define _OFF_T_DECLARED 48*1eaf0ac3Slogwang #endif 49*1eaf0ac3Slogwang 50*1eaf0ac3Slogwang #if __BSD_VISIBLE 51*1eaf0ac3Slogwang enum uio_rw { UIO_READ, UIO_WRITE }; 52*1eaf0ac3Slogwang 53*1eaf0ac3Slogwang /* Segment flag values. */ 54*1eaf0ac3Slogwang enum uio_seg { 55*1eaf0ac3Slogwang UIO_USERSPACE, /* from user data space */ 56*1eaf0ac3Slogwang UIO_SYSSPACE, /* from system space */ 57*1eaf0ac3Slogwang UIO_NOCOPY /* don't copy, already in object */ 58*1eaf0ac3Slogwang }; 59*1eaf0ac3Slogwang #endif 60*1eaf0ac3Slogwang 61*1eaf0ac3Slogwang #ifdef _KERNEL 62*1eaf0ac3Slogwang 63*1eaf0ac3Slogwang struct uio { 64*1eaf0ac3Slogwang struct iovec *uio_iov; /* scatter/gather list */ 65*1eaf0ac3Slogwang int uio_iovcnt; /* length of scatter/gather list */ 66*1eaf0ac3Slogwang off_t uio_offset; /* offset in target object */ 67*1eaf0ac3Slogwang ssize_t uio_resid; /* remaining bytes to process */ 68*1eaf0ac3Slogwang enum uio_seg uio_segflg; /* address space */ 69*1eaf0ac3Slogwang enum uio_rw uio_rw; /* operation */ 70*1eaf0ac3Slogwang struct thread *uio_td; /* owner */ 71*1eaf0ac3Slogwang }; 72*1eaf0ac3Slogwang 73*1eaf0ac3Slogwang /* 74*1eaf0ac3Slogwang * Limits 75*1eaf0ac3Slogwang * 76*1eaf0ac3Slogwang * N.B.: UIO_MAXIOV must be no less than IOV_MAX from <sys/syslimits.h> 77*1eaf0ac3Slogwang * which in turn must be no less than _XOPEN_IOV_MAX from <limits.h>. If 78*1eaf0ac3Slogwang * we ever make this tunable (probably pointless), then IOV_MAX should be 79*1eaf0ac3Slogwang * removed from <sys/syslimits.h> and applications would be expected to use 80*1eaf0ac3Slogwang * sysconf(3) to find out the correct value, or else assume the worst 81*1eaf0ac3Slogwang * (_XOPEN_IOV_MAX). Perhaps UIO_MAXIOV should be simply defined as 82*1eaf0ac3Slogwang * IOV_MAX. 83*1eaf0ac3Slogwang */ 84*1eaf0ac3Slogwang #define UIO_MAXIOV 1024 /* max 1K of iov's */ 85*1eaf0ac3Slogwang 86*1eaf0ac3Slogwang struct vm_object; 87*1eaf0ac3Slogwang struct vm_page; 88*1eaf0ac3Slogwang struct bus_dma_segment; 89*1eaf0ac3Slogwang 90*1eaf0ac3Slogwang struct uio *cloneuio(struct uio *uiop); 91*1eaf0ac3Slogwang int copyinfrom(const void * __restrict src, void * __restrict dst, 92*1eaf0ac3Slogwang size_t len, int seg); 93*1eaf0ac3Slogwang int copyiniov(const struct iovec *iovp, u_int iovcnt, struct iovec **iov, 94*1eaf0ac3Slogwang int error); 95*1eaf0ac3Slogwang int copyinstrfrom(const void * __restrict src, void * __restrict dst, 96*1eaf0ac3Slogwang size_t len, size_t * __restrict copied, int seg); 97*1eaf0ac3Slogwang int copyinuio(const struct iovec *iovp, u_int iovcnt, struct uio **uiop); 98*1eaf0ac3Slogwang int copyout_map(struct thread *td, vm_offset_t *addr, size_t sz); 99*1eaf0ac3Slogwang int copyout_unmap(struct thread *td, vm_offset_t addr, size_t sz); 100*1eaf0ac3Slogwang int physcopyin(void *src, vm_paddr_t dst, size_t len); 101*1eaf0ac3Slogwang int physcopyout(vm_paddr_t src, void *dst, size_t len); 102*1eaf0ac3Slogwang int physcopyin_vlist(struct bus_dma_segment *src, off_t offset, 103*1eaf0ac3Slogwang vm_paddr_t dst, size_t len); 104*1eaf0ac3Slogwang int physcopyout_vlist(vm_paddr_t src, struct bus_dma_segment *dst, 105*1eaf0ac3Slogwang off_t offset, size_t len); 106*1eaf0ac3Slogwang int uiomove(void *cp, int n, struct uio *uio); 107*1eaf0ac3Slogwang int uiomove_frombuf(void *buf, int buflen, struct uio *uio); 108*1eaf0ac3Slogwang int uiomove_fromphys(struct vm_page *ma[], vm_offset_t offset, int n, 109*1eaf0ac3Slogwang struct uio *uio); 110*1eaf0ac3Slogwang int uiomove_nofault(void *cp, int n, struct uio *uio); 111*1eaf0ac3Slogwang int uiomove_object(struct vm_object *obj, off_t obj_size, struct uio *uio); 112*1eaf0ac3Slogwang 113*1eaf0ac3Slogwang #else /* !_KERNEL */ 114*1eaf0ac3Slogwang 115*1eaf0ac3Slogwang __BEGIN_DECLS 116*1eaf0ac3Slogwang ssize_t readv(int, const struct iovec *, int); 117*1eaf0ac3Slogwang ssize_t writev(int, const struct iovec *, int); 118*1eaf0ac3Slogwang #if __BSD_VISIBLE 119*1eaf0ac3Slogwang ssize_t preadv(int, const struct iovec *, int, off_t); 120*1eaf0ac3Slogwang ssize_t pwritev(int, const struct iovec *, int, off_t); 121*1eaf0ac3Slogwang #endif 122*1eaf0ac3Slogwang __END_DECLS 123*1eaf0ac3Slogwang 124*1eaf0ac3Slogwang #endif /* _KERNEL */ 125*1eaf0ac3Slogwang 126*1eaf0ac3Slogwang #endif /* !_SYS_UIO_H_ */ 127