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/compat/linuxkpi/common/include/linux/dma-buf-map.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 /* Public domain. */
    2 
    3 #ifndef _LINUX_DMA_BUF_MAP_H
    4 #define _LINUX_DMA_BUF_MAP_H
    5 
    6 #include <linux/io.h>
    7 #include <linux/string.h>
    8 
    9 struct dma_buf_map {
   10         union {
   11                 void *vaddr_iomem;
   12                 void *vaddr;
   13         };
   14         bool is_iomem;
   15 };
   16 
   17 static inline void
   18 dma_buf_map_incr(struct dma_buf_map *dbm, size_t n)
   19 {
   20         if (dbm->is_iomem)
   21                 dbm->vaddr_iomem += n;
   22         else
   23                 dbm->vaddr += n;
   24 }
   25 
   26 static inline void
   27 dma_buf_map_memcpy_to(struct dma_buf_map *dbm, const void *src, size_t len)
   28 {
   29         if (dbm->is_iomem)
   30                 memcpy_toio(dbm->vaddr_iomem, src, len);
   31         else
   32                 memcpy(dbm->vaddr, src, len);
   33 }
   34 
   35 static inline bool
   36 dma_buf_map_is_null(const struct dma_buf_map *dbm)
   37 {
   38         if (dbm->is_iomem)
   39                 return (dbm->vaddr_iomem == NULL);
   40         else
   41                 return (dbm->vaddr == NULL);
   42 }
   43 
   44 static inline bool
   45 dma_buf_map_is_set(const struct dma_buf_map *dbm)
   46 {
   47         if (dbm->is_iomem)
   48                 return (dbm->vaddr_iomem != NULL);
   49         else
   50                 return (dbm->vaddr != NULL);
   51 }
   52 
   53 static inline bool
   54 dma_buf_map_is_equal(
   55     const struct dma_buf_map *dbm_a, const struct dma_buf_map *dbm_b)
   56 {
   57         if (dbm_a->is_iomem != dbm_b->is_iomem)
   58                 return (false);
   59 
   60         if (dbm_a->is_iomem)
   61                 return (dbm_a->vaddr_iomem == dbm_b->vaddr_iomem);
   62         else
   63                 return (dbm_a->vaddr == dbm_b->vaddr);
   64 }
   65 
   66 static inline void
   67 dma_buf_map_clear(struct dma_buf_map *dbm)
   68 {
   69         if (dbm->is_iomem) {
   70                 dbm->vaddr_iomem = NULL;
   71                 dbm->is_iomem = false;
   72         } else {
   73                 dbm->vaddr = NULL;
   74         }
   75 }
   76 
   77 static inline void
   78 dma_buf_map_set_vaddr_iomem(struct dma_buf_map *dbm, void *addr)
   79 {
   80         dbm->vaddr_iomem = addr;
   81         dbm->is_iomem = true;
   82 }
   83 
   84 static inline void
   85 dma_buf_map_set_vaddr(struct dma_buf_map *dbm, void *addr)
   86 {
   87         dbm->vaddr = addr;
   88         dbm->is_iomem = false;
   89 }
   90 
   91 #endif

Cache object: 9694ac649c78e19e1fdea4fad21f018b


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