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 buffer * | buffer_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. | |
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 buf_list_entry | ( | slnode | ) | slist_entry(slnode, struct buffer, node) |
| #define buf_list_peek_head | ( | list | ) | slist_peek_head(list, struct buffer, node) |
| #define buf_list_peek_next | ( | buf | ) | slist_peek_next(&(buf)->node, struct buffer, node) |
| #define buf_list_peek_tail | ( | list | ) | slist_peek_tail(list, struct buffer, node) |
| #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.
Referenced by udc_fifo_read_data(), and udc_fifo_write_data().
| struct buffer* buffer_alloc | ( | void | ) | [read] |
Allocate a buffer structure.
Definition at line 49 of file buffer.c.
References buffer::dma_desc, and mem_pool_alloc().
| void buffer_free | ( | struct buffer * | buf | ) |
| static void buffer_init_rx | ( | struct buffer * | buf, | |
| void * | data, | |||
| size_t | len | |||
| ) | [inline, static] |
Initialize a buffer for receiving data.
| 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.
| 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.
| 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.
| 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().
Referenced by main().
| 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.
1.6.3