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/memdesc.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) 2012 EMC Corp.
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  *
   26  * $FreeBSD: releng/10.4/sys/sys/memdesc.h 246713 2013-02-12 16:57:20Z kib $
   27  */
   28 
   29 #ifndef _SYS_MEMDESC_H_
   30 #define _SYS_MEMDESC_H_
   31 
   32 struct bio;
   33 struct bus_dma_segment;
   34 struct uio;
   35 struct mbuf;
   36 union ccb;
   37 
   38 /*
   39  * struct memdesc encapsulates various memory descriptors and provides
   40  * abstract access to them.
   41  */
   42 struct memdesc {
   43         union {
   44                 void                    *md_vaddr;
   45                 vm_paddr_t              md_paddr;
   46                 struct bus_dma_segment  *md_list;
   47                 struct bio              *md_bio;
   48                 struct uio              *md_uio;
   49                 struct mbuf             *md_mbuf;
   50                 union ccb               *md_ccb;
   51         } u;
   52         size_t          md_opaque;      /* type specific data. */
   53         uint32_t        md_type;        /* Type of memory. */
   54 };
   55 
   56 #define MEMDESC_VADDR   1       /* Contiguous virtual address. */
   57 #define MEMDESC_PADDR   2       /* Contiguous physical address. */
   58 #define MEMDESC_VLIST   3       /* scatter/gather list of kva addresses. */
   59 #define MEMDESC_PLIST   4       /* scatter/gather list of physical addresses. */
   60 #define MEMDESC_BIO     5       /* Pointer to a bio (block io). */
   61 #define MEMDESC_UIO     6       /* Pointer to a uio (any io). */
   62 #define MEMDESC_MBUF    7       /* Pointer to a mbuf (network io). */
   63 #define MEMDESC_CCB     8       /* Cam control block. (scsi/ata io). */
   64 
   65 static inline struct memdesc
   66 memdesc_vaddr(void *vaddr, size_t len)
   67 {
   68         struct memdesc mem;
   69 
   70         mem.u.md_vaddr = vaddr;
   71         mem.md_opaque = len;
   72         mem.md_type = MEMDESC_VADDR;
   73 
   74         return (mem);
   75 }
   76 
   77 static inline struct memdesc
   78 memdesc_paddr(vm_paddr_t paddr, size_t len)
   79 {
   80         struct memdesc mem;
   81 
   82         mem.u.md_paddr = paddr;
   83         mem.md_opaque = len;
   84         mem.md_type = MEMDESC_PADDR;
   85 
   86         return (mem);
   87 }
   88 
   89 static inline struct memdesc
   90 memdesc_vlist(struct bus_dma_segment *vlist, int sglist_cnt)
   91 {
   92         struct memdesc mem;
   93 
   94         mem.u.md_list = vlist;
   95         mem.md_opaque = sglist_cnt;
   96         mem.md_type = MEMDESC_VLIST;
   97 
   98         return (mem);
   99 }
  100 
  101 static inline struct memdesc
  102 memdesc_plist(struct bus_dma_segment *plist, int sglist_cnt)
  103 {
  104         struct memdesc mem;
  105 
  106         mem.u.md_list = plist;
  107         mem.md_opaque = sglist_cnt;
  108         mem.md_type = MEMDESC_PLIST;
  109 
  110         return (mem);
  111 }
  112 
  113 static inline struct memdesc
  114 memdesc_bio(struct bio *bio)
  115 {
  116         struct memdesc mem;
  117 
  118         mem.u.md_bio = bio;
  119         mem.md_type = MEMDESC_BIO;
  120 
  121         return (mem);
  122 }
  123 
  124 static inline struct memdesc
  125 memdesc_uio(struct uio *uio)
  126 {
  127         struct memdesc mem;
  128 
  129         mem.u.md_uio = uio;
  130         mem.md_type = MEMDESC_UIO;
  131 
  132         return (mem);
  133 }
  134 
  135 static inline struct memdesc
  136 memdesc_mbuf(struct mbuf *mbuf)
  137 {
  138         struct memdesc mem;
  139 
  140         mem.u.md_mbuf = mbuf;
  141         mem.md_type = MEMDESC_MBUF;
  142 
  143         return (mem);
  144 }
  145 
  146 static inline struct memdesc
  147 memdesc_ccb(union ccb *ccb)
  148 {
  149         struct memdesc mem;
  150 
  151         mem.u.md_ccb = ccb;
  152         mem.md_type = MEMDESC_CCB;
  153 
  154         return (mem);
  155 }
  156 #endif /* _SYS_MEMDESC_H_ */

Cache object: efec0c2d6b66af409ad23348118a7a57


[ 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.