|
132 | 132 | #endif
|
133 | 133 | #endif /* if ( portUSING_MPU_WRAPPERS == 1 ) */
|
134 | 134 |
|
135 |
| -/* Used by heap_5.c to define the start address and size of each memory region |
136 |
| - * that together comprise the total FreeRTOS heap space. */ |
137 |
| -typedef struct HeapRegion |
138 |
| -{ |
139 |
| - uint8_t * pucStartAddress; |
140 |
| - size_t xSizeInBytes; |
141 |
| -} HeapRegion_t; |
| 135 | +/* Only include heap related functions and structs if using dynamic allocation */ |
| 136 | +#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) |
142 | 137 |
|
143 |
| -/* Used to pass information about the heap out of vPortGetHeapStats(). */ |
144 |
| -typedef struct xHeapStats |
145 |
| -{ |
146 |
| - 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. */ |
147 |
| - size_t xSizeOfLargestFreeBlockInBytes; /* The maximum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ |
148 |
| - size_t xSizeOfSmallestFreeBlockInBytes; /* The minimum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ |
149 |
| - size_t xNumberOfFreeBlocks; /* The number of free memory blocks within the heap at the time vPortGetHeapStats() is called. */ |
150 |
| - 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. */ |
151 |
| - size_t xNumberOfSuccessfulAllocations; /* The number of calls to pvPortMalloc() that have returned a valid memory block. */ |
152 |
| - size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */ |
153 |
| -} HeapStats_t; |
| 138 | + /* Used by heap_5.c to define the start address and size of each memory region |
| 139 | + * that together comprise the total FreeRTOS heap space. */ |
| 140 | + typedef struct HeapRegion |
| 141 | + { |
| 142 | + uint8_t * pucStartAddress; |
| 143 | + size_t xSizeInBytes; |
| 144 | + } HeapRegion_t; |
154 | 145 |
|
155 |
| -/* |
156 |
| - * Used to define multiple heap regions for use by heap_5.c. This function |
157 |
| - * must be called before any calls to pvPortMalloc() - not creating a task, |
158 |
| - * queue, semaphore, mutex, software timer, event group, etc. will result in |
159 |
| - * pvPortMalloc being called. |
160 |
| - * |
161 |
| - * pxHeapRegions passes in an array of HeapRegion_t structures - each of which |
162 |
| - * defines a region of memory that can be used as the heap. The array is |
163 |
| - * terminated by a HeapRegions_t structure that has a size of 0. The region |
164 |
| - * with the lowest start address must appear first in the array. |
165 |
| - */ |
166 |
| -void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION; |
| 146 | + /* Used to pass information about the heap out of vPortGetHeapStats(). */ |
| 147 | + typedef struct xHeapStats |
| 148 | + { |
| 149 | + 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. */ |
| 150 | + size_t xSizeOfLargestFreeBlockInBytes; /* The maximum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ |
| 151 | + size_t xSizeOfSmallestFreeBlockInBytes; /* The minimum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */ |
| 152 | + size_t xNumberOfFreeBlocks; /* The number of free memory blocks within the heap at the time vPortGetHeapStats() is called. */ |
| 153 | + 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. */ |
| 154 | + size_t xNumberOfSuccessfulAllocations; /* The number of calls to pvPortMalloc() that have returned a valid memory block. */ |
| 155 | + size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */ |
| 156 | + } HeapStats_t; |
167 | 157 |
|
168 |
| -/* |
169 |
| - * Returns a HeapStats_t structure filled with information about the current |
170 |
| - * heap state. |
171 |
| - */ |
172 |
| -void vPortGetHeapStats( HeapStats_t * pxHeapStats ); |
| 158 | + /* |
| 159 | + * Used to define multiple heap regions for use by heap_5.c. This function |
| 160 | + * must be called before any calls to pvPortMalloc() - not creating a task, |
| 161 | + * queue, semaphore, mutex, software timer, event group, etc. will result in |
| 162 | + * pvPortMalloc being called. |
| 163 | + * |
| 164 | + * pxHeapRegions passes in an array of HeapRegion_t structures - each of which |
| 165 | + * defines a region of memory that can be used as the heap. The array is |
| 166 | + * terminated by a HeapRegions_t structure that has a size of 0. The region |
| 167 | + * with the lowest start address must appear first in the array. |
| 168 | + */ |
| 169 | + void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION; |
173 | 170 |
|
174 |
| -/* |
175 |
| - * Map to the memory management routines required for the port. |
176 |
| - */ |
177 |
| -void * pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION; |
178 |
| -void * pvPortCalloc( size_t xNum, |
179 |
| - size_t xSize ) PRIVILEGED_FUNCTION; |
180 |
| -void vPortFree( void * pv ) PRIVILEGED_FUNCTION; |
181 |
| -void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION; |
182 |
| -size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION; |
183 |
| -size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION; |
| 171 | + /* |
| 172 | + * Returns a HeapStats_t structure filled with information about the current |
| 173 | + * heap state. |
| 174 | + */ |
| 175 | + void vPortGetHeapStats( HeapStats_t * pxHeapStats ); |
184 | 176 |
|
185 |
| -#if ( configSTACK_ALLOCATION_FROM_SEPARATE_HEAP == 1 ) |
186 |
| - void * pvPortMallocStack( size_t xSize ) PRIVILEGED_FUNCTION; |
187 |
| - void vPortFreeStack( void * pv ) PRIVILEGED_FUNCTION; |
188 |
| -#else |
189 |
| - #define pvPortMallocStack pvPortMalloc |
190 |
| - #define vPortFreeStack vPortFree |
191 |
| -#endif |
| 177 | + /* |
| 178 | + * Map to the memory management routines required for the port. |
| 179 | + */ |
| 180 | + void * pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION; |
| 181 | + void * pvPortCalloc( size_t xNum, |
| 182 | + size_t xSize ) PRIVILEGED_FUNCTION; |
| 183 | + void vPortFree( void * pv ) PRIVILEGED_FUNCTION; |
| 184 | + void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION; |
| 185 | + size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION; |
| 186 | + size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION; |
192 | 187 |
|
193 |
| -#if ( configUSE_MALLOC_FAILED_HOOK == 1 ) |
| 188 | + #if ( configSTACK_ALLOCATION_FROM_SEPARATE_HEAP == 1 ) |
| 189 | + void * pvPortMallocStack( size_t xSize ) PRIVILEGED_FUNCTION; |
| 190 | + void vPortFreeStack( void * pv ) PRIVILEGED_FUNCTION; |
| 191 | + #else |
| 192 | + #define pvPortMallocStack pvPortMalloc |
| 193 | + #define vPortFreeStack vPortFree |
| 194 | + #endif |
194 | 195 |
|
195 |
| -/** |
196 |
| - * task.h |
197 |
| - * @code{c} |
198 |
| - * void vApplicationMallocFailedHook( void ) |
199 |
| - * @endcode |
200 |
| - * |
201 |
| - * This hook function is called when allocation failed. |
202 |
| - */ |
203 |
| - void vApplicationMallocFailedHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */ |
204 |
| -#endif |
| 196 | + #if ( configUSE_MALLOC_FAILED_HOOK == 1 ) |
| 197 | + /** |
| 198 | + * task.h |
| 199 | + * @code{c} |
| 200 | + * void vApplicationMallocFailedHook( void ) |
| 201 | + * @endcode |
| 202 | + * |
| 203 | + * This hook function is called when allocation failed. |
| 204 | + */ |
| 205 | + void vApplicationMallocFailedHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */ |
| 206 | + #endif /* ( configUSE_MALLOC_FAILED_HOOK == 1 ) */ |
| 207 | + |
| 208 | +#endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) */ |
205 | 209 |
|
206 | 210 | /*
|
207 | 211 | * Setup the hardware ready for the scheduler to take control. This generally
|
|
0 commit comments