VSF Documented
Data Structures | Macros | Functions | Variables
vsf_pool.c File Reference
#include "service/vsf_service_cfg.h"
#include "vsf_pool.h"
#include "hal/arch/vsf_arch.h"
#include "../heap/vsf_heap.h"

Data Structures

struct  __vsf_pool_node_t
 

Macros

#define __VSF_POOL_CLASS_IMPLEMENT
 
#define vsf_this   (*this_ptr)
 
#define VSF_POOL_LOCK()   vsf_this.region_ptr->enter()
 
#define VSF_POOL_UNLOCK()   vsf_this.region_ptr->leave(orig)
 
#define __VSF_POOL_USE_DEFAULT_ATOM_ACCESS
 
#define VSF_POOL_CFG_SUPPORT_USER_ITEM_INIT   ENABLED
 

Typedefs

protected class __vsf_pool_node_t
typedef struct __vsf_pool_node_t __vsf_pool_node_t
 

Functions

void vsf_pool_init (vsf_pool_t *obj_ptr, uint32_t item_size, uint_fast16_t align, vsf_pool_cfg_t *cfg_ptr)
 initialise target pool !
 
bool vsf_pool_add_buffer (vsf_pool_t *this_ptr, uintptr_t buffer_ptr, uint32_t buffer_size, uint32_t item_size)
 add memory to pool !
 
bool vsf_plug_in_on_failed_to_feed_pool_on_heap (vsf_pool_t *obj_ptr)
 
uintptr_t vsf_pool_alloc (vsf_pool_t *obj_ptr)
 try to fetch a memory block from the target pool !
 
bool vsf_pool_add_buffer_ex (vsf_pool_t *obj_ptr, uintptr_t buffer_ptr, uint32_t buffer_size, uint32_t item_size, vsf_pool_item_init_evt_handler_t *item_init_fn)
 add memory to pool !
 
void vsf_pool_free (vsf_pool_t *obj_ptr, uintptr_t pItem)
 return a memory block to the target pool !
 
uint_fast16_t vsf_pool_get_count (vsf_pool_t *obj_ptr)
 get the number of memory blocks available in the target pool !
 
uintptr_t vsf_pool_get_tag (vsf_pool_t *obj_ptr)
 get the address of the object which is attached to the pool !
 
uintptr_t vsf_pool_set_tag (vsf_pool_t *obj_ptr, uintptr_t target_ptr)
 set the address of the object which is attached to the pool !
 
vsf_protect_region_tvsf_pool_get_region (vsf_pool_t *obj_ptr)
 get the address of the code region used by this pool !
 

Variables

const i_pool_t VSF_POOL
 

Macro Definition Documentation

◆ __VSF_POOL_CLASS_IMPLEMENT

#define __VSF_POOL_CLASS_IMPLEMENT

◆ vsf_this

#define vsf_this   (*this_ptr)

◆ VSF_POOL_LOCK

#define VSF_POOL_LOCK ( )    vsf_this.region_ptr->enter()

◆ VSF_POOL_UNLOCK

#define VSF_POOL_UNLOCK ( )    vsf_this.region_ptr->leave(orig)

◆ __VSF_POOL_USE_DEFAULT_ATOM_ACCESS

#define __VSF_POOL_USE_DEFAULT_ATOM_ACCESS

◆ VSF_POOL_CFG_SUPPORT_USER_ITEM_INIT

#define VSF_POOL_CFG_SUPPORT_USER_ITEM_INIT   ENABLED

Typedef Documentation

◆ __vsf_pool_node_t

Function Documentation

◆ vsf_pool_init()

void vsf_pool_init ( vsf_pool_t *  obj_ptr,
uint32_t  item_size,
uint_fast16_t  align,
vsf_pool_cfg_t cfg_ptr 
)

initialise target pool !

Parameters
this_ptraddress of the target pool !
cfg_ptrconfigurations !
Returns
none

add pool to the pool list

◆ vsf_pool_add_buffer()

bool vsf_pool_add_buffer ( vsf_pool_t *  this_ptr,
uintptr_t  buffer_ptr,
uint32_t  buffer_size,
uint32_t  item_size 
)

add memory to pool !

Parameters
this_ptraddress of the target pool !
buffer_ptraddress of the target memory !
buffer_sizethe size of the target memory !
item_sizememory block size of the pool !
Return values
falsethe buffer size is too small or invalid parameters !
truebuffer is added

◆ vsf_plug_in_on_failed_to_feed_pool_on_heap()

bool vsf_plug_in_on_failed_to_feed_pool_on_heap ( vsf_pool_t *  obj_ptr)
Note
return true will let the vsf_pool try again. Usually we can use this function to print out the heap and pool usage info. You can also use this function to allocate more resources to either pool or heap and ask vsf pool to try again.

◆ vsf_pool_alloc()

uintptr_t vsf_pool_alloc ( vsf_pool_t *  obj_ptr)

try to fetch a memory block from the target pool !

Parameters
this_ptraddress of the target pool !
Return values
NULLthe pool is empty !
!NULLaddress of the allocated memory block

feed on heap

◆ vsf_pool_add_buffer_ex()

bool vsf_pool_add_buffer_ex ( vsf_pool_t *  obj_ptr,
uintptr_t  buffer_ptr,
uint32_t  buffer_size,
uint32_t  item_size,
vsf_pool_item_init_evt_handler_t *  item_init_fn 
)

add memory to pool !

Parameters
this_ptraddress of the target pool !
buffer_ptraddress of the target memory !
buffer_sizethe size of the target memory !
item_sizememory block size of the pool !
item_init_fnblock initialisation handler !
Return values
falsethe buffer size is too small or invalid parameters !
truebuffer is added

◆ vsf_pool_free()

void vsf_pool_free ( vsf_pool_t *  obj_ptr,
uintptr_t  pItem 
)

return a memory block to the target pool !

Parameters
this_ptraddress of the target pool !
pItemtarget memory block !
Returns
none

◆ vsf_pool_get_count()

uint_fast16_t vsf_pool_get_count ( vsf_pool_t *  obj_ptr)

get the number of memory blocks available in the target pool !

Parameters
this_ptraddress of the target pool !
Returns
the number of memory blocks

◆ vsf_pool_get_tag()

uintptr_t vsf_pool_get_tag ( vsf_pool_t *  obj_ptr)

get the address of the object which is attached to the pool !

Parameters
this_ptraddress of the target pool !
Returns
the address of the object

◆ vsf_pool_set_tag()

uintptr_t vsf_pool_set_tag ( vsf_pool_t *  obj_ptr,
uintptr_t  target_ptr 
)

set the address of the object which is attached to the pool !

Parameters
this_ptraddress of the target pool !
Returns
the address of the object

◆ vsf_pool_get_region()

vsf_protect_region_t * vsf_pool_get_region ( vsf_pool_t *  obj_ptr)

get the address of the code region used by this pool !

Parameters
this_ptraddress of the target pool !
Returns
the address of the code region

Variable Documentation

◆ VSF_POOL

const i_pool_t VSF_POOL

◆ pool_list

vsf_slist_t pool_list

◆ pool_cnt

uint16_t pool_cnt