\r
#define pvPortMalloc MPU_pvPortMalloc\r
#define vPortFree MPU_vPortFree\r
+ #define xPortGetFreeHeapSize MPU_xPortGetFreeHeapSize\r
+ #define vPortInitialiseBlocks MPU_vPortInitialiseBlocks\r
\r
/* Remove the privileged function macro. */\r
#define PRIVILEGED_FUNCTION\r
void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION;\r
void vPortFree( void *pv ) PRIVILEGED_FUNCTION;\r
void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION;\r
+size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION;\r
\r
/*\r
* Setup the hardware ready for the scheduler to take control. This generally\r
\r
portRESET_PRIVILEGE( xRunningPrivileged );\r
}\r
+/*-----------------------------------------------------------*/\r
+\r
+void MPU_vPortInitialiseBlocks( void )\r
+{\r
+portBASE_TYPE xRunningPrivileged = prvRaisePrivilege();\r
+\r
+ vPortInitialiseBlocks();\r
+\r
+ portRESET_PRIVILEGE( xRunningPrivileged );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+size_t MPU_xPortGetFreeHeapSize( void )\r
+{\r
+size_t xReturn;\r
+portBASE_TYPE xRunningPrivileged = prvRaisePrivilege();\r
+\r
+ xReturn = xPortGetFreeHeapSize();\r
+\r
+ portRESET_PRIVILEGE( xRunningPrivileged );\r
+ \r
+ return xReturn;\r
+}\r
+\r
/* Only required when static memory is not cleared. */\r
xNextFreeByte = ( size_t ) 0;\r
}\r
+/*-----------------------------------------------------------*/\r
+\r
+size_t xPortGetFreeHeapSize( void )\r
+{\r
+ return ( configTOTAL_HEAP_SIZE - xNextFreeByte );\r
+}\r
+\r
\r
\r
/* Create a couple of list links to mark the start and end of the list. */\r
static xBlockLink xStart, xEnd;\r
\r
+/* Keeps track of the number of free bytes remaining, but says nothing about\r
+fragmentation. */\r
+static size_t xFreeBytesRemaining = configTOTAL_HEAP_SIZE;\r
+\r
/* STATIC FUNCTIONS ARE DEFINED AS MACROS TO MINIMIZE THE FUNCTION CALL DEPTH. */\r
\r
/*\r
/* Insert the new block into the list of free blocks. */\r
prvInsertBlockIntoFreeList( ( pxNewBlockLink ) );\r
}\r
+ \r
+ xFreeBytesRemaining -= xWantedSize;\r
}\r
}\r
}\r
{\r
/* Add this block to the list of free blocks. */\r
prvInsertBlockIntoFreeList( ( ( xBlockLink * ) pxLink ) );\r
+ xFreeBytesRemaining += pxLink->xBlockSize;\r
}\r
xTaskResumeAll();\r
}\r
}\r
/*-----------------------------------------------------------*/\r
\r
+size_t xPortGetFreeHeapSize( void )\r
+{\r
+ return xFreeBytesRemaining;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r