1139825Simp/*- 21541Srgrimes * Copyright (c) 1982, 1986, 1993, 1994 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * 51541Srgrimes * Redistribution and use in source and binary forms, with or without 61541Srgrimes * modification, are permitted provided that the following conditions 71541Srgrimes * are met: 81541Srgrimes * 1. Redistributions of source code must retain the above copyright 91541Srgrimes * notice, this list of conditions and the following disclaimer. 101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111541Srgrimes * notice, this list of conditions and the following disclaimer in the 121541Srgrimes * documentation and/or other materials provided with the distribution. 131541Srgrimes * 4. Neither the name of the University nor the names of its contributors 141541Srgrimes * may be used to endorse or promote products derived from this software 151541Srgrimes * without specific prior written permission. 161541Srgrimes * 171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271541Srgrimes * SUCH DAMAGE. 281541Srgrimes * 291541Srgrimes * @(#)uio.h 8.5 (Berkeley) 2/22/94 3050477Speter * $FreeBSD$ 311541Srgrimes */ 321541Srgrimes 331541Srgrimes#ifndef _SYS_UIO_H_ 341541Srgrimes#define _SYS_UIO_H_ 351541Srgrimes 36104925Smike#include <sys/cdefs.h> 37104925Smike#include <sys/_types.h> 38108366Sphk#include <sys/_iovec.h> 39104925Smike 40104925Smike#ifndef _SSIZE_T_DECLARED 41104925Smiketypedef __ssize_t ssize_t; 42104925Smike#define _SSIZE_T_DECLARED 43104925Smike#endif 44104925Smike 45147813Sjhb#ifndef _OFF_T_DECLARED 46147813Sjhbtypedef __off_t off_t; 47147813Sjhb#define _OFF_T_DECLARED 48147813Sjhb#endif 49147813Sjhb 50104925Smike#if __BSD_VISIBLE 511541Srgrimesenum uio_rw { UIO_READ, UIO_WRITE }; 521541Srgrimes 531541Srgrimes/* Segment flag values. */ 541541Srgrimesenum uio_seg { 551541Srgrimes UIO_USERSPACE, /* from user data space */ 561541Srgrimes UIO_SYSSPACE, /* from system space */ 577620Sdg UIO_NOCOPY /* don't copy, already in object */ 581541Srgrimes}; 59104925Smike#endif 601541Srgrimes 6155205Speter#ifdef _KERNEL 6231855Sbde 631541Srgrimesstruct uio { 64164754Salfred struct iovec *uio_iov; /* scatter/gather list */ 65164754Salfred int uio_iovcnt; /* length of scatter/gather list */ 66164754Salfred off_t uio_offset; /* offset in target object */ 67194990Skib ssize_t uio_resid; /* remaining bytes to process */ 68164754Salfred enum uio_seg uio_segflg; /* address space */ 69164754Salfred enum uio_rw uio_rw; /* operation */ 70164754Salfred struct thread *uio_td; /* owner */ 711541Srgrimes}; 721541Srgrimes 731541Srgrimes/* 741541Srgrimes * Limits 7578431Swollman * 7678431Swollman * N.B.: UIO_MAXIOV must be no less than IOV_MAX from <sys/syslimits.h> 7778431Swollman * which in turn must be no less than _XOPEN_IOV_MAX from <limits.h>. If 7878431Swollman * we ever make this tunable (probably pointless), then IOV_MAX should be 7978431Swollman * removed from <sys/syslimits.h> and applications would be expected to use 8078431Swollman * sysconf(3) to find out the correct value, or else assume the worst 8178431Swollman * (_XOPEN_IOV_MAX). Perhaps UIO_MAXIOV should be simply defined as 8278431Swollman * IOV_MAX. 831541Srgrimes */ 841541Srgrimes#define UIO_MAXIOV 1024 /* max 1K of iov's */ 851541Srgrimes 8631855Sbdestruct vm_object; 87127236Salcstruct vm_page; 88292348Skenstruct bus_dma_segment; 892811Sbde 90131897Sphkstruct uio *cloneuio(struct uio *uiop); 91123852Salfredint copyinfrom(const void * __restrict src, void * __restrict dst, 92123852Salfred size_t len, int seg); 93227496Salfredint copyiniov(const struct iovec *iovp, u_int iovcnt, struct iovec **iov, 94131897Sphk int error); 95123852Salfredint copyinstrfrom(const void * __restrict src, void * __restrict dst, 96123852Salfred size_t len, size_t * __restrict copied, int seg); 97227496Salfredint copyinuio(const struct iovec *iovp, u_int iovcnt, struct uio **uiop); 98220100Skibint copyout_map(struct thread *td, vm_offset_t *addr, size_t sz); 99220100Skibint copyout_unmap(struct thread *td, vm_offset_t addr, size_t sz); 100246713Skibint physcopyin(void *src, vm_paddr_t dst, size_t len); 101246713Skibint physcopyout(vm_paddr_t src, void *dst, size_t len); 102292348Skenint physcopyin_vlist(struct bus_dma_segment *src, off_t offset, 103292348Sken vm_paddr_t dst, size_t len); 104292348Skenint physcopyout_vlist(vm_paddr_t src, struct bus_dma_segment *dst, 105292348Sken off_t offset, size_t len); 106123887Sbdeint uiomove(void *cp, int n, struct uio *uio); 107123887Sbdeint uiomove_frombuf(void *buf, int buflen, struct uio *uio); 108127236Salcint uiomove_fromphys(struct vm_page *ma[], vm_offset_t offset, int n, 109127236Salc struct uio *uio); 110223889Skibint uiomove_nofault(void *cp, int n, struct uio *uio); 111254601Skibint uiomove_object(struct vm_object *obj, off_t obj_size, struct uio *uio); 1122811Sbde 11355205Speter#else /* !_KERNEL */ 1142811Sbde 1151541Srgrimes__BEGIN_DECLS 11692719Salfredssize_t readv(int, const struct iovec *, int); 11792719Salfredssize_t writev(int, const struct iovec *, int); 118189816Sdas#if __BSD_VISIBLE 119147813Sjhbssize_t preadv(int, const struct iovec *, int, off_t); 120147813Sjhbssize_t pwritev(int, const struct iovec *, int, off_t); 121189816Sdas#endif 1221541Srgrimes__END_DECLS 1232811Sbde 12455205Speter#endif /* _KERNEL */ 1252811Sbde 1261541Srgrimes#endif /* !_SYS_UIO_H_ */ 127