Choco OS  V.0.16.9.0
Join to the chocolate world
oc_memman.h
Go to the documentation of this file.
1 
134 #ifndef INC_KERNEL_OC_MEMMAN_H_
135 #define INC_KERNEL_OC_MEMMAN_H_
136 
137 #include <oc_mem_lld.h>
138 #include <oc_errors.h>
139 #include <stdbool.h>
140 #include <oc_stdlib.h>
141 
147 #define _________________________________________TYPES_SECTION_____________________________________________________________________________
148 
151 //==========================================================================================================================================
155 //==========================================================================================================================================
156 typedef void (*oC_MemMan_DumpFunction_t)(oC_UInt_t Data);
157 
158 //==========================================================================================================================================
159 //==========================================================================================================================================
160 typedef struct
161 {
163  oC_UInt_t Size;
165 
166 //==========================================================================================================================================
167 //==========================================================================================================================================
168 typedef struct
169 {
170  void * Address;
171  oC_UInt_t Size;
172  const char * Function;
173  oC_UInt_t LineNumber;
174  bool Overflowed;
176 
177 #undef _________________________________________TYPES_SECTION_____________________________________________________________________________
178 
185 #define _________________________________________INTERFACE_SECTION__________________________________________________________________________
186 
189 extern oC_ErrorCode_t oC_MemMan_TurnOn ( void );
190 extern oC_ErrorCode_t oC_MemMan_TurnOff ( void );
191 extern void oC_MemMan_CheckOverflow ( void );
192 extern void oC_MemMan_CheckMemoryExhausted ( void );
193 extern void oC_MemMan_CheckMemoryLeak ( void );
194 extern oC_ErrorCode_t oC_MemMan_TestAndRepairMainHeap ( oC_MemMan_DumpFunction_t DumpFunction );
195 extern oC_HeapMap_t oC_MemMan_AllocateHeapMap ( oC_UInt_t Size , Allocator_t Allocator , const char * Function, uint32_t LineNumber , AllocationFlags_t Flags );
196 extern bool oC_MemMan_FreeHeapMap ( oC_HeapMap_t * Map , AllocationFlags_t Flags);
197 extern void * oC_MemMan_RawAllocate ( oC_HeapMap_t Map , oC_UInt_t Size , const char * Function, uint32_t LineNumber , AllocationFlags_t Flags);
198 extern bool oC_MemMan_RawFree ( oC_HeapMap_t Map , void * Address , oC_UInt_t Size );
199 extern void * oC_MemMan_Allocate ( oC_UInt_t Size , Allocator_t Allocator , const char * Function, uint32_t LineNumber , AllocationFlags_t Flags , oC_UInt_t Alignment );
200 extern bool oC_MemMan_Free ( void * Address , AllocationFlags_t Flags);
201 extern bool oC_MemMan_FreeAllMemoryOfAllocator ( Allocator_t Allocator );
202 extern oC_ErrorCode_t oC_MemMan_SetEventHandler ( MemoryEventHandler_t EventHandler );
203 extern Allocator_t oC_MemMan_GetAllocatorOfAddress ( const void * Address );
204 extern oC_UInt_t oC_MemMan_GetSizeOfAllocation ( const void * Address );
205 extern void * oC_MemMan_AlignAddress ( const void * Address );
206 extern void * oC_MemMan_AlignAddressTo ( const void * Address , oC_UInt_t Alignment );
207 extern bool oC_MemMan_IsAddressAligned ( const void * Address );
208 extern bool oC_MemMan_IsAddressAlignedTo ( const void * Address , oC_UInt_t Alignment );
209 extern oC_UInt_t oC_MemMan_AlignSize ( oC_UInt_t Size );
210 extern oC_UInt_t oC_MemMan_AlignSizeTo ( oC_UInt_t Size , oC_UInt_t Alignment );
211 extern bool oC_MemMan_IsSizeAligned ( oC_UInt_t Size );
212 extern oC_UInt_t oC_MemMan_GetMaximumAllocationSize ( void );
213 extern oC_UInt_t oC_MemMan_GetFlashSize ( void );
214 extern oC_UInt_t oC_MemMan_GetRamSize ( void );
215 extern oC_UInt_t oC_MemMan_GetFreeFlashSize ( void );
216 extern oC_UInt_t oC_MemMan_GetFreeRamSize ( void );
217 extern oC_UInt_t oC_MemMan_GetExternalHeapSize ( void );
218 extern oC_UInt_t oC_MemMan_GetDmaRamHeapSize ( void );
219 extern oC_UInt_t oC_MemMan_GetMemoryOfAllocatorSize ( Allocator_t Allocator );
220 extern oC_UInt_t oC_MemMan_GetAllocationBlockSize ( void );
221 extern oC_UInt_t oC_MemMan_GetHeapMapSize ( oC_HeapMap_t Map );
222 extern oC_UInt_t oC_MemMan_GetFreeHeapMapSize ( oC_HeapMap_t Map );
223 extern bool oC_MemMan_IsFlashAddress ( const void * Address );
224 extern bool oC_MemMan_IsUsedFlashAddress ( const void * Address );
225 extern bool oC_MemMan_IsRamAddress ( const void * Address );
226 extern bool oC_MemMan_IsDynamicAllocatedAddress ( const void * Address );
227 extern bool oC_MemMan_IsStaticRamAddress ( const void * Address );
228 extern bool oC_MemMan_IsAddressCorrect ( const void * Address );
229 extern bool oC_MemMan_IsAllocatorCorrect ( Allocator_t Allocator );
230 extern oC_ErrorCode_t oC_MemMan_ReadAllocatorsStats ( oC_MemMan_AllocatorsStats_t * outAllocatorsArray , oC_UInt_t * Size );
231 extern oC_ErrorCode_t oC_MemMan_ReadAllocationsStats ( Allocator_t Allocator , oC_MemMan_AllocationStats_t * outAllocationsArray , oC_UInt_t * Size , bool JoinSimilar );
232 extern bool oC_MemMan_FindOverflowedAllocation ( Allocator_t Allocator , oC_MemMan_AllocationStats_t * outAllocationStat );
233 extern oC_ErrorCode_t oC_MemMan_ConfigureExternalHeapMap ( void * StartAddress , oC_UInt_t Size );
234 extern oC_ErrorCode_t oC_MemMan_UnconfigureExternalHeapMap ( void );
235 extern float oC_MemMan_GetMemoryExhaustedLimit ( void );
236 extern float oC_MemMan_GetPanicMemoryExhaustedLimit( void );
237 extern oC_ErrorCode_t oC_MemMan_SetMemoryExhaustedLimit ( float LimitPercent );
238 extern oC_ErrorCode_t oC_MemMan_SetPanicMemoryExhaustedLimit( float LimitPercent );
239 
240 #undef _________________________________________INTERFACE_SECTION__________________________________________________________________________
241 
243 #endif /* INC_KERNEL_OC_MEMMAN_H_ */
bool oC_MemMan_IsAllocatorCorrect(Allocator_t Allocator)
checks if allocator is correct
Definition: oc_memman.c:1587
bool oC_MemMan_FreeHeapMap(oC_HeapMap_t *Map, AllocationFlags_t Flags)
release heap map
Definition: oc_memman.c:596
void(* oC_MemMan_DumpFunction_t)(oC_UInt_t Data)
stores pointer to function for dumping data
Definition: oc_memman.h:156
void * oC_MemMan_AlignAddressTo(const void *Address, oC_UInt_t Alignment)
returns address aligned to the given alignment.
Definition: oc_memman.c:1174
oC_ErrorCode_t oC_MemMan_TurnOff(void)
turns off the module
Definition: oc_memman.c:313
float oC_MemMan_GetPanicMemoryExhaustedLimit(void)
Definition: oc_memman.c:1851
oC_UInt_t oC_MemMan_GetFreeFlashSize(void)
returns size of the machine not used flash
Definition: oc_memman.c:1359
bool oC_MemMan_IsRamAddress(const void *Address)
checks if address is in ram section
Definition: oc_memman.c:1542
identifier for allocations
Definition: oc_stdlib.h:159
oC_ErrorCode_t oC_MemMan_UnconfigureExternalHeapMap(void)
unconfigures external heap
Definition: oc_memman.c:1809
oC_UInt_t oC_MemMan_AlignSizeTo(oC_UInt_t Size, oC_UInt_t Alignment)
returns size aligned to the given alignment
Definition: oc_memman.c:1239
oC_UInt_t oC_MemMan_GetMaximumAllocationSize(void)
returns maximum size of allocation
Definition: oc_memman.c:1269
bool oC_MemMan_FreeAllMemoryOfAllocator(Allocator_t Allocator)
release all memory of allocator
Definition: oc_memman.c:985
void * oC_MemMan_RawAllocate(oC_HeapMap_t Map, oC_UInt_t Size, const char *Function, uint32_t LineNumber, AllocationFlags_t Flags)
allow to allocate memory in heap map
Definition: oc_memman.c:643
bool oC_MemMan_IsStaticRamAddress(const void *Address)
checks if address is in static used ram section (data section)
Definition: oc_memman.c:1567
oC_UInt_t oC_MemMan_GetSizeOfAllocation(const void *Address)
returns size of allocation
Definition: oc_memman.c:1133
oC_ErrorCode_t oC_MemMan_SetPanicMemoryExhaustedLimit(float LimitPercent)
Definition: oc_memman.c:1890
float oC_MemMan_GetMemoryExhaustedLimit(void)
Definition: oc_memman.c:1840
bool oC_MemMan_RawFree(oC_HeapMap_t Map, void *Address, oC_UInt_t Size)
release memory in heap map
Definition: oc_memman.c:692
oC_UInt_t oC_MemMan_GetHeapMapSize(oC_HeapMap_t Map)
returns size of heap map
Definition: oc_memman.c:1482
oC_UInt_t oC_MemMan_GetExternalHeapSize(void)
returns size of external ram
Definition: oc_memman.c:1400
The file with LLD interface for the MEM driver.
oC_UInt_t oC_MemMan_GetFreeHeapMapSize(oC_HeapMap_t Map)
returns size of free memory in heap map
Definition: oc_memman.c:1504
oC_ErrorCode_t oC_MemMan_TurnOn(void)
turns on memory manager
Definition: oc_memman.c:251
oC_ErrorCode_t oC_MemMan_ConfigureExternalHeapMap(void *StartAddress, oC_UInt_t Size)
prepares HeapMap stored in external RAM
Definition: oc_memman.c:1782
void * oC_MemMan_Allocate(oC_UInt_t Size, Allocator_t Allocator, const char *Function, uint32_t LineNumber, AllocationFlags_t Flags, oC_UInt_t Alignment)
allocates memory on heap
Definition: oc_memman.c:770
oC_UInt_t oC_MemMan_GetAllocationBlockSize(void)
returns size of block needed for allocation
Definition: oc_memman.c:1466
bool oC_MemMan_IsDynamicAllocatedAddress(const void *Address)
checks if address is in dynamic allocated section
Definition: oc_memman.c:1552
bool oC_MemMan_IsAddressCorrect(const void *Address)
checks if address is correct - in RAM or in FLASH
Definition: oc_memman.c:1577
oC_UInt_t oC_MemMan_GetFlashSize(void)
returns size of the machine flash
Definition: oc_memman.c:1323
bool oC_MemMan_IsAddressAlignedTo(const void *Address, oC_UInt_t Alignment)
checks if address is aligned to given alignment
Definition: oc_memman.c:1206
oC_ErrorCode_t oC_MemMan_ReadAllocatorsStats(oC_MemMan_AllocatorsStats_t *outAllocatorsArray, oC_UInt_t *Size)
Reads allocators statistics array.
Definition: oc_memman.c:1604
Allocator_t oC_MemMan_GetAllocatorOfAddress(const void *Address)
returns allocator of address
Definition: oc_memman.c:1098
bool oC_MemMan_IsAddressAligned(const void *Address)
checks if address is aligned
Definition: oc_memman.c:1190
bool oC_MemMan_FindOverflowedAllocation(Allocator_t Allocator, oC_MemMan_AllocationStats_t *outAllocationStat)
searches for a overflowed buffer
Definition: oc_memman.c:1743
void oC_MemMan_CheckMemoryLeak(void)
checks if memory is not leaking
Definition: oc_memman.c:425
oC_ErrorCode_t oC_MemMan_ReadAllocationsStats(Allocator_t Allocator, oC_MemMan_AllocationStats_t *outAllocationsArray, oC_UInt_t *Size, bool JoinSimilar)
Reads allocations statistics of the allocator.
Definition: oc_memman.c:1671
oC_UInt_t oC_MemMan_GetFreeRamSize(void)
returns size of free ram
Definition: oc_memman.c:1371
oC_UInt_t oC_MemMan_AlignSize(oC_UInt_t Size)
returns size aligned to the machine alignment
Definition: oc_memman.c:1222
oC_UInt_t oC_MemMan_GetMemoryOfAllocatorSize(Allocator_t Allocator)
returns size of allocations per allocator
Definition: oc_memman.c:1439
bool oC_MemMan_Free(void *Address, AllocationFlags_t Flags)
release allocated memory
Definition: oc_memman.c:908
oC_UInt_t oC_MemMan_GetDmaRamHeapSize(void)
returns size of external ram
Definition: oc_memman.c:1419
oC_ErrorCode_t oC_MemMan_SetMemoryExhaustedLimit(float LimitPercent)
Definition: oc_memman.c:1865
oC_UInt_t oC_MemMan_GetRamSize(void)
returns size of the machine ram
Definition: oc_memman.c:1335
bool oC_MemMan_IsUsedFlashAddress(const void *Address)
checks if address is in used flash section
Definition: oc_memman.c:1532
oC_ErrorCode_t oC_MemMan_TestAndRepairMainHeap(oC_MemMan_DumpFunction_t DumpFunction)
diagnoses main heap
Definition: oc_memman.c:449
bool oC_MemMan_IsSizeAligned(oC_UInt_t Size)
checks if a size is aligned
Definition: oc_memman.c:1255
void * oC_MemMan_AlignAddress(const void *Address)
returns address aligned to the machine alignment.
Definition: oc_memman.c:1159
static const oC_Allocator_t Allocator
Definition: oc_eth.c:152
void oC_MemMan_CheckMemoryExhausted(void)
checks if memory exhausted event not occurs.
Definition: oc_memman.c:385
oC_ErrorCode_t oC_MemMan_SetEventHandler(MemoryEventHandler_t EventHandler)
sets event handler function
Definition: oc_memman.c:1035
oC_HeapMap_t oC_MemMan_AllocateHeapMap(oC_UInt_t Size, Allocator_t Allocator, const char *Function, uint32_t LineNumber, AllocationFlags_t Flags)
allocates memory for new heap map
Definition: oc_memman.c:543
bool oC_MemMan_IsFlashAddress(const void *Address)
checks if address is placed in the flash section
Definition: oc_memman.c:1522
void oC_MemMan_CheckOverflow(void)
scan each block to check if the overflow event not occurs.
Definition: oc_memman.c:355