Public Member Functions | |
| EmacTestMemoryManager () | |
| Creates emac test memory manager. More... | |
| virtual emac_mem_buf_t * | alloc_heap (uint32_t size, uint32_t align) |
| Allocates memory buffer from the heap. More... | |
| emac_mem_buf_t * | alloc_heap (uint32_t size, uint32_t align, uint8_t opt) |
| Allocates memory buffer from the heap. More... | |
| virtual emac_mem_buf_t * | alloc_pool (uint32_t size, uint32_t align) |
| Allocates memory buffer chain from a pool. More... | |
| emac_mem_buf_t * | alloc_pool (uint32_t size, uint32_t align, uint8_t opt) |
| Allocates memory buffer chain from a pool. More... | |
| virtual uint32_t | get_pool_alloc_unit (uint32_t align) const |
| Get memory buffer pool allocation unit. More... | |
| virtual void | free (emac_mem_buf_t *buf) |
| Free memory buffer chain. More... | |
| virtual uint32_t | get_total_len (const emac_mem_buf_t *buf) const |
| Return total length of a memory buffer chain. More... | |
| virtual void | copy (emac_mem_buf_t *to_buf, const emac_mem_buf_t *from_buf) |
| Copy a memory buffer chain. More... | |
| virtual void | cat (emac_mem_buf_t *to_buf, emac_mem_buf_t *cat_buf) |
| Concatenate two memory buffer chains. More... | |
| virtual emac_mem_buf_t * | get_next (const emac_mem_buf_t *buf) const |
| Returns the next buffer. More... | |
| virtual void * | get_ptr (const emac_mem_buf_t *buf) const |
| Return pointer to the payload of the buffer. More... | |
| virtual uint32_t | get_len (const emac_mem_buf_t *buf) const |
| Return payload size of the buffer. More... | |
| virtual void | set_len (emac_mem_buf_t *buf, uint32_t len) |
| Sets the payload size of the buffer. More... | |
| virtual void | set_alloc_unit (uint32_t alloc_unit) |
| Sets memory buffer pool allocation unit. More... | |
| void | set_memory_available (bool memory) |
| Sets whether memory is available. More... | |
| void | get_memory_statistics (int *buffers, int *memory) |
| Gets memory statistics. More... | |
| virtual void | copy_to_buf (net_stack_mem_buf_t *to_buf, const void *ptr, uint32_t len) |
| Copy to a memory buffer chain. More... | |
| virtual uint32_t | copy_from_buf (void *ptr, uint32_t len, const net_stack_mem_buf_t *from_buf) const |
| Copy from a memory buffer chain. More... | |
Definition at line 37 of file emac_TestMemoryManager.h.
Creates emac test memory manager.
|
virtual |
Allocates memory buffer from the heap.
Memory buffer allocated from heap is always contiguous and can be arbitrary size.
| size | Size of the memory to allocate in bytes |
| align | Memory alignment requirement in bytes |
Implements NetStackMemoryManager.
| emac_mem_buf_t* alloc_heap | ( | uint32_t | size, |
| uint32_t | align, | ||
| uint8_t | opt | ||
| ) |
Allocates memory buffer from the heap.
Memory buffer allocated from heap is always contiguous and can be arbitrary size.
| size | Size of the memory to allocate in bytes |
| align | Memory alignment requirement in bytes |
| opt | Options |
|
virtual |
Allocates memory buffer chain from a pool.
Memory allocated from pool is contiguous if size is equal or less than (aligned) allocation unit, otherwise may be chained. Will typically come from fixed-size packet pool memory.
| size | Total size of the memory to allocate in bytes |
| align | Memory alignment requirement for each buffer in bytes |
Implements NetStackMemoryManager.
| emac_mem_buf_t* alloc_pool | ( | uint32_t | size, |
| uint32_t | align, | ||
| uint8_t | opt | ||
| ) |
Allocates memory buffer chain from a pool.
Memory allocated from pool is contiguous if size is equal or less than (aligned) allocation unit, otherwise may be chained. Will typically come from fixed-size packet pool memory.
| size | Total size of the memory to allocate in bytes |
| align | Memory alignment requirement for each buffer in bytes |
| opt | Options |
|
virtual |
Concatenate two memory buffer chains.
Concatenates buffer chain to end of the other buffer chain. Concatenated-to buffer total length is adjusted accordingly. cat_buf must point to the start of a the chain. After concatenation to_buf's chain now owns those buffers, and they will be freed when the to_buf chain is freed.
| to_buf | Memory buffer chain to concatenate to |
| cat_buf | Memory buffer chain to concatenate |
Implements NetStackMemoryManager.
|
virtual |
Copy a memory buffer chain.
Copies data from one buffer chain to another. Copy operation does not adjust the lengths of the copied-to memory buffer chain, so chain total lengths must be the same.
| to_buf | Memory buffer chain to copy to |
| from_buf | Memory buffer chain to copy from |
Implements NetStackMemoryManager.
|
virtualinherited |
Copy from a memory buffer chain.
Copies data from a memory buffer chain.
| len | Data length |
| ptr | Pointer to data |
| from_buf | Memory buffer chain to copy from |
|
virtualinherited |
Copy to a memory buffer chain.
Copies data to a buffer chain. Copy operation does not adjust the lengths of the copied-to memory buffer chain, so chain total length must match the copied length.
| to_buf | Memory buffer chain to copy to |
| ptr | Pointer to data |
| len | Data length |
|
virtual |
Free memory buffer chain.
If memory buffer is chained must point to the start of the chain. Frees all buffers from the chained list.
| buf | Memory buffer chain to be freed. |
Implements NetStackMemoryManager.
|
virtual |
Return payload size of the buffer.
| buf | Memory buffer |
Implements NetStackMemoryManager.
| void get_memory_statistics | ( | int * | buffers, |
| int * | memory | ||
| ) |
Gets memory statistics.
Gets memory usage statistics
| buffers | Number of buffers that are reserved |
| memory | Reserved memory in bytes |
|
virtual |
Returns the next buffer.
Returns the next buffer from the memory buffer chain.
| buf | Memory buffer |
Implements NetStackMemoryManager.
|
virtual |
Get memory buffer pool allocation unit.
Returns the maximum size of contiguous memory that can be allocated from a pool.
| align | Memory alignment requirement in bytes |
Implements NetStackMemoryManager.
|
virtual |
Return pointer to the payload of the buffer.
| buf | Memory buffer |
Implements NetStackMemoryManager.
|
virtual |
Return total length of a memory buffer chain.
Returns a total length of this buffer and any following buffers in the chain.
| buf | Memory buffer chain |
Implements NetStackMemoryManager.
|
virtual |
Sets memory buffer pool allocation unit.
Sets the maximum size of contiguous memory that can be allocated from a pool.
| alloc_unit | Contiguous memory size |
|
virtual |
Sets the payload size of the buffer.
The allocated payload size will not change. It is not permitted to change the length of a buffer that is not the first (or only) in a chain.
| buf | Memory buffer |
| len | Payload size, must be less or equal allocated size |
Implements NetStackMemoryManager.
| void set_memory_available | ( | bool | memory | ) |
Sets whether memory is available.
Can be used to disable memory allocation request from emac.
| memory | True if memory is available |