xref: /Kernel-v10.6.2/portable/Common/mpu_wrappers.c (revision ef7b253b56c9788077f5ecd6c9deb4021923d646)
1 /*
2  * FreeRTOS Kernel V10.6.2
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 #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 1 ) )
52 
53     #if ( configENABLE_ACCESS_CONTROL_LIST == 1 )
54         #error Access control list is not available with this MPU wrapper. Please set configENABLE_ACCESS_CONTROL_LIST to 0.
55     #endif
56 
57     #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
MPU_xTaskCreate(TaskFunction_t pvTaskCode,const char * const pcName,uint16_t usStackDepth,void * pvParameters,UBaseType_t uxPriority,TaskHandle_t * pxCreatedTask)58         BaseType_t MPU_xTaskCreate( TaskFunction_t pvTaskCode,
59                                     const char * const pcName,
60                                     uint16_t usStackDepth,
61                                     void * pvParameters,
62                                     UBaseType_t uxPriority,
63                                     TaskHandle_t * pxCreatedTask ) /* FREERTOS_SYSTEM_CALL */
64         {
65             BaseType_t xReturn;
66 
67             if( portIS_PRIVILEGED() == pdFALSE )
68             {
69                 portRAISE_PRIVILEGE();
70                 portMEMORY_BARRIER();
71 
72                 uxPriority = uxPriority & ~( portPRIVILEGE_BIT );
73                 portMEMORY_BARRIER();
74 
75                 xReturn = xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask );
76                 portMEMORY_BARRIER();
77 
78                 portRESET_PRIVILEGE();
79                 portMEMORY_BARRIER();
80             }
81             else
82             {
83                 xReturn = xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask );
84             }
85 
86             return xReturn;
87         }
88     #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
89 /*-----------------------------------------------------------*/
90 
91     #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
MPU_xTaskCreateStatic(TaskFunction_t pxTaskCode,const char * const pcName,const uint32_t ulStackDepth,void * const pvParameters,UBaseType_t uxPriority,StackType_t * const puxStackBuffer,StaticTask_t * const pxTaskBuffer)92         TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode,
93                                             const char * const pcName,
94                                             const uint32_t ulStackDepth,
95                                             void * const pvParameters,
96                                             UBaseType_t uxPriority,
97                                             StackType_t * const puxStackBuffer,
98                                             StaticTask_t * const pxTaskBuffer ) /* FREERTOS_SYSTEM_CALL */
99         {
100             TaskHandle_t xReturn;
101 
102             if( portIS_PRIVILEGED() == pdFALSE )
103             {
104                 portRAISE_PRIVILEGE();
105                 portMEMORY_BARRIER();
106 
107                 uxPriority = uxPriority & ~( portPRIVILEGE_BIT );
108                 portMEMORY_BARRIER();
109 
110                 xReturn = xTaskCreateStatic( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer );
111                 portMEMORY_BARRIER();
112 
113                 portRESET_PRIVILEGE();
114                 portMEMORY_BARRIER();
115             }
116             else
117             {
118                 xReturn = xTaskCreateStatic( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer );
119             }
120 
121             return xReturn;
122         }
123     #endif /* configSUPPORT_STATIC_ALLOCATION */
124 /*-----------------------------------------------------------*/
125 
126     #if ( INCLUDE_vTaskDelete == 1 )
MPU_vTaskDelete(TaskHandle_t pxTaskToDelete)127         void MPU_vTaskDelete( TaskHandle_t pxTaskToDelete ) /* FREERTOS_SYSTEM_CALL */
128         {
129             if( portIS_PRIVILEGED() == pdFALSE )
130             {
131                 portRAISE_PRIVILEGE();
132                 portMEMORY_BARRIER();
133 
134                 vTaskDelete( pxTaskToDelete );
135                 portMEMORY_BARRIER();
136 
137                 portRESET_PRIVILEGE();
138                 portMEMORY_BARRIER();
139             }
140             else
141             {
142                 vTaskDelete( pxTaskToDelete );
143             }
144         }
145     #endif /* if ( INCLUDE_vTaskDelete == 1 ) */
146 /*-----------------------------------------------------------*/
147 
148     #if ( INCLUDE_xTaskDelayUntil == 1 )
MPU_xTaskDelayUntil(TickType_t * const pxPreviousWakeTime,TickType_t xTimeIncrement)149         BaseType_t MPU_xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
150                                         TickType_t xTimeIncrement ) /* FREERTOS_SYSTEM_CALL */
151         {
152             BaseType_t xReturn;
153 
154             if( portIS_PRIVILEGED() == pdFALSE )
155             {
156                 portRAISE_PRIVILEGE();
157                 portMEMORY_BARRIER();
158 
159                 xReturn = xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement );
160                 portMEMORY_BARRIER();
161 
162                 portRESET_PRIVILEGE();
163                 portMEMORY_BARRIER();
164             }
165             else
166             {
167                 xReturn = xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement );
168             }
169 
170             return xReturn;
171         }
172     #endif /* if ( INCLUDE_xTaskDelayUntil == 1 ) */
173 /*-----------------------------------------------------------*/
174 
175     #if ( INCLUDE_xTaskAbortDelay == 1 )
MPU_xTaskAbortDelay(TaskHandle_t xTask)176         BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */
177         {
178             BaseType_t xReturn;
179 
180             if( portIS_PRIVILEGED() == pdFALSE )
181             {
182                 portRAISE_PRIVILEGE();
183                 portMEMORY_BARRIER();
184 
185                 xReturn = xTaskAbortDelay( xTask );
186                 portMEMORY_BARRIER();
187 
188                 portRESET_PRIVILEGE();
189                 portMEMORY_BARRIER();
190             }
191             else
192             {
193                 xReturn = xTaskAbortDelay( xTask );
194             }
195 
196             return xReturn;
197         }
198     #endif /* if ( INCLUDE_xTaskAbortDelay == 1 ) */
199 /*-----------------------------------------------------------*/
200 
201     #if ( INCLUDE_vTaskDelay == 1 )
MPU_vTaskDelay(TickType_t xTicksToDelay)202         void MPU_vTaskDelay( TickType_t xTicksToDelay ) /* FREERTOS_SYSTEM_CALL */
203         {
204             if( portIS_PRIVILEGED() == pdFALSE )
205             {
206                 portRAISE_PRIVILEGE();
207                 portMEMORY_BARRIER();
208 
209                 vTaskDelay( xTicksToDelay );
210                 portMEMORY_BARRIER();
211 
212                 portRESET_PRIVILEGE();
213                 portMEMORY_BARRIER();
214             }
215             else
216             {
217                 vTaskDelay( xTicksToDelay );
218             }
219         }
220     #endif /* if ( INCLUDE_vTaskDelay == 1 ) */
221 /*-----------------------------------------------------------*/
222 
223     #if ( INCLUDE_uxTaskPriorityGet == 1 )
MPU_uxTaskPriorityGet(const TaskHandle_t pxTask)224         UBaseType_t MPU_uxTaskPriorityGet( const TaskHandle_t pxTask ) /* FREERTOS_SYSTEM_CALL */
225         {
226             UBaseType_t uxReturn;
227 
228             if( portIS_PRIVILEGED() == pdFALSE )
229             {
230                 portRAISE_PRIVILEGE();
231                 portMEMORY_BARRIER();
232 
233                 uxReturn = uxTaskPriorityGet( pxTask );
234                 portMEMORY_BARRIER();
235 
236                 portRESET_PRIVILEGE();
237                 portMEMORY_BARRIER();
238             }
239             else
240             {
241                 uxReturn = uxTaskPriorityGet( pxTask );
242             }
243 
244             return uxReturn;
245         }
246     #endif /* if ( INCLUDE_uxTaskPriorityGet == 1 ) */
247 /*-----------------------------------------------------------*/
248 
249     #if ( INCLUDE_vTaskPrioritySet == 1 )
MPU_vTaskPrioritySet(TaskHandle_t pxTask,UBaseType_t uxNewPriority)250         void MPU_vTaskPrioritySet( TaskHandle_t pxTask,
251                                    UBaseType_t uxNewPriority ) /* FREERTOS_SYSTEM_CALL */
252         {
253             if( portIS_PRIVILEGED() == pdFALSE )
254             {
255                 portRAISE_PRIVILEGE();
256                 portMEMORY_BARRIER();
257 
258                 vTaskPrioritySet( pxTask, uxNewPriority );
259                 portMEMORY_BARRIER();
260 
261                 portRESET_PRIVILEGE();
262                 portMEMORY_BARRIER();
263             }
264             else
265             {
266                 vTaskPrioritySet( pxTask, uxNewPriority );
267             }
268         }
269     #endif /* if ( INCLUDE_vTaskPrioritySet == 1 ) */
270 /*-----------------------------------------------------------*/
271 
272     #if ( INCLUDE_eTaskGetState == 1 )
MPU_eTaskGetState(TaskHandle_t pxTask)273         eTaskState MPU_eTaskGetState( TaskHandle_t pxTask ) /* FREERTOS_SYSTEM_CALL */
274         {
275             eTaskState eReturn;
276 
277             if( portIS_PRIVILEGED() == pdFALSE )
278             {
279                 portRAISE_PRIVILEGE();
280                 portMEMORY_BARRIER();
281 
282                 eReturn = eTaskGetState( pxTask );
283                 portMEMORY_BARRIER();
284 
285                 portRESET_PRIVILEGE();
286                 portMEMORY_BARRIER();
287             }
288             else
289             {
290                 eReturn = eTaskGetState( pxTask );
291             }
292 
293             return eReturn;
294         }
295     #endif /* if ( INCLUDE_eTaskGetState == 1 ) */
296 /*-----------------------------------------------------------*/
297 
298     #if ( configUSE_TRACE_FACILITY == 1 )
MPU_vTaskGetInfo(TaskHandle_t xTask,TaskStatus_t * pxTaskStatus,BaseType_t xGetFreeStackSpace,eTaskState eState)299         void MPU_vTaskGetInfo( TaskHandle_t xTask,
300                                TaskStatus_t * pxTaskStatus,
301                                BaseType_t xGetFreeStackSpace,
302                                eTaskState eState ) /* FREERTOS_SYSTEM_CALL */
303         {
304             if( portIS_PRIVILEGED() == pdFALSE )
305             {
306                 portRAISE_PRIVILEGE();
307                 portMEMORY_BARRIER();
308 
309                 vTaskGetInfo( xTask, pxTaskStatus, xGetFreeStackSpace, eState );
310                 portMEMORY_BARRIER();
311 
312                 portRESET_PRIVILEGE();
313                 portMEMORY_BARRIER();
314             }
315             else
316             {
317                 vTaskGetInfo( xTask, pxTaskStatus, xGetFreeStackSpace, eState );
318             }
319         }
320     #endif /* if ( configUSE_TRACE_FACILITY == 1 ) */
321 /*-----------------------------------------------------------*/
322 
323     #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
MPU_xTaskGetIdleTaskHandle(void)324         TaskHandle_t MPU_xTaskGetIdleTaskHandle( void ) /* FREERTOS_SYSTEM_CALL */
325         {
326             TaskHandle_t xReturn;
327 
328             if( portIS_PRIVILEGED() == pdFALSE )
329             {
330                 portRAISE_PRIVILEGE();
331                 portMEMORY_BARRIER();
332                 xReturn = xTaskGetIdleTaskHandle();
333                 portMEMORY_BARRIER();
334 
335                 portRESET_PRIVILEGE();
336                 portMEMORY_BARRIER();
337             }
338             else
339             {
340                 xReturn = xTaskGetIdleTaskHandle();
341             }
342 
343             return xReturn;
344         }
345     #endif /* if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) */
346 /*-----------------------------------------------------------*/
347 
348     #if ( INCLUDE_vTaskSuspend == 1 )
MPU_vTaskSuspend(TaskHandle_t pxTaskToSuspend)349         void MPU_vTaskSuspend( TaskHandle_t pxTaskToSuspend ) /* FREERTOS_SYSTEM_CALL */
350         {
351             if( portIS_PRIVILEGED() == pdFALSE )
352             {
353                 portRAISE_PRIVILEGE();
354                 portMEMORY_BARRIER();
355 
356                 vTaskSuspend( pxTaskToSuspend );
357                 portMEMORY_BARRIER();
358 
359                 portRESET_PRIVILEGE();
360                 portMEMORY_BARRIER();
361             }
362             else
363             {
364                 vTaskSuspend( pxTaskToSuspend );
365             }
366         }
367     #endif /* if ( INCLUDE_vTaskSuspend == 1 ) */
368 /*-----------------------------------------------------------*/
369 
370     #if ( INCLUDE_vTaskSuspend == 1 )
MPU_vTaskResume(TaskHandle_t pxTaskToResume)371         void MPU_vTaskResume( TaskHandle_t pxTaskToResume ) /* FREERTOS_SYSTEM_CALL */
372         {
373             if( portIS_PRIVILEGED() == pdFALSE )
374             {
375                 portRAISE_PRIVILEGE();
376                 portMEMORY_BARRIER();
377 
378                 vTaskResume( pxTaskToResume );
379                 portMEMORY_BARRIER();
380 
381                 portRESET_PRIVILEGE();
382                 portMEMORY_BARRIER();
383             }
384             else
385             {
386                 vTaskResume( pxTaskToResume );
387             }
388         }
389     #endif /* if ( INCLUDE_vTaskSuspend == 1 ) */
390 /*-----------------------------------------------------------*/
391 
MPU_vTaskSuspendAll(void)392     void MPU_vTaskSuspendAll( void ) /* FREERTOS_SYSTEM_CALL */
393     {
394         if( portIS_PRIVILEGED() == pdFALSE )
395         {
396             portRAISE_PRIVILEGE();
397             portMEMORY_BARRIER();
398 
399             vTaskSuspendAll();
400             portMEMORY_BARRIER();
401 
402             portRESET_PRIVILEGE();
403             portMEMORY_BARRIER();
404         }
405         else
406         {
407             vTaskSuspendAll();
408         }
409     }
410 /*-----------------------------------------------------------*/
411 
MPU_xTaskResumeAll(void)412     BaseType_t MPU_xTaskResumeAll( void ) /* FREERTOS_SYSTEM_CALL */
413     {
414         BaseType_t xReturn;
415 
416         if( portIS_PRIVILEGED() == pdFALSE )
417         {
418             portRAISE_PRIVILEGE();
419             portMEMORY_BARRIER();
420 
421             xReturn = xTaskResumeAll();
422             portMEMORY_BARRIER();
423 
424             portRESET_PRIVILEGE();
425             portMEMORY_BARRIER();
426         }
427         else
428         {
429             xReturn = xTaskResumeAll();
430         }
431 
432         return xReturn;
433     }
434 /*-----------------------------------------------------------*/
435 
MPU_xTaskGetTickCount(void)436     TickType_t MPU_xTaskGetTickCount( void ) /* FREERTOS_SYSTEM_CALL */
437     {
438         TickType_t xReturn;
439 
440         if( portIS_PRIVILEGED() == pdFALSE )
441         {
442             portRAISE_PRIVILEGE();
443             portMEMORY_BARRIER();
444 
445             xReturn = xTaskGetTickCount();
446             portMEMORY_BARRIER();
447 
448             portRESET_PRIVILEGE();
449             portMEMORY_BARRIER();
450         }
451         else
452         {
453             xReturn = xTaskGetTickCount();
454         }
455 
456         return xReturn;
457     }
458 /*-----------------------------------------------------------*/
459 
MPU_uxTaskGetNumberOfTasks(void)460     UBaseType_t MPU_uxTaskGetNumberOfTasks( void ) /* FREERTOS_SYSTEM_CALL */
461     {
462         UBaseType_t uxReturn;
463 
464         if( portIS_PRIVILEGED() == pdFALSE )
465         {
466             portRAISE_PRIVILEGE();
467             portMEMORY_BARRIER();
468 
469             uxReturn = uxTaskGetNumberOfTasks();
470             portMEMORY_BARRIER();
471 
472             portRESET_PRIVILEGE();
473             portMEMORY_BARRIER();
474         }
475         else
476         {
477             uxReturn = uxTaskGetNumberOfTasks();
478         }
479 
480         return uxReturn;
481     }
482 /*-----------------------------------------------------------*/
483 
MPU_pcTaskGetName(TaskHandle_t xTaskToQuery)484     char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) /* FREERTOS_SYSTEM_CALL */
485     {
486         char * pcReturn;
487 
488         if( portIS_PRIVILEGED() == pdFALSE )
489         {
490             portRAISE_PRIVILEGE();
491             portMEMORY_BARRIER();
492 
493             pcReturn = pcTaskGetName( xTaskToQuery );
494             portMEMORY_BARRIER();
495 
496             portRESET_PRIVILEGE();
497             portMEMORY_BARRIER();
498         }
499         else
500         {
501             pcReturn = pcTaskGetName( xTaskToQuery );
502         }
503 
504         return pcReturn;
505     }
506 /*-----------------------------------------------------------*/
507 
508     #if ( INCLUDE_xTaskGetHandle == 1 )
MPU_xTaskGetHandle(const char * pcNameToQuery)509         TaskHandle_t MPU_xTaskGetHandle( const char * pcNameToQuery ) /* FREERTOS_SYSTEM_CALL */
510         {
511             TaskHandle_t xReturn;
512 
513             if( portIS_PRIVILEGED() == pdFALSE )
514             {
515                 portRAISE_PRIVILEGE();
516                 portMEMORY_BARRIER();
517 
518                 xReturn = xTaskGetHandle( pcNameToQuery );
519                 portMEMORY_BARRIER();
520 
521                 portRESET_PRIVILEGE();
522                 portMEMORY_BARRIER();
523             }
524             else
525             {
526                 xReturn = xTaskGetHandle( pcNameToQuery );
527             }
528 
529             return xReturn;
530         }
531     #endif /* if ( INCLUDE_xTaskGetHandle == 1 ) */
532 /*-----------------------------------------------------------*/
533 
534     #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
MPU_vTaskList(char * pcWriteBuffer)535         void MPU_vTaskList( char * pcWriteBuffer ) /* FREERTOS_SYSTEM_CALL */
536         {
537             if( portIS_PRIVILEGED() == pdFALSE )
538             {
539                 portRAISE_PRIVILEGE();
540                 portMEMORY_BARRIER();
541 
542                 vTaskList( pcWriteBuffer );
543                 portMEMORY_BARRIER();
544 
545                 portRESET_PRIVILEGE();
546                 portMEMORY_BARRIER();
547             }
548             else
549             {
550                 vTaskList( pcWriteBuffer );
551             }
552         }
553     #endif /* if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */
554 /*-----------------------------------------------------------*/
555 
556     #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
MPU_vTaskGetRunTimeStats(char * pcWriteBuffer)557         void MPU_vTaskGetRunTimeStats( char * pcWriteBuffer ) /* FREERTOS_SYSTEM_CALL */
558         {
559             if( portIS_PRIVILEGED() == pdFALSE )
560             {
561                 portRAISE_PRIVILEGE();
562                 portMEMORY_BARRIER();
563 
564                 vTaskGetRunTimeStats( pcWriteBuffer );
565                 portMEMORY_BARRIER();
566 
567                 portRESET_PRIVILEGE();
568                 portMEMORY_BARRIER();
569             }
570             else
571             {
572                 vTaskGetRunTimeStats( pcWriteBuffer );
573             }
574         }
575     #endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */
576 /*-----------------------------------------------------------*/
577 
578     #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) )
MPU_ulTaskGetIdleRunTimePercent(void)579         configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimePercent( void ) /* FREERTOS_SYSTEM_CALL */
580         {
581             configRUN_TIME_COUNTER_TYPE xReturn;
582 
583             if( portIS_PRIVILEGED() == pdFALSE )
584             {
585                 portRAISE_PRIVILEGE();
586                 portMEMORY_BARRIER();
587 
588                 xReturn = ulTaskGetIdleRunTimePercent();
589                 portMEMORY_BARRIER();
590 
591                 portRESET_PRIVILEGE();
592                 portMEMORY_BARRIER();
593             }
594             else
595             {
596                 xReturn = ulTaskGetIdleRunTimePercent();
597             }
598 
599             return xReturn;
600         }
601     #endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) */
602 /*-----------------------------------------------------------*/
603 
604     #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) )
MPU_ulTaskGetIdleRunTimeCounter(void)605         configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimeCounter( void ) /* FREERTOS_SYSTEM_CALL */
606         {
607             configRUN_TIME_COUNTER_TYPE xReturn;
608 
609             if( portIS_PRIVILEGED() == pdFALSE )
610             {
611                 portRAISE_PRIVILEGE();
612                 portMEMORY_BARRIER();
613 
614                 xReturn = ulTaskGetIdleRunTimeCounter();
615                 portMEMORY_BARRIER();
616 
617                 portRESET_PRIVILEGE();
618                 portMEMORY_BARRIER();
619             }
620             else
621             {
622                 xReturn = ulTaskGetIdleRunTimeCounter();
623             }
624 
625             return xReturn;
626         }
627     #endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) */
628 /*-----------------------------------------------------------*/
629 
630     #if ( configUSE_APPLICATION_TASK_TAG == 1 )
MPU_vTaskSetApplicationTaskTag(TaskHandle_t xTask,TaskHookFunction_t pxTagValue)631         void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask,
632                                              TaskHookFunction_t pxTagValue ) /* FREERTOS_SYSTEM_CALL */
633         {
634             if( portIS_PRIVILEGED() == pdFALSE )
635             {
636                 portRAISE_PRIVILEGE();
637                 portMEMORY_BARRIER();
638 
639                 vTaskSetApplicationTaskTag( xTask, pxTagValue );
640                 portMEMORY_BARRIER();
641 
642                 portRESET_PRIVILEGE();
643                 portMEMORY_BARRIER();
644             }
645             else
646             {
647                 vTaskSetApplicationTaskTag( xTask, pxTagValue );
648             }
649         }
650     #endif /* if ( configUSE_APPLICATION_TASK_TAG == 1 ) */
651 /*-----------------------------------------------------------*/
652 
653     #if ( configUSE_APPLICATION_TASK_TAG == 1 )
MPU_xTaskGetApplicationTaskTag(TaskHandle_t xTask)654         TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */
655         {
656             TaskHookFunction_t xReturn;
657 
658             if( portIS_PRIVILEGED() == pdFALSE )
659             {
660                 portRAISE_PRIVILEGE();
661                 portMEMORY_BARRIER();
662 
663                 xReturn = xTaskGetApplicationTaskTag( xTask );
664                 portMEMORY_BARRIER();
665 
666                 portRESET_PRIVILEGE();
667                 portMEMORY_BARRIER();
668             }
669             else
670             {
671                 xReturn = xTaskGetApplicationTaskTag( xTask );
672             }
673 
674             return xReturn;
675         }
676     #endif /* if ( configUSE_APPLICATION_TASK_TAG == 1 ) */
677 /*-----------------------------------------------------------*/
678 
679     #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
MPU_vTaskSetThreadLocalStoragePointer(TaskHandle_t xTaskToSet,BaseType_t xIndex,void * pvValue)680         void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet,
681                                                     BaseType_t xIndex,
682                                                     void * pvValue ) /* FREERTOS_SYSTEM_CALL */
683         {
684             if( portIS_PRIVILEGED() == pdFALSE )
685             {
686                 portRAISE_PRIVILEGE();
687                 portMEMORY_BARRIER();
688 
689                 vTaskSetThreadLocalStoragePointer( xTaskToSet, xIndex, pvValue );
690                 portMEMORY_BARRIER();
691 
692                 portRESET_PRIVILEGE();
693                 portMEMORY_BARRIER();
694             }
695             else
696             {
697                 vTaskSetThreadLocalStoragePointer( xTaskToSet, xIndex, pvValue );
698             }
699         }
700     #endif /* if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) */
701 /*-----------------------------------------------------------*/
702 
703     #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
MPU_pvTaskGetThreadLocalStoragePointer(TaskHandle_t xTaskToQuery,BaseType_t xIndex)704         void * MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery,
705                                                        BaseType_t xIndex ) /* FREERTOS_SYSTEM_CALL */
706         {
707             void * pvReturn;
708 
709             if( portIS_PRIVILEGED() == pdFALSE )
710             {
711                 portRAISE_PRIVILEGE();
712                 portMEMORY_BARRIER();
713 
714                 pvReturn = pvTaskGetThreadLocalStoragePointer( xTaskToQuery, xIndex );
715                 portMEMORY_BARRIER();
716 
717                 portRESET_PRIVILEGE();
718                 portMEMORY_BARRIER();
719             }
720             else
721             {
722                 pvReturn = pvTaskGetThreadLocalStoragePointer( xTaskToQuery, xIndex );
723             }
724 
725             return pvReturn;
726         }
727     #endif /* if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) */
728 /*-----------------------------------------------------------*/
729 
730     #if ( configUSE_APPLICATION_TASK_TAG == 1 )
MPU_xTaskCallApplicationTaskHook(TaskHandle_t xTask,void * pvParameter)731         BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask,
732                                                      void * pvParameter ) /* FREERTOS_SYSTEM_CALL */
733         {
734             BaseType_t xReturn;
735 
736             if( portIS_PRIVILEGED() == pdFALSE )
737             {
738                 portRAISE_PRIVILEGE();
739                 portMEMORY_BARRIER();
740 
741                 xReturn = xTaskCallApplicationTaskHook( xTask, pvParameter );
742                 portMEMORY_BARRIER();
743 
744                 portRESET_PRIVILEGE();
745                 portMEMORY_BARRIER();
746             }
747             else
748             {
749                 xReturn = xTaskCallApplicationTaskHook( xTask, pvParameter );
750             }
751 
752             return xReturn;
753         }
754     #endif /* if ( configUSE_APPLICATION_TASK_TAG == 1 ) */
755 /*-----------------------------------------------------------*/
756 
757     #if ( configUSE_TRACE_FACILITY == 1 )
MPU_uxTaskGetSystemState(TaskStatus_t * pxTaskStatusArray,UBaseType_t uxArraySize,configRUN_TIME_COUNTER_TYPE * pulTotalRunTime)758         UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t * pxTaskStatusArray,
759                                               UBaseType_t uxArraySize,
760                                               configRUN_TIME_COUNTER_TYPE * pulTotalRunTime ) /* FREERTOS_SYSTEM_CALL */
761         {
762             UBaseType_t uxReturn;
763 
764             if( portIS_PRIVILEGED() == pdFALSE )
765             {
766                 portRAISE_PRIVILEGE();
767                 portMEMORY_BARRIER();
768 
769                 uxReturn = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, pulTotalRunTime );
770                 portMEMORY_BARRIER();
771 
772                 portRESET_PRIVILEGE();
773                 portMEMORY_BARRIER();
774             }
775             else
776             {
777                 uxReturn = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, pulTotalRunTime );
778             }
779 
780             return uxReturn;
781         }
782     #endif /* if ( configUSE_TRACE_FACILITY == 1 ) */
783 /*-----------------------------------------------------------*/
784 
MPU_xTaskCatchUpTicks(TickType_t xTicksToCatchUp)785     BaseType_t MPU_xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) /* FREERTOS_SYSTEM_CALL */
786     {
787         BaseType_t xReturn;
788 
789         if( portIS_PRIVILEGED() == pdFALSE )
790         {
791             portRAISE_PRIVILEGE();
792             portMEMORY_BARRIER();
793 
794             xReturn = xTaskCatchUpTicks( xTicksToCatchUp );
795             portMEMORY_BARRIER();
796 
797             portRESET_PRIVILEGE();
798             portMEMORY_BARRIER();
799         }
800         else
801         {
802             xReturn = xTaskCatchUpTicks( xTicksToCatchUp );
803         }
804 
805         return xReturn;
806     }
807 /*-----------------------------------------------------------*/
808 
809     #if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )
MPU_uxTaskGetStackHighWaterMark(TaskHandle_t xTask)810         UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */
811         {
812             UBaseType_t uxReturn;
813 
814             if( portIS_PRIVILEGED() == pdFALSE )
815             {
816                 portRAISE_PRIVILEGE();
817                 portMEMORY_BARRIER();
818 
819                 uxReturn = uxTaskGetStackHighWaterMark( xTask );
820                 portMEMORY_BARRIER();
821 
822                 portRESET_PRIVILEGE();
823                 portMEMORY_BARRIER();
824             }
825             else
826             {
827                 uxReturn = uxTaskGetStackHighWaterMark( xTask );
828             }
829 
830             return uxReturn;
831         }
832     #endif /* if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) */
833 /*-----------------------------------------------------------*/
834 
835     #if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 )
MPU_uxTaskGetStackHighWaterMark2(TaskHandle_t xTask)836         configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */
837         {
838             configSTACK_DEPTH_TYPE uxReturn;
839 
840             if( portIS_PRIVILEGED() == pdFALSE )
841             {
842                 portRAISE_PRIVILEGE();
843                 portMEMORY_BARRIER();
844 
845                 uxReturn = uxTaskGetStackHighWaterMark2( xTask );
846                 portMEMORY_BARRIER();
847 
848                 portRESET_PRIVILEGE();
849                 portMEMORY_BARRIER();
850             }
851             else
852             {
853                 uxReturn = uxTaskGetStackHighWaterMark2( xTask );
854             }
855 
856             return uxReturn;
857         }
858     #endif /* if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) */
859 /*-----------------------------------------------------------*/
860 
861     #if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) )
MPU_xTaskGetCurrentTaskHandle(void)862         TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ) /* FREERTOS_SYSTEM_CALL */
863         {
864             TaskHandle_t xReturn;
865 
866             if( portIS_PRIVILEGED() == pdFALSE )
867             {
868                 portRAISE_PRIVILEGE();
869                 portMEMORY_BARRIER();
870                 xReturn = xTaskGetCurrentTaskHandle();
871                 portMEMORY_BARRIER();
872 
873                 portRESET_PRIVILEGE();
874                 portMEMORY_BARRIER();
875             }
876             else
877             {
878                 xReturn = xTaskGetCurrentTaskHandle();
879             }
880 
881             return xReturn;
882         }
883     #endif /* if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) ) */
884 /*-----------------------------------------------------------*/
885 
886     #if ( INCLUDE_xTaskGetSchedulerState == 1 )
MPU_xTaskGetSchedulerState(void)887         BaseType_t MPU_xTaskGetSchedulerState( void ) /* FREERTOS_SYSTEM_CALL */
888         {
889             BaseType_t xReturn;
890 
891             if( portIS_PRIVILEGED() == pdFALSE )
892             {
893                 portRAISE_PRIVILEGE();
894                 portMEMORY_BARRIER();
895 
896                 xReturn = xTaskGetSchedulerState();
897                 portMEMORY_BARRIER();
898 
899                 portRESET_PRIVILEGE();
900                 portMEMORY_BARRIER();
901             }
902             else
903             {
904                 xReturn = xTaskGetSchedulerState();
905             }
906 
907             return xReturn;
908         }
909     #endif /* if ( INCLUDE_xTaskGetSchedulerState == 1 ) */
910 /*-----------------------------------------------------------*/
911 
MPU_vTaskSetTimeOutState(TimeOut_t * const pxTimeOut)912     void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) /* FREERTOS_SYSTEM_CALL */
913     {
914         if( portIS_PRIVILEGED() == pdFALSE )
915         {
916             portRAISE_PRIVILEGE();
917             portMEMORY_BARRIER();
918 
919             vTaskSetTimeOutState( pxTimeOut );
920             portMEMORY_BARRIER();
921 
922             portRESET_PRIVILEGE();
923             portMEMORY_BARRIER();
924         }
925         else
926         {
927             vTaskSetTimeOutState( pxTimeOut );
928         }
929     }
930 /*-----------------------------------------------------------*/
931 
MPU_xTaskCheckForTimeOut(TimeOut_t * const pxTimeOut,TickType_t * const pxTicksToWait)932     BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut,
933                                          TickType_t * const pxTicksToWait ) /* FREERTOS_SYSTEM_CALL */
934     {
935         BaseType_t xReturn;
936 
937         if( portIS_PRIVILEGED() == pdFALSE )
938         {
939             portRAISE_PRIVILEGE();
940             portMEMORY_BARRIER();
941 
942             xReturn = xTaskCheckForTimeOut( pxTimeOut, pxTicksToWait );
943             portMEMORY_BARRIER();
944 
945             portRESET_PRIVILEGE();
946             portMEMORY_BARRIER();
947         }
948         else
949         {
950             xReturn = xTaskCheckForTimeOut( pxTimeOut, pxTicksToWait );
951         }
952 
953         return xReturn;
954     }
955 /*-----------------------------------------------------------*/
956 
957     #if ( configUSE_TASK_NOTIFICATIONS == 1 )
MPU_xTaskGenericNotify(TaskHandle_t xTaskToNotify,UBaseType_t uxIndexToNotify,uint32_t ulValue,eNotifyAction eAction,uint32_t * pulPreviousNotificationValue)958         BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify,
959                                            UBaseType_t uxIndexToNotify,
960                                            uint32_t ulValue,
961                                            eNotifyAction eAction,
962                                            uint32_t * pulPreviousNotificationValue ) /* FREERTOS_SYSTEM_CALL */
963         {
964             BaseType_t xReturn;
965 
966             if( portIS_PRIVILEGED() == pdFALSE )
967             {
968                 portRAISE_PRIVILEGE();
969                 portMEMORY_BARRIER();
970 
971                 xReturn = xTaskGenericNotify( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue );
972                 portMEMORY_BARRIER();
973 
974                 portRESET_PRIVILEGE();
975                 portMEMORY_BARRIER();
976             }
977             else
978             {
979                 xReturn = xTaskGenericNotify( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue );
980             }
981 
982             return xReturn;
983         }
984     #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
985 /*-----------------------------------------------------------*/
986 
987     #if ( configUSE_TASK_NOTIFICATIONS == 1 )
MPU_xTaskGenericNotifyWait(UBaseType_t uxIndexToWaitOn,uint32_t ulBitsToClearOnEntry,uint32_t ulBitsToClearOnExit,uint32_t * pulNotificationValue,TickType_t xTicksToWait)988         BaseType_t MPU_xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn,
989                                                uint32_t ulBitsToClearOnEntry,
990                                                uint32_t ulBitsToClearOnExit,
991                                                uint32_t * pulNotificationValue,
992                                                TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
993         {
994             BaseType_t xReturn;
995 
996             if( portIS_PRIVILEGED() == pdFALSE )
997             {
998                 portRAISE_PRIVILEGE();
999                 portMEMORY_BARRIER();
1000 
1001                 xReturn = xTaskGenericNotifyWait( uxIndexToWaitOn, ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait );
1002                 portMEMORY_BARRIER();
1003 
1004                 portRESET_PRIVILEGE();
1005                 portMEMORY_BARRIER();
1006             }
1007             else
1008             {
1009                 xReturn = xTaskGenericNotifyWait( uxIndexToWaitOn, ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait );
1010             }
1011 
1012             return xReturn;
1013         }
1014     #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
1015 /*-----------------------------------------------------------*/
1016 
1017     #if ( configUSE_TASK_NOTIFICATIONS == 1 )
MPU_ulTaskGenericNotifyTake(UBaseType_t uxIndexToWaitOn,BaseType_t xClearCountOnExit,TickType_t xTicksToWait)1018         uint32_t MPU_ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn,
1019                                               BaseType_t xClearCountOnExit,
1020                                               TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
1021         {
1022             uint32_t ulReturn;
1023 
1024             if( portIS_PRIVILEGED() == pdFALSE )
1025             {
1026                 portRAISE_PRIVILEGE();
1027                 portMEMORY_BARRIER();
1028 
1029                 ulReturn = ulTaskGenericNotifyTake( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait );
1030                 portMEMORY_BARRIER();
1031 
1032                 portRESET_PRIVILEGE();
1033                 portMEMORY_BARRIER();
1034             }
1035             else
1036             {
1037                 ulReturn = ulTaskGenericNotifyTake( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait );
1038             }
1039 
1040             return ulReturn;
1041         }
1042     #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
1043 /*-----------------------------------------------------------*/
1044 
1045     #if ( configUSE_TASK_NOTIFICATIONS == 1 )
MPU_xTaskGenericNotifyStateClear(TaskHandle_t xTask,UBaseType_t uxIndexToClear)1046         BaseType_t MPU_xTaskGenericNotifyStateClear( TaskHandle_t xTask,
1047                                                      UBaseType_t uxIndexToClear ) /* FREERTOS_SYSTEM_CALL */
1048         {
1049             BaseType_t xReturn;
1050 
1051             if( portIS_PRIVILEGED() == pdFALSE )
1052             {
1053                 portRAISE_PRIVILEGE();
1054                 portMEMORY_BARRIER();
1055 
1056                 xReturn = xTaskGenericNotifyStateClear( xTask, uxIndexToClear );
1057                 portMEMORY_BARRIER();
1058 
1059                 portRESET_PRIVILEGE();
1060                 portMEMORY_BARRIER();
1061             }
1062             else
1063             {
1064                 xReturn = xTaskGenericNotifyStateClear( xTask, uxIndexToClear );
1065             }
1066 
1067             return xReturn;
1068         }
1069     #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
1070 /*-----------------------------------------------------------*/
1071 
1072     #if ( configUSE_TASK_NOTIFICATIONS == 1 )
MPU_ulTaskGenericNotifyValueClear(TaskHandle_t xTask,UBaseType_t uxIndexToClear,uint32_t ulBitsToClear)1073         uint32_t MPU_ulTaskGenericNotifyValueClear( TaskHandle_t xTask,
1074                                                     UBaseType_t uxIndexToClear,
1075                                                     uint32_t ulBitsToClear ) /* FREERTOS_SYSTEM_CALL */
1076         {
1077             uint32_t ulReturn;
1078 
1079             if( portIS_PRIVILEGED() == pdFALSE )
1080             {
1081                 portRAISE_PRIVILEGE();
1082                 portMEMORY_BARRIER();
1083 
1084                 ulReturn = ulTaskGenericNotifyValueClear( xTask, uxIndexToClear, ulBitsToClear );
1085                 portMEMORY_BARRIER();
1086 
1087                 portRESET_PRIVILEGE();
1088                 portMEMORY_BARRIER();
1089             }
1090             else
1091             {
1092                 ulReturn = ulTaskGenericNotifyValueClear( xTask, uxIndexToClear, ulBitsToClear );
1093             }
1094 
1095             return ulReturn;
1096         }
1097     #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
1098 /*-----------------------------------------------------------*/
1099 
1100     #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
MPU_xQueueGenericCreate(UBaseType_t uxQueueLength,UBaseType_t uxItemSize,uint8_t ucQueueType)1101         QueueHandle_t MPU_xQueueGenericCreate( UBaseType_t uxQueueLength,
1102                                                UBaseType_t uxItemSize,
1103                                                uint8_t ucQueueType ) /* FREERTOS_SYSTEM_CALL */
1104         {
1105             QueueHandle_t xReturn;
1106 
1107             if( portIS_PRIVILEGED() == pdFALSE )
1108             {
1109                 portRAISE_PRIVILEGE();
1110                 portMEMORY_BARRIER();
1111 
1112                 xReturn = xQueueGenericCreate( uxQueueLength, uxItemSize, ucQueueType );
1113                 portMEMORY_BARRIER();
1114 
1115                 portRESET_PRIVILEGE();
1116                 portMEMORY_BARRIER();
1117             }
1118             else
1119             {
1120                 xReturn = xQueueGenericCreate( uxQueueLength, uxItemSize, ucQueueType );
1121             }
1122 
1123             return xReturn;
1124         }
1125     #endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) */
1126 /*-----------------------------------------------------------*/
1127 
1128     #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
MPU_xQueueGenericCreateStatic(const UBaseType_t uxQueueLength,const UBaseType_t uxItemSize,uint8_t * pucQueueStorage,StaticQueue_t * pxStaticQueue,const uint8_t ucQueueType)1129         QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength,
1130                                                      const UBaseType_t uxItemSize,
1131                                                      uint8_t * pucQueueStorage,
1132                                                      StaticQueue_t * pxStaticQueue,
1133                                                      const uint8_t ucQueueType ) /* FREERTOS_SYSTEM_CALL */
1134         {
1135             QueueHandle_t xReturn;
1136 
1137             if( portIS_PRIVILEGED() == pdFALSE )
1138             {
1139                 portRAISE_PRIVILEGE();
1140                 portMEMORY_BARRIER();
1141 
1142                 xReturn = xQueueGenericCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxStaticQueue, ucQueueType );
1143                 portMEMORY_BARRIER();
1144 
1145                 portRESET_PRIVILEGE();
1146                 portMEMORY_BARRIER();
1147             }
1148             else
1149             {
1150                 xReturn = xQueueGenericCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxStaticQueue, ucQueueType );
1151             }
1152 
1153             return xReturn;
1154         }
1155     #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
1156 /*-----------------------------------------------------------*/
1157 
MPU_xQueueGenericReset(QueueHandle_t pxQueue,BaseType_t xNewQueue)1158     BaseType_t MPU_xQueueGenericReset( QueueHandle_t pxQueue,
1159                                        BaseType_t xNewQueue ) /* FREERTOS_SYSTEM_CALL */
1160     {
1161         BaseType_t xReturn;
1162 
1163         if( portIS_PRIVILEGED() == pdFALSE )
1164         {
1165             portRAISE_PRIVILEGE();
1166             portMEMORY_BARRIER();
1167 
1168             xReturn = xQueueGenericReset( pxQueue, xNewQueue );
1169             portMEMORY_BARRIER();
1170 
1171             portRESET_PRIVILEGE();
1172             portMEMORY_BARRIER();
1173         }
1174         else
1175         {
1176             xReturn = xQueueGenericReset( pxQueue, xNewQueue );
1177         }
1178 
1179         return xReturn;
1180     }
1181 /*-----------------------------------------------------------*/
1182 
MPU_xQueueGenericSend(QueueHandle_t xQueue,const void * const pvItemToQueue,TickType_t xTicksToWait,BaseType_t xCopyPosition)1183     BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue,
1184                                       const void * const pvItemToQueue,
1185                                       TickType_t xTicksToWait,
1186                                       BaseType_t xCopyPosition ) /* FREERTOS_SYSTEM_CALL */
1187     {
1188         BaseType_t xReturn;
1189 
1190         if( portIS_PRIVILEGED() == pdFALSE )
1191         {
1192             portRAISE_PRIVILEGE();
1193             portMEMORY_BARRIER();
1194 
1195             xReturn = xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, xCopyPosition );
1196             portMEMORY_BARRIER();
1197 
1198             portRESET_PRIVILEGE();
1199             portMEMORY_BARRIER();
1200         }
1201         else
1202         {
1203             xReturn = xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, xCopyPosition );
1204         }
1205 
1206         return xReturn;
1207     }
1208 /*-----------------------------------------------------------*/
1209 
MPU_uxQueueMessagesWaiting(const QueueHandle_t pxQueue)1210     UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t pxQueue ) /* FREERTOS_SYSTEM_CALL */
1211     {
1212         UBaseType_t uxReturn;
1213 
1214         if( portIS_PRIVILEGED() == pdFALSE )
1215         {
1216             portRAISE_PRIVILEGE();
1217             portMEMORY_BARRIER();
1218 
1219             uxReturn = uxQueueMessagesWaiting( pxQueue );
1220             portMEMORY_BARRIER();
1221 
1222             portRESET_PRIVILEGE();
1223             portMEMORY_BARRIER();
1224         }
1225         else
1226         {
1227             uxReturn = uxQueueMessagesWaiting( pxQueue );
1228         }
1229 
1230         return uxReturn;
1231     }
1232 /*-----------------------------------------------------------*/
1233 
MPU_uxQueueSpacesAvailable(const QueueHandle_t xQueue)1234     UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */
1235     {
1236         UBaseType_t uxReturn;
1237 
1238         if( portIS_PRIVILEGED() == pdFALSE )
1239         {
1240             portRAISE_PRIVILEGE();
1241             portMEMORY_BARRIER();
1242 
1243             uxReturn = uxQueueSpacesAvailable( xQueue );
1244             portMEMORY_BARRIER();
1245 
1246             portRESET_PRIVILEGE();
1247             portMEMORY_BARRIER();
1248         }
1249         else
1250         {
1251             uxReturn = uxQueueSpacesAvailable( xQueue );
1252         }
1253 
1254         return uxReturn;
1255     }
1256 /*-----------------------------------------------------------*/
1257 
MPU_xQueueReceive(QueueHandle_t pxQueue,void * const pvBuffer,TickType_t xTicksToWait)1258     BaseType_t MPU_xQueueReceive( QueueHandle_t pxQueue,
1259                                   void * const pvBuffer,
1260                                   TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
1261     {
1262         BaseType_t xReturn;
1263 
1264         if( portIS_PRIVILEGED() == pdFALSE )
1265         {
1266             portRAISE_PRIVILEGE();
1267             portMEMORY_BARRIER();
1268 
1269             xReturn = xQueueReceive( pxQueue, pvBuffer, xTicksToWait );
1270             portMEMORY_BARRIER();
1271 
1272             portRESET_PRIVILEGE();
1273             portMEMORY_BARRIER();
1274         }
1275         else
1276         {
1277             xReturn = xQueueReceive( pxQueue, pvBuffer, xTicksToWait );
1278         }
1279 
1280         return xReturn;
1281     }
1282 /*-----------------------------------------------------------*/
1283 
MPU_xQueuePeek(QueueHandle_t xQueue,void * const pvBuffer,TickType_t xTicksToWait)1284     BaseType_t MPU_xQueuePeek( QueueHandle_t xQueue,
1285                                void * const pvBuffer,
1286                                TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
1287     {
1288         BaseType_t xReturn;
1289 
1290         if( portIS_PRIVILEGED() == pdFALSE )
1291         {
1292             portRAISE_PRIVILEGE();
1293             portMEMORY_BARRIER();
1294 
1295             xReturn = xQueuePeek( xQueue, pvBuffer, xTicksToWait );
1296             portMEMORY_BARRIER();
1297 
1298             portRESET_PRIVILEGE();
1299             portMEMORY_BARRIER();
1300         }
1301         else
1302         {
1303             xReturn = xQueuePeek( xQueue, pvBuffer, xTicksToWait );
1304         }
1305 
1306         return xReturn;
1307     }
1308 /*-----------------------------------------------------------*/
1309 
MPU_xQueueSemaphoreTake(QueueHandle_t xQueue,TickType_t xTicksToWait)1310     BaseType_t MPU_xQueueSemaphoreTake( QueueHandle_t xQueue,
1311                                         TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
1312     {
1313         BaseType_t xReturn;
1314 
1315         if( portIS_PRIVILEGED() == pdFALSE )
1316         {
1317             portRAISE_PRIVILEGE();
1318             portMEMORY_BARRIER();
1319 
1320             xReturn = xQueueSemaphoreTake( xQueue, xTicksToWait );
1321             portMEMORY_BARRIER();
1322 
1323             portRESET_PRIVILEGE();
1324             portMEMORY_BARRIER();
1325         }
1326         else
1327         {
1328             xReturn = xQueueSemaphoreTake( xQueue, xTicksToWait );
1329         }
1330 
1331         return xReturn;
1332     }
1333 /*-----------------------------------------------------------*/
1334 
1335     #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )
MPU_xQueueGetMutexHolder(QueueHandle_t xSemaphore)1336         TaskHandle_t MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ) /* FREERTOS_SYSTEM_CALL */
1337         {
1338             void * xReturn;
1339 
1340             if( portIS_PRIVILEGED() == pdFALSE )
1341             {
1342                 portRAISE_PRIVILEGE();
1343                 portMEMORY_BARRIER();
1344 
1345                 xReturn = xQueueGetMutexHolder( xSemaphore );
1346                 portMEMORY_BARRIER();
1347 
1348                 portRESET_PRIVILEGE();
1349                 portMEMORY_BARRIER();
1350             }
1351             else
1352             {
1353                 xReturn = xQueueGetMutexHolder( xSemaphore );
1354             }
1355 
1356             return xReturn;
1357         }
1358     #endif /* if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) */
1359 /*-----------------------------------------------------------*/
1360 
1361     #if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
MPU_xQueueCreateMutex(const uint8_t ucQueueType)1362         QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) /* FREERTOS_SYSTEM_CALL */
1363         {
1364             QueueHandle_t xReturn;
1365 
1366             if( portIS_PRIVILEGED() == pdFALSE )
1367             {
1368                 portRAISE_PRIVILEGE();
1369                 portMEMORY_BARRIER();
1370 
1371                 xReturn = xQueueCreateMutex( ucQueueType );
1372                 portMEMORY_BARRIER();
1373 
1374                 portRESET_PRIVILEGE();
1375                 portMEMORY_BARRIER();
1376             }
1377             else
1378             {
1379                 xReturn = xQueueCreateMutex( ucQueueType );
1380             }
1381 
1382             return xReturn;
1383         }
1384     #endif /* if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */
1385 /*-----------------------------------------------------------*/
1386 
1387     #if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
MPU_xQueueCreateMutexStatic(const uint8_t ucQueueType,StaticQueue_t * pxStaticQueue)1388         QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType,
1389                                                    StaticQueue_t * pxStaticQueue ) /* FREERTOS_SYSTEM_CALL */
1390         {
1391             QueueHandle_t xReturn;
1392 
1393             if( portIS_PRIVILEGED() == pdFALSE )
1394             {
1395                 portRAISE_PRIVILEGE();
1396                 portMEMORY_BARRIER();
1397 
1398                 xReturn = xQueueCreateMutexStatic( ucQueueType, pxStaticQueue );
1399                 portMEMORY_BARRIER();
1400 
1401                 portRESET_PRIVILEGE();
1402                 portMEMORY_BARRIER();
1403             }
1404             else
1405             {
1406                 xReturn = xQueueCreateMutexStatic( ucQueueType, pxStaticQueue );
1407             }
1408 
1409             return xReturn;
1410         }
1411     #endif /* if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) */
1412 /*-----------------------------------------------------------*/
1413 
1414     #if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
MPU_xQueueCreateCountingSemaphore(UBaseType_t uxCountValue,UBaseType_t uxInitialCount)1415         QueueHandle_t MPU_xQueueCreateCountingSemaphore( UBaseType_t uxCountValue,
1416                                                          UBaseType_t uxInitialCount ) /* FREERTOS_SYSTEM_CALL */
1417         {
1418             QueueHandle_t xReturn;
1419 
1420             if( portIS_PRIVILEGED() == pdFALSE )
1421             {
1422                 portRAISE_PRIVILEGE();
1423                 portMEMORY_BARRIER();
1424 
1425                 xReturn = xQueueCreateCountingSemaphore( uxCountValue, uxInitialCount );
1426                 portMEMORY_BARRIER();
1427 
1428                 portRESET_PRIVILEGE();
1429                 portMEMORY_BARRIER();
1430             }
1431             else
1432             {
1433                 xReturn = xQueueCreateCountingSemaphore( uxCountValue, uxInitialCount );
1434             }
1435 
1436             return xReturn;
1437         }
1438     #endif /* if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */
1439 /*-----------------------------------------------------------*/
1440 
1441     #if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
1442 
MPU_xQueueCreateCountingSemaphoreStatic(const UBaseType_t uxMaxCount,const UBaseType_t uxInitialCount,StaticQueue_t * pxStaticQueue)1443         QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
1444                                                                const UBaseType_t uxInitialCount,
1445                                                                StaticQueue_t * pxStaticQueue ) /* FREERTOS_SYSTEM_CALL */
1446         {
1447             QueueHandle_t xReturn;
1448 
1449             if( portIS_PRIVILEGED() == pdFALSE )
1450             {
1451                 portRAISE_PRIVILEGE();
1452                 portMEMORY_BARRIER();
1453 
1454                 xReturn = xQueueCreateCountingSemaphoreStatic( uxMaxCount, uxInitialCount, pxStaticQueue );
1455                 portMEMORY_BARRIER();
1456 
1457                 portRESET_PRIVILEGE();
1458                 portMEMORY_BARRIER();
1459             }
1460             else
1461             {
1462                 xReturn = xQueueCreateCountingSemaphoreStatic( uxMaxCount, uxInitialCount, pxStaticQueue );
1463             }
1464 
1465             return xReturn;
1466         }
1467     #endif /* if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) */
1468 /*-----------------------------------------------------------*/
1469 
1470     #if ( configUSE_RECURSIVE_MUTEXES == 1 )
MPU_xQueueTakeMutexRecursive(QueueHandle_t xMutex,TickType_t xBlockTime)1471         BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex,
1472                                                  TickType_t xBlockTime ) /* FREERTOS_SYSTEM_CALL */
1473         {
1474             BaseType_t xReturn;
1475 
1476             if( portIS_PRIVILEGED() == pdFALSE )
1477             {
1478                 portRAISE_PRIVILEGE();
1479                 portMEMORY_BARRIER();
1480 
1481                 xReturn = xQueueTakeMutexRecursive( xMutex, xBlockTime );
1482                 portMEMORY_BARRIER();
1483 
1484                 portRESET_PRIVILEGE();
1485                 portMEMORY_BARRIER();
1486             }
1487             else
1488             {
1489                 xReturn = xQueueTakeMutexRecursive( xMutex, xBlockTime );
1490             }
1491 
1492             return xReturn;
1493         }
1494     #endif /* if ( configUSE_RECURSIVE_MUTEXES == 1 ) */
1495 /*-----------------------------------------------------------*/
1496 
1497     #if ( configUSE_RECURSIVE_MUTEXES == 1 )
MPU_xQueueGiveMutexRecursive(QueueHandle_t xMutex)1498         BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t xMutex ) /* FREERTOS_SYSTEM_CALL */
1499         {
1500             BaseType_t xReturn;
1501 
1502             if( portIS_PRIVILEGED() == pdFALSE )
1503             {
1504                 portRAISE_PRIVILEGE();
1505                 portMEMORY_BARRIER();
1506 
1507                 xReturn = xQueueGiveMutexRecursive( xMutex );
1508                 portMEMORY_BARRIER();
1509 
1510                 portRESET_PRIVILEGE();
1511                 portMEMORY_BARRIER();
1512             }
1513             else
1514             {
1515                 xReturn = xQueueGiveMutexRecursive( xMutex );
1516             }
1517 
1518             return xReturn;
1519         }
1520     #endif /* if ( configUSE_RECURSIVE_MUTEXES == 1 ) */
1521 /*-----------------------------------------------------------*/
1522 
1523     #if ( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
MPU_xQueueCreateSet(UBaseType_t uxEventQueueLength)1524         QueueSetHandle_t MPU_xQueueCreateSet( UBaseType_t uxEventQueueLength ) /* FREERTOS_SYSTEM_CALL */
1525         {
1526             QueueSetHandle_t xReturn;
1527 
1528             if( portIS_PRIVILEGED() == pdFALSE )
1529             {
1530                 portRAISE_PRIVILEGE();
1531                 portMEMORY_BARRIER();
1532 
1533                 xReturn = xQueueCreateSet( uxEventQueueLength );
1534                 portMEMORY_BARRIER();
1535 
1536                 portRESET_PRIVILEGE();
1537                 portMEMORY_BARRIER();
1538             }
1539             else
1540             {
1541                 xReturn = xQueueCreateSet( uxEventQueueLength );
1542             }
1543 
1544             return xReturn;
1545         }
1546     #endif /* if ( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */
1547 /*-----------------------------------------------------------*/
1548 
1549     #if ( configUSE_QUEUE_SETS == 1 )
MPU_xQueueSelectFromSet(QueueSetHandle_t xQueueSet,TickType_t xBlockTimeTicks)1550         QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet,
1551                                                         TickType_t xBlockTimeTicks ) /* FREERTOS_SYSTEM_CALL */
1552         {
1553             QueueSetMemberHandle_t xReturn;
1554 
1555             if( portIS_PRIVILEGED() == pdFALSE )
1556             {
1557                 portRAISE_PRIVILEGE();
1558                 portMEMORY_BARRIER();
1559 
1560                 xReturn = xQueueSelectFromSet( xQueueSet, xBlockTimeTicks );
1561                 portMEMORY_BARRIER();
1562 
1563                 portRESET_PRIVILEGE();
1564                 portMEMORY_BARRIER();
1565             }
1566             else
1567             {
1568                 xReturn = xQueueSelectFromSet( xQueueSet, xBlockTimeTicks );
1569             }
1570 
1571             return xReturn;
1572         }
1573     #endif /* if ( configUSE_QUEUE_SETS == 1 ) */
1574 /*-----------------------------------------------------------*/
1575 
1576     #if ( configUSE_QUEUE_SETS == 1 )
MPU_xQueueAddToSet(QueueSetMemberHandle_t xQueueOrSemaphore,QueueSetHandle_t xQueueSet)1577         BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore,
1578                                        QueueSetHandle_t xQueueSet ) /* FREERTOS_SYSTEM_CALL */
1579         {
1580             BaseType_t xReturn;
1581 
1582             if( portIS_PRIVILEGED() == pdFALSE )
1583             {
1584                 portRAISE_PRIVILEGE();
1585                 portMEMORY_BARRIER();
1586 
1587                 xReturn = xQueueAddToSet( xQueueOrSemaphore, xQueueSet );
1588                 portMEMORY_BARRIER();
1589 
1590                 portRESET_PRIVILEGE();
1591                 portMEMORY_BARRIER();
1592             }
1593             else
1594             {
1595                 xReturn = xQueueAddToSet( xQueueOrSemaphore, xQueueSet );
1596             }
1597 
1598             return xReturn;
1599         }
1600     #endif /* if ( configUSE_QUEUE_SETS == 1 ) */
1601 /*-----------------------------------------------------------*/
1602 
1603     #if ( configUSE_QUEUE_SETS == 1 )
MPU_xQueueRemoveFromSet(QueueSetMemberHandle_t xQueueOrSemaphore,QueueSetHandle_t xQueueSet)1604         BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
1605                                             QueueSetHandle_t xQueueSet ) /* FREERTOS_SYSTEM_CALL */
1606         {
1607             BaseType_t xReturn;
1608 
1609             if( portIS_PRIVILEGED() == pdFALSE )
1610             {
1611                 portRAISE_PRIVILEGE();
1612                 portMEMORY_BARRIER();
1613 
1614                 xReturn = xQueueRemoveFromSet( xQueueOrSemaphore, xQueueSet );
1615                 portMEMORY_BARRIER();
1616 
1617                 portRESET_PRIVILEGE();
1618                 portMEMORY_BARRIER();
1619             }
1620             else
1621             {
1622                 xReturn = xQueueRemoveFromSet( xQueueOrSemaphore, xQueueSet );
1623             }
1624 
1625             return xReturn;
1626         }
1627     #endif /* if ( configUSE_QUEUE_SETS == 1 ) */
1628 /*-----------------------------------------------------------*/
1629 
1630     #if configQUEUE_REGISTRY_SIZE > 0
MPU_vQueueAddToRegistry(QueueHandle_t xQueue,const char * pcName)1631         void MPU_vQueueAddToRegistry( QueueHandle_t xQueue,
1632                                       const char * pcName ) /* FREERTOS_SYSTEM_CALL */
1633         {
1634             if( portIS_PRIVILEGED() == pdFALSE )
1635             {
1636                 portRAISE_PRIVILEGE();
1637                 portMEMORY_BARRIER();
1638 
1639                 vQueueAddToRegistry( xQueue, pcName );
1640                 portMEMORY_BARRIER();
1641 
1642                 portRESET_PRIVILEGE();
1643                 portMEMORY_BARRIER();
1644             }
1645             else
1646             {
1647                 vQueueAddToRegistry( xQueue, pcName );
1648             }
1649         }
1650     #endif /* if configQUEUE_REGISTRY_SIZE > 0 */
1651 /*-----------------------------------------------------------*/
1652 
1653     #if configQUEUE_REGISTRY_SIZE > 0
MPU_vQueueUnregisterQueue(QueueHandle_t xQueue)1654         void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */
1655         {
1656             if( portIS_PRIVILEGED() == pdFALSE )
1657             {
1658                 portRAISE_PRIVILEGE();
1659                 portMEMORY_BARRIER();
1660 
1661                 vQueueUnregisterQueue( xQueue );
1662                 portMEMORY_BARRIER();
1663 
1664                 portRESET_PRIVILEGE();
1665                 portMEMORY_BARRIER();
1666             }
1667             else
1668             {
1669                 vQueueUnregisterQueue( xQueue );
1670             }
1671         }
1672     #endif /* if configQUEUE_REGISTRY_SIZE > 0 */
1673 /*-----------------------------------------------------------*/
1674 
1675     #if configQUEUE_REGISTRY_SIZE > 0
MPU_pcQueueGetName(QueueHandle_t xQueue)1676         const char * MPU_pcQueueGetName( QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */
1677         {
1678             const char * pcReturn;
1679 
1680             if( portIS_PRIVILEGED() == pdFALSE )
1681             {
1682                 portRAISE_PRIVILEGE();
1683                 portMEMORY_BARRIER();
1684 
1685                 pcReturn = pcQueueGetName( xQueue );
1686                 portMEMORY_BARRIER();
1687 
1688                 portRESET_PRIVILEGE();
1689                 portMEMORY_BARRIER();
1690             }
1691             else
1692             {
1693                 pcReturn = pcQueueGetName( xQueue );
1694             }
1695 
1696             return pcReturn;
1697         }
1698     #endif /* if configQUEUE_REGISTRY_SIZE > 0 */
1699 /*-----------------------------------------------------------*/
1700 
MPU_vQueueDelete(QueueHandle_t xQueue)1701     void MPU_vQueueDelete( QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */
1702     {
1703         if( portIS_PRIVILEGED() == pdFALSE )
1704         {
1705             portRAISE_PRIVILEGE();
1706             portMEMORY_BARRIER();
1707 
1708             vQueueDelete( xQueue );
1709             portMEMORY_BARRIER();
1710 
1711             portRESET_PRIVILEGE();
1712             portMEMORY_BARRIER();
1713         }
1714         else
1715         {
1716             vQueueDelete( xQueue );
1717         }
1718     }
1719 /*-----------------------------------------------------------*/
1720 
1721     #if ( configUSE_TIMERS == 1 )
MPU_pvTimerGetTimerID(const TimerHandle_t xTimer)1722         void * MPU_pvTimerGetTimerID( const TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */
1723         {
1724             void * pvReturn;
1725 
1726             if( portIS_PRIVILEGED() == pdFALSE )
1727             {
1728                 portRAISE_PRIVILEGE();
1729                 portMEMORY_BARRIER();
1730 
1731                 pvReturn = pvTimerGetTimerID( xTimer );
1732                 portMEMORY_BARRIER();
1733 
1734                 portRESET_PRIVILEGE();
1735                 portMEMORY_BARRIER();
1736             }
1737             else
1738             {
1739                 pvReturn = pvTimerGetTimerID( xTimer );
1740             }
1741 
1742             return pvReturn;
1743         }
1744     #endif /* if ( configUSE_TIMERS == 1 ) */
1745 /*-----------------------------------------------------------*/
1746 
1747     #if ( configUSE_TIMERS == 1 )
MPU_vTimerSetTimerID(TimerHandle_t xTimer,void * pvNewID)1748         void MPU_vTimerSetTimerID( TimerHandle_t xTimer,
1749                                    void * pvNewID ) /* FREERTOS_SYSTEM_CALL */
1750         {
1751             if( portIS_PRIVILEGED() == pdFALSE )
1752             {
1753                 portRAISE_PRIVILEGE();
1754                 portMEMORY_BARRIER();
1755 
1756                 vTimerSetTimerID( xTimer, pvNewID );
1757                 portMEMORY_BARRIER();
1758 
1759                 portRESET_PRIVILEGE();
1760                 portMEMORY_BARRIER();
1761             }
1762             else
1763             {
1764                 vTimerSetTimerID( xTimer, pvNewID );
1765             }
1766         }
1767     #endif /* if ( configUSE_TIMERS == 1 ) */
1768 /*-----------------------------------------------------------*/
1769 
1770     #if ( configUSE_TIMERS == 1 )
MPU_xTimerIsTimerActive(TimerHandle_t xTimer)1771         BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */
1772         {
1773             BaseType_t xReturn;
1774 
1775             if( portIS_PRIVILEGED() == pdFALSE )
1776             {
1777                 portRAISE_PRIVILEGE();
1778                 portMEMORY_BARRIER();
1779 
1780                 xReturn = xTimerIsTimerActive( xTimer );
1781                 portMEMORY_BARRIER();
1782 
1783                 portRESET_PRIVILEGE();
1784                 portMEMORY_BARRIER();
1785             }
1786             else
1787             {
1788                 xReturn = xTimerIsTimerActive( xTimer );
1789             }
1790 
1791             return xReturn;
1792         }
1793     #endif /* if ( configUSE_TIMERS == 1 ) */
1794 /*-----------------------------------------------------------*/
1795 
1796     #if ( configUSE_TIMERS == 1 )
MPU_xTimerGetTimerDaemonTaskHandle(void)1797         TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void ) /* FREERTOS_SYSTEM_CALL */
1798         {
1799             TaskHandle_t xReturn;
1800 
1801             if( portIS_PRIVILEGED() == pdFALSE )
1802             {
1803                 portRAISE_PRIVILEGE();
1804                 portMEMORY_BARRIER();
1805 
1806                 xReturn = xTimerGetTimerDaemonTaskHandle();
1807                 portMEMORY_BARRIER();
1808 
1809                 portRESET_PRIVILEGE();
1810                 portMEMORY_BARRIER();
1811             }
1812             else
1813             {
1814                 xReturn = xTimerGetTimerDaemonTaskHandle();
1815             }
1816 
1817             return xReturn;
1818         }
1819     #endif /* if ( configUSE_TIMERS == 1 ) */
1820 /*-----------------------------------------------------------*/
1821 
1822     #if ( configUSE_TIMERS == 1 )
MPU_vTimerSetReloadMode(TimerHandle_t xTimer,const BaseType_t uxAutoReload)1823         void MPU_vTimerSetReloadMode( TimerHandle_t xTimer,
1824                                       const BaseType_t uxAutoReload ) /* FREERTOS_SYSTEM_CALL */
1825         {
1826             if( portIS_PRIVILEGED() == pdFALSE )
1827             {
1828                 portRAISE_PRIVILEGE();
1829                 portMEMORY_BARRIER();
1830 
1831                 vTimerSetReloadMode( xTimer, uxAutoReload );
1832                 portMEMORY_BARRIER();
1833 
1834                 portRESET_PRIVILEGE();
1835                 portMEMORY_BARRIER();
1836             }
1837             else
1838             {
1839                 vTimerSetReloadMode( xTimer, uxAutoReload );
1840             }
1841         }
1842     #endif /* if ( configUSE_TIMERS == 1 ) */
1843 /*-----------------------------------------------------------*/
1844 
1845     #if ( configUSE_TIMERS == 1 )
MPU_uxTimerGetReloadMode(TimerHandle_t xTimer)1846         UBaseType_t MPU_uxTimerGetReloadMode( TimerHandle_t xTimer )
1847         {
1848             UBaseType_t uxReturn;
1849 
1850             if( portIS_PRIVILEGED() == pdFALSE )
1851             {
1852                 portRAISE_PRIVILEGE();
1853                 portMEMORY_BARRIER();
1854 
1855                 uxReturn = uxTimerGetReloadMode( xTimer );
1856                 portMEMORY_BARRIER();
1857 
1858                 portRESET_PRIVILEGE();
1859                 portMEMORY_BARRIER();
1860             }
1861             else
1862             {
1863                 uxReturn = uxTimerGetReloadMode( xTimer );
1864             }
1865 
1866             return uxReturn;
1867         }
1868     #endif /* if ( configUSE_TIMERS == 1 ) */
1869 /*-----------------------------------------------------------*/
1870 
1871     #if ( configUSE_TIMERS == 1 )
MPU_pcTimerGetName(TimerHandle_t xTimer)1872         const char * MPU_pcTimerGetName( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */
1873         {
1874             const char * pcReturn;
1875 
1876             if( portIS_PRIVILEGED() == pdFALSE )
1877             {
1878                 portRAISE_PRIVILEGE();
1879                 portMEMORY_BARRIER();
1880 
1881                 pcReturn = pcTimerGetName( xTimer );
1882                 portMEMORY_BARRIER();
1883 
1884                 portRESET_PRIVILEGE();
1885                 portMEMORY_BARRIER();
1886             }
1887             else
1888             {
1889                 pcReturn = pcTimerGetName( xTimer );
1890             }
1891 
1892             return pcReturn;
1893         }
1894     #endif /* if ( configUSE_TIMERS == 1 ) */
1895 /*-----------------------------------------------------------*/
1896 
1897     #if ( configUSE_TIMERS == 1 )
MPU_xTimerGetPeriod(TimerHandle_t xTimer)1898         TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */
1899         {
1900             TickType_t xReturn;
1901 
1902             if( portIS_PRIVILEGED() == pdFALSE )
1903             {
1904                 portRAISE_PRIVILEGE();
1905                 portMEMORY_BARRIER();
1906 
1907                 xReturn = xTimerGetPeriod( xTimer );
1908                 portMEMORY_BARRIER();
1909 
1910                 portRESET_PRIVILEGE();
1911                 portMEMORY_BARRIER();
1912             }
1913             else
1914             {
1915                 xReturn = xTimerGetPeriod( xTimer );
1916             }
1917 
1918             return xReturn;
1919         }
1920     #endif /* if ( configUSE_TIMERS == 1 ) */
1921 /*-----------------------------------------------------------*/
1922 
1923     #if ( configUSE_TIMERS == 1 )
MPU_xTimerGetExpiryTime(TimerHandle_t xTimer)1924         TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */
1925         {
1926             TickType_t xReturn;
1927 
1928             if( portIS_PRIVILEGED() == pdFALSE )
1929             {
1930                 portRAISE_PRIVILEGE();
1931                 portMEMORY_BARRIER();
1932 
1933                 xReturn = xTimerGetExpiryTime( xTimer );
1934                 portMEMORY_BARRIER();
1935 
1936                 portRESET_PRIVILEGE();
1937                 portMEMORY_BARRIER();
1938             }
1939             else
1940             {
1941                 xReturn = xTimerGetExpiryTime( xTimer );
1942             }
1943 
1944             return xReturn;
1945         }
1946     #endif /* if ( configUSE_TIMERS == 1 ) */
1947 /*-----------------------------------------------------------*/
1948 
1949     #if ( configUSE_TIMERS == 1 )
MPU_xTimerGenericCommand(TimerHandle_t xTimer,const BaseType_t xCommandID,const TickType_t xOptionalValue,BaseType_t * const pxHigherPriorityTaskWoken,const TickType_t xTicksToWait)1950         BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer,
1951                                              const BaseType_t xCommandID,
1952                                              const TickType_t xOptionalValue,
1953                                              BaseType_t * const pxHigherPriorityTaskWoken,
1954                                              const TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
1955         {
1956             BaseType_t xReturn;
1957 
1958             if( portIS_PRIVILEGED() == pdFALSE )
1959             {
1960                 portRAISE_PRIVILEGE();
1961                 portMEMORY_BARRIER();
1962 
1963                 xReturn = xTimerGenericCommand( xTimer, xCommandID, xOptionalValue, pxHigherPriorityTaskWoken, xTicksToWait );
1964                 portMEMORY_BARRIER();
1965 
1966                 portRESET_PRIVILEGE();
1967                 portMEMORY_BARRIER();
1968             }
1969             else
1970             {
1971                 xReturn = xTimerGenericCommand( xTimer, xCommandID, xOptionalValue, pxHigherPriorityTaskWoken, xTicksToWait );
1972             }
1973 
1974             return xReturn;
1975         }
1976     #endif /* if ( configUSE_TIMERS == 1 ) */
1977 /*-----------------------------------------------------------*/
1978 
1979     #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
MPU_xEventGroupCreate(void)1980         EventGroupHandle_t MPU_xEventGroupCreate( void ) /* FREERTOS_SYSTEM_CALL */
1981         {
1982             EventGroupHandle_t xReturn;
1983 
1984             if( portIS_PRIVILEGED() == pdFALSE )
1985             {
1986                 portRAISE_PRIVILEGE();
1987                 portMEMORY_BARRIER();
1988 
1989                 xReturn = xEventGroupCreate();
1990                 portMEMORY_BARRIER();
1991 
1992                 portRESET_PRIVILEGE();
1993                 portMEMORY_BARRIER();
1994             }
1995             else
1996             {
1997                 xReturn = xEventGroupCreate();
1998             }
1999 
2000             return xReturn;
2001         }
2002     #endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) */
2003 /*-----------------------------------------------------------*/
2004 
2005     #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
MPU_xEventGroupCreateStatic(StaticEventGroup_t * pxEventGroupBuffer)2006         EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) /* FREERTOS_SYSTEM_CALL */
2007         {
2008             EventGroupHandle_t xReturn;
2009 
2010             if( portIS_PRIVILEGED() == pdFALSE )
2011             {
2012                 portRAISE_PRIVILEGE();
2013                 portMEMORY_BARRIER();
2014 
2015                 xReturn = xEventGroupCreateStatic( pxEventGroupBuffer );
2016                 portMEMORY_BARRIER();
2017 
2018                 portRESET_PRIVILEGE();
2019                 portMEMORY_BARRIER();
2020             }
2021             else
2022             {
2023                 xReturn = xEventGroupCreateStatic( pxEventGroupBuffer );
2024             }
2025 
2026             return xReturn;
2027         }
2028     #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
2029 /*-----------------------------------------------------------*/
2030 
MPU_xEventGroupWaitBits(EventGroupHandle_t xEventGroup,const EventBits_t uxBitsToWaitFor,const BaseType_t xClearOnExit,const BaseType_t xWaitForAllBits,TickType_t xTicksToWait)2031     EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
2032                                          const EventBits_t uxBitsToWaitFor,
2033                                          const BaseType_t xClearOnExit,
2034                                          const BaseType_t xWaitForAllBits,
2035                                          TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
2036     {
2037         EventBits_t xReturn;
2038 
2039         if( portIS_PRIVILEGED() == pdFALSE )
2040         {
2041             portRAISE_PRIVILEGE();
2042             portMEMORY_BARRIER();
2043 
2044             xReturn = xEventGroupWaitBits( xEventGroup, uxBitsToWaitFor, xClearOnExit, xWaitForAllBits, xTicksToWait );
2045             portMEMORY_BARRIER();
2046 
2047             portRESET_PRIVILEGE();
2048             portMEMORY_BARRIER();
2049         }
2050         else
2051         {
2052             xReturn = xEventGroupWaitBits( xEventGroup, uxBitsToWaitFor, xClearOnExit, xWaitForAllBits, xTicksToWait );
2053         }
2054 
2055         return xReturn;
2056     }
2057 /*-----------------------------------------------------------*/
2058 
MPU_xEventGroupClearBits(EventGroupHandle_t xEventGroup,const EventBits_t uxBitsToClear)2059     EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup,
2060                                           const EventBits_t uxBitsToClear ) /* FREERTOS_SYSTEM_CALL */
2061     {
2062         EventBits_t xReturn;
2063 
2064         if( portIS_PRIVILEGED() == pdFALSE )
2065         {
2066             portRAISE_PRIVILEGE();
2067             portMEMORY_BARRIER();
2068 
2069             xReturn = xEventGroupClearBits( xEventGroup, uxBitsToClear );
2070             portMEMORY_BARRIER();
2071 
2072             portRESET_PRIVILEGE();
2073             portMEMORY_BARRIER();
2074         }
2075         else
2076         {
2077             xReturn = xEventGroupClearBits( xEventGroup, uxBitsToClear );
2078         }
2079 
2080         return xReturn;
2081     }
2082 /*-----------------------------------------------------------*/
2083 
MPU_xEventGroupSetBits(EventGroupHandle_t xEventGroup,const EventBits_t uxBitsToSet)2084     EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup,
2085                                         const EventBits_t uxBitsToSet ) /* FREERTOS_SYSTEM_CALL */
2086     {
2087         EventBits_t xReturn;
2088 
2089         if( portIS_PRIVILEGED() == pdFALSE )
2090         {
2091             portRAISE_PRIVILEGE();
2092             portMEMORY_BARRIER();
2093 
2094             xReturn = xEventGroupSetBits( xEventGroup, uxBitsToSet );
2095             portMEMORY_BARRIER();
2096 
2097             portRESET_PRIVILEGE();
2098             portMEMORY_BARRIER();
2099         }
2100         else
2101         {
2102             xReturn = xEventGroupSetBits( xEventGroup, uxBitsToSet );
2103         }
2104 
2105         return xReturn;
2106     }
2107 /*-----------------------------------------------------------*/
2108 
MPU_xEventGroupSync(EventGroupHandle_t xEventGroup,const EventBits_t uxBitsToSet,const EventBits_t uxBitsToWaitFor,TickType_t xTicksToWait)2109     EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup,
2110                                      const EventBits_t uxBitsToSet,
2111                                      const EventBits_t uxBitsToWaitFor,
2112                                      TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
2113     {
2114         EventBits_t xReturn;
2115 
2116         if( portIS_PRIVILEGED() == pdFALSE )
2117         {
2118             portRAISE_PRIVILEGE();
2119             portMEMORY_BARRIER();
2120 
2121             xReturn = xEventGroupSync( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTicksToWait );
2122             portMEMORY_BARRIER();
2123 
2124             portRESET_PRIVILEGE();
2125             portMEMORY_BARRIER();
2126         }
2127         else
2128         {
2129             xReturn = xEventGroupSync( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTicksToWait );
2130         }
2131 
2132         return xReturn;
2133     }
2134 /*-----------------------------------------------------------*/
2135 
MPU_vEventGroupDelete(EventGroupHandle_t xEventGroup)2136     void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) /* FREERTOS_SYSTEM_CALL */
2137     {
2138         if( portIS_PRIVILEGED() == pdFALSE )
2139         {
2140             portRAISE_PRIVILEGE();
2141             portMEMORY_BARRIER();
2142 
2143             vEventGroupDelete( xEventGroup );
2144             portMEMORY_BARRIER();
2145 
2146             portRESET_PRIVILEGE();
2147             portMEMORY_BARRIER();
2148         }
2149         else
2150         {
2151             vEventGroupDelete( xEventGroup );
2152         }
2153     }
2154 /*-----------------------------------------------------------*/
2155 
MPU_xStreamBufferSend(StreamBufferHandle_t xStreamBuffer,const void * pvTxData,size_t xDataLengthBytes,TickType_t xTicksToWait)2156     size_t MPU_xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
2157                                   const void * pvTxData,
2158                                   size_t xDataLengthBytes,
2159                                   TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
2160     {
2161         size_t xReturn;
2162 
2163         if( portIS_PRIVILEGED() == pdFALSE )
2164         {
2165             portRAISE_PRIVILEGE();
2166             portMEMORY_BARRIER();
2167 
2168             xReturn = xStreamBufferSend( xStreamBuffer, pvTxData, xDataLengthBytes, xTicksToWait );
2169             portMEMORY_BARRIER();
2170 
2171             portRESET_PRIVILEGE();
2172             portMEMORY_BARRIER();
2173         }
2174         else
2175         {
2176             xReturn = xStreamBufferSend( xStreamBuffer, pvTxData, xDataLengthBytes, xTicksToWait );
2177         }
2178 
2179         return xReturn;
2180     }
2181 /*-----------------------------------------------------------*/
2182 
MPU_xStreamBufferNextMessageLengthBytes(StreamBufferHandle_t xStreamBuffer)2183     size_t MPU_xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
2184     {
2185         size_t xReturn;
2186 
2187         if( portIS_PRIVILEGED() == pdFALSE )
2188         {
2189             portRAISE_PRIVILEGE();
2190             portMEMORY_BARRIER();
2191 
2192             xReturn = xStreamBufferNextMessageLengthBytes( xStreamBuffer );
2193             portMEMORY_BARRIER();
2194 
2195             portRESET_PRIVILEGE();
2196             portMEMORY_BARRIER();
2197         }
2198         else
2199         {
2200             xReturn = xStreamBufferNextMessageLengthBytes( xStreamBuffer );
2201         }
2202 
2203         return xReturn;
2204     }
2205 /*-----------------------------------------------------------*/
2206 
MPU_xStreamBufferReceive(StreamBufferHandle_t xStreamBuffer,void * pvRxData,size_t xBufferLengthBytes,TickType_t xTicksToWait)2207     size_t MPU_xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer,
2208                                      void * pvRxData,
2209                                      size_t xBufferLengthBytes,
2210                                      TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
2211     {
2212         size_t xReturn;
2213 
2214         if( portIS_PRIVILEGED() == pdFALSE )
2215         {
2216             portRAISE_PRIVILEGE();
2217             portMEMORY_BARRIER();
2218 
2219             xReturn = xStreamBufferReceive( xStreamBuffer, pvRxData, xBufferLengthBytes, xTicksToWait );
2220             portMEMORY_BARRIER();
2221 
2222             portRESET_PRIVILEGE();
2223             portMEMORY_BARRIER();
2224         }
2225         else
2226         {
2227             xReturn = xStreamBufferReceive( xStreamBuffer, pvRxData, xBufferLengthBytes, xTicksToWait );
2228         }
2229 
2230         return xReturn;
2231     }
2232 /*-----------------------------------------------------------*/
2233 
MPU_vStreamBufferDelete(StreamBufferHandle_t xStreamBuffer)2234     void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
2235     {
2236         if( portIS_PRIVILEGED() == pdFALSE )
2237         {
2238             portRAISE_PRIVILEGE();
2239             portMEMORY_BARRIER();
2240 
2241             vStreamBufferDelete( xStreamBuffer );
2242             portMEMORY_BARRIER();
2243 
2244             portRESET_PRIVILEGE();
2245             portMEMORY_BARRIER();
2246         }
2247         else
2248         {
2249             vStreamBufferDelete( xStreamBuffer );
2250         }
2251     }
2252 /*-----------------------------------------------------------*/
2253 
MPU_xStreamBufferIsFull(StreamBufferHandle_t xStreamBuffer)2254     BaseType_t MPU_xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
2255     {
2256         BaseType_t xReturn;
2257 
2258         if( portIS_PRIVILEGED() == pdFALSE )
2259         {
2260             portRAISE_PRIVILEGE();
2261             portMEMORY_BARRIER();
2262 
2263             xReturn = xStreamBufferIsFull( xStreamBuffer );
2264             portMEMORY_BARRIER();
2265 
2266             portRESET_PRIVILEGE();
2267             portMEMORY_BARRIER();
2268         }
2269         else
2270         {
2271             xReturn = xStreamBufferIsFull( xStreamBuffer );
2272         }
2273 
2274         return xReturn;
2275     }
2276 /*-----------------------------------------------------------*/
2277 
MPU_xStreamBufferIsEmpty(StreamBufferHandle_t xStreamBuffer)2278     BaseType_t MPU_xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
2279     {
2280         BaseType_t xReturn;
2281 
2282         if( portIS_PRIVILEGED() == pdFALSE )
2283         {
2284             portRAISE_PRIVILEGE();
2285             portMEMORY_BARRIER();
2286 
2287             xReturn = xStreamBufferIsEmpty( xStreamBuffer );
2288             portMEMORY_BARRIER();
2289 
2290             portRESET_PRIVILEGE();
2291             portMEMORY_BARRIER();
2292         }
2293         else
2294         {
2295             xReturn = xStreamBufferIsEmpty( xStreamBuffer );
2296         }
2297 
2298         return xReturn;
2299     }
2300 /*-----------------------------------------------------------*/
2301 
MPU_xStreamBufferReset(StreamBufferHandle_t xStreamBuffer)2302     BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
2303     {
2304         BaseType_t xReturn;
2305 
2306         if( portIS_PRIVILEGED() == pdFALSE )
2307         {
2308             portRAISE_PRIVILEGE();
2309             portMEMORY_BARRIER();
2310 
2311             xReturn = xStreamBufferReset( xStreamBuffer );
2312             portMEMORY_BARRIER();
2313 
2314             portRESET_PRIVILEGE();
2315             portMEMORY_BARRIER();
2316         }
2317         else
2318         {
2319             xReturn = xStreamBufferReset( xStreamBuffer );
2320         }
2321 
2322         return xReturn;
2323     }
2324 /*-----------------------------------------------------------*/
2325 
MPU_xStreamBufferSpacesAvailable(StreamBufferHandle_t xStreamBuffer)2326     size_t MPU_xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
2327     {
2328         size_t xReturn;
2329 
2330         if( portIS_PRIVILEGED() == pdFALSE )
2331         {
2332             portRAISE_PRIVILEGE();
2333             portMEMORY_BARRIER();
2334             xReturn = xStreamBufferSpacesAvailable( xStreamBuffer );
2335             portMEMORY_BARRIER();
2336 
2337             portRESET_PRIVILEGE();
2338             portMEMORY_BARRIER();
2339         }
2340         else
2341         {
2342             xReturn = xStreamBufferSpacesAvailable( xStreamBuffer );
2343         }
2344 
2345         return xReturn;
2346     }
2347 /*-----------------------------------------------------------*/
2348 
MPU_xStreamBufferBytesAvailable(StreamBufferHandle_t xStreamBuffer)2349     size_t MPU_xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
2350     {
2351         size_t xReturn;
2352 
2353         if( portIS_PRIVILEGED() == pdFALSE )
2354         {
2355             portRAISE_PRIVILEGE();
2356             portMEMORY_BARRIER();
2357 
2358             xReturn = xStreamBufferBytesAvailable( xStreamBuffer );
2359             portMEMORY_BARRIER();
2360 
2361             portRESET_PRIVILEGE();
2362             portMEMORY_BARRIER();
2363         }
2364         else
2365         {
2366             xReturn = xStreamBufferBytesAvailable( xStreamBuffer );
2367         }
2368 
2369         return xReturn;
2370     }
2371 /*-----------------------------------------------------------*/
2372 
MPU_xStreamBufferSetTriggerLevel(StreamBufferHandle_t xStreamBuffer,size_t xTriggerLevel)2373     BaseType_t MPU_xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer,
2374                                                  size_t xTriggerLevel ) /* FREERTOS_SYSTEM_CALL */
2375     {
2376         BaseType_t xReturn;
2377 
2378         if( portIS_PRIVILEGED() == pdFALSE )
2379         {
2380             portRAISE_PRIVILEGE();
2381             portMEMORY_BARRIER();
2382 
2383             xReturn = xStreamBufferSetTriggerLevel( xStreamBuffer, xTriggerLevel );
2384             portMEMORY_BARRIER();
2385 
2386             portRESET_PRIVILEGE();
2387             portMEMORY_BARRIER();
2388         }
2389         else
2390         {
2391             xReturn = xStreamBufferSetTriggerLevel( xStreamBuffer, xTriggerLevel );
2392         }
2393 
2394         return xReturn;
2395     }
2396 /*-----------------------------------------------------------*/
2397 
2398     #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
MPU_xStreamBufferGenericCreate(size_t xBufferSizeBytes,size_t xTriggerLevelBytes,BaseType_t xIsMessageBuffer,StreamBufferCallbackFunction_t pxSendCompletedCallback,StreamBufferCallbackFunction_t pxReceiveCompletedCallback)2399         StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes,
2400                                                              size_t xTriggerLevelBytes,
2401                                                              BaseType_t xIsMessageBuffer,
2402                                                              StreamBufferCallbackFunction_t pxSendCompletedCallback,
2403                                                              StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) /* FREERTOS_SYSTEM_CALL */
2404         {
2405             StreamBufferHandle_t xReturn;
2406 
2407             /**
2408              * Streambuffer application level callback functionality is disabled for MPU
2409              * enabled ports.
2410              */
2411             configASSERT( ( pxSendCompletedCallback == NULL ) &&
2412                           ( pxReceiveCompletedCallback == NULL ) );
2413 
2414             if( ( pxSendCompletedCallback == NULL ) &&
2415                 ( pxReceiveCompletedCallback == NULL ) )
2416             {
2417                 if( portIS_PRIVILEGED() == pdFALSE )
2418                 {
2419                     portRAISE_PRIVILEGE();
2420                     portMEMORY_BARRIER();
2421 
2422                     xReturn = xStreamBufferGenericCreate( xBufferSizeBytes,
2423                                                           xTriggerLevelBytes,
2424                                                           xIsMessageBuffer,
2425                                                           NULL,
2426                                                           NULL );
2427                     portMEMORY_BARRIER();
2428 
2429                     portRESET_PRIVILEGE();
2430                     portMEMORY_BARRIER();
2431                 }
2432                 else
2433                 {
2434                     xReturn = xStreamBufferGenericCreate( xBufferSizeBytes,
2435                                                           xTriggerLevelBytes,
2436                                                           xIsMessageBuffer,
2437                                                           NULL,
2438                                                           NULL );
2439                 }
2440             }
2441             else
2442             {
2443                 traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer );
2444                 xReturn = NULL;
2445             }
2446 
2447             return xReturn;
2448         }
2449     #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
2450 /*-----------------------------------------------------------*/
2451 
2452     #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
MPU_xStreamBufferGenericCreateStatic(size_t xBufferSizeBytes,size_t xTriggerLevelBytes,BaseType_t xIsMessageBuffer,uint8_t * const pucStreamBufferStorageArea,StaticStreamBuffer_t * const pxStaticStreamBuffer,StreamBufferCallbackFunction_t pxSendCompletedCallback,StreamBufferCallbackFunction_t pxReceiveCompletedCallback)2453         StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
2454                                                                    size_t xTriggerLevelBytes,
2455                                                                    BaseType_t xIsMessageBuffer,
2456                                                                    uint8_t * const pucStreamBufferStorageArea,
2457                                                                    StaticStreamBuffer_t * const pxStaticStreamBuffer,
2458                                                                    StreamBufferCallbackFunction_t pxSendCompletedCallback,
2459                                                                    StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) /* FREERTOS_SYSTEM_CALL */
2460         {
2461             StreamBufferHandle_t xReturn;
2462 
2463             /**
2464              * Streambuffer application level callback functionality is disabled for MPU
2465              * enabled ports.
2466              */
2467             configASSERT( ( pxSendCompletedCallback == NULL ) &&
2468                           ( pxReceiveCompletedCallback == NULL ) );
2469 
2470             if( ( pxSendCompletedCallback == NULL ) &&
2471                 ( pxReceiveCompletedCallback == NULL ) )
2472             {
2473                 if( portIS_PRIVILEGED() == pdFALSE )
2474                 {
2475                     portRAISE_PRIVILEGE();
2476                     portMEMORY_BARRIER();
2477 
2478                     xReturn = xStreamBufferGenericCreateStatic( xBufferSizeBytes,
2479                                                                 xTriggerLevelBytes,
2480                                                                 xIsMessageBuffer,
2481                                                                 pucStreamBufferStorageArea,
2482                                                                 pxStaticStreamBuffer,
2483                                                                 NULL,
2484                                                                 NULL );
2485                     portMEMORY_BARRIER();
2486 
2487                     portRESET_PRIVILEGE();
2488                     portMEMORY_BARRIER();
2489                 }
2490                 else
2491                 {
2492                     xReturn = xStreamBufferGenericCreateStatic( xBufferSizeBytes,
2493                                                                 xTriggerLevelBytes,
2494                                                                 xIsMessageBuffer,
2495                                                                 pucStreamBufferStorageArea,
2496                                                                 pxStaticStreamBuffer,
2497                                                                 NULL,
2498                                                                 NULL );
2499                 }
2500             }
2501             else
2502             {
2503                 traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer );
2504                 xReturn = NULL;
2505             }
2506 
2507             return xReturn;
2508         }
2509     #endif /* configSUPPORT_STATIC_ALLOCATION */
2510 /*-----------------------------------------------------------*/
2511 
2512 
2513 /* Functions that the application writer wants to execute in privileged mode
2514  * can be defined in application_defined_privileged_functions.h.  The functions
2515  * must take the same format as those above whereby the privilege state on exit
2516  * equals the privilege state on entry.  For example:
2517  *
2518  * void MPU_FunctionName( [parameters ] ) FREERTOS_SYSTEM_CALL;
2519  * void MPU_FunctionName( [parameters ] )
2520  * {
2521  *      if( portIS_PRIVILEGED() == pdFALSE )
2522  *      {
2523  *          portRAISE_PRIVILEGE();
2524  *          portMEMORY_BARRIER();
2525  *
2526  *          FunctionName( [parameters ] );
2527  *          portMEMORY_BARRIER();
2528  *
2529  *          portRESET_PRIVILEGE();
2530  *          portMEMORY_BARRIER();
2531  *      }
2532  *      else
2533  *      {
2534  *          FunctionName( [parameters ] );
2535  *      }
2536  * }
2537  */
2538 
2539     #if configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS == 1
2540         #include "application_defined_privileged_functions.h"
2541     #endif
2542 /*-----------------------------------------------------------*/
2543 
2544 #endif /* #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 1 ) ) */
2545 /*-----------------------------------------------------------*/
2546