108 lines
4.4 KiB
C
108 lines
4.4 KiB
C
/*
|
||
* @Description:
|
||
* @Version:
|
||
* @Author: Arnold
|
||
* @Date: 2023-10-27 13:48:57
|
||
* @LastEditTime: 2024-01-08 23:11:25
|
||
*/
|
||
#ifndef __MM_H__
|
||
#define __MM_H__
|
||
#include <stddef.h>
|
||
#include <stdbool.h>
|
||
#include <string.h>
|
||
#include <stdint.h>
|
||
|
||
|
||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 4 * 1024 ) )
|
||
|
||
|
||
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
|
||
#define portBYTE_ALIGNMENT 8
|
||
#define portNOP() __asm volatile ( "NOP" )
|
||
#define mtCOVERAGE_TEST_MARKER() __asm volatile ( "NOP" )
|
||
#define configTICK_RATE_HZ ( 1000 )
|
||
|
||
|
||
#if portBYTE_ALIGNMENT == 32
|
||
#define portBYTE_ALIGNMENT_MASK ( 0x001f )
|
||
#elif portBYTE_ALIGNMENT == 16
|
||
#define portBYTE_ALIGNMENT_MASK ( 0x000f )
|
||
#elif portBYTE_ALIGNMENT == 8
|
||
#define portBYTE_ALIGNMENT_MASK ( 0x0007 )
|
||
#elif portBYTE_ALIGNMENT == 4
|
||
#define portBYTE_ALIGNMENT_MASK ( 0x0003 )
|
||
#elif portBYTE_ALIGNMENT == 2
|
||
#define portBYTE_ALIGNMENT_MASK ( 0x0001 )
|
||
#elif portBYTE_ALIGNMENT == 1
|
||
#define portBYTE_ALIGNMENT_MASK ( 0x0000 )
|
||
#else /* if portBYTE_ALIGNMENT == 32 */
|
||
#error "Invalid portBYTE_ALIGNMENT definition"
|
||
#endif /* if portBYTE_ALIGNMENT == 32 */
|
||
|
||
|
||
#if ( configUSE_16_BIT_TICKS == 1 )
|
||
typedef uint16_t TickType_t;
|
||
#define portMAX_DELAY ( TickType_t ) 0xffff
|
||
#else
|
||
typedef uint32_t TickType_t;
|
||
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
|
||
#endif
|
||
#define portPOINTER_SIZE_TYPE uint64_t
|
||
/* It is a good idea to define configASSERT() while developing. configASSERT()
|
||
* uses the same semantics as the standard C assert() macro. */
|
||
#define configASSERT( x ) \
|
||
do \
|
||
{ \
|
||
if( x ) \
|
||
{ \
|
||
vFakeAssert( true, __FILE__, __LINE__ ); \
|
||
} \
|
||
else \
|
||
{ \
|
||
vFakeAssert( false, __FILE__, __LINE__ ); \
|
||
} \
|
||
} while( 0 )
|
||
|
||
void vFakeAssert( bool x,
|
||
char * file,
|
||
int line );
|
||
|
||
/* Used to pass information about the heap out of vPortGetHeapStats(). */
|
||
typedef struct xHeapStats
|
||
{
|
||
size_t xAvailableHeapSpaceInBytes; /* The total heap size currently available - this is the sum of all the free blocks, not the largest block that can be allocated. */
|
||
size_t xSizeOfLargestFreeBlockInBytes; /* The maximum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */
|
||
size_t xSizeOfSmallestFreeBlockInBytes; /* The minimum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */
|
||
size_t xNumberOfFreeBlocks; /* The number of free memory blocks within the heap at the time vPortGetHeapStats() is called. */
|
||
size_t xMinimumEverFreeBytesRemaining; /* The minimum amount of total free memory (sum of all free blocks) there has been in the heap since the system booted. */
|
||
size_t xNumberOfSuccessfulAllocations; /* The number of calls to pvPortMalloc() that have returned a valid memory block. */
|
||
size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */
|
||
} HeapStats_t;
|
||
|
||
#ifndef traceMALLOC
|
||
#define traceMALLOC( pvAddress, uiSize )
|
||
#endif
|
||
|
||
#ifndef traceFREE
|
||
#define traceFREE( pvAddress, uiSize )
|
||
#endif
|
||
|
||
|
||
/* #define vFakeAssert(x, file, line) if (!(x)) { \
|
||
LogError("Assertion failed in file %s at line %d", file, line); \
|
||
RecordAssertionFailure(); \
|
||
} */
|
||
#define vFakeAssert(x, file, line) if (!(x)) { }
|
||
|
||
void * pvPortMalloc( size_t xWantedSize );//<2F><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>
|
||
void vPortFree( void * pv );//<2F>ͷ<EFBFBD><CDB7>ڴ<EFBFBD>
|
||
size_t xPortGetFreeHeapSize( void );//<2F><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD>ö<EFBFBD><C3B6>ڴ<EFBFBD><DAB4>Ĵ<EFBFBD>С
|
||
size_t xPortGetMinimumEverFreeHeapSize( void );//<2F><><EFBFBD>ڻ<EFBFBD>ȡϵͳ<CFB5><CDB3><EFBFBD>е<EFBFBD><D0B5><EFBFBD>С<EFBFBD><D0A1><EFBFBD>д<EFBFBD>С!!!!
|
||
void vPortInitialiseBlocks( void );//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƿ<EFBFBD><C6BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD>ڴ<EFBFBD>,<2C><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>
|
||
void * pvPortCalloc( size_t xNum, //<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>С<EFBFBD><D0A1><EFBFBD>ڴ濨
|
||
size_t xSize );
|
||
void vPortGetHeapStats( HeapStats_t * pxHeapStats );//ͳ<>Ƶ<EFBFBD>ǰ<EFBFBD>ѵ<EFBFBD><D1B5><EFBFBD><EFBFBD><EFBFBD>
|
||
#endif
|
||
|
||
|