]> begriffs open source - cmsis-freertos/blob - Source/portable/Common/mpu_wrappers.c
Update cmsis_os2.c
[cmsis-freertos] / Source / portable / Common / mpu_wrappers.c
1 /*
2     FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
3     All rights reserved
4
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
6
7     This file is part of the FreeRTOS distribution.
8
9     FreeRTOS is free software; you can redistribute it and/or modify it under
10     the terms of the GNU General Public License (version 2) as published by the
11     Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
12
13     ***************************************************************************
14     >>!   NOTE: The modification to the GPL is included to allow you to     !<<
15     >>!   distribute a combined work that includes FreeRTOS without being   !<<
16     >>!   obliged to provide the source code for proprietary components     !<<
17     >>!   outside of the FreeRTOS kernel.                                   !<<
18     ***************************************************************************
19
20     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
21     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22     FOR A PARTICULAR PURPOSE.  Full license text is available on the following
23     link: http://www.freertos.org/a00114.html
24
25     ***************************************************************************
26      *                                                                       *
27      *    FreeRTOS provides completely free yet professionally developed,    *
28      *    robust, strictly quality controlled, supported, and cross          *
29      *    platform software that is more than just the market leader, it     *
30      *    is the industry's de facto standard.                               *
31      *                                                                       *
32      *    Help yourself get started quickly while simultaneously helping     *
33      *    to support the FreeRTOS project by purchasing a FreeRTOS           *
34      *    tutorial book, reference manual, or both:                          *
35      *    http://www.FreeRTOS.org/Documentation                              *
36      *                                                                       *
37     ***************************************************************************
38
39     http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading
40     the FAQ page "My application does not run, what could be wrong?".  Have you
41     defined configASSERT()?
42
43     http://www.FreeRTOS.org/support - In return for receiving this top quality
44     embedded software for free we request you assist our global community by
45     participating in the support forum.
46
47     http://www.FreeRTOS.org/training - Investing in training allows your team to
48     be as productive as possible as early as possible.  Now you can receive
49     FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
50     Ltd, and the world's leading authority on the world's leading RTOS.
51
52     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
53     including FreeRTOS+Trace - an indispensable productivity tool, a DOS
54     compatible FAT file system, and our tiny thread aware UDP/IP stack.
55
56     http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
57     Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
58
59     http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
60     Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS
61     licenses offer ticketed support, indemnification and commercial middleware.
62
63     http://www.SafeRTOS.com - High Integrity Systems also provide a safety
64     engineered and independently SIL3 certified version for use in safety and
65     mission critical applications that require provable dependability.
66
67     1 tab == 4 spaces!
68 */
69
70 /*
71  * Implementation of the wrapper functions used to raise the processor privilege
72  * before calling a standard FreeRTOS API function.
73  */
74
75 /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
76 all the API functions to use the MPU wrappers.  That should only be done when
77 task.h is included from an application file. */
78 #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
79
80 /* Scheduler includes. */
81 #include "FreeRTOS.h"
82 #include "task.h"
83 #include "queue.h"
84 #include "timers.h"
85 #include "event_groups.h"
86 #include "mpu_prototypes.h"
87
88 #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
89
90 /*
91  * Checks to see if being called from the context of an unprivileged task, and
92  * if so raises the privilege level and returns false - otherwise does nothing
93  * other than return true.
94  */
95 extern BaseType_t xPortRaisePrivilege( void );
96
97 /*-----------------------------------------------------------*/
98
99 BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask )
100 {
101 BaseType_t xReturn;
102 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
103
104         xReturn = xTaskCreateRestricted( pxTaskDefinition, pxCreatedTask );
105         vPortResetPrivilege( xRunningPrivileged );
106         return xReturn;
107 }
108 /*-----------------------------------------------------------*/
109
110 #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
111         BaseType_t MPU_xTaskCreate( TaskFunction_t pvTaskCode, const char * const pcName, uint16_t usStackDepth, void *pvParameters, UBaseType_t uxPriority, TaskHandle_t *pxCreatedTask )
112         {
113         BaseType_t xReturn;
114         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
115
116                 xReturn = xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask );
117                 vPortResetPrivilege( xRunningPrivileged );
118                 return xReturn;
119         }
120 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
121 /*-----------------------------------------------------------*/
122
123 #if( configSUPPORT_STATIC_ALLOCATION == 1 )
124         TaskHandle_t 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 )
125         {
126         TaskHandle_t xReturn;
127         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
128
129                 xReturn = xTaskCreateStatic( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer );
130                 vPortResetPrivilege( xRunningPrivileged );
131                 return xReturn;
132         }
133 #endif /* configSUPPORT_STATIC_ALLOCATION */
134 /*-----------------------------------------------------------*/
135
136 void MPU_vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const xRegions )
137 {
138 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
139
140         vTaskAllocateMPURegions( xTask, xRegions );
141         vPortResetPrivilege( xRunningPrivileged );
142 }
143 /*-----------------------------------------------------------*/
144
145 #if ( INCLUDE_vTaskDelete == 1 )
146         void MPU_vTaskDelete( TaskHandle_t pxTaskToDelete )
147         {
148         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
149
150                 vTaskDelete( pxTaskToDelete );
151                 vPortResetPrivilege( xRunningPrivileged );
152         }
153 #endif
154 /*-----------------------------------------------------------*/
155
156 #if ( INCLUDE_vTaskDelayUntil == 1 )
157         void MPU_vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, TickType_t xTimeIncrement )
158         {
159         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
160
161                 vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement );
162                 vPortResetPrivilege( xRunningPrivileged );
163         }
164 #endif
165 /*-----------------------------------------------------------*/
166
167 #if ( INCLUDE_xTaskAbortDelay == 1 )
168         BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask )
169         {
170         BaseType_t xReturn;
171         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
172
173                 xReturn = xTaskAbortDelay( xTask );
174                 vPortResetPrivilege( xRunningPrivileged );
175                 return xReturn;
176         }
177 #endif
178 /*-----------------------------------------------------------*/
179
180 #if ( INCLUDE_vTaskDelay == 1 )
181         void MPU_vTaskDelay( TickType_t xTicksToDelay )
182         {
183         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
184
185                 vTaskDelay( xTicksToDelay );
186                 vPortResetPrivilege( xRunningPrivileged );
187         }
188 #endif
189 /*-----------------------------------------------------------*/
190
191 #if ( INCLUDE_uxTaskPriorityGet == 1 )
192         UBaseType_t MPU_uxTaskPriorityGet( TaskHandle_t pxTask )
193         {
194         UBaseType_t uxReturn;
195         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
196
197                 uxReturn = uxTaskPriorityGet( pxTask );
198                 vPortResetPrivilege( xRunningPrivileged );
199                 return uxReturn;
200         }
201 #endif
202 /*-----------------------------------------------------------*/
203
204 #if ( INCLUDE_vTaskPrioritySet == 1 )
205         void MPU_vTaskPrioritySet( TaskHandle_t pxTask, UBaseType_t uxNewPriority )
206         {
207         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
208
209                 vTaskPrioritySet( pxTask, uxNewPriority );
210                 vPortResetPrivilege( xRunningPrivileged );
211         }
212 #endif
213 /*-----------------------------------------------------------*/
214
215 #if ( INCLUDE_eTaskGetState == 1 )
216         eTaskState MPU_eTaskGetState( TaskHandle_t pxTask )
217         {
218         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
219         eTaskState eReturn;
220
221                 eReturn = eTaskGetState( pxTask );
222                 vPortResetPrivilege( xRunningPrivileged );
223                 return eReturn;
224         }
225 #endif
226 /*-----------------------------------------------------------*/
227
228 #if( configUSE_TRACE_FACILITY == 1 )
229         void MPU_vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState )
230         {
231         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
232
233                 vTaskGetInfo( xTask, pxTaskStatus, xGetFreeStackSpace, eState );
234                 vPortResetPrivilege( xRunningPrivileged );
235         }
236 #endif
237 /*-----------------------------------------------------------*/
238
239 #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
240         TaskHandle_t MPU_xTaskGetIdleTaskHandle( void )
241         {
242         TaskHandle_t xReturn;
243         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
244
245                 xReturn = xTaskGetIdleTaskHandle();
246                 vPortResetPrivilege( xRunningPrivileged );
247                 return xReturn;
248         }
249 #endif
250 /*-----------------------------------------------------------*/
251
252 #if ( INCLUDE_vTaskSuspend == 1 )
253         void MPU_vTaskSuspend( TaskHandle_t pxTaskToSuspend )
254         {
255         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
256
257                 vTaskSuspend( pxTaskToSuspend );
258                 vPortResetPrivilege( xRunningPrivileged );
259         }
260 #endif
261 /*-----------------------------------------------------------*/
262
263 #if ( INCLUDE_vTaskSuspend == 1 )
264         void MPU_vTaskResume( TaskHandle_t pxTaskToResume )
265         {
266         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
267
268                 vTaskResume( pxTaskToResume );
269                 vPortResetPrivilege( xRunningPrivileged );
270         }
271 #endif
272 /*-----------------------------------------------------------*/
273
274 void MPU_vTaskSuspendAll( void )
275 {
276 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
277
278         vTaskSuspendAll();
279         vPortResetPrivilege( xRunningPrivileged );
280 }
281 /*-----------------------------------------------------------*/
282
283 BaseType_t MPU_xTaskResumeAll( void )
284 {
285 BaseType_t xReturn;
286 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
287
288         xReturn = xTaskResumeAll();
289         vPortResetPrivilege( xRunningPrivileged );
290         return xReturn;
291 }
292 /*-----------------------------------------------------------*/
293
294 TickType_t MPU_xTaskGetTickCount( void )
295 {
296 TickType_t xReturn;
297 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
298
299         xReturn = xTaskGetTickCount();
300         vPortResetPrivilege( xRunningPrivileged );
301         return xReturn;
302 }
303 /*-----------------------------------------------------------*/
304
305 UBaseType_t MPU_uxTaskGetNumberOfTasks( void )
306 {
307 UBaseType_t uxReturn;
308 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
309
310         uxReturn = uxTaskGetNumberOfTasks();
311         vPortResetPrivilege( xRunningPrivileged );
312         return uxReturn;
313 }
314 /*-----------------------------------------------------------*/
315
316 char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery )
317 {
318 char *pcReturn;
319 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
320
321         pcReturn = pcTaskGetName( xTaskToQuery );
322         vPortResetPrivilege( xRunningPrivileged );
323         return pcReturn;
324 }
325 /*-----------------------------------------------------------*/
326
327 #if ( INCLUDE_xTaskGetHandle == 1 )
328         TaskHandle_t MPU_xTaskGetHandle( const char *pcNameToQuery )
329         {
330         TaskHandle_t xReturn;
331         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
332
333                 xReturn = xTaskGetHandle( pcNameToQuery );
334                 vPortResetPrivilege( xRunningPrivileged );
335                 return xReturn;
336         }
337 #endif
338 /*-----------------------------------------------------------*/
339
340 #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) )
341         void MPU_vTaskList( char *pcWriteBuffer )
342         {
343         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
344
345                 vTaskList( pcWriteBuffer );
346                 vPortResetPrivilege( xRunningPrivileged );
347         }
348 #endif
349 /*-----------------------------------------------------------*/
350
351 #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) )
352         void MPU_vTaskGetRunTimeStats( char *pcWriteBuffer )
353         {
354         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
355
356                 vTaskGetRunTimeStats( pcWriteBuffer );
357                 vPortResetPrivilege( xRunningPrivileged );
358         }
359 #endif
360 /*-----------------------------------------------------------*/
361
362 #if ( configUSE_APPLICATION_TASK_TAG == 1 )
363         void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxTagValue )
364         {
365         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
366
367                 vTaskSetApplicationTaskTag( xTask, pxTagValue );
368                 vPortResetPrivilege( xRunningPrivileged );
369         }
370 #endif
371 /*-----------------------------------------------------------*/
372
373 #if ( configUSE_APPLICATION_TASK_TAG == 1 )
374         TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask )
375         {
376         TaskHookFunction_t xReturn;
377         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
378
379                 xReturn = xTaskGetApplicationTaskTag( xTask );
380                 vPortResetPrivilege( xRunningPrivileged );
381                 return xReturn;
382         }
383 #endif
384 /*-----------------------------------------------------------*/
385
386 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
387         void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue )
388         {
389         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
390
391                 vTaskSetThreadLocalStoragePointer( xTaskToSet, xIndex, pvValue );
392                 vPortResetPrivilege( xRunningPrivileged );
393         }
394 #endif
395 /*-----------------------------------------------------------*/
396
397 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
398         void *MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex )
399         {
400         void *pvReturn;
401         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
402
403                 pvReturn = pvTaskGetThreadLocalStoragePointer( xTaskToQuery, xIndex );
404                 vPortResetPrivilege( xRunningPrivileged );
405                 return pvReturn;
406         }
407 #endif
408 /*-----------------------------------------------------------*/
409
410 #if ( configUSE_APPLICATION_TASK_TAG == 1 )
411         BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter )
412         {
413         BaseType_t xReturn;
414         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
415
416                 xReturn = xTaskCallApplicationTaskHook( xTask, pvParameter );
417                 vPortResetPrivilege( xRunningPrivileged );
418                 return xReturn;
419         }
420 #endif
421 /*-----------------------------------------------------------*/
422
423 #if ( configUSE_TRACE_FACILITY == 1 )
424         UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t *pxTaskStatusArray, UBaseType_t uxArraySize, uint32_t *pulTotalRunTime )
425         {
426         UBaseType_t uxReturn;
427         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
428
429                 uxReturn = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, pulTotalRunTime );
430                 vPortResetPrivilege( xRunningPrivileged );
431                 return uxReturn;
432         }
433 #endif
434 /*-----------------------------------------------------------*/
435
436 #if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )
437         UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask )
438         {
439         UBaseType_t uxReturn;
440         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
441
442                 uxReturn = uxTaskGetStackHighWaterMark( xTask );
443                 vPortResetPrivilege( xRunningPrivileged );
444                 return uxReturn;
445         }
446 #endif
447 /*-----------------------------------------------------------*/
448
449 #if ( INCLUDE_xTaskGetCurrentTaskHandle == 1 )
450         TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void )
451         {
452         TaskHandle_t xReturn;
453         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
454
455                 xReturn = xTaskGetCurrentTaskHandle();
456                 vPortResetPrivilege( xRunningPrivileged );
457                 return xReturn;
458         }
459 #endif
460 /*-----------------------------------------------------------*/
461
462 #if ( INCLUDE_xTaskGetSchedulerState == 1 )
463         BaseType_t MPU_xTaskGetSchedulerState( void )
464         {
465         BaseType_t xReturn;
466         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
467
468                 xReturn = xTaskGetSchedulerState();
469                 vPortResetPrivilege( xRunningPrivileged );
470                 return xReturn;
471         }
472 #endif
473 /*-----------------------------------------------------------*/
474
475 void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut )
476 {
477 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
478
479         vTaskSetTimeOutState( pxTimeOut );
480         vPortResetPrivilege( xRunningPrivileged );
481 }
482 /*-----------------------------------------------------------*/
483
484 BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait )
485 {
486 BaseType_t xReturn;
487 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
488
489         xReturn = xTaskCheckForTimeOut( pxTimeOut, pxTicksToWait );
490         vPortResetPrivilege( xRunningPrivileged );
491         return xReturn;
492 }
493 /*-----------------------------------------------------------*/
494
495 #if( configUSE_TASK_NOTIFICATIONS == 1 )
496         BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue )
497         {
498         BaseType_t xReturn;
499         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
500
501                 xReturn = xTaskGenericNotify( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue );
502                 vPortResetPrivilege( xRunningPrivileged );
503                 return xReturn;
504         }
505 #endif
506 /*-----------------------------------------------------------*/
507
508 #if( configUSE_TASK_NOTIFICATIONS == 1 )
509         BaseType_t MPU_xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait )
510         {
511         BaseType_t xReturn;
512         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
513
514                 xReturn = xTaskNotifyWait( ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait );
515                 vPortResetPrivilege( xRunningPrivileged );
516                 return xReturn;
517         }
518 #endif
519 /*-----------------------------------------------------------*/
520
521 #if( configUSE_TASK_NOTIFICATIONS == 1 )
522         uint32_t MPU_ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait )
523         {
524         uint32_t ulReturn;
525         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
526
527                 ulReturn = ulTaskNotifyTake( xClearCountOnExit, xTicksToWait );
528                 vPortResetPrivilege( xRunningPrivileged );
529                 return ulReturn;
530         }
531 #endif
532 /*-----------------------------------------------------------*/
533
534 #if( configUSE_TASK_NOTIFICATIONS == 1 )
535         BaseType_t MPU_xTaskNotifyStateClear( TaskHandle_t xTask )
536         {
537         BaseType_t xReturn;
538         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
539
540                 xReturn = xTaskNotifyStateClear( xTask );
541                 vPortResetPrivilege( xRunningPrivileged );
542                 return xReturn;
543         }
544 #endif
545 /*-----------------------------------------------------------*/
546
547 #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
548         QueueHandle_t MPU_xQueueGenericCreate( UBaseType_t uxQueueLength, UBaseType_t uxItemSize, uint8_t ucQueueType )
549         {
550         QueueHandle_t xReturn;
551         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
552
553                 xReturn = xQueueGenericCreate( uxQueueLength, uxItemSize, ucQueueType );
554                 vPortResetPrivilege( xRunningPrivileged );
555                 return xReturn;
556         }
557 #endif
558 /*-----------------------------------------------------------*/
559
560 #if( configSUPPORT_STATIC_ALLOCATION == 1 )
561         QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType )
562         {
563         QueueHandle_t xReturn;
564         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
565
566                 xReturn = xQueueGenericCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxStaticQueue, ucQueueType );
567                 vPortResetPrivilege( xRunningPrivileged );
568                 return xReturn;
569         }
570 #endif
571 /*-----------------------------------------------------------*/
572
573 BaseType_t MPU_xQueueGenericReset( QueueHandle_t pxQueue, BaseType_t xNewQueue )
574 {
575 BaseType_t xReturn;
576 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
577
578         xReturn = xQueueGenericReset( pxQueue, xNewQueue );
579         vPortResetPrivilege( xRunningPrivileged );
580         return xReturn;
581 }
582 /*-----------------------------------------------------------*/
583
584 BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, BaseType_t xCopyPosition )
585 {
586 BaseType_t xReturn;
587 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
588
589         xReturn = xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, xCopyPosition );
590         vPortResetPrivilege( xRunningPrivileged );
591         return xReturn;
592 }
593 /*-----------------------------------------------------------*/
594
595 UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t pxQueue )
596 {
597 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
598 UBaseType_t uxReturn;
599
600         uxReturn = uxQueueMessagesWaiting( pxQueue );
601         vPortResetPrivilege( xRunningPrivileged );
602         return uxReturn;
603 }
604 /*-----------------------------------------------------------*/
605
606 UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue )
607 {
608 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
609 UBaseType_t uxReturn;
610
611         uxReturn = uxQueueSpacesAvailable( xQueue );
612         vPortResetPrivilege( xRunningPrivileged );
613         return uxReturn;
614 }
615 /*-----------------------------------------------------------*/
616
617 BaseType_t MPU_xQueueGenericReceive( QueueHandle_t pxQueue, void * const pvBuffer, TickType_t xTicksToWait, BaseType_t xJustPeeking )
618 {
619 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
620 BaseType_t xReturn;
621
622         xReturn = xQueueGenericReceive( pxQueue, pvBuffer, xTicksToWait, xJustPeeking );
623         vPortResetPrivilege( xRunningPrivileged );
624         return xReturn;
625 }
626 /*-----------------------------------------------------------*/
627
628 BaseType_t MPU_xQueuePeekFromISR( QueueHandle_t pxQueue, void * const pvBuffer )
629 {
630 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
631 BaseType_t xReturn;
632
633         xReturn = xQueuePeekFromISR( pxQueue, pvBuffer );
634         vPortResetPrivilege( xRunningPrivileged );
635         return xReturn;
636 }
637 /*-----------------------------------------------------------*/
638
639 void* MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore )
640 {
641 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
642 void * xReturn;
643
644         xReturn = ( void * ) xQueueGetMutexHolder( xSemaphore );
645         vPortResetPrivilege( xRunningPrivileged );
646         return xReturn;
647 }
648 /*-----------------------------------------------------------*/
649
650 #if( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
651         QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType )
652         {
653         QueueHandle_t xReturn;
654         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
655
656                 xReturn = xQueueCreateMutex( ucQueueType );
657                 vPortResetPrivilege( xRunningPrivileged );
658                 return xReturn;
659         }
660 #endif
661 /*-----------------------------------------------------------*/
662
663 #if( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
664         QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue )
665         {
666         QueueHandle_t xReturn;
667         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
668
669                 xReturn = xQueueCreateMutexStatic( ucQueueType, pxStaticQueue );
670                 vPortResetPrivilege( xRunningPrivileged );
671                 return xReturn;
672         }
673 #endif
674 /*-----------------------------------------------------------*/
675
676 #if( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
677         QueueHandle_t MPU_xQueueCreateCountingSemaphore( UBaseType_t uxCountValue, UBaseType_t uxInitialCount )
678         {
679         QueueHandle_t xReturn;
680         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
681
682                 xReturn = xQueueCreateCountingSemaphore( uxCountValue, uxInitialCount );
683                 vPortResetPrivilege( xRunningPrivileged );
684                 return xReturn;
685         }
686 #endif
687 /*-----------------------------------------------------------*/
688
689 #if( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
690
691         QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue )
692         {
693         QueueHandle_t xReturn;
694         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
695
696                 xReturn = xQueueCreateCountingSemaphoreStatic( uxMaxCount, uxInitialCount, pxStaticQueue );
697                 vPortResetPrivilege( xRunningPrivileged );
698                 return xReturn;
699         }
700 #endif
701 /*-----------------------------------------------------------*/
702
703 #if ( configUSE_MUTEXES == 1 )
704         BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xBlockTime )
705         {
706         BaseType_t xReturn;
707         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
708
709                 xReturn = xQueueTakeMutexRecursive( xMutex, xBlockTime );
710                 vPortResetPrivilege( xRunningPrivileged );
711                 return xReturn;
712         }
713 #endif
714 /*-----------------------------------------------------------*/
715
716 #if ( configUSE_MUTEXES == 1 )
717         BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t xMutex )
718         {
719         BaseType_t xReturn;
720         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
721
722                 xReturn = xQueueGiveMutexRecursive( xMutex );
723                 vPortResetPrivilege( xRunningPrivileged );
724                 return xReturn;
725         }
726 #endif
727 /*-----------------------------------------------------------*/
728
729 #if ( configUSE_QUEUE_SETS == 1 )
730         QueueSetHandle_t MPU_xQueueCreateSet( UBaseType_t uxEventQueueLength )
731         {
732         QueueSetHandle_t xReturn;
733         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
734
735                 xReturn = xQueueCreateSet( uxEventQueueLength );
736                 vPortResetPrivilege( xRunningPrivileged );
737                 return xReturn;
738         }
739 #endif
740 /*-----------------------------------------------------------*/
741
742 #if ( configUSE_QUEUE_SETS == 1 )
743         QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet, TickType_t xBlockTimeTicks )
744         {
745         QueueSetMemberHandle_t xReturn;
746         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
747
748                 xReturn = xQueueSelectFromSet( xQueueSet, xBlockTimeTicks );
749                 vPortResetPrivilege( xRunningPrivileged );
750                 return xReturn;
751         }
752 #endif
753 /*-----------------------------------------------------------*/
754
755 #if ( configUSE_QUEUE_SETS == 1 )
756         BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet )
757         {
758         BaseType_t xReturn;
759         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
760
761                 xReturn = xQueueAddToSet( xQueueOrSemaphore, xQueueSet );
762                 vPortResetPrivilege( xRunningPrivileged );
763                 return xReturn;
764         }
765 #endif
766 /*-----------------------------------------------------------*/
767
768 #if ( configUSE_QUEUE_SETS == 1 )
769         BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet )
770         {
771         BaseType_t xReturn;
772         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
773
774                 xReturn = xQueueRemoveFromSet( xQueueOrSemaphore, xQueueSet );
775                 vPortResetPrivilege( xRunningPrivileged );
776                 return xReturn;
777         }
778 #endif
779 /*-----------------------------------------------------------*/
780
781 #if configQUEUE_REGISTRY_SIZE > 0
782         void MPU_vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName )
783         {
784         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
785
786                 vQueueAddToRegistry( xQueue, pcName );
787
788                 vPortResetPrivilege( xRunningPrivileged );
789         }
790 #endif
791 /*-----------------------------------------------------------*/
792
793 #if configQUEUE_REGISTRY_SIZE > 0
794         void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue )
795         {
796         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
797
798                 vQueueUnregisterQueue( xQueue );
799
800                 vPortResetPrivilege( xRunningPrivileged );
801         }
802 #endif
803 /*-----------------------------------------------------------*/
804
805 #if configQUEUE_REGISTRY_SIZE > 0
806         const char *MPU_pcQueueGetName( QueueHandle_t xQueue )
807         {
808         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
809         const char *pcReturn;
810
811                 pcReturn = pcQueueGetName( xQueue );
812
813                 vPortResetPrivilege( xRunningPrivileged );
814                 return pcReturn;
815         }
816 #endif
817 /*-----------------------------------------------------------*/
818
819 void MPU_vQueueDelete( QueueHandle_t xQueue )
820 {
821 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
822
823         vQueueDelete( xQueue );
824
825         vPortResetPrivilege( xRunningPrivileged );
826 }
827 /*-----------------------------------------------------------*/
828
829 #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
830
831         void *MPU_pvPortMalloc( size_t xSize )
832         {
833         void *pvReturn;
834         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
835
836                 pvReturn = pvPortMalloc( xSize );
837
838                 vPortResetPrivilege( xRunningPrivileged );
839
840                 return pvReturn;
841         }
842
843 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
844 /*-----------------------------------------------------------*/
845
846 #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
847
848         void MPU_vPortFree( void *pv )
849         {
850         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
851
852                 vPortFree( pv );
853
854                 vPortResetPrivilege( xRunningPrivileged );
855         }
856
857 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
858 /*-----------------------------------------------------------*/
859
860 void MPU_vPortInitialiseBlocks( void )
861 {
862 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
863
864         vPortInitialiseBlocks();
865
866         vPortResetPrivilege( xRunningPrivileged );
867 }
868 /*-----------------------------------------------------------*/
869
870 size_t MPU_xPortGetFreeHeapSize( void )
871 {
872 size_t xReturn;
873 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
874
875         xReturn = xPortGetFreeHeapSize();
876
877         vPortResetPrivilege( xRunningPrivileged );
878
879         return xReturn;
880 }
881 /*-----------------------------------------------------------*/
882
883 #if( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) )
884         TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction )
885         {
886         TimerHandle_t xReturn;
887         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
888
889                 xReturn = xTimerCreate( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction );
890                 vPortResetPrivilege( xRunningPrivileged );
891
892                 return xReturn;
893         }
894 #endif
895 /*-----------------------------------------------------------*/
896
897 #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) )
898         TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction, StaticTimer_t *pxTimerBuffer )
899         {
900         TimerHandle_t xReturn;
901         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
902
903                 xReturn = xTimerCreateStatic( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction, pxTimerBuffer );
904                 vPortResetPrivilege( xRunningPrivileged );
905
906                 return xReturn;
907         }
908 #endif
909 /*-----------------------------------------------------------*/
910
911 #if( configUSE_TIMERS == 1 )
912         void *MPU_pvTimerGetTimerID( const TimerHandle_t xTimer )
913         {
914         void * pvReturn;
915         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
916
917                 pvReturn = pvTimerGetTimerID( xTimer );
918                 vPortResetPrivilege( xRunningPrivileged );
919
920                 return pvReturn;
921         }
922 #endif
923 /*-----------------------------------------------------------*/
924
925 #if( configUSE_TIMERS == 1 )
926         void MPU_vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID )
927         {
928         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
929
930                 vTimerSetTimerID( xTimer, pvNewID );
931                 vPortResetPrivilege( xRunningPrivileged );
932         }
933 #endif
934 /*-----------------------------------------------------------*/
935
936 #if( configUSE_TIMERS == 1 )
937         BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer )
938         {
939         BaseType_t xReturn;
940         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
941
942                 xReturn = xTimerIsTimerActive( xTimer );
943                 vPortResetPrivilege( xRunningPrivileged );
944
945                 return xReturn;
946         }
947 #endif
948 /*-----------------------------------------------------------*/
949
950 #if( configUSE_TIMERS == 1 )
951         TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void )
952         {
953         TaskHandle_t xReturn;
954         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
955
956                 xReturn = xTimerGetTimerDaemonTaskHandle();
957                 vPortResetPrivilege( xRunningPrivileged );
958
959                 return xReturn;
960         }
961 #endif
962 /*-----------------------------------------------------------*/
963
964 #if( ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )
965         BaseType_t MPU_xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait )
966         {
967         BaseType_t xReturn;
968         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
969
970                 xReturn = xTimerPendFunctionCall( xFunctionToPend, pvParameter1, ulParameter2, xTicksToWait );
971                 vPortResetPrivilege( xRunningPrivileged );
972
973                 return xReturn;
974         }
975 #endif
976 /*-----------------------------------------------------------*/
977
978 #if( configUSE_TIMERS == 1 )
979         const char * MPU_pcTimerGetName( TimerHandle_t xTimer )
980         {
981         const char * pcReturn;
982         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
983
984                 pcReturn = pcTimerGetName( xTimer );
985                 vPortResetPrivilege( xRunningPrivileged );
986
987                 return pcReturn;
988         }
989 #endif
990 /*-----------------------------------------------------------*/
991
992 #if( configUSE_TIMERS == 1 )
993         TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer )
994         {
995         TickType_t xReturn;
996         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
997
998                 xReturn = xTimerGetPeriod( xTimer );
999                 vPortResetPrivilege( xRunningPrivileged );
1000
1001                 return xReturn;
1002         }
1003 #endif
1004 /*-----------------------------------------------------------*/
1005
1006 #if( configUSE_TIMERS == 1 )
1007         TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer )
1008         {
1009         TickType_t xReturn;
1010         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1011
1012                 xReturn = xTimerGetExpiryTime( xTimer );
1013                 vPortResetPrivilege( xRunningPrivileged );
1014
1015                 return xReturn;
1016         }
1017 #endif
1018 /*-----------------------------------------------------------*/
1019
1020 #if( configUSE_TIMERS == 1 )
1021         BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait )
1022         {
1023         BaseType_t xReturn;
1024         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1025
1026                 xReturn = xTimerGenericCommand( xTimer, xCommandID, xOptionalValue, pxHigherPriorityTaskWoken, xTicksToWait );
1027                 vPortResetPrivilege( xRunningPrivileged );
1028
1029                 return xReturn;
1030         }
1031 #endif
1032 /*-----------------------------------------------------------*/
1033
1034 #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
1035         EventGroupHandle_t MPU_xEventGroupCreate( void )
1036         {
1037         EventGroupHandle_t xReturn;
1038         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1039
1040                 xReturn = xEventGroupCreate();
1041                 vPortResetPrivilege( xRunningPrivileged );
1042
1043                 return xReturn;
1044         }
1045 #endif
1046 /*-----------------------------------------------------------*/
1047
1048 #if( configSUPPORT_STATIC_ALLOCATION == 1 )
1049         EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t *pxEventGroupBuffer )
1050         {
1051         EventGroupHandle_t xReturn;
1052         BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1053
1054                 xReturn = xEventGroupCreateStatic( pxEventGroupBuffer );
1055                 vPortResetPrivilege( xRunningPrivileged );
1056
1057                 return xReturn;
1058         }
1059 #endif
1060 /*-----------------------------------------------------------*/
1061
1062 EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait )
1063 {
1064 EventBits_t xReturn;
1065 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1066
1067         xReturn = xEventGroupWaitBits( xEventGroup, uxBitsToWaitFor, xClearOnExit, xWaitForAllBits, xTicksToWait );
1068         vPortResetPrivilege( xRunningPrivileged );
1069
1070         return xReturn;
1071 }
1072 /*-----------------------------------------------------------*/
1073
1074 EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear )
1075 {
1076 EventBits_t xReturn;
1077 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1078
1079         xReturn = xEventGroupClearBits( xEventGroup, uxBitsToClear );
1080         vPortResetPrivilege( xRunningPrivileged );
1081
1082         return xReturn;
1083 }
1084 /*-----------------------------------------------------------*/
1085
1086 EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet )
1087 {
1088 EventBits_t xReturn;
1089 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1090
1091         xReturn = xEventGroupSetBits( xEventGroup, uxBitsToSet );
1092         vPortResetPrivilege( xRunningPrivileged );
1093
1094         return xReturn;
1095 }
1096 /*-----------------------------------------------------------*/
1097
1098 EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait )
1099 {
1100 EventBits_t xReturn;
1101 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1102
1103         xReturn = xEventGroupSync( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTicksToWait );
1104         vPortResetPrivilege( xRunningPrivileged );
1105
1106         return xReturn;
1107 }
1108 /*-----------------------------------------------------------*/
1109
1110 void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup )
1111 {
1112 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1113
1114         vEventGroupDelete( xEventGroup );
1115         vPortResetPrivilege( xRunningPrivileged );
1116 }
1117 /*-----------------------------------------------------------*/
1118
1119
1120
1121
1122
1123 /* Functions that the application writer wants to execute in privileged mode
1124 can be defined in application_defined_privileged_functions.h.  The functions
1125 must take the same format as those above whereby the privilege state on exit
1126 equals the privilege state on entry.  For example:
1127
1128 void MPU_FunctionName( [parameters ] )
1129 {
1130 BaseType_t xRunningPrivileged = xPortRaisePrivilege();
1131
1132         FunctionName( [parameters ] );
1133
1134         vPortResetPrivilege( xRunningPrivileged );
1135 }
1136 */
1137
1138 #if configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS == 1
1139         #include "application_defined_privileged_functions.h"
1140 #endif