# include/buffer.h File Reference

Generic Buffer structure and associated helper functions. More...

`#include <dma.h>`
`#include <slist.h>`
`#include <types.h>`

Include dependency graph for buffer.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## 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, const void *data, phys_addr_t phys, 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, void *data, phys_addr_t phys, size_t len)
| Initialize an already-DMA-mapped buffer for receiving data.

## Detailed Description

Generic Buffer structure and associated helper functions.

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.

- Compiler: IAR EWAVR32 and GNU GCC for AVR32
- Supported devices: All devices with a USB host and/or device controller
- AppNote:

Author:
  Atmel Corporation: http://www.atmel.com
  Support and FAQ: http://support.atmel.no/

Definition in file buffer.h.

## Function Documentation

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(), buffer::len, buffer_addr_t::phys, and buffer_addr_t::ptr.

Referenced by journal_find_last_entry(), and usb_req_alloc_single_rx().

Here is the call graph for this function:

static void buffer_init_rx_mapped | ( | struct buffer * | buf,
|  | void * | data,
|  | phys_addr_t | phys,
|  | size_t | len |
| ) |  |  | `[inline, static]`

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

Parameters:

  | buf | The buffer
  | data | Virtual address of data area to associate with the buffer
  | phys | Physical address of data area
  | len | Length of the data area in bytes

Definition at line 121 of file buffer.h.

References buffer::addr, buffer::len, buffer_addr_t::phys, and buffer_addr_t::ptr.

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 75 of file buffer.h.

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

Referenced by journal_commit_card(), journal_open_entry(), usb_func_get_descriptor(), and usb_req_alloc_single_tx().

Here is the call graph for this function:

static void buffer_init_tx_mapped | ( | struct buffer * | buf,
|  | const void * | data,
|  | phys_addr_t | phys,
|  | size_t | len |
| ) |  |  | `[inline, static]`

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

Parameters:

  | buf | The buffer
  | data | Virtual address of data area to associate with the buffer
  | phys | Physical address of data area
  | len | Length of the data area in bytes

Definition at line 92 of file buffer.h.

References buffer::addr, buffer::len, buffer_addr_t::phys, and buffer_addr_t::ptr.

Referenced by journal_clean_last_entry().