DMA pool allocator
[Memory Allocation]

Collaboration diagram for DMA pool allocator:

Data Structures

struct  dma_pool
 DMA memory pool. More...

Modules

 Generic DMA pool allocator

Functions

void dma_pool_init_coherent_physmem (struct dma_pool *dmapool, struct physmem_pool *phys_pool, unsigned int nr_objects, size_t objsize, unsigned int align_order)
 Initialize a DMA pool using the physmem allocator.
static void dma_pool_init_coherent (struct dma_pool *pool, phys_addr_t phys_start, size_t size, size_t objsize, unsigned int align_order)
 Initialize a DMA-coherent memory pool.
static dma_addr_t dma_pool_alloc (struct dma_pool *pool)
 Allocate an object from a DMA pool.
static void dma_pool_free (struct dma_pool *pool, dma_addr_t addr)
 Free an object previously allocated from pool.

Detailed Description

This is a memory pool allocator for DMA memory. DMA memory differs from "regular" memory in that both the physical and virtual addresses are kept track of, and cache coherency issues are easier to deal with.

On cache- and MMU-less processors, DMA memory pools are essentially identical to regular memory pools. Nevertheless, it is highly recommended to utilize DMA memory for any memory which is to be used in data transfers involving hardware, as it will make the code more easily portable to other chips.


Function Documentation

dma_addr_t dma_pool_alloc ( struct dma_pool pool  )  [inline, static]

Allocate an object from a DMA pool.

Parameters:
pool The pool from which the object will be allocated

Definition at line 77 of file dmapool_nommu.h.

References mem_pool_alloc(), dma_pool::mempool, and dma_addr_t::ptr.

void dma_pool_free ( struct dma_pool pool,
dma_addr_t  addr 
) [inline, static]

Free an object previously allocated from pool.

Warning:
If an object is freed into a different pool than the one from which it was allocated, or if the same object is freed multiple times, the DMA pool will get corrupted and subsequent allocations may return invalid objects or fail in other, unexpected ways.
Parameters:
pool The pool from which the object was allocated
addr The physical and virtual address of the object

Definition at line 87 of file dmapool_nommu.h.

References mem_pool_free(), dma_pool::mempool, and dma_addr_t::ptr.

void dma_pool_init_coherent ( struct dma_pool pool,
phys_addr_t  phys_start,
size_t  size,
size_t  objsize,
unsigned int  align_order 
) [inline, static]

Initialize a DMA-coherent memory pool.

This function will initialize a pool of fixed-size objects located in DMA-coherent memory. Since the memory is coherent, no cache synchronization is needed before and after DMA data transfers.

Parameters:
pool The DMA pool to be initialized
phys_start The physical address of the underlying memory area
size The size of the underlying memory area in bytes
objsize The size of each object in bytes
align_order log2 of the minimum object alignment in bytes

Definition at line 69 of file dmapool_nommu.h.

References mem_pool_init(), and dma_pool::mempool.

Referenced by dma_pool_init_coherent_physmem().

void dma_pool_init_coherent_physmem ( struct dma_pool dmapool,
struct physmem_pool phys_pool,
unsigned int  nr_objects,
size_t  objsize,
unsigned int  align_order 
)

Initialize a DMA pool using the physmem allocator.

This function will grab enough physical memory for nr_objects from phys_pool and use this to initialize dmapool.

Parameters:
dmapool The DMA pool to be initialized.
phys_pool The physical memory pool from which to grab memory
nr_objects The number of objects in the pool
objsize The size of each object in bytes.
align_order log2 of the minimum object alignment in bytes.
Precondition:
nr_objects must be at least one.
There must be enough available memory in phys_pool.
objsize must be larger than the size of a pointer.
See also:
dma_pool_init()

Definition at line 67 of file dmapool.c.

References assert, dma_pool_init_coherent(), physmem_alloc(), PHYSMEM_ALLOC_ERR, and round_up.

Generated on Thu Apr 29 14:10:34 2010 for xplain-bc by  doxygen 1.6.3