83 #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE 88 #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE 90 #if( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) 91 #error This file must not be used if configSUPPORT_DYNAMIC_ALLOCATION is 0 95 #define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( xHeapStructSize << 1 ) ) 98 #define heapBITS_PER_BYTE ( ( size_t ) 8 ) 101 #if( configAPPLICATION_ALLOCATED_HEAP == 1 ) 157 BlockLink_t *pxBlock, *pxPreviousBlock, *pxNewBlockLink;
158 void *pvReturn =
NULL;
177 if( ( xWantedSize & xBlockAllocatedBit ) == 0 )
181 if( xWantedSize > 0 )
187 if( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 )
191 configASSERT( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) == 0 );
203 if( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) )
207 pxPreviousBlock = &
xStart;
211 pxPreviousBlock = pxBlock;
217 if( pxBlock != pxEnd )
235 pxNewBlockLink = (
void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize );
236 configASSERT( ( ( (
size_t ) pxNewBlockLink ) & portBYTE_ALIGNMENT_MASK ) == 0 );
240 pxNewBlockLink->xBlockSize = pxBlock->
xBlockSize - xWantedSize;
253 if( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining )
285 #if( configUSE_MALLOC_FAILED_HOOK == 1 ) 287 if( pvReturn ==
NULL )
289 #if defined(__GNUC__) 290 #pragma GCC diagnostic push 291 #pragma GCC diagnostic ignored "-Wnested-externs" 294 #if defined(__GNUC__) 295 #pragma GCC diagnostic pop 306 configASSERT( ( ( (
size_t ) pvReturn ) & (
size_t ) portBYTE_ALIGNMENT_MASK ) == 0 );
313 uint8_t *puc = ( uint8_t * ) pv;
323 pxLink = (
void * ) puc;
329 if( ( pxLink->
xBlockSize & xBlockAllocatedBit ) != 0 )
380 uint8_t *pucAlignedHeap;
385 uxAddress = ( size_t )
ucHeap;
387 if( ( uxAddress & portBYTE_ALIGNMENT_MASK ) != 0 )
390 uxAddress &= ~( ( size_t ) portBYTE_ALIGNMENT_MASK );
391 xTotalHeapSize -= uxAddress - ( size_t )
ucHeap;
394 pucAlignedHeap = ( uint8_t * ) uxAddress;
403 uxAddress = ( ( size_t ) pucAlignedHeap ) + xTotalHeapSize;
405 uxAddress &= ~( ( size_t ) portBYTE_ALIGNMENT_MASK );
406 pxEnd = (
void * ) uxAddress;
412 pxFirstFreeBlock = (
void * ) pucAlignedHeap;
413 pxFirstFreeBlock->
xBlockSize = uxAddress - ( size_t ) pxFirstFreeBlock;
417 xMinimumEverFreeBytesRemaining = pxFirstFreeBlock->
xBlockSize;
418 xFreeBytesRemaining = pxFirstFreeBlock->
xBlockSize;
421 xBlockAllocatedBit = ( ( size_t ) 1 ) << ( (
sizeof( size_t ) *
heapBITS_PER_BYTE ) - 1 );
439 puc = ( uint8_t * ) pxIterator;
440 if( ( puc + pxIterator->
xBlockSize ) == ( uint8_t * ) pxBlockToInsert )
443 pxBlockToInsert = pxIterator;
452 puc = ( uint8_t * ) pxBlockToInsert;
475 if( pxIterator != pxBlockToInsert )
void vApplicationMallocFailedHook(uint32_t size, uint32_t remaining, uint32_t prevLR)
static BlockLink_t * pxEnd
void vPortInitialiseBlocks(void)
void vTaskSuspendAll(void) PRIVILEGED_FUNCTION
#define configTOTAL_HEAP_SIZE
size_t xPortGetMinimumEverFreeHeapSize(void)
#define heapMINIMUM_BLOCK_SIZE
struct A_BLOCK_LINK * pxNextFreeBlock
static size_t xBlockAllocatedBit
#define heapBITS_PER_BYTE
static void prvInsertBlockIntoFreeList(BlockLink_t *pxBlockToInsert)
static size_t xMinimumEverFreeBytesRemaining
struct A_BLOCK_LINK BlockLink_t
#define traceFREE(pvAddress, uiSize)
static size_t xFreeBytesRemaining
static void prvHeapInit(void)
void * pvPortMalloc(size_t xWantedSize)
BaseType_t xTaskResumeAll(void) PRIVILEGED_FUNCTION
#define traceMALLOC(pvAddress, uiSize)
static BlockLink_t xStart
#define portBYTE_ALIGNMENT
size_t xPortGetFreeHeapSize(void)
static const size_t xHeapStructSize
#define mtCOVERAGE_TEST_MARKER()
static uint8_t ucHeap[configTOTAL_HEAP_SIZE]