89#if VSF_USE_POOL == ENABLED
94#define __PLOOC_CLASS_USE_STRICT_TEMPLATE__
96#if defined(__VSF_POOL_CLASS_IMPLEMENT)
97# define __PLOOC_CLASS_IMPLEMENT__
98# undef __VSF_POOL_CLASS_IMPLEMENT
99#elif defined(__VSF_POOL_CLASS_INHERIT__)
100# define __PLOOC_CLASS_INHERIT__
101# undef __VSF_POOL_CLASS_INHERIT__
112#ifndef VSF_POOL_CFG_STATISTIC_MODE
113# define VSF_POOL_CFG_STATISTIC_MODE ENABLED
116#ifndef VSF_POOL_CFG_FEED_ON_HEAP
117# define VSF_POOL_CFG_FEED_ON_HEAP ENABLED
120#ifndef VSF_POOL_CFG_SUPPORT_USER_OBJECT
121# define VSF_POOL_CFG_SUPPORT_USER_OBJECT ENABLED
124#define __vsf_pool(__name) __name##_pool_t
125#define __vsf_pool_item(__name) __name##_pool_item_t
127#define __declare_vsf_pool(__name) \
128 typedef union vsf_pool_item(__name) vsf_pool_item(__name); \
129 dcl_class(vsf_pool(__name))
131#if VSF_POOL_CFG_SUPPORT_USER_OBJECT == ENABLED
132# define ____define_vsf_pool_tag(__name) \
133 VSF_CAL_SECTION(".text." #__name "_pool_get_tag") \
134 extern uintptr_t __name##_pool_get_tag(vsf_pool(__name) *); \
135 VSF_CAL_SECTION(".text." #__name "_pool_set_tag") \
136 extern uintptr_t __name##_pool_set_tag(vsf_pool(__name) *, uintptr_t);
137# define ____implement_vsf_pool_tag(__name) \
138 VSF_CAL_WEAK(__name##_pool_get_tag) \
139 VSF_CAL_SECTION(".text." #__name "_pool_get_tag") \
140 uintptr_t __name##_pool_get_tag(vsf_pool(__name) *this_ptr) \
142 return vsf_pool_get_tag((vsf_pool_t *)this_ptr); \
144 VSF_CAL_WEAK(__name##_pool_set_tag) \
145 VSF_CAL_SECTION(".text." #__name "_pool_set_tag") \
146 uintptr_t __name##_pool_set_tag( vsf_pool(__name) *this_ptr, \
147 uintptr_t target_ptr) \
149 return vsf_pool_set_tag((vsf_pool_t *)this_ptr, target_ptr); \
151# define __define_vsf_pool_tag(__name) ____define_vsf_pool_tag(__name)
152# define __implement_vsf_pool_tag(__name) ____implement_vsf_pool_tag(__name)
154# define __define_vsf_pool_tag(__name)
155# define __implement_vsf_pool_tag(__name)
158#define __define_vsf_pool(__name, __type) \
159 union vsf_pool_item(__name) { \
160 implement(vsf_slist_t) \
163 def_class(vsf_pool(__name), \
165 implement(vsf_pool_t) \
168 end_def_class(vsf_pool(__name)) \
169 extern void __name##_pool_init(vsf_pool(__name) *, vsf_pool_cfg_t *); \
170 VSF_CAL_SECTION(".text." #__name "_pool_init_ex") \
171 extern void __name##_pool_init_ex( \
172 vsf_pool(__name) *, uint_fast16_t, vsf_pool_cfg_t *); \
173 extern bool __name##_pool_add_buffer( \
174 vsf_pool(__name) *, uintptr_t, uint_fast32_t ); \
175 extern __type *__name##_pool_alloc(vsf_pool(__name) *); \
176 extern void __name##_pool_free(vsf_pool(__name) *, __type *); \
177 VSF_CAL_SECTION(".text." #__name "_pool_add_buffer_ex") \
178 extern bool __name##_pool_add_buffer_ex( \
179 vsf_pool(__name) *this_ptr, \
181 uint_fast32_t u32_size, \
182 vsf_pool_item_init_evt_handler_t *handler_fn); \
183 VSF_CAL_SECTION(".text." #__name "_get_pool_item_count") \
184 extern uint_fast32_t __name##_get_pool_item_count(vsf_pool(__name) *); \
185 VSF_CAL_SECTION(".text." #__name "_pool_get_region") \
186 extern vsf_protect_region_t *__name##_pool_get_region(vsf_pool(__name) *); \
187 __define_vsf_pool_tag(__name)
190#define __implement_vsf_pool(__name, __type) \
191VSF_CAL_WEAK(__name##_pool_init) \
192void __name##_pool_init(vsf_pool(__name) *this_ptr, vsf_pool_cfg_t *cfg_ptr) \
194 vsf_pool_init( &(this_ptr->use_as__vsf_pool_t), \
196 VSF_CAL_ALIGN_OF(__type), \
199void __name##_pool_init_ex( vsf_pool(__name) *this_ptr, \
200 uint_fast16_t align, \
201 vsf_pool_cfg_t *cfg_ptr) \
203 vsf_pool_init( &(this_ptr->use_as__vsf_pool_t), \
205 vsf_max(align,VSF_CAL_ALIGN_OF(__type)), \
208VSF_CAL_WEAK(__name##_pool_add_buffer) \
209bool __name##_pool_add_buffer( \
210 vsf_pool(__name) *this_ptr, uintptr_t buffer_ptr, uint_fast32_t u32_size) \
212 return vsf_pool_add_buffer((vsf_pool_t *)this_ptr, buffer_ptr, \
213 u32_size, sizeof(vsf_pool_item(__name))); \
215VSF_CAL_WEAK(__name##_pool_add_buffer_ex) \
216VSF_CAL_SECTION(".text." #__name "_pool_add_buffer_ex") \
217bool __name##_pool_add_buffer_ex( \
218 vsf_pool(__name) *this_ptr, \
220 uint_fast32_t u32_size, \
221 vsf_pool_item_init_evt_handler_t *handler_fn) \
223 return vsf_pool_add_buffer_ex( \
224 (vsf_pool_t *)this_ptr, (uintptr_t)buffer_ptr, \
226 sizeof(vsf_pool_item(__name)), \
229VSF_CAL_WEAK(__name##_pool_alloc) \
230__type *__name##_pool_alloc(vsf_pool(__name) *this_ptr) \
232 return (__type *)vsf_pool_alloc((vsf_pool_t *)this_ptr); \
234VSF_CAL_WEAK(__name##_pool_free) \
235void __name##_pool_free(vsf_pool(__name) *this_ptr, __type *item_ptr) \
237 vsf_pool_free((vsf_pool_t *)this_ptr, (uintptr_t)item_ptr); \
239VSF_CAL_WEAK(__name##_get_pool_item_count) \
240VSF_CAL_SECTION(".text." #__name "_get_pool_item_count") \
241uint_fast32_t __name##_get_pool_item_count(vsf_pool(__name) *this_ptr) \
243 return vsf_pool_get_count((vsf_pool_t *)this_ptr); \
245VSF_CAL_WEAK(__name##_pool_get_region) \
246VSF_CAL_SECTION(".text." #__name "_pool_get_region") \
247vsf_protect_region_t *__name##_pool_get_region(vsf_pool(__name) *this_ptr) \
249 return vsf_pool_get_region((vsf_pool_t *)this_ptr); \
251__implement_vsf_pool_tag(__name)
258#define vsf_pool(__name) __vsf_pool(__name)
259#define vsf_pool_item(__name) __vsf_pool_item(__name)
261#define declare_vsf_pool(__name) \
262 __declare_vsf_pool(__name)
264#define dcl_vsf_pool(__name) \
265 declare_vsf_pool(__name)
267#define define_vsf_pool(__name, \
269 __define_vsf_pool(__name, __type)
271#define def_vsf_pool(__name, \
273 define_vsf_pool(__name, __type)
275#define end_def_pool(__name)
276#define end_define_pool(__name)
278#define implement_vsf_pool(__name, \
280 __implement_vsf_pool(__name, __type)
282#define imp_vsf_pool(__name, \
284 implement_vsf_pool(__name, __type)
286#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
287#define VSF_POOL_INIT(__NAME, \
292 vsf_pool_cfg_t cfg = { \
293 .pool_name_str = (const uint8_t *)#__NAME, \
295 __NAME##_pool_init((__VSF_POOL), &cfg); \
296 static VSF_CAL_NO_INIT vsf_pool_item(__NAME) __buffer[__SIZE]; \
297 vsf_pool_add_buffer((vsf_pool_t *)(__VSF_POOL), \
298 (uintptr_t)__buffer, \
300 sizeof(vsf_pool_item(__NAME))); \
303#define VSF_POOL_INIT(__NAME, \
309 vsf_pool_cfg_t cfg = { \
310 .pool_name_str = (const uint8_t *)#__NAME, \
313 __NAME##_pool_init((__VSF_POOL), &cfg); \
314 static VSF_CAL_NO_INIT vsf_pool_item(__NAME) __buffer[__SIZE]; \
315 vsf_pool_add_buffer((vsf_pool_t *)(__VSF_POOL), \
316 (uintptr_t)__buffer, \
318 sizeof(vsf_pool_item(__NAME))); \
322#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
323#define VSF_POOL_PREPARE(__NAME, \
327 vsf_pool(__name) *this_ptr = (__VSF_POOL); \
328 vsf_pool_cfg_t cfg = { \
329 (const uint8_t *)#__NAME,
331#define END_VSF_POOL_PREPARE(__NAME) \
333 __NAME##_pool_init((this_ptr), &cfg); \
337#define VSF_POOL_PREPARE( \
343 vsf_pool_cfg_t cfg = { \
344 .pool_name_str = (const uint8_t *)#__NAME, \
347 __NAME##_pool_init((__VSF_POOL), &cfg); \
351#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
352#define VSF_POOL_INIT_EX( \
359 vsf_pool_cfg_t cfg = { \
360 .pool_name_str = (const uint8_t *)#__NAME, \
362 __NAME##_pool_init_ex((__VSF_POOL), (__ALIGN), &cfg); \
363 static VSF_CAL_NO_INIT vsf_pool_item(__NAME) \
364 __buffer[__SIZE] VSF_CAL_ALIGN((__ALIGN)); \
365 vsf_pool_add_buffer((vsf_pool_t *)(__VSF_POOL), \
368 sizeof(vsf_pool_item(__NAME))); \
371#define VSF_POOL_INIT_EX( \
379 vsf_pool_cfg_t cfg = { \
380 .pool_name_str = (const uint8_t *)#__NAME, \
383 __NAME##_pool_init_ex((__VSF_POOL), (__ALIGN), &cfg); \
384 static VSF_CAL_NO_INIT vsf_pool_item(__NAME) \
385 __buffer[__SIZE] VSF_CAL_ALIGN((__ALIGN)); \
386 vsf_pool_add_buffer((vsf_pool_t *)(__VSF_POOL), \
389 sizeof(vsf_pool_item(__NAME))); \
393#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
394#define VSF_POOL_PREPARE_EX( \
400 vsf_pool_cfg_t cfg = { \
401 .pool_name_str = (const uint8_t *)#__NAME, \
403 __NAME##_pool_init_ex((__VSF_POOL), (__ALIGN), &cfg); \
406#define VSF_POOL_PREPARE_EX( \
413 vsf_pool_cfg_t cfg = { \
414 .pool_name_str = (const uint8_t *)#__NAME, \
417 __NAME##_pool_init_ex((__VSF_POOL), (__ALIGN), &cfg); \
421#define VSF_POOL_ADD_BUFFER(__NAME, \
425 __NAME##_pool_add_buffer( (__VSF_POOL), \
426 (uintptr_t)(__BUFFER), \
429#define VSF_POOL_ADD_BUFFER_EX(__NAME, \
434 __NAME##_pool_add_buffer_ex((__VSF_POOL), \
435 (uintptr_t)(__BUFFER), \
439#define VSF_POOL_FREE(__NAME, \
443 __NAME##_pool_free((__VSF_POOL), (__ITEM))
445#define VSF_POOL_ALLOC(__NAME, \
447 __NAME##_pool_alloc((__VSF_POOL))
449#define VSF_POOL_ITEM_COUNT(__NAME, \
451 __NAME##_get_pool_item_count((__VSF_POOL))
453#define VSF_POOL_GET_REGION(__NAME, \
455 __NAME##_pool_get_region((__VSF_POOL))
457#if VSF_POOL_CFG_SUPPORT_USER_OBJECT == ENABLED
458#define VSF_POOL_GET_TAG(__NAME, \
460 __NAME##_pool_get_tag((__VSF_POOL))
462#define VSF_POOL_SET_TAG(__NAME, \
465 __NAME##_pool_set_tag((__VSF_POOL), (__TARGET))
475vsf_pool_item_init_evt_handler_t(
uintptr_t target_ptr,
480#if VSF_POOL_CFG_STATISTIC_MODE == ENABLED \
481 || VSF_POOL_CFG_FEED_ON_HEAP == ENABLED
483# if VSF_POOL_CFG_STATISTIC_MODE == ENABLED
512 vsf_pool_item_init_evt_handler_t *item_init_fn;
516#
if !defined(VSF_POOL_CFG_ATOM_ACCESS)
531end_def_class(vsf_pool_t)
538 vsf_pool_item_init_evt_handler_t *item_init_fn;
546 void (*
Init) (vsf_pool_t *obj_ptr,
555 vsf_pool_item_init_evt_handler_t *item_init_fn);
565#if VSF_POOL_CFG_SUPPORT_USER_OBJECT == ENABLED
604 vsf_pool_item_init_evt_handler_t *item_init_fn);
640#if VSF_POOL_CFG_SUPPORT_USER_OBJECT == ENABLED
#define VSF_CAL_SECTION(__SEC)
Definition __compiler.h:181
#define ENABLED
Definition __type.h:28
def_interface(i_adc_t) i_peripheral_t
vsf_err_t(* Init)(vsf_adc_cfg_t *pCfg)
Definition adc_interface.h:38
end_def_interface(i_pm_wakeup_t) struct vsf_pm_pclk_cfg_t
Definition device.h:249
unsigned short uint16_t
Definition lvgl.h:41
unsigned int uint32_t
Definition lvgl.h:43
unsigned char uint8_t
Definition lvgl.h:40
uint32_t uintptr_t
Definition stdint.h:38
unsigned int uint_fast32_t
Definition stdint.h:27
unsigned short uint_fast16_t
Definition stdint.h:25
Definition vsf_pool.h:482
uint16_t u15_align
Definition vsf_pool.h:488
uint16_t is_no_feed_on_heap
Definition vsf_pool.h:489
vsf_slist_node_t const uint8_t * pool_name
Definition vsf_pool.h:485
uint32_t item_size
Definition vsf_pool.h:487
Definition vsf_arch_abstraction.h:54
Definition vsf_list.h:876
Definition vsf_list.h:872
def_class(vsf_stream_fifo_t, which(vsf_stream_tx_t TX;vsf_stream_rx_t RX;), private:vsf_slist_queue_t union { vsf_stream_fifo_cfg_t cfg;struct { vsf_stream_dat_rdy_evt_t tDataReadyEventHandling;vsf_stream_dat_drn_evt_t tDataDrainEventHandling;vsf_stream_status_t Status;#if !defined(VSF_PBUF_QUEUE_CFG_ATOM_ACCESS) vsf_protect_region_t *pregion;#endif };};) end_def_class(vsf_stream_fifo_t) extern vsf_err_t vsf_stream_fifo_init(vsf_stream_fifo_t *obj_ptr
const i_pool_t VSF_POOL
Definition vsf_pool.c:79
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 !
Definition vsf_pool.c:398
uintptr_t(* Set)(vsf_pool_t *obj_ptr, uintptr_t target_ptr)
Definition vsf_pool.h:568
uintptr_t vsf_pool_alloc(vsf_pool_t *obj_ptr)
try to fetch a memory block from the target pool !
Definition vsf_pool.c:232
#define VSF_POOL_CFG_STATISTIC_MODE
Definition vsf_pool.h:113
#define VSF_POOL_CFG_FEED_ON_HEAP
Definition vsf_pool.h:117
bool(* Add)(vsf_pool_t *obj_ptr, uintptr_t buffer_ptr, uint32_t buffer_size, uint32_t item_size)
Definition vsf_pool.h:556
void vsf_pool_free(vsf_pool_t *obj_ptr, uintptr_t item_ptr)
return a memory block to the target pool !
Definition vsf_pool.c:352
bool vsf_pool_add_buffer(vsf_pool_t *obj_ptr, uintptr_t buffer_ptr, uint32_t buffer_size, uint32_t item_size)
add memory to pool !
Definition vsf_pool.c:194
dcl_class(vsf_pool_t) typedef void vsf_pool_item_init_evt_handler_t(uintptr_t target_ptr
void(* Free)(vsf_pool_t *obj_ptr, uintptr_t item_ptr)
Definition vsf_pool.h:563
vsf_protect_region_t * vsf_pool_get_region(vsf_pool_t *obj_ptr)
get the address of the code region used by this pool !
Definition vsf_pool.c:413
uint32_t uint_fast16_t align
Definition vsf_pool.h:548
uintptr_t vsf_pool_get_tag(vsf_pool_t *obj_ptr)
get the address of the object which is attached to the pool !
Definition vsf_pool.c:385
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 !
Definition vsf_pool.c:301
bool(* AddEx)(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)
Definition vsf_pool.h:551
uint32_t uint_fast16_t vsf_pool_cfg_t * cfg_ptr
Definition vsf_pool.h:549
uint_fast16_t vsf_pool_get_count(vsf_pool_t *obj_ptr)
get the number of memory blocks available in the target pool !
Definition vsf_pool.c:371
#define VSF_POOL_CFG_SUPPORT_USER_OBJECT
Definition vsf_pool.h:121
uintptr_t(* Get)(vsf_pool_t *obj_ptr)
Definition vsf_pool.h:567
vsf_pool_cfg_t
Definition vsf_pool.h:539
dcl_interface(i_pool_t) def_interface(i_pool_t) void(*Init)(vsf_pool_t *obj_ptr
uintptr_t uint_fast32_t item_size
Definition vsf_pool.h:477
uintptr_t(* Allocate)(vsf_pool_t *obj_ptr)
Definition vsf_pool.h:562
uintptr_t item_ptr
Definition vsf_pool.h:476
uint_fast16_t(* Count)(vsf_pool_t *obj_ptr)
Definition vsf_pool.h:564
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 !
Definition vsf_pool.c:132