![]() |
m2mb API docs
25.30.003
m2mb API sets documentation
|
OS pool prototypes. More...
Go to the source code of this file.
Data Structures | |
| struct | M2MB_OS_POOL_CMD_ARG_TAG |
Macros | |
| #define | M2MB_OS_POOL_INVALID 0 |
| #define | M2MB_OS_POOL_INVALID_ATTR 0 |
| #define | M2MB_OS_POOL_BLOCK ( ( MEM_W ) 0x1 ) |
| #define | M2MB_OS_POOL_BYTE ( ( MEM_W ) 0x0 ) |
| #define | M2MB_OS_MIN_POOL_SIZE ( 128 ) |
| #define | m2mb_os_pool_setAttrItem_(h, args...) m2mb_os_pool_setAttrItem( h, CMDS_ARGS( args ) ) |
Typedefs | |
| typedef struct M2MB_OS_POOL_HANDLE_TAG * | M2MB_OS_POOL_HANDLE |
| typedef struct M2MB_OS_POOL_ATTR_HANDLE_TAG * | M2MB_OS_POOL_ATTR_HANDLE |
| typedef struct M2MB_OS_POOL_CMD_ARG_TAG | M2MB_OS_POOL_CMD_ARG_T |
Functions | |
| M2MB_OS_RESULT_E | m2mb_os_pool_init (M2MB_OS_POOL_HANDLE *pPoolHandle, M2MB_OS_POOL_ATTR_HANDLE *pPoolAttrHandle) |
| Pool memory area creation. More... | |
| M2MB_OS_RESULT_E | m2mb_os_pool_deinit (M2MB_OS_POOL_HANDLE poolHandle) |
| Pool memory area deinit or deletion. More... | |
| void * | m2mb_os_pool_malloc (M2MB_OS_POOL_HANDLE poolHandle, UINT32 size) |
| Memory allocation from specified pool. More... | |
| void * | m2mb_os_pool_calloc (M2MB_OS_POOL_HANDLE poolHandle, UINT32 size) |
| Memory allocation from specified pool and set them to 0. More... | |
| void * | m2mb_os_pool_realloc (M2MB_OS_POOL_HANDLE poolHOld, M2MB_OS_POOL_HANDLE poolHNew, void *ptrOld, UINT32 newsize) |
| Reallocate memory from specified pool. More... | |
| M2MB_OS_RESULT_E | m2mb_os_pool_free (M2MB_OS_POOL_HANDLE poolHandle, void *ptrToFree) |
| Free allocated memory from specified pool. More... | |
| M2MB_OS_RESULT_E | m2mb_os_pool_setAttrItem (M2MB_OS_POOL_ATTR_HANDLE *pPoolAttrHandle, UINT8 nCmds,...) |
| Set specific pool attributes for pool creation. More... | |
| M2MB_OS_RESULT_E | m2mb_os_pool_getItem (M2MB_OS_POOL_HANDLE poolHandle, M2MB_OS_POOL_SEL_CMD_E selCmd, MEM_W *pOut, void *pIn) |
| Get specific pool properties. More... | |
| M2MB_OS_RESULT_E | m2mb_os_pool_setItem (M2MB_OS_POOL_HANDLE poolHandle, M2MB_OS_POOL_SEL_CMD_E selCmd, void *pIn) |
| Set specific pool properties. More... | |
| M2MB_OS_RESULT_E | m2mb_os_pool_memInfo (M2MB_OS_POOL_HANDLE poolHandle, M2MB_OS_POOL_MEMINFO_E memInfoSelect, MEM_W *pOut) |
| Get memory information from specific pool. More... | |
OS pool prototypes.
m2m/m2m_generic/common/m2mb_inc/m2mb_os_pool.h
basic functions for OS pool are provided
@notes Dependencies: m2mb_types.h m2mb_os_types.h
| void* m2mb_os_pool_calloc | ( | M2MB_OS_POOL_HANDLE | poolHandle, |
| UINT32 | size | ||
| ) |
Memory allocation from specified pool and set them to 0.
This service allocates memory from the memory area associated with the pool and set to 0. In case that poolHandle is M2MB_OS_POOL_INVALID, the function callocs from systemHEAP. The highest allocated amount of memory in block pool can be block size.
| [in] | poolHandle | pointer to pool handle |
| [in] | size | size of the memory to be allocated |
Allowed From Initialization and tasks in case of block granularity, allowed also in ISR and timer context Preemption Possible No
Example
| M2MB_OS_RESULT_E m2mb_os_pool_deinit | ( | M2MB_OS_POOL_HANDLE | poolHandle | ) |
Pool memory area deinit or deletion.
This service deletes the specified os pool. It is the applications responsibility to prevent use of a deleted pool.
| [in] | poolHandle | handle of the pool |
| M2MB_OS_RESULT_E m2mb_os_pool_free | ( | M2MB_OS_POOL_HANDLE | poolHandle, |
| void * | ptrToFree | ||
| ) |
Free allocated memory from specified pool.
This function provides service to free already allocated memory space. In case that poolHandle is M2MB_OS_POOL_INVALID, the function tries to free from systemHEAP.
| [in] | poolHandle | |
| [in] | ptrToFree |
| M2MB_OS_RESULT_E m2mb_os_pool_getItem | ( | M2MB_OS_POOL_HANDLE | poolHandle, |
| M2MB_OS_POOL_SEL_CMD_E | selCmd, | ||
| MEM_W * | pOut, | ||
| void * | pIn | ||
| ) |
Get specific pool properties.
This function retrieve special information of the specified pool Selecting cmd, a parameter to be retrieved can be set To be used when pool is already created: its right usage is under application responsibility In case poolHandle is M2MB_OS_POOL_INVALID, retrieve info on systemHeap
| [in] | poolHandle | pool handle, identify the pool |
| [in] | selCmd | Select parameter to be retrieved (see M2MB_OS_POOL_SEL_CMD_E) param [out] pOut pointer Output parameter, its meaning depend on selCmd used See examples |
| [in] | pIn | pointer to Parameter to be specified, if any, to get right output See examples If parameter is not needed, use NULL |
Please note M2MB_OS_POOL_SEL_CMD_VADDR, M2MB_OS_POOL_SEL_CMD_PERMISSION not still available
Example
| M2MB_OS_RESULT_E m2mb_os_pool_init | ( | M2MB_OS_POOL_HANDLE * | pPoolHandle, |
| M2MB_OS_POOL_ATTR_HANDLE * | pPoolAttrHandle | ||
| ) |
Pool memory area creation.
This service creates a pool to be used for allocation via m2mb_os_pool_alloc( ... ) function. It creates it in the area specified \ or allocate by system with properties defined by attributes: size, block or byte granularity, Virtual address, permission... In case area is provided, some space will be lost due to internal management structures, so the area available will be a bit less than the area provided
| [out] | pPoolHandle | pointer to pool handle |
| [in] | pPoolAttrHandle | pointer to pool attribute handle |
Example
| void* m2mb_os_pool_malloc | ( | M2MB_OS_POOL_HANDLE | poolHandle, |
| UINT32 | size | ||
| ) |
Memory allocation from specified pool.
This service allocates memory from the memory area associated with the pool. In case that poolHandle is M2MB_OS_POOL_INVALID, the function mallocs from systemHEAP. The highest allocated amount of memory in block pool can be block size.
| [in] | poolHandle | pointer to pool handle |
| [in] | size | size of the memory to be allocated |
Allowed From Initialization and tasks in case of block granularity, allowed also in ISR and timer context Preemption Possible No
Example
| M2MB_OS_RESULT_E m2mb_os_pool_memInfo | ( | M2MB_OS_POOL_HANDLE | poolHandle, |
| M2MB_OS_POOL_MEMINFO_E | memInfoSelect, | ||
| MEM_W * | pOut | ||
| ) |
Get memory information from specific pool.
This function returns pool information: -the total number of memory fragments in byte pool -the total number of available bytes in the byte pool -the total number of bytes of the pool -the total number of available blocks in the block pool -the total number of blocks in the block pool
in case poolHandle is NULL, it is considered as system heap pool
| [in] | poolHandle | |
| [in] | type | of information required: M2MB_OS_POOL_MEMINFO_E |
| [out] | value | of information required: *pOut |
Example
| void* m2mb_os_pool_realloc | ( | M2MB_OS_POOL_HANDLE | poolHOld, |
| M2MB_OS_POOL_HANDLE | poolHNew, | ||
| void * | ptrOld, | ||
| UINT32 | newsize | ||
| ) |
Reallocate memory from specified pool.
Changes the size of the memory pool pointed to by ptrOld.
The function may move the memory pool to a new location (whose address is returned by the function).
In the byte pool the content of the memory pool is preserved up to the lesser of the new and old sizes, even if the block is moved to a new location. If the new size is larger, the value of the newly allocated portion is indeterminate. Instead in the block pool the content of the memory pool is preserved up to the lesser of the new size and block pool size.
In case that poolHOld and\or poolHNew are M2MB_OS_POOL_INVALID, the function realloc from systemHEAP if needed.
| [in] | poolHOld | |
| [in] | poolHNew | |
| [in] | ptrOld | |
| [in] | newsize |
| M2MB_OS_RESULT_E m2mb_os_pool_setAttrItem | ( | M2MB_OS_POOL_ATTR_HANDLE * | pPoolAttrHandle, |
| UINT8 | nCmds, | ||
| ... | |||
| ) |
Set specific pool attributes for pool creation.
This function set special information of the specified pool. Selecting cmd, a parameter can be set. To be used when pool is already created: its right usage is under application responsibility. In the case of block pool the block size must be defined. In case area is provided as attibute ( M2MB_OS_POOL_SEL_CMD_MEM_START ), some space will be lost due to internal management structures, so the area available will be a bit less than the area provided
| [in |
| M2MB_OS_RESULT_E m2mb_os_pool_setItem | ( | M2MB_OS_POOL_HANDLE | poolHandle, |
| M2MB_OS_POOL_SEL_CMD_E | selCmd, | ||
| void * | pIn | ||
| ) |
Set specific pool properties.
This function set value for specified parameter of the specified pool Selecting cmd, a parameter to be set can be selected To be used when pool is already created: it is under application responsibility
| [in] | poolHandle | pool handle identify the pool to set parameter to |
| [in] | selCmd | Select parameter to be set (see M2MB_OS_POOL_SEL_CMD_E) |
| [in] | pIn | pointer to Parameter to be specified, if any, to get right output See examples If parameter is not needed, use NULL |
Example