VSF Documented
vsf_pool.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __VSF_POOL_H__
19#define __VSF_POOL_H__
20
21/* example:
22
23 // 0. Include vsf header file
24 #include "vsf.h"
25
26 // 1. Defining type of pool member
27 typedef struct xxxx_t {
28 ......
29 } xxxx_t;
30
31 // 2. Declare the pool with user type
32 dcl_vsf_pool(xxxx_pool)
33
34 // 3. Defining the pool
35 def_vsf_pool(xxxx_pool, xxxx_t)
36
37 // 4. Implement the pool
38 imp_vsf_pool(xxxx_pool, xxxx_t)
39
40 // 5. Defining pool variable
41 static VSF_CAL_NO_INIT vsf_pool(xxxx_pool) __xxxx_pool;
42
43 void user_example_task(void)
44 {
45 ......
46
47 // 6. Initialization user pool with size, attached object and code region .
48 // the attached object and code region can be omitted.
49
50 // VSF_POOL_INIT(xxxx_pool, &__xxxx_pool, 8);
51
52 // if you haven't decided the number of item inside the pool, you can
53 // reply on the so-called "feed-on-heap" feature.
54
55 // VSF_POOL_PREPARE(xxxx_pool, &__xxxx_pool);
56
57 // you just need to use either one of these two APIs mentioned above.
58 // A tyipcal code example taking advantage of those two APIs is:
59
60 #ifndef XXXX_POOL_ITEM_NUM
61 VSF_POOL_PREPARE(xxxx_pool, &__xxxx_pool);
62 #else
63 VSF_POOL_INIT(xxxx_pool, &__xxxx_pool, XXXX_POOL_ITEM_NUM);
64 #endif
65
66 ......
67
68 // 7. Alloc memory from user pool
69 xxxx_t *target_ptr = VSF_POOL_ALLOC(xxxx_pool, &__xxxx_pool);
70 if (NULL != target_ptr) {
71 // 7.1. Do something when alloc successfully
72
73 // 8. Free memory to user pool
74 VSF_POOL_FREE(xxxx_pool, &__xxxx_pool, target_ptr);
75 } else {
76 // 7.2. Do something when alloc failed
77 }
78
79 ......
80 }
81 */
82
83/*============================ INCLUDES ======================================*/
86// for vsf_protect_region support
87#include "hal/arch/vsf_arch.h"
88
89#if VSF_USE_POOL == ENABLED
94#define __PLOOC_CLASS_USE_STRICT_TEMPLATE__
95
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__
102#endif
103
104#include "utilities/ooc_class.h"
105
106#ifdef __cplusplus
107extern "C" {
108#endif
109/*============================ MACROS ========================================*/
110
112#ifndef VSF_POOL_CFG_STATISTIC_MODE
113# define VSF_POOL_CFG_STATISTIC_MODE ENABLED
114#endif
115
116#ifndef VSF_POOL_CFG_FEED_ON_HEAP
117# define VSF_POOL_CFG_FEED_ON_HEAP ENABLED
118#endif
119
120#ifndef VSF_POOL_CFG_SUPPORT_USER_OBJECT
121# define VSF_POOL_CFG_SUPPORT_USER_OBJECT ENABLED
122#endif
123
124#define __vsf_pool(__name) __name##_pool_t
125#define __vsf_pool_item(__name) __name##_pool_item_t
126
127#define __declare_vsf_pool(__name) \
128 typedef union vsf_pool_item(__name) vsf_pool_item(__name); \
129 dcl_class(vsf_pool(__name))
130
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) \
141 { \
142 return vsf_pool_get_tag((vsf_pool_t *)this_ptr); \
143 } \
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) \
148 { \
149 return vsf_pool_set_tag((vsf_pool_t *)this_ptr, target_ptr); \
150 }
151# define __define_vsf_pool_tag(__name) ____define_vsf_pool_tag(__name)
152# define __implement_vsf_pool_tag(__name) ____implement_vsf_pool_tag(__name)
153#else
154# define __define_vsf_pool_tag(__name)
155# define __implement_vsf_pool_tag(__name)
156#endif
157
158#define __define_vsf_pool(__name, __type) \
159 union vsf_pool_item(__name) { \
160 implement(vsf_slist_t) \
161 __type __item; \
162 }; \
163 def_class(vsf_pool(__name), \
164 public_member( \
165 implement(vsf_pool_t) \
166 ) \
167 ) \
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, \
180 void *buffer_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)
188
189
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) \
193{ \
194 vsf_pool_init( &(this_ptr->use_as__vsf_pool_t), \
195 sizeof(__type), \
196 VSF_CAL_ALIGN_OF(__type), \
197 cfg_ptr); \
198} \
199void __name##_pool_init_ex( vsf_pool(__name) *this_ptr, \
200 uint_fast16_t align, \
201 vsf_pool_cfg_t *cfg_ptr) \
202{ \
203 vsf_pool_init( &(this_ptr->use_as__vsf_pool_t), \
204 sizeof(__type), \
205 vsf_max(align,VSF_CAL_ALIGN_OF(__type)), \
206 cfg_ptr); \
207} \
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) \
211{ \
212 return vsf_pool_add_buffer((vsf_pool_t *)this_ptr, buffer_ptr, \
213 u32_size, sizeof(vsf_pool_item(__name))); \
214} \
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, \
219 void *buffer_ptr, \
220 uint_fast32_t u32_size, \
221 vsf_pool_item_init_evt_handler_t *handler_fn) \
222{ \
223 return vsf_pool_add_buffer_ex( \
224 (vsf_pool_t *)this_ptr, (uintptr_t)buffer_ptr, \
225 u32_size, \
226 sizeof(vsf_pool_item(__name)), \
227 handler_fn); \
228} \
229VSF_CAL_WEAK(__name##_pool_alloc) \
230__type *__name##_pool_alloc(vsf_pool(__name) *this_ptr) \
231{ \
232 return (__type *)vsf_pool_alloc((vsf_pool_t *)this_ptr); \
233} \
234VSF_CAL_WEAK(__name##_pool_free) \
235void __name##_pool_free(vsf_pool(__name) *this_ptr, __type *item_ptr) \
236{ \
237 vsf_pool_free((vsf_pool_t *)this_ptr, (uintptr_t)item_ptr); \
238} \
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) \
242{ \
243 return vsf_pool_get_count((vsf_pool_t *)this_ptr); \
244} \
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) \
248{ \
249 return vsf_pool_get_region((vsf_pool_t *)this_ptr); \
250} \
251__implement_vsf_pool_tag(__name)
252
253
254
255
258#define vsf_pool(__name) __vsf_pool(__name)
259#define vsf_pool_item(__name) __vsf_pool_item(__name)
260
261#define declare_vsf_pool(__name) /* the name of the pool */ \
262 __declare_vsf_pool(__name)
263
264#define dcl_vsf_pool(__name) /* the name of the pool */ \
265 declare_vsf_pool(__name)
266
267#define define_vsf_pool(__name, /* the name of the pool */ \
268 __type) /* the type of the unit */ \
269 __define_vsf_pool(__name, __type)
270
271#define def_vsf_pool(__name, /* the name of the pool */ \
272 __type) /* the type of the unit */ \
273 define_vsf_pool(__name, __type)
274
275#define end_def_pool(__name)
276#define end_define_pool(__name)
277
278#define implement_vsf_pool(__name, /* the name of the pool */ \
279 __type) /* the type of the unit */ \
280 __implement_vsf_pool(__name, __type)
281
282#define imp_vsf_pool(__name, /* the name of the pool */ \
283 __type) /* the type of the unit */ \
284 implement_vsf_pool(__name, __type)
285
286#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
287#define VSF_POOL_INIT(__NAME, /* the name of the pool */ \
288 __VSF_POOL, /* the address of the pool */ \
289 __SIZE) /* the total size of the pool */ \
290 /* the address of the code region obj_ptr */\
291 do { \
292 vsf_pool_cfg_t cfg = { \
293 .pool_name_str = (const uint8_t *)#__NAME, \
294 }; \
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, \
299 sizeof(__buffer), \
300 sizeof(vsf_pool_item(__NAME))); \
301 } while(0)
302#else
303#define VSF_POOL_INIT(__NAME, /* the name of the pool */ \
304 __VSF_POOL, /* the address of the pool */ \
305 __SIZE, /* the total size of the pool */ \
306 ...) /* the address of an attached object */ \
307 /* the address of the code region obj_ptr */\
308 do { \
309 vsf_pool_cfg_t cfg = { \
310 .pool_name_str = (const uint8_t *)#__NAME, \
311 __VA_ARGS__ \
312 }; \
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, \
317 sizeof(__buffer), \
318 sizeof(vsf_pool_item(__NAME))); \
319 } while(0)
320#endif
321
322#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
323#define VSF_POOL_PREPARE(__NAME, /* the name of the pool */ \
324 __VSF_POOL) /* the address of the pool */ \
325 /* the address of the code region obj_ptr */\
326 do { \
327 vsf_pool(__name) *this_ptr = (__VSF_POOL); \
328 vsf_pool_cfg_t cfg = { \
329 (const uint8_t *)#__NAME,
330
331#define END_VSF_POOL_PREPARE(__NAME) \
332 }; \
333 __NAME##_pool_init((this_ptr), &cfg); \
334 } while(0);
335
336#else
337#define VSF_POOL_PREPARE( \
338 __NAME, /* the name of the pool */ \
339 __VSF_POOL, /* the address of the pool */ \
340 ...) /* the address of an attached object */ \
341 /* the address of the code region obj_ptr */\
342 do { \
343 vsf_pool_cfg_t cfg = { \
344 .pool_name_str = (const uint8_t *)#__NAME, \
345 __VA_ARGS__ \
346 }; \
347 __NAME##_pool_init((__VSF_POOL), &cfg); \
348 } while(0)
349#endif
350
351#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
352#define VSF_POOL_INIT_EX( \
353 __NAME, /* the name of the pool */ \
354 __VSF_POOL, /* the address of the pool */ \
355 __SIZE, /* the total size of the pool */ \
356 __ALIGN) /* the item alignment */ \
357 /* the address of the code region obj_ptr */\
358 do { \
359 vsf_pool_cfg_t cfg = { \
360 .pool_name_str = (const uint8_t *)#__NAME, \
361 }; \
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), \
366 __buffer, \
367 sizeof(__buffer), \
368 sizeof(vsf_pool_item(__NAME))); \
369 } while(0)
370#else
371#define VSF_POOL_INIT_EX( \
372 __NAME, /* the name of the pool */ \
373 __VSF_POOL, /* the address of the pool */ \
374 __SIZE, /* the total size of the pool */ \
375 __ALIGN, /* the item alignment */ \
376 ...) /* the address of an attached object */ \
377 /* the address of the code region obj_ptr */\
378 do { \
379 vsf_pool_cfg_t cfg = { \
380 .pool_name_str = (const uint8_t *)#__NAME, \
381 __VA_ARGS__ \
382 }; \
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), \
387 __buffer, \
388 sizeof(__buffer), \
389 sizeof(vsf_pool_item(__NAME))); \
390 } while(0)
391#endif
392
393#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
394#define VSF_POOL_PREPARE_EX( \
395 __NAME, /* the name of the pool */ \
396 __VSF_POOL, /* the address of the pool */ \
397 __ALIGN) /* the item alignment */ \
398 /* the address of the code region obj_ptr */\
399 do { \
400 vsf_pool_cfg_t cfg = { \
401 .pool_name_str = (const uint8_t *)#__NAME, \
402 }; \
403 __NAME##_pool_init_ex((__VSF_POOL), (__ALIGN), &cfg); \
404 } while(0)
405#else
406#define VSF_POOL_PREPARE_EX( \
407 __NAME, /* the name of the pool */ \
408 __VSF_POOL, /* the address of the pool */ \
409 __ALIGN, /* the item alignment */ \
410 ...) /* the address of an attached object */ \
411 /* the address of the code region obj_ptr */\
412 do { \
413 vsf_pool_cfg_t cfg = { \
414 .pool_name_str = (const uint8_t *)#__NAME, \
415 __VA_ARGS__ \
416 }; \
417 __NAME##_pool_init_ex((__VSF_POOL), (__ALIGN), &cfg); \
418 } while(0)
419#endif
420
421#define VSF_POOL_ADD_BUFFER(__NAME, /* the name of the pool */ \
422 __VSF_POOL, /* the address of the pool */ \
423 __BUFFER, /* the address of the buffer */ \
424 __SIZE) /* the size of the buffer */ \
425 __NAME##_pool_add_buffer( (__VSF_POOL), \
426 (uintptr_t)(__BUFFER), \
427 (__SIZE))
428
429#define VSF_POOL_ADD_BUFFER_EX(__NAME, /* the name of the pool */ \
430 __VSF_POOL, /* the address of the pool */ \
431 __BUFFER, /* the address of the buffer */ \
432 __SIZE, /* the size of the buffer */ \
433 __HANDLER) /* the block initialisation routine */ \
434 __NAME##_pool_add_buffer_ex((__VSF_POOL), \
435 (uintptr_t)(__BUFFER), \
436 (__SIZE), \
437 (__HANDLER))
438
439#define VSF_POOL_FREE(__NAME, /* the name of the pool */ \
440 __VSF_POOL, /* the address of the pool */ \
441 __ITEM) /* the address of the memory block */ \
442 /* to be released */ \
443 __NAME##_pool_free((__VSF_POOL), (__ITEM))
444
445#define VSF_POOL_ALLOC(__NAME, /* the name of the pool */ \
446 __VSF_POOL) /* the address of the pool */ \
447 __NAME##_pool_alloc((__VSF_POOL))
448
449#define VSF_POOL_ITEM_COUNT(__NAME, /* the name of the pool */ \
450 __VSF_POOL) /* the address of the pool */ \
451 __NAME##_get_pool_item_count((__VSF_POOL))
452
453#define VSF_POOL_GET_REGION(__NAME, /* the name of the pool */ \
454 __VSF_POOL) /* the address of the pool */ \
455 __NAME##_pool_get_region((__VSF_POOL))
456
457#if VSF_POOL_CFG_SUPPORT_USER_OBJECT == ENABLED
458#define VSF_POOL_GET_TAG(__NAME, /* the name of the pool */ \
459 __VSF_POOL) /* the address of the pool */ \
460 __NAME##_pool_get_tag((__VSF_POOL))
461
462#define VSF_POOL_SET_TAG(__NAME, /* the name of the pool */ \
463 __VSF_POOL, /* the address of the pool */ \
464 __TARGET) /* the address of the target */ \
465 __NAME##_pool_set_tag((__VSF_POOL), (__TARGET))
466#endif
468
469/*============================ TYPES =========================================*/
470
471dcl_class(vsf_pool_t)
472
473typedef
474void
475vsf_pool_item_init_evt_handler_t( uintptr_t target_ptr,
478
479
480#if VSF_POOL_CFG_STATISTIC_MODE == ENABLED \
481 || VSF_POOL_CFG_FEED_ON_HEAP == ENABLED
482typedef struct vsf_pool_info_t{
483# if VSF_POOL_CFG_STATISTIC_MODE == ENABLED
484 implement(vsf_slist_node_t)
486# endif
491#endif
492
495def_class(vsf_pool_t,
496
497 private_member(
498 vsf_slist_t free_list;
499 uint16_t free_cnt;
500 uint16_t used_cnt;
501 )
502
505 private_member(
506 implement_ex(vsf_pool_info_t, statistic)
507 )
508#endif
509
511 private_member(
512 vsf_pool_item_init_evt_handler_t *item_init_fn;
513 )
514#endif
515
516#if !defined(VSF_POOL_CFG_ATOM_ACCESS)
517 private_member(
519 vsf_protect_region_t *region_ptr;
520 )
521#endif
522
524 protected_member(
526 uintptr_t target_ptr;
527 )
528#endif
529
530)
531end_def_class(vsf_pool_t)
533
534typedef struct vsf_pool_cfg_t {
535 const uint8_t *pool_name_str;
536 uintptr_t target_ptr;
537 vsf_protect_region_t *region_ptr;
538 vsf_pool_item_init_evt_handler_t *item_init_fn;
540
541
545def_interface(i_pool_t)
546 void (*Init) (vsf_pool_t *obj_ptr,
550 struct {
551 bool (*AddEx) (vsf_pool_t *obj_ptr,
552 uintptr_t buffer_ptr,
553 uint32_t buffer_size,
555 vsf_pool_item_init_evt_handler_t *item_init_fn);
556 bool (*Add) (vsf_pool_t *obj_ptr,
557 uintptr_t buffer_ptr,
558 uint32_t buffer_size,
561
562 uintptr_t (*Allocate) (vsf_pool_t *obj_ptr);
563 void (*Free) (vsf_pool_t *obj_ptr, uintptr_t item_ptr);
564 uint_fast16_t (*Count) (vsf_pool_t *obj_ptr);
565#if VSF_POOL_CFG_SUPPORT_USER_OBJECT == ENABLED
566 struct {
567 uintptr_t (*Get) (vsf_pool_t *obj_ptr);
568 uintptr_t (*Set) (vsf_pool_t *obj_ptr, uintptr_t target_ptr);
570#endif
571end_def_interface(i_pool_t)
573/*============================ GLOBAL VARIABLES ==============================*/
574extern const i_pool_t VSF_POOL;
575
576/*============================ PROTOTYPES ====================================*/
577
585extern void vsf_pool_init( vsf_pool_t *obj_ptr,
589
599extern bool
600vsf_pool_add_buffer_ex( vsf_pool_t *obj_ptr,
601 uintptr_t buffer_ptr,
602 uint32_t buffer_size,
604 vsf_pool_item_init_evt_handler_t *item_init_fn);
605
614extern bool vsf_pool_add_buffer(vsf_pool_t *obj_ptr,
615 uintptr_t buffer_ptr,
616 uint32_t buffer_size,
618
624extern uintptr_t vsf_pool_alloc(vsf_pool_t *obj_ptr);
625
631extern void vsf_pool_free(vsf_pool_t *obj_ptr, uintptr_t item_ptr);
632
633VSF_CAL_SECTION(".text.vsf.utilities.vsf_pool_get_count")
638extern uint_fast16_t vsf_pool_get_count(vsf_pool_t *obj_ptr);
639
640#if VSF_POOL_CFG_SUPPORT_USER_OBJECT == ENABLED
641VSF_CAL_SECTION(".text.vsf.utilities.vsf_pool_get_tag")
646extern uintptr_t vsf_pool_get_tag(vsf_pool_t *obj_ptr);
647
648VSF_CAL_SECTION(".text.vsf.utilities.vsf_pool_set_tag")
653extern uintptr_t vsf_pool_set_tag(vsf_pool_t *obj_ptr, uintptr_t target_ptr);
654#endif
655
656VSF_CAL_SECTION(".text.vsf.utilities.vsf_pool_get_region")
661extern vsf_protect_region_t *vsf_pool_get_region(vsf_pool_t *obj_ptr);
662
663#ifdef __cplusplus
664}
665#endif
666
667#endif
668#endif
#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
bool
Definition type.h:60
end_def_interface(i_pm_wakeup_t) struct vsf_pm_pclk_cfg_t
Definition device.h:249
uint32_t uintptr_t
Definition stdint.h:38
unsigned short uint16_t
Definition stdint.h:7
unsigned uint32_t
Definition stdint.h:9
unsigned int uint_fast32_t
Definition stdint.h:27
unsigned short uint_fast16_t
Definition stdint.h:25
unsigned char uint8_t
Definition stdint.h:5
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
struct @767 Tag
struct @766 Buffer
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