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  * When the MPU is used the standard (non MPU) API functions are mapped to
31  * equivalents that start "MPU_", the prototypes for which are defined in this
32  * header files.  This will cause the application code to call the MPU_ version
33  * which wraps the non-MPU version with privilege promoting then demoting code,
34  * so the kernel code always runs will full privileges.
35  */
36 
37 
38 #ifndef MPU_PROTOTYPES_H
39 #define MPU_PROTOTYPES_H
40 
41 typedef struct xTaskGenericNotifyParams
42 {
43     TaskHandle_t xTaskToNotify;
44     UBaseType_t uxIndexToNotify;
45     uint32_t ulValue;
46     eNotifyAction eAction;
47     uint32_t * pulPreviousNotificationValue;
48 } xTaskGenericNotifyParams_t;
49 
50 typedef struct xTaskGenericNotifyWaitParams
51 {
52     UBaseType_t uxIndexToWaitOn;
53     uint32_t ulBitsToClearOnEntry;
54     uint32_t ulBitsToClearOnExit;
55     uint32_t * pulNotificationValue;
56     TickType_t xTicksToWait;
57 } xTaskGenericNotifyWaitParams_t;
58 
59 typedef struct xTimerGenericCommandFromTaskParams
60 {
61     TimerHandle_t xTimer;
62     BaseType_t xCommandID;
63     TickType_t xOptionalValue;
64     BaseType_t * pxHigherPriorityTaskWoken;
65     TickType_t xTicksToWait;
66 } xTimerGenericCommandFromTaskParams_t;
67 
68 typedef struct xEventGroupWaitBitsParams
69 {
70     EventGroupHandle_t xEventGroup;
71     EventBits_t uxBitsToWaitFor;
72     BaseType_t xClearOnExit;
73     BaseType_t xWaitForAllBits;
74     TickType_t xTicksToWait;
75 } xEventGroupWaitBitsParams_t;
76 
77 /* MPU versions of task.h API functions. */
78 void MPU_vTaskDelay( const TickType_t xTicksToDelay ) FREERTOS_SYSTEM_CALL;
79 BaseType_t MPU_xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
80                                 const TickType_t xTimeIncrement ) FREERTOS_SYSTEM_CALL;
81 BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;
82 UBaseType_t MPU_uxTaskPriorityGet( const TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;
83 eTaskState MPU_eTaskGetState( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;
84 void MPU_vTaskGetInfo( TaskHandle_t xTask,
85                        TaskStatus_t * pxTaskStatus,
86                        BaseType_t xGetFreeStackSpace,
87                        eTaskState eState ) FREERTOS_SYSTEM_CALL;
88 void MPU_vTaskSuspend( TaskHandle_t xTaskToSuspend ) FREERTOS_SYSTEM_CALL;
89 void MPU_vTaskResume( TaskHandle_t xTaskToResume ) FREERTOS_SYSTEM_CALL;
90 TickType_t MPU_xTaskGetTickCount( void ) FREERTOS_SYSTEM_CALL;
91 UBaseType_t MPU_uxTaskGetNumberOfTasks( void ) FREERTOS_SYSTEM_CALL;
92 UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;
93 configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;
94 void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask,
95                                      TaskHookFunction_t pxHookFunction ) FREERTOS_SYSTEM_CALL;
96 TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;
97 void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet,
98                                             BaseType_t xIndex,
99                                             void * pvValue ) FREERTOS_SYSTEM_CALL;
100 void * MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery,
101                                                BaseType_t xIndex ) FREERTOS_SYSTEM_CALL;
102 TaskHandle_t MPU_xTaskGetIdleTaskHandle( void ) FREERTOS_SYSTEM_CALL;
103 UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray,
104                                       const UBaseType_t uxArraySize,
105                                       configRUN_TIME_COUNTER_TYPE * const pulTotalRunTime ) FREERTOS_SYSTEM_CALL;
106 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetRunTimeCounter( const TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;
107 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetRunTimePercent( const TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;
108 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimeCounter( void ) FREERTOS_SYSTEM_CALL;
109 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimePercent( void ) FREERTOS_SYSTEM_CALL;
110 BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify,
111                                    UBaseType_t uxIndexToNotify,
112                                    uint32_t ulValue,
113                                    eNotifyAction eAction,
114                                    uint32_t * pulPreviousNotificationValue ) FREERTOS_SYSTEM_CALL;
115 BaseType_t MPU_xTaskGenericNotifyEntry( const xTaskGenericNotifyParams_t * pxParams ) FREERTOS_SYSTEM_CALL;
116 BaseType_t MPU_xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn,
117                                        uint32_t ulBitsToClearOnEntry,
118                                        uint32_t ulBitsToClearOnExit,
119                                        uint32_t * pulNotificationValue,
120                                        TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
121 BaseType_t MPU_xTaskGenericNotifyWaitEntry( const xTaskGenericNotifyWaitParams_t * pxParams ) FREERTOS_SYSTEM_CALL;
122 uint32_t MPU_ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn,
123                                       BaseType_t xClearCountOnExit,
124                                       TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
125 BaseType_t MPU_xTaskGenericNotifyStateClear( TaskHandle_t xTask,
126                                              UBaseType_t uxIndexToClear ) FREERTOS_SYSTEM_CALL;
127 uint32_t MPU_ulTaskGenericNotifyValueClear( TaskHandle_t xTask,
128                                             UBaseType_t uxIndexToClear,
129                                             uint32_t ulBitsToClear ) FREERTOS_SYSTEM_CALL;
130 void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) FREERTOS_SYSTEM_CALL;
131 BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut,
132                                      TickType_t * const pxTicksToWait ) FREERTOS_SYSTEM_CALL;
133 TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ) FREERTOS_SYSTEM_CALL;
134 BaseType_t MPU_xTaskGetSchedulerState( void ) FREERTOS_SYSTEM_CALL;
135 
136 /* Privileged only wrappers for Task APIs. These are needed so that
137  * the application can use opaque handles maintained in mpu_wrappers.c
138  * with all the APIs. */
139 #if ( configUSE_MPU_WRAPPERS_V1 == 1 )
140 
141     BaseType_t MPU_xTaskCreate( TaskFunction_t pxTaskCode,
142                                 const char * const pcName,
143                                 const configSTACK_DEPTH_TYPE uxStackDepth,
144                                 void * const pvParameters,
145                                 UBaseType_t uxPriority,
146                                 TaskHandle_t * const pxCreatedTask ) FREERTOS_SYSTEM_CALL;
147     TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode,
148                                         const char * const pcName,
149                                         const configSTACK_DEPTH_TYPE uxStackDepth,
150                                         void * const pvParameters,
151                                         UBaseType_t uxPriority,
152                                         StackType_t * const puxStackBuffer,
153                                         StaticTask_t * const pxTaskBuffer ) FREERTOS_SYSTEM_CALL;
154     void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ) FREERTOS_SYSTEM_CALL;
155     void MPU_vTaskPrioritySet( TaskHandle_t xTask,
156                                UBaseType_t uxNewPriority ) FREERTOS_SYSTEM_CALL;
157     TaskHandle_t MPU_xTaskGetHandle( const char * pcNameToQuery ) FREERTOS_SYSTEM_CALL;
158     BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask,
159                                                  void * pvParameter ) FREERTOS_SYSTEM_CALL;
160     void MPU_vTaskGetRunTimeStatistics( char * pcWriteBuffer,
161                                         size_t uxBufferLength ) FREERTOS_SYSTEM_CALL;
162     void MPU_vTaskListTasks( char * pcWriteBuffer,
163                              size_t uxBufferLength ) FREERTOS_SYSTEM_CALL;
164     void MPU_vTaskSuspendAll( void ) FREERTOS_SYSTEM_CALL;
165     BaseType_t MPU_xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) FREERTOS_SYSTEM_CALL;
166     BaseType_t MPU_xTaskResumeAll( void ) FREERTOS_SYSTEM_CALL;
167 
168 #else /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
169 
170     BaseType_t MPU_xTaskCreate( TaskFunction_t pxTaskCode,
171                                 const char * const pcName,
172                                 const configSTACK_DEPTH_TYPE uxStackDepth,
173                                 void * const pvParameters,
174                                 UBaseType_t uxPriority,
175                                 TaskHandle_t * const pxCreatedTask ) PRIVILEGED_FUNCTION;
176     TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode,
177                                         const char * const pcName,
178                                         const configSTACK_DEPTH_TYPE uxStackDepth,
179                                         void * const pvParameters,
180                                         UBaseType_t uxPriority,
181                                         StackType_t * const puxStackBuffer,
182                                         StaticTask_t * const pxTaskBuffer ) PRIVILEGED_FUNCTION;
183     void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
184     void MPU_vTaskPrioritySet( TaskHandle_t xTask,
185                                UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION;
186     TaskHandle_t MPU_xTaskGetHandle( const char * pcNameToQuery ) PRIVILEGED_FUNCTION;
187     BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask,
188                                                  void * pvParameter ) PRIVILEGED_FUNCTION;
189 
190 #endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
191 
192 char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION;
193 BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition,
194                                       TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
195 BaseType_t MPU_xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition,
196                                             TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION;
197 void MPU_vTaskAllocateMPURegions( TaskHandle_t xTaskToModify,
198                                   const MemoryRegion_t * const xRegions ) PRIVILEGED_FUNCTION;
199 BaseType_t MPU_xTaskGetStaticBuffers( TaskHandle_t xTask,
200                                       StackType_t ** ppuxStackBuffer,
201                                       StaticTask_t ** ppxTaskBuffer ) PRIVILEGED_FUNCTION;
202 UBaseType_t MPU_uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
203 UBaseType_t MPU_uxTaskBasePriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
204 UBaseType_t MPU_uxTaskBasePriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
205 BaseType_t MPU_xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
206 TaskHookFunction_t MPU_xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
207 BaseType_t MPU_xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify,
208                                           UBaseType_t uxIndexToNotify,
209                                           uint32_t ulValue,
210                                           eNotifyAction eAction,
211                                           uint32_t * pulPreviousNotificationValue,
212                                           BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
213 void MPU_vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify,
214                                         UBaseType_t uxIndexToNotify,
215                                         BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
216 
217 /* MPU versions of queue.h API functions. */
218 BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue,
219                                   const void * const pvItemToQueue,
220                                   TickType_t xTicksToWait,
221                                   const BaseType_t xCopyPosition ) FREERTOS_SYSTEM_CALL;
222 BaseType_t MPU_xQueueReceive( QueueHandle_t xQueue,
223                               void * const pvBuffer,
224                               TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
225 BaseType_t MPU_xQueuePeek( QueueHandle_t xQueue,
226                            void * const pvBuffer,
227                            TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
228 BaseType_t MPU_xQueueSemaphoreTake( QueueHandle_t xQueue,
229                                     TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
230 UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL;
231 UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL;
232 TaskHandle_t MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ) FREERTOS_SYSTEM_CALL;
233 BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex,
234                                          TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
235 BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t pxMutex ) FREERTOS_SYSTEM_CALL;
236 void MPU_vQueueAddToRegistry( QueueHandle_t xQueue,
237                               const char * pcName ) FREERTOS_SYSTEM_CALL;
238 void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL;
239 const char * MPU_pcQueueGetName( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL;
240 BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore,
241                                QueueSetHandle_t xQueueSet ) FREERTOS_SYSTEM_CALL;
242 QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet,
243                                                 const TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
244 void MPU_vQueueSetQueueNumber( QueueHandle_t xQueue,
245                                UBaseType_t uxQueueNumber ) FREERTOS_SYSTEM_CALL;
246 UBaseType_t MPU_uxQueueGetQueueNumber( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL;
247 uint8_t MPU_ucQueueGetQueueType( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL;
248 
249 /* Privileged only wrappers for Queue APIs. These are needed so that
250  * the application can use opaque handles maintained in mpu_wrappers.c
251  * with all the APIs. */
252 #if ( configUSE_MPU_WRAPPERS_V1 == 1 )
253 
254     void MPU_vQueueDelete( QueueHandle_t xQueue ) FREERTOS_SYSTEM_CALL;
255     QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL;
256     QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType,
257                                                StaticQueue_t * pxStaticQueue ) FREERTOS_SYSTEM_CALL;
258     QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount,
259                                                      const UBaseType_t uxInitialCount ) FREERTOS_SYSTEM_CALL;
260     QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
261                                                            const UBaseType_t uxInitialCount,
262                                                            StaticQueue_t * pxStaticQueue ) FREERTOS_SYSTEM_CALL;
263     QueueHandle_t MPU_xQueueGenericCreate( const UBaseType_t uxQueueLength,
264                                            const UBaseType_t uxItemSize,
265                                            const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL;
266     QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength,
267                                                  const UBaseType_t uxItemSize,
268                                                  uint8_t * pucQueueStorage,
269                                                  StaticQueue_t * pxStaticQueue,
270                                                  const uint8_t ucQueueType ) FREERTOS_SYSTEM_CALL;
271     QueueSetHandle_t MPU_xQueueCreateSet( const UBaseType_t uxEventQueueLength ) FREERTOS_SYSTEM_CALL;
272     QueueSetHandle_t MPU_xQueueCreateSetStatic( const UBaseType_t uxEventQueueLength,
273                                                 uint8_t * pucQueueStorage,
274                                                 StaticQueue_t * pxStaticQueue ) FREERTOS_SYSTEM_CALL;
275     BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
276                                         QueueSetHandle_t xQueueSet ) FREERTOS_SYSTEM_CALL;
277     BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue,
278                                        BaseType_t xNewQueue ) FREERTOS_SYSTEM_CALL;
279 
280 #else /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
281 
282     void MPU_vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
283     QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
284     QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType,
285                                                StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION;
286     QueueHandle_t MPU_xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount,
287                                                      const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION;
288     QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
289                                                            const UBaseType_t uxInitialCount,
290                                                            StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION;
291     QueueHandle_t MPU_xQueueGenericCreate( const UBaseType_t uxQueueLength,
292                                            const UBaseType_t uxItemSize,
293                                            const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
294     QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength,
295                                                  const UBaseType_t uxItemSize,
296                                                  uint8_t * pucQueueStorage,
297                                                  StaticQueue_t * pxStaticQueue,
298                                                  const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
299     QueueSetHandle_t MPU_xQueueCreateSet( const UBaseType_t uxEventQueueLength ) PRIVILEGED_FUNCTION;
300     QueueSetHandle_t MPU_xQueueCreateSetStatic( const UBaseType_t uxEventQueueLength,
301                                                 uint8_t * pucQueueStorage,
302                                                 StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION;
303     BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
304                                         QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
305     BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue,
306                                        BaseType_t xNewQueue ) PRIVILEGED_FUNCTION;
307 
308 #endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
309 
310 BaseType_t MPU_xQueueGenericGetStaticBuffers( QueueHandle_t xQueue,
311                                               uint8_t ** ppucQueueStorage,
312                                               StaticQueue_t ** ppxStaticQueue ) PRIVILEGED_FUNCTION;
313 BaseType_t MPU_xQueueGenericSendFromISR( QueueHandle_t xQueue,
314                                          const void * const pvItemToQueue,
315                                          BaseType_t * const pxHigherPriorityTaskWoken,
316                                          const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION;
317 BaseType_t MPU_xQueueGiveFromISR( QueueHandle_t xQueue,
318                                   BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
319 BaseType_t MPU_xQueuePeekFromISR( QueueHandle_t xQueue,
320                                   void * const pvBuffer ) PRIVILEGED_FUNCTION;
321 BaseType_t MPU_xQueueReceiveFromISR( QueueHandle_t xQueue,
322                                      void * const pvBuffer,
323                                      BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
324 BaseType_t MPU_xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
325 BaseType_t MPU_xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
326 UBaseType_t MPU_uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
327 TaskHandle_t MPU_xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION;
328 QueueSetMemberHandle_t MPU_xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
329 
330 /* MPU versions of timers.h API functions. */
331 void * MPU_pvTimerGetTimerID( const TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL;
332 void MPU_vTimerSetTimerID( TimerHandle_t xTimer,
333                            void * pvNewID ) FREERTOS_SYSTEM_CALL;
334 BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL;
335 TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void ) FREERTOS_SYSTEM_CALL;
336 BaseType_t MPU_xTimerGenericCommandFromTask( TimerHandle_t xTimer,
337                                              const BaseType_t xCommandID,
338                                              const TickType_t xOptionalValue,
339                                              BaseType_t * const pxHigherPriorityTaskWoken,
340                                              const TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
341 BaseType_t MPU_xTimerGenericCommandFromTaskEntry( const xTimerGenericCommandFromTaskParams_t * pxParams ) FREERTOS_SYSTEM_CALL;
342 const char * MPU_pcTimerGetName( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL;
343 void MPU_vTimerSetReloadMode( TimerHandle_t xTimer,
344                               const BaseType_t xAutoReload ) FREERTOS_SYSTEM_CALL;
345 BaseType_t MPU_xTimerGetReloadMode( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL;
346 UBaseType_t MPU_uxTimerGetReloadMode( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL;
347 TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL;
348 TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer ) FREERTOS_SYSTEM_CALL;
349 
350 /* Privileged only wrappers for Timer APIs. These are needed so that
351  * the application can use opaque handles maintained in mpu_wrappers.c
352  * with all the APIs. */
353 TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName,
354                                 const TickType_t xTimerPeriodInTicks,
355                                 const BaseType_t xAutoReload,
356                                 void * const pvTimerID,
357                                 TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION;
358 TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName,
359                                       const TickType_t xTimerPeriodInTicks,
360                                       const BaseType_t xAutoReload,
361                                       void * const pvTimerID,
362                                       TimerCallbackFunction_t pxCallbackFunction,
363                                       StaticTimer_t * pxTimerBuffer ) PRIVILEGED_FUNCTION;
364 BaseType_t MPU_xTimerGetStaticBuffer( TimerHandle_t xTimer,
365                                       StaticTimer_t ** ppxTimerBuffer ) PRIVILEGED_FUNCTION;
366 BaseType_t MPU_xTimerGenericCommandFromISR( TimerHandle_t xTimer,
367                                             const BaseType_t xCommandID,
368                                             const TickType_t xOptionalValue,
369                                             BaseType_t * const pxHigherPriorityTaskWoken,
370                                             const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
371 
372 /* MPU versions of event_group.h API functions. */
373 EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
374                                      const EventBits_t uxBitsToWaitFor,
375                                      const BaseType_t xClearOnExit,
376                                      const BaseType_t xWaitForAllBits,
377                                      TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
378 EventBits_t MPU_xEventGroupWaitBitsEntry( const xEventGroupWaitBitsParams_t * pxParams ) FREERTOS_SYSTEM_CALL;
379 EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup,
380                                       const EventBits_t uxBitsToClear ) FREERTOS_SYSTEM_CALL;
381 EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup,
382                                     const EventBits_t uxBitsToSet ) FREERTOS_SYSTEM_CALL;
383 EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup,
384                                  const EventBits_t uxBitsToSet,
385                                  const EventBits_t uxBitsToWaitFor,
386                                  TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
387 #if ( configUSE_TRACE_FACILITY == 1 )
388     UBaseType_t MPU_uxEventGroupGetNumber( void * xEventGroup ) FREERTOS_SYSTEM_CALL;
389     void MPU_vEventGroupSetNumber( void * xEventGroup,
390                                    UBaseType_t uxEventGroupNumber ) FREERTOS_SYSTEM_CALL;
391 #endif /* #if ( configUSE_TRACE_FACILITY == 1 ) */
392 
393 /* Privileged only wrappers for Event Group APIs. These are needed so that
394  * the application can use opaque handles maintained in mpu_wrappers.c
395  * with all the APIs. */
396 #if ( configUSE_MPU_WRAPPERS_V1 == 1 )
397 
398     EventGroupHandle_t MPU_xEventGroupCreate( void ) FREERTOS_SYSTEM_CALL;
399     EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) FREERTOS_SYSTEM_CALL;
400     void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) FREERTOS_SYSTEM_CALL;
401 
402 #else /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
403 
404     EventGroupHandle_t MPU_xEventGroupCreate( void ) PRIVILEGED_FUNCTION;
405     EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) PRIVILEGED_FUNCTION;
406     void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;
407 
408 #endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
409 
410 BaseType_t MPU_xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup,
411                                            StaticEventGroup_t ** ppxEventGroupBuffer ) PRIVILEGED_FUNCTION;
412 EventBits_t MPU_xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;
413 
414 #if ( configUSE_MPU_WRAPPERS_V1 == 0 )
415     BaseType_t MPU_xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup,
416                                                 const EventBits_t uxBitsToClear ) FREERTOS_SYSTEM_CALL;
417     BaseType_t MPU_xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup,
418                                               const EventBits_t uxBitsToSet,
419                                               BaseType_t * pxHigherPriorityTaskWoken ) FREERTOS_SYSTEM_CALL;
420 #endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 0 ) */
421 
422 /* MPU versions of message/stream_buffer.h API functions. */
423 size_t MPU_xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
424                               const void * pvTxData,
425                               size_t xDataLengthBytes,
426                               TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
427 size_t MPU_xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer,
428                                  void * pvRxData,
429                                  size_t xBufferLengthBytes,
430                                  TickType_t xTicksToWait ) FREERTOS_SYSTEM_CALL;
431 BaseType_t MPU_xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL;
432 BaseType_t MPU_xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL;
433 size_t MPU_xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL;
434 size_t MPU_xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL;
435 BaseType_t MPU_xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer,
436                                              size_t xTriggerLevel ) FREERTOS_SYSTEM_CALL;
437 size_t MPU_xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL;
438 
439 /* Privileged only wrappers for Stream Buffer APIs. These are needed so that
440  * the application can use opaque handles maintained in mpu_wrappers.c
441  * with all the APIs. */
442 #if ( configUSE_MPU_WRAPPERS_V1 == 1 )
443 
444     StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes,
445                                                          size_t xTriggerLevelBytes,
446                                                          BaseType_t xStreamBufferType,
447                                                          StreamBufferCallbackFunction_t pxSendCompletedCallback,
448                                                          StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) FREERTOS_SYSTEM_CALL;
449     StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
450                                                                size_t xTriggerLevelBytes,
451                                                                BaseType_t xStreamBufferType,
452                                                                uint8_t * const pucStreamBufferStorageArea,
453                                                                StaticStreamBuffer_t * const pxStaticStreamBuffer,
454                                                                StreamBufferCallbackFunction_t pxSendCompletedCallback,
455                                                                StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) FREERTOS_SYSTEM_CALL;
456     void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL;
457     BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) FREERTOS_SYSTEM_CALL;
458 
459 #else /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
460 
461     StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes,
462                                                          size_t xTriggerLevelBytes,
463                                                          BaseType_t xStreamBufferType,
464                                                          StreamBufferCallbackFunction_t pxSendCompletedCallback,
465                                                          StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) PRIVILEGED_FUNCTION;
466     StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
467                                                                size_t xTriggerLevelBytes,
468                                                                BaseType_t xStreamBufferType,
469                                                                uint8_t * const pucStreamBufferStorageArea,
470                                                                StaticStreamBuffer_t * const pxStaticStreamBuffer,
471                                                                StreamBufferCallbackFunction_t pxSendCompletedCallback,
472                                                                StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) PRIVILEGED_FUNCTION;
473     void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
474     BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
475 
476 #endif /* #if ( configUSE_MPU_WRAPPERS_V1 == 1 ) */
477 
478 BaseType_t MPU_xStreamBufferGetStaticBuffers( StreamBufferHandle_t xStreamBuffers,
479                                               uint8_t * ppucStreamBufferStorageArea,
480                                               StaticStreamBuffer_t * ppxStaticStreamBuffer ) PRIVILEGED_FUNCTION;
481 size_t MPU_xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer,
482                                      const void * pvTxData,
483                                      size_t xDataLengthBytes,
484                                      BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
485 size_t MPU_xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer,
486                                         void * pvRxData,
487                                         size_t xBufferLengthBytes,
488                                         BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
489 BaseType_t MPU_xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer,
490                                                   BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
491 BaseType_t MPU_xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer,
492                                                      BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
493 BaseType_t MPU_xStreamBufferResetFromISR( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
494 
495 #endif /* MPU_PROTOTYPES_H */
496