Skip to content

Commit

Permalink
Add MPU macros to heap_5.c
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Lavery committed Aug 10, 2023
1 parent 3888ffb commit 8f0289f
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions portable/MemMang/heap_5.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ typedef struct A_BLOCK_LINK
/* We require xApplicationGetRandomNumber in order to initialize our canary value */
extern BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber );
/* Canary value for protecting internal heap pointers */
static portPOINTER_SIZE_TYPE xHeapCanary;
PRIVILEGED_DATA static portPOINTER_SIZE_TYPE xHeapCanary;
/* Highest and lowest heap addresses for bounds checking */
static void * pxHeapHighAddress = NULL;
static void * pxHeapLowAddress = NULL;
PRIVILEGED_DATA static void * pxHeapHighAddress = NULL;
PRIVILEGED_DATA static void * pxHeapLowAddress = NULL;

/* Macro to load/store pxNextFreeBlock pointers to memory. By XORing the
* pointers with a random canary value, intentional heap overwrites will
Expand Down Expand Up @@ -167,24 +167,24 @@ typedef struct A_BLOCK_LINK
* the block in front it and/or the block behind it if the memory blocks are
* adjacent to each other.
*/
static void prvInsertBlockIntoFreeList( BlockLink_t * pxBlockToInsert );

static void prvInsertBlockIntoFreeList( BlockLink_t * pxBlockToInsert ) PRIVILEGED_FUNCTION;
void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION;
/*-----------------------------------------------------------*/

/* The size of the structure placed at the beginning of each allocated memory
* block must by correctly byte aligned. */
static const size_t xHeapStructSize = ( sizeof( BlockLink_t ) + ( ( size_t ) ( portBYTE_ALIGNMENT - 1 ) ) ) & ~( ( size_t ) portBYTE_ALIGNMENT_MASK );

/* Create a couple of list links to mark the start and end of the list. */
static BlockLink_t xStart;
static BlockLink_t * pxEnd = NULL;
PRIVILEGED_DATA static BlockLink_t xStart;
PRIVILEGED_DATA static BlockLink_t * pxEnd = NULL;

/* Keeps track of the number of calls to allocate and free memory as well as the
* number of free bytes remaining, but says nothing about fragmentation. */
static size_t xFreeBytesRemaining = 0U;
static size_t xMinimumEverFreeBytesRemaining = 0U;
static size_t xNumberOfSuccessfulAllocations = 0;
static size_t xNumberOfSuccessfulFrees = 0;
PRIVILEGED_DATA static size_t xFreeBytesRemaining = 0U;
PRIVILEGED_DATA static size_t xMinimumEverFreeBytesRemaining = 0U;
PRIVILEGED_DATA static size_t xNumberOfSuccessfulAllocations = 0;
PRIVILEGED_DATA static size_t xNumberOfSuccessfulFrees = 0;

/*-----------------------------------------------------------*/

Expand Down Expand Up @@ -444,7 +444,7 @@ void * pvPortCalloc( size_t xNum,
}
/*-----------------------------------------------------------*/

static void prvInsertBlockIntoFreeList( BlockLink_t * pxBlockToInsert )
static void prvInsertBlockIntoFreeList( BlockLink_t * pxBlockToInsert ) /* PRIVILEGED_FUNCTION */
{
BlockLink_t * pxIterator;
uint8_t * puc;
Expand Down Expand Up @@ -513,7 +513,7 @@ static void prvInsertBlockIntoFreeList( BlockLink_t * pxBlockToInsert )
}
/*-----------------------------------------------------------*/

void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions )
void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) /* PRIVILEGED_FUNCTION */
{
BlockLink_t * pxFirstFreeBlockInRegion = NULL;
BlockLink_t * pxPreviousFreeBlock;
Expand Down

0 comments on commit 8f0289f

Please sign in to comment.