- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

# lib/dmapool.c

    00001 #include <assert.h>
    00002 #include <dmapool.h>
    00003 #include <physmem.h>
    00004
    00005 #ifndef dma_pool_small_physmem_pool
    00006 # define dma_pool_small_physmem_pool    hsb_sram_pool
    00007 #endif
    00008 #ifndef dma_pool_large_physmem_pool
    00009 # define dma_pool_large_physmem_pool    hsb_sram_pool
    00010 #endif
    00011
    00030 void dma_pool_init_coherent_physmem(struct dma_pool *dmapool,
    00031                 struct physmem_pool *phys_pool, unsigned int nr_objects,
    00032                 size_t objsize, unsigned int align_order)
    00033 {
    00034         phys_addr_t     pool_addr;
    00035         size_t          pool_size;
    00036         size_t          block_size;
    00037
    00038         assert(dmapool);
    00039         assert(phys_pool);
    00040         assert(nr_objects > 0);
    00041
    00042         block_size = round_up(objsize, align_order);
    00043         pool_size = nr_objects * block_size;
    00044
    00045         pool_addr = physmem_alloc(phys_pool, pool_size, align_order);
    00046         assert(pool_addr != PHYSMEM_ALLOC_ERR);
    00047
    00048         dma_pool_init_coherent(dmapool, pool_addr, pool_size,
    00049                         objsize, align_order);
    00050 }
    00051
    00052 #ifdef CONFIG_DMAPOOL_GENERIC_POOLS
    00053 #include <app/config_dmapool.h>
    00054
    00055 #ifdef CONFIG_DMAPOOL_SMALL_OBJ_SIZE
    00056 struct dma_pool dmapool_size_small;
    00057 #endif
    00058 #ifdef CONFIG_DMAPOOL_LARGE_OBJ_SIZE
    00059 struct dma_pool dmapool_size_large;
    00060 #endif
    00061
    00062 void *dma_alloc_noninline(phys_addr_t *phys, size_t size)
    00063 {
    00064         return dma_alloc_inline(phys, size);
    00065 }
    00066
    00067 void dma_free_noninline(const void *obj, size_t size)
    00068 {
    00069         return dma_free_inline(obj, size);
    00070 }
    00071
    00078 void dma_pool_init(void)
    00079 {
    00080 #ifdef CONFIG_DMAPOOL_LARGE_OBJ_SIZE
    00081         dma_pool_init_coherent_physmem(&dmapool_size_large,
    00082                         &dma_pool_large_physmem_pool,
    00083                         CONFIG_DMAPOOL_NR_LARGE_OBJS,
    00084                         CONFIG_DMAPOOL_LARGE_OBJ_SIZE, CPU_DMA_ALIGN);
    00085 #endif
    00086 #ifdef CONFIG_DMAPOOL_SMALL_OBJ_SIZE
    00087         dma_pool_init_coherent_physmem(&dmapool_size_small,
    00088                         &dma_pool_small_physmem_pool,
    00089                         CONFIG_DMAPOOL_NR_SMALL_OBJS,
    00090                         CONFIG_DMAPOOL_SMALL_OBJ_SIZE, CPU_DMA_ALIGN);
    00091 #endif
    00092 }
    00093 #endif /* CONFIG_DMAPOOL_GENERIC_POOLS */