00001
00038 #include <assert.h>
00039 #include <dmapool.h>
00040 #include <physmem.h>
00041
00042 #ifndef dma_pool_small_physmem_pool
00043 # define dma_pool_small_physmem_pool dma_sram_pool
00044 #endif
00045 #ifndef dma_pool_large_physmem_pool
00046 # define dma_pool_large_physmem_pool dma_sram_pool
00047 #endif
00048
00067 void dma_pool_init_coherent_physmem(struct dma_pool *dmapool,
00068 struct physmem_pool *phys_pool, unsigned int nr_objects,
00069 size_t objsize, unsigned int align_order)
00070 {
00071 phys_addr_t pool_addr;
00072 size_t pool_size;
00073 size_t block_size;
00074
00075 assert(dmapool);
00076 assert(phys_pool);
00077 assert(nr_objects > 0);
00078
00079 block_size = round_up(objsize, align_order);
00080 pool_size = nr_objects * block_size;
00081
00082 pool_addr = physmem_alloc(phys_pool, pool_size, align_order);
00083 assert(pool_addr != PHYSMEM_ALLOC_ERR);
00084
00085 dma_pool_init_coherent(dmapool, pool_addr, pool_size,
00086 objsize, align_order);
00087 }
00088
00089 #ifdef CONFIG_DMAPOOL_GENERIC_POOLS
00090
00091 #include <app/dmapool.h>
00092
00093 #ifdef CONFIG_DMAPOOL_SMALL_OBJ_SIZE
00094 struct dma_pool dmapool_size_small;
00095 #endif
00096 #ifdef CONFIG_DMAPOOL_LARGE_OBJ_SIZE
00097 struct dma_pool dmapool_size_large;
00098 #endif
00099
00100 dma_addr_t dma_alloc_noninline(size_t size)
00101 {
00102 return dma_alloc_inline(size);
00103 }
00104
00105 void dma_free_noninline(dma_addr_t obj, size_t size)
00106 {
00107 dma_free_inline(obj, size);
00108 }
00109
00116 void dma_pool_init(void)
00117 {
00118 #ifdef CONFIG_DMAPOOL_LARGE_OBJ_SIZE
00119 dma_pool_init_coherent_physmem(&dmapool_size_large,
00120 &dma_pool_large_physmem_pool,
00121 CONFIG_DMAPOOL_NR_LARGE_OBJS,
00122 CONFIG_DMAPOOL_LARGE_OBJ_SIZE, CPU_DMA_ALIGN);
00123 #endif
00124 #ifdef CONFIG_DMAPOOL_SMALL_OBJ_SIZE
00125 dma_pool_init_coherent_physmem(&dmapool_size_small,
00126 &dma_pool_small_physmem_pool,
00127 CONFIG_DMAPOOL_NR_SMALL_OBJS,
00128 CONFIG_DMAPOOL_SMALL_OBJ_SIZE, CPU_DMA_ALIGN);
00129 #endif
00130 }
00131 #endif