Generic Buffers

Data Structures

struct  buffer
 A generic data buffer. More...

Functions

static void buffer_init_tx (struct buffer *buf, const void *data, size_t len)
 Initialize a buffer for transmitting data.
static void buffer_init_tx_mapped (struct buffer *buf, dma_addr_t addr, size_t len)
 Initialize an already-DMA-mapped buffer for transmitting data.
static void buffer_init_rx (struct buffer *buf, void *data, size_t len)
 Initialize a buffer for receiving data.
static void buffer_init_rx_mapped (struct buffer *buf, dma_addr_t addr, size_t len)
 Initialize an already-DMA-mapped buffer for receiving data.
struct bufferbuffer_alloc (void)
 Allocate a buffer structure.
void buffer_free (struct buffer *buf)
 Free the buffer structure buf.
void buffer_resize (struct buffer *buf, size_t new_size)
 Resize the buffer pointed to by buf. The caller must make sure the new size fit into the allocated memory space.
void buffer_pool_init (void)
 Initialize the buffer pool.

Buffer List Manipulation

The following macros are simple wrappers around the generic singly-linked-list functionality designed to make it easier to operate on singly linked lists of buffers (which is a very common thing to put on singly linked lists).



#define buf_list_entry(slnode)   slist_entry(slnode, struct buffer, node)
 Convert a slist node to a buffer struct.
#define buf_list_peek_head(list)   slist_peek_head(list, struct buffer, node)
 Return the first buffer in list.
#define buf_list_peek_tail(list)   slist_peek_tail(list, struct buffer, node)
 Return the last buffer in list.
#define buf_list_peek_next(buf)   slist_peek_next(&(buf)->node, struct buffer, node)
 Return the buffer following buf in the list.
#define buf_list_pop_head(list)   slist_pop_head(list, struct buffer, node)
 Return the first buffer in list and remove it.

Detailed Description

This is a generic buffer data structure used by several subsystems. Chains of buffers may be passed around between different drivers, minimizing the cost of copying and data conversion.


Define Documentation

#define buf_list_entry ( slnode   )     slist_entry(slnode, struct buffer, node)

Convert a slist node to a buffer struct.

Definition at line 145 of file buffer.h.

#define buf_list_peek_head ( list   )     slist_peek_head(list, struct buffer, node)

Return the first buffer in list.

Definition at line 148 of file buffer.h.

#define buf_list_peek_next ( buf   )     slist_peek_next(&(buf)->node, struct buffer, node)

Return the buffer following buf in the list.

Definition at line 154 of file buffer.h.

#define buf_list_peek_tail ( list   )     slist_peek_tail(list, struct buffer, node)

Return the last buffer in list.

Definition at line 151 of file buffer.h.

#define buf_list_pop_head ( list   )     slist_pop_head(list, struct buffer, node)

Return the first buffer in list and remove it.

Definition at line 157 of file buffer.h.


Function Documentation

struct buffer* buffer_alloc ( void   )  [read]

Allocate a buffer structure.

Returns:
A new buffer structure, or NULL if the buffer pool is exhausted.

Definition at line 49 of file buffer.c.

References buffer::dma_desc, and mem_pool_alloc().

void buffer_free ( struct buffer buf  ) 

Free the buffer structure buf.

Definition at line 62 of file buffer.c.

References mem_pool_free().

static void buffer_init_rx ( struct buffer buf,
void *  data,
size_t  len 
) [inline, static]

Initialize a buffer for receiving data.

Parameters:
buf The buffer
data Data area to associate with the buffer
len Length of the data area in bytes

Definition at line 106 of file buffer.h.

References buffer::addr, DMA_FROM_DEVICE, dma_map_single(), and buffer::len.

static void buffer_init_rx_mapped ( struct buffer buf,
dma_addr_t  addr,
size_t  len 
) [inline, static]

Initialize an already-DMA-mapped buffer for receiving data.

Parameters:
buf The buffer
addr Physical/virtual address of the data DMA mapping
len Length of the data area in bytes

Definition at line 119 of file buffer.h.

References buffer::addr, and buffer::len.

static void buffer_init_tx ( struct buffer buf,
const void *  data,
size_t  len 
) [inline, static]

Initialize a buffer for transmitting data.

Parameters:
buf The buffer
data Data area to associate with the buffer
len Length of the data area in bytes

Definition at line 78 of file buffer.h.

References buffer::addr, dma_map_single(), DMA_TO_DEVICE, and buffer::len.

static void buffer_init_tx_mapped ( struct buffer buf,
dma_addr_t  addr,
size_t  len 
) [inline, static]

Initialize an already-DMA-mapped buffer for transmitting data.

Parameters:
buf The buffer
addr Physical/virtual address of the data DMA mapping
len Length of the data area in bytes

Definition at line 93 of file buffer.h.

References buffer::addr, and buffer::len.

void buffer_pool_init ( void   ) 

Initialize the buffer pool.

This must be called by the application before any buffers may be allocated from the pool.

Definition at line 129 of file buffer.c.

References cpu_sram_pool, and mem_pool_init_physmem().

void buffer_resize ( struct buffer buf,
size_t  new_size 
)

Resize the buffer pointed to by buf. The caller must make sure the new size fit into the allocated memory space.

Definition at line 71 of file buffer.c.

References assert, and buffer::len.

Generated on Thu Apr 29 15:18:23 2010 for display-training by  doxygen 1.6.3