The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/xio.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2003,2004 The DragonFly Project.  All rights reserved.
    3  * 
    4  * This code is derived from software contributed to The DragonFly Project
    5  * by Matthew Dillon <dillon@backplane.com>
    6  * 
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in
   15  *    the documentation and/or other materials provided with the
   16  *    distribution.
   17  * 3. Neither the name of The DragonFly Project nor the names of its
   18  *    contributors may be used to endorse or promote products derived
   19  *    from this software without specific, prior written permission.
   20  * 
   21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
   24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
   25  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   26  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
   27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
   29  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   31  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   32  * SUCH DAMAGE.
   33  * 
   34  * $DragonFly: src/sys/sys/xio.h,v 1.10 2007/08/13 17:20:05 dillon Exp $
   35  */
   36 
   37 /*
   38  * An XIO holds a platform-agnostic page list representing a data set for
   39  * the purposes of I/O, mapping (SFBUF/MSFBUF), or other operations.  The
   40  * representation of the data set is byte aligned.  xio_offset and xio_bytes
   41  * specifies the precise byte-ranged block within the page list being
   42  * represented.
   43  *
   44  * XIOs do not track an ongoing I/O, they simply represent a block of data.
   45  * For this reason most XIO API functions have a 'uoffset' argument which
   46  * the caller may use to index within the represented dataset.  This index
   47  * is relative to the represented dataset, NOT to the beginning of the
   48  * first page.
   49  */
   50 #ifndef _SYS_XIO_H_
   51 #define _SYS_XIO_H_
   52 
   53 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
   54 
   55 #ifndef _SYS_TYPES_H_
   56 #include <sys/types.h>
   57 #endif
   58 #ifndef _SYS_UIO_H_
   59 #include <sys/uio.h>
   60 #endif
   61 #ifndef _SYS_MSGPORT_H_
   62 #include <sys/msgport.h>
   63 #endif
   64 #ifndef _MACHINE_PARAM_H_
   65 #include <machine/param.h>
   66 #endif
   67 
   68 #define XIO_INTERNAL_PAGES      btoc(MAXPHYS)
   69 #define XIO_INTERNAL_SIZE       (XIO_INTERNAL_PAGES * PAGE_SIZE)
   70 
   71 struct vm_page;
   72 
   73 struct xio {
   74         struct vm_page **xio_pages;
   75         int     xio_npages;     /* number of pages in xio_pages[] array */
   76         int     xio_offset;     /* byte offset (may exceed a page) */
   77         int     xio_bytes;      /* number of bytes to transfer */
   78         int     xio_flags;
   79         int     xio_error;
   80         struct vm_page *xio_internal_pages[XIO_INTERNAL_PAGES];
   81 };
   82 
   83 typedef struct xio *xio_t;
   84 
   85 #define XIOF_READ       0x0001
   86 #define XIOF_WRITE      0x0002
   87 #define XIOF_VMLINEAR   0x0004  /* must be VM object linear */
   88 
   89 #endif
   90 
   91 #if defined(_KERNEL)
   92 
   93 void xio_init(xio_t xio);
   94 int xio_init_ubuf(xio_t xio, void *ubase, size_t ubytes, int vmprot);
   95 int xio_init_kbuf(xio_t xio, void *kbase, size_t kbytes);
   96 int xio_init_pages(xio_t xio, struct vm_page **mbase, int npages, int xflags);
   97 void xio_release(xio_t xio);
   98 int xio_uio_copy(xio_t xio, int uoffset, struct uio *uio, size_t *sizep);
   99 int xio_copy_xtou(xio_t xio, int uoffset, void *uptr, int bytes);
  100 int xio_copy_xtok(xio_t xio, int uoffset, void *kptr, int bytes);
  101 int xio_copy_utox(xio_t xio, int uoffset, const void *uptr, int bytes);
  102 int xio_copy_ktox(xio_t xio, int uoffset, const void *kptr, int bytes);
  103 
  104 /*
  105  * XIOs are not modified by copy operations, the caller must track the 
  106  * offset itself.  This routine will return the number of bytes remaining
  107  * in an XIO's buffer given an offset relative to the buffer used to
  108  * originally construct the XIO.
  109  */
  110 static __inline
  111 int
  112 xio_remaining(xio_t xio, int uoffset)
  113 {
  114         return(xio->xio_bytes - uoffset);
  115 }
  116 
  117 /*
  118  * XIOs do not map data but if the page list WERE mapped, this routine will
  119  * return the actual KVA offset given a user offset relative to the original
  120  * buffer used to construct the XIO.
  121  */
  122 static __inline
  123 int
  124 xio_kvaoffset(xio_t xio, int uoffset)
  125 {
  126         return(xio->xio_offset + uoffset);
  127 }
  128 
  129 #endif /* _KERNEL */
  130 
  131 #endif /* !_SYS_XIO_H_ */

Cache object: a2fc0c6a538be5b84e5f4252deee6fe7


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.