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_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_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 )
3021 BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
3022 QueueSetHandle_t xQueueSet ) /* PRIVILEGED_FUNCTION */
3024 BaseType_t xReturn = pdFAIL;
3025 QueueSetMemberHandle_t xInternalQueueSetMemberHandle = NULL;
3026 QueueSetHandle_t xInternalQueueSetHandle = NULL;
3027 int32_t lIndexQueueSet, lIndexQueueSetMember;
3029 lIndexQueueSet = ( int32_t ) xQueueSet;
3030 lIndexQueueSetMember = ( int32_t ) xQueueOrSemaphore;
3032 if( ( IS_EXTERNAL_INDEX_VALID( lIndexQueueSet ) != pdFALSE ) &&
3033 ( IS_EXTERNAL_INDEX_VALID( lIndexQueueSetMember ) != pdFALSE ) )
3035 xInternalQueueSetHandle = MPU_GetQueueSetHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) );
3036 xInternalQueueSetMemberHandle = MPU_GetQueueSetMemberHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSetMember ) );
3038 if( ( xInternalQueueSetHandle != NULL ) && ( xInternalQueueSetMemberHandle != NULL ) )
3040 xReturn = xQueueRemoveFromSet( xInternalQueueSetMemberHandle, xInternalQueueSetHandle );
3047 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */
3048 /*-----------------------------------------------------------*/
3050 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
3052 BaseType_t MPU_xQueueGenericGetStaticBuffers( QueueHandle_t xQueue,
3053 uint8_t ** ppucQueueStorage,
3054 StaticQueue_t ** ppxStaticQueue ) /* PRIVILEGED_FUNCTION */
3057 QueueHandle_t xInternalQueueHandle = NULL;
3058 BaseType_t xReturn = pdFALSE;
3060 lIndex = ( int32_t ) xQueue;
3062 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3064 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3066 if( xInternalQueueHandle != NULL )
3068 xReturn = xQueueGenericGetStaticBuffers( xInternalQueueHandle, ppucQueueStorage, ppxStaticQueue );
3075 #endif /*if ( configSUPPORT_STATIC_ALLOCATION == 1 )*/
3076 /*-----------------------------------------------------------*/
3078 BaseType_t MPU_xQueueGenericSendFromISR( QueueHandle_t xQueue,
3079 const void * const pvItemToQueue,
3080 BaseType_t * const pxHigherPriorityTaskWoken,
3081 const BaseType_t xCopyPosition ) /* PRIVILEGED_FUNCTION */
3083 BaseType_t xReturn = pdFAIL;
3085 QueueHandle_t xInternalQueueHandle = NULL;
3087 lIndex = ( int32_t ) xQueue;
3089 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3091 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3093 if( xInternalQueueHandle != NULL )
3095 xReturn = xQueueGenericSendFromISR( xInternalQueueHandle, pvItemToQueue, pxHigherPriorityTaskWoken, xCopyPosition );
3102 /*-----------------------------------------------------------*/
3104 BaseType_t MPU_xQueueGiveFromISR( QueueHandle_t xQueue,
3105 BaseType_t * const pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
3107 BaseType_t xReturn = pdFAIL;
3109 QueueHandle_t xInternalQueueHandle = NULL;
3111 lIndex = ( int32_t ) xQueue;
3113 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3115 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3117 if( xInternalQueueHandle != NULL )
3119 xReturn = xQueueGiveFromISR( xInternalQueueHandle, pxHigherPriorityTaskWoken );
3126 /*-----------------------------------------------------------*/
3128 BaseType_t MPU_xQueuePeekFromISR( QueueHandle_t xQueue,
3129 void * const pvBuffer ) /* PRIVILEGED_FUNCTION */
3131 BaseType_t xReturn = pdFAIL;
3133 QueueHandle_t xInternalQueueHandle = NULL;
3135 lIndex = ( int32_t ) xQueue;
3137 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3139 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3141 if( xInternalQueueHandle != NULL )
3143 xReturn = xQueuePeekFromISR( xInternalQueueHandle, pvBuffer );
3150 /*-----------------------------------------------------------*/
3152 BaseType_t MPU_xQueueReceiveFromISR( QueueHandle_t xQueue,
3153 void * const pvBuffer,
3154 BaseType_t * const pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
3156 BaseType_t xReturn = pdFAIL;
3158 QueueHandle_t xInternalQueueHandle = NULL;
3160 lIndex = ( int32_t ) xQueue;
3162 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3164 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3166 if( xInternalQueueHandle != NULL )
3168 xReturn = xQueueReceiveFromISR( xInternalQueueHandle, pvBuffer, pxHigherPriorityTaskWoken );
3175 /*-----------------------------------------------------------*/
3177 BaseType_t MPU_xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */
3179 BaseType_t xReturn = pdFAIL;
3181 QueueHandle_t xInternalQueueHandle = NULL;
3183 lIndex = ( int32_t ) xQueue;
3185 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3187 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3189 if( xInternalQueueHandle != NULL )
3191 xReturn = xQueueIsQueueEmptyFromISR( xInternalQueueHandle );
3197 /*-----------------------------------------------------------*/
3199 BaseType_t MPU_xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */
3201 BaseType_t xReturn = pdFAIL;
3203 QueueHandle_t xInternalQueueHandle = NULL;
3205 lIndex = ( int32_t ) xQueue;
3207 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3209 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3211 if( xInternalQueueHandle != NULL )
3213 xReturn = xQueueIsQueueFullFromISR( xInternalQueueHandle );
3220 /*-----------------------------------------------------------*/
3222 UBaseType_t MPU_uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */
3224 UBaseType_t uxReturn = 0;
3226 QueueHandle_t xInternalQueueHandle = NULL;
3228 lIndex = ( int32_t ) xQueue;
3230 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3232 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3234 if( xInternalQueueHandle != NULL )
3236 uxReturn = uxQueueMessagesWaitingFromISR( xInternalQueueHandle );
3243 /*-----------------------------------------------------------*/
3245 #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )
3247 TaskHandle_t MPU_xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) /* PRIVILEGED_FUNCTION */
3249 TaskHandle_t xMutexHolderTaskInternalHandle = NULL;
3250 TaskHandle_t xMutexHolderTaskExternalHandle = NULL;
3251 int32_t lIndex, lMutexHolderTaskIndex;
3252 QueueHandle_t xInternalSemaphoreHandle = NULL;
3254 lIndex = ( int32_t ) xSemaphore;
3256 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3258 xInternalSemaphoreHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3260 if( xInternalSemaphoreHandle != NULL )
3262 xMutexHolderTaskInternalHandle = xQueueGetMutexHolder( xInternalSemaphoreHandle );
3264 if( xMutexHolderTaskInternalHandle != NULL )
3266 lMutexHolderTaskIndex = MPU_GetIndexForTaskHandle( xMutexHolderTaskInternalHandle );
3268 if( lMutexHolderTaskIndex != -1 )
3270 xMutexHolderTaskExternalHandle = ( TaskHandle_t ) ( CONVERT_TO_EXTERNAL_INDEX( lMutexHolderTaskIndex ) );
3276 return xMutexHolderTaskExternalHandle;
3279 #endif /* #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) */
3280 /*-----------------------------------------------------------*/
3282 #if ( configUSE_QUEUE_SETS == 1 )
3284 QueueSetMemberHandle_t MPU_xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) /* PRIVILEGED_FUNCTION */
3286 QueueSetHandle_t xInternalQueueSetHandle = NULL;
3287 QueueSetMemberHandle_t xSelectedMemberInternal = NULL;
3288 QueueSetMemberHandle_t xSelectedMemberExternal = NULL;
3289 int32_t lIndexQueueSet, lIndexSelectedMember;
3291 lIndexQueueSet = ( int32_t ) xQueueSet;
3293 if( IS_EXTERNAL_INDEX_VALID( lIndexQueueSet ) != pdFALSE )
3295 xInternalQueueSetHandle = MPU_GetQueueSetHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) );
3297 if( xInternalQueueSetHandle != NULL )
3299 xSelectedMemberInternal = xQueueSelectFromSetFromISR( xInternalQueueSetHandle );
3301 if( xSelectedMemberInternal != NULL )
3303 lIndexSelectedMember = MPU_GetIndexForQueueSetMemberHandle( xSelectedMemberInternal );
3305 if( lIndexSelectedMember != -1 )
3307 xSelectedMemberExternal = ( QueueSetMemberHandle_t ) ( CONVERT_TO_EXTERNAL_INDEX( lIndexSelectedMember ) );
3313 return xSelectedMemberExternal;
3316 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */
3317 /*-----------------------------------------------------------*/
3319 /*-----------------------------------------------------------*/
3320 /* MPU wrappers for timers APIs. */
3321 /*-----------------------------------------------------------*/
3323 #if ( configUSE_TIMERS == 1 )
3325 void * MPU_pvTimerGetTimerIDImpl( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3327 void * MPU_pvTimerGetTimerIDImpl( const TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3329 void * pvReturn = NULL;
3330 TimerHandle_t xInternalTimerHandle = NULL;
3332 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3334 lIndex = ( int32_t ) xTimer;
3336 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3338 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3340 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3342 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3344 if( xInternalTimerHandle != NULL )
3346 pvReturn = pvTimerGetTimerID( xInternalTimerHandle );
3354 #endif /* if ( configUSE_TIMERS == 1 ) */
3355 /*-----------------------------------------------------------*/
3357 #if ( configUSE_TIMERS == 1 )
3359 void MPU_vTimerSetTimerIDImpl( TimerHandle_t xTimer,
3360 void * pvNewID ) PRIVILEGED_FUNCTION;
3362 void MPU_vTimerSetTimerIDImpl( TimerHandle_t xTimer,
3363 void * pvNewID ) /* PRIVILEGED_FUNCTION */
3365 TimerHandle_t xInternalTimerHandle = NULL;
3367 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3369 lIndex = ( int32_t ) xTimer;
3371 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3373 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3375 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3377 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3379 if( xInternalTimerHandle != NULL )
3381 vTimerSetTimerID( xInternalTimerHandle, pvNewID );
3387 #endif /* if ( configUSE_TIMERS == 1 ) */
3388 /*-----------------------------------------------------------*/
3390 #if ( configUSE_TIMERS == 1 )
3392 BaseType_t MPU_xTimerIsTimerActiveImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3394 BaseType_t MPU_xTimerIsTimerActiveImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3396 BaseType_t xReturn = pdFALSE;
3397 TimerHandle_t xInternalTimerHandle = NULL;
3399 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3401 lIndex = ( int32_t ) xTimer;
3403 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3405 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3407 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3409 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3411 if( xInternalTimerHandle != NULL )
3413 xReturn = xTimerIsTimerActive( xInternalTimerHandle );
3421 #endif /* if ( configUSE_TIMERS == 1 ) */
3422 /*-----------------------------------------------------------*/
3424 #if ( configUSE_TIMERS == 1 )
3426 TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandleImpl( void ) PRIVILEGED_FUNCTION;
3428 TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandleImpl( void ) /* PRIVILEGED_FUNCTION */
3430 TaskHandle_t xReturn;
3432 xReturn = xTimerGetTimerDaemonTaskHandle();
3437 #endif /* if ( configUSE_TIMERS == 1 ) */
3438 /*-----------------------------------------------------------*/
3440 #if ( configUSE_TIMERS == 1 )
3442 BaseType_t MPU_xTimerGenericCommandFromTask( TimerHandle_t xTimer,
3443 const BaseType_t xCommandID,
3444 const TickType_t xOptionalValue,
3445 BaseType_t * const pxHigherPriorityTaskWoken,
3446 const TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
3448 BaseType_t xReturn = pdFALSE;
3449 xTimerGenericCommandFromTaskParams_t xParams;
3451 xParams.xTimer = xTimer;
3452 xParams.xCommandID = xCommandID;
3453 xParams.xOptionalValue = xOptionalValue;
3454 xParams.pxHigherPriorityTaskWoken = pxHigherPriorityTaskWoken;
3455 xParams.xTicksToWait = xTicksToWait;
3457 xReturn = MPU_xTimerGenericCommandFromTaskEntry( &( xParams ) );
3462 BaseType_t MPU_xTimerGenericCommandFromTaskImpl( const xTimerGenericCommandFromTaskParams_t * pxParams ) PRIVILEGED_FUNCTION;
3464 BaseType_t MPU_xTimerGenericCommandFromTaskImpl( const xTimerGenericCommandFromTaskParams_t * pxParams ) /* PRIVILEGED_FUNCTION */
3466 BaseType_t xReturn = pdFALSE;
3467 TimerHandle_t xInternalTimerHandle = NULL;
3469 BaseType_t xIsHigherPriorityTaskWokenWriteable = pdFALSE;
3470 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3471 BaseType_t xAreParamsReadable = pdFALSE;
3473 if( pxParams != NULL )
3475 xAreParamsReadable = xPortIsAuthorizedToAccessBuffer( pxParams,
3476 sizeof( xTimerGenericCommandFromTaskParams_t ),
3477 tskMPU_READ_PERMISSION );
3480 if( xAreParamsReadable == pdTRUE )
3482 if( pxParams->xCommandID < tmrFIRST_FROM_ISR_COMMAND )
3484 if( pxParams->pxHigherPriorityTaskWoken != NULL )
3486 xIsHigherPriorityTaskWokenWriteable = xPortIsAuthorizedToAccessBuffer( pxParams->pxHigherPriorityTaskWoken,
3487 sizeof( BaseType_t ),
3488 tskMPU_WRITE_PERMISSION );
3491 if( ( pxParams->pxHigherPriorityTaskWoken == NULL ) ||
3492 ( xIsHigherPriorityTaskWokenWriteable == pdTRUE ) )
3494 lIndex = ( int32_t ) ( pxParams->xTimer );
3496 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3498 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3500 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3502 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3504 if( xInternalTimerHandle != NULL )
3506 xReturn = xTimerGenericCommandFromTask( xInternalTimerHandle,
3507 pxParams->xCommandID,
3508 pxParams->xOptionalValue,
3509 pxParams->pxHigherPriorityTaskWoken,
3510 pxParams->xTicksToWait );
3521 #endif /* if ( configUSE_TIMERS == 1 ) */
3522 /*-----------------------------------------------------------*/
3524 #if ( configUSE_TIMERS == 1 )
3526 const char * MPU_pcTimerGetNameImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3528 const char * MPU_pcTimerGetNameImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3530 const char * pcReturn = NULL;
3531 TimerHandle_t xInternalTimerHandle = NULL;
3533 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3535 lIndex = ( int32_t ) xTimer;
3537 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3539 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3541 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3543 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3545 if( xInternalTimerHandle != NULL )
3547 pcReturn = pcTimerGetName( xInternalTimerHandle );
3555 #endif /* if ( configUSE_TIMERS == 1 ) */
3556 /*-----------------------------------------------------------*/
3558 #if ( configUSE_TIMERS == 1 )
3560 void MPU_vTimerSetReloadModeImpl( TimerHandle_t xTimer,
3561 const UBaseType_t uxAutoReload ) PRIVILEGED_FUNCTION;
3563 void MPU_vTimerSetReloadModeImpl( TimerHandle_t xTimer,
3564 const UBaseType_t uxAutoReload ) /* PRIVILEGED_FUNCTION */
3566 TimerHandle_t xInternalTimerHandle = NULL;
3568 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3570 lIndex = ( int32_t ) xTimer;
3572 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3574 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3576 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3578 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3580 if( xInternalTimerHandle != NULL )
3582 vTimerSetReloadMode( xInternalTimerHandle, uxAutoReload );
3588 #endif /* if ( configUSE_TIMERS == 1 ) */
3589 /*-----------------------------------------------------------*/
3591 #if ( configUSE_TIMERS == 1 )
3593 BaseType_t MPU_xTimerGetReloadModeImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3595 BaseType_t MPU_xTimerGetReloadModeImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3597 BaseType_t xReturn = pdFALSE;
3598 TimerHandle_t xInternalTimerHandle = NULL;
3600 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3602 lIndex = ( int32_t ) xTimer;
3604 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3606 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3608 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3610 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3612 if( xInternalTimerHandle != NULL )
3614 xReturn = xTimerGetReloadMode( xInternalTimerHandle );
3622 #endif /* if ( configUSE_TIMERS == 1 ) */
3623 /*-----------------------------------------------------------*/
3625 #if ( configUSE_TIMERS == 1 )
3627 UBaseType_t MPU_uxTimerGetReloadModeImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3629 UBaseType_t MPU_uxTimerGetReloadModeImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3631 UBaseType_t uxReturn = 0;
3632 TimerHandle_t xInternalTimerHandle = NULL;
3634 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3636 lIndex = ( int32_t ) xTimer;
3638 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3640 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3642 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3644 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3646 if( xInternalTimerHandle != NULL )
3648 uxReturn = uxTimerGetReloadMode( xInternalTimerHandle );
3656 #endif /* if ( configUSE_TIMERS == 1 ) */
3657 /*-----------------------------------------------------------*/
3659 #if ( configUSE_TIMERS == 1 )
3661 TickType_t MPU_xTimerGetPeriodImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3663 TickType_t MPU_xTimerGetPeriodImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3665 TickType_t xReturn = 0;
3666 TimerHandle_t xInternalTimerHandle = NULL;
3668 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3670 lIndex = ( int32_t ) xTimer;
3672 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3674 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3676 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3678 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3680 if( xInternalTimerHandle != NULL )
3682 xReturn = xTimerGetPeriod( xInternalTimerHandle );
3690 #endif /* if ( configUSE_TIMERS == 1 ) */
3691 /*-----------------------------------------------------------*/
3693 #if ( configUSE_TIMERS == 1 )
3695 TickType_t MPU_xTimerGetExpiryTimeImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3697 TickType_t MPU_xTimerGetExpiryTimeImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3699 TickType_t xReturn = 0;
3700 TimerHandle_t xInternalTimerHandle = NULL;
3702 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3704 lIndex = ( int32_t ) xTimer;
3706 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3708 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3710 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3712 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3714 if( xInternalTimerHandle != NULL )
3716 xReturn = xTimerGetExpiryTime( xInternalTimerHandle );
3724 #endif /* if ( configUSE_TIMERS == 1 ) */
3725 /*-----------------------------------------------------------*/
3727 /* Privileged only wrappers for Timer APIs. These are needed so that
3728 * the application can use opaque handles maintained in mpu_wrappers.c
3729 * with all the APIs. */
3730 /*-----------------------------------------------------------*/
3732 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 )
3734 TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName,
3735 const TickType_t xTimerPeriodInTicks,
3736 const UBaseType_t uxAutoReload,
3737 void * const pvTimerID,
3738 TimerCallbackFunction_t pxCallbackFunction ) /* PRIVILEGED_FUNCTION */
3740 TimerHandle_t xInternalTimerHandle = NULL;
3741 TimerHandle_t xExternalTimerHandle = NULL;
3744 lIndex = MPU_GetFreeIndexInKernelObjectPool();
3748 xInternalTimerHandle = xTimerCreate( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, MPU_TimerCallback );
3750 if( xInternalTimerHandle != NULL )
3752 MPU_StoreTimerHandleAtIndex( lIndex, xInternalTimerHandle, pxCallbackFunction );
3753 xExternalTimerHandle = ( TimerHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
3757 MPU_SetIndexFreeInKernelObjectPool( lIndex );
3761 return xExternalTimerHandle;
3764 #endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) */
3765 /*-----------------------------------------------------------*/
3767 #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 )
3769 TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName,
3770 const TickType_t xTimerPeriodInTicks,
3771 const UBaseType_t uxAutoReload,
3772 void * const pvTimerID,
3773 TimerCallbackFunction_t pxCallbackFunction,
3774 StaticTimer_t * pxTimerBuffer ) /* PRIVILEGED_FUNCTION */
3776 TimerHandle_t xInternalTimerHandle = NULL;
3777 TimerHandle_t xExternalTimerHandle = NULL;
3780 lIndex = MPU_GetFreeIndexInKernelObjectPool();
3784 xInternalTimerHandle = xTimerCreateStatic( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, MPU_TimerCallback, pxTimerBuffer );
3786 if( xInternalTimerHandle != NULL )
3788 MPU_StoreTimerHandleAtIndex( lIndex, xInternalTimerHandle, pxCallbackFunction );
3789 xExternalTimerHandle = ( TimerHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
3793 MPU_SetIndexFreeInKernelObjectPool( lIndex );
3797 return xExternalTimerHandle;
3800 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) */
3801 /*-----------------------------------------------------------*/
3803 #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 )
3805 BaseType_t MPU_xTimerGetStaticBuffer( TimerHandle_t xTimer,
3806 StaticTimer_t ** ppxTimerBuffer ) /* PRIVILEGED_FUNCTION */
3808 TimerHandle_t xInternalTimerHandle = NULL;
3810 BaseType_t xReturn = pdFALSE;
3812 lIndex = ( int32_t ) xTimer;
3814 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3816 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3818 if( xInternalTimerHandle != NULL )
3820 xReturn = xTimerGetStaticBuffer( xInternalTimerHandle, ppxTimerBuffer );
3827 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) */
3828 /*-----------------------------------------------------------*/
3830 #if ( configUSE_TIMERS == 1 )
3832 BaseType_t MPU_xTimerGenericCommandFromISR( TimerHandle_t xTimer,
3833 const BaseType_t xCommandID,
3834 const TickType_t xOptionalValue,
3835 BaseType_t * const pxHigherPriorityTaskWoken,
3836 const TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
3838 BaseType_t xReturn = pdFALSE;
3839 TimerHandle_t xInternalTimerHandle = NULL;
3841 BaseType_t xIsHigherPriorityTaskWokenWriteable = pdFALSE;
3843 if( pxHigherPriorityTaskWoken != NULL )
3845 xIsHigherPriorityTaskWokenWriteable = xPortIsAuthorizedToAccessBuffer( pxHigherPriorityTaskWoken,
3846 sizeof( BaseType_t ),
3847 tskMPU_WRITE_PERMISSION );
3850 if( ( pxHigherPriorityTaskWoken == NULL ) || ( xIsHigherPriorityTaskWokenWriteable == pdTRUE ) )
3852 lIndex = ( int32_t ) xTimer;
3854 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3856 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3858 if( xInternalTimerHandle != NULL )
3860 xReturn = xTimerGenericCommandFromISR( xInternalTimerHandle, xCommandID, xOptionalValue, pxHigherPriorityTaskWoken, xTicksToWait );
3868 #endif /* if ( configUSE_TIMERS == 1 ) */
3869 /*-----------------------------------------------------------*/
3871 /*-----------------------------------------------------------*/
3872 /* MPU wrappers for event group APIs. */
3873 /*-----------------------------------------------------------*/
3875 #if ( configUSE_EVENT_GROUPS == 1 )
3877 EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
3878 const EventBits_t uxBitsToWaitFor,
3879 const BaseType_t xClearOnExit,
3880 const BaseType_t xWaitForAllBits,
3881 TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
3883 EventBits_t xReturn = 0;
3884 xEventGroupWaitBitsParams_t xParams;
3886 xParams.xEventGroup = xEventGroup;
3887 xParams.uxBitsToWaitFor = uxBitsToWaitFor;
3888 xParams.xClearOnExit = xClearOnExit;
3889 xParams.xWaitForAllBits = xWaitForAllBits;
3890 xParams.xTicksToWait = xTicksToWait;
3892 xReturn = MPU_xEventGroupWaitBitsEntry( &( xParams ) );
3897 EventBits_t MPU_xEventGroupWaitBitsImpl( const xEventGroupWaitBitsParams_t * pxParams ) PRIVILEGED_FUNCTION;
3899 EventBits_t MPU_xEventGroupWaitBitsImpl( const xEventGroupWaitBitsParams_t * pxParams ) /* PRIVILEGED_FUNCTION */
3901 EventBits_t xReturn = 0;
3902 EventGroupHandle_t xInternalEventGroupHandle = NULL;
3904 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE;
3905 BaseType_t xAreParamsReadable = pdFALSE;
3907 if( pxParams != NULL )
3909 xAreParamsReadable = xPortIsAuthorizedToAccessBuffer( pxParams,
3910 sizeof( xEventGroupWaitBitsParams_t ),
3911 tskMPU_READ_PERMISSION );
3914 if( xAreParamsReadable == pdTRUE )
3916 if( ( ( pxParams->uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0U ) &&
3917 ( pxParams->uxBitsToWaitFor != 0U )
3918 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
3919 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( pxParams->xTicksToWait != 0U ) ) )
3923 lIndex = ( int32_t ) ( pxParams->xEventGroup );
3925 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3927 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3929 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE )
3931 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3933 if( xInternalEventGroupHandle != NULL )
3935 xReturn = xEventGroupWaitBits( xInternalEventGroupHandle,
3936 pxParams->uxBitsToWaitFor,
3937 pxParams->xClearOnExit,
3938 pxParams->xWaitForAllBits,
3939 pxParams->xTicksToWait );
3949 #endif /* #if ( configUSE_EVENT_GROUPS == 1 ) */
3950 /*-----------------------------------------------------------*/
3952 #if ( configUSE_EVENT_GROUPS == 1 )
3954 EventBits_t MPU_xEventGroupClearBitsImpl( EventGroupHandle_t xEventGroup,
3955 const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION;
3957 EventBits_t MPU_xEventGroupClearBitsImpl( EventGroupHandle_t xEventGroup,
3958 const EventBits_t uxBitsToClear ) /* PRIVILEGED_FUNCTION */
3960 EventBits_t xReturn = 0;
3961 EventGroupHandle_t xInternalEventGroupHandle = NULL;
3963 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE;
3965 if( ( uxBitsToClear & eventEVENT_BITS_CONTROL_BYTES ) == 0U )
3967 lIndex = ( int32_t ) xEventGroup;
3969 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3971 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3973 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE )
3975 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3977 if( xInternalEventGroupHandle != NULL )
3979 xReturn = xEventGroupClearBits( xInternalEventGroupHandle, uxBitsToClear );
3988 #endif /* #if ( configUSE_EVENT_GROUPS == 1 ) */
3989 /*-----------------------------------------------------------*/
3991 #if ( configUSE_EVENT_GROUPS == 1 )
3993 EventBits_t MPU_xEventGroupSetBitsImpl( EventGroupHandle_t xEventGroup,
3994 const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION;
3996 EventBits_t MPU_xEventGroupSetBitsImpl( EventGroupHandle_t xEventGroup,
3997 const EventBits_t uxBitsToSet ) /* PRIVILEGED_FUNCTION */
3999 EventBits_t xReturn = 0;
4000 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4002 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE;
4004 if( ( uxBitsToSet & eventEVENT_BITS_CONTROL_BYTES ) == 0U )
4006 lIndex = ( int32_t ) xEventGroup;
4008 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4010 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4012 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE )
4014 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4016 if( xInternalEventGroupHandle != NULL )
4018 xReturn = xEventGroupSetBits( xInternalEventGroupHandle, uxBitsToSet );
4027 #endif /* #if ( configUSE_EVENT_GROUPS == 1 ) */
4028 /*-----------------------------------------------------------*/
4030 #if ( configUSE_EVENT_GROUPS == 1 )
4032 EventBits_t MPU_xEventGroupSyncImpl( EventGroupHandle_t xEventGroup,
4033 const EventBits_t uxBitsToSet,
4034 const EventBits_t uxBitsToWaitFor,
4035 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
4037 EventBits_t MPU_xEventGroupSyncImpl( EventGroupHandle_t xEventGroup,
4038 const EventBits_t uxBitsToSet,
4039 const EventBits_t uxBitsToWaitFor,
4040 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
4042 EventBits_t xReturn = 0;
4043 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4045 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE;
4047 if( ( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0U ) &&
4048 ( uxBitsToWaitFor != 0U )
4049 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
4050 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0U ) ) )
4054 lIndex = ( int32_t ) xEventGroup;
4056 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4058 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4060 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE )
4062 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4064 if( xInternalEventGroupHandle != NULL )
4066 xReturn = xEventGroupSync( xInternalEventGroupHandle, uxBitsToSet, uxBitsToWaitFor, xTicksToWait );
4075 #endif /* #if ( configUSE_EVENT_GROUPS == 1 ) */
4076 /*-----------------------------------------------------------*/
4078 #if ( ( configUSE_EVENT_GROUPS == 1 ) && ( configUSE_TRACE_FACILITY == 1 ) )
4080 UBaseType_t MPU_uxEventGroupGetNumberImpl( void * xEventGroup ) PRIVILEGED_FUNCTION;
4082 UBaseType_t MPU_uxEventGroupGetNumberImpl( void * xEventGroup ) /* PRIVILEGED_FUNCTION */
4084 UBaseType_t xReturn = 0;
4085 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4087 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE;
4089 lIndex = ( int32_t ) xEventGroup;
4091 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4093 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4095 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE )
4097 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4099 if( xInternalEventGroupHandle != NULL )
4101 xReturn = uxEventGroupGetNumber( xInternalEventGroupHandle );
4109 #endif /* #if ( ( configUSE_EVENT_GROUPS == 1 ) && ( configUSE_TRACE_FACILITY == 1 ) ) */
4110 /*-----------------------------------------------------------*/
4112 #if ( ( configUSE_EVENT_GROUPS == 1 ) && ( configUSE_TRACE_FACILITY == 1 ) )
4114 void MPU_vEventGroupSetNumberImpl( void * xEventGroup,
4115 UBaseType_t uxEventGroupNumber ) PRIVILEGED_FUNCTION;
4117 void MPU_vEventGroupSetNumberImpl( void * xEventGroup,
4118 UBaseType_t uxEventGroupNumber ) /* PRIVILEGED_FUNCTION */
4120 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4122 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE;
4124 lIndex = ( int32_t ) xEventGroup;
4126 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4128 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4130 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE )
4132 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4134 if( xInternalEventGroupHandle != NULL )
4136 vEventGroupSetNumber( xInternalEventGroupHandle, uxEventGroupNumber );
4142 #endif /* #if ( ( configUSE_EVENT_GROUPS == 1 ) && ( configUSE_TRACE_FACILITY == 1 ) ) */
4143 /*-----------------------------------------------------------*/
4145 /* Privileged only wrappers for Event Group APIs. These are needed so that
4146 * the application can use opaque handles maintained in mpu_wrappers.c
4147 * with all the APIs. */
4148 /*-----------------------------------------------------------*/
4150 #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_EVENT_GROUPS == 1 ) )
4152 EventGroupHandle_t MPU_xEventGroupCreate( void ) /* PRIVILEGED_FUNCTION */
4154 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4155 EventGroupHandle_t xExternalEventGroupHandle = NULL;
4158 lIndex = MPU_GetFreeIndexInKernelObjectPool();
4162 xInternalEventGroupHandle = xEventGroupCreate();
4164 if( xInternalEventGroupHandle != NULL )
4166 MPU_StoreEventGroupHandleAtIndex( lIndex, xInternalEventGroupHandle );
4167 xExternalEventGroupHandle = ( EventGroupHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
4171 MPU_SetIndexFreeInKernelObjectPool( lIndex );
4175 return xExternalEventGroupHandle;
4178 #endif /* #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_EVENT_GROUPS == 1 ) ) */
4179 /*-----------------------------------------------------------*/
4181 #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_EVENT_GROUPS == 1 ) )
4183 EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) /* PRIVILEGED_FUNCTION */
4185 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4186 EventGroupHandle_t xExternalEventGroupHandle = NULL;
4189 lIndex = MPU_GetFreeIndexInKernelObjectPool();
4193 xInternalEventGroupHandle = xEventGroupCreateStatic( pxEventGroupBuffer );
4195 if( xInternalEventGroupHandle != NULL )
4197 MPU_StoreEventGroupHandleAtIndex( lIndex, xInternalEventGroupHandle );
4198 xExternalEventGroupHandle = ( EventGroupHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
4202 MPU_SetIndexFreeInKernelObjectPool( lIndex );
4206 return xExternalEventGroupHandle;
4209 #endif /* #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_EVENT_GROUPS == 1 ) ) */
4210 /*-----------------------------------------------------------*/
4212 #if ( configUSE_EVENT_GROUPS == 1 )
4214 void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) /* PRIVILEGED_FUNCTION */
4216 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4219 lIndex = ( int32_t ) xEventGroup;
4221 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4223 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4225 if( xInternalEventGroupHandle != NULL )
4227 vEventGroupDelete( xInternalEventGroupHandle );
4228 MPU_SetIndexFreeInKernelObjectPool( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4233 #endif /* #if ( configUSE_EVENT_GROUPS == 1 ) */
4234 /*-----------------------------------------------------------*/
4236 #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_EVENT_GROUPS == 1 ) )
4238 BaseType_t MPU_xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup,
4239 StaticEventGroup_t ** ppxEventGroupBuffer ) /* PRIVILEGED_FUNCTION */
4241 BaseType_t xReturn = pdFALSE;
4242 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4245 lIndex = ( int32_t ) xEventGroup;
4247 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4249 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4251 if( xInternalEventGroupHandle != NULL )
4253 xReturn = xEventGroupGetStaticBuffer( xInternalEventGroupHandle, ppxEventGroupBuffer );
4260 #endif /* #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_EVENT_GROUPS == 1 ) ) */
4261 /*-----------------------------------------------------------*/
4263 #if ( ( configUSE_EVENT_GROUPS == 1 ) && ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )
4265 BaseType_t MPU_xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup,
4266 const EventBits_t uxBitsToClear ) /* PRIVILEGED_FUNCTION */
4268 BaseType_t xReturn = pdFALSE;
4269 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4272 lIndex = ( int32_t ) xEventGroup;
4274 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4276 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4278 if( xInternalEventGroupHandle != NULL )
4280 xReturn = xEventGroupClearBitsFromISR( xInternalEventGroupHandle, uxBitsToClear );
4287 #endif /* #if ( ( configUSE_EVENT_GROUPS == 1 ) && ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) ) */
4288 /*-----------------------------------------------------------*/
4290 #if ( ( configUSE_EVENT_GROUPS == 1 ) && ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )
4292 BaseType_t MPU_xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup,
4293 const EventBits_t uxBitsToSet,
4294 BaseType_t * pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
4296 BaseType_t xReturn = pdFALSE;
4297 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4300 lIndex = ( int32_t ) xEventGroup;
4302 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4304 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4306 if( xInternalEventGroupHandle != NULL )
4308 xReturn = xEventGroupSetBitsFromISR( xInternalEventGroupHandle, uxBitsToSet, pxHigherPriorityTaskWoken );
4315 #endif /* #if ( ( configUSE_EVENT_GROUPS == 1 ) && ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) ) */
4316 /*-----------------------------------------------------------*/
4318 #if ( configUSE_EVENT_GROUPS == 1 )
4320 EventBits_t MPU_xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ) /* PRIVILEGED_FUNCTION */
4322 EventBits_t xReturn = 0;
4323 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4326 lIndex = ( int32_t ) xEventGroup;
4328 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4330 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4332 if( xInternalEventGroupHandle != NULL )
4334 xReturn = xEventGroupGetBitsFromISR( xInternalEventGroupHandle );
4341 #endif /* #if ( configUSE_EVENT_GROUPS == 1 ) */
4342 /*-----------------------------------------------------------*/
4344 /*-----------------------------------------------------------*/
4345 /* MPU wrappers for stream buffer APIs. */
4346 /*-----------------------------------------------------------*/
4348 #if ( configUSE_STREAM_BUFFERS == 1 )
4350 size_t MPU_xStreamBufferSendImpl( StreamBufferHandle_t xStreamBuffer,
4351 const void * pvTxData,
4352 size_t xDataLengthBytes,
4353 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
4355 size_t MPU_xStreamBufferSendImpl( StreamBufferHandle_t xStreamBuffer,
4356 const void * pvTxData,
4357 size_t xDataLengthBytes,
4358 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
4361 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4363 BaseType_t xIsTxDataBufferReadable = pdFALSE;
4364 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4366 if( pvTxData != NULL )
4368 xIsTxDataBufferReadable = xPortIsAuthorizedToAccessBuffer( pvTxData,
4370 tskMPU_READ_PERMISSION );
4372 if( xIsTxDataBufferReadable == pdTRUE )
4374 lIndex = ( int32_t ) xStreamBuffer;
4376 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4378 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4380 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4382 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4384 if( xInternalStreamBufferHandle != NULL )
4386 xReturn = xStreamBufferSend( xInternalStreamBufferHandle, pvTxData, xDataLengthBytes, xTicksToWait );
4396 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4397 /*-----------------------------------------------------------*/
4399 #if ( configUSE_STREAM_BUFFERS == 1 )
4401 size_t MPU_xStreamBufferReceiveImpl( StreamBufferHandle_t xStreamBuffer,
4403 size_t xBufferLengthBytes,
4404 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
4406 size_t MPU_xStreamBufferReceiveImpl( StreamBufferHandle_t xStreamBuffer,
4408 size_t xBufferLengthBytes,
4409 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
4412 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4414 BaseType_t xIsRxDataBufferWriteable = pdFALSE;
4415 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4417 if( pvRxData != NULL )
4419 xIsRxDataBufferWriteable = xPortIsAuthorizedToAccessBuffer( pvRxData,
4421 tskMPU_WRITE_PERMISSION );
4423 if( xIsRxDataBufferWriteable == pdTRUE )
4425 lIndex = ( int32_t ) xStreamBuffer;
4427 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4429 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4431 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4433 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4435 if( xInternalStreamBufferHandle != NULL )
4437 xReturn = xStreamBufferReceive( xInternalStreamBufferHandle, pvRxData, xBufferLengthBytes, xTicksToWait );
4447 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4448 /*-----------------------------------------------------------*/
4450 #if ( configUSE_STREAM_BUFFERS == 1 )
4452 BaseType_t MPU_xStreamBufferIsFullImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
4454 BaseType_t MPU_xStreamBufferIsFullImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4456 BaseType_t xReturn = pdFALSE;
4457 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4459 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4461 lIndex = ( int32_t ) xStreamBuffer;
4463 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4465 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4467 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4469 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4471 if( xInternalStreamBufferHandle != NULL )
4473 xReturn = xStreamBufferIsFull( xInternalStreamBufferHandle );
4481 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4482 /*-----------------------------------------------------------*/
4484 #if ( configUSE_STREAM_BUFFERS == 1 )
4486 BaseType_t MPU_xStreamBufferIsEmptyImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
4488 BaseType_t MPU_xStreamBufferIsEmptyImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4490 BaseType_t xReturn = pdFALSE;
4491 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4493 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4495 lIndex = ( int32_t ) xStreamBuffer;
4497 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4499 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4501 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4503 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4505 if( xInternalStreamBufferHandle != NULL )
4507 xReturn = xStreamBufferIsEmpty( xInternalStreamBufferHandle );
4515 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4516 /*-----------------------------------------------------------*/
4518 #if ( configUSE_STREAM_BUFFERS == 1 )
4520 size_t MPU_xStreamBufferSpacesAvailableImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
4522 size_t MPU_xStreamBufferSpacesAvailableImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4525 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4527 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4529 lIndex = ( int32_t ) xStreamBuffer;
4531 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4533 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4535 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4537 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4539 if( xInternalStreamBufferHandle != NULL )
4541 xReturn = xStreamBufferSpacesAvailable( xInternalStreamBufferHandle );
4549 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4550 /*-----------------------------------------------------------*/
4552 #if ( configUSE_STREAM_BUFFERS == 1 )
4554 size_t MPU_xStreamBufferBytesAvailableImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
4556 size_t MPU_xStreamBufferBytesAvailableImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4559 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4561 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4563 lIndex = ( int32_t ) xStreamBuffer;
4565 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4567 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4569 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4571 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4573 if( xInternalStreamBufferHandle != NULL )
4575 xReturn = xStreamBufferBytesAvailable( xInternalStreamBufferHandle );
4583 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4584 /*-----------------------------------------------------------*/
4586 #if ( configUSE_STREAM_BUFFERS == 1 )
4588 BaseType_t MPU_xStreamBufferSetTriggerLevelImpl( StreamBufferHandle_t xStreamBuffer,
4589 size_t xTriggerLevel ) PRIVILEGED_FUNCTION;
4591 BaseType_t MPU_xStreamBufferSetTriggerLevelImpl( StreamBufferHandle_t xStreamBuffer,
4592 size_t xTriggerLevel ) /* PRIVILEGED_FUNCTION */
4594 BaseType_t xReturn = pdFALSE;
4595 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4597 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4599 lIndex = ( int32_t ) xStreamBuffer;
4601 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4603 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4605 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4607 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4609 if( xInternalStreamBufferHandle != NULL )
4611 xReturn = xStreamBufferSetTriggerLevel( xInternalStreamBufferHandle, xTriggerLevel );
4619 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4620 /*-----------------------------------------------------------*/
4622 #if ( configUSE_STREAM_BUFFERS == 1 )
4624 size_t MPU_xStreamBufferNextMessageLengthBytesImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
4626 size_t MPU_xStreamBufferNextMessageLengthBytesImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4629 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4631 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4633 lIndex = ( int32_t ) xStreamBuffer;
4635 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4637 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4639 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4641 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4643 if( xInternalStreamBufferHandle != NULL )
4645 xReturn = xStreamBufferNextMessageLengthBytes( xInternalStreamBufferHandle );
4653 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4654 /*-----------------------------------------------------------*/
4656 /* Privileged only wrappers for Stream Buffer APIs. These are needed so that
4657 * the application can use opaque handles maintained in mpu_wrappers.c
4658 * with all the APIs. */
4659 /*-----------------------------------------------------------*/
4661 #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_STREAM_BUFFERS == 1 ) )
4663 StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes,
4664 size_t xTriggerLevelBytes,
4665 BaseType_t xIsMessageBuffer,
4666 StreamBufferCallbackFunction_t pxSendCompletedCallback,
4667 StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) /* PRIVILEGED_FUNCTION */
4669 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4670 StreamBufferHandle_t xExternalStreamBufferHandle = NULL;
4674 * Stream buffer application level callback functionality is disabled for MPU
4677 configASSERT( ( pxSendCompletedCallback == NULL ) &&
4678 ( pxReceiveCompletedCallback == NULL ) );
4680 if( ( pxSendCompletedCallback == NULL ) &&
4681 ( pxReceiveCompletedCallback == NULL ) )
4683 lIndex = MPU_GetFreeIndexInKernelObjectPool();
4687 xInternalStreamBufferHandle = xStreamBufferGenericCreate( xBufferSizeBytes,
4693 if( xInternalStreamBufferHandle != NULL )
4695 MPU_StoreStreamBufferHandleAtIndex( lIndex, xInternalStreamBufferHandle );
4696 xExternalStreamBufferHandle = ( StreamBufferHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
4700 MPU_SetIndexFreeInKernelObjectPool( lIndex );
4706 traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer );
4707 xExternalStreamBufferHandle = NULL;
4710 return xExternalStreamBufferHandle;
4713 #endif /* #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_STREAM_BUFFERS == 1 ) ) */
4714 /*-----------------------------------------------------------*/
4716 #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_STREAM_BUFFERS == 1 ) )
4718 StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
4719 size_t xTriggerLevelBytes,
4720 BaseType_t xIsMessageBuffer,
4721 uint8_t * const pucStreamBufferStorageArea,
4722 StaticStreamBuffer_t * const pxStaticStreamBuffer,
4723 StreamBufferCallbackFunction_t pxSendCompletedCallback,
4724 StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) /* PRIVILEGED_FUNCTION */
4726 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4727 StreamBufferHandle_t xExternalStreamBufferHandle = NULL;
4731 * Stream buffer application level callback functionality is disabled for MPU
4734 configASSERT( ( pxSendCompletedCallback == NULL ) &&
4735 ( pxReceiveCompletedCallback == NULL ) );
4737 if( ( pxSendCompletedCallback == NULL ) &&
4738 ( pxReceiveCompletedCallback == NULL ) )
4740 lIndex = MPU_GetFreeIndexInKernelObjectPool();
4744 xInternalStreamBufferHandle = xStreamBufferGenericCreateStatic( xBufferSizeBytes,
4747 pucStreamBufferStorageArea,
4748 pxStaticStreamBuffer,
4752 if( xInternalStreamBufferHandle != NULL )
4754 MPU_StoreStreamBufferHandleAtIndex( lIndex, xInternalStreamBufferHandle );
4755 xExternalStreamBufferHandle = ( StreamBufferHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
4759 MPU_SetIndexFreeInKernelObjectPool( lIndex );
4765 traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer );
4766 xExternalStreamBufferHandle = NULL;
4769 return xExternalStreamBufferHandle;
4772 #endif /* #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_STREAM_BUFFERS == 1 ) ) */
4773 /*-----------------------------------------------------------*/
4775 #if ( configUSE_STREAM_BUFFERS == 1 )
4777 void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4779 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4782 lIndex = ( int32_t ) xStreamBuffer;
4784 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4786 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4788 if( xInternalStreamBufferHandle != NULL )
4790 vStreamBufferDelete( xInternalStreamBufferHandle );
4793 MPU_SetIndexFreeInKernelObjectPool( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4797 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4798 /*-----------------------------------------------------------*/
4800 #if ( configUSE_STREAM_BUFFERS == 1 )
4802 BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4804 BaseType_t xReturn = pdFALSE;
4805 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4808 lIndex = ( int32_t ) xStreamBuffer;
4810 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4812 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4814 if( xInternalStreamBufferHandle != NULL )
4816 xReturn = xStreamBufferReset( xInternalStreamBufferHandle );
4823 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4824 /*-----------------------------------------------------------*/
4826 #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_STREAM_BUFFERS == 1 ) )
4828 BaseType_t MPU_xStreamBufferGetStaticBuffers( StreamBufferHandle_t xStreamBuffers,
4829 uint8_t * ppucStreamBufferStorageArea,
4830 StaticStreamBuffer_t * ppxStaticStreamBuffer ) /* PRIVILEGED_FUNCTION */
4832 BaseType_t xReturn = pdFALSE;
4833 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4836 lIndex = ( int32_t ) xStreamBuffers;
4838 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4840 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4842 if( xInternalStreamBufferHandle != NULL )
4844 xReturn = MPU_xStreamBufferGetStaticBuffers( xInternalStreamBufferHandle, ppucStreamBufferStorageArea, ppxStaticStreamBuffer );
4851 #endif /* #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_STREAM_BUFFERS == 1 ) ) */
4852 /*-----------------------------------------------------------*/
4854 #if ( configUSE_STREAM_BUFFERS == 1 )
4856 size_t MPU_xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer,
4857 const void * pvTxData,
4858 size_t xDataLengthBytes,
4859 BaseType_t * const pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
4862 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4865 lIndex = ( int32_t ) xStreamBuffer;
4867 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4869 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4871 if( xInternalStreamBufferHandle != NULL )
4873 xReturn = xStreamBufferSendFromISR( xInternalStreamBufferHandle, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken );
4880 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4881 /*-----------------------------------------------------------*/
4883 #if ( configUSE_STREAM_BUFFERS == 1 )
4885 size_t MPU_xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer,
4887 size_t xBufferLengthBytes,
4888 BaseType_t * const pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
4891 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4894 lIndex = ( int32_t ) xStreamBuffer;
4896 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4898 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4900 if( xInternalStreamBufferHandle != NULL )
4902 xReturn = xStreamBufferReceiveFromISR( xInternalStreamBufferHandle, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken );
4909 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4910 /*-----------------------------------------------------------*/
4912 #if ( configUSE_STREAM_BUFFERS == 1 )
4914 BaseType_t MPU_xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer,
4915 BaseType_t * pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
4917 BaseType_t xReturn = pdFALSE;
4918 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4921 lIndex = ( int32_t ) xStreamBuffer;
4923 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4925 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4927 if( xInternalStreamBufferHandle != NULL )
4929 xReturn = xStreamBufferSendCompletedFromISR( xInternalStreamBufferHandle, pxHigherPriorityTaskWoken );
4936 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4937 /*-----------------------------------------------------------*/
4939 #if ( configUSE_STREAM_BUFFERS == 1 )
4941 BaseType_t MPU_xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer,
4942 BaseType_t * pxHigherPriorityTaskWoken ) /*PRIVILEGED_FUNCTION */
4944 BaseType_t xReturn = pdFALSE;
4945 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4948 lIndex = ( int32_t ) xStreamBuffer;
4950 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4952 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4954 if( xInternalStreamBufferHandle != NULL )
4956 xReturn = xStreamBufferReceiveCompletedFromISR( xInternalStreamBufferHandle, pxHigherPriorityTaskWoken );
4963 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4965 /*-----------------------------------------------------------*/
4967 #if ( configUSE_STREAM_BUFFERS == 1 )
4969 BaseType_t MPU_xStreamBufferResetFromISR( StreamBufferHandle_t xStreamBuffer ) /*PRIVILEGED_FUNCTION */
4971 BaseType_t xReturn = pdFAIL;
4972 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4975 lIndex = ( int32_t ) xStreamBuffer;
4977 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4979 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4981 if( xInternalStreamBufferHandle != NULL )
4983 xReturn = xStreamBufferResetFromISR( xInternalStreamBufferHandle );
4990 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */
4992 /*-----------------------------------------------------------*/
4994 /* Functions that the application writer wants to execute in privileged mode
4995 * can be defined in application_defined_privileged_functions.h. */
4997 #if configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS == 1
4998 #include "application_defined_privileged_functions.h"
5000 /*-----------------------------------------------------------*/
5003 * @brief Array of system call implementation functions.
5005 * The index in the array MUST match the corresponding system call number
5006 * defined in mpu_wrappers.h.
5008 PRIVILEGED_DATA UBaseType_t uxSystemCallImplementations[ NUM_SYSTEM_CALLS ] =
5010 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
5011 ( UBaseType_t ) MPU_xTaskGenericNotifyImpl, /* SYSTEM_CALL_xTaskGenericNotify. */
5012 ( UBaseType_t ) MPU_xTaskGenericNotifyWaitImpl, /* SYSTEM_CALL_xTaskGenericNotifyWait. */
5014 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGenericNotify. */
5015 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGenericNotifyWait. */
5018 #if ( configUSE_TIMERS == 1 )
5019 ( UBaseType_t ) MPU_xTimerGenericCommandFromTaskImpl, /* SYSTEM_CALL_xTimerGenericCommandFromTask. */
5021 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGenericCommandFromTask. */
5024 #if ( configUSE_EVENT_GROUPS == 1 )
5025 ( UBaseType_t ) MPU_xEventGroupWaitBitsImpl, /* SYSTEM_CALL_xEventGroupWaitBits. */
5027 ( UBaseType_t ) 0, /* SYSTEM_CALL_xEventGroupWaitBits. */
5030 /* The system calls above this line take 5 parameters. */
5032 #if ( INCLUDE_xTaskDelayUntil == 1 )
5033 ( UBaseType_t ) MPU_xTaskDelayUntilImpl, /* SYSTEM_CALL_xTaskDelayUntil. */
5035 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskDelayUntil. */
5038 #if ( INCLUDE_xTaskAbortDelay == 1 )
5039 ( UBaseType_t ) MPU_xTaskAbortDelayImpl, /* SYSTEM_CALL_xTaskAbortDelay. */
5041 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskAbortDelay. */
5044 #if ( INCLUDE_vTaskDelay == 1 )
5045 ( UBaseType_t ) MPU_vTaskDelayImpl, /* SYSTEM_CALL_vTaskDelay. */
5047 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskDelay. */
5050 #if ( INCLUDE_uxTaskPriorityGet == 1 )
5051 ( UBaseType_t ) MPU_uxTaskPriorityGetImpl, /* SYSTEM_CALL_uxTaskPriorityGet. */
5053 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTaskPriorityGet. */
5056 #if ( INCLUDE_eTaskGetState == 1 )
5057 ( UBaseType_t ) MPU_eTaskGetStateImpl, /* SYSTEM_CALL_eTaskGetState. */
5059 ( UBaseType_t ) 0, /* SYSTEM_CALL_eTaskGetState. */
5062 #if ( configUSE_TRACE_FACILITY == 1 )
5063 ( UBaseType_t ) MPU_vTaskGetInfoImpl, /* SYSTEM_CALL_vTaskGetInfo. */
5065 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskGetInfo. */
5068 #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
5069 ( UBaseType_t ) MPU_xTaskGetIdleTaskHandleImpl, /* SYSTEM_CALL_xTaskGetIdleTaskHandle. */
5071 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGetIdleTaskHandle. */
5074 #if ( INCLUDE_vTaskSuspend == 1 )
5075 ( UBaseType_t ) MPU_vTaskSuspendImpl, /* SYSTEM_CALL_vTaskSuspend. */
5076 ( UBaseType_t ) MPU_vTaskResumeImpl, /* SYSTEM_CALL_vTaskResume. */
5078 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskSuspend. */
5079 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskResume. */
5082 ( UBaseType_t ) MPU_xTaskGetTickCountImpl, /* SYSTEM_CALL_xTaskGetTickCount. */
5083 ( UBaseType_t ) MPU_uxTaskGetNumberOfTasksImpl, /* SYSTEM_CALL_uxTaskGetNumberOfTasks. */
5085 #if ( configGENERATE_RUN_TIME_STATS == 1 )
5086 ( UBaseType_t ) MPU_ulTaskGetRunTimeCounterImpl, /* SYSTEM_CALL_ulTaskGetRunTimeCounter. */
5087 ( UBaseType_t ) MPU_ulTaskGetRunTimePercentImpl, /* SYSTEM_CALL_ulTaskGetRunTimePercent. */
5089 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGetRunTimeCounter. */
5090 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGetRunTimePercent. */
5093 #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) )
5094 ( UBaseType_t ) MPU_ulTaskGetIdleRunTimePercentImpl, /* SYSTEM_CALL_ulTaskGetIdleRunTimePercent. */
5095 ( UBaseType_t ) MPU_ulTaskGetIdleRunTimeCounterImpl, /* SYSTEM_CALL_ulTaskGetIdleRunTimeCounter. */
5097 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGetIdleRunTimePercent. */
5098 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGetIdleRunTimeCounter. */
5101 #if ( configUSE_APPLICATION_TASK_TAG == 1 )
5102 ( UBaseType_t ) MPU_vTaskSetApplicationTaskTagImpl, /* SYSTEM_CALL_vTaskSetApplicationTaskTag. */
5103 ( UBaseType_t ) MPU_xTaskGetApplicationTaskTagImpl, /* SYSTEM_CALL_xTaskGetApplicationTaskTag. */
5105 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskSetApplicationTaskTag. */
5106 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGetApplicationTaskTag. */
5109 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
5110 ( UBaseType_t ) MPU_vTaskSetThreadLocalStoragePointerImpl, /* SYSTEM_CALL_vTaskSetThreadLocalStoragePointer. */
5111 ( UBaseType_t ) MPU_pvTaskGetThreadLocalStoragePointerImpl, /* SYSTEM_CALL_pvTaskGetThreadLocalStoragePointer. */
5113 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskSetThreadLocalStoragePointer. */
5114 ( UBaseType_t ) 0, /* SYSTEM_CALL_pvTaskGetThreadLocalStoragePointer. */
5117 #if ( configUSE_TRACE_FACILITY == 1 )
5118 ( UBaseType_t ) MPU_uxTaskGetSystemStateImpl, /* SYSTEM_CALL_uxTaskGetSystemState. */
5120 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTaskGetSystemState. */
5123 #if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )
5124 ( UBaseType_t ) MPU_uxTaskGetStackHighWaterMarkImpl, /* SYSTEM_CALL_uxTaskGetStackHighWaterMark. */
5126 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTaskGetStackHighWaterMark. */
5129 #if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 )
5130 ( UBaseType_t ) MPU_uxTaskGetStackHighWaterMark2Impl, /* SYSTEM_CALL_uxTaskGetStackHighWaterMark2. */
5132 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTaskGetStackHighWaterMark2. */
5135 #if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) )
5136 ( UBaseType_t ) MPU_xTaskGetCurrentTaskHandleImpl, /* SYSTEM_CALL_xTaskGetCurrentTaskHandle. */
5138 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGetCurrentTaskHandle. */
5141 #if ( INCLUDE_xTaskGetSchedulerState == 1 )
5142 ( UBaseType_t ) MPU_xTaskGetSchedulerStateImpl, /* SYSTEM_CALL_xTaskGetSchedulerState. */
5144 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGetSchedulerState. */
5147 ( UBaseType_t ) MPU_vTaskSetTimeOutStateImpl, /* SYSTEM_CALL_vTaskSetTimeOutState. */
5148 ( UBaseType_t ) MPU_xTaskCheckForTimeOutImpl, /* SYSTEM_CALL_xTaskCheckForTimeOut. */
5150 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
5151 ( UBaseType_t ) MPU_ulTaskGenericNotifyTakeImpl, /* SYSTEM_CALL_ulTaskGenericNotifyTake. */
5152 ( UBaseType_t ) MPU_xTaskGenericNotifyStateClearImpl, /* SYSTEM_CALL_xTaskGenericNotifyStateClear. */
5153 ( UBaseType_t ) MPU_ulTaskGenericNotifyValueClearImpl, /* SYSTEM_CALL_ulTaskGenericNotifyValueClear. */
5155 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGenericNotifyTake. */
5156 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGenericNotifyStateClear. */
5157 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGenericNotifyValueClear. */
5160 ( UBaseType_t ) MPU_xQueueGenericSendImpl, /* SYSTEM_CALL_xQueueGenericSend. */
5161 ( UBaseType_t ) MPU_uxQueueMessagesWaitingImpl, /* SYSTEM_CALL_uxQueueMessagesWaiting. */
5162 ( UBaseType_t ) MPU_uxQueueSpacesAvailableImpl, /* SYSTEM_CALL_uxQueueSpacesAvailable. */
5163 ( UBaseType_t ) MPU_xQueueReceiveImpl, /* SYSTEM_CALL_xQueueReceive. */
5164 ( UBaseType_t ) MPU_xQueuePeekImpl, /* SYSTEM_CALL_xQueuePeek. */
5165 ( UBaseType_t ) MPU_xQueueSemaphoreTakeImpl, /* SYSTEM_CALL_xQueueSemaphoreTake. */
5167 #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )
5168 ( UBaseType_t ) MPU_xQueueGetMutexHolderImpl, /* SYSTEM_CALL_xQueueGetMutexHolder. */
5170 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueGetMutexHolder. */
5173 #if ( configUSE_RECURSIVE_MUTEXES == 1 )
5174 ( UBaseType_t ) MPU_xQueueTakeMutexRecursiveImpl, /* SYSTEM_CALL_xQueueTakeMutexRecursive. */
5175 ( UBaseType_t ) MPU_xQueueGiveMutexRecursiveImpl, /* SYSTEM_CALL_xQueueGiveMutexRecursive. */
5177 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueTakeMutexRecursive. */
5178 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueGiveMutexRecursive. */
5181 #if ( configUSE_QUEUE_SETS == 1 )
5182 ( UBaseType_t ) MPU_xQueueSelectFromSetImpl, /* SYSTEM_CALL_xQueueSelectFromSet. */
5183 ( UBaseType_t ) MPU_xQueueAddToSetImpl, /* SYSTEM_CALL_xQueueAddToSet. */
5185 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueSelectFromSet. */
5186 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueAddToSet. */
5189 #if configQUEUE_REGISTRY_SIZE > 0
5190 ( UBaseType_t ) MPU_vQueueAddToRegistryImpl, /* SYSTEM_CALL_vQueueAddToRegistry. */
5191 ( UBaseType_t ) MPU_vQueueUnregisterQueueImpl, /* SYSTEM_CALL_vQueueUnregisterQueue. */
5192 ( UBaseType_t ) MPU_pcQueueGetNameImpl, /* SYSTEM_CALL_pcQueueGetName. */
5194 ( UBaseType_t ) 0, /* SYSTEM_CALL_vQueueAddToRegistry. */
5195 ( UBaseType_t ) 0, /* SYSTEM_CALL_vQueueUnregisterQueue. */
5196 ( UBaseType_t ) 0, /* SYSTEM_CALL_pcQueueGetName. */
5199 #if ( configUSE_TIMERS == 1 )
5200 ( UBaseType_t ) MPU_pvTimerGetTimerIDImpl, /* SYSTEM_CALL_pvTimerGetTimerID. */
5201 ( UBaseType_t ) MPU_vTimerSetTimerIDImpl, /* SYSTEM_CALL_vTimerSetTimerID. */
5202 ( UBaseType_t ) MPU_xTimerIsTimerActiveImpl, /* SYSTEM_CALL_xTimerIsTimerActive. */
5203 ( UBaseType_t ) MPU_xTimerGetTimerDaemonTaskHandleImpl, /* SYSTEM_CALL_xTimerGetTimerDaemonTaskHandle. */
5204 ( UBaseType_t ) MPU_pcTimerGetNameImpl, /* SYSTEM_CALL_pcTimerGetName. */
5205 ( UBaseType_t ) MPU_vTimerSetReloadModeImpl, /* SYSTEM_CALL_vTimerSetReloadMode. */
5206 ( UBaseType_t ) MPU_xTimerGetReloadModeImpl, /* SYSTEM_CALL_xTimerGetReloadMode. */
5207 ( UBaseType_t ) MPU_uxTimerGetReloadModeImpl, /* SYSTEM_CALL_uxTimerGetReloadMode. */
5208 ( UBaseType_t ) MPU_xTimerGetPeriodImpl, /* SYSTEM_CALL_xTimerGetPeriod. */
5209 ( UBaseType_t ) MPU_xTimerGetExpiryTimeImpl, /* SYSTEM_CALL_xTimerGetExpiryTime. */
5211 ( UBaseType_t ) 0, /* SYSTEM_CALL_pvTimerGetTimerID. */
5212 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTimerSetTimerID. */
5213 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerIsTimerActive. */
5214 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGetTimerDaemonTaskHandle. */
5215 ( UBaseType_t ) 0, /* SYSTEM_CALL_pcTimerGetName. */
5216 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTimerSetReloadMode. */
5217 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGetReloadMode. */
5218 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTimerGetReloadMode. */
5219 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGetPeriod. */
5220 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGetExpiryTime. */
5223 #if ( configUSE_EVENT_GROUPS == 1 )
5224 ( UBaseType_t ) MPU_xEventGroupClearBitsImpl, /* SYSTEM_CALL_xEventGroupClearBits. */
5225 ( UBaseType_t ) MPU_xEventGroupSetBitsImpl, /* SYSTEM_CALL_xEventGroupSetBits. */
5226 ( UBaseType_t ) MPU_xEventGroupSyncImpl, /* SYSTEM_CALL_xEventGroupSync. */
5228 #if ( configUSE_TRACE_FACILITY == 1 )
5229 ( UBaseType_t ) MPU_uxEventGroupGetNumberImpl, /* SYSTEM_CALL_uxEventGroupGetNumber. */
5230 ( UBaseType_t ) MPU_vEventGroupSetNumberImpl, /* SYSTEM_CALL_vEventGroupSetNumber. */
5232 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxEventGroupGetNumber. */
5233 ( UBaseType_t ) 0, /* SYSTEM_CALL_vEventGroupSetNumber. */
5236 ( UBaseType_t ) 0, /* SYSTEM_CALL_xEventGroupClearBits. */
5237 ( UBaseType_t ) 0, /* SYSTEM_CALL_xEventGroupSetBits. */
5238 ( UBaseType_t ) 0, /* SYSTEM_CALL_xEventGroupSync. */
5239 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxEventGroupGetNumber. */
5240 ( UBaseType_t ) 0, /* SYSTEM_CALL_vEventGroupSetNumber. */
5243 #if ( configUSE_STREAM_BUFFERS == 1 )
5244 ( UBaseType_t ) MPU_xStreamBufferSendImpl, /* SYSTEM_CALL_xStreamBufferSend. */
5245 ( UBaseType_t ) MPU_xStreamBufferReceiveImpl, /* SYSTEM_CALL_xStreamBufferReceive. */
5246 ( UBaseType_t ) MPU_xStreamBufferIsFullImpl, /* SYSTEM_CALL_xStreamBufferIsFull. */
5247 ( UBaseType_t ) MPU_xStreamBufferIsEmptyImpl, /* SYSTEM_CALL_xStreamBufferIsEmpty. */
5248 ( UBaseType_t ) MPU_xStreamBufferSpacesAvailableImpl, /* SYSTEM_CALL_xStreamBufferSpacesAvailable. */
5249 ( UBaseType_t ) MPU_xStreamBufferBytesAvailableImpl, /* SYSTEM_CALL_xStreamBufferBytesAvailable. */
5250 ( UBaseType_t ) MPU_xStreamBufferSetTriggerLevelImpl, /* SYSTEM_CALL_xStreamBufferSetTriggerLevel. */
5251 ( UBaseType_t ) MPU_xStreamBufferNextMessageLengthBytesImpl /* SYSTEM_CALL_xStreamBufferNextMessageLengthBytes. */
5253 ( UBaseType_t ) 0, /* SYSTEM_CALL_xStreamBufferSend. */
5254 ( UBaseType_t ) 0, /* SYSTEM_CALL_xStreamBufferReceive. */
5255 ( UBaseType_t ) 0, /* SYSTEM_CALL_xStreamBufferIsFull. */
5256 ( UBaseType_t ) 0, /* SYSTEM_CALL_xStreamBufferIsEmpty. */
5257 ( UBaseType_t ) 0, /* SYSTEM_CALL_xStreamBufferSpacesAvailable. */
5258 ( UBaseType_t ) 0, /* SYSTEM_CALL_xStreamBufferBytesAvailable. */
5259 ( UBaseType_t ) 0, /* SYSTEM_CALL_xStreamBufferSetTriggerLevel. */
5260 ( UBaseType_t ) 0, /* SYSTEM_CALL_xStreamBufferNextMessageLengthBytes. */
5264 /*-----------------------------------------------------------*/
5266 #endif /* #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) ) */
5267 /*-----------------------------------------------------------*/