- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

# include/buffer.h

Go to the documentation of this file.

    00001
    00045 #ifndef BUFFER_H_INCLUDED
    00046 #define BUFFER_H_INCLUDED
    00047
    00048 #include <dma.h>
    00049 #include <slist.h>
    00050 #include <types.h>
    00051
    00058 struct buffer {
    00060         void                    *dma_desc;
    00062         buffer_addr_t           addr;
    00064         size_t                  len;
    00066         struct slist_node       node;
    00067 };
    00068
    00075 static inline void buffer_init_tx(struct buffer *buf,
    00076                 const void *data, size_t len)
    00077 {
    00078         buf->addr.ptr = (void *)data;
    00079         buf->addr.phys = dma_map_single(buf->addr.ptr, len, DMA_TO_DEVICE);
    00080         buf->len = len;
    00081 }
    00082
    00092 static inline void buffer_init_tx_mapped(struct buffer *buf,
    00093                 const void *data, phys_addr_t phys, size_t len)
    00094 {
    00095         buf->addr.ptr = (void *)data;
    00096         buf->addr.phys = phys;
    00097         buf->len = len;
    00098 }
    00099
    00106 static inline void buffer_init_rx(struct buffer *buf, void *data, size_t len)
    00107 {
    00108         buf->addr.ptr = data;
    00109         buf->addr.phys = dma_map_single(data, len, DMA_FROM_DEVICE);
    00110         buf->len = len;
    00111 }
    00112
    00121 static inline void buffer_init_rx_mapped(struct buffer *buf,
    00122                 void *data, phys_addr_t phys, size_t len)
    00123 {
    00124         buf->addr.ptr = data;
    00125         buf->addr.phys = phys;
    00126         buf->len = len;
    00127 }
    00128
    00129 extern struct buffer *buffer_alloc(void);
    00130 extern void buffer_free(struct buffer *buf);
    00131 extern void buffer_resize(struct buffer *buf, size_t new_size);
    00132
    00133 extern struct buffer *buffer_dma_alloc(size_t size);
    00134 extern void buffer_dma_free(struct buffer *buf, size_t size);
    00135
    00136 extern void buffer_pool_init(void);
    00137
    00138 #endif /* BUFFER_H_INCLUDED */