ESP8266
mem_manager.h
1 #ifndef __MEM_MANAGER_H__
2 #define __MEM_MANAGER_H__
3 
4 #include "c_types.h"
5 
6 /*------------------------变量定义------------------------*/
7 
8 #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
9 #ifndef IOT_SIP_MODE
10 //#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 0x3fffc000 - (uint32)&_heap_start ) )//fix 16000 to 24000 on 14.2.26
11 #else
12 #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 8000 ) )
13 #endif
14 #define portBYTE_ALIGNMENT 8
15 #define pdFALSE 0
16 #define pdTRUE 1
17 
18 #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
19 #if portBYTE_ALIGNMENT == 8
20  #define portBYTE_ALIGNMENT_MASK ( 0x0007 )
21 #endif
22 
23 #if portBYTE_ALIGNMENT == 4
24  #define portBYTE_ALIGNMENT_MASK ( 0x0003 )
25 #endif
26 
27 #if portBYTE_ALIGNMENT == 2
28  #define portBYTE_ALIGNMENT_MASK ( 0x0001 )
29 #endif
30 
31 #if portBYTE_ALIGNMENT == 1
32  #define portBYTE_ALIGNMENT_MASK ( 0x0000 )
33 #endif
34 
35 #ifndef portBYTE_ALIGNMENT_MASK
36  #error "Invalid portBYTE_ALIGNMENT definition"
37 #endif
38 
39 #define configUSE_MALLOC_FAILED_HOOK 1
40 #define portPOINTER_SIZE_TYPE unsigned int
41 
42 #define heapMINIMUM_BLOCK_SIZE ( ( size_t ) ( heapSTRUCT_SIZE * 2 ) )
43 
44 //#define configADJUSTED_HEAP_SIZE ( configTOTAL_HEAP_SIZE - portBYTE_ALIGNMENT )
45 
46 //static unsigned char ucHeap[ configTOTAL_HEAP_SIZE ];
47 //static unsigned char *ucHeap;
48 
49 typedef struct A_BLOCK_LINK
50 {
51  struct A_BLOCK_LINK *pxNextFreeBlock; //The next free block in the list.
52  size_t xBlockSize; //The size of the free block.
53 } xBlockLink;
54 
55 static const unsigned short heapSTRUCT_SIZE = ( sizeof( xBlockLink ) + portBYTE_ALIGNMENT - ( sizeof( xBlockLink ) % portBYTE_ALIGNMENT ) );
56 
57 //static const size_t xTotalHeapSize = ( ( size_t ) configADJUSTED_HEAP_SIZE ) & ( ( size_t ) ~portBYTE_ALIGNMENT_MASK );
58 
59 //static xBlockLink xStart, *pxEnd = NULL;
60 
61 //static size_t xFreeBytesRemaining = ( ( size_t ) configADJUSTED_HEAP_SIZE ) & ( ( size_t ) ~portBYTE_ALIGNMENT_MASK );
62 
63 
64 /*------------------------函数声明-----------------------------------*/
65 
66 //static void prvInsertBlockIntoFreeList( xBlockLink *pxBlockToInsert ) ;//ICACHE_FLASH_ATTR;
67 
68 //static void prvHeapInit( void ) ;//ICACHE_FLASH_ATTR;
69 
70 void vApplicationMallocFailedHook( void ) ;//ICACHE_FLASH_ATTR;
71 
72 void *pvPortMalloc( size_t xWantedSize ) ;//ICACHE_FLASH_ATTR;
73 
74 void vPortFree( void *pv ) ;//ICACHE_FLASH_ATTR;
75 
76 size_t xPortGetFreeHeapSize( void ) ;//ICACHE_FLASH_ATTR;
77 
78 void vPortInitialiseBlocks( void ) ;//ICACHE_FLASH_ATTR;
79 /*-----------------------------------------------------------*/
80 
81 #endif
struct A_BLOCK_LINK * pxNextFreeBlock
Definition: mem_manager.h:51
Definition: mem_manager.h:49
size_t xBlockSize
Definition: mem_manager.h:52