1 /*
2 * FreeRTOS Kernel <DEVELOPMENT BRANCH>
3 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 *
5 * SPDX-License-Identifier: MIT
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy of
8 * this software and associated documentation files (the "Software"), to deal in
9 * the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11 * the Software, and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * https://www.FreeRTOS.org
25 * https://github.com/FreeRTOS
26 *
27 */
28
29 /*-----------------------------------------------------------
30 * Portable layer API. Each function must be defined for each port.
31 *----------------------------------------------------------*/
32
35
36 /* Each FreeRTOS port has a unique portmacro.h header file. Originally a
37 * pre-processor definition was used to ensure the pre-processor found the correct
38 * portmacro.h file for the port being used. That scheme was deprecated in favour
39 * of setting the compiler's include path such that it found the correct
40 * portmacro.h file - removing the need for the constant and allowing the
41 * portmacro.h file to be located anywhere in relation to the port being used.
42 * Purely for reasons of backward compatibility the old method is still valid, but
43 * to make it clear that new projects should not use it, support for the port
44 * specific constants has been moved into the deprecated_definitions.h header
45 * file. */
46 #include "deprecated_definitions.h"
47
48 /* If portENTER_CRITICAL is not defined then including deprecated_definitions.h
49 * did not result in a portmacro.h header file being included - and it should be
50 * included here. In this case the path to the correct portmacro.h header file
51 * must be set in the compiler's include path. */
53 #include "portmacro.h"
54 #endif
55
68 #else /* if portBYTE_ALIGNMENT == 32 */
69 #error "Invalid portBYTE_ALIGNMENT definition"
70 #endif /* if portBYTE_ALIGNMENT == 32 */
71
74 #endif
75
78 #endif
79
82 #endif
83
86 #endif
87
89 /* Defaults to 0 for backward compatibility. */
91 #endif
92
93 /* *INDENT-OFF* */
94 #ifdef __cplusplus
95 extern "C" {
96 #endif
97 /* *INDENT-ON* */
98
99 #include "mpu_wrappers.h"
100
101 /*
102 * Setup the stack of a new task so it is ready to be placed under the
103 * scheduler control. The registers have to be placed on the stack in
104 * the order that the port expects to find them.
105 *
106 */
111 TaskFunction_t pxCode,
113
BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION;
114 #else
116 TaskFunction_t pxCode,
118
BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION;
119 #endif
120 #else /* if ( portUSING_MPU_WRAPPERS == 1 ) */
124 TaskFunction_t pxCode,
126 #else
128 TaskFunction_t pxCode,
130 #endif
131 #endif /* if ( portUSING_MPU_WRAPPERS == 1 ) */
132
133 /* Used by heap_5.c to define the start address and size of each memory region
134 * that together comprise the total FreeRTOS heap space. */
136 {
140
141 /* Used to pass information about the heap out of vPortGetHeapStats(). */
143 {
144 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. */
145 size_t
xSizeOfLargestFreeBlockInBytes; /* The maximum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */
146 size_t
xSizeOfSmallestFreeBlockInBytes; /* The minimum size, in bytes, of all the free blocks within the heap at the time vPortGetHeapStats() is called. */
147 size_t
xNumberOfFreeBlocks; /* The number of free memory blocks within the heap at the time vPortGetHeapStats() is called. */
148 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. */
150 size_t
xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */
152
153 /*
154 * Used to define multiple heap regions for use by heap_5.c. This function
155 * must be called before any calls to pvPortMalloc() - not creating a task,
156 * queue, semaphore, mutex, software timer, event group, etc. will result in
157 * pvPortMalloc being called.
158 *
159 * pxHeapRegions passes in an array of HeapRegion_t structures - each of which
160 * defines a region of memory that can be used as the heap. The array is
161 * terminated by a HeapRegions_t structure that has a size of 0. The region
162 * with the lowest start address must appear first in the array.
163 */
165
166 /*
167 * Returns a HeapStats_t structure filled with information about the current
168 * heap state.
169 */
171
172 /*
173 * Map to the memory management routines required for the port.
174 */
175 void *
pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION;
177 size_t xSize ) PRIVILEGED_FUNCTION;
178 void
vPortFree( void * pv ) PRIVILEGED_FUNCTION;
179 void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION;
182
186 #else
189 #endif
190
191 #if ( configUSE_MALLOC_FAILED_HOOK == 1 )
192
193 /**
194 * task.h
195 * @code{c}
196 * void vApplicationMallocFailedHook( void )
197 * @endcode
198 *
199 * This hook function is called when allocation failed.
200 */
201 void vApplicationMallocFailedHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */
202 #endif
203
204 /*
205 * Setup the hardware ready for the scheduler to take control. This generally
206 * sets up a tick interrupt and sets timers for the correct tick frequency.
207 */
208
BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION;
209
210 /*
211 * Undo any hardware/ISR setup that was performed by xPortStartScheduler() so
212 * the hardware is left in its original condition after the scheduler stops
213 * executing.
214 */
215 void vPortEndScheduler( void ) PRIVILEGED_FUNCTION;
216
217 /*
218 * The structures and methods of manipulating the MPU are contained within the
219 * port layer.
220 *
221 * Fills the xMPUSettings structure with the memory region information
222 * contained in xRegions.
223 */
226 void vPortStoreTaskMPUSettings( xMPU_SETTINGS * xMPUSettings,
229 uint32_t ulStackDepth ) PRIVILEGED_FUNCTION;
230 #endif
231
232 /* *INDENT-OFF* */
233 #ifdef __cplusplus
234 }
235 #endif
236 /* *INDENT-ON* */
237
238 #endif /* PORTABLE_H */