00001
00038 #ifndef DMAPOOL_H_INCLUDED
00039 #define DMAPOOL_H_INCLUDED
00040
00041 #include <cpu/dmapool.h>
00042
00061 void dma_pool_init_coherent_physmem(struct dma_pool *dmapool,
00062 struct physmem_pool *phys_pool, unsigned int nr_objects,
00063 size_t objsize, unsigned int align_order);
00064
00100
00101 #include <assert.h>
00102 #include <app/dmapool.h>
00103
00130 #ifdef CONFIG_DMAPOOL_SMALL_OBJ_SIZE
00131 extern struct dma_pool dmapool_size_small;
00132 #endif
00133 #ifdef CONFIG_DMAPOOL_LARGE_OBJ_SIZE
00134 extern struct dma_pool dmapool_size_large;
00135 #endif
00136
00137 static inline struct dma_pool *dmapool_find_pool(size_t alloc_size)
00138 {
00139 #ifdef CONFIG_DMAPOOL_SMALL_OBJ_SIZE
00140 if (alloc_size <= CONFIG_DMAPOOL_SMALL_OBJ_SIZE)
00141 return &dmapool_size_small;
00142 #endif
00143 #ifdef CONFIG_DMAPOOL_LARGE_OBJ_SIZE
00144 if (alloc_size <= CONFIG_DMAPOOL_LARGE_OBJ_SIZE)
00145 return &dmapool_size_large;
00146 #endif
00147
00148 return NULL;
00149 }
00150
00151 static inline dma_addr_t dma_alloc_inline(size_t size)
00152 {
00153 struct dma_pool *pool;
00154
00155 pool = dmapool_find_pool(size);
00156 if (likely(pool))
00157 return dma_pool_alloc(pool);
00158 else
00159 return dma_addr_failure();
00160 }
00161
00162 extern dma_addr_t dma_alloc_noninline(size_t size);
00163
00176 static inline dma_addr_t dma_alloc(size_t size)
00177 {
00178 if (is_constant(size))
00179 return dma_alloc_inline(size);
00180 else
00181 return dma_alloc_noninline(size);
00182 }
00183
00184 static inline void dma_free_inline(dma_addr_t obj, size_t size)
00185 {
00186 struct dma_pool *pool;
00187
00188 pool = dmapool_find_pool(size);
00189 assert(pool);
00190 dma_pool_free(pool, obj);
00191 }
00192
00193 extern void dma_free_noninline(dma_addr_t obj, size_t size);
00194
00205 static inline void dma_free(dma_addr_t obj, size_t size)
00206 {
00207 if (is_constant(size))
00208 dma_free_inline(obj, size);
00209 else
00210 dma_free_noninline(obj, size);
00211 }
00212
00213 extern void dma_pool_init(void);
00214
00216
00217
00218
00220
00221 #endif