2 * FreeRTOS Kernel <DEVELOPMENT BRANCH>
3 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * SPDX-License-Identifier: MIT
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:
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
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.
24 * https://www.FreeRTOS.org
25 * https://github.com/FreeRTOS
30 * Implementation of the wrapper functions used to raise the processor privilege
31 * before calling a standard FreeRTOS API function.
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
39 /* Scheduler includes. */
44 #include "event_groups.h"
45 #include "stream_buffer.h"
46 #include "mpu_prototypes.h"
47 #include "mpu_syscall_numbers.h"
49 #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
50 /*-----------------------------------------------------------*/
52 #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) )
54 #ifndef configPROTECTED_KERNEL_OBJECT_POOL_SIZE
55 #error configPROTECTED_KERNEL_OBJECT_POOL_SIZE must be defined to maximum number of kernel objects in the application.
59 * @brief Offset added to the index before returning to the user.
61 * If the actual handle is stored at index i, ( i + INDEX_OFFSET )
62 * is returned to the user.
64 #define INDEX_OFFSET 1
67 * @brief Opaque type for a kernel object.
70 typedef struct OpaqueObject * OpaqueObjectHandle_t;
73 * @brief Defines kernel object in the kernel object pool.
75 typedef struct KernelObject
77 OpaqueObjectHandle_t xInternalObjectHandle;
78 uint32_t ulKernelObjectType;
79 void * pvKernelObjectData;
83 * @brief Kernel object types.
85 #define KERNEL_OBJECT_TYPE_INVALID ( 0UL )
86 #define KERNEL_OBJECT_TYPE_QUEUE ( 1UL )
87 #define KERNEL_OBJECT_TYPE_TASK ( 2UL )
88 #define KERNEL_OBJECT_TYPE_STREAM_BUFFER ( 3UL )
89 #define KERNEL_OBJECT_TYPE_EVENT_GROUP ( 4UL )
90 #define KERNEL_OBJECT_TYPE_TIMER ( 5UL )
93 * @brief Checks whether an external index is valid or not.
95 #define IS_EXTERNAL_INDEX_VALID( lIndex ) \
96 ( ( ( ( lIndex ) >= INDEX_OFFSET ) && \
97 ( ( lIndex ) < ( configPROTECTED_KERNEL_OBJECT_POOL_SIZE + INDEX_OFFSET ) ) ) ? pdTRUE : pdFALSE )
100 * @brief Checks whether an internal index is valid or not.
102 #define IS_INTERNAL_INDEX_VALID( lIndex ) \
103 ( ( ( ( lIndex ) >= 0 ) && \
104 ( ( lIndex ) < ( configPROTECTED_KERNEL_OBJECT_POOL_SIZE ) ) ) ? pdTRUE : pdFALSE )
107 * @brief Converts an internal index into external.
109 #define CONVERT_TO_EXTERNAL_INDEX( lIndex ) ( ( lIndex ) + INDEX_OFFSET )
112 * @brief Converts an external index into internal.
114 #define CONVERT_TO_INTERNAL_INDEX( lIndex ) ( ( lIndex ) - INDEX_OFFSET )
117 * @brief Max value that fits in a uint32_t type.
119 #define mpuUINT32_MAX ( ~( ( uint32_t ) 0 ) )
122 * @brief Check if multiplying a and b will result in overflow.
124 #define mpuMULTIPLY_UINT32_WILL_OVERFLOW( a, b ) ( ( ( a ) > 0 ) && ( ( b ) > ( mpuUINT32_MAX / ( a ) ) ) )
127 * @brief Get the index of a free slot in the kernel object pool.
129 * If a free slot is found, this function marks the slot as
132 * @return Index of a free slot is returned, if a free slot is
133 * found. Otherwise -1 is returned.
135 static int32_t MPU_GetFreeIndexInKernelObjectPool( void ) PRIVILEGED_FUNCTION;
138 * @brief Set the given index as free in the kernel object pool.
140 * @param lIndex The index to set as free.
142 static void MPU_SetIndexFreeInKernelObjectPool( int32_t lIndex ) PRIVILEGED_FUNCTION;
145 * @brief Get the index at which a given kernel object is stored.
147 * @param xHandle The given kernel object handle.
148 * @param ulKernelObjectType The kernel object type.
150 * @return Index at which the kernel object is stored if it is a valid
151 * handle, -1 otherwise.
153 static int32_t MPU_GetIndexForHandle( OpaqueObjectHandle_t xHandle,
154 uint32_t ulKernelObjectType ) PRIVILEGED_FUNCTION;
157 * @brief Store the given kernel object handle at the given index in
158 * the kernel object pool.
160 * @param lIndex Index to store the given handle at.
161 * @param xHandle Kernel object handle to store.
162 * @param pvKernelObjectData The data associated with the kernel object.
163 * Currently, only used for timer objects to store timer callback.
164 * @param ulKernelObjectType The kernel object type.
166 static void MPU_StoreHandleAndDataAtIndex( int32_t lIndex,
167 OpaqueObjectHandle_t xHandle,
168 void * pvKernelObjectData,
169 uint32_t ulKernelObjectType ) PRIVILEGED_FUNCTION;
172 * @brief Get the kernel object handle at the given index from
173 * the kernel object pool.
175 * @param lIndex Index at which to get the kernel object handle.
176 * @param ulKernelObjectType The kernel object type.
178 * @return The kernel object handle at the index.
180 static OpaqueObjectHandle_t MPU_GetHandleAtIndex( int32_t lIndex,
181 uint32_t ulKernelObjectType ) PRIVILEGED_FUNCTION;
183 #if ( configUSE_TIMERS == 1 )
186 * @brief The function registered as callback for all the timers.
188 * We intercept all the timer callbacks so that we can call application
189 * callbacks with opaque handle.
191 * @param xInternalHandle The internal timer handle.
193 static void MPU_TimerCallback( TimerHandle_t xInternalHandle ) PRIVILEGED_FUNCTION;
195 #endif /* #if ( configUSE_TIMERS == 1 ) */
198 * Wrappers to keep all the casting in one place.
200 #define MPU_StoreQueueHandleAtIndex( lIndex, xHandle ) MPU_StoreHandleAndDataAtIndex( ( lIndex ), ( OpaqueObjectHandle_t ) ( xHandle ), NULL, KERNEL_OBJECT_TYPE_QUEUE )
201 #define MPU_GetQueueHandleAtIndex( lIndex ) ( QueueHandle_t ) MPU_GetHandleAtIndex( ( lIndex ), KERNEL_OBJECT_TYPE_QUEUE )
203 #if ( configUSE_QUEUE_SETS == 1 )
204 #define MPU_StoreQueueSetHandleAtIndex( lIndex, xHandle ) MPU_StoreHandleAndDataAtIndex( ( lIndex ), ( OpaqueObjectHandle_t ) ( xHandle ), NULL, KERNEL_OBJECT_TYPE_QUEUE )
205 #define MPU_GetQueueSetHandleAtIndex( lIndex ) ( QueueSetHandle_t ) MPU_GetHandleAtIndex( ( lIndex ), KERNEL_OBJECT_TYPE_QUEUE )
206 #define MPU_StoreQueueSetMemberHandleAtIndex( lIndex, xHandle ) MPU_StoreHandleAndDataAtIndex( ( lIndex ), ( OpaqueObjectHandle_t ) ( xHandle ), NULL, KERNEL_OBJECT_TYPE_QUEUE )
207 #define MPU_GetQueueSetMemberHandleAtIndex( lIndex ) ( QueueSetMemberHandle_t ) MPU_GetHandleAtIndex( ( lIndex ), KERNEL_OBJECT_TYPE_QUEUE )
208 #define MPU_GetIndexForQueueSetMemberHandle( xHandle ) MPU_GetIndexForHandle( ( OpaqueObjectHandle_t ) ( xHandle ), KERNEL_OBJECT_TYPE_QUEUE )
212 * Wrappers to keep all the casting in one place for Task APIs.
214 #define MPU_StoreTaskHandleAtIndex( lIndex, xHandle ) MPU_StoreHandleAndDataAtIndex( ( lIndex ), ( OpaqueObjectHandle_t ) ( xHandle ), NULL, KERNEL_OBJECT_TYPE_TASK )
215 #define MPU_GetTaskHandleAtIndex( lIndex ) ( TaskHandle_t ) MPU_GetHandleAtIndex( ( lIndex ), KERNEL_OBJECT_TYPE_TASK )
216 #define MPU_GetIndexForTaskHandle( xHandle ) MPU_GetIndexForHandle( ( OpaqueObjectHandle_t ) ( xHandle ), KERNEL_OBJECT_TYPE_TASK )
218 #if ( configUSE_EVENT_GROUPS == 1 )
220 * Wrappers to keep all the casting in one place for Event Group APIs.
222 #define MPU_StoreEventGroupHandleAtIndex( lIndex, xHandle ) MPU_StoreHandleAndDataAtIndex( ( lIndex ), ( OpaqueObjectHandle_t ) ( xHandle ), NULL, KERNEL_OBJECT_TYPE_EVENT_GROUP )
223 #define MPU_GetEventGroupHandleAtIndex( lIndex ) ( EventGroupHandle_t ) MPU_GetHandleAtIndex( ( lIndex ), KERNEL_OBJECT_TYPE_EVENT_GROUP )
224 #define MPU_GetIndexForEventGroupHandle( xHandle ) MPU_GetIndexForHandle( ( OpaqueObjectHandle_t ) ( xHandle ), KERNEL_OBJECT_TYPE_EVENT_GROUP )
226 #endif /* #if ( configUSE_EVENT_GROUPS == 1 ) */
228 #if ( configUSE_STREAM_BUFFERS == 1 )
230 * Wrappers to keep all the casting in one place for Stream Buffer APIs.
232 #define MPU_StoreStreamBufferHandleAtIndex( lIndex, xHandle ) MPU_StoreHandleAndDataAtIndex( ( lIndex ), ( OpaqueObjectHandle_t ) ( xHandle), NULL, KERNEL_OBJECT_TYPE_STREAM_BUFFER )
233 #define MPU_GetStreamBufferHandleAtIndex( lIndex ) ( StreamBufferHandle_t ) MPU_GetHandleAtIndex( ( lIndex ), KERNEL_OBJECT_TYPE_STREAM_BUFFER )
234 #define MPU_GetIndexForStreamBufferHandle( xHandle ) MPU_GetIndexForHandle( ( OpaqueObjectHandle_t ) ( xHandle ), KERNEL_OBJECT_TYPE_STREAM_BUFFER )
236 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
238 #if ( configUSE_TIMERS == 1 )
240 * Wrappers to keep all the casting in one place for Timer APIs.
242 #define MPU_StoreTimerHandleAtIndex( lIndex, xHandle, pxApplicationCallback ) MPU_StoreHandleAndDataAtIndex( ( lIndex ), ( OpaqueObjectHandle_t ) ( xHandle ), ( void * ) ( pxApplicationCallback ), KERNEL_OBJECT_TYPE_TIMER )
243 #define MPU_GetTimerHandleAtIndex( lIndex ) ( TimerHandle_t ) MPU_GetHandleAtIndex( ( lIndex ), KERNEL_OBJECT_TYPE_TIMER )
244 #define MPU_GetIndexForTimerHandle( xHandle ) MPU_GetIndexForHandle( ( OpaqueObjectHandle_t ) ( xHandle ), KERNEL_OBJECT_TYPE_TIMER )
246 #endif /* #if ( configUSE_TIMERS == 1 ) */
248 /*-----------------------------------------------------------*/
251 * @brief Kernel object pool.
253 PRIVILEGED_DATA static KernelObject_t xKernelObjectPool[ configPROTECTED_KERNEL_OBJECT_POOL_SIZE ] = { 0 };
254 /*-----------------------------------------------------------*/
256 static int32_t MPU_GetFreeIndexInKernelObjectPool( void ) /* PRIVILEGED_FUNCTION */
258 int32_t i, lFreeIndex = -1;
260 /* This function is called only from resource create APIs
261 * which are not supposed to be called from ISRs. Therefore,
262 * we only need to suspend the scheduler and do not require
263 * critical section. */
266 for( i = 0; i < configPROTECTED_KERNEL_OBJECT_POOL_SIZE; i++ )
268 if( xKernelObjectPool[ i ].xInternalObjectHandle == NULL )
270 /* Mark this index as not free. */
271 xKernelObjectPool[ i ].xInternalObjectHandle = ( OpaqueObjectHandle_t ) ( ~0U );
277 ( void ) xTaskResumeAll();
281 /*-----------------------------------------------------------*/
283 static void MPU_SetIndexFreeInKernelObjectPool( int32_t lIndex ) /* PRIVILEGED_FUNCTION */
285 configASSERT( IS_INTERNAL_INDEX_VALID( lIndex ) != pdFALSE );
287 taskENTER_CRITICAL();
289 xKernelObjectPool[ lIndex ].xInternalObjectHandle = NULL;
290 xKernelObjectPool[ lIndex ].ulKernelObjectType = KERNEL_OBJECT_TYPE_INVALID;
291 xKernelObjectPool[ lIndex ].pvKernelObjectData = NULL;
295 /*-----------------------------------------------------------*/
297 static int32_t MPU_GetIndexForHandle( OpaqueObjectHandle_t xHandle,
298 uint32_t ulKernelObjectType ) /* PRIVILEGED_FUNCTION */
300 int32_t i, lIndex = -1;
302 configASSERT( xHandle != NULL );
304 for( i = 0; i < configPROTECTED_KERNEL_OBJECT_POOL_SIZE; i++ )
306 if( ( xKernelObjectPool[ i ].xInternalObjectHandle == xHandle ) &&
307 ( xKernelObjectPool[ i ].ulKernelObjectType == ulKernelObjectType ) )
316 /*-----------------------------------------------------------*/
318 static void MPU_StoreHandleAndDataAtIndex( int32_t lIndex,
319 OpaqueObjectHandle_t xHandle,
320 void * pvKernelObjectData,
321 uint32_t ulKernelObjectType ) /* PRIVILEGED_FUNCTION */
323 configASSERT( IS_INTERNAL_INDEX_VALID( lIndex ) != pdFALSE );
324 xKernelObjectPool[ lIndex ].xInternalObjectHandle = xHandle;
325 xKernelObjectPool[ lIndex ].ulKernelObjectType = ulKernelObjectType;
326 xKernelObjectPool[ lIndex ].pvKernelObjectData = pvKernelObjectData;
328 /*-----------------------------------------------------------*/
330 static OpaqueObjectHandle_t MPU_GetHandleAtIndex( int32_t lIndex,
331 uint32_t ulKernelObjectType ) /* PRIVILEGED_FUNCTION */
333 OpaqueObjectHandle_t xObjectHandle = NULL;
335 configASSERT( IS_INTERNAL_INDEX_VALID( lIndex ) != pdFALSE );
337 if( xKernelObjectPool[ lIndex ].ulKernelObjectType == ulKernelObjectType )
339 xObjectHandle = xKernelObjectPool[ lIndex ].xInternalObjectHandle;
342 return xObjectHandle;
344 /*-----------------------------------------------------------*/
346 #if ( configENABLE_ACCESS_CONTROL_LIST == 1 )
348 void vGrantAccessToKernelObject( TaskHandle_t xExternalTaskHandle,
349 int32_t lExternalKernelObjectHandle ) /* PRIVILEGED_FUNCTION */
351 int32_t lExternalTaskIndex;
352 TaskHandle_t xInternalTaskHandle = NULL;
354 if( IS_EXTERNAL_INDEX_VALID( lExternalKernelObjectHandle ) != pdFALSE )
356 if( xExternalTaskHandle == NULL )
358 vPortGrantAccessToKernelObject( xExternalTaskHandle, CONVERT_TO_INTERNAL_INDEX( lExternalKernelObjectHandle ) );
362 lExternalTaskIndex = ( int32_t ) xExternalTaskHandle;
364 if( IS_EXTERNAL_INDEX_VALID( lExternalTaskIndex ) != pdFALSE )
366 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lExternalTaskIndex ) );
368 if( xInternalTaskHandle != NULL )
370 vPortGrantAccessToKernelObject( xInternalTaskHandle,
371 CONVERT_TO_INTERNAL_INDEX( lExternalKernelObjectHandle ) );
378 #endif /* #if ( configENABLE_ACCESS_CONTROL_LIST == 1 ) */
379 /*-----------------------------------------------------------*/
381 #if ( configENABLE_ACCESS_CONTROL_LIST == 1 )
383 void vRevokeAccessToKernelObject( TaskHandle_t xExternalTaskHandle,
384 int32_t lExternalKernelObjectHandle ) /* PRIVILEGED_FUNCTION */
386 int32_t lExternalTaskIndex;
387 TaskHandle_t xInternalTaskHandle = NULL;
389 if( IS_EXTERNAL_INDEX_VALID( lExternalKernelObjectHandle ) != pdFALSE )
391 if( xExternalTaskHandle == NULL )
393 vPortRevokeAccessToKernelObject( xExternalTaskHandle, CONVERT_TO_INTERNAL_INDEX( lExternalKernelObjectHandle ) );
397 lExternalTaskIndex = ( int32_t ) xExternalTaskHandle;
399 if( IS_EXTERNAL_INDEX_VALID( lExternalTaskIndex ) != pdFALSE )
401 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lExternalTaskIndex ) );
403 if( xInternalTaskHandle != NULL )
405 vPortRevokeAccessToKernelObject( xInternalTaskHandle,
406 CONVERT_TO_INTERNAL_INDEX( lExternalKernelObjectHandle ) );
413 #endif /* #if ( configENABLE_ACCESS_CONTROL_LIST == 1 ) */
414 /*-----------------------------------------------------------*/
416 #if ( configUSE_TIMERS == 1 )
418 static void MPU_TimerCallback( TimerHandle_t xInternalHandle ) /* PRIVILEGED_FUNCTION */
420 int32_t i, lIndex = -1;
421 TimerHandle_t xExternalHandle = NULL;
422 TimerCallbackFunction_t pxApplicationCallBack = NULL;
424 /* Coming from the timer task and therefore, should be valid. */
425 configASSERT( xInternalHandle != NULL );
427 for( i = 0; i < configPROTECTED_KERNEL_OBJECT_POOL_SIZE; i++ )
429 if( ( ( TimerHandle_t ) xKernelObjectPool[ i ].xInternalObjectHandle == xInternalHandle ) &&
430 ( xKernelObjectPool[ i ].ulKernelObjectType == KERNEL_OBJECT_TYPE_TIMER ) )
437 configASSERT( lIndex != -1 );
438 xExternalHandle = ( TimerHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
440 pxApplicationCallBack = ( TimerCallbackFunction_t ) xKernelObjectPool[ lIndex ].pvKernelObjectData;
441 pxApplicationCallBack( xExternalHandle );
444 #endif /* #if ( configUSE_TIMERS == 1 ) */
445 /*-----------------------------------------------------------*/
447 /*-----------------------------------------------------------*/
448 /* MPU wrappers for tasks APIs. */
449 /*-----------------------------------------------------------*/
451 #if ( INCLUDE_xTaskDelayUntil == 1 )
453 BaseType_t MPU_xTaskDelayUntilImpl( TickType_t * const pxPreviousWakeTime,
454 TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION;
456 BaseType_t MPU_xTaskDelayUntilImpl( TickType_t * const pxPreviousWakeTime,
457 TickType_t xTimeIncrement ) /* PRIVILEGED_FUNCTION */
459 BaseType_t xReturn = pdFAIL;
460 BaseType_t xIsPreviousWakeTimeAccessible = pdFALSE;
462 if( ( pxPreviousWakeTime != NULL ) && ( xTimeIncrement > 0U ) )
464 xIsPreviousWakeTimeAccessible = xPortIsAuthorizedToAccessBuffer( pxPreviousWakeTime,
465 sizeof( TickType_t ),
466 ( tskMPU_WRITE_PERMISSION | tskMPU_READ_PERMISSION ) );
468 if( xIsPreviousWakeTimeAccessible == pdTRUE )
470 xReturn = xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement );
477 #endif /* if ( INCLUDE_xTaskDelayUntil == 1 ) */
478 /*-----------------------------------------------------------*/
480 #if ( INCLUDE_xTaskAbortDelay == 1 )
482 BaseType_t MPU_xTaskAbortDelayImpl( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
484 BaseType_t MPU_xTaskAbortDelayImpl( TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
486 BaseType_t xReturn = pdFAIL;
487 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
488 TaskHandle_t xInternalTaskHandle = NULL;
491 lIndex = ( int32_t ) xTask;
493 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
495 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
497 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
499 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
501 if( xInternalTaskHandle != NULL )
503 xReturn = xTaskAbortDelay( xInternalTaskHandle );
511 #endif /* if ( INCLUDE_xTaskAbortDelay == 1 ) */
512 /*-----------------------------------------------------------*/
514 #if ( INCLUDE_vTaskDelay == 1 )
516 void MPU_vTaskDelayImpl( TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
518 void MPU_vTaskDelayImpl( TickType_t xTicksToDelay ) /* PRIVILEGED_FUNCTION */
520 vTaskDelay( xTicksToDelay );
523 #endif /* if ( INCLUDE_vTaskDelay == 1 ) */
524 /*-----------------------------------------------------------*/
526 #if ( INCLUDE_uxTaskPriorityGet == 1 )
528 UBaseType_t MPU_uxTaskPriorityGetImpl( const TaskHandle_t pxTask ) PRIVILEGED_FUNCTION;
530 UBaseType_t MPU_uxTaskPriorityGetImpl( const TaskHandle_t pxTask ) /* PRIVILEGED_FUNCTION */
532 UBaseType_t uxReturn = configMAX_PRIORITIES;
533 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
535 TaskHandle_t xInternalTaskHandle = NULL;
539 uxReturn = uxTaskPriorityGet( pxTask );
543 lIndex = ( int32_t ) pxTask;
545 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
547 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
549 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
551 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
553 if( xInternalTaskHandle != NULL )
555 uxReturn = uxTaskPriorityGet( xInternalTaskHandle );
564 #endif /* if ( INCLUDE_uxTaskPriorityGet == 1 ) */
565 /*-----------------------------------------------------------*/
567 #if ( INCLUDE_eTaskGetState == 1 )
569 eTaskState MPU_eTaskGetStateImpl( TaskHandle_t pxTask ) PRIVILEGED_FUNCTION;
571 eTaskState MPU_eTaskGetStateImpl( TaskHandle_t pxTask ) /* PRIVILEGED_FUNCTION */
573 eTaskState eReturn = eInvalid;
574 TaskHandle_t xInternalTaskHandle = NULL;
576 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
578 lIndex = ( int32_t ) pxTask;
580 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
582 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
584 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
586 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
588 if( xInternalTaskHandle != NULL )
590 eReturn = eTaskGetState( xInternalTaskHandle );
598 #endif /* if ( INCLUDE_eTaskGetState == 1 ) */
599 /*-----------------------------------------------------------*/
601 #if ( configUSE_TRACE_FACILITY == 1 )
603 void MPU_vTaskGetInfoImpl( TaskHandle_t xTask,
604 TaskStatus_t * pxTaskStatus,
605 BaseType_t xGetFreeStackSpace,
606 eTaskState eState ) PRIVILEGED_FUNCTION;
608 void MPU_vTaskGetInfoImpl( TaskHandle_t xTask,
609 TaskStatus_t * pxTaskStatus,
610 BaseType_t xGetFreeStackSpace,
611 eTaskState eState ) /* PRIVILEGED_FUNCTION */
614 TaskHandle_t xInternalTaskHandle = NULL;
615 BaseType_t xIsTaskStatusWriteable = pdFALSE;
616 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
618 xIsTaskStatusWriteable = xPortIsAuthorizedToAccessBuffer( pxTaskStatus,
619 sizeof( TaskStatus_t ),
620 tskMPU_WRITE_PERMISSION );
622 if( xIsTaskStatusWriteable == pdTRUE )
626 vTaskGetInfo( xTask, pxTaskStatus, xGetFreeStackSpace, eState );
630 lIndex = ( int32_t ) xTask;
632 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
634 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
636 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
638 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
640 if( xInternalTaskHandle != NULL )
642 vTaskGetInfo( xInternalTaskHandle, pxTaskStatus, xGetFreeStackSpace, eState );
650 #endif /* if ( configUSE_TRACE_FACILITY == 1 ) */
651 /*-----------------------------------------------------------*/
653 #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
655 TaskHandle_t MPU_xTaskGetIdleTaskHandleImpl( void ) PRIVILEGED_FUNCTION;
657 TaskHandle_t MPU_xTaskGetIdleTaskHandleImpl( void ) /* PRIVILEGED_FUNCTION */
659 TaskHandle_t xIdleTaskHandle = NULL;
661 xIdleTaskHandle = xTaskGetIdleTaskHandle();
663 return xIdleTaskHandle;
666 #endif /* if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) */
667 /*-----------------------------------------------------------*/
669 #if ( INCLUDE_vTaskSuspend == 1 )
671 void MPU_vTaskSuspendImpl( TaskHandle_t pxTaskToSuspend ) PRIVILEGED_FUNCTION;
673 void MPU_vTaskSuspendImpl( TaskHandle_t pxTaskToSuspend ) /* PRIVILEGED_FUNCTION */
676 TaskHandle_t xInternalTaskHandle = NULL;
677 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
679 if( pxTaskToSuspend == NULL )
681 vTaskSuspend( pxTaskToSuspend );
685 /* After the scheduler starts, only privileged tasks are allowed
686 * to suspend other tasks. */
687 #if ( INCLUDE_xTaskGetSchedulerState == 1 )
688 if( ( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED ) || ( portIS_TASK_PRIVILEGED() == pdTRUE ) )
690 if( portIS_TASK_PRIVILEGED() == pdTRUE )
693 lIndex = ( int32_t ) pxTaskToSuspend;
695 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
697 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
699 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
701 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
703 if( xInternalTaskHandle != NULL )
705 vTaskSuspend( xInternalTaskHandle );
713 #endif /* if ( INCLUDE_vTaskSuspend == 1 ) */
714 /*-----------------------------------------------------------*/
716 #if ( INCLUDE_vTaskSuspend == 1 )
718 void MPU_vTaskResumeImpl( TaskHandle_t pxTaskToResume ) PRIVILEGED_FUNCTION;
720 void MPU_vTaskResumeImpl( TaskHandle_t pxTaskToResume ) /* PRIVILEGED_FUNCTION */
723 TaskHandle_t xInternalTaskHandle = NULL;
724 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
726 lIndex = ( int32_t ) pxTaskToResume;
728 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
730 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
732 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
734 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
736 if( xInternalTaskHandle != NULL )
738 vTaskResume( xInternalTaskHandle );
744 #endif /* if ( INCLUDE_vTaskSuspend == 1 ) */
745 /*-----------------------------------------------------------*/
747 TickType_t MPU_xTaskGetTickCountImpl( void ) PRIVILEGED_FUNCTION;
749 TickType_t MPU_xTaskGetTickCountImpl( void ) /* PRIVILEGED_FUNCTION */
753 xReturn = xTaskGetTickCount();
757 /*-----------------------------------------------------------*/
759 UBaseType_t MPU_uxTaskGetNumberOfTasksImpl( void ) PRIVILEGED_FUNCTION;
761 UBaseType_t MPU_uxTaskGetNumberOfTasksImpl( void ) /* PRIVILEGED_FUNCTION */
763 UBaseType_t uxReturn;
765 uxReturn = uxTaskGetNumberOfTasks();
769 /*-----------------------------------------------------------*/
771 #if ( configGENERATE_RUN_TIME_STATS == 1 )
773 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetRunTimeCounterImpl( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
775 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetRunTimeCounterImpl( const TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
777 configRUN_TIME_COUNTER_TYPE xReturn = 0;
779 TaskHandle_t xInternalTaskHandle = NULL;
780 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
784 xReturn = ulTaskGetRunTimeCounter( xTask );
788 lIndex = ( int32_t ) xTask;
790 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
792 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
794 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
796 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
798 if( xInternalTaskHandle != NULL )
800 xReturn = ulTaskGetRunTimeCounter( xInternalTaskHandle );
809 #endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) */
810 /*-----------------------------------------------------------*/
812 #if ( configGENERATE_RUN_TIME_STATS == 1 )
814 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetRunTimePercentImpl( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
816 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetRunTimePercentImpl( const TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
818 configRUN_TIME_COUNTER_TYPE xReturn = 0;
820 TaskHandle_t xInternalTaskHandle = NULL;
821 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
825 xReturn = ulTaskGetRunTimePercent( xTask );
829 lIndex = ( int32_t ) xTask;
831 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
833 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
835 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
837 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
839 if( xInternalTaskHandle != NULL )
841 xReturn = ulTaskGetRunTimePercent( xInternalTaskHandle );
850 #endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) */
851 /*-----------------------------------------------------------*/
853 #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) )
855 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimePercentImpl( void ) PRIVILEGED_FUNCTION;
857 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimePercentImpl( void ) /* PRIVILEGED_FUNCTION */
859 configRUN_TIME_COUNTER_TYPE xReturn;
861 xReturn = ulTaskGetIdleRunTimePercent();
866 #endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) */
867 /*-----------------------------------------------------------*/
869 #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) )
871 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimeCounterImpl( void ) PRIVILEGED_FUNCTION;
873 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimeCounterImpl( void ) /* PRIVILEGED_FUNCTION */
875 configRUN_TIME_COUNTER_TYPE xReturn;
877 xReturn = ulTaskGetIdleRunTimeCounter();
882 #endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) */
883 /*-----------------------------------------------------------*/
885 #if ( configUSE_APPLICATION_TASK_TAG == 1 )
887 void MPU_vTaskSetApplicationTaskTagImpl( TaskHandle_t xTask,
888 TaskHookFunction_t pxTagValue ) PRIVILEGED_FUNCTION;
890 void MPU_vTaskSetApplicationTaskTagImpl( TaskHandle_t xTask,
891 TaskHookFunction_t pxTagValue ) /* PRIVILEGED_FUNCTION */
893 TaskHandle_t xInternalTaskHandle = NULL;
895 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
899 vTaskSetApplicationTaskTag( xTask, pxTagValue );
903 lIndex = ( int32_t ) xTask;
905 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
907 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
909 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
911 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
913 if( xInternalTaskHandle != NULL )
915 vTaskSetApplicationTaskTag( xInternalTaskHandle, pxTagValue );
922 #endif /* if ( configUSE_APPLICATION_TASK_TAG == 1 ) */
923 /*-----------------------------------------------------------*/
925 #if ( configUSE_APPLICATION_TASK_TAG == 1 )
927 TaskHookFunction_t MPU_xTaskGetApplicationTaskTagImpl( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
929 TaskHookFunction_t MPU_xTaskGetApplicationTaskTagImpl( TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
931 TaskHookFunction_t xReturn = NULL;
933 TaskHandle_t xInternalTaskHandle = NULL;
934 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
938 xReturn = xTaskGetApplicationTaskTag( xTask );
942 lIndex = ( int32_t ) xTask;
944 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
946 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
948 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
950 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
952 if( xInternalTaskHandle != NULL )
954 xReturn = xTaskGetApplicationTaskTag( xInternalTaskHandle );
963 #endif /* if ( configUSE_APPLICATION_TASK_TAG == 1 ) */
964 /*-----------------------------------------------------------*/
966 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
968 void MPU_vTaskSetThreadLocalStoragePointerImpl( TaskHandle_t xTaskToSet,
970 void * pvValue ) PRIVILEGED_FUNCTION;
972 void MPU_vTaskSetThreadLocalStoragePointerImpl( TaskHandle_t xTaskToSet,
974 void * pvValue ) /* PRIVILEGED_FUNCTION */
977 TaskHandle_t xInternalTaskHandle = NULL;
978 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
980 if( xTaskToSet == NULL )
982 vTaskSetThreadLocalStoragePointer( xTaskToSet, xIndex, pvValue );
986 lIndex = ( int32_t ) xTaskToSet;
988 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
990 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
992 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
994 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
996 if( xInternalTaskHandle != NULL )
998 vTaskSetThreadLocalStoragePointer( xInternalTaskHandle, xIndex, pvValue );
1005 #endif /* if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) */
1006 /*-----------------------------------------------------------*/
1008 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
1010 void * MPU_pvTaskGetThreadLocalStoragePointerImpl( TaskHandle_t xTaskToQuery,
1011 BaseType_t xIndex ) PRIVILEGED_FUNCTION;
1013 void * MPU_pvTaskGetThreadLocalStoragePointerImpl( TaskHandle_t xTaskToQuery,
1014 BaseType_t xIndex ) /* PRIVILEGED_FUNCTION */
1016 void * pvReturn = NULL;
1018 TaskHandle_t xInternalTaskHandle = NULL;
1019 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
1021 if( xTaskToQuery == NULL )
1023 pvReturn = pvTaskGetThreadLocalStoragePointer( xTaskToQuery, xIndex );
1027 lIndex = ( int32_t ) xTaskToQuery;
1029 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1031 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1033 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
1035 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1037 if( xInternalTaskHandle != NULL )
1039 pvReturn = pvTaskGetThreadLocalStoragePointer( xInternalTaskHandle, xIndex );
1048 #endif /* if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) */
1049 /*-----------------------------------------------------------*/
1051 #if ( configUSE_TRACE_FACILITY == 1 )
1053 UBaseType_t MPU_uxTaskGetSystemStateImpl( TaskStatus_t * pxTaskStatusArray,
1054 UBaseType_t uxArraySize,
1055 configRUN_TIME_COUNTER_TYPE * pulTotalRunTime ) PRIVILEGED_FUNCTION;
1057 UBaseType_t MPU_uxTaskGetSystemStateImpl( TaskStatus_t * pxTaskStatusArray,
1058 UBaseType_t uxArraySize,
1059 configRUN_TIME_COUNTER_TYPE * pulTotalRunTime ) /* PRIVILEGED_FUNCTION */
1061 UBaseType_t uxReturn = 0;
1062 UBaseType_t xIsTaskStatusArrayWriteable = pdFALSE;
1063 UBaseType_t xIsTotalRunTimeWriteable = pdFALSE;
1064 uint32_t ulArraySize = ( uint32_t ) uxArraySize;
1065 uint32_t ulTaskStatusSize = ( uint32_t ) sizeof( TaskStatus_t );
1067 if( mpuMULTIPLY_UINT32_WILL_OVERFLOW( ulTaskStatusSize, ulArraySize ) == 0 )
1069 xIsTaskStatusArrayWriteable = xPortIsAuthorizedToAccessBuffer( pxTaskStatusArray,
1070 ulTaskStatusSize * ulArraySize,
1071 tskMPU_WRITE_PERMISSION );
1073 if( pulTotalRunTime != NULL )
1075 xIsTotalRunTimeWriteable = xPortIsAuthorizedToAccessBuffer( pulTotalRunTime,
1076 sizeof( configRUN_TIME_COUNTER_TYPE ),
1077 tskMPU_WRITE_PERMISSION );
1080 if( ( xIsTaskStatusArrayWriteable == pdTRUE ) &&
1081 ( ( pulTotalRunTime == NULL ) || ( xIsTotalRunTimeWriteable == pdTRUE ) ) )
1083 uxReturn = uxTaskGetSystemState( pxTaskStatusArray, ( UBaseType_t ) ulArraySize, pulTotalRunTime );
1090 #endif /* if ( configUSE_TRACE_FACILITY == 1 ) */
1091 /*-----------------------------------------------------------*/
1093 #if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )
1095 UBaseType_t MPU_uxTaskGetStackHighWaterMarkImpl( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1097 UBaseType_t MPU_uxTaskGetStackHighWaterMarkImpl( TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
1099 UBaseType_t uxReturn = 0;
1101 TaskHandle_t xInternalTaskHandle = NULL;
1102 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
1106 uxReturn = uxTaskGetStackHighWaterMark( xTask );
1110 lIndex = ( int32_t ) xTask;
1112 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1114 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1116 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
1118 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1120 if( xInternalTaskHandle != NULL )
1122 uxReturn = uxTaskGetStackHighWaterMark( xInternalTaskHandle );
1131 #endif /* if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) */
1132 /*-----------------------------------------------------------*/
1134 #if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 )
1136 configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2Impl( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1138 configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2Impl( TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
1140 configSTACK_DEPTH_TYPE uxReturn = 0;
1142 TaskHandle_t xInternalTaskHandle = NULL;
1143 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
1147 uxReturn = uxTaskGetStackHighWaterMark2( xTask );
1151 lIndex = ( int32_t ) xTask;
1153 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1155 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1157 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
1159 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1161 if( xInternalTaskHandle != NULL )
1163 uxReturn = uxTaskGetStackHighWaterMark2( xInternalTaskHandle );
1172 #endif /* if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) */
1173 /*-----------------------------------------------------------*/
1175 #if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_RECURSIVE_MUTEXES == 1 ) )
1177 TaskHandle_t MPU_xTaskGetCurrentTaskHandleImpl( void ) PRIVILEGED_FUNCTION;
1179 TaskHandle_t MPU_xTaskGetCurrentTaskHandleImpl( void ) /* PRIVILEGED_FUNCTION */
1181 TaskHandle_t xInternalTaskHandle = NULL;
1182 TaskHandle_t xExternalTaskHandle = NULL;
1185 xInternalTaskHandle = xTaskGetCurrentTaskHandle();
1187 if( xInternalTaskHandle != NULL )
1189 lIndex = MPU_GetIndexForTaskHandle( xInternalTaskHandle );
1193 xExternalTaskHandle = ( TaskHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
1197 return xExternalTaskHandle;
1200 #endif /* if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_RECURSIVE_MUTEXES == 1 ) ) */
1201 /*-----------------------------------------------------------*/
1203 #if ( INCLUDE_xTaskGetSchedulerState == 1 )
1205 BaseType_t MPU_xTaskGetSchedulerStateImpl( void ) PRIVILEGED_FUNCTION;
1207 BaseType_t MPU_xTaskGetSchedulerStateImpl( void ) /* PRIVILEGED_FUNCTION */
1209 BaseType_t xReturn = taskSCHEDULER_NOT_STARTED;
1211 xReturn = xTaskGetSchedulerState();
1216 #endif /* if ( INCLUDE_xTaskGetSchedulerState == 1 ) */
1217 /*-----------------------------------------------------------*/
1219 void MPU_vTaskSetTimeOutStateImpl( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
1221 void MPU_vTaskSetTimeOutStateImpl( TimeOut_t * const pxTimeOut ) /* PRIVILEGED_FUNCTION */
1223 BaseType_t xIsTimeOutWriteable = pdFALSE;
1225 if( pxTimeOut != NULL )
1227 xIsTimeOutWriteable = xPortIsAuthorizedToAccessBuffer( pxTimeOut,
1228 sizeof( TimeOut_t ),
1229 tskMPU_WRITE_PERMISSION );
1231 if( xIsTimeOutWriteable == pdTRUE )
1233 vTaskSetTimeOutState( pxTimeOut );
1237 /*-----------------------------------------------------------*/
1239 BaseType_t MPU_xTaskCheckForTimeOutImpl( TimeOut_t * const pxTimeOut,
1240 TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION;
1242 BaseType_t MPU_xTaskCheckForTimeOutImpl( TimeOut_t * const pxTimeOut,
1243 TickType_t * const pxTicksToWait ) /* PRIVILEGED_FUNCTION */
1245 BaseType_t xReturn = pdFALSE;
1246 BaseType_t xIsTimeOutWriteable = pdFALSE;
1247 BaseType_t xIsTicksToWaitWriteable = pdFALSE;
1249 if( ( pxTimeOut != NULL ) && ( pxTicksToWait != NULL ) )
1251 xIsTimeOutWriteable = xPortIsAuthorizedToAccessBuffer( pxTimeOut,
1252 sizeof( TimeOut_t ),
1253 tskMPU_WRITE_PERMISSION );
1254 xIsTicksToWaitWriteable = xPortIsAuthorizedToAccessBuffer( pxTicksToWait,
1255 sizeof( TickType_t ),
1256 tskMPU_WRITE_PERMISSION );
1258 if( ( xIsTimeOutWriteable == pdTRUE ) && ( xIsTicksToWaitWriteable == pdTRUE ) )
1260 xReturn = xTaskCheckForTimeOut( pxTimeOut, pxTicksToWait );
1266 /*-----------------------------------------------------------*/
1268 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
1270 BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify,
1271 UBaseType_t uxIndexToNotify,
1273 eNotifyAction eAction,
1274 uint32_t * pulPreviousNotificationValue ) /* FREERTOS_SYSTEM_CALL */
1276 BaseType_t xReturn = pdFAIL;
1277 xTaskGenericNotifyParams_t xParams;
1279 xParams.xTaskToNotify = xTaskToNotify;
1280 xParams.uxIndexToNotify = uxIndexToNotify;
1281 xParams.ulValue = ulValue;
1282 xParams.eAction = eAction;
1283 xParams.pulPreviousNotificationValue = pulPreviousNotificationValue;
1285 xReturn = MPU_xTaskGenericNotifyEntry( &( xParams ) );
1290 BaseType_t MPU_xTaskGenericNotifyImpl( const xTaskGenericNotifyParams_t * pxParams ) PRIVILEGED_FUNCTION;
1292 BaseType_t MPU_xTaskGenericNotifyImpl( const xTaskGenericNotifyParams_t * pxParams ) /* PRIVILEGED_FUNCTION */
1294 BaseType_t xReturn = pdFAIL;
1296 TaskHandle_t xInternalTaskHandle = NULL;
1297 BaseType_t xIsPreviousNotificationValueWriteable = pdFALSE;
1298 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
1299 BaseType_t xAreParamsReadable = pdFALSE;
1301 if( pxParams != NULL )
1303 xAreParamsReadable = xPortIsAuthorizedToAccessBuffer( pxParams,
1304 sizeof( xTaskGenericNotifyParams_t ),
1305 tskMPU_READ_PERMISSION );
1308 if( xAreParamsReadable == pdTRUE )
1310 if( ( pxParams->uxIndexToNotify < configTASK_NOTIFICATION_ARRAY_ENTRIES ) &&
1311 ( ( pxParams->eAction == eNoAction ) ||
1312 ( pxParams->eAction == eSetBits ) ||
1313 ( pxParams->eAction == eIncrement ) ||
1314 ( pxParams->eAction == eSetValueWithOverwrite ) ||
1315 ( pxParams->eAction == eSetValueWithoutOverwrite ) ) )
1317 if( pxParams->pulPreviousNotificationValue != NULL )
1319 xIsPreviousNotificationValueWriteable = xPortIsAuthorizedToAccessBuffer( pxParams->pulPreviousNotificationValue,
1321 tskMPU_WRITE_PERMISSION );
1324 if( ( pxParams->pulPreviousNotificationValue == NULL ) ||
1325 ( xIsPreviousNotificationValueWriteable == pdTRUE ) )
1327 lIndex = ( int32_t ) ( pxParams->xTaskToNotify );
1329 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1331 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1333 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
1335 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1337 if( xInternalTaskHandle != NULL )
1339 xReturn = xTaskGenericNotify( xInternalTaskHandle,
1340 pxParams->uxIndexToNotify,
1343 pxParams->pulPreviousNotificationValue );
1354 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
1355 /*-----------------------------------------------------------*/
1357 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
1359 BaseType_t MPU_xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn,
1360 uint32_t ulBitsToClearOnEntry,
1361 uint32_t ulBitsToClearOnExit,
1362 uint32_t * pulNotificationValue,
1363 TickType_t xTicksToWait )
1365 BaseType_t xReturn = pdFAIL;
1366 xTaskGenericNotifyWaitParams_t xParams;
1368 xParams.uxIndexToWaitOn = uxIndexToWaitOn;
1369 xParams.ulBitsToClearOnEntry = ulBitsToClearOnEntry;
1370 xParams.ulBitsToClearOnExit = ulBitsToClearOnExit;
1371 xParams.pulNotificationValue = pulNotificationValue;
1372 xParams.xTicksToWait = xTicksToWait;
1374 xReturn = MPU_xTaskGenericNotifyWaitEntry( &( xParams ) );
1379 BaseType_t MPU_xTaskGenericNotifyWaitImpl( const xTaskGenericNotifyWaitParams_t * pxParams ) PRIVILEGED_FUNCTION;
1381 BaseType_t MPU_xTaskGenericNotifyWaitImpl( const xTaskGenericNotifyWaitParams_t * pxParams ) /* PRIVILEGED_FUNCTION */
1383 BaseType_t xReturn = pdFAIL;
1384 BaseType_t xIsNotificationValueWritable = pdFALSE;
1385 BaseType_t xAreParamsReadable = pdFALSE;
1387 if( pxParams != NULL )
1389 xAreParamsReadable = xPortIsAuthorizedToAccessBuffer( pxParams,
1390 sizeof( xTaskGenericNotifyWaitParams_t ),
1391 tskMPU_READ_PERMISSION );
1394 if( xAreParamsReadable == pdTRUE )
1396 if( pxParams->uxIndexToWaitOn < configTASK_NOTIFICATION_ARRAY_ENTRIES )
1398 if( pxParams->pulNotificationValue != NULL )
1400 xIsNotificationValueWritable = xPortIsAuthorizedToAccessBuffer( pxParams->pulNotificationValue,
1402 tskMPU_WRITE_PERMISSION );
1405 if( ( pxParams->pulNotificationValue == NULL ) ||
1406 ( xIsNotificationValueWritable == pdTRUE ) )
1408 xReturn = xTaskGenericNotifyWait( pxParams->uxIndexToWaitOn,
1409 pxParams->ulBitsToClearOnEntry,
1410 pxParams->ulBitsToClearOnExit,
1411 pxParams->pulNotificationValue,
1412 pxParams->xTicksToWait );
1420 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
1421 /*-----------------------------------------------------------*/
1423 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
1425 uint32_t MPU_ulTaskGenericNotifyTakeImpl( UBaseType_t uxIndexToWaitOn,
1426 BaseType_t xClearCountOnExit,
1427 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
1429 uint32_t MPU_ulTaskGenericNotifyTakeImpl( UBaseType_t uxIndexToWaitOn,
1430 BaseType_t xClearCountOnExit,
1431 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
1433 uint32_t ulReturn = 0;
1435 if( uxIndexToWaitOn < configTASK_NOTIFICATION_ARRAY_ENTRIES )
1437 ulReturn = ulTaskGenericNotifyTake( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait );
1443 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
1444 /*-----------------------------------------------------------*/
1446 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
1448 BaseType_t MPU_xTaskGenericNotifyStateClearImpl( TaskHandle_t xTask,
1449 UBaseType_t uxIndexToClear ) PRIVILEGED_FUNCTION;
1451 BaseType_t MPU_xTaskGenericNotifyStateClearImpl( TaskHandle_t xTask,
1452 UBaseType_t uxIndexToClear ) /* PRIVILEGED_FUNCTION */
1454 BaseType_t xReturn = pdFAIL;
1456 TaskHandle_t xInternalTaskHandle = NULL;
1457 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
1459 if( uxIndexToClear < configTASK_NOTIFICATION_ARRAY_ENTRIES )
1463 xReturn = xTaskGenericNotifyStateClear( xTask, uxIndexToClear );
1467 lIndex = ( int32_t ) xTask;
1469 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1471 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1473 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
1475 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1477 if( xInternalTaskHandle != NULL )
1479 xReturn = xTaskGenericNotifyStateClear( xInternalTaskHandle, uxIndexToClear );
1489 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
1490 /*-----------------------------------------------------------*/
1492 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
1494 uint32_t MPU_ulTaskGenericNotifyValueClearImpl( TaskHandle_t xTask,
1495 UBaseType_t uxIndexToClear,
1496 uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;
1498 uint32_t MPU_ulTaskGenericNotifyValueClearImpl( TaskHandle_t xTask,
1499 UBaseType_t uxIndexToClear,
1500 uint32_t ulBitsToClear ) /* PRIVILEGED_FUNCTION */
1502 uint32_t ulReturn = 0;
1504 TaskHandle_t xInternalTaskHandle = NULL;
1505 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
1507 if( uxIndexToClear < configTASK_NOTIFICATION_ARRAY_ENTRIES )
1511 ulReturn = ulTaskGenericNotifyValueClear( xTask, uxIndexToClear, ulBitsToClear );
1515 lIndex = ( int32_t ) xTask;
1517 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1519 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1521 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
1523 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1525 if( xInternalTaskHandle != NULL )
1527 ulReturn = ulTaskGenericNotifyValueClear( xInternalTaskHandle, uxIndexToClear, ulBitsToClear );
1537 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
1538 /*-----------------------------------------------------------*/
1540 /* Privileged only wrappers for Task APIs. These are needed so that
1541 * the application can use opaque handles maintained in mpu_wrappers.c
1542 * with all the APIs. */
1543 /*-----------------------------------------------------------*/
1545 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
1547 BaseType_t MPU_xTaskCreate( TaskFunction_t pvTaskCode,
1548 const char * const pcName,
1549 const configSTACK_DEPTH_TYPE uxStackDepth,
1550 void * pvParameters,
1551 UBaseType_t uxPriority,
1552 TaskHandle_t * pxCreatedTask ) /* PRIVILEGED_FUNCTION */
1554 BaseType_t xReturn = pdFAIL;
1556 TaskHandle_t xInternalTaskHandle = NULL;
1558 lIndex = MPU_GetFreeIndexInKernelObjectPool();
1562 /* xTaskCreate() can only be used to create privileged tasks in MPU port. */
1563 if( ( uxPriority & portPRIVILEGE_BIT ) != 0 )
1565 xReturn = xTaskCreate( pvTaskCode, pcName, uxStackDepth, pvParameters, uxPriority, &( xInternalTaskHandle ) );
1567 if( ( xReturn == pdPASS ) && ( xInternalTaskHandle != NULL ) )
1569 MPU_StoreTaskHandleAtIndex( lIndex, xInternalTaskHandle );
1571 if( pxCreatedTask != NULL )
1573 *pxCreatedTask = ( TaskHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
1578 MPU_SetIndexFreeInKernelObjectPool( lIndex );
1586 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
1587 /*-----------------------------------------------------------*/
1589 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1591 TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode,
1592 const char * const pcName,
1593 const configSTACK_DEPTH_TYPE uxStackDepth,
1594 void * const pvParameters,
1595 UBaseType_t uxPriority,
1596 StackType_t * const puxStackBuffer,
1597 StaticTask_t * const pxTaskBuffer ) /* PRIVILEGED_FUNCTION */
1599 TaskHandle_t xExternalTaskHandle = NULL;
1600 TaskHandle_t xInternalTaskHandle = NULL;
1603 lIndex = MPU_GetFreeIndexInKernelObjectPool();
1607 xInternalTaskHandle = xTaskCreateStatic( pxTaskCode, pcName, uxStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer );
1609 if( xInternalTaskHandle != NULL )
1611 MPU_StoreTaskHandleAtIndex( lIndex, xInternalTaskHandle );
1613 #if ( configENABLE_ACCESS_CONTROL_LIST == 1 )
1615 /* By default, an unprivileged task has access to itself. */
1616 if( ( uxPriority & portPRIVILEGE_BIT ) == 0 )
1618 vPortGrantAccessToKernelObject( xInternalTaskHandle, lIndex );
1623 xExternalTaskHandle = ( TaskHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
1627 MPU_SetIndexFreeInKernelObjectPool( lIndex );
1631 return xExternalTaskHandle;
1634 #endif /* configSUPPORT_STATIC_ALLOCATION */
1635 /*-----------------------------------------------------------*/
1637 #if ( INCLUDE_vTaskDelete == 1 )
1639 void MPU_vTaskDelete( TaskHandle_t pxTaskToDelete ) /* PRIVILEGED_FUNCTION */
1641 TaskHandle_t xInternalTaskHandle = NULL;
1644 if( pxTaskToDelete == NULL )
1646 xInternalTaskHandle = xTaskGetCurrentTaskHandle();
1647 lIndex = MPU_GetIndexForTaskHandle( xInternalTaskHandle );
1651 MPU_SetIndexFreeInKernelObjectPool( lIndex );
1654 vTaskDelete( xInternalTaskHandle );
1658 lIndex = ( int32_t ) pxTaskToDelete;
1660 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1662 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1664 if( xInternalTaskHandle != NULL )
1666 MPU_SetIndexFreeInKernelObjectPool( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1667 vTaskDelete( xInternalTaskHandle );
1673 #endif /* #if ( INCLUDE_vTaskDelete == 1 ) */
1674 /*-----------------------------------------------------------*/
1677 #if ( INCLUDE_vTaskPrioritySet == 1 )
1679 void MPU_vTaskPrioritySet( TaskHandle_t pxTask,
1680 UBaseType_t uxNewPriority ) /* PRIVILEGED_FUNCTION */
1682 TaskHandle_t xInternalTaskHandle = NULL;
1685 if( pxTask == NULL )
1687 vTaskPrioritySet( pxTask, uxNewPriority );
1691 lIndex = ( int32_t ) pxTask;
1693 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1695 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1697 if( xInternalTaskHandle != NULL )
1699 vTaskPrioritySet( xInternalTaskHandle, uxNewPriority );
1705 #endif /* if ( INCLUDE_vTaskPrioritySet == 1 ) */
1706 /*-----------------------------------------------------------*/
1708 #if ( INCLUDE_xTaskGetHandle == 1 )
1710 TaskHandle_t MPU_xTaskGetHandle( const char * pcNameToQuery ) /* PRIVILEGED_FUNCTION */
1712 TaskHandle_t xInternalTaskHandle = NULL;
1713 TaskHandle_t xExternalTaskHandle = NULL;
1716 xInternalTaskHandle = xTaskGetHandle( pcNameToQuery );
1718 if( xInternalTaskHandle != NULL )
1720 lIndex = MPU_GetIndexForTaskHandle( xInternalTaskHandle );
1724 xExternalTaskHandle = ( TaskHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
1728 return xExternalTaskHandle;
1731 #endif /* if ( INCLUDE_xTaskGetHandle == 1 ) */
1732 /*-----------------------------------------------------------*/
1735 #if ( configUSE_APPLICATION_TASK_TAG == 1 )
1737 BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask,
1738 void * pvParameter ) /* PRIVILEGED_FUNCTION */
1740 BaseType_t xReturn = pdFAIL;
1742 TaskHandle_t xInternalTaskHandle = NULL;
1746 xReturn = xTaskCallApplicationTaskHook( xTask, pvParameter );
1750 lIndex = ( int32_t ) xTask;
1752 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1754 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1756 if( xInternalTaskHandle != NULL )
1758 xReturn = xTaskCallApplicationTaskHook( xInternalTaskHandle, pvParameter );
1766 #endif /* if ( configUSE_APPLICATION_TASK_TAG == 1 ) */
1767 /*-----------------------------------------------------------*/
1769 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
1771 BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition,
1772 TaskHandle_t * pxCreatedTask ) /* PRIVILEGED_FUNCTION */
1774 BaseType_t xReturn = pdFAIL;
1776 TaskHandle_t xInternalTaskHandle = NULL;
1778 lIndex = MPU_GetFreeIndexInKernelObjectPool();
1782 xReturn = xTaskCreateRestricted( pxTaskDefinition, &( xInternalTaskHandle ) );
1784 if( ( xReturn == pdPASS ) && ( xInternalTaskHandle != NULL ) )
1786 MPU_StoreTaskHandleAtIndex( lIndex, xInternalTaskHandle );
1788 #if ( configENABLE_ACCESS_CONTROL_LIST == 1 )
1790 /* By default, an unprivileged task has access to itself. */
1791 if( ( pxTaskDefinition->uxPriority & portPRIVILEGE_BIT ) == 0 )
1793 vPortGrantAccessToKernelObject( xInternalTaskHandle, lIndex );
1798 if( pxCreatedTask != NULL )
1800 *pxCreatedTask = ( TaskHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
1805 MPU_SetIndexFreeInKernelObjectPool( lIndex );
1812 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
1813 /*-----------------------------------------------------------*/
1815 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1817 BaseType_t MPU_xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition,
1818 TaskHandle_t * pxCreatedTask ) /* PRIVILEGED_FUNCTION */
1820 BaseType_t xReturn = pdFAIL;
1822 TaskHandle_t xInternalTaskHandle = NULL;
1824 lIndex = MPU_GetFreeIndexInKernelObjectPool();
1828 xReturn = xTaskCreateRestrictedStatic( pxTaskDefinition, &( xInternalTaskHandle ) );
1830 if( ( xReturn == pdPASS ) && ( xInternalTaskHandle != NULL ) )
1832 MPU_StoreTaskHandleAtIndex( lIndex, xInternalTaskHandle );
1834 #if ( configENABLE_ACCESS_CONTROL_LIST == 1 )
1836 /* By default, an unprivileged task has access to itself. */
1837 if( ( pxTaskDefinition->uxPriority & portPRIVILEGE_BIT ) == 0 )
1839 vPortGrantAccessToKernelObject( xInternalTaskHandle, lIndex );
1844 if( pxCreatedTask != NULL )
1846 *pxCreatedTask = ( TaskHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
1851 MPU_SetIndexFreeInKernelObjectPool( lIndex );
1858 #endif /* configSUPPORT_STATIC_ALLOCATION */
1859 /*-----------------------------------------------------------*/
1861 void MPU_vTaskAllocateMPURegions( TaskHandle_t xTaskToModify,
1862 const MemoryRegion_t * const xRegions ) /* PRIVILEGED_FUNCTION */
1864 TaskHandle_t xInternalTaskHandle = NULL;
1867 if( xTaskToModify == NULL )
1869 vTaskAllocateMPURegions( xTaskToModify, xRegions );
1873 lIndex = ( int32_t ) xTaskToModify;
1875 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1877 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1879 if( xInternalTaskHandle != NULL )
1881 vTaskAllocateMPURegions( xInternalTaskHandle, xRegions );
1886 /*-----------------------------------------------------------*/
1888 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1890 BaseType_t MPU_xTaskGetStaticBuffers( TaskHandle_t xTask,
1891 StackType_t ** ppuxStackBuffer,
1892 StaticTask_t ** ppxTaskBuffer ) /* PRIVILEGED_FUNCTION */
1894 TaskHandle_t xInternalTaskHandle = NULL;
1896 BaseType_t xReturn = pdFALSE;
1900 xInternalTaskHandle = xTaskGetCurrentTaskHandle();
1901 xReturn = xTaskGetStaticBuffers( xInternalTaskHandle, ppuxStackBuffer, ppxTaskBuffer );
1905 lIndex = ( int32_t ) xTask;
1907 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1909 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1911 if( xInternalTaskHandle != NULL )
1913 xReturn = xTaskGetStaticBuffers( xInternalTaskHandle, ppuxStackBuffer, ppxTaskBuffer );
1921 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
1922 /*-----------------------------------------------------------*/
1924 char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) /* PRIVILEGED_FUNCTION */
1926 char * pcReturn = NULL;
1928 TaskHandle_t xInternalTaskHandle = NULL;
1930 if( xTaskToQuery == NULL )
1932 pcReturn = pcTaskGetName( xTaskToQuery );
1936 lIndex = ( int32_t ) xTaskToQuery;
1938 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1940 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1942 if( xInternalTaskHandle != NULL )
1944 pcReturn = pcTaskGetName( xInternalTaskHandle );
1951 /*-----------------------------------------------------------*/
1953 #if ( INCLUDE_uxTaskPriorityGet == 1 )
1955 UBaseType_t MPU_uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
1957 UBaseType_t uxReturn = configMAX_PRIORITIES;
1959 TaskHandle_t xInternalTaskHandle = NULL;
1963 uxReturn = uxTaskPriorityGetFromISR( xTask );
1967 lIndex = ( int32_t ) xTask;
1969 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1971 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1973 if( xInternalTaskHandle != NULL )
1975 uxReturn = uxTaskPriorityGetFromISR( xInternalTaskHandle );
1983 #endif /* #if ( INCLUDE_uxTaskPriorityGet == 1 ) */
1984 /*-----------------------------------------------------------*/
1986 #if ( ( INCLUDE_uxTaskPriorityGet == 1 ) && ( configUSE_MUTEXES == 1 ) )
1988 UBaseType_t MPU_uxTaskBasePriorityGet( const TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
1990 UBaseType_t uxReturn = configMAX_PRIORITIES;
1992 TaskHandle_t xInternalTaskHandle = NULL;
1996 uxReturn = uxTaskBasePriorityGet( xTask );
2000 lIndex = ( int32_t ) xTask;
2002 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2004 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2006 if( xInternalTaskHandle != NULL )
2008 uxReturn = uxTaskBasePriorityGet( xInternalTaskHandle );
2016 #endif /* #if ( ( INCLUDE_uxTaskPriorityGet == 1 ) && ( configUSE_MUTEXES == 1 ) ) */
2017 /*-----------------------------------------------------------*/
2019 #if ( ( INCLUDE_uxTaskPriorityGet == 1 ) && ( configUSE_MUTEXES == 1 ) )
2021 UBaseType_t MPU_uxTaskBasePriorityGetFromISR( const TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
2023 UBaseType_t uxReturn = configMAX_PRIORITIES;
2025 TaskHandle_t xInternalTaskHandle = NULL;
2029 uxReturn = uxTaskBasePriorityGetFromISR( xTask );
2033 lIndex = ( int32_t ) xTask;
2035 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2037 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2039 if( xInternalTaskHandle != NULL )
2041 uxReturn = uxTaskBasePriorityGetFromISR( xInternalTaskHandle );
2049 #endif /* #if ( ( INCLUDE_uxTaskPriorityGet == 1 ) && ( configUSE_MUTEXES == 1 ) ) */
2050 /*-----------------------------------------------------------*/
2052 #if ( ( INCLUDE_xTaskResumeFromISR == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) )
2054 BaseType_t MPU_xTaskResumeFromISR( TaskHandle_t xTaskToResume ) /* PRIVILEGED_FUNCTION */
2056 BaseType_t xReturn = pdFAIL;
2058 TaskHandle_t xInternalTaskHandle = NULL;
2060 lIndex = ( int32_t ) xTaskToResume;
2062 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2064 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2066 if( xInternalTaskHandle != NULL )
2068 xReturn = xTaskResumeFromISR( xInternalTaskHandle );
2075 #endif /* #if ( ( INCLUDE_xTaskResumeFromISR == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) )*/
2076 /*---------------------------------------------------------------------------------------*/
2078 #if ( configUSE_APPLICATION_TASK_TAG == 1 )
2080 TaskHookFunction_t MPU_xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
2082 TaskHookFunction_t xReturn = NULL;
2084 TaskHandle_t xInternalTaskHandle = NULL;
2088 xReturn = xTaskGetApplicationTaskTagFromISR( xTask );
2092 lIndex = ( int32_t ) xTask;
2094 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2096 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2098 if( xInternalTaskHandle != NULL )
2100 xReturn = xTaskGetApplicationTaskTagFromISR( xInternalTaskHandle );
2108 #endif /* #if ( configUSE_APPLICATION_TASK_TAG == 1 ) */
2109 /*---------------------------------------------------------------------------------------*/
2111 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
2113 BaseType_t MPU_xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify,
2114 UBaseType_t uxIndexToNotify,
2116 eNotifyAction eAction,
2117 uint32_t * pulPreviousNotificationValue,
2118 BaseType_t * pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
2120 BaseType_t xReturn = pdFAIL;
2122 TaskHandle_t xInternalTaskHandle = NULL;
2124 lIndex = ( int32_t ) xTaskToNotify;
2126 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2128 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2130 if( xInternalTaskHandle != NULL )
2132 xReturn = xTaskGenericNotifyFromISR( xInternalTaskHandle, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken );
2139 #endif /* #if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
2140 /*---------------------------------------------------------------------------------------*/
2142 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
2144 void MPU_vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify,
2145 UBaseType_t uxIndexToNotify,
2146 BaseType_t * pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
2149 TaskHandle_t xInternalTaskHandle = NULL;
2151 lIndex = ( int32_t ) xTaskToNotify;
2153 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2155 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2157 if( xInternalTaskHandle != NULL )
2159 vTaskGenericNotifyGiveFromISR( xInternalTaskHandle, uxIndexToNotify, pxHigherPriorityTaskWoken );
2163 #endif /*#if ( configUSE_TASK_NOTIFICATIONS == 1 )*/
2164 /*-----------------------------------------------------------*/
2166 /*-----------------------------------------------------------*/
2167 /* MPU wrappers for queue APIs. */
2168 /*-----------------------------------------------------------*/
2170 BaseType_t MPU_xQueueGenericSendImpl( QueueHandle_t xQueue,
2171 const void * const pvItemToQueue,
2172 TickType_t xTicksToWait,
2173 BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION;
2175 BaseType_t MPU_xQueueGenericSendImpl( QueueHandle_t xQueue,
2176 const void * const pvItemToQueue,
2177 TickType_t xTicksToWait,
2178 BaseType_t xCopyPosition ) /* PRIVILEGED_FUNCTION */
2181 QueueHandle_t xInternalQueueHandle = NULL;
2182 BaseType_t xReturn = pdFAIL;
2183 BaseType_t xIsItemToQueueReadable = pdFALSE;
2184 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2185 UBaseType_t uxQueueItemSize, uxQueueLength;
2187 lIndex = ( int32_t ) xQueue;
2189 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2191 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2193 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2195 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2197 if( xInternalQueueHandle != NULL )
2199 uxQueueItemSize = uxQueueGetQueueItemSize( xInternalQueueHandle );
2200 uxQueueLength = uxQueueGetQueueLength( xInternalQueueHandle );
2202 if( ( !( ( pvItemToQueue == NULL ) && ( uxQueueItemSize != ( UBaseType_t ) 0U ) ) ) &&
2203 ( !( ( xCopyPosition == queueOVERWRITE ) && ( uxQueueLength != ( UBaseType_t ) 1U ) ) )
2204 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
2205 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0U ) ) )
2209 if( pvItemToQueue != NULL )
2211 xIsItemToQueueReadable = xPortIsAuthorizedToAccessBuffer( pvItemToQueue,
2213 tskMPU_READ_PERMISSION );
2216 if( ( pvItemToQueue == NULL ) || ( xIsItemToQueueReadable == pdTRUE ) )
2218 xReturn = xQueueGenericSend( xInternalQueueHandle, pvItemToQueue, xTicksToWait, xCopyPosition );
2227 /*-----------------------------------------------------------*/
2229 UBaseType_t MPU_uxQueueMessagesWaitingImpl( const QueueHandle_t pxQueue ) PRIVILEGED_FUNCTION;
2231 UBaseType_t MPU_uxQueueMessagesWaitingImpl( const QueueHandle_t pxQueue ) /* PRIVILEGED_FUNCTION */
2234 QueueHandle_t xInternalQueueHandle = NULL;
2235 UBaseType_t uxReturn = 0;
2236 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2238 lIndex = ( int32_t ) pxQueue;
2240 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2242 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2244 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2246 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2248 if( xInternalQueueHandle != NULL )
2250 uxReturn = uxQueueMessagesWaiting( xInternalQueueHandle );
2257 /*-----------------------------------------------------------*/
2259 UBaseType_t MPU_uxQueueSpacesAvailableImpl( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
2261 UBaseType_t MPU_uxQueueSpacesAvailableImpl( const QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */
2264 QueueHandle_t xInternalQueueHandle = NULL;
2265 UBaseType_t uxReturn = 0;
2266 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2268 lIndex = ( int32_t ) xQueue;
2270 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2272 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2274 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2276 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2278 if( xInternalQueueHandle != NULL )
2280 uxReturn = uxQueueSpacesAvailable( xInternalQueueHandle );
2287 /*-----------------------------------------------------------*/
2289 BaseType_t MPU_xQueueReceiveImpl( QueueHandle_t pxQueue,
2290 void * const pvBuffer,
2291 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2293 BaseType_t MPU_xQueueReceiveImpl( QueueHandle_t pxQueue,
2294 void * const pvBuffer,
2295 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
2298 QueueHandle_t xInternalQueueHandle = NULL;
2299 BaseType_t xReturn = pdFAIL;
2300 BaseType_t xIsReceiveBufferWritable = pdFALSE;
2301 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2302 UBaseType_t uxQueueItemSize;
2304 lIndex = ( int32_t ) pxQueue;
2306 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2308 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2310 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2312 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2314 if( xInternalQueueHandle != NULL )
2316 uxQueueItemSize = uxQueueGetQueueItemSize( xInternalQueueHandle );
2318 if( ( !( ( ( pvBuffer ) == NULL ) && ( uxQueueItemSize != ( UBaseType_t ) 0U ) ) )
2319 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
2320 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0U ) ) )
2324 xIsReceiveBufferWritable = xPortIsAuthorizedToAccessBuffer( pvBuffer,
2326 tskMPU_WRITE_PERMISSION );
2328 if( xIsReceiveBufferWritable == pdTRUE )
2330 xReturn = xQueueReceive( xInternalQueueHandle, pvBuffer, xTicksToWait );
2339 /*-----------------------------------------------------------*/
2341 BaseType_t MPU_xQueuePeekImpl( QueueHandle_t xQueue,
2342 void * const pvBuffer,
2343 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2345 BaseType_t MPU_xQueuePeekImpl( QueueHandle_t xQueue,
2346 void * const pvBuffer,
2347 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
2350 QueueHandle_t xInternalQueueHandle = NULL;
2351 BaseType_t xReturn = pdFAIL;
2352 BaseType_t xIsReceiveBufferWritable = pdFALSE;
2353 UBaseType_t uxQueueItemSize;
2354 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2356 lIndex = ( int32_t ) xQueue;
2358 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2360 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2362 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2364 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2366 if( xInternalQueueHandle != NULL )
2368 uxQueueItemSize = uxQueueGetQueueItemSize( xInternalQueueHandle );
2370 if( ( !( ( ( pvBuffer ) == NULL ) && ( uxQueueItemSize != ( UBaseType_t ) 0U ) ) )
2371 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
2372 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0U ) ) )
2376 xIsReceiveBufferWritable = xPortIsAuthorizedToAccessBuffer( pvBuffer,
2378 tskMPU_WRITE_PERMISSION );
2380 if( xIsReceiveBufferWritable == pdTRUE )
2382 xReturn = xQueuePeek( xInternalQueueHandle, pvBuffer, xTicksToWait );
2391 /*-----------------------------------------------------------*/
2393 BaseType_t MPU_xQueueSemaphoreTakeImpl( QueueHandle_t xQueue,
2394 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2396 BaseType_t MPU_xQueueSemaphoreTakeImpl( QueueHandle_t xQueue,
2397 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
2400 QueueHandle_t xInternalQueueHandle = NULL;
2401 BaseType_t xReturn = pdFAIL;
2402 UBaseType_t uxQueueItemSize;
2403 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2405 lIndex = ( int32_t ) xQueue;
2407 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2409 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2411 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2413 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2415 if( xInternalQueueHandle != NULL )
2417 uxQueueItemSize = uxQueueGetQueueItemSize( xInternalQueueHandle );
2419 if( ( uxQueueItemSize == 0U )
2420 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
2421 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0U ) ) )
2425 xReturn = xQueueSemaphoreTake( xInternalQueueHandle, xTicksToWait );
2433 /*-----------------------------------------------------------*/
2435 #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )
2437 TaskHandle_t MPU_xQueueGetMutexHolderImpl( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION;
2439 TaskHandle_t MPU_xQueueGetMutexHolderImpl( QueueHandle_t xSemaphore ) /* PRIVILEGED_FUNCTION */
2441 TaskHandle_t xMutexHolderTaskInternalHandle = NULL;
2442 TaskHandle_t xMutexHolderTaskExternalHandle = NULL;
2443 int32_t lIndex, lMutexHolderTaskIndex;
2444 QueueHandle_t xInternalQueueHandle = NULL;
2445 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2448 lIndex = ( int32_t ) xSemaphore;
2450 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2452 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2454 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2456 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2458 if( xInternalQueueHandle != NULL )
2460 xMutexHolderTaskInternalHandle = xQueueGetMutexHolder( xInternalQueueHandle );
2462 if( xMutexHolderTaskInternalHandle != NULL )
2464 lMutexHolderTaskIndex = MPU_GetIndexForTaskHandle( xMutexHolderTaskInternalHandle );
2466 if( lMutexHolderTaskIndex != -1 )
2468 xMutexHolderTaskExternalHandle = ( TaskHandle_t ) ( CONVERT_TO_EXTERNAL_INDEX( lMutexHolderTaskIndex ) );
2475 return xMutexHolderTaskExternalHandle;
2478 #endif /* if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) */
2479 /*-----------------------------------------------------------*/
2481 #if ( configUSE_RECURSIVE_MUTEXES == 1 )
2483 BaseType_t MPU_xQueueTakeMutexRecursiveImpl( QueueHandle_t xMutex,
2484 TickType_t xBlockTime ) PRIVILEGED_FUNCTION;
2486 BaseType_t MPU_xQueueTakeMutexRecursiveImpl( QueueHandle_t xMutex,
2487 TickType_t xBlockTime ) /* PRIVILEGED_FUNCTION */
2489 BaseType_t xReturn = pdFAIL;
2490 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2492 QueueHandle_t xInternalQueueHandle = NULL;
2493 UBaseType_t uxQueueItemSize;
2495 lIndex = ( int32_t ) xMutex;
2497 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2499 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2501 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2503 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2505 if( xInternalQueueHandle != NULL )
2507 uxQueueItemSize = uxQueueGetQueueItemSize( xInternalQueueHandle );
2509 if( uxQueueItemSize == 0 )
2511 xReturn = xQueueTakeMutexRecursive( xInternalQueueHandle, xBlockTime );
2520 #endif /* if ( configUSE_RECURSIVE_MUTEXES == 1 ) */
2521 /*-----------------------------------------------------------*/
2523 #if ( configUSE_RECURSIVE_MUTEXES == 1 )
2525 BaseType_t MPU_xQueueGiveMutexRecursiveImpl( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION;
2527 BaseType_t MPU_xQueueGiveMutexRecursiveImpl( QueueHandle_t xMutex ) /* PRIVILEGED_FUNCTION */
2529 BaseType_t xReturn = pdFAIL;
2530 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2532 QueueHandle_t xInternalQueueHandle = NULL;
2534 lIndex = ( int32_t ) xMutex;
2536 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2538 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2540 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2542 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2544 if( xInternalQueueHandle != NULL )
2546 xReturn = xQueueGiveMutexRecursive( xInternalQueueHandle );
2554 #endif /* if ( configUSE_RECURSIVE_MUTEXES == 1 ) */
2555 /*-----------------------------------------------------------*/
2557 #if ( configUSE_QUEUE_SETS == 1 )
2559 QueueSetMemberHandle_t MPU_xQueueSelectFromSetImpl( QueueSetHandle_t xQueueSet,
2560 TickType_t xBlockTimeTicks ) PRIVILEGED_FUNCTION;
2562 QueueSetMemberHandle_t MPU_xQueueSelectFromSetImpl( QueueSetHandle_t xQueueSet,
2563 TickType_t xBlockTimeTicks ) /* PRIVILEGED_FUNCTION */
2565 QueueSetHandle_t xInternalQueueSetHandle = NULL;
2566 QueueSetMemberHandle_t xSelectedMemberInternal = NULL;
2567 QueueSetMemberHandle_t xSelectedMemberExternal = NULL;
2568 int32_t lIndexQueueSet, lIndexSelectedMember;
2569 BaseType_t xCallingTaskIsAuthorizedToAccessQueueSet = pdFALSE;
2571 lIndexQueueSet = ( int32_t ) xQueueSet;
2573 if( IS_EXTERNAL_INDEX_VALID( lIndexQueueSet ) != pdFALSE )
2575 xCallingTaskIsAuthorizedToAccessQueueSet = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) );
2577 if( xCallingTaskIsAuthorizedToAccessQueueSet == pdTRUE )
2579 xInternalQueueSetHandle = MPU_GetQueueSetHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) );
2581 if( xInternalQueueSetHandle != NULL )
2583 xSelectedMemberInternal = xQueueSelectFromSet( xInternalQueueSetHandle, xBlockTimeTicks );
2585 if( xSelectedMemberInternal != NULL )
2587 lIndexSelectedMember = MPU_GetIndexForQueueSetMemberHandle( xSelectedMemberInternal );
2589 if( lIndexSelectedMember != -1 )
2591 xSelectedMemberExternal = ( QueueSetMemberHandle_t ) ( CONVERT_TO_EXTERNAL_INDEX( lIndexSelectedMember ) );
2598 return xSelectedMemberExternal;
2601 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */
2602 /*-----------------------------------------------------------*/
2604 #if ( configUSE_QUEUE_SETS == 1 )
2606 BaseType_t MPU_xQueueAddToSetImpl( QueueSetMemberHandle_t xQueueOrSemaphore,
2607 QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
2609 BaseType_t MPU_xQueueAddToSetImpl( QueueSetMemberHandle_t xQueueOrSemaphore,
2610 QueueSetHandle_t xQueueSet ) /* PRIVILEGED_FUNCTION */
2612 BaseType_t xReturn = pdFAIL;
2613 QueueSetMemberHandle_t xInternalQueueSetMemberHandle = NULL;
2614 QueueSetHandle_t xInternalQueueSetHandle = NULL;
2615 int32_t lIndexQueueSet, lIndexQueueSetMember;
2616 BaseType_t xCallingTaskIsAuthorizedToAccessQueueSet = pdFALSE;
2617 BaseType_t xCallingTaskIsAuthorizedToAccessQueueSetMember = pdFALSE;
2619 lIndexQueueSet = ( int32_t ) xQueueSet;
2620 lIndexQueueSetMember = ( int32_t ) xQueueOrSemaphore;
2622 if( ( IS_EXTERNAL_INDEX_VALID( lIndexQueueSet ) != pdFALSE ) &&
2623 ( IS_EXTERNAL_INDEX_VALID( lIndexQueueSetMember ) != pdFALSE ) )
2625 xCallingTaskIsAuthorizedToAccessQueueSet = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) );
2626 xCallingTaskIsAuthorizedToAccessQueueSetMember = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSetMember ) );
2628 if( ( xCallingTaskIsAuthorizedToAccessQueueSet == pdTRUE ) && ( xCallingTaskIsAuthorizedToAccessQueueSetMember == pdTRUE ) )
2630 xInternalQueueSetHandle = MPU_GetQueueSetHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) );
2631 xInternalQueueSetMemberHandle = MPU_GetQueueSetMemberHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSetMember ) );
2633 if( ( xInternalQueueSetHandle != NULL ) && ( xInternalQueueSetMemberHandle != NULL ) )
2635 xReturn = xQueueAddToSet( xInternalQueueSetMemberHandle, xInternalQueueSetHandle );
2643 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */
2644 /*-----------------------------------------------------------*/
2646 #if configQUEUE_REGISTRY_SIZE > 0
2648 void MPU_vQueueAddToRegistryImpl( QueueHandle_t xQueue,
2649 const char * pcName ) PRIVILEGED_FUNCTION;
2651 void MPU_vQueueAddToRegistryImpl( QueueHandle_t xQueue,
2652 const char * pcName ) /* PRIVILEGED_FUNCTION */
2655 QueueHandle_t xInternalQueueHandle = NULL;
2656 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2658 lIndex = ( int32_t ) xQueue;
2660 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2662 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2664 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2666 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2668 if( xInternalQueueHandle != NULL )
2670 vQueueAddToRegistry( xInternalQueueHandle, pcName );
2676 #endif /* if configQUEUE_REGISTRY_SIZE > 0 */
2677 /*-----------------------------------------------------------*/
2679 #if configQUEUE_REGISTRY_SIZE > 0
2681 void MPU_vQueueUnregisterQueueImpl( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
2683 void MPU_vQueueUnregisterQueueImpl( QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */
2686 QueueHandle_t xInternalQueueHandle = NULL;
2687 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2689 lIndex = ( int32_t ) xQueue;
2691 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2693 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2695 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2697 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2699 if( xInternalQueueHandle != NULL )
2701 vQueueUnregisterQueue( xInternalQueueHandle );
2707 #endif /* if configQUEUE_REGISTRY_SIZE > 0 */
2708 /*-----------------------------------------------------------*/
2710 #if configQUEUE_REGISTRY_SIZE > 0
2712 const char * MPU_pcQueueGetNameImpl( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
2714 const char * MPU_pcQueueGetNameImpl( QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */
2716 const char * pcReturn = NULL;
2717 QueueHandle_t xInternalQueueHandle = NULL;
2719 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2721 lIndex = ( int32_t ) xQueue;
2723 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2725 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2727 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2729 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2731 if( xInternalQueueHandle != NULL )
2733 pcReturn = pcQueueGetName( xInternalQueueHandle );
2741 #endif /* if configQUEUE_REGISTRY_SIZE > 0 */
2742 /*-----------------------------------------------------------*/
2744 /* Privileged only wrappers for Queue APIs. These are needed so that
2745 * the application can use opaque handles maintained in mpu_wrappers.c
2746 * with all the APIs. */
2747 /*-----------------------------------------------------------*/
2749 void MPU_vQueueDelete( QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */
2751 QueueHandle_t xInternalQueueHandle = NULL;
2754 lIndex = ( int32_t ) xQueue;
2756 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2758 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2760 if( xInternalQueueHandle != NULL )
2762 vQueueDelete( xInternalQueueHandle );
2763 MPU_SetIndexFreeInKernelObjectPool( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2767 /*-----------------------------------------------------------*/
2769 #if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
2771 QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) /* PRIVILEGED_FUNCTION */
2773 QueueHandle_t xInternalQueueHandle = NULL;
2774 QueueHandle_t xExternalQueueHandle = NULL;
2777 lIndex = MPU_GetFreeIndexInKernelObjectPool();
2781 xInternalQueueHandle = xQueueCreateMutex( ucQueueType );
2783 if( xInternalQueueHandle != NULL )
2785 MPU_StoreQueueHandleAtIndex( lIndex, xInternalQueueHandle );
2786 xExternalQueueHandle = ( QueueHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
2790 MPU_SetIndexFreeInKernelObjectPool( lIndex );
2794 return xExternalQueueHandle;
2797 #endif /* if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */
2798 /*-----------------------------------------------------------*/
2800 #if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
2802 QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType,
2803 StaticQueue_t * pxStaticQueue ) /* PRIVILEGED_FUNCTION */
2805 QueueHandle_t xInternalQueueHandle = NULL;
2806 QueueHandle_t xExternalQueueHandle = NULL;
2809 lIndex = MPU_GetFreeIndexInKernelObjectPool();
2813 xInternalQueueHandle = xQueueCreateMutexStatic( ucQueueType, pxStaticQueue );
2815 if( xInternalQueueHandle != NULL )
2817 MPU_StoreQueueHandleAtIndex( lIndex, xInternalQueueHandle );
2818 xExternalQueueHandle = ( QueueHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
2822 MPU_SetIndexFreeInKernelObjectPool( lIndex );
2826 return xExternalQueueHandle;
2829 #endif /* if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) */
2830 /*-----------------------------------------------------------*/
2832 #if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
2834 QueueHandle_t MPU_xQueueCreateCountingSemaphore( UBaseType_t uxCountValue,
2835 UBaseType_t uxInitialCount ) /* PRIVILEGED_FUNCTION */
2837 QueueHandle_t xInternalQueueHandle = NULL;
2838 QueueHandle_t xExternalQueueHandle = NULL;
2841 lIndex = MPU_GetFreeIndexInKernelObjectPool();
2845 xInternalQueueHandle = xQueueCreateCountingSemaphore( uxCountValue, uxInitialCount );
2847 if( xInternalQueueHandle != NULL )
2849 MPU_StoreQueueHandleAtIndex( lIndex, xInternalQueueHandle );
2850 xExternalQueueHandle = ( QueueHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
2854 MPU_SetIndexFreeInKernelObjectPool( lIndex );
2858 return xExternalQueueHandle;
2861 #endif /* if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */
2862 /*-----------------------------------------------------------*/
2864 #if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
2866 QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
2867 const UBaseType_t uxInitialCount,
2868 StaticQueue_t * pxStaticQueue ) /* PRIVILEGED_FUNCTION */
2870 QueueHandle_t xInternalQueueHandle = NULL;
2871 QueueHandle_t xExternalQueueHandle = NULL;
2874 lIndex = MPU_GetFreeIndexInKernelObjectPool();
2878 xInternalQueueHandle = xQueueCreateCountingSemaphoreStatic( uxMaxCount, uxInitialCount, pxStaticQueue );
2880 if( xInternalQueueHandle != NULL )
2882 MPU_StoreQueueHandleAtIndex( lIndex, xInternalQueueHandle );
2883 xExternalQueueHandle = ( QueueHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
2887 MPU_SetIndexFreeInKernelObjectPool( lIndex );
2891 return xExternalQueueHandle;
2894 #endif /* if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) */
2895 /*-----------------------------------------------------------*/
2897 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
2899 QueueHandle_t MPU_xQueueGenericCreate( UBaseType_t uxQueueLength,
2900 UBaseType_t uxItemSize,
2901 uint8_t ucQueueType ) /* PRIVILEGED_FUNCTION */
2903 QueueHandle_t xInternalQueueHandle = NULL;
2904 QueueHandle_t xExternalQueueHandle = NULL;
2907 lIndex = MPU_GetFreeIndexInKernelObjectPool();
2911 xInternalQueueHandle = xQueueGenericCreate( uxQueueLength, uxItemSize, ucQueueType );
2913 if( xInternalQueueHandle != NULL )
2915 MPU_StoreQueueHandleAtIndex( lIndex, xInternalQueueHandle );
2916 xExternalQueueHandle = ( QueueHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
2920 MPU_SetIndexFreeInKernelObjectPool( lIndex );
2924 return xExternalQueueHandle;
2927 #endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) */
2928 /*-----------------------------------------------------------*/
2930 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
2932 QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength,
2933 const UBaseType_t uxItemSize,
2934 uint8_t * pucQueueStorage,
2935 StaticQueue_t * pxStaticQueue,
2936 const uint8_t ucQueueType ) /* PRIVILEGED_FUNCTION */
2938 QueueHandle_t xInternalQueueHandle = NULL;
2939 QueueHandle_t xExternalQueueHandle = NULL;
2942 lIndex = MPU_GetFreeIndexInKernelObjectPool();
2946 xInternalQueueHandle = xQueueGenericCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxStaticQueue, ucQueueType );
2948 if( xInternalQueueHandle != NULL )
2950 MPU_StoreQueueHandleAtIndex( lIndex, xInternalQueueHandle );
2951 xExternalQueueHandle = ( QueueHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
2955 MPU_SetIndexFreeInKernelObjectPool( lIndex );
2959 return xExternalQueueHandle;
2962 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
2963 /*-----------------------------------------------------------*/
2965 BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue,
2966 BaseType_t xNewQueue ) /* PRIVILEGED_FUNCTION */
2969 QueueHandle_t xInternalQueueHandle = NULL;
2970 BaseType_t xReturn = pdFAIL;
2972 lIndex = ( int32_t ) xQueue;
2974 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2976 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2978 if( xInternalQueueHandle != NULL )
2980 xReturn = xQueueGenericReset( xInternalQueueHandle, xNewQueue );
2986 /*-----------------------------------------------------------*/
2988 #if ( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
2990 QueueSetHandle_t MPU_xQueueCreateSet( UBaseType_t uxEventQueueLength ) /* PRIVILEGED_FUNCTION */
2992 QueueSetHandle_t xInternalQueueSetHandle = NULL;
2993 QueueSetHandle_t xExternalQueueSetHandle = NULL;
2996 lIndex = MPU_GetFreeIndexInKernelObjectPool();
3000 xInternalQueueSetHandle = xQueueCreateSet( uxEventQueueLength );
3002 if( xInternalQueueSetHandle != NULL )
3004 MPU_StoreQueueSetHandleAtIndex( lIndex, xInternalQueueSetHandle );
3005 xExternalQueueSetHandle = ( QueueSetHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
3009 MPU_SetIndexFreeInKernelObjectPool( lIndex );
3013 return xExternalQueueSetHandle;
3016 #endif /* if ( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */
3017 /*-----------------------------------------------------------*/
3019 #if ( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
3021 QueueSetHandle_t MPU_xQueueCreateSetStatic( const UBaseType_t uxEventQueueLength,
3022 uint8_t * pucQueueStorage,
3023 StaticQueue_t * pxStaticQueue ) /* PRIVILEGED_FUNCTION */
3025 QueueSetHandle_t xInternalQueueSetHandle = NULL;
3026 QueueSetHandle_t xExternalQueueSetHandle = NULL;
3029 lIndex = MPU_GetFreeIndexInKernelObjectPool();
3033 xInternalQueueSetHandle = xQueueCreateSetStatic( uxEventQueueLength, pucQueueStorage, pxStaticQueue );
3035 if( xInternalQueueSetHandle != NULL )
3037 MPU_StoreQueueSetHandleAtIndex( lIndex, xInternalQueueSetHandle );
3038 xExternalQueueSetHandle = ( QueueSetHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
3042 MPU_SetIndexFreeInKernelObjectPool( lIndex );
3046 return xExternalQueueSetHandle;
3049 #endif /* if ( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) */
3050 /*-----------------------------------------------------------*/
3052 #if ( configUSE_QUEUE_SETS == 1 )
3054 BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
3055 QueueSetHandle_t xQueueSet ) /* PRIVILEGED_FUNCTION */
3057 BaseType_t xReturn = pdFAIL;
3058 QueueSetMemberHandle_t xInternalQueueSetMemberHandle = NULL;
3059 QueueSetHandle_t xInternalQueueSetHandle = NULL;
3060 int32_t lIndexQueueSet, lIndexQueueSetMember;
3062 lIndexQueueSet = ( int32_t ) xQueueSet;
3063 lIndexQueueSetMember = ( int32_t ) xQueueOrSemaphore;
3065 if( ( IS_EXTERNAL_INDEX_VALID( lIndexQueueSet ) != pdFALSE ) &&
3066 ( IS_EXTERNAL_INDEX_VALID( lIndexQueueSetMember ) != pdFALSE ) )
3068 xInternalQueueSetHandle = MPU_GetQueueSetHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) );
3069 xInternalQueueSetMemberHandle = MPU_GetQueueSetMemberHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSetMember ) );
3071 if( ( xInternalQueueSetHandle != NULL ) && ( xInternalQueueSetMemberHandle != NULL ) )
3073 xReturn = xQueueRemoveFromSet( xInternalQueueSetMemberHandle, xInternalQueueSetHandle );
3080 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */
3081 /*-----------------------------------------------------------*/
3083 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
3085 BaseType_t MPU_xQueueGenericGetStaticBuffers( QueueHandle_t xQueue,
3086 uint8_t ** ppucQueueStorage,
3087 StaticQueue_t ** ppxStaticQueue ) /* PRIVILEGED_FUNCTION */
3090 QueueHandle_t xInternalQueueHandle = NULL;
3091 BaseType_t xReturn = pdFALSE;
3093 lIndex = ( int32_t ) xQueue;
3095 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3097 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3099 if( xInternalQueueHandle != NULL )
3101 xReturn = xQueueGenericGetStaticBuffers( xInternalQueueHandle, ppucQueueStorage, ppxStaticQueue );
3108 #endif /*if ( configSUPPORT_STATIC_ALLOCATION == 1 )*/
3109 /*-----------------------------------------------------------*/
3111 BaseType_t MPU_xQueueGenericSendFromISR( QueueHandle_t xQueue,
3112 const void * const pvItemToQueue,
3113 BaseType_t * const pxHigherPriorityTaskWoken,
3114 const BaseType_t xCopyPosition ) /* PRIVILEGED_FUNCTION */
3116 BaseType_t xReturn = pdFAIL;
3118 QueueHandle_t xInternalQueueHandle = NULL;
3120 lIndex = ( int32_t ) xQueue;
3122 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3124 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3126 if( xInternalQueueHandle != NULL )
3128 xReturn = xQueueGenericSendFromISR( xInternalQueueHandle, pvItemToQueue, pxHigherPriorityTaskWoken, xCopyPosition );
3135 /*-----------------------------------------------------------*/
3137 BaseType_t MPU_xQueueGiveFromISR( QueueHandle_t xQueue,
3138 BaseType_t * const pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
3140 BaseType_t xReturn = pdFAIL;
3142 QueueHandle_t xInternalQueueHandle = NULL;
3144 lIndex = ( int32_t ) xQueue;
3146 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3148 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3150 if( xInternalQueueHandle != NULL )
3152 xReturn = xQueueGiveFromISR( xInternalQueueHandle, pxHigherPriorityTaskWoken );
3159 /*-----------------------------------------------------------*/
3161 BaseType_t MPU_xQueuePeekFromISR( QueueHandle_t xQueue,
3162 void * const pvBuffer ) /* PRIVILEGED_FUNCTION */
3164 BaseType_t xReturn = pdFAIL;
3166 QueueHandle_t xInternalQueueHandle = NULL;
3168 lIndex = ( int32_t ) xQueue;
3170 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3172 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3174 if( xInternalQueueHandle != NULL )
3176 xReturn = xQueuePeekFromISR( xInternalQueueHandle, pvBuffer );
3183 /*-----------------------------------------------------------*/
3185 BaseType_t MPU_xQueueReceiveFromISR( QueueHandle_t xQueue,
3186 void * const pvBuffer,
3187 BaseType_t * const pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
3189 BaseType_t xReturn = pdFAIL;
3191 QueueHandle_t xInternalQueueHandle = NULL;
3193 lIndex = ( int32_t ) xQueue;
3195 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3197 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3199 if( xInternalQueueHandle != NULL )
3201 xReturn = xQueueReceiveFromISR( xInternalQueueHandle, pvBuffer, pxHigherPriorityTaskWoken );
3208 /*-----------------------------------------------------------*/
3210 BaseType_t MPU_xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */
3212 BaseType_t xReturn = pdFAIL;
3214 QueueHandle_t xInternalQueueHandle = NULL;
3216 lIndex = ( int32_t ) xQueue;
3218 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3220 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3222 if( xInternalQueueHandle != NULL )
3224 xReturn = xQueueIsQueueEmptyFromISR( xInternalQueueHandle );
3230 /*-----------------------------------------------------------*/
3232 BaseType_t MPU_xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */
3234 BaseType_t xReturn = pdFAIL;
3236 QueueHandle_t xInternalQueueHandle = NULL;
3238 lIndex = ( int32_t ) xQueue;
3240 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3242 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3244 if( xInternalQueueHandle != NULL )
3246 xReturn = xQueueIsQueueFullFromISR( xInternalQueueHandle );
3253 /*-----------------------------------------------------------*/
3255 UBaseType_t MPU_uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */
3257 UBaseType_t uxReturn = 0;
3259 QueueHandle_t xInternalQueueHandle = NULL;
3261 lIndex = ( int32_t ) xQueue;
3263 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3265 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3267 if( xInternalQueueHandle != NULL )
3269 uxReturn = uxQueueMessagesWaitingFromISR( xInternalQueueHandle );
3276 /*-----------------------------------------------------------*/
3278 #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )
3280 TaskHandle_t MPU_xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) /* PRIVILEGED_FUNCTION */
3282 TaskHandle_t xMutexHolderTaskInternalHandle = NULL;
3283 TaskHandle_t xMutexHolderTaskExternalHandle = NULL;
3284 int32_t lIndex, lMutexHolderTaskIndex;
3285 QueueHandle_t xInternalSemaphoreHandle = NULL;
3287 lIndex = ( int32_t ) xSemaphore;
3289 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3291 xInternalSemaphoreHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3293 if( xInternalSemaphoreHandle != NULL )
3295 xMutexHolderTaskInternalHandle = xQueueGetMutexHolder( xInternalSemaphoreHandle );
3297 if( xMutexHolderTaskInternalHandle != NULL )
3299 lMutexHolderTaskIndex = MPU_GetIndexForTaskHandle( xMutexHolderTaskInternalHandle );
3301 if( lMutexHolderTaskIndex != -1 )
3303 xMutexHolderTaskExternalHandle = ( TaskHandle_t ) ( CONVERT_TO_EXTERNAL_INDEX( lMutexHolderTaskIndex ) );
3309 return xMutexHolderTaskExternalHandle;
3312 #endif /* #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) */
3313 /*-----------------------------------------------------------*/
3315 #if ( configUSE_QUEUE_SETS == 1 )
3317 QueueSetMemberHandle_t MPU_xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) /* PRIVILEGED_FUNCTION */
3319 QueueSetHandle_t xInternalQueueSetHandle = NULL;
3320 QueueSetMemberHandle_t xSelectedMemberInternal = NULL;
3321 QueueSetMemberHandle_t xSelectedMemberExternal = NULL;
3322 int32_t lIndexQueueSet, lIndexSelectedMember;
3324 lIndexQueueSet = ( int32_t ) xQueueSet;
3326 if( IS_EXTERNAL_INDEX_VALID( lIndexQueueSet ) != pdFALSE )
3328 xInternalQueueSetHandle = MPU_GetQueueSetHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) );
3330 if( xInternalQueueSetHandle != NULL )
3332 xSelectedMemberInternal = xQueueSelectFromSetFromISR( xInternalQueueSetHandle );
3334 if( xSelectedMemberInternal != NULL )
3336 lIndexSelectedMember = MPU_GetIndexForQueueSetMemberHandle( xSelectedMemberInternal );
3338 if( lIndexSelectedMember != -1 )
3340 xSelectedMemberExternal = ( QueueSetMemberHandle_t ) ( CONVERT_TO_EXTERNAL_INDEX( lIndexSelectedMember ) );
3346 return xSelectedMemberExternal;
3349 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */
3350 /*-----------------------------------------------------------*/
3352 /*-----------------------------------------------------------*/
3353 /* MPU wrappers for timers APIs. */
3354 /*-----------------------------------------------------------*/
3356 #if ( configUSE_TIMERS == 1 )
3358 void * MPU_pvTimerGetTimerIDImpl( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3360 void * MPU_pvTimerGetTimerIDImpl( const TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3362 void * pvReturn = NULL;
3363 TimerHandle_t xInternalTimerHandle = NULL;
3365 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3367 lIndex = ( int32_t ) xTimer;
3369 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3371 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3373 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3375 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3377 if( xInternalTimerHandle != NULL )
3379 pvReturn = pvTimerGetTimerID( xInternalTimerHandle );
3387 #endif /* if ( configUSE_TIMERS == 1 ) */
3388 /*-----------------------------------------------------------*/
3390 #if ( configUSE_TIMERS == 1 )
3392 void MPU_vTimerSetTimerIDImpl( TimerHandle_t xTimer,
3393 void * pvNewID ) PRIVILEGED_FUNCTION;
3395 void MPU_vTimerSetTimerIDImpl( TimerHandle_t xTimer,
3396 void * pvNewID ) /* PRIVILEGED_FUNCTION */
3398 TimerHandle_t xInternalTimerHandle = NULL;
3400 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3402 lIndex = ( int32_t ) xTimer;
3404 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3406 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3408 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3410 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3412 if( xInternalTimerHandle != NULL )
3414 vTimerSetTimerID( xInternalTimerHandle, pvNewID );
3420 #endif /* if ( configUSE_TIMERS == 1 ) */
3421 /*-----------------------------------------------------------*/
3423 #if ( configUSE_TIMERS == 1 )
3425 BaseType_t MPU_xTimerIsTimerActiveImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3427 BaseType_t MPU_xTimerIsTimerActiveImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3429 BaseType_t xReturn = pdFALSE;
3430 TimerHandle_t xInternalTimerHandle = NULL;
3432 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3434 lIndex = ( int32_t ) xTimer;
3436 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3438 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3440 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3442 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3444 if( xInternalTimerHandle != NULL )
3446 xReturn = xTimerIsTimerActive( xInternalTimerHandle );
3454 #endif /* if ( configUSE_TIMERS == 1 ) */
3455 /*-----------------------------------------------------------*/
3457 #if ( configUSE_TIMERS == 1 )
3459 TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandleImpl( void ) PRIVILEGED_FUNCTION;
3461 TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandleImpl( void ) /* PRIVILEGED_FUNCTION */
3463 TaskHandle_t xReturn;
3465 xReturn = xTimerGetTimerDaemonTaskHandle();
3470 #endif /* if ( configUSE_TIMERS == 1 ) */
3471 /*-----------------------------------------------------------*/
3473 #if ( configUSE_TIMERS == 1 )
3475 BaseType_t MPU_xTimerGenericCommandFromTask( TimerHandle_t xTimer,
3476 const BaseType_t xCommandID,
3477 const TickType_t xOptionalValue,
3478 BaseType_t * const pxHigherPriorityTaskWoken,
3479 const TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
3481 BaseType_t xReturn = pdFALSE;
3482 xTimerGenericCommandFromTaskParams_t xParams;
3484 xParams.xTimer = xTimer;
3485 xParams.xCommandID = xCommandID;
3486 xParams.xOptionalValue = xOptionalValue;
3487 xParams.pxHigherPriorityTaskWoken = pxHigherPriorityTaskWoken;
3488 xParams.xTicksToWait = xTicksToWait;
3490 xReturn = MPU_xTimerGenericCommandFromTaskEntry( &( xParams ) );
3495 BaseType_t MPU_xTimerGenericCommandFromTaskImpl( const xTimerGenericCommandFromTaskParams_t * pxParams ) PRIVILEGED_FUNCTION;
3497 BaseType_t MPU_xTimerGenericCommandFromTaskImpl( const xTimerGenericCommandFromTaskParams_t * pxParams ) /* PRIVILEGED_FUNCTION */
3499 BaseType_t xReturn = pdFALSE;
3500 TimerHandle_t xInternalTimerHandle = NULL;
3502 BaseType_t xIsHigherPriorityTaskWokenWriteable = pdFALSE;
3503 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3504 BaseType_t xAreParamsReadable = pdFALSE;
3506 if( pxParams != NULL )
3508 xAreParamsReadable = xPortIsAuthorizedToAccessBuffer( pxParams,
3509 sizeof( xTimerGenericCommandFromTaskParams_t ),
3510 tskMPU_READ_PERMISSION );
3513 if( xAreParamsReadable == pdTRUE )
3515 if( pxParams->xCommandID < tmrFIRST_FROM_ISR_COMMAND )
3517 if( pxParams->pxHigherPriorityTaskWoken != NULL )
3519 xIsHigherPriorityTaskWokenWriteable = xPortIsAuthorizedToAccessBuffer( pxParams->pxHigherPriorityTaskWoken,
3520 sizeof( BaseType_t ),
3521 tskMPU_WRITE_PERMISSION );
3524 if( ( pxParams->pxHigherPriorityTaskWoken == NULL ) ||
3525 ( xIsHigherPriorityTaskWokenWriteable == pdTRUE ) )
3527 lIndex = ( int32_t ) ( pxParams->xTimer );
3529 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3531 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3533 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3535 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3537 if( xInternalTimerHandle != NULL )
3539 xReturn = xTimerGenericCommandFromTask( xInternalTimerHandle,
3540 pxParams->xCommandID,
3541 pxParams->xOptionalValue,
3542 pxParams->pxHigherPriorityTaskWoken,
3543 pxParams->xTicksToWait );
3554 #endif /* if ( configUSE_TIMERS == 1 ) */
3555 /*-----------------------------------------------------------*/
3557 #if ( configUSE_TIMERS == 1 )
3559 const char * MPU_pcTimerGetNameImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3561 const char * MPU_pcTimerGetNameImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3563 const char * pcReturn = NULL;
3564 TimerHandle_t xInternalTimerHandle = NULL;
3566 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3568 lIndex = ( int32_t ) xTimer;
3570 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3572 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3574 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3576 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3578 if( xInternalTimerHandle != NULL )
3580 pcReturn = pcTimerGetName( xInternalTimerHandle );
3588 #endif /* if ( configUSE_TIMERS == 1 ) */
3589 /*-----------------------------------------------------------*/
3591 #if ( configUSE_TIMERS == 1 )
3593 void MPU_vTimerSetReloadModeImpl( TimerHandle_t xTimer,
3594 const BaseType_t xAutoReload ) PRIVILEGED_FUNCTION;
3596 void MPU_vTimerSetReloadModeImpl( TimerHandle_t xTimer,
3597 const BaseType_t xAutoReload ) /* PRIVILEGED_FUNCTION */
3599 TimerHandle_t xInternalTimerHandle = NULL;
3601 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3603 lIndex = ( int32_t ) xTimer;
3605 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3607 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3609 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3611 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3613 if( xInternalTimerHandle != NULL )
3615 vTimerSetReloadMode( xInternalTimerHandle, xAutoReload );
3621 #endif /* if ( configUSE_TIMERS == 1 ) */
3622 /*-----------------------------------------------------------*/
3624 #if ( configUSE_TIMERS == 1 )
3626 BaseType_t MPU_xTimerGetReloadModeImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3628 BaseType_t MPU_xTimerGetReloadModeImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3630 BaseType_t xReturn = pdFALSE;
3631 TimerHandle_t xInternalTimerHandle = NULL;
3633 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3635 lIndex = ( int32_t ) xTimer;
3637 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3639 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3641 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3643 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3645 if( xInternalTimerHandle != NULL )
3647 xReturn = xTimerGetReloadMode( xInternalTimerHandle );
3655 #endif /* if ( configUSE_TIMERS == 1 ) */
3656 /*-----------------------------------------------------------*/
3658 #if ( configUSE_TIMERS == 1 )
3660 UBaseType_t MPU_uxTimerGetReloadModeImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3662 UBaseType_t MPU_uxTimerGetReloadModeImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3664 UBaseType_t uxReturn = 0;
3665 TimerHandle_t xInternalTimerHandle = NULL;
3667 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3669 lIndex = ( int32_t ) xTimer;
3671 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3673 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3675 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3677 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3679 if( xInternalTimerHandle != NULL )
3681 uxReturn = uxTimerGetReloadMode( xInternalTimerHandle );
3689 #endif /* if ( configUSE_TIMERS == 1 ) */
3690 /*-----------------------------------------------------------*/
3692 #if ( configUSE_TIMERS == 1 )
3694 TickType_t MPU_xTimerGetPeriodImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3696 TickType_t MPU_xTimerGetPeriodImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3698 TickType_t xReturn = 0;
3699 TimerHandle_t xInternalTimerHandle = NULL;
3701 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3703 lIndex = ( int32_t ) xTimer;
3705 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3707 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3709 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3711 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3713 if( xInternalTimerHandle != NULL )
3715 xReturn = xTimerGetPeriod( xInternalTimerHandle );
3723 #endif /* if ( configUSE_TIMERS == 1 ) */
3724 /*-----------------------------------------------------------*/
3726 #if ( configUSE_TIMERS == 1 )
3728 TickType_t MPU_xTimerGetExpiryTimeImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3730 TickType_t MPU_xTimerGetExpiryTimeImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3732 TickType_t xReturn = 0;
3733 TimerHandle_t xInternalTimerHandle = NULL;
3735 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3737 lIndex = ( int32_t ) xTimer;
3739 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3741 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3743 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3745 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3747 if( xInternalTimerHandle != NULL )
3749 xReturn = xTimerGetExpiryTime( xInternalTimerHandle );
3757 #endif /* if ( configUSE_TIMERS == 1 ) */
3758 /*-----------------------------------------------------------*/
3760 /* Privileged only wrappers for Timer APIs. These are needed so that
3761 * the application can use opaque handles maintained in mpu_wrappers.c
3762 * with all the APIs. */
3763 /*-----------------------------------------------------------*/
3765 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 )
3767 TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName,
3768 const TickType_t xTimerPeriodInTicks,
3769 const BaseType_t xAutoReload,
3770 void * const pvTimerID,
3771 TimerCallbackFunction_t pxCallbackFunction ) /* PRIVILEGED_FUNCTION */
3773 TimerHandle_t xInternalTimerHandle = NULL;
3774 TimerHandle_t xExternalTimerHandle = NULL;
3777 lIndex = MPU_GetFreeIndexInKernelObjectPool();
3781 xInternalTimerHandle = xTimerCreate( pcTimerName, xTimerPeriodInTicks, xAutoReload, pvTimerID, MPU_TimerCallback );
3783 if( xInternalTimerHandle != NULL )
3785 MPU_StoreTimerHandleAtIndex( lIndex, xInternalTimerHandle, pxCallbackFunction );
3786 xExternalTimerHandle = ( TimerHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
3790 MPU_SetIndexFreeInKernelObjectPool( lIndex );
3794 return xExternalTimerHandle;
3797 #endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) */
3798 /*-----------------------------------------------------------*/
3800 #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 )
3802 TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName,
3803 const TickType_t xTimerPeriodInTicks,
3804 const BaseType_t xAutoReload,
3805 void * const pvTimerID,
3806 TimerCallbackFunction_t pxCallbackFunction,
3807 StaticTimer_t * pxTimerBuffer ) /* PRIVILEGED_FUNCTION */
3809 TimerHandle_t xInternalTimerHandle = NULL;
3810 TimerHandle_t xExternalTimerHandle = NULL;
3813 lIndex = MPU_GetFreeIndexInKernelObjectPool();
3817 xInternalTimerHandle = xTimerCreateStatic( pcTimerName, xTimerPeriodInTicks, xAutoReload, pvTimerID, MPU_TimerCallback, pxTimerBuffer );
3819 if( xInternalTimerHandle != NULL )
3821 MPU_StoreTimerHandleAtIndex( lIndex, xInternalTimerHandle, pxCallbackFunction );
3822 xExternalTimerHandle = ( TimerHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
3826 MPU_SetIndexFreeInKernelObjectPool( lIndex );
3830 return xExternalTimerHandle;
3833 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) */
3834 /*-----------------------------------------------------------*/
3836 #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 )
3838 BaseType_t MPU_xTimerGetStaticBuffer( TimerHandle_t xTimer,
3839 StaticTimer_t ** ppxTimerBuffer ) /* PRIVILEGED_FUNCTION */
3841 TimerHandle_t xInternalTimerHandle = NULL;
3843 BaseType_t xReturn = pdFALSE;
3845 lIndex = ( int32_t ) xTimer;
3847 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3849 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3851 if( xInternalTimerHandle != NULL )
3853 xReturn = xTimerGetStaticBuffer( xInternalTimerHandle, ppxTimerBuffer );
3860 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) */
3861 /*-----------------------------------------------------------*/
3863 #if ( configUSE_TIMERS == 1 )
3865 BaseType_t MPU_xTimerGenericCommandFromISR( TimerHandle_t xTimer,
3866 const BaseType_t xCommandID,
3867 const TickType_t xOptionalValue,
3868 BaseType_t * const pxHigherPriorityTaskWoken,
3869 const TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
3871 BaseType_t xReturn = pdFALSE;
3872 TimerHandle_t xInternalTimerHandle = NULL;
3875 lIndex = ( int32_t ) xTimer;
3877 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3879 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3881 if( xInternalTimerHandle != NULL )
3883 xReturn = xTimerGenericCommandFromISR( xInternalTimerHandle, xCommandID, xOptionalValue, pxHigherPriorityTaskWoken, xTicksToWait );
3890 #endif /* if ( configUSE_TIMERS == 1 ) */
3891 /*-----------------------------------------------------------*/
3893 /*-----------------------------------------------------------*/
3894 /* MPU wrappers for event group APIs. */
3895 /*-----------------------------------------------------------*/
3897 #if ( configUSE_EVENT_GROUPS == 1 )
3899 EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
3900 const EventBits_t uxBitsToWaitFor,
3901 const BaseType_t xClearOnExit,
3902 const BaseType_t xWaitForAllBits,
3903 TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
3905 EventBits_t xReturn = 0;
3906 xEventGroupWaitBitsParams_t xParams;
3908 xParams.xEventGroup = xEventGroup;
3909 xParams.uxBitsToWaitFor = uxBitsToWaitFor;
3910 xParams.xClearOnExit = xClearOnExit;
3911 xParams.xWaitForAllBits = xWaitForAllBits;
3912 xParams.xTicksToWait = xTicksToWait;
3914 xReturn = MPU_xEventGroupWaitBitsEntry( &( xParams ) );
3919 EventBits_t MPU_xEventGroupWaitBitsImpl( const xEventGroupWaitBitsParams_t * pxParams ) PRIVILEGED_FUNCTION;
3921 EventBits_t MPU_xEventGroupWaitBitsImpl( const xEventGroupWaitBitsParams_t * pxParams ) /* PRIVILEGED_FUNCTION */
3923 EventBits_t xReturn = 0;
3924 EventGroupHandle_t xInternalEventGroupHandle = NULL;
3926 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE;
3927 BaseType_t xAreParamsReadable = pdFALSE;
3929 if( pxParams != NULL )
3931 xAreParamsReadable = xPortIsAuthorizedToAccessBuffer( pxParams,
3932 sizeof( xEventGroupWaitBitsParams_t ),
3933 tskMPU_READ_PERMISSION );
3936 if( xAreParamsReadable == pdTRUE )
3938 if( ( ( pxParams->uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0U ) &&
3939 ( pxParams->uxBitsToWaitFor != 0U )
3940 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
3941 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( pxParams->xTicksToWait != 0U ) ) )
3945 lIndex = ( int32_t ) ( pxParams->xEventGroup );
3947 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3949 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3951 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE )
3953 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3955 if( xInternalEventGroupHandle != NULL )
3957 xReturn = xEventGroupWaitBits( xInternalEventGroupHandle,
3958 pxParams->uxBitsToWaitFor,
3959 pxParams->xClearOnExit,
3960 pxParams->xWaitForAllBits,
3961 pxParams->xTicksToWait );
3971 #endif /* #if ( configUSE_EVENT_GROUPS == 1 ) */
3972 /*-----------------------------------------------------------*/
3974 #if ( configUSE_EVENT_GROUPS == 1 )
3976 EventBits_t MPU_xEventGroupClearBitsImpl( EventGroupHandle_t xEventGroup,
3977 const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION;
3979 EventBits_t MPU_xEventGroupClearBitsImpl( EventGroupHandle_t xEventGroup,
3980 const EventBits_t uxBitsToClear ) /* PRIVILEGED_FUNCTION */
3982 EventBits_t xReturn = 0;
3983 EventGroupHandle_t xInternalEventGroupHandle = NULL;
3985 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE;
3987 if( ( uxBitsToClear & eventEVENT_BITS_CONTROL_BYTES ) == 0U )
3989 lIndex = ( int32_t ) xEventGroup;
3991 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3993 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3995 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE )
3997 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3999 if( xInternalEventGroupHandle != NULL )
4001 xReturn = xEventGroupClearBits( xInternalEventGroupHandle, uxBitsToClear );
4010 #endif /* #if ( configUSE_EVENT_GROUPS == 1 ) */
4011 /*-----------------------------------------------------------*/
4013 #if ( configUSE_EVENT_GROUPS == 1 )
4015 EventBits_t MPU_xEventGroupSetBitsImpl( EventGroupHandle_t xEventGroup,
4016 const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION;
4018 EventBits_t MPU_xEventGroupSetBitsImpl( EventGroupHandle_t xEventGroup,
4019 const EventBits_t uxBitsToSet ) /* PRIVILEGED_FUNCTION */
4021 EventBits_t xReturn = 0;
4022 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4024 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE;
4026 if( ( uxBitsToSet & eventEVENT_BITS_CONTROL_BYTES ) == 0U )
4028 lIndex = ( int32_t ) xEventGroup;
4030 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4032 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4034 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE )
4036 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4038 if( xInternalEventGroupHandle != NULL )
4040 xReturn = xEventGroupSetBits( xInternalEventGroupHandle, uxBitsToSet );
4049 #endif /* #if ( configUSE_EVENT_GROUPS == 1 ) */
4050 /*-----------------------------------------------------------*/
4052 #if ( configUSE_EVENT_GROUPS == 1 )
4054 EventBits_t MPU_xEventGroupSyncImpl( EventGroupHandle_t xEventGroup,
4055 const EventBits_t uxBitsToSet,
4056 const EventBits_t uxBitsToWaitFor,
4057 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
4059 EventBits_t MPU_xEventGroupSyncImpl( EventGroupHandle_t xEventGroup,
4060 const EventBits_t uxBitsToSet,
4061 const EventBits_t uxBitsToWaitFor,
4062 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
4064 EventBits_t xReturn = 0;
4065 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4067 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE;
4069 if( ( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0U ) &&
4070 ( uxBitsToWaitFor != 0U )
4071 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
4072 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0U ) ) )
4076 lIndex = ( int32_t ) xEventGroup;
4078 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4080 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4082 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE )
4084 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4086 if( xInternalEventGroupHandle != NULL )
4088 xReturn = xEventGroupSync( xInternalEventGroupHandle, uxBitsToSet, uxBitsToWaitFor, xTicksToWait );
4097 #endif /* #if ( configUSE_EVENT_GROUPS == 1 ) */
4098 /*-----------------------------------------------------------*/
4100 #if ( ( configUSE_EVENT_GROUPS == 1 ) && ( configUSE_TRACE_FACILITY == 1 ) )
4102 UBaseType_t MPU_uxEventGroupGetNumberImpl( void * xEventGroup ) PRIVILEGED_FUNCTION;
4104 UBaseType_t MPU_uxEventGroupGetNumberImpl( void * xEventGroup ) /* PRIVILEGED_FUNCTION */
4106 UBaseType_t xReturn = 0;
4107 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4109 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE;
4111 lIndex = ( int32_t ) xEventGroup;
4113 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4115 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4117 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE )
4119 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4121 if( xInternalEventGroupHandle != NULL )
4123 xReturn = uxEventGroupGetNumber( xInternalEventGroupHandle );
4131 #endif /* #if ( ( configUSE_EVENT_GROUPS == 1 ) && ( configUSE_TRACE_FACILITY == 1 ) ) */
4132 /*-----------------------------------------------------------*/
4134 #if ( ( configUSE_EVENT_GROUPS == 1 ) && ( configUSE_TRACE_FACILITY == 1 ) )
4136 void MPU_vEventGroupSetNumberImpl( void * xEventGroup,
4137 UBaseType_t uxEventGroupNumber ) PRIVILEGED_FUNCTION;
4139 void MPU_vEventGroupSetNumberImpl( void * xEventGroup,
4140 UBaseType_t uxEventGroupNumber ) /* PRIVILEGED_FUNCTION */
4142 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4144 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE;
4146 lIndex = ( int32_t ) xEventGroup;
4148 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4150 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4152 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE )
4154 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4156 if( xInternalEventGroupHandle != NULL )
4158 vEventGroupSetNumber( xInternalEventGroupHandle, uxEventGroupNumber );
4164 #endif /* #if ( ( configUSE_EVENT_GROUPS == 1 ) && ( configUSE_TRACE_FACILITY == 1 ) ) */
4165 /*-----------------------------------------------------------*/
4167 /* Privileged only wrappers for Event Group APIs. These are needed so that
4168 * the application can use opaque handles maintained in mpu_wrappers.c
4169 * with all the APIs. */
4170 /*-----------------------------------------------------------*/
4172 #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_EVENT_GROUPS == 1 ) )
4174 EventGroupHandle_t MPU_xEventGroupCreate( void ) /* PRIVILEGED_FUNCTION */
4176 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4177 EventGroupHandle_t xExternalEventGroupHandle = NULL;
4180 lIndex = MPU_GetFreeIndexInKernelObjectPool();
4184 xInternalEventGroupHandle = xEventGroupCreate();
4186 if( xInternalEventGroupHandle != NULL )
4188 MPU_StoreEventGroupHandleAtIndex( lIndex, xInternalEventGroupHandle );
4189 xExternalEventGroupHandle = ( EventGroupHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
4193 MPU_SetIndexFreeInKernelObjectPool( lIndex );
4197 return xExternalEventGroupHandle;
4200 #endif /* #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_EVENT_GROUPS == 1 ) ) */
4201 /*-----------------------------------------------------------*/
4203 #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_EVENT_GROUPS == 1 ) )
4205 EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) /* PRIVILEGED_FUNCTION */
4207 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4208 EventGroupHandle_t xExternalEventGroupHandle = NULL;
4211 lIndex = MPU_GetFreeIndexInKernelObjectPool();
4215 xInternalEventGroupHandle = xEventGroupCreateStatic( pxEventGroupBuffer );
4217 if( xInternalEventGroupHandle != NULL )
4219 MPU_StoreEventGroupHandleAtIndex( lIndex, xInternalEventGroupHandle );
4220 xExternalEventGroupHandle = ( EventGroupHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
4224 MPU_SetIndexFreeInKernelObjectPool( lIndex );
4228 return xExternalEventGroupHandle;
4231 #endif /* #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_EVENT_GROUPS == 1 ) ) */
4232 /*-----------------------------------------------------------*/
4234 #if ( configUSE_EVENT_GROUPS == 1 )
4236 void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) /* PRIVILEGED_FUNCTION */
4238 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4241 lIndex = ( int32_t ) xEventGroup;
4243 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4245 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4247 if( xInternalEventGroupHandle != NULL )
4249 vEventGroupDelete( xInternalEventGroupHandle );
4250 MPU_SetIndexFreeInKernelObjectPool( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4255 #endif /* #if ( configUSE_EVENT_GROUPS == 1 ) */
4256 /*-----------------------------------------------------------*/
4258 #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_EVENT_GROUPS == 1 ) )
4260 BaseType_t MPU_xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup,
4261 StaticEventGroup_t ** ppxEventGroupBuffer ) /* PRIVILEGED_FUNCTION */
4263 BaseType_t xReturn = pdFALSE;
4264 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4267 lIndex = ( int32_t ) xEventGroup;
4269 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4271 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4273 if( xInternalEventGroupHandle != NULL )
4275 xReturn = xEventGroupGetStaticBuffer( xInternalEventGroupHandle, ppxEventGroupBuffer );
4282 #endif /* #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_EVENT_GROUPS == 1 ) ) */
4283 /*-----------------------------------------------------------*/
4285 #if ( ( configUSE_EVENT_GROUPS == 1 ) && ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )
4287 BaseType_t MPU_xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup,
4288 const EventBits_t uxBitsToClear ) /* PRIVILEGED_FUNCTION */
4290 BaseType_t xReturn = pdFALSE;
4291 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4294 lIndex = ( int32_t ) xEventGroup;
4296 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4298 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4300 if( xInternalEventGroupHandle != NULL )
4302 xReturn = xEventGroupClearBitsFromISR( xInternalEventGroupHandle, uxBitsToClear );
4309 #endif /* #if ( ( configUSE_EVENT_GROUPS == 1 ) && ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) ) */
4310 /*-----------------------------------------------------------*/
4312 #if ( ( configUSE_EVENT_GROUPS == 1 ) && ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )
4314 BaseType_t MPU_xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup,
4315 const EventBits_t uxBitsToSet,
4316 BaseType_t * pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
4318 BaseType_t xReturn = pdFALSE;
4319 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4322 lIndex = ( int32_t ) xEventGroup;
4324 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4326 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4328 if( xInternalEventGroupHandle != NULL )
4330 xReturn = xEventGroupSetBitsFromISR( xInternalEventGroupHandle, uxBitsToSet, pxHigherPriorityTaskWoken );
4337 #endif /* #if ( ( configUSE_EVENT_GROUPS == 1 ) && ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) ) */
4338 /*-----------------------------------------------------------*/
4340 #if ( configUSE_EVENT_GROUPS == 1 )
4342 EventBits_t MPU_xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ) /* PRIVILEGED_FUNCTION */
4344 EventBits_t xReturn = 0;
4345 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4348 lIndex = ( int32_t ) xEventGroup;
4350 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4352 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4354 if( xInternalEventGroupHandle != NULL )
4356 xReturn = xEventGroupGetBitsFromISR( xInternalEventGroupHandle );
4363 #endif /* #if ( configUSE_EVENT_GROUPS == 1 ) */
4364 /*-----------------------------------------------------------*/
4366 /*-----------------------------------------------------------*/
4367 /* MPU wrappers for stream buffer APIs. */
4368 /*-----------------------------------------------------------*/
4370 #if ( configUSE_STREAM_BUFFERS == 1 )
4372 size_t MPU_xStreamBufferSendImpl( StreamBufferHandle_t xStreamBuffer,
4373 const void * pvTxData,
4374 size_t xDataLengthBytes,
4375 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
4377 size_t MPU_xStreamBufferSendImpl( StreamBufferHandle_t xStreamBuffer,
4378 const void * pvTxData,
4379 size_t xDataLengthBytes,
4380 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
4383 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4385 BaseType_t xIsTxDataBufferReadable = pdFALSE;
4386 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4388 if( pvTxData != NULL )
4390 xIsTxDataBufferReadable = xPortIsAuthorizedToAccessBuffer( pvTxData,
4392 tskMPU_READ_PERMISSION );
4394 if( xIsTxDataBufferReadable == pdTRUE )
4396 lIndex = ( int32_t ) xStreamBuffer;
4398 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4400 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4402 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4404 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4406 if( xInternalStreamBufferHandle != NULL )
4408 xReturn = xStreamBufferSend( xInternalStreamBufferHandle, pvTxData, xDataLengthBytes, xTicksToWait );
4418 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4419 /*-----------------------------------------------------------*/
4421 #if ( configUSE_STREAM_BUFFERS == 1 )
4423 size_t MPU_xStreamBufferReceiveImpl( StreamBufferHandle_t xStreamBuffer,
4425 size_t xBufferLengthBytes,
4426 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
4428 size_t MPU_xStreamBufferReceiveImpl( StreamBufferHandle_t xStreamBuffer,
4430 size_t xBufferLengthBytes,
4431 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
4434 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4436 BaseType_t xIsRxDataBufferWriteable = pdFALSE;
4437 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4439 if( pvRxData != NULL )
4441 xIsRxDataBufferWriteable = xPortIsAuthorizedToAccessBuffer( pvRxData,
4443 tskMPU_WRITE_PERMISSION );
4445 if( xIsRxDataBufferWriteable == pdTRUE )
4447 lIndex = ( int32_t ) xStreamBuffer;
4449 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4451 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4453 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4455 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4457 if( xInternalStreamBufferHandle != NULL )
4459 xReturn = xStreamBufferReceive( xInternalStreamBufferHandle, pvRxData, xBufferLengthBytes, xTicksToWait );
4469 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4470 /*-----------------------------------------------------------*/
4472 #if ( configUSE_STREAM_BUFFERS == 1 )
4474 BaseType_t MPU_xStreamBufferIsFullImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
4476 BaseType_t MPU_xStreamBufferIsFullImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4478 BaseType_t xReturn = pdFALSE;
4479 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4481 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4483 lIndex = ( int32_t ) xStreamBuffer;
4485 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4487 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4489 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4491 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4493 if( xInternalStreamBufferHandle != NULL )
4495 xReturn = xStreamBufferIsFull( xInternalStreamBufferHandle );
4503 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4504 /*-----------------------------------------------------------*/
4506 #if ( configUSE_STREAM_BUFFERS == 1 )
4508 BaseType_t MPU_xStreamBufferIsEmptyImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
4510 BaseType_t MPU_xStreamBufferIsEmptyImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4512 BaseType_t xReturn = pdFALSE;
4513 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4515 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4517 lIndex = ( int32_t ) xStreamBuffer;
4519 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4521 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4523 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4525 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4527 if( xInternalStreamBufferHandle != NULL )
4529 xReturn = xStreamBufferIsEmpty( xInternalStreamBufferHandle );
4537 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4538 /*-----------------------------------------------------------*/
4540 #if ( configUSE_STREAM_BUFFERS == 1 )
4542 size_t MPU_xStreamBufferSpacesAvailableImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
4544 size_t MPU_xStreamBufferSpacesAvailableImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4547 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4549 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4551 lIndex = ( int32_t ) xStreamBuffer;
4553 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4555 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4557 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4559 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4561 if( xInternalStreamBufferHandle != NULL )
4563 xReturn = xStreamBufferSpacesAvailable( xInternalStreamBufferHandle );
4571 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4572 /*-----------------------------------------------------------*/
4574 #if ( configUSE_STREAM_BUFFERS == 1 )
4576 size_t MPU_xStreamBufferBytesAvailableImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
4578 size_t MPU_xStreamBufferBytesAvailableImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4581 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4583 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4585 lIndex = ( int32_t ) xStreamBuffer;
4587 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4589 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4591 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4593 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4595 if( xInternalStreamBufferHandle != NULL )
4597 xReturn = xStreamBufferBytesAvailable( xInternalStreamBufferHandle );
4605 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4606 /*-----------------------------------------------------------*/
4608 #if ( configUSE_STREAM_BUFFERS == 1 )
4610 BaseType_t MPU_xStreamBufferSetTriggerLevelImpl( StreamBufferHandle_t xStreamBuffer,
4611 size_t xTriggerLevel ) PRIVILEGED_FUNCTION;
4613 BaseType_t MPU_xStreamBufferSetTriggerLevelImpl( StreamBufferHandle_t xStreamBuffer,
4614 size_t xTriggerLevel ) /* PRIVILEGED_FUNCTION */
4616 BaseType_t xReturn = pdFALSE;
4617 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4619 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4621 lIndex = ( int32_t ) xStreamBuffer;
4623 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4625 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4627 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4629 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4631 if( xInternalStreamBufferHandle != NULL )
4633 xReturn = xStreamBufferSetTriggerLevel( xInternalStreamBufferHandle, xTriggerLevel );
4641 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4642 /*-----------------------------------------------------------*/
4644 #if ( configUSE_STREAM_BUFFERS == 1 )
4646 size_t MPU_xStreamBufferNextMessageLengthBytesImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
4648 size_t MPU_xStreamBufferNextMessageLengthBytesImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4651 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4653 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4655 lIndex = ( int32_t ) xStreamBuffer;
4657 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4659 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4661 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4663 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4665 if( xInternalStreamBufferHandle != NULL )
4667 xReturn = xStreamBufferNextMessageLengthBytes( xInternalStreamBufferHandle );
4675 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4676 /*-----------------------------------------------------------*/
4678 /* Privileged only wrappers for Stream Buffer APIs. These are needed so that
4679 * the application can use opaque handles maintained in mpu_wrappers.c
4680 * with all the APIs. */
4681 /*-----------------------------------------------------------*/
4683 #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_STREAM_BUFFERS == 1 ) )
4685 StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes,
4686 size_t xTriggerLevelBytes,
4687 BaseType_t xStreamBufferType,
4688 StreamBufferCallbackFunction_t pxSendCompletedCallback,
4689 StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) /* PRIVILEGED_FUNCTION */
4691 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4692 StreamBufferHandle_t xExternalStreamBufferHandle = NULL;
4696 * Stream buffer application level callback functionality is disabled for MPU
4699 configASSERT( ( pxSendCompletedCallback == NULL ) &&
4700 ( pxReceiveCompletedCallback == NULL ) );
4702 if( ( pxSendCompletedCallback == NULL ) &&
4703 ( pxReceiveCompletedCallback == NULL ) )
4705 lIndex = MPU_GetFreeIndexInKernelObjectPool();
4709 xInternalStreamBufferHandle = xStreamBufferGenericCreate( xBufferSizeBytes,
4715 if( xInternalStreamBufferHandle != NULL )
4717 MPU_StoreStreamBufferHandleAtIndex( lIndex, xInternalStreamBufferHandle );
4718 xExternalStreamBufferHandle = ( StreamBufferHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
4722 MPU_SetIndexFreeInKernelObjectPool( lIndex );
4728 traceSTREAM_BUFFER_CREATE_FAILED( xStreamBufferType );
4729 xExternalStreamBufferHandle = NULL;
4732 return xExternalStreamBufferHandle;
4735 #endif /* #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_STREAM_BUFFERS == 1 ) ) */
4736 /*-----------------------------------------------------------*/
4738 #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_STREAM_BUFFERS == 1 ) )
4740 StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
4741 size_t xTriggerLevelBytes,
4742 BaseType_t xStreamBufferType,
4743 uint8_t * const pucStreamBufferStorageArea,
4744 StaticStreamBuffer_t * const pxStaticStreamBuffer,
4745 StreamBufferCallbackFunction_t pxSendCompletedCallback,
4746 StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) /* PRIVILEGED_FUNCTION */
4748 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4749 StreamBufferHandle_t xExternalStreamBufferHandle = NULL;
4753 * Stream buffer application level callback functionality is disabled for MPU
4756 configASSERT( ( pxSendCompletedCallback == NULL ) &&
4757 ( pxReceiveCompletedCallback == NULL ) );
4759 if( ( pxSendCompletedCallback == NULL ) &&
4760 ( pxReceiveCompletedCallback == NULL ) )
4762 lIndex = MPU_GetFreeIndexInKernelObjectPool();
4766 xInternalStreamBufferHandle = xStreamBufferGenericCreateStatic( xBufferSizeBytes,
4769 pucStreamBufferStorageArea,
4770 pxStaticStreamBuffer,
4774 if( xInternalStreamBufferHandle != NULL )
4776 MPU_StoreStreamBufferHandleAtIndex( lIndex, xInternalStreamBufferHandle );
4777 xExternalStreamBufferHandle = ( StreamBufferHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
4781 MPU_SetIndexFreeInKernelObjectPool( lIndex );
4787 traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xStreamBufferType );
4788 xExternalStreamBufferHandle = NULL;
4791 return xExternalStreamBufferHandle;
4794 #endif /* #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_STREAM_BUFFERS == 1 ) ) */
4795 /*-----------------------------------------------------------*/
4797 #if ( configUSE_STREAM_BUFFERS == 1 )
4799 void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4801 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4804 lIndex = ( int32_t ) xStreamBuffer;
4806 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4808 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4810 if( xInternalStreamBufferHandle != NULL )
4812 vStreamBufferDelete( xInternalStreamBufferHandle );
4815 MPU_SetIndexFreeInKernelObjectPool( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4819 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4820 /*-----------------------------------------------------------*/
4822 #if ( configUSE_STREAM_BUFFERS == 1 )
4824 BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4826 BaseType_t xReturn = pdFALSE;
4827 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4830 lIndex = ( int32_t ) xStreamBuffer;
4832 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4834 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4836 if( xInternalStreamBufferHandle != NULL )
4838 xReturn = xStreamBufferReset( xInternalStreamBufferHandle );
4845 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4846 /*-----------------------------------------------------------*/
4848 #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_STREAM_BUFFERS == 1 ) )
4850 BaseType_t MPU_xStreamBufferGetStaticBuffers( StreamBufferHandle_t xStreamBuffers,
4851 uint8_t * ppucStreamBufferStorageArea,
4852 StaticStreamBuffer_t * ppxStaticStreamBuffer ) /* PRIVILEGED_FUNCTION */
4854 BaseType_t xReturn = pdFALSE;
4855 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4858 lIndex = ( int32_t ) xStreamBuffers;
4860 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4862 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4864 if( xInternalStreamBufferHandle != NULL )
4866 xReturn = MPU_xStreamBufferGetStaticBuffers( xInternalStreamBufferHandle, ppucStreamBufferStorageArea, ppxStaticStreamBuffer );
4873 #endif /* #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_STREAM_BUFFERS == 1 ) ) */
4874 /*-----------------------------------------------------------*/
4876 #if ( configUSE_STREAM_BUFFERS == 1 )
4878 size_t MPU_xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer,
4879 const void * pvTxData,
4880 size_t xDataLengthBytes,
4881 BaseType_t * const pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
4884 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4887 lIndex = ( int32_t ) xStreamBuffer;
4889 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4891 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4893 if( xInternalStreamBufferHandle != NULL )
4895 xReturn = xStreamBufferSendFromISR( xInternalStreamBufferHandle, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken );
4902 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4903 /*-----------------------------------------------------------*/
4905 #if ( configUSE_STREAM_BUFFERS == 1 )
4907 size_t MPU_xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer,
4909 size_t xBufferLengthBytes,
4910 BaseType_t * const pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
4913 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4916 lIndex = ( int32_t ) xStreamBuffer;
4918 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4920 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4922 if( xInternalStreamBufferHandle != NULL )
4924 xReturn = xStreamBufferReceiveFromISR( xInternalStreamBufferHandle, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken );
4931 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4932 /*-----------------------------------------------------------*/
4934 #if ( configUSE_STREAM_BUFFERS == 1 )
4936 BaseType_t MPU_xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer,
4937 BaseType_t * pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
4939 BaseType_t xReturn = pdFALSE;
4940 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4943 lIndex = ( int32_t ) xStreamBuffer;
4945 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4947 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4949 if( xInternalStreamBufferHandle != NULL )
4951 xReturn = xStreamBufferSendCompletedFromISR( xInternalStreamBufferHandle, pxHigherPriorityTaskWoken );
4958 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4959 /*-----------------------------------------------------------*/
4961 #if ( configUSE_STREAM_BUFFERS == 1 )
4963 BaseType_t MPU_xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer,
4964 BaseType_t * pxHigherPriorityTaskWoken ) /*PRIVILEGED_FUNCTION */
4966 BaseType_t xReturn = pdFALSE;
4967 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4970 lIndex = ( int32_t ) xStreamBuffer;
4972 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4974 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4976 if( xInternalStreamBufferHandle != NULL )
4978 xReturn = xStreamBufferReceiveCompletedFromISR( xInternalStreamBufferHandle, pxHigherPriorityTaskWoken );
4985 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4987 /*-----------------------------------------------------------*/
4989 #if ( configUSE_STREAM_BUFFERS == 1 )
4991 BaseType_t MPU_xStreamBufferResetFromISR( StreamBufferHandle_t xStreamBuffer ) /*PRIVILEGED_FUNCTION */
4993 BaseType_t xReturn = pdFAIL;
4994 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4997 lIndex = ( int32_t ) xStreamBuffer;
4999 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
5001 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
5003 if( xInternalStreamBufferHandle != NULL )
5005 xReturn = xStreamBufferResetFromISR( xInternalStreamBufferHandle );
5012 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
5014 /*-----------------------------------------------------------*/
5016 /* Functions that the application writer wants to execute in privileged mode
5017 * can be defined in application_defined_privileged_functions.h. */
5019 #if configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS == 1
5020 #include "application_defined_privileged_functions.h"
5022 /*-----------------------------------------------------------*/
5025 * @brief Array of system call implementation functions.
5027 * The index in the array MUST match the corresponding system call number
5028 * defined in mpu_wrappers.h.
5030 PRIVILEGED_DATA UBaseType_t uxSystemCallImplementations[ NUM_SYSTEM_CALLS ] =
5032 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
5033 ( UBaseType_t ) MPU_xTaskGenericNotifyImpl, /* SYSTEM_CALL_xTaskGenericNotify. */
5034 ( UBaseType_t ) MPU_xTaskGenericNotifyWaitImpl, /* SYSTEM_CALL_xTaskGenericNotifyWait. */
5036 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGenericNotify. */
5037 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGenericNotifyWait. */
5040 #if ( configUSE_TIMERS == 1 )
5041 ( UBaseType_t ) MPU_xTimerGenericCommandFromTaskImpl, /* SYSTEM_CALL_xTimerGenericCommandFromTask. */
5043 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGenericCommandFromTask. */
5046 #if ( configUSE_EVENT_GROUPS == 1 )
5047 ( UBaseType_t ) MPU_xEventGroupWaitBitsImpl, /* SYSTEM_CALL_xEventGroupWaitBits. */
5049 ( UBaseType_t ) 0, /* SYSTEM_CALL_xEventGroupWaitBits. */
5052 /* The system calls above this line take 5 parameters. */
5054 #if ( INCLUDE_xTaskDelayUntil == 1 )
5055 ( UBaseType_t ) MPU_xTaskDelayUntilImpl, /* SYSTEM_CALL_xTaskDelayUntil. */
5057 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskDelayUntil. */
5060 #if ( INCLUDE_xTaskAbortDelay == 1 )
5061 ( UBaseType_t ) MPU_xTaskAbortDelayImpl, /* SYSTEM_CALL_xTaskAbortDelay. */
5063 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskAbortDelay. */
5066 #if ( INCLUDE_vTaskDelay == 1 )
5067 ( UBaseType_t ) MPU_vTaskDelayImpl, /* SYSTEM_CALL_vTaskDelay. */
5069 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskDelay. */
5072 #if ( INCLUDE_uxTaskPriorityGet == 1 )
5073 ( UBaseType_t ) MPU_uxTaskPriorityGetImpl, /* SYSTEM_CALL_uxTaskPriorityGet. */
5075 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTaskPriorityGet. */
5078 #if ( INCLUDE_eTaskGetState == 1 )
5079 ( UBaseType_t ) MPU_eTaskGetStateImpl, /* SYSTEM_CALL_eTaskGetState. */
5081 ( UBaseType_t ) 0, /* SYSTEM_CALL_eTaskGetState. */
5084 #if ( configUSE_TRACE_FACILITY == 1 )
5085 ( UBaseType_t ) MPU_vTaskGetInfoImpl, /* SYSTEM_CALL_vTaskGetInfo. */
5087 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskGetInfo. */
5090 #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
5091 ( UBaseType_t ) MPU_xTaskGetIdleTaskHandleImpl, /* SYSTEM_CALL_xTaskGetIdleTaskHandle. */
5093 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGetIdleTaskHandle. */
5096 #if ( INCLUDE_vTaskSuspend == 1 )
5097 ( UBaseType_t ) MPU_vTaskSuspendImpl, /* SYSTEM_CALL_vTaskSuspend. */
5098 ( UBaseType_t ) MPU_vTaskResumeImpl, /* SYSTEM_CALL_vTaskResume. */
5100 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskSuspend. */
5101 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskResume. */
5104 ( UBaseType_t ) MPU_xTaskGetTickCountImpl, /* SYSTEM_CALL_xTaskGetTickCount. */
5105 ( UBaseType_t ) MPU_uxTaskGetNumberOfTasksImpl, /* SYSTEM_CALL_uxTaskGetNumberOfTasks. */
5107 #if ( configGENERATE_RUN_TIME_STATS == 1 )
5108 ( UBaseType_t ) MPU_ulTaskGetRunTimeCounterImpl, /* SYSTEM_CALL_ulTaskGetRunTimeCounter. */
5109 ( UBaseType_t ) MPU_ulTaskGetRunTimePercentImpl, /* SYSTEM_CALL_ulTaskGetRunTimePercent. */
5111 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGetRunTimeCounter. */
5112 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGetRunTimePercent. */
5115 #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) )
5116 ( UBaseType_t ) MPU_ulTaskGetIdleRunTimePercentImpl, /* SYSTEM_CALL_ulTaskGetIdleRunTimePercent. */
5117 ( UBaseType_t ) MPU_ulTaskGetIdleRunTimeCounterImpl, /* SYSTEM_CALL_ulTaskGetIdleRunTimeCounter. */
5119 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGetIdleRunTimePercent. */
5120 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGetIdleRunTimeCounter. */
5123 #if ( configUSE_APPLICATION_TASK_TAG == 1 )
5124 ( UBaseType_t ) MPU_vTaskSetApplicationTaskTagImpl, /* SYSTEM_CALL_vTaskSetApplicationTaskTag. */
5125 ( UBaseType_t ) MPU_xTaskGetApplicationTaskTagImpl, /* SYSTEM_CALL_xTaskGetApplicationTaskTag. */
5127 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskSetApplicationTaskTag. */
5128 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGetApplicationTaskTag. */
5131 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
5132 ( UBaseType_t ) MPU_vTaskSetThreadLocalStoragePointerImpl, /* SYSTEM_CALL_vTaskSetThreadLocalStoragePointer. */
5133 ( UBaseType_t ) MPU_pvTaskGetThreadLocalStoragePointerImpl, /* SYSTEM_CALL_pvTaskGetThreadLocalStoragePointer. */
5135 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskSetThreadLocalStoragePointer. */
5136 ( UBaseType_t ) 0, /* SYSTEM_CALL_pvTaskGetThreadLocalStoragePointer. */
5139 #if ( configUSE_TRACE_FACILITY == 1 )
5140 ( UBaseType_t ) MPU_uxTaskGetSystemStateImpl, /* SYSTEM_CALL_uxTaskGetSystemState. */
5142 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTaskGetSystemState. */
5145 #if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )
5146 ( UBaseType_t ) MPU_uxTaskGetStackHighWaterMarkImpl, /* SYSTEM_CALL_uxTaskGetStackHighWaterMark. */
5148 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTaskGetStackHighWaterMark. */
5151 #if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 )
5152 ( UBaseType_t ) MPU_uxTaskGetStackHighWaterMark2Impl, /* SYSTEM_CALL_uxTaskGetStackHighWaterMark2. */
5154 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTaskGetStackHighWaterMark2. */
5157 #if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) )
5158 ( UBaseType_t ) MPU_xTaskGetCurrentTaskHandleImpl, /* SYSTEM_CALL_xTaskGetCurrentTaskHandle. */
5160 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGetCurrentTaskHandle. */
5163 #if ( INCLUDE_xTaskGetSchedulerState == 1 )
5164 ( UBaseType_t ) MPU_xTaskGetSchedulerStateImpl, /* SYSTEM_CALL_xTaskGetSchedulerState. */
5166 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGetSchedulerState. */
5169 ( UBaseType_t ) MPU_vTaskSetTimeOutStateImpl, /* SYSTEM_CALL_vTaskSetTimeOutState. */
5170 ( UBaseType_t ) MPU_xTaskCheckForTimeOutImpl, /* SYSTEM_CALL_xTaskCheckForTimeOut. */
5172 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
5173 ( UBaseType_t ) MPU_ulTaskGenericNotifyTakeImpl, /* SYSTEM_CALL_ulTaskGenericNotifyTake. */
5174 ( UBaseType_t ) MPU_xTaskGenericNotifyStateClearImpl, /* SYSTEM_CALL_xTaskGenericNotifyStateClear. */
5175 ( UBaseType_t ) MPU_ulTaskGenericNotifyValueClearImpl, /* SYSTEM_CALL_ulTaskGenericNotifyValueClear. */
5177 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGenericNotifyTake. */
5178 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGenericNotifyStateClear. */
5179 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGenericNotifyValueClear. */
5182 ( UBaseType_t ) MPU_xQueueGenericSendImpl, /* SYSTEM_CALL_xQueueGenericSend. */
5183 ( UBaseType_t ) MPU_uxQueueMessagesWaitingImpl, /* SYSTEM_CALL_uxQueueMessagesWaiting. */
5184 ( UBaseType_t ) MPU_uxQueueSpacesAvailableImpl, /* SYSTEM_CALL_uxQueueSpacesAvailable. */
5185 ( UBaseType_t ) MPU_xQueueReceiveImpl, /* SYSTEM_CALL_xQueueReceive. */
5186 ( UBaseType_t ) MPU_xQueuePeekImpl, /* SYSTEM_CALL_xQueuePeek. */
5187 ( UBaseType_t ) MPU_xQueueSemaphoreTakeImpl, /* SYSTEM_CALL_xQueueSemaphoreTake. */
5189 #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )
5190 ( UBaseType_t ) MPU_xQueueGetMutexHolderImpl, /* SYSTEM_CALL_xQueueGetMutexHolder. */
5192 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueGetMutexHolder. */
5195 #if ( configUSE_RECURSIVE_MUTEXES == 1 )
5196 ( UBaseType_t ) MPU_xQueueTakeMutexRecursiveImpl, /* SYSTEM_CALL_xQueueTakeMutexRecursive. */
5197 ( UBaseType_t ) MPU_xQueueGiveMutexRecursiveImpl, /* SYSTEM_CALL_xQueueGiveMutexRecursive. */
5199 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueTakeMutexRecursive. */
5200 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueGiveMutexRecursive. */
5203 #if ( configUSE_QUEUE_SETS == 1 )
5204 ( UBaseType_t ) MPU_xQueueSelectFromSetImpl, /* SYSTEM_CALL_xQueueSelectFromSet. */
5205 ( UBaseType_t ) MPU_xQueueAddToSetImpl, /* SYSTEM_CALL_xQueueAddToSet. */
5207 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueSelectFromSet. */
5208 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueAddToSet. */
5211 #if configQUEUE_REGISTRY_SIZE > 0
5212 ( UBaseType_t ) MPU_vQueueAddToRegistryImpl, /* SYSTEM_CALL_vQueueAddToRegistry. */
5213 ( UBaseType_t ) MPU_vQueueUnregisterQueueImpl, /* SYSTEM_CALL_vQueueUnregisterQueue. */
5214 ( UBaseType_t ) MPU_pcQueueGetNameImpl, /* SYSTEM_CALL_pcQueueGetName. */
5216 ( UBaseType_t ) 0, /* SYSTEM_CALL_vQueueAddToRegistry. */
5217 ( UBaseType_t ) 0, /* SYSTEM_CALL_vQueueUnregisterQueue. */
5218 ( UBaseType_t ) 0, /* SYSTEM_CALL_pcQueueGetName. */
5221 #if ( configUSE_TIMERS == 1 )
5222 ( UBaseType_t ) MPU_pvTimerGetTimerIDImpl, /* SYSTEM_CALL_pvTimerGetTimerID. */
5223 ( UBaseType_t ) MPU_vTimerSetTimerIDImpl, /* SYSTEM_CALL_vTimerSetTimerID. */
5224 ( UBaseType_t ) MPU_xTimerIsTimerActiveImpl, /* SYSTEM_CALL_xTimerIsTimerActive. */
5225 ( UBaseType_t ) MPU_xTimerGetTimerDaemonTaskHandleImpl, /* SYSTEM_CALL_xTimerGetTimerDaemonTaskHandle. */
5226 ( UBaseType_t ) MPU_pcTimerGetNameImpl, /* SYSTEM_CALL_pcTimerGetName. */
5227 ( UBaseType_t ) MPU_vTimerSetReloadModeImpl, /* SYSTEM_CALL_vTimerSetReloadMode. */
5228 ( UBaseType_t ) MPU_xTimerGetReloadModeImpl, /* SYSTEM_CALL_xTimerGetReloadMode. */
5229 ( UBaseType_t ) MPU_uxTimerGetReloadModeImpl, /* SYSTEM_CALL_uxTimerGetReloadMode. */
5230 ( UBaseType_t ) MPU_xTimerGetPeriodImpl, /* SYSTEM_CALL_xTimerGetPeriod. */
5231 ( UBaseType_t ) MPU_xTimerGetExpiryTimeImpl, /* SYSTEM_CALL_xTimerGetExpiryTime. */
5233 ( UBaseType_t ) 0, /* SYSTEM_CALL_pvTimerGetTimerID. */
5234 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTimerSetTimerID. */
5235 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerIsTimerActive. */
5236 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGetTimerDaemonTaskHandle. */
5237 ( UBaseType_t ) 0, /* SYSTEM_CALL_pcTimerGetName. */
5238 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTimerSetReloadMode. */
5239 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGetReloadMode. */
5240 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTimerGetReloadMode. */
5241 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGetPeriod. */
5242 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGetExpiryTime. */
5245 #if ( configUSE_EVENT_GROUPS == 1 )
5246 ( UBaseType_t ) MPU_xEventGroupClearBitsImpl, /* SYSTEM_CALL_xEventGroupClearBits. */
5247 ( UBaseType_t ) MPU_xEventGroupSetBitsImpl, /* SYSTEM_CALL_xEventGroupSetBits. */
5248 ( UBaseType_t ) MPU_xEventGroupSyncImpl, /* SYSTEM_CALL_xEventGroupSync. */
5250 #if ( configUSE_TRACE_FACILITY == 1 )
5251 ( UBaseType_t ) MPU_uxEventGroupGetNumberImpl, /* SYSTEM_CALL_uxEventGroupGetNumber. */
5252 ( UBaseType_t ) MPU_vEventGroupSetNumberImpl, /* SYSTEM_CALL_vEventGroupSetNumber. */
5254 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxEventGroupGetNumber. */
5255 ( UBaseType_t ) 0, /* SYSTEM_CALL_vEventGroupSetNumber. */
5258 ( UBaseType_t ) 0, /* SYSTEM_CALL_xEventGroupClearBits. */
5259 ( UBaseType_t ) 0, /* SYSTEM_CALL_xEventGroupSetBits. */
5260 ( UBaseType_t ) 0, /* SYSTEM_CALL_xEventGroupSync. */
5261 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxEventGroupGetNumber. */
5262 ( UBaseType_t ) 0, /* SYSTEM_CALL_vEventGroupSetNumber. */
5265 #if ( configUSE_STREAM_BUFFERS == 1 )
5266 ( UBaseType_t ) MPU_xStreamBufferSendImpl, /* SYSTEM_CALL_xStreamBufferSend. */
5267 ( UBaseType_t ) MPU_xStreamBufferReceiveImpl, /* SYSTEM_CALL_xStreamBufferReceive. */
5268 ( UBaseType_t ) MPU_xStreamBufferIsFullImpl, /* SYSTEM_CALL_xStreamBufferIsFull. */
5269 ( UBaseType_t ) MPU_xStreamBufferIsEmptyImpl, /* SYSTEM_CALL_xStreamBufferIsEmpty. */
5270 ( UBaseType_t ) MPU_xStreamBufferSpacesAvailableImpl, /* SYSTEM_CALL_xStreamBufferSpacesAvailable. */
5271 ( UBaseType_t ) MPU_xStreamBufferBytesAvailableImpl, /* SYSTEM_CALL_xStreamBufferBytesAvailable. */
5272 ( UBaseType_t ) MPU_xStreamBufferSetTriggerLevelImpl, /* SYSTEM_CALL_xStreamBufferSetTriggerLevel. */
5273 ( UBaseType_t ) MPU_xStreamBufferNextMessageLengthBytesImpl /* SYSTEM_CALL_xStreamBufferNextMessageLengthBytes. */
5275 ( UBaseType_t ) 0, /* SYSTEM_CALL_xStreamBufferSend. */
5276 ( UBaseType_t ) 0, /* SYSTEM_CALL_xStreamBufferReceive. */
5277 ( UBaseType_t ) 0, /* SYSTEM_CALL_xStreamBufferIsFull. */
5278 ( UBaseType_t ) 0, /* SYSTEM_CALL_xStreamBufferIsEmpty. */
5279 ( UBaseType_t ) 0, /* SYSTEM_CALL_xStreamBufferSpacesAvailable. */
5280 ( UBaseType_t ) 0, /* SYSTEM_CALL_xStreamBufferBytesAvailable. */
5281 ( UBaseType_t ) 0, /* SYSTEM_CALL_xStreamBufferSetTriggerLevel. */
5282 ( UBaseType_t ) 0, /* SYSTEM_CALL_xStreamBufferNextMessageLengthBytes. */
5286 /*-----------------------------------------------------------*/
5288 #endif /* #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) ) */
5289 /*-----------------------------------------------------------*/