]> begriffs open source - cmsis-freertos/blob - Source/portable/Common/mpu_wrappers.c
Updated pack to FreeRTOS 10.4.4
[cmsis-freertos] / Source / portable / Common / mpu_wrappers.c
1 /*
2  * FreeRTOS Kernel V10.4.4
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  * Implementation of the wrapper functions used to raise the processor privilege
31  * before calling a standard FreeRTOS API function.
32  */
33
34 /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
35  * all the API functions to use the MPU wrappers.  That should only be done when
36  * task.h is included from an application file. */
37 #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
38
39 /* Scheduler includes. */
40 #include "FreeRTOS.h"
41 #include "task.h"
42 #include "queue.h"
43 #include "timers.h"
44 #include "event_groups.h"
45 #include "stream_buffer.h"
46 #include "mpu_prototypes.h"
47
48 #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
49
50 /**
51  * @brief Calls the port specific code to raise the privilege.
52  *
53  * @return pdFALSE if privilege was raised, pdTRUE otherwise.
54  */
55 BaseType_t xPortRaisePrivilege( void ) FREERTOS_SYSTEM_CALL;
56
57 /**
58  * @brief If xRunningPrivileged is not pdTRUE, calls the port specific
59  * code to reset the privilege, otherwise does nothing.
60  */
61 void vPortResetPrivilege( BaseType_t xRunningPrivileged );
62 /*-----------------------------------------------------------*/
63
64 BaseType_t xPortRaisePrivilege( void ) /* FREERTOS_SYSTEM_CALL */
65 {
66     BaseType_t xRunningPrivileged;
67
68     /* Check whether the processor is already privileged. */
69     xRunningPrivileged = portIS_PRIVILEGED();
70
71     /* If the processor is not already privileged, raise privilege. */
72     if( xRunningPrivileged == pdFALSE )
73     {
74         portRAISE_PRIVILEGE();
75     }
76
77     return xRunningPrivileged;
78 }
79 /*-----------------------------------------------------------*/
80
81 void vPortResetPrivilege( BaseType_t xRunningPrivileged )
82 {
83     if( xRunningPrivileged == pdFALSE )
84     {
85         portRESET_PRIVILEGE();
86     }
87 }
88 /*-----------------------------------------------------------*/
89
90 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
91     BaseType_t MPU_xTaskCreate( TaskFunction_t pvTaskCode,
92                                 const char * const pcName,
93                                 uint16_t usStackDepth,
94                                 void * pvParameters,
95                                 UBaseType_t uxPriority,
96                                 TaskHandle_t * pxCreatedTask ) /* FREERTOS_SYSTEM_CALL */
97     {
98         BaseType_t xReturn;
99         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
100
101         xReturn = xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask );
102         vPortResetPrivilege( xRunningPrivileged );
103         return xReturn;
104     }
105 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
106 /*-----------------------------------------------------------*/
107
108 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
109     TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode,
110                                         const char * const pcName,
111                                         const uint32_t ulStackDepth,
112                                         void * const pvParameters,
113                                         UBaseType_t uxPriority,
114                                         StackType_t * const puxStackBuffer,
115                                         StaticTask_t * const pxTaskBuffer ) /* FREERTOS_SYSTEM_CALL */
116     {
117         TaskHandle_t xReturn;
118         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
119
120         xReturn = xTaskCreateStatic( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer );
121         vPortResetPrivilege( xRunningPrivileged );
122         return xReturn;
123     }
124 #endif /* configSUPPORT_STATIC_ALLOCATION */
125 /*-----------------------------------------------------------*/
126
127 #if ( INCLUDE_vTaskDelete == 1 )
128     void MPU_vTaskDelete( TaskHandle_t pxTaskToDelete ) /* FREERTOS_SYSTEM_CALL */
129     {
130         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
131
132         vTaskDelete( pxTaskToDelete );
133         vPortResetPrivilege( xRunningPrivileged );
134     }
135 #endif
136 /*-----------------------------------------------------------*/
137
138 #if ( INCLUDE_xTaskDelayUntil == 1 )
139     BaseType_t MPU_xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
140                                     TickType_t xTimeIncrement ) /* FREERTOS_SYSTEM_CALL */
141     {
142         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
143         BaseType_t xReturn;
144
145         xReturn = xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement );
146         vPortResetPrivilege( xRunningPrivileged );
147         return xReturn;
148     }
149 #endif
150 /*-----------------------------------------------------------*/
151
152 #if ( INCLUDE_xTaskAbortDelay == 1 )
153     BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */
154     {
155         BaseType_t xReturn;
156         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
157
158         xReturn = xTaskAbortDelay( xTask );
159         vPortResetPrivilege( xRunningPrivileged );
160         return xReturn;
161     }
162 #endif
163 /*-----------------------------------------------------------*/
164
165 #if ( INCLUDE_vTaskDelay == 1 )
166     void MPU_vTaskDelay( TickType_t xTicksToDelay ) /* FREERTOS_SYSTEM_CALL */
167     {
168         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
169
170         vTaskDelay( xTicksToDelay );
171         vPortResetPrivilege( xRunningPrivileged );
172     }
173 #endif
174 /*-----------------------------------------------------------*/
175
176 #if ( INCLUDE_uxTaskPriorityGet == 1 )
177     UBaseType_t MPU_uxTaskPriorityGet( const TaskHandle_t pxTask ) /* FREERTOS_SYSTEM_CALL */
178     {
179         UBaseType_t uxReturn;
180         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
181
182         uxReturn = uxTaskPriorityGet( pxTask );
183         vPortResetPrivilege( xRunningPrivileged );
184         return uxReturn;
185     }
186 #endif
187 /*-----------------------------------------------------------*/
188
189 #if ( INCLUDE_vTaskPrioritySet == 1 )
190     void MPU_vTaskPrioritySet( TaskHandle_t pxTask,
191                                UBaseType_t uxNewPriority ) /* FREERTOS_SYSTEM_CALL */
192     {
193         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
194
195         vTaskPrioritySet( pxTask, uxNewPriority );
196         vPortResetPrivilege( xRunningPrivileged );
197     }
198 #endif
199 /*-----------------------------------------------------------*/
200
201 #if ( INCLUDE_eTaskGetState == 1 )
202     eTaskState MPU_eTaskGetState( TaskHandle_t pxTask ) /* FREERTOS_SYSTEM_CALL */
203     {
204         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
205         eTaskState eReturn;
206
207         eReturn = eTaskGetState( pxTask );
208         vPortResetPrivilege( xRunningPrivileged );
209         return eReturn;
210     }
211 #endif
212 /*-----------------------------------------------------------*/
213
214 #if ( configUSE_TRACE_FACILITY == 1 )
215     void MPU_vTaskGetInfo( TaskHandle_t xTask,
216                            TaskStatus_t * pxTaskStatus,
217                            BaseType_t xGetFreeStackSpace,
218                            eTaskState eState ) /* FREERTOS_SYSTEM_CALL */
219     {
220         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
221
222         vTaskGetInfo( xTask, pxTaskStatus, xGetFreeStackSpace, eState );
223         vPortResetPrivilege( xRunningPrivileged );
224     }
225 #endif /* if ( configUSE_TRACE_FACILITY == 1 ) */
226 /*-----------------------------------------------------------*/
227
228 #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
229     TaskHandle_t MPU_xTaskGetIdleTaskHandle( void ) /* FREERTOS_SYSTEM_CALL */
230     {
231         TaskHandle_t xReturn;
232         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
233
234         xReturn = xTaskGetIdleTaskHandle();
235         vPortResetPrivilege( xRunningPrivileged );
236         return xReturn;
237     }
238 #endif
239 /*-----------------------------------------------------------*/
240
241 #if ( INCLUDE_vTaskSuspend == 1 )
242     void MPU_vTaskSuspend( TaskHandle_t pxTaskToSuspend ) /* FREERTOS_SYSTEM_CALL */
243     {
244         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
245
246         vTaskSuspend( pxTaskToSuspend );
247         vPortResetPrivilege( xRunningPrivileged );
248     }
249 #endif
250 /*-----------------------------------------------------------*/
251
252 #if ( INCLUDE_vTaskSuspend == 1 )
253     void MPU_vTaskResume( TaskHandle_t pxTaskToResume ) /* FREERTOS_SYSTEM_CALL */
254     {
255         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
256
257         vTaskResume( pxTaskToResume );
258         vPortResetPrivilege( xRunningPrivileged );
259     }
260 #endif
261 /*-----------------------------------------------------------*/
262
263 void MPU_vTaskSuspendAll( void ) /* FREERTOS_SYSTEM_CALL */
264 {
265     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
266
267     vTaskSuspendAll();
268     vPortResetPrivilege( xRunningPrivileged );
269 }
270 /*-----------------------------------------------------------*/
271
272 BaseType_t MPU_xTaskResumeAll( void ) /* FREERTOS_SYSTEM_CALL */
273 {
274     BaseType_t xReturn;
275     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
276
277     xReturn = xTaskResumeAll();
278     vPortResetPrivilege( xRunningPrivileged );
279     return xReturn;
280 }
281 /*-----------------------------------------------------------*/
282
283 TickType_t MPU_xTaskGetTickCount( void ) /* FREERTOS_SYSTEM_CALL */
284 {
285     TickType_t xReturn;
286     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
287
288     xReturn = xTaskGetTickCount();
289     vPortResetPrivilege( xRunningPrivileged );
290     return xReturn;
291 }
292 /*-----------------------------------------------------------*/
293
294 UBaseType_t MPU_uxTaskGetNumberOfTasks( void ) /* FREERTOS_SYSTEM_CALL */
295 {
296     UBaseType_t uxReturn;
297     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
298
299     uxReturn = uxTaskGetNumberOfTasks();
300     vPortResetPrivilege( xRunningPrivileged );
301     return uxReturn;
302 }
303 /*-----------------------------------------------------------*/
304
305 char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) /* FREERTOS_SYSTEM_CALL */
306 {
307     char * pcReturn;
308     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
309
310     pcReturn = pcTaskGetName( xTaskToQuery );
311     vPortResetPrivilege( xRunningPrivileged );
312     return pcReturn;
313 }
314 /*-----------------------------------------------------------*/
315
316 #if ( INCLUDE_xTaskGetHandle == 1 )
317     TaskHandle_t MPU_xTaskGetHandle( const char * pcNameToQuery ) /* FREERTOS_SYSTEM_CALL */
318     {
319         TaskHandle_t xReturn;
320         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
321
322         xReturn = xTaskGetHandle( pcNameToQuery );
323         vPortResetPrivilege( xRunningPrivileged );
324         return xReturn;
325     }
326 #endif
327 /*-----------------------------------------------------------*/
328
329 #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
330     void MPU_vTaskList( char * pcWriteBuffer ) /* FREERTOS_SYSTEM_CALL */
331     {
332         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
333
334         vTaskList( pcWriteBuffer );
335         vPortResetPrivilege( xRunningPrivileged );
336     }
337 #endif
338 /*-----------------------------------------------------------*/
339
340 #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
341     void MPU_vTaskGetRunTimeStats( char * pcWriteBuffer ) /* FREERTOS_SYSTEM_CALL */
342     {
343         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
344
345         vTaskGetRunTimeStats( pcWriteBuffer );
346         vPortResetPrivilege( xRunningPrivileged );
347     }
348 #endif
349 /*-----------------------------------------------------------*/
350
351 #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) )
352     uint32_t MPU_ulTaskGetIdleRunTimeCounter( void ) /* FREERTOS_SYSTEM_CALL */
353     {
354         uint32_t xReturn;
355         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
356
357         xReturn = ulTaskGetIdleRunTimeCounter();
358         vPortResetPrivilege( xRunningPrivileged );
359         return xReturn;
360     }
361 #endif
362 /*-----------------------------------------------------------*/
363
364 #if ( configUSE_APPLICATION_TASK_TAG == 1 )
365     void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask,
366                                          TaskHookFunction_t pxTagValue ) /* FREERTOS_SYSTEM_CALL */
367     {
368         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
369
370         vTaskSetApplicationTaskTag( xTask, pxTagValue );
371         vPortResetPrivilege( xRunningPrivileged );
372     }
373 #endif
374 /*-----------------------------------------------------------*/
375
376 #if ( configUSE_APPLICATION_TASK_TAG == 1 )
377     TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */
378     {
379         TaskHookFunction_t xReturn;
380         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
381
382         xReturn = xTaskGetApplicationTaskTag( xTask );
383         vPortResetPrivilege( xRunningPrivileged );
384         return xReturn;
385     }
386 #endif
387 /*-----------------------------------------------------------*/
388
389 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
390     void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet,
391                                                 BaseType_t xIndex,
392                                                 void * pvValue ) /* FREERTOS_SYSTEM_CALL */
393     {
394         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
395
396         vTaskSetThreadLocalStoragePointer( xTaskToSet, xIndex, pvValue );
397         vPortResetPrivilege( xRunningPrivileged );
398     }
399 #endif
400 /*-----------------------------------------------------------*/
401
402 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
403     void * MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery,
404                                                    BaseType_t xIndex ) /* FREERTOS_SYSTEM_CALL */
405     {
406         void * pvReturn;
407         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
408
409         pvReturn = pvTaskGetThreadLocalStoragePointer( xTaskToQuery, xIndex );
410         vPortResetPrivilege( xRunningPrivileged );
411         return pvReturn;
412     }
413 #endif /* if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) */
414 /*-----------------------------------------------------------*/
415
416 #if ( configUSE_APPLICATION_TASK_TAG == 1 )
417     BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask,
418                                                  void * pvParameter ) /* FREERTOS_SYSTEM_CALL */
419     {
420         BaseType_t xReturn;
421         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
422
423         xReturn = xTaskCallApplicationTaskHook( xTask, pvParameter );
424         vPortResetPrivilege( xRunningPrivileged );
425         return xReturn;
426     }
427 #endif /* if ( configUSE_APPLICATION_TASK_TAG == 1 ) */
428 /*-----------------------------------------------------------*/
429
430 #if ( configUSE_TRACE_FACILITY == 1 )
431     UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t * pxTaskStatusArray,
432                                           UBaseType_t uxArraySize,
433                                           uint32_t * pulTotalRunTime ) /* FREERTOS_SYSTEM_CALL */
434     {
435         UBaseType_t uxReturn;
436         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
437
438         uxReturn = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, pulTotalRunTime );
439         vPortResetPrivilege( xRunningPrivileged );
440         return uxReturn;
441     }
442 #endif /* if ( configUSE_TRACE_FACILITY == 1 ) */
443 /*-----------------------------------------------------------*/
444
445 BaseType_t MPU_xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) /* FREERTOS_SYSTEM_CALL */
446 {
447     BaseType_t xReturn;
448     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
449
450     xReturn = xTaskCatchUpTicks( xTicksToCatchUp );
451     vPortResetPrivilege( xRunningPrivileged );
452     return xReturn;
453 }
454 /*-----------------------------------------------------------*/
455
456 #if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )
457     UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */
458     {
459         UBaseType_t uxReturn;
460         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
461
462         uxReturn = uxTaskGetStackHighWaterMark( xTask );
463         vPortResetPrivilege( xRunningPrivileged );
464         return uxReturn;
465     }
466 #endif
467 /*-----------------------------------------------------------*/
468
469 #if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 )
470     configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */
471     {
472         configSTACK_DEPTH_TYPE uxReturn;
473         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
474
475         uxReturn = uxTaskGetStackHighWaterMark2( xTask );
476         vPortResetPrivilege( xRunningPrivileged );
477         return uxReturn;
478     }
479 #endif
480 /*-----------------------------------------------------------*/
481
482 #if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ))
483     TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ) /* FREERTOS_SYSTEM_CALL */
484     {
485         TaskHandle_t xReturn;
486         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
487
488         xReturn = xTaskGetCurrentTaskHandle();
489         vPortResetPrivilege( xRunningPrivileged );
490         return xReturn;
491     }
492 #endif
493 /*-----------------------------------------------------------*/
494
495 #if ( INCLUDE_xTaskGetSchedulerState == 1 )
496     BaseType_t MPU_xTaskGetSchedulerState( void ) /* FREERTOS_SYSTEM_CALL */
497     {
498         BaseType_t xReturn;
499         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
500
501         xReturn = xTaskGetSchedulerState();
502         vPortResetPrivilege( xRunningPrivileged );
503         return xReturn;
504     }
505 #endif
506 /*-----------------------------------------------------------*/
507
508 void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) /* FREERTOS_SYSTEM_CALL */
509 {
510     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
511
512     vTaskSetTimeOutState( pxTimeOut );
513     vPortResetPrivilege( xRunningPrivileged );
514 }
515 /*-----------------------------------------------------------*/
516
517 BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut,
518                                      TickType_t * const pxTicksToWait ) /* FREERTOS_SYSTEM_CALL */
519 {
520     BaseType_t xReturn;
521     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
522
523     xReturn = xTaskCheckForTimeOut( pxTimeOut, pxTicksToWait );
524     vPortResetPrivilege( xRunningPrivileged );
525     return xReturn;
526 }
527 /*-----------------------------------------------------------*/
528
529 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
530     BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify,
531                                        UBaseType_t uxIndexToNotify,
532                                        uint32_t ulValue,
533                                        eNotifyAction eAction,
534                                        uint32_t * pulPreviousNotificationValue ) /* FREERTOS_SYSTEM_CALL */
535     {
536         BaseType_t xReturn;
537         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
538
539         xReturn = xTaskGenericNotify( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue );
540         vPortResetPrivilege( xRunningPrivileged );
541         return xReturn;
542     }
543 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
544 /*-----------------------------------------------------------*/
545
546 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
547     BaseType_t MPU_xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn,
548                                            uint32_t ulBitsToClearOnEntry,
549                                            uint32_t ulBitsToClearOnExit,
550                                            uint32_t * pulNotificationValue,
551                                            TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
552     {
553         BaseType_t xReturn;
554         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
555
556         xReturn = xTaskGenericNotifyWait( uxIndexToWaitOn, ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait );
557         vPortResetPrivilege( xRunningPrivileged );
558         return xReturn;
559     }
560 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
561 /*-----------------------------------------------------------*/
562
563 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
564     uint32_t MPU_ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn,
565                                           BaseType_t xClearCountOnExit,
566                                           TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
567     {
568         uint32_t ulReturn;
569         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
570
571         ulReturn = ulTaskGenericNotifyTake( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait );
572         vPortResetPrivilege( xRunningPrivileged );
573         return ulReturn;
574     }
575 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
576 /*-----------------------------------------------------------*/
577
578 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
579     BaseType_t MPU_xTaskGenericNotifyStateClear( TaskHandle_t xTask,
580                                                  UBaseType_t uxIndexToClear ) /* FREERTOS_SYSTEM_CALL */
581     {
582         BaseType_t xReturn;
583         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
584
585         xReturn = xTaskGenericNotifyStateClear( xTask, uxIndexToClear );
586         vPortResetPrivilege( xRunningPrivileged );
587         return xReturn;
588     }
589 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
590 /*-----------------------------------------------------------*/
591
592 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
593     uint32_t MPU_ulTaskGenericNotifyValueClear( TaskHandle_t xTask,
594                                                 UBaseType_t uxIndexToClear,
595                                                 uint32_t ulBitsToClear ) /* FREERTOS_SYSTEM_CALL */
596     {
597         uint32_t ulReturn;
598         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
599
600         ulReturn = ulTaskGenericNotifyValueClear( xTask, uxIndexToClear, ulBitsToClear );
601         vPortResetPrivilege( xRunningPrivileged );
602         return ulReturn;
603     }
604 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
605 /*-----------------------------------------------------------*/
606
607 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
608     QueueHandle_t MPU_xQueueGenericCreate( UBaseType_t uxQueueLength,
609                                            UBaseType_t uxItemSize,
610                                            uint8_t ucQueueType ) /* FREERTOS_SYSTEM_CALL */
611     {
612         QueueHandle_t xReturn;
613         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
614
615         xReturn = xQueueGenericCreate( uxQueueLength, uxItemSize, ucQueueType );
616         vPortResetPrivilege( xRunningPrivileged );
617         return xReturn;
618     }
619 #endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) */
620 /*-----------------------------------------------------------*/
621
622 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
623     QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength,
624                                                  const UBaseType_t uxItemSize,
625                                                  uint8_t * pucQueueStorage,
626                                                  StaticQueue_t * pxStaticQueue,
627                                                  const uint8_t ucQueueType ) /* FREERTOS_SYSTEM_CALL */
628     {
629         QueueHandle_t xReturn;
630         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
631
632         xReturn = xQueueGenericCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxStaticQueue, ucQueueType );
633         vPortResetPrivilege( xRunningPrivileged );
634         return xReturn;
635     }
636 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
637 /*-----------------------------------------------------------*/
638
639 BaseType_t MPU_xQueueGenericReset( QueueHandle_t pxQueue,
640                                    BaseType_t xNewQueue ) /* FREERTOS_SYSTEM_CALL */
641 {
642     BaseType_t xReturn;
643     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
644
645     xReturn = xQueueGenericReset( pxQueue, xNewQueue );
646     vPortResetPrivilege( xRunningPrivileged );
647     return xReturn;
648 }
649 /*-----------------------------------------------------------*/
650
651 BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue,
652                                   const void * const pvItemToQueue,
653                                   TickType_t xTicksToWait,
654                                   BaseType_t xCopyPosition ) /* FREERTOS_SYSTEM_CALL */
655 {
656     BaseType_t xReturn;
657     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
658
659     xReturn = xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, xCopyPosition );
660     vPortResetPrivilege( xRunningPrivileged );
661     return xReturn;
662 }
663 /*-----------------------------------------------------------*/
664
665 UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t pxQueue ) /* FREERTOS_SYSTEM_CALL */
666 {
667     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
668     UBaseType_t uxReturn;
669
670     uxReturn = uxQueueMessagesWaiting( pxQueue );
671     vPortResetPrivilege( xRunningPrivileged );
672     return uxReturn;
673 }
674 /*-----------------------------------------------------------*/
675
676 UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */
677 {
678     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
679     UBaseType_t uxReturn;
680
681     uxReturn = uxQueueSpacesAvailable( xQueue );
682     vPortResetPrivilege( xRunningPrivileged );
683     return uxReturn;
684 }
685 /*-----------------------------------------------------------*/
686
687 BaseType_t MPU_xQueueReceive( QueueHandle_t pxQueue,
688                               void * const pvBuffer,
689                               TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
690 {
691     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
692     BaseType_t xReturn;
693
694     xReturn = xQueueReceive( pxQueue, pvBuffer, xTicksToWait );
695     vPortResetPrivilege( xRunningPrivileged );
696     return xReturn;
697 }
698 /*-----------------------------------------------------------*/
699
700 BaseType_t MPU_xQueuePeek( QueueHandle_t xQueue,
701                            void * const pvBuffer,
702                            TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
703 {
704     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
705     BaseType_t xReturn;
706
707     xReturn = xQueuePeek( xQueue, pvBuffer, xTicksToWait );
708     vPortResetPrivilege( xRunningPrivileged );
709     return xReturn;
710 }
711 /*-----------------------------------------------------------*/
712
713 BaseType_t MPU_xQueueSemaphoreTake( QueueHandle_t xQueue,
714                                     TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
715 {
716     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
717     BaseType_t xReturn;
718
719     xReturn = xQueueSemaphoreTake( xQueue, xTicksToWait );
720     vPortResetPrivilege( xRunningPrivileged );
721     return xReturn;
722 }
723 /*-----------------------------------------------------------*/
724
725 #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )
726     TaskHandle_t MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ) /* FREERTOS_SYSTEM_CALL */
727     {
728         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
729         void * xReturn;
730
731         xReturn = xQueueGetMutexHolder( xSemaphore );
732         vPortResetPrivilege( xRunningPrivileged );
733         return xReturn;
734     }
735 #endif
736 /*-----------------------------------------------------------*/
737
738 #if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
739     QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) /* FREERTOS_SYSTEM_CALL */
740     {
741         QueueHandle_t xReturn;
742         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
743
744         xReturn = xQueueCreateMutex( ucQueueType );
745         vPortResetPrivilege( xRunningPrivileged );
746         return xReturn;
747     }
748 #endif
749 /*-----------------------------------------------------------*/
750
751 #if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
752     QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType,
753                                                StaticQueue_t * pxStaticQueue ) /* FREERTOS_SYSTEM_CALL */
754     {
755         QueueHandle_t xReturn;
756         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
757
758         xReturn = xQueueCreateMutexStatic( ucQueueType, pxStaticQueue );
759         vPortResetPrivilege( xRunningPrivileged );
760         return xReturn;
761     }
762 #endif /* if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) */
763 /*-----------------------------------------------------------*/
764
765 #if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
766     QueueHandle_t MPU_xQueueCreateCountingSemaphore( UBaseType_t uxCountValue,
767                                                      UBaseType_t uxInitialCount ) /* FREERTOS_SYSTEM_CALL */
768     {
769         QueueHandle_t xReturn;
770         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
771
772         xReturn = xQueueCreateCountingSemaphore( uxCountValue, uxInitialCount );
773         vPortResetPrivilege( xRunningPrivileged );
774         return xReturn;
775     }
776 #endif /* if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */
777 /*-----------------------------------------------------------*/
778
779 #if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
780
781     QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
782                                                            const UBaseType_t uxInitialCount,
783                                                            StaticQueue_t * pxStaticQueue ) /* FREERTOS_SYSTEM_CALL */
784     {
785         QueueHandle_t xReturn;
786         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
787
788         xReturn = xQueueCreateCountingSemaphoreStatic( uxMaxCount, uxInitialCount, pxStaticQueue );
789         vPortResetPrivilege( xRunningPrivileged );
790         return xReturn;
791     }
792 #endif /* if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) */
793 /*-----------------------------------------------------------*/
794
795 #if ( configUSE_RECURSIVE_MUTEXES == 1 )
796     BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex,
797                                              TickType_t xBlockTime ) /* FREERTOS_SYSTEM_CALL */
798     {
799         BaseType_t xReturn;
800         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
801
802         xReturn = xQueueTakeMutexRecursive( xMutex, xBlockTime );
803         vPortResetPrivilege( xRunningPrivileged );
804         return xReturn;
805     }
806 #endif /* if ( configUSE_RECURSIVE_MUTEXES == 1 ) */
807 /*-----------------------------------------------------------*/
808
809 #if ( configUSE_RECURSIVE_MUTEXES == 1 )
810     BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t xMutex ) /* FREERTOS_SYSTEM_CALL */
811     {
812         BaseType_t xReturn;
813         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
814
815         xReturn = xQueueGiveMutexRecursive( xMutex );
816         vPortResetPrivilege( xRunningPrivileged );
817         return xReturn;
818     }
819 #endif
820 /*-----------------------------------------------------------*/
821
822 #if ( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
823     QueueSetHandle_t MPU_xQueueCreateSet( UBaseType_t uxEventQueueLength ) /* FREERTOS_SYSTEM_CALL */
824     {
825         QueueSetHandle_t xReturn;
826         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
827
828         xReturn = xQueueCreateSet( uxEventQueueLength );
829         vPortResetPrivilege( xRunningPrivileged );
830         return xReturn;
831     }
832 #endif
833 /*-----------------------------------------------------------*/
834
835 #if ( configUSE_QUEUE_SETS == 1 )
836     QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet,
837                                                     TickType_t xBlockTimeTicks ) /* FREERTOS_SYSTEM_CALL */
838     {
839         QueueSetMemberHandle_t xReturn;
840         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
841
842         xReturn = xQueueSelectFromSet( xQueueSet, xBlockTimeTicks );
843         vPortResetPrivilege( xRunningPrivileged );
844         return xReturn;
845     }
846 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */
847 /*-----------------------------------------------------------*/
848
849 #if ( configUSE_QUEUE_SETS == 1 )
850     BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore,
851                                    QueueSetHandle_t xQueueSet ) /* FREERTOS_SYSTEM_CALL */
852     {
853         BaseType_t xReturn;
854         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
855
856         xReturn = xQueueAddToSet( xQueueOrSemaphore, xQueueSet );
857         vPortResetPrivilege( xRunningPrivileged );
858         return xReturn;
859     }
860 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */
861 /*-----------------------------------------------------------*/
862
863 #if ( configUSE_QUEUE_SETS == 1 )
864     BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
865                                         QueueSetHandle_t xQueueSet ) /* FREERTOS_SYSTEM_CALL */
866     {
867         BaseType_t xReturn;
868         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
869
870         xReturn = xQueueRemoveFromSet( xQueueOrSemaphore, xQueueSet );
871         vPortResetPrivilege( xRunningPrivileged );
872         return xReturn;
873     }
874 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */
875 /*-----------------------------------------------------------*/
876
877 #if configQUEUE_REGISTRY_SIZE > 0
878     void MPU_vQueueAddToRegistry( QueueHandle_t xQueue,
879                                   const char * pcName ) /* FREERTOS_SYSTEM_CALL */
880     {
881         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
882
883         vQueueAddToRegistry( xQueue, pcName );
884
885         vPortResetPrivilege( xRunningPrivileged );
886     }
887 #endif
888 /*-----------------------------------------------------------*/
889
890 #if configQUEUE_REGISTRY_SIZE > 0
891     void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */
892     {
893         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
894
895         vQueueUnregisterQueue( xQueue );
896
897         vPortResetPrivilege( xRunningPrivileged );
898     }
899 #endif
900 /*-----------------------------------------------------------*/
901
902 #if configQUEUE_REGISTRY_SIZE > 0
903     const char * MPU_pcQueueGetName( QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */
904     {
905         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
906         const char * pcReturn;
907
908         pcReturn = pcQueueGetName( xQueue );
909
910         vPortResetPrivilege( xRunningPrivileged );
911         return pcReturn;
912     }
913 #endif /* if configQUEUE_REGISTRY_SIZE > 0 */
914 /*-----------------------------------------------------------*/
915
916 void MPU_vQueueDelete( QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */
917 {
918     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
919
920     vQueueDelete( xQueue );
921
922     vPortResetPrivilege( xRunningPrivileged );
923 }
924 /*-----------------------------------------------------------*/
925
926 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
927     void MPU_vPortInitialiseBlocks( void ) /* FREERTOS_SYSTEM_CALL */
928     {
929         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
930
931         vPortInitialiseBlocks();
932
933         vPortResetPrivilege( xRunningPrivileged );
934     }
935 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
936 /*-----------------------------------------------------------*/
937
938 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
939     size_t MPU_xPortGetFreeHeapSize( void ) /* FREERTOS_SYSTEM_CALL */
940     {
941         size_t xReturn;
942         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
943
944         xReturn = xPortGetFreeHeapSize();
945
946         vPortResetPrivilege( xRunningPrivileged );
947
948         return xReturn;
949     }
950 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
951 /*-----------------------------------------------------------*/
952
953 #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) )
954     TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName,
955                                     const TickType_t xTimerPeriodInTicks,
956                                     const UBaseType_t uxAutoReload,
957                                     void * const pvTimerID,
958                                     TimerCallbackFunction_t pxCallbackFunction ) /* FREERTOS_SYSTEM_CALL */
959     {
960         TimerHandle_t xReturn;
961         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
962
963         xReturn = xTimerCreate( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction );
964         vPortResetPrivilege( xRunningPrivileged );
965
966         return xReturn;
967     }
968 #endif /* if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) ) */
969 /*-----------------------------------------------------------*/
970
971 #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) )
972     TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName,
973                                           const TickType_t xTimerPeriodInTicks,
974                                           const UBaseType_t uxAutoReload,
975                                           void * const pvTimerID,
976                                           TimerCallbackFunction_t pxCallbackFunction,
977                                           StaticTimer_t * pxTimerBuffer ) /* FREERTOS_SYSTEM_CALL */
978     {
979         TimerHandle_t xReturn;
980         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
981
982         xReturn = xTimerCreateStatic( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction, pxTimerBuffer );
983         vPortResetPrivilege( xRunningPrivileged );
984
985         return xReturn;
986     }
987 #endif /* if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) ) */
988 /*-----------------------------------------------------------*/
989
990 #if ( configUSE_TIMERS == 1 )
991     void * MPU_pvTimerGetTimerID( const TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */
992     {
993         void * pvReturn;
994         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
995
996         pvReturn = pvTimerGetTimerID( xTimer );
997         vPortResetPrivilege( xRunningPrivileged );
998
999         return pvReturn;
1000     }
1001 #endif /* if ( configUSE_TIMERS == 1 ) */
1002 /*-----------------------------------------------------------*/
1003
1004 #if ( configUSE_TIMERS == 1 )
1005     void MPU_vTimerSetTimerID( TimerHandle_t xTimer,
1006                                void * pvNewID ) /* FREERTOS_SYSTEM_CALL */
1007     {
1008         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1009
1010         vTimerSetTimerID( xTimer, pvNewID );
1011         vPortResetPrivilege( xRunningPrivileged );
1012     }
1013 #endif
1014 /*-----------------------------------------------------------*/
1015
1016 #if ( configUSE_TIMERS == 1 )
1017     BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */
1018     {
1019         BaseType_t xReturn;
1020         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1021
1022         xReturn = xTimerIsTimerActive( xTimer );
1023         vPortResetPrivilege( xRunningPrivileged );
1024
1025         return xReturn;
1026     }
1027 #endif /* if ( configUSE_TIMERS == 1 ) */
1028 /*-----------------------------------------------------------*/
1029
1030 #if ( configUSE_TIMERS == 1 )
1031     TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void ) /* FREERTOS_SYSTEM_CALL */
1032     {
1033         TaskHandle_t xReturn;
1034         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1035
1036         xReturn = xTimerGetTimerDaemonTaskHandle();
1037         vPortResetPrivilege( xRunningPrivileged );
1038
1039         return xReturn;
1040     }
1041 #endif /* if ( configUSE_TIMERS == 1 ) */
1042 /*-----------------------------------------------------------*/
1043
1044 #if ( ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )
1045     BaseType_t MPU_xTimerPendFunctionCall( PendedFunction_t xFunctionToPend,
1046                                            void * pvParameter1,
1047                                            uint32_t ulParameter2,
1048                                            TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
1049     {
1050         BaseType_t xReturn;
1051         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1052
1053         xReturn = xTimerPendFunctionCall( xFunctionToPend, pvParameter1, ulParameter2, xTicksToWait );
1054         vPortResetPrivilege( xRunningPrivileged );
1055
1056         return xReturn;
1057     }
1058 #endif /* if ( ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) ) */
1059 /*-----------------------------------------------------------*/
1060
1061 #if ( configUSE_TIMERS == 1 )
1062     void MPU_vTimerSetReloadMode( TimerHandle_t xTimer,
1063                                   const UBaseType_t uxAutoReload ) /* FREERTOS_SYSTEM_CALL */
1064     {
1065         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1066
1067         vTimerSetReloadMode( xTimer, uxAutoReload );
1068         vPortResetPrivilege( xRunningPrivileged );
1069     }
1070 #endif
1071 /*-----------------------------------------------------------*/
1072
1073 #if ( configUSE_TIMERS == 1 )
1074     UBaseType_t MPU_uxTimerGetReloadMode( TimerHandle_t xTimer )
1075     {
1076         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1077         UBaseType_t uxReturn;
1078
1079         uxReturn = uxTimerGetReloadMode( xTimer );
1080         vPortResetPrivilege( xRunningPrivileged );
1081         return uxReturn;
1082     }
1083 #endif
1084 /*-----------------------------------------------------------*/
1085
1086 #if ( configUSE_TIMERS == 1 )
1087     const char * MPU_pcTimerGetName( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */
1088     {
1089         const char * pcReturn;
1090         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1091
1092         pcReturn = pcTimerGetName( xTimer );
1093         vPortResetPrivilege( xRunningPrivileged );
1094
1095         return pcReturn;
1096     }
1097 #endif /* if ( configUSE_TIMERS == 1 ) */
1098 /*-----------------------------------------------------------*/
1099
1100 #if ( configUSE_TIMERS == 1 )
1101     TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */
1102     {
1103         TickType_t xReturn;
1104         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1105
1106         xReturn = xTimerGetPeriod( xTimer );
1107         vPortResetPrivilege( xRunningPrivileged );
1108
1109         return xReturn;
1110     }
1111 #endif /* if ( configUSE_TIMERS == 1 ) */
1112 /*-----------------------------------------------------------*/
1113
1114 #if ( configUSE_TIMERS == 1 )
1115     TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */
1116     {
1117         TickType_t xReturn;
1118         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1119
1120         xReturn = xTimerGetExpiryTime( xTimer );
1121         vPortResetPrivilege( xRunningPrivileged );
1122
1123         return xReturn;
1124     }
1125 #endif /* if ( configUSE_TIMERS == 1 ) */
1126 /*-----------------------------------------------------------*/
1127
1128 #if ( configUSE_TIMERS == 1 )
1129     BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer,
1130                                          const BaseType_t xCommandID,
1131                                          const TickType_t xOptionalValue,
1132                                          BaseType_t * const pxHigherPriorityTaskWoken,
1133                                          const TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
1134     {
1135         BaseType_t xReturn;
1136         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1137
1138         xReturn = xTimerGenericCommand( xTimer, xCommandID, xOptionalValue, pxHigherPriorityTaskWoken, xTicksToWait );
1139         vPortResetPrivilege( xRunningPrivileged );
1140
1141         return xReturn;
1142     }
1143 #endif /* if ( configUSE_TIMERS == 1 ) */
1144 /*-----------------------------------------------------------*/
1145
1146 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
1147     EventGroupHandle_t MPU_xEventGroupCreate( void ) /* FREERTOS_SYSTEM_CALL */
1148     {
1149         EventGroupHandle_t xReturn;
1150         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1151
1152         xReturn = xEventGroupCreate();
1153         vPortResetPrivilege( xRunningPrivileged );
1154
1155         return xReturn;
1156     }
1157 #endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) */
1158 /*-----------------------------------------------------------*/
1159
1160 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1161     EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) /* FREERTOS_SYSTEM_CALL */
1162     {
1163         EventGroupHandle_t xReturn;
1164         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1165
1166         xReturn = xEventGroupCreateStatic( pxEventGroupBuffer );
1167         vPortResetPrivilege( xRunningPrivileged );
1168
1169         return xReturn;
1170     }
1171 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
1172 /*-----------------------------------------------------------*/
1173
1174 EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
1175                                      const EventBits_t uxBitsToWaitFor,
1176                                      const BaseType_t xClearOnExit,
1177                                      const BaseType_t xWaitForAllBits,
1178                                      TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
1179 {
1180     EventBits_t xReturn;
1181     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1182
1183     xReturn = xEventGroupWaitBits( xEventGroup, uxBitsToWaitFor, xClearOnExit, xWaitForAllBits, xTicksToWait );
1184     vPortResetPrivilege( xRunningPrivileged );
1185
1186     return xReturn;
1187 }
1188 /*-----------------------------------------------------------*/
1189
1190 EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup,
1191                                       const EventBits_t uxBitsToClear ) /* FREERTOS_SYSTEM_CALL */
1192 {
1193     EventBits_t xReturn;
1194     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1195
1196     xReturn = xEventGroupClearBits( xEventGroup, uxBitsToClear );
1197     vPortResetPrivilege( xRunningPrivileged );
1198
1199     return xReturn;
1200 }
1201 /*-----------------------------------------------------------*/
1202
1203 EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup,
1204                                     const EventBits_t uxBitsToSet ) /* FREERTOS_SYSTEM_CALL */
1205 {
1206     EventBits_t xReturn;
1207     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1208
1209     xReturn = xEventGroupSetBits( xEventGroup, uxBitsToSet );
1210     vPortResetPrivilege( xRunningPrivileged );
1211
1212     return xReturn;
1213 }
1214 /*-----------------------------------------------------------*/
1215
1216 EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup,
1217                                  const EventBits_t uxBitsToSet,
1218                                  const EventBits_t uxBitsToWaitFor,
1219                                  TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
1220 {
1221     EventBits_t xReturn;
1222     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1223
1224     xReturn = xEventGroupSync( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTicksToWait );
1225     vPortResetPrivilege( xRunningPrivileged );
1226
1227     return xReturn;
1228 }
1229 /*-----------------------------------------------------------*/
1230
1231 void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) /* FREERTOS_SYSTEM_CALL */
1232 {
1233     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1234
1235     vEventGroupDelete( xEventGroup );
1236     vPortResetPrivilege( xRunningPrivileged );
1237 }
1238 /*-----------------------------------------------------------*/
1239
1240 size_t MPU_xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
1241                               const void * pvTxData,
1242                               size_t xDataLengthBytes,
1243                               TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
1244 {
1245     size_t xReturn;
1246     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1247
1248     xReturn = xStreamBufferSend( xStreamBuffer, pvTxData, xDataLengthBytes, xTicksToWait );
1249     vPortResetPrivilege( xRunningPrivileged );
1250
1251     return xReturn;
1252 }
1253 /*-----------------------------------------------------------*/
1254
1255 size_t MPU_xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
1256 {
1257     size_t xReturn;
1258     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1259
1260     xReturn = xStreamBufferNextMessageLengthBytes( xStreamBuffer );
1261     vPortResetPrivilege( xRunningPrivileged );
1262
1263     return xReturn;
1264 }
1265 /*-----------------------------------------------------------*/
1266
1267 size_t MPU_xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer,
1268                                  void * pvRxData,
1269                                  size_t xBufferLengthBytes,
1270                                  TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
1271 {
1272     size_t xReturn;
1273     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1274
1275     xReturn = xStreamBufferReceive( xStreamBuffer, pvRxData, xBufferLengthBytes, xTicksToWait );
1276     vPortResetPrivilege( xRunningPrivileged );
1277
1278     return xReturn;
1279 }
1280 /*-----------------------------------------------------------*/
1281
1282 void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
1283 {
1284     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1285
1286     vStreamBufferDelete( xStreamBuffer );
1287     vPortResetPrivilege( xRunningPrivileged );
1288 }
1289 /*-----------------------------------------------------------*/
1290
1291 BaseType_t MPU_xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
1292 {
1293     BaseType_t xReturn;
1294     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1295
1296     xReturn = xStreamBufferIsFull( xStreamBuffer );
1297     vPortResetPrivilege( xRunningPrivileged );
1298
1299     return xReturn;
1300 }
1301 /*-----------------------------------------------------------*/
1302
1303 BaseType_t MPU_xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
1304 {
1305     BaseType_t xReturn;
1306     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1307
1308     xReturn = xStreamBufferIsEmpty( xStreamBuffer );
1309     vPortResetPrivilege( xRunningPrivileged );
1310
1311     return xReturn;
1312 }
1313 /*-----------------------------------------------------------*/
1314
1315 BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
1316 {
1317     BaseType_t xReturn;
1318     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1319
1320     xReturn = xStreamBufferReset( xStreamBuffer );
1321     vPortResetPrivilege( xRunningPrivileged );
1322
1323     return xReturn;
1324 }
1325 /*-----------------------------------------------------------*/
1326
1327 size_t MPU_xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
1328 {
1329     size_t xReturn;
1330     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1331
1332     xReturn = xStreamBufferSpacesAvailable( xStreamBuffer );
1333     vPortResetPrivilege( xRunningPrivileged );
1334
1335     return xReturn;
1336 }
1337 /*-----------------------------------------------------------*/
1338
1339 size_t MPU_xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
1340 {
1341     size_t xReturn;
1342     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1343
1344     xReturn = xStreamBufferBytesAvailable( xStreamBuffer );
1345     vPortResetPrivilege( xRunningPrivileged );
1346
1347     return xReturn;
1348 }
1349 /*-----------------------------------------------------------*/
1350
1351 BaseType_t MPU_xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer,
1352                                              size_t xTriggerLevel ) /* FREERTOS_SYSTEM_CALL */
1353 {
1354     BaseType_t xReturn;
1355     BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1356
1357     xReturn = xStreamBufferSetTriggerLevel( xStreamBuffer, xTriggerLevel );
1358     vPortResetPrivilege( xRunningPrivileged );
1359
1360     return xReturn;
1361 }
1362 /*-----------------------------------------------------------*/
1363
1364 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
1365     StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes,
1366                                                          size_t xTriggerLevelBytes,
1367                                                          BaseType_t xIsMessageBuffer ) /* FREERTOS_SYSTEM_CALL */
1368     {
1369         StreamBufferHandle_t xReturn;
1370         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1371
1372         xReturn = xStreamBufferGenericCreate( xBufferSizeBytes, xTriggerLevelBytes, xIsMessageBuffer );
1373         vPortResetPrivilege( xRunningPrivileged );
1374
1375         return xReturn;
1376     }
1377 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
1378 /*-----------------------------------------------------------*/
1379
1380 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1381     StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
1382                                                                size_t xTriggerLevelBytes,
1383                                                                BaseType_t xIsMessageBuffer,
1384                                                                uint8_t * const pucStreamBufferStorageArea,
1385                                                                StaticStreamBuffer_t * const pxStaticStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
1386     {
1387         StreamBufferHandle_t xReturn;
1388         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1389
1390         xReturn = xStreamBufferGenericCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, xIsMessageBuffer, pucStreamBufferStorageArea, pxStaticStreamBuffer );
1391         vPortResetPrivilege( xRunningPrivileged );
1392
1393         return xReturn;
1394     }
1395 #endif /* configSUPPORT_STATIC_ALLOCATION */
1396 /*-----------------------------------------------------------*/
1397
1398
1399 /* Functions that the application writer wants to execute in privileged mode
1400  * can be defined in application_defined_privileged_functions.h.  The functions
1401  * must take the same format as those above whereby the privilege state on exit
1402  * equals the privilege state on entry.  For example:
1403  *
1404  * void MPU_FunctionName( [parameters ] )
1405  * {
1406  * BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1407  *
1408  *  FunctionName( [parameters ] );
1409  *
1410  *  vPortResetPrivilege( xRunningPrivileged );
1411  * }
1412  */
1413
1414 #if configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS == 1
1415     #include "application_defined_privileged_functions.h"
1416 #endif