Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Buffer Management

Buffer Management (large and small buffers): provides services for dynamically allocating and freeing memory buffers.

Data Structures

struct  buffer_t
 Buffer structure holding information of each buffer. More...
 

Macros

#define BMM_BUFFER_POINTER(buf)   ((buf)->body)
 This macro provides the pointer to the corresponding body of the supplied buffer header. More...
 

Functions

buffer_tbmm_buffer_alloc (uint8_t size)
 Allocates a buffer. More...
 
void bmm_buffer_free (buffer_t *pbuffer)
 Frees up a buffer. More...
 
__PACK__RST_DATA__ void bmm_buffer_init (void)
 Initializes the buffer module. More...
 

Variables

uint8_t * buffer_t::body
 Pointer to the buffer body. More...
 
struct buffer_tag * buffer_t::next
 Pointer to next free buffer. More...
 

#define BMM_BUFFER_POINTER (   buf)    ((buf)->body)

This macro provides the pointer to the corresponding body of the supplied buffer header.

Referenced by handle_received_frame_irq(), and process_incoming_frame().

buffer_t* bmm_buffer_alloc ( uint8_t  size)

Allocates a buffer.

This function allocates a buffer and returns a pointer to the buffer. The same pointer should be used while freeing the buffer.User should call BMM_BUFFER_POINTER(buf) to get the pointer to buffer user area.

Parameters
sizesize of buffer to be allocated.
Returns
pointer to the buffer allocated, NULL if buffer not available.

References LARGE_BUFFER_SIZE, qmm_queue_remove(), and SMALL_BUFFER_SIZE.

Referenced by handle_received_frame_irq(), tal_init(), and tal_task().

void bmm_buffer_free ( buffer_t pbuffer)

Frees up a buffer.

This function frees up a buffer. The pointer passed to this function should be the pointer returned during buffer allocation. The result is unpredictable if an incorrect pointer is passed.

Parameters
pbufferPointer to buffer that has to be freed.

References qmm_queue_append().

Referenced by qmm_queue_flush(), tal_reset(), and tal_rx_frame_cb().

__PACK__RST_DATA__ void bmm_buffer_init ( void  )

Initializes the buffer module.

This function initializes the buffer module. This function should be called before using any other functionality of buffer module.

References buffer_t::body, buf_pool, LARGE_BUFFER_SIZE, qmm_queue_append(), qmm_queue_init(), SMALL_BUFFER_SIZE, TOTAL_NUMBER_OF_LARGE_BUFS, and TOTAL_NUMBER_OF_SMALL_BUFS.

Referenced by tal_init().

uint8_t* buffer_t::body

Pointer to the buffer body.

Referenced by bmm_buffer_init(), and queue_read_or_remove().

struct buffer_tag* buffer_t::next

Pointer to next free buffer.

Referenced by qmm_queue_append(), and queue_read_or_remove().