R_RTOS  0.1
DistributedRealTimeOperatingSystemfortheARMCortexMArchitecture
R_RTOS_memMngr.h
Go to the documentation of this file.
1 
17 #ifndef HEADERS_R_RTOS_MEMMNGR_H_
18 #define HEADERS_R_RTOS_MEMMNGR_H_
19 #include "R_RTOS_inc.h"
20 #include <stdint.h>
21 
25 #define malloc rMalloc
26 
29 #define calloc rCalloc
30 
33 #define realloc rRealloc
34 
37 #define free rFree
38 
39 /* MEMORY_MANAGEMENT */
43 typedef uint16_t BlckSize;
44 
45 
51 #define BIGGEST_BLCK ((BlckSize)0x100u)//256 Byte
52 
58 #define BIGGEST_BLCK_MSK ((BlckSize)(BIGGEST_BLCK - (BlckSize)1u))
59 
67 #define SMALLEST_BLCK ((BlckSize)0x8u) //8 Byte
68 
74 #define SMALLER_BLCK_MSK ((BlckSize)(SMALLEST_BLCK - (BlckSize)1u))
75 
81 #define SMALLER_BLCK_DIVISOR (MemIndex)(0x3u)
82 
90 #define CACHE_SIZE ((uint8_t)0x10u) // 16 Cache slots
91 
95 typedef uint8_t MemPoolID;
96 
100 typedef uint16_t MemFlags;
101 
107 typedef void *stdPtr;
108 
112 typedef uint16_t MemIndex;
113 
114 /* MEM BLCK FLAGS - flagsForMemBlock
115  * ------------------------
116  * | BIT - Purpose |
117  * |----------------------|
118  * | 0 - IsTaken |
119  * | 1 - IsLower |
120  * | 2 - 4 Byte | - SMALLEST BLCK
121  * | 3 - 8 Byte |
122  * | 4 - 16 Byte |
123  * | 5 - 32 Byte |
124  * | 6 - 64 Byte |
125  * | 7 - 128 Byte |
126  * | 8 - 256 Byte | - BIGGEST BLCK
127  * | 9 - 512 Byte |
128  * | 10 - 1024 Byte |
129  * | 11 - 2048 Byte |
130  * | 12 - SPLIT |
131  * | 13 - MERGED |
132  * | 14 - PrevTaken |
133  * | 15 - NxtTaken |
134  * ------------------------
135  *
136  * MEM BLCK FLAGS - additionalFlags
137  * ------------------------
138  * | BIT - Purpose |
139  * |----------------------|
140  * | 0 - IsBlckBeg |
141  * | 1 - IsBlckLast|
142  * | 2 - PRV 4 B | - SMALLEST BLCK
143  * | 3 - PRV 8 B |
144  * | 4 - PRV 16 B |
145  * | 5 - PRV 32 B |
146  * | 6 - PRV 64 B |
147  * | 7 - PRV 128 B |
148  * | 8 - PRV 256 B | - BIGGEST BLCK
149  * | 9 - PRV 512 B |
150  * | 10 - PRV 1024 B|
151  * | 11 - PRV 2048 B|
152  * | 12 - nxtSplit |
153  * | 13 - prevSplit |
154  * | 14 - bggrMrgd |
155  * | 15 - CACHED |
156  * ------------------------
157  */
158 
169 typedef struct memMngrHead
170 {
193 
217 // struct memMngrHead *ptrNXT; //!< Pointer to next free MemMngrHead
218 // struct memMngrHead *ptrPREV; //!< Pointer to previous free MemMngrHead
219 } MemMngrHead;
220 
233 typedef struct memBlckhead
234 {
257 
279 } MemBlckHead;
280 
281 #define MEM_MNGR_GET_MEMMNGRHEAD(pointer) ((MemMngrHead *)( (uint32_t) pointer - (uint32_t) sizeof(MemBlckHead)))
282 #define MEM_MNGR_GET_PTRTOMEM(memMngrPtr) ((void *) ((uint32_t) memMngrPtr + (uint32_t) sizeof(MemBlckHead)))
283 
284 //PARSE FLAGS
285 #define MEM_FLG_PARSE(memFlgs,shft) ((MemFlags)((MemFlags)(memFlgs >> (MemFlags)shft) & (MemFlags)0x1u))
286 #define MEM_FLG_GET_BIT_MSK(bit) ((MemFlags)((MemFlags)0x1u << (MemFlags)bit))
287 #define MEM_FLG_GET_STRUC_PFIELD(struc,field) ((struc)->field)
288 #define MEM_FLG_SET_BIT(pMemMngrHead, bit, whichFlags) MEM_FLG_GET_STRUC_PFIELD(pMemMngrHead, whichFlags) |= MEM_FLG_GET_BIT_MSK(bit)
289 #define MEM_FLG_CLR_BIT(pMemMngrHead, bit, whichFlags) MEM_FLG_GET_STRUC_PFIELD(pMemMngrHead, whichFlags) &= ((MemFlags)(~MEM_FLG_GET_BIT_MSK(bit)))
290 #define MEM_FLG_SET_BIT_MSK(pMemMngrHead, msk, whichFlags) MEM_FLG_GET_STRUC_PFIELD(pMemMngrHead, whichFlags) |= (MemFlags)msk
291 #define MEM_FLG_CLR_BIT_MSK(pMemMngrHead, msk, whichFlags) MEM_FLG_GET_STRUC_PFIELD(pMemMngrHead, whichFlags) &= ((MemFlags)(~((MemFlags)msk)))
292 
293 /* MEM BLCK FLAGS - flagsForMemBlock
294  * ------------------------
295  * | BIT - Purpose |
296  * |----------------------|
297  * | 0 - IsTaken |
298  * | 1 - IsLower |
299  * | 2 - 4 Byte | - SMALLEST BLCK
300  * | 3 - 8 Byte |
301  * | 4 - 16 Byte |
302  * | 5 - 32 Byte |
303  * | 6 - 64 Byte |
304  * | 7 - 128 Byte |
305  * | 8 - 256 Byte | - BIGGEST BLCK
306  * | 9 - 512 Byte |
307  * | 10 - 1024 Byte |
308  * | 11 - 2048 Byte |
309  * | 12 - SPLIT |
310  * | 13 - MERGED |
311  * | 14 - PrevTaken |
312  * | 15 - NxtTaken |
313  * ------------------------
314  */
315 
316 //flagsForMemBlock
317 #define MEM_FLGS_TAKEN_SHFT ((MemFlags)0x0u)
318 #define MEM_FLGS_TAKEN_MSK ((MemFlags)0x1u)
319 #define MEM_FLGS_ISLOWER_SHFT ((MemFlags)0x1u)
320 #define MEM_FLGS_ISLOWER_MSK ((MemFlags)0x2u)
321 #define MEM_FLGS_SPLT_4_SHFT ((MemFlags)0x2u)
322 #define MEM_FLGS_SPLT_4_MSK ((MemFlags)0x4u)
323 #define MEM_FLGS_SPLT_8_SHFT ((MemFlags)0x3u)
324 #define MEM_FLGS_SPLT_8_MSK ((MemFlags)0x8u)
325 #define MEM_FLGS_SPLT_16_SHFT ((MemFlags)0x4u)
326 #define MEM_FLGS_SPLT_16_MSK ((MemFlags)0x10u)
327 #define MEM_FLGS_SPLT_32_SHFT ((MemFlags)0x5u)
328 #define MEM_FLGS_SPLT_32_MSK ((MemFlags)0x20u)
329 #define MEM_FLGS_SPLT_64_SHFT ((MemFlags)0x6u)
330 #define MEM_FLGS_SPLT_64_MSK ((MemFlags)0x40u)
331 #define MEM_FLGS_SPLT_128_SHFT ((MemFlags)0x7u)
332 #define MEM_FLGS_SPLT_128_MSK ((MemFlags)0x80u)
333 #define MEM_FLGS_BGGSTBLCK_SHFT ((MemFlags)0x8u)
334 #define MEM_FLGS_BGGSTBLCK_MSK ((MemFlags)0x100u)
335 #define MEM_FLGS_MERGE512_SHFT ((MemFlags)0x9u)
336 #define MEM_FLGS_MERGE512_MSK ((MemFlags)0x200u)
337 #define MEM_FLGS_MERGE1024_SHFT ((MemFlags)0xAu)
338 #define MEM_FLGS_MERGE1024_MSK ((MemFlags)0x400u)
339 #define MEM_FLGS_MERGE2048_SHFT ((MemFlags)0xBu)
340 #define MEM_FLGS_MERGE2048_MSK ((MemFlags)0x800u)
341 #define MEM_FLGS_SPLT_SHFT ((MemFlags)0xCu)
342 #define MEM_FLGS_SPLT_MSK ((MemFlags)0x1000u)
343 #define MEM_FLGS_MERGED_SHFT ((MemFlags)0xDu)
344 #define MEM_FLGS_MERGED_MSK ((MemFlags)0x2000u)
345 #define MEM_FLGS_PREVTAKEN_SHFT ((MemFlags)0xEu)
346 #define MEM_FLGS_PREVTAKEN_MSK ((MemFlags)0x4000u)
347 #define MEM_FLGS_NXTTAKEN_SHFT ((MemFlags)0xFu)
348 #define MEM_FLGS_NXTTAKEN_MSK ((MemFlags)0x8000u)
349 
350 #define MEM_FLGS_SIZE_MSK ((MemFlags)0xFFCu)
351 
352 #define MEM_FLG_ISTAKEN(memFlgs) MEM_FLG_PARSE(memFlgs,MEM_FLGS_TAKEN_SHFT)
353 #define MEM_FLG_SET_TAKEN(pMemMngrHead) MEM_FLG_SET_BIT_MSK(pMemMngrHead, MEM_FLGS_TAKEN_MSK, flagsForMemBlock)
354 #define MEM_FLG_CLR_TAKEN(pMemMngrHead) MEM_FLG_CLR_BIT_MSK(pMemMngrHead, MEM_FLGS_TAKEN_MSK, flagsForMemBlock)
355 #define MEM_FLG_PREVTAKEN(memFlgs) MEM_FLG_PARSE(memFlgs,MEM_FLGS_PREVTAKEN_SHFT)
356 #define MEM_FLG_SET_PREVTAKEN(pMemMngrHead) MEM_FLG_SET_BIT_MSK(pMemMngrHead, MEM_FLGS_PREVTAKEN_MSK, flagsForMemBlock)
357 #define MEM_FLG_CLR_PREVTAKEN(pMemMngrHead) MEM_FLG_CLR_BIT_MSK(pMemMngrHead, MEM_FLGS_PREVTAKEN_MSK, flagsForMemBlock)
358 #define MEM_FLG_NXTTAKEN(memFlgs) MEM_FLG_PARSE(memFlgs,MEM_FLGS_NXTTAKEN_SHFT)
359 #define MEM_FLG_SET_NXTTAKEN(pMemMngrHead) MEM_FLG_SET_BIT_MSK(pMemMngrHead, MEM_FLGS_NXTTAKEN_MSK, flagsForMemBlock)
360 #define MEM_FLG_CLR_NXTTAKEN(pMemMngrHead) MEM_FLG_CLR_BIT_MSK(pMemMngrHead, MEM_FLGS_NXTTAKEN_MSK, flagsForMemBlock)
361 #define MEM_FLG_ISSPLIT(memFlgs) MEM_FLG_PARSE(memFlgs,MEM_FLGS_SPLT_SHFT)
362 #define MEM_FLG_SET_SPLIT(pMemMngrHead) MEM_FLG_SET_BIT_MSK(pMemMngrHead, MEM_FLGS_SPLT_MSK, flagsForMemBlock)
363 #define MEM_FLG_CLR_SPLIT(pMemMngrHead) MEM_FLG_CLR_BIT_MSK(pMemMngrHead, MEM_FLGS_SPLT_MSK, flagsForMemBlock)
364 #define MEM_FLG_ISLOWER(memFlgs) MEM_FLG_PARSE(memFlgs,MEM_FLGS_ISLOWER_SHFT)
365 #define MEM_FLG_SET_ISLOWER(pMemMngrHead) MEM_FLG_SET_BIT_MSK(pMemMngrHead, MEM_FLGS_ISLOWER_MSK, flagsForMemBlock)
366 #define MEM_FLG_CLR_ISLOWER(pMemMngrHead) MEM_FLG_CLR_BIT_MSK(pMemMngrHead, MEM_FLGS_ISLOWER_MSK, flagsForMemBlock)
367 #define MEM_FLG_ISMERGED(memFlgs) MEM_FLG_PARSE(memFlgs,MEM_FLGS_MERGED_SHFT)
368 #define MEM_FLG_SET_MERGED(pMemMngrHead) MEM_FLG_SET_BIT_MSK(pMemMngrHead, MEM_FLGS_MERGED_MSK, flagsForMemBlock)
369 #define MEM_FLG_CLR_MERGED(pMemMngrHead) MEM_FLG_CLR_BIT_MSK(pMemMngrHead, MEM_FLGS_MERGED_MSK, flagsForMemBlock)
370 #define MEM_FL_WASLOWER(memFlgs) MEM_FLG_PARSE(memFlgs,MEM_FLGS_WASLOWER_SHFT)
371 // MORE THAN ONE BIT SET --- n & (n - 1) != 0
372 #define MEM_FLG_GET_MEMSIZE(memFlgs) (MemSize)(memFlgs & MEM_FLGS_SIZE_MSK)
373 #define MEM_FLG_SET_MEMSIZE(pMemMngrHead, newSize) \
374  do \
375  {\
376  if(((BlckSize)(newSize)) < BIGGEST_BLCK )\
377  {\
378  MEM_FLG_SET_SPLIT(pMemMngrHead);\
379  } else \
380  {\
381  MEM_FLG_CLR_SPLIT(pMemMngrHead);\
382  }\
383  (pMemMngrHead)->flagsForMemBlock = (MemFlags)((pMemMngrHead)->flagsForMemBlock & (MemFlags)(~MEM_FLGS_SIZE_MSK));\
384  (pMemMngrHead)->flagsForMemBlock = (MemFlags)((pMemMngrHead)->flagsForMemBlock | (MemFlags)((MemFlags)(newSize) & MEM_FLGS_SIZE_MSK));\
385  }while((uint8_t)0x0u)
386 #define MEM_FLG_ISCOMBO(memFlgs) (MemSize)((MEM_FLG_GET_MEMSIZE(memFlgs) & (MemSize)(MEM_FLG_GET_MEMSIZE(memFlgs)-(MemSize)1u)) ? 1u : 0u)
387 #define MEM_FLG_BIGGER_COMBO(memFlgs) (MemSize)(MEM_FLG_GET_MEMSIZE(memFlgs) & (MemSize)(MEM_FLG_GET_MEMSIZE(memFlgs)-(MemSize)1u))
388 #define MEM_FLG_SMALLER_COMBO(memFlgs) (MemSize)(MEM_FLG_GET_MEMSIZE(memFlgs) & (MemSize)(-MEM_FLG_GET_MEMSIZE(memFlgs)))
389 
390 /*
391  * MEM BLCK FLAGS - additionalFlags
392  * ------------------------
393  * | BIT - Purpose |
394  * |----------------------|
395  * | 0 - IsBlckBeg |
396  * | 1 - IsBlckLast|
397  * | 2 - PRV 4 B | - SMALLEST BLCK
398  * | 3 - PRV 8 B |
399  * | 4 - PRV 16 B |
400  * | 5 - PRV 32 B |
401  * | 6 - PRV 64 B |
402  * | 7 - PRV 128 B |
403  * | 8 - PRV 256 B | - BIGGEST BLCK
404  * | 9 - PRV 512 B |
405  * | 10 - PRV 1024 B|
406  * | 11 - PRV 2048 B|
407  * | 12 - nxtSplit |
408  * | 13 - prevSplit |
409  * | 14 - bggrMrgd |
410  * | 15 - |
411  * ------------------------
412  */
413 //additionalFlags
414 #define MEM_FLGS_ISBLCKBEG_SHFT ((MemFlags)0x0u)
415 #define MEM_FLGS_ISBLCKBEG_MSK ((MemFlags)0x1u)
416 #define MEM_FLGS_ISBLCKLAST_SHFT ((MemFlags)0x1u)
417 #define MEM_FLGS_ISBLCKLAST_MSK ((MemFlags)0x2u)
418 #define MEM_FLGS_PRV_SPLT_4_SHFT MEM_FLGS_SPLT_4_SHFT
419 #define MEM_FLGS_PRV_SPLT_4_MSK MEM_FLGS_SPLT_4_MSK
420 #define MEM_FLGS_PRV_SPLT_8_SHFT MEM_FLGS_SPLT_8_SHFT
421 #define MEM_FLGS_PRV_SPLT_8_MSK MEM_FLGS_SPLT_8_MSK
422 #define MEM_FLGS_PRV_SPLT_16_SHFT MEM_FLGS_SPLT_16_SHFT
423 #define MEM_FLGS_PRV_SPLT_16_MSK MEM_FLGS_SPLT_16_MSK
424 #define MEM_FLGS_PRV_SPLT_32_SHFT MEM_FLGS_SPLT_32_SHFT
425 #define MEM_FLGS_PRV_SPLT_32_MSK MEM_FLGS_SPLT_32_MSK
426 #define MEM_FLGS_PRV_SPLT_64_SHFT MEM_FLGS_SPLT_64_SHFT
427 #define MEM_FLGS_PRV_SPLT_64_MSK MEM_FLGS_SPLT_64_MSK
428 #define MEM_FLGS_PRV_SPLT_128_SHFT MEM_FLGS_SPLT_128_SHFT
429 #define MEM_FLGS_PRV_SPLT_128_MSK MEM_FLGS_SPLT_128_MSK
430 #define MEM_FLGS_PRV_BGGSTBLCK_SHFT MEM_FLGS_BGGSTBLCK_SHFT
431 #define MEM_FLGS_PRV_BGGSTBLCK_MSK MEM_FLGS_BGGSTBLCK_MSK
432 #define MEM_FLGS_PRV_MERGE512_SHFT MEM_FLGS_MERGE512_SHFT
433 #define MEM_FLGS_PRV_MERGE512_MSK MEM_FLGS_MERGE512_MSK
434 #define MEM_FLGS_PRV_MERGE1024_SHFT MEM_FLGS_MERGE1024_SHFT
435 #define MEM_FLGS_PRV_MERGE1024_MSK MEM_FLGS_MERGE1024_MSK
436 #define MEM_FLGS_PRV_MERGE2048_SHFT MEM_FLGS_MERGE2048_SHFT
437 #define MEM_FLGS_PRV_MERGE2048_MSK MEM_FLGS_MERGE2048_MSK
438 #define MEM_FLGS_NXT_SPLT_SHFT ((MemFlags)0xCu)
439 #define MEM_FLGS_NXT_SPLT_MSK ((MemFlags)0x1000u)
440 #define MEM_FLGS_PREV_SPLT_SHFT ((MemFlags)0xDu)
441 #define MEM_FLGS_PREV_SPLT_MSK ((MemFlags)0x2000u)
442 #define MEM_FLGS_BGGRMRGD_SHFT ((MemFlags)0xEu)
443 #define MEM_FLGS_BGGRMRGD_MSK ((MemFlags)0x4000u)
444 #define MEM_FLGS_CACHED_SHFT ((MemFlags)0xFu)
445 #define MEM_FLGS_CACHED_MSK ((MemFlags)0x8000u)
446 
447 #define MEM_FLG_ISBLCKBEG(memFlgs) MEM_FLG_PARSE(memFlgs,MEM_FLGS_ISBLCKBEG_SHFT)
448 #define MEM_FLG_SET_BLCKBEG(pMemMngrHead) MEM_FLG_SET_BIT_MSK(pMemMngrHead, MEM_FLGS_ISBLCKBEG_MSK, additionalFlags)
449 #define MEM_FLG_CLR_BLCKBEG(pMemMngrHead) MEM_FLG_CLR_BIT_MSK(pMemMngrHead, MEM_FLGS_ISBLCKBEG_MSK, additionalFlags)
450 #define MEM_FLG_ISBLCKLAST(memFlgs) MEM_FLG_PARSE(memFlgs,MEM_FLGS_ISBLCKLAST_SHFT)
451 #define MEM_FLG_SET_BLCKLAST(pMemMngrHead) MEM_FLG_SET_BIT_MSK(pMemMngrHead, MEM_FLGS_ISBLCKLAST_MSK, additionalFlags)
452 #define MEM_FLG_CLR_BLCKLAST(pMemMngrHead) MEM_FLG_CLR_BIT_MSK(pMemMngrHead, MEM_FLGS_ISBLCKLAST_MSK, additionalFlags)
453 #define MEM_FLG_NXT_SPLT(memFlgs) MEM_FLG_PARSE(memFlgs,MEM_FLGS_NXT_SPLT_SHFT)
454 #define MEM_FLG_SET_NXT_SPLT(pMemMngrHead) MEM_FLG_SET_BIT_MSK(pMemMngrHead, MEM_FLGS_NXT_SPLT_MSK, additionalFlags)
455 #define MEM_FLG_CLR_NXT_SPLT(pMemMngrHead) MEM_FLG_CLR_BIT_MSK(pMemMngrHead, MEM_FLGS_NXT_SPLT_MSK, additionalFlags)
456 #define MEM_FLG_PREV_SPLT(memFlgs) MEM_FLG_PARSE(memFlgs,MEM_FLGS_PREV_SPLT_SHFT)
457 #define MEM_FLG_SET_PREV_SPLT(pMemMngrHead) MEM_FLG_SET_BIT_MSK(pMemMngrHead, MEM_FLGS_PREV_SPLT_MSK, additionalFlags)
458 #define MEM_FLG_CLR_PREV_SPLT(pMemMngrHead) MEM_FLG_CLR_BIT_MSK(pMemMngrHead, MEM_FLGS_PREV_SPLT_MSK, additionalFlags)
459 #define MEM_FLG_GET_PREV_MEMSIZE(memFlgs) (BlckSize)(memFlgs & MEM_FLGS_SIZE_MSK)
460 #define MEM_FLG_SET_PREV_MEMSIZE(pMemMngrHead, newSize) \
461  do \
462  {\
463  (pMemMngrHead)->additionalFlags = (MemFlags)((pMemMngrHead)->additionalFlags & (MemFlags)(~MEM_FLGS_SIZE_MSK));\
464  (pMemMngrHead)->additionalFlags = (MemFlags)((pMemMngrHead)->additionalFlags | (MemFlags)((MemFlags)(newSize) & MEM_FLGS_SIZE_MSK));\
465  }while((uint8_t)0x0u)
466 #define MEM_FLG_PREV_ISCOMBO(memFlgs) (MemSize)((MEM_FLG_GET_PREV_MEMSIZE(memFlgs) & (MemSize)(MEM_FLG_GET_PREV_MEMSIZE(memFlgs)-(MemSize)1u)) ? 1u : 0u)
467 #define MEM_FLG_PREV_BIGGER_COMBO(memFlgs) (MemSize)(MEM_FLG_GET_PREV_MEMSIZE(memFlgs) & (MemSize)(MEM_FLG_GET_PREV_MEMSIZE(memFlgs)-(MemSize)1u))
468 #define MEM_FLG_PREV_SMALLER_COMBO(memFlgs) (MemSize)(MEM_FLG_GET_PREV_MEMSIZE(memFlgs) & (MemSize)(-MEM_FLG_GET_PREV_MEMSIZE(memFlgs)))
469 #define MEM_FLG_BGGRMRGD(memFlgs) MEM_FLG_PARSE(memFlgs,MEM_FLGS_BGGRMRGD_SHFT)
470 #define MEM_FLG_SET_BGGRMRGD(pMemMngrHead) MEM_FLG_SET_BIT_MSK(pMemMngrHead, MEM_FLGS_BGGRMRGD_MSK, additionalFlags)
471 #define MEM_FLG_CLR_BGGRMRGD(pMemMngrHead) MEM_FLG_CLR_BIT_MSK(pMemMngrHead, MEM_FLGS_BGGRMRGD_MSK, additionalFlags)
472 #define MEM_FLG_ISCACHED(memFlgs) MEM_FLG_PARSE(memFlgs,MEM_FLGS_CACHED_SHFT)
473 #define MEM_FLG_SET_CACHED(pMemMngrHead) MEM_FLG_SET_BIT_MSK(pMemMngrHead, MEM_FLGS_CACHED_MSK, additionalFlags)
474 #define MEM_FLG_CLR_CACHED(pMemMngrHead) MEM_FLG_CLR_BIT_MSK(pMemMngrHead, MEM_FLGS_CACHED_MSK, additionalFlags)
475 
476 #define MEM_FLG_TAKENORCACHED(pMemMngrHead) (MemFlags)(MEM_FLG_ISTAKEN(pMemMngrHead->flagsForMemBlock) | MEM_FLG_ISCACHED(pMemMngrHead->additionalFlags))
477 
478 // END MEMORY_MANAGEMENT //
479 
487 RetCode initMEM( void );
488 
494 void * rMalloc( MemSize desiredSize );
495 
503 void * rCalloc( MemSize desiredSize );
504 
513 void * rRealloc( void * ptrToExistingMem, MemSize desiredSize );
514 
519 void rFree( void *pToBeFreed );
520 
526 void rFullyFree( MemMngrHead * blckToFullyFree );
527 
542  const MemSize sizeOfElements,
543  const uint8_t elements,
544  MemPoolID * const memPoolID );
545 
554 RetCode memMngr_DeleteMemPool( const MemPoolID memPoolID );
555 
566 RetCode memMngr_MemPoolMalloc( void ** ptrToMem, const MemPoolID memPoolID );
567 
579 RetCode memMngr_MemPoolFree( void * ptrToMem, const MemPoolID memPoolID );
580 
585 #endif /* HEADERS_R_RTOS_MEMMNGR_H_ */
586 
MemIndex nxtMemBlck
index of the next memory block
Definition: R_RTOS_memMngr.h:215
void * rRealloc(void *const ptrToExistingMem, const MemSize desiredSize)
Allocate a block of memory satisfying the desiredSize property.
Definition: R_RTOS_memMngr.c:967
uint16_t MemFlags
16Bit flag value.
Definition: R_RTOS_memMngr.h:100
MemIndex prvMemBlck
index of the previous memory block
Definition: R_RTOS_memMngr.h:216
struct memBlckhead MemBlckHead
memBlckhead
uint16_t MemSize
Type for memory size.
Definition: R_RTOS_inc.h:1490
void * rCalloc(const MemSize desiredSize)
Definition: R_RTOS_memMngr.c:954
void rFullyFree(MemMngrHead *blckToFullyFree)
Free a block of memory previously allocated with either rMalloc, rCalloc or rRealloc.
Definition: R_RTOS_memMngr.c:1028
Defines, Typedefs and Macros for the whole system.
struct memMngrHead MemMngrHead
memMngrHead
MemFlags flagsForMemBlock
Contains the most important flags for handling this block of memory.
Definition: R_RTOS_memMngr.h:192
void * stdPtr
Simple void pointer.
Definition: R_RTOS_memMngr.h:107
uint8_t MemPoolID
8Bit ID value of a memory pool.
Definition: R_RTOS_memMngr.h:95
Contains the only the flag information about the memory block.
Definition: R_RTOS_memMngr.h:233
RetCode memMngr_DeleteMemPool(const MemPoolID memPoolID)
Delete a previously created memory pool linked to the provided MemPoolID.
Definition: R_RTOS_memMngr.c:1095
MemFlags additionalFlags
Contains flags for handling neighbors of this buddy block.
Definition: R_RTOS_memMngr.h:278
RetCode memMngr_CreateMemPool(const MemSize sizeOfElements, const uint8_t elements, MemPoolID *const memPoolID)
Creates a memory pool with the given MemPoolID.
Definition: R_RTOS_memMngr.c:1045
void rFree(void *const pToBeFreed)
The provided block of memory will be added to the memory block cache.
Definition: R_RTOS_memMngr.c:1012
RetCode initMEM(void)
Initialize the memory manager.
Definition: R_RTOS_memMngr.c:132
MemFlags additionalFlags
Contains flags for handling neighbors of this buddy block.
Definition: R_RTOS_memMngr.h:214
MemFlags flagsForMemBlock
Contains the most important flags for handling this block of memory.
Definition: R_RTOS_memMngr.h:256
RetCode memMngr_MemPoolMalloc(void **ptrToMem, const MemPoolID memPoolID)
Allocate an element from the memory pool specified by the provided MemPoolID.
Definition: R_RTOS_memMngr.c:1101
RetCode memMngr_MemPoolFree(void *ptrToMem, const MemPoolID memPoolID)
Free a previously allocated block of memory from a memory pool and put it back into the memory pool...
Definition: R_RTOS_memMngr.c:1122
void * rMalloc(const MemSize desiredSize)
Allocate a block of memory satisfying the desiredSize property.
Definition: R_RTOS_memMngr.c:926
Contains the full information about the memory block.
Definition: R_RTOS_memMngr.h:169
uint16_t MemIndex
Used for indexing memory blocks.
Definition: R_RTOS_memMngr.h:112
uint8_t RetCode
Return codes for functions.
Definition: R_RTOS_inc.h:1424
uint16_t BlckSize
Size of a block of memory.
Definition: R_RTOS_memMngr.h:43