Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * include/linux/dmapool.h
0003  *
0004  * Allocation pools for DMAable (coherent) memory.
0005  *
0006  * This file is licensed under  the terms of the GNU General Public 
0007  * License version 2. This program is licensed "as is" without any 
0008  * warranty of any kind, whether express or implied.
0009  */
0010 
0011 #ifndef LINUX_DMAPOOL_H
0012 #define LINUX_DMAPOOL_H
0013 
0014 #include <linux/scatterlist.h>
0015 #include <asm/io.h>
0016 
0017 struct device;
0018 
0019 #ifdef CONFIG_HAS_DMA
0020 
0021 struct dma_pool *dma_pool_create(const char *name, struct device *dev, 
0022             size_t size, size_t align, size_t allocation);
0023 
0024 void dma_pool_destroy(struct dma_pool *pool);
0025 
0026 void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
0027              dma_addr_t *handle);
0028 void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t addr);
0029 
0030 /*
0031  * Managed DMA pool
0032  */
0033 struct dma_pool *dmam_pool_create(const char *name, struct device *dev,
0034                   size_t size, size_t align, size_t allocation);
0035 void dmam_pool_destroy(struct dma_pool *pool);
0036 
0037 #else /* !CONFIG_HAS_DMA */
0038 static inline struct dma_pool *dma_pool_create(const char *name,
0039     struct device *dev, size_t size, size_t align, size_t allocation)
0040 { return NULL; }
0041 static inline void dma_pool_destroy(struct dma_pool *pool) { }
0042 static inline void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
0043                    dma_addr_t *handle) { return NULL; }
0044 static inline void dma_pool_free(struct dma_pool *pool, void *vaddr,
0045                  dma_addr_t addr) { }
0046 static inline struct dma_pool *dmam_pool_create(const char *name,
0047     struct device *dev, size_t size, size_t align, size_t allocation)
0048 { return NULL; }
0049 static inline void dmam_pool_destroy(struct dma_pool *pool) { }
0050 #endif /* !CONFIG_HAS_DMA */
0051 
0052 static inline void *dma_pool_zalloc(struct dma_pool *pool, gfp_t mem_flags,
0053                     dma_addr_t *handle)
0054 {
0055     return dma_pool_alloc(pool, mem_flags | __GFP_ZERO, handle);
0056 }
0057 
0058 #endif
0059