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-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

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

Cache object: eac9add8298639843ca9780223114197


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