2 * FreeRTOS Kernel V11.0.1
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 ) ) )
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 ) ) )
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 )
219 * Wrappers to keep all the casting in one place for Event Group APIs.
221 #define MPU_StoreEventGroupHandleAtIndex( lIndex, xHandle ) MPU_StoreHandleAndDataAtIndex( lIndex, ( OpaqueObjectHandle_t ) xHandle, NULL, KERNEL_OBJECT_TYPE_EVENT_GROUP )
222 #define MPU_GetEventGroupHandleAtIndex( lIndex ) ( EventGroupHandle_t ) MPU_GetHandleAtIndex( lIndex, KERNEL_OBJECT_TYPE_EVENT_GROUP )
223 #define MPU_GetIndexForEventGroupHandle( xHandle ) MPU_GetIndexForHandle( ( OpaqueObjectHandle_t ) xHandle, KERNEL_OBJECT_TYPE_EVENT_GROUP )
226 * Wrappers to keep all the casting in one place for Stream Buffer APIs.
228 #define MPU_StoreStreamBufferHandleAtIndex( lIndex, xHandle ) MPU_StoreHandleAndDataAtIndex( lIndex, ( OpaqueObjectHandle_t ) xHandle, NULL, KERNEL_OBJECT_TYPE_STREAM_BUFFER )
229 #define MPU_GetStreamBufferHandleAtIndex( lIndex ) ( StreamBufferHandle_t ) MPU_GetHandleAtIndex( lIndex, KERNEL_OBJECT_TYPE_STREAM_BUFFER )
230 #define MPU_GetIndexForStreamBufferHandle( xHandle ) MPU_GetIndexForHandle( ( OpaqueObjectHandle_t ) xHandle, KERNEL_OBJECT_TYPE_STREAM_BUFFER )
232 #if ( configUSE_TIMERS == 1 )
235 * Wrappers to keep all the casting in one place for Timer APIs.
237 #define MPU_StoreTimerHandleAtIndex( lIndex, xHandle, pxApplicationCallback ) MPU_StoreHandleAndDataAtIndex( lIndex, ( OpaqueObjectHandle_t ) xHandle, ( void * ) pxApplicationCallback, KERNEL_OBJECT_TYPE_TIMER )
238 #define MPU_GetTimerHandleAtIndex( lIndex ) ( TimerHandle_t ) MPU_GetHandleAtIndex( lIndex, KERNEL_OBJECT_TYPE_TIMER )
239 #define MPU_GetIndexForTimerHandle( xHandle ) MPU_GetIndexForHandle( ( OpaqueObjectHandle_t ) xHandle, KERNEL_OBJECT_TYPE_TIMER )
241 #endif /* #if ( configUSE_TIMERS == 1 ) */
243 /*-----------------------------------------------------------*/
246 * @brief Kernel object pool.
248 PRIVILEGED_DATA static KernelObject_t xKernelObjectPool[ configPROTECTED_KERNEL_OBJECT_POOL_SIZE ] = { NULL };
249 /*-----------------------------------------------------------*/
251 static int32_t MPU_GetFreeIndexInKernelObjectPool( void ) /* PRIVILEGED_FUNCTION */
253 int32_t i, lFreeIndex = -1;
255 /* This function is called only from resource create APIs
256 * which are not supposed to be called from ISRs. Therefore,
257 * we only need to suspend the scheduler and do not require
258 * critical section. */
261 for( i = 0; i < configPROTECTED_KERNEL_OBJECT_POOL_SIZE; i++ )
263 if( xKernelObjectPool[ i ].xInternalObjectHandle == NULL )
265 /* Mark this index as not free. */
266 xKernelObjectPool[ i ].xInternalObjectHandle = ( OpaqueObjectHandle_t ) ( ~0 );
276 /*-----------------------------------------------------------*/
278 static void MPU_SetIndexFreeInKernelObjectPool( int32_t lIndex ) /* PRIVILEGED_FUNCTION */
280 configASSERT( IS_INTERNAL_INDEX_VALID( lIndex ) != pdFALSE );
282 taskENTER_CRITICAL();
284 xKernelObjectPool[ lIndex ].xInternalObjectHandle = NULL;
285 xKernelObjectPool[ lIndex ].ulKernelObjectType = KERNEL_OBJECT_TYPE_INVALID;
286 xKernelObjectPool[ lIndex ].pvKernelObjectData = NULL;
290 /*-----------------------------------------------------------*/
292 static int32_t MPU_GetIndexForHandle( OpaqueObjectHandle_t xHandle,
293 uint32_t ulKernelObjectType ) /* PRIVILEGED_FUNCTION */
295 int32_t i, lIndex = -1;
297 configASSERT( xHandle != NULL );
299 for( i = 0; i < configPROTECTED_KERNEL_OBJECT_POOL_SIZE; i++ )
301 if( ( xKernelObjectPool[ i ].xInternalObjectHandle == xHandle ) &&
302 ( xKernelObjectPool[ i ].ulKernelObjectType == ulKernelObjectType ) )
311 /*-----------------------------------------------------------*/
313 static void MPU_StoreHandleAndDataAtIndex( int32_t lIndex,
314 OpaqueObjectHandle_t xHandle,
315 void * pvKernelObjectData,
316 uint32_t ulKernelObjectType ) /* PRIVILEGED_FUNCTION */
318 configASSERT( IS_INTERNAL_INDEX_VALID( lIndex ) != pdFALSE );
319 xKernelObjectPool[ lIndex ].xInternalObjectHandle = xHandle;
320 xKernelObjectPool[ lIndex ].ulKernelObjectType = ulKernelObjectType;
321 xKernelObjectPool[ lIndex ].pvKernelObjectData = pvKernelObjectData;
323 /*-----------------------------------------------------------*/
325 static OpaqueObjectHandle_t MPU_GetHandleAtIndex( int32_t lIndex,
326 uint32_t ulKernelObjectType ) /* PRIVILEGED_FUNCTION */
328 OpaqueObjectHandle_t xObjectHandle = NULL;
330 configASSERT( IS_INTERNAL_INDEX_VALID( lIndex ) != pdFALSE );
332 if( xKernelObjectPool[ lIndex ].ulKernelObjectType == ulKernelObjectType )
334 xObjectHandle = xKernelObjectPool[ lIndex ].xInternalObjectHandle;
337 return xObjectHandle;
339 /*-----------------------------------------------------------*/
341 #if ( configENABLE_ACCESS_CONTROL_LIST == 1 )
343 void vGrantAccessToKernelObject( TaskHandle_t xExternalTaskHandle,
344 int32_t lExternalKernelObjectHandle ) /* PRIVILEGED_FUNCTION */
346 int32_t lExternalTaskIndex;
347 TaskHandle_t xInternalTaskHandle = NULL;
349 if( IS_EXTERNAL_INDEX_VALID( lExternalKernelObjectHandle ) != pdFALSE )
351 if( xExternalTaskHandle == NULL )
353 vPortGrantAccessToKernelObject( xExternalTaskHandle, CONVERT_TO_INTERNAL_INDEX( lExternalKernelObjectHandle ) );
357 lExternalTaskIndex = ( int32_t ) xExternalTaskHandle;
359 if( IS_EXTERNAL_INDEX_VALID( lExternalTaskIndex ) != pdFALSE )
361 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lExternalTaskIndex ) );
363 if( xInternalTaskHandle != NULL )
365 vPortGrantAccessToKernelObject( xInternalTaskHandle,
366 CONVERT_TO_INTERNAL_INDEX( lExternalKernelObjectHandle ) );
373 #endif /* #if ( configENABLE_ACCESS_CONTROL_LIST == 1 ) */
374 /*-----------------------------------------------------------*/
376 #if ( configENABLE_ACCESS_CONTROL_LIST == 1 )
378 void vRevokeAccessToKernelObject( TaskHandle_t xExternalTaskHandle,
379 int32_t lExternalKernelObjectHandle ) /* PRIVILEGED_FUNCTION */
381 int32_t lExternalTaskIndex;
382 TaskHandle_t xInternalTaskHandle = NULL;
384 if( IS_EXTERNAL_INDEX_VALID( lExternalKernelObjectHandle ) != pdFALSE )
386 if( xExternalTaskHandle == NULL )
388 vPortRevokeAccessToKernelObject( xExternalTaskHandle, CONVERT_TO_INTERNAL_INDEX( lExternalKernelObjectHandle ) );
392 lExternalTaskIndex = ( int32_t ) xExternalTaskHandle;
394 if( IS_EXTERNAL_INDEX_VALID( lExternalTaskIndex ) != pdFALSE )
396 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lExternalTaskIndex ) );
398 if( xInternalTaskHandle != NULL )
400 vPortRevokeAccessToKernelObject( xInternalTaskHandle,
401 CONVERT_TO_INTERNAL_INDEX( lExternalKernelObjectHandle ) );
408 #endif /* #if ( configENABLE_ACCESS_CONTROL_LIST == 1 ) */
409 /*-----------------------------------------------------------*/
411 #if ( configUSE_TIMERS == 1 )
413 static void MPU_TimerCallback( TimerHandle_t xInternalHandle ) /* PRIVILEGED_FUNCTION */
415 int32_t i, lIndex = -1;
416 TimerHandle_t xExternalHandle = NULL;
417 TimerCallbackFunction_t pxApplicationCallBack = NULL;
419 /* Coming from the timer task and therefore, should be valid. */
420 configASSERT( xInternalHandle != NULL );
422 for( i = 0; i < configPROTECTED_KERNEL_OBJECT_POOL_SIZE; i++ )
424 if( ( ( TimerHandle_t ) xKernelObjectPool[ i ].xInternalObjectHandle == xInternalHandle ) &&
425 ( xKernelObjectPool[ i ].ulKernelObjectType == KERNEL_OBJECT_TYPE_TIMER ) )
432 configASSERT( lIndex != -1 );
433 xExternalHandle = ( TimerHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
435 pxApplicationCallBack = ( TimerCallbackFunction_t ) xKernelObjectPool[ lIndex ].pvKernelObjectData;
436 pxApplicationCallBack( xExternalHandle );
439 #endif /* #if ( configUSE_TIMERS == 1 ) */
440 /*-----------------------------------------------------------*/
442 /*-----------------------------------------------------------*/
443 /* MPU wrappers for tasks APIs. */
444 /*-----------------------------------------------------------*/
446 #if ( INCLUDE_xTaskDelayUntil == 1 )
448 BaseType_t MPU_xTaskDelayUntilImpl( TickType_t * const pxPreviousWakeTime,
449 TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION;
451 BaseType_t MPU_xTaskDelayUntilImpl( TickType_t * const pxPreviousWakeTime,
452 TickType_t xTimeIncrement ) /* PRIVILEGED_FUNCTION */
454 BaseType_t xReturn = pdFAIL;
455 BaseType_t xIsPreviousWakeTimeAccessible = pdFALSE;
457 if( ( pxPreviousWakeTime != NULL ) && ( xTimeIncrement > 0U ) )
459 xIsPreviousWakeTimeAccessible = xPortIsAuthorizedToAccessBuffer( pxPreviousWakeTime,
460 sizeof( TickType_t ),
461 ( tskMPU_WRITE_PERMISSION | tskMPU_READ_PERMISSION ) );
463 if( xIsPreviousWakeTimeAccessible == pdTRUE )
465 xReturn = xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement );
472 #endif /* if ( INCLUDE_xTaskDelayUntil == 1 ) */
473 /*-----------------------------------------------------------*/
475 #if ( INCLUDE_xTaskAbortDelay == 1 )
477 BaseType_t MPU_xTaskAbortDelayImpl( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
479 BaseType_t MPU_xTaskAbortDelayImpl( TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
481 BaseType_t xReturn = pdFAIL;
482 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
483 TaskHandle_t xInternalTaskHandle = NULL;
486 lIndex = ( int32_t ) xTask;
488 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
490 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
492 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
494 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
496 if( xInternalTaskHandle != NULL )
498 xReturn = xTaskAbortDelay( xInternalTaskHandle );
506 #endif /* if ( INCLUDE_xTaskAbortDelay == 1 ) */
507 /*-----------------------------------------------------------*/
509 #if ( INCLUDE_vTaskDelay == 1 )
511 void MPU_vTaskDelayImpl( TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
513 void MPU_vTaskDelayImpl( TickType_t xTicksToDelay ) /* PRIVILEGED_FUNCTION */
515 vTaskDelay( xTicksToDelay );
518 #endif /* if ( INCLUDE_vTaskDelay == 1 ) */
519 /*-----------------------------------------------------------*/
521 #if ( INCLUDE_uxTaskPriorityGet == 1 )
523 UBaseType_t MPU_uxTaskPriorityGetImpl( const TaskHandle_t pxTask ) PRIVILEGED_FUNCTION;
525 UBaseType_t MPU_uxTaskPriorityGetImpl( const TaskHandle_t pxTask ) /* PRIVILEGED_FUNCTION */
527 UBaseType_t uxReturn = configMAX_PRIORITIES;
528 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
530 TaskHandle_t xInternalTaskHandle = NULL;
534 uxReturn = uxTaskPriorityGet( pxTask );
538 lIndex = ( int32_t ) pxTask;
540 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
542 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
544 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
546 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
548 if( xInternalTaskHandle != NULL )
550 uxReturn = uxTaskPriorityGet( xInternalTaskHandle );
559 #endif /* if ( INCLUDE_uxTaskPriorityGet == 1 ) */
560 /*-----------------------------------------------------------*/
562 #if ( INCLUDE_eTaskGetState == 1 )
564 eTaskState MPU_eTaskGetStateImpl( TaskHandle_t pxTask ) PRIVILEGED_FUNCTION;
566 eTaskState MPU_eTaskGetStateImpl( TaskHandle_t pxTask ) /* PRIVILEGED_FUNCTION */
568 eTaskState eReturn = eInvalid;
569 TaskHandle_t xInternalTaskHandle = NULL;
571 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
573 lIndex = ( int32_t ) pxTask;
575 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
577 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
579 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
581 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
583 if( xInternalTaskHandle != NULL )
585 eReturn = eTaskGetState( xInternalTaskHandle );
593 #endif /* if ( INCLUDE_eTaskGetState == 1 ) */
594 /*-----------------------------------------------------------*/
596 #if ( configUSE_TRACE_FACILITY == 1 )
598 void MPU_vTaskGetInfoImpl( TaskHandle_t xTask,
599 TaskStatus_t * pxTaskStatus,
600 BaseType_t xGetFreeStackSpace,
601 eTaskState eState ) PRIVILEGED_FUNCTION;
603 void MPU_vTaskGetInfoImpl( TaskHandle_t xTask,
604 TaskStatus_t * pxTaskStatus,
605 BaseType_t xGetFreeStackSpace,
606 eTaskState eState ) /* PRIVILEGED_FUNCTION */
609 TaskHandle_t xInternalTaskHandle = NULL;
610 BaseType_t xIsTaskStatusWriteable = pdFALSE;
611 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
613 xIsTaskStatusWriteable = xPortIsAuthorizedToAccessBuffer( pxTaskStatus,
614 sizeof( TaskStatus_t ),
615 tskMPU_WRITE_PERMISSION );
617 if( xIsTaskStatusWriteable == pdTRUE )
621 vTaskGetInfo( xTask, pxTaskStatus, xGetFreeStackSpace, eState );
625 lIndex = ( int32_t ) xTask;
627 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
629 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
631 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
633 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
635 if( xInternalTaskHandle != NULL )
637 vTaskGetInfo( xInternalTaskHandle, pxTaskStatus, xGetFreeStackSpace, eState );
645 #endif /* if ( configUSE_TRACE_FACILITY == 1 ) */
646 /*-----------------------------------------------------------*/
648 #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
650 TaskHandle_t MPU_xTaskGetIdleTaskHandleImpl( void ) PRIVILEGED_FUNCTION;
652 TaskHandle_t MPU_xTaskGetIdleTaskHandleImpl( void ) /* PRIVILEGED_FUNCTION */
654 TaskHandle_t xIdleTaskHandle = NULL;
656 xIdleTaskHandle = xTaskGetIdleTaskHandle();
658 return xIdleTaskHandle;
661 #endif /* if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) */
662 /*-----------------------------------------------------------*/
664 #if ( INCLUDE_vTaskSuspend == 1 )
666 void MPU_vTaskSuspendImpl( TaskHandle_t pxTaskToSuspend ) PRIVILEGED_FUNCTION;
668 void MPU_vTaskSuspendImpl( TaskHandle_t pxTaskToSuspend ) /* PRIVILEGED_FUNCTION */
671 TaskHandle_t xInternalTaskHandle = NULL;
672 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
674 if( pxTaskToSuspend == NULL )
676 vTaskSuspend( pxTaskToSuspend );
680 /* After the scheduler starts, only privileged tasks are allowed
681 * to suspend other tasks. */
682 #if ( INCLUDE_xTaskGetSchedulerState == 1 )
683 if( ( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED ) || ( portIS_TASK_PRIVILEGED() == pdTRUE ) )
685 if( portIS_TASK_PRIVILEGED() == pdTRUE )
688 lIndex = ( int32_t ) pxTaskToSuspend;
690 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
692 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
694 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
696 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
698 if( xInternalTaskHandle != NULL )
700 vTaskSuspend( xInternalTaskHandle );
708 #endif /* if ( INCLUDE_vTaskSuspend == 1 ) */
709 /*-----------------------------------------------------------*/
711 #if ( INCLUDE_vTaskSuspend == 1 )
713 void MPU_vTaskResumeImpl( TaskHandle_t pxTaskToResume ) PRIVILEGED_FUNCTION;
715 void MPU_vTaskResumeImpl( TaskHandle_t pxTaskToResume ) /* PRIVILEGED_FUNCTION */
718 TaskHandle_t xInternalTaskHandle = NULL;
719 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
721 lIndex = ( int32_t ) pxTaskToResume;
723 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
725 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
727 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
729 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
731 if( xInternalTaskHandle != NULL )
733 vTaskResume( xInternalTaskHandle );
739 #endif /* if ( INCLUDE_vTaskSuspend == 1 ) */
740 /*-----------------------------------------------------------*/
742 TickType_t MPU_xTaskGetTickCountImpl( void ) PRIVILEGED_FUNCTION;
744 TickType_t MPU_xTaskGetTickCountImpl( void ) /* PRIVILEGED_FUNCTION */
748 xReturn = xTaskGetTickCount();
752 /*-----------------------------------------------------------*/
754 UBaseType_t MPU_uxTaskGetNumberOfTasksImpl( void ) PRIVILEGED_FUNCTION;
756 UBaseType_t MPU_uxTaskGetNumberOfTasksImpl( void ) /* PRIVILEGED_FUNCTION */
758 UBaseType_t uxReturn;
760 uxReturn = uxTaskGetNumberOfTasks();
764 /*-----------------------------------------------------------*/
766 #if ( configGENERATE_RUN_TIME_STATS == 1 )
768 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetRunTimeCounterImpl( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
770 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetRunTimeCounterImpl( const TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
772 configRUN_TIME_COUNTER_TYPE xReturn = 0;
774 TaskHandle_t xInternalTaskHandle = NULL;
775 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
779 xReturn = ulTaskGetRunTimeCounter( xTask );
783 lIndex = ( int32_t ) xTask;
785 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
787 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
789 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
791 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
793 if( xInternalTaskHandle != NULL )
795 xReturn = ulTaskGetRunTimeCounter( xInternalTaskHandle );
804 #endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) */
805 /*-----------------------------------------------------------*/
807 #if ( configGENERATE_RUN_TIME_STATS == 1 )
809 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetRunTimePercentImpl( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
811 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetRunTimePercentImpl( const TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
813 configRUN_TIME_COUNTER_TYPE xReturn = 0;
815 TaskHandle_t xInternalTaskHandle = NULL;
816 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
820 xReturn = ulTaskGetRunTimePercent( xTask );
824 lIndex = ( int32_t ) xTask;
826 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
828 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
830 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
832 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
834 if( xInternalTaskHandle != NULL )
836 xReturn = ulTaskGetRunTimePercent( xInternalTaskHandle );
845 #endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) */
846 /*-----------------------------------------------------------*/
848 #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) )
850 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimePercentImpl( void ) PRIVILEGED_FUNCTION;
852 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimePercentImpl( void ) /* PRIVILEGED_FUNCTION */
854 configRUN_TIME_COUNTER_TYPE xReturn;
856 xReturn = ulTaskGetIdleRunTimePercent();
861 #endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) */
862 /*-----------------------------------------------------------*/
864 #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) )
866 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimeCounterImpl( void ) PRIVILEGED_FUNCTION;
868 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimeCounterImpl( void ) /* PRIVILEGED_FUNCTION */
870 configRUN_TIME_COUNTER_TYPE xReturn;
872 xReturn = ulTaskGetIdleRunTimeCounter();
877 #endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) */
878 /*-----------------------------------------------------------*/
880 #if ( configUSE_APPLICATION_TASK_TAG == 1 )
882 void MPU_vTaskSetApplicationTaskTagImpl( TaskHandle_t xTask,
883 TaskHookFunction_t pxTagValue ) PRIVILEGED_FUNCTION;
885 void MPU_vTaskSetApplicationTaskTagImpl( TaskHandle_t xTask,
886 TaskHookFunction_t pxTagValue ) /* PRIVILEGED_FUNCTION */
888 TaskHandle_t xInternalTaskHandle = NULL;
890 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
894 vTaskSetApplicationTaskTag( xTask, pxTagValue );
898 lIndex = ( int32_t ) xTask;
900 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
902 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
904 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
906 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
908 if( xInternalTaskHandle != NULL )
910 vTaskSetApplicationTaskTag( xInternalTaskHandle, pxTagValue );
917 #endif /* if ( configUSE_APPLICATION_TASK_TAG == 1 ) */
918 /*-----------------------------------------------------------*/
920 #if ( configUSE_APPLICATION_TASK_TAG == 1 )
922 TaskHookFunction_t MPU_xTaskGetApplicationTaskTagImpl( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
924 TaskHookFunction_t MPU_xTaskGetApplicationTaskTagImpl( TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
926 TaskHookFunction_t xReturn = NULL;
928 TaskHandle_t xInternalTaskHandle = NULL;
929 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
933 xReturn = xTaskGetApplicationTaskTag( xTask );
937 lIndex = ( int32_t ) xTask;
939 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
941 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
943 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
945 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
947 if( xInternalTaskHandle != NULL )
949 xReturn = xTaskGetApplicationTaskTag( xInternalTaskHandle );
958 #endif /* if ( configUSE_APPLICATION_TASK_TAG == 1 ) */
959 /*-----------------------------------------------------------*/
961 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
963 void MPU_vTaskSetThreadLocalStoragePointerImpl( TaskHandle_t xTaskToSet,
965 void * pvValue ) PRIVILEGED_FUNCTION;
967 void MPU_vTaskSetThreadLocalStoragePointerImpl( TaskHandle_t xTaskToSet,
969 void * pvValue ) /* PRIVILEGED_FUNCTION */
972 TaskHandle_t xInternalTaskHandle = NULL;
973 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
975 if( xTaskToSet == NULL )
977 vTaskSetThreadLocalStoragePointer( xTaskToSet, xIndex, pvValue );
981 lIndex = ( int32_t ) xTaskToSet;
983 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
985 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
987 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
989 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
991 if( xInternalTaskHandle != NULL )
993 vTaskSetThreadLocalStoragePointer( xInternalTaskHandle, xIndex, pvValue );
1000 #endif /* if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) */
1001 /*-----------------------------------------------------------*/
1003 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
1005 void * MPU_pvTaskGetThreadLocalStoragePointerImpl( TaskHandle_t xTaskToQuery,
1006 BaseType_t xIndex ) PRIVILEGED_FUNCTION;
1008 void * MPU_pvTaskGetThreadLocalStoragePointerImpl( TaskHandle_t xTaskToQuery,
1009 BaseType_t xIndex ) /* PRIVILEGED_FUNCTION */
1011 void * pvReturn = NULL;
1013 TaskHandle_t xInternalTaskHandle = NULL;
1014 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
1016 if( xTaskToQuery == NULL )
1018 pvReturn = pvTaskGetThreadLocalStoragePointer( xTaskToQuery, xIndex );
1022 lIndex = ( int32_t ) xTaskToQuery;
1024 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1026 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1028 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
1030 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1032 if( xInternalTaskHandle != NULL )
1034 pvReturn = pvTaskGetThreadLocalStoragePointer( xInternalTaskHandle, xIndex );
1043 #endif /* if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) */
1044 /*-----------------------------------------------------------*/
1046 #if ( configUSE_TRACE_FACILITY == 1 )
1048 UBaseType_t MPU_uxTaskGetSystemStateImpl( TaskStatus_t * pxTaskStatusArray,
1049 UBaseType_t uxArraySize,
1050 configRUN_TIME_COUNTER_TYPE * pulTotalRunTime ) PRIVILEGED_FUNCTION;
1052 UBaseType_t MPU_uxTaskGetSystemStateImpl( TaskStatus_t * pxTaskStatusArray,
1053 UBaseType_t uxArraySize,
1054 configRUN_TIME_COUNTER_TYPE * pulTotalRunTime ) /* PRIVILEGED_FUNCTION */
1056 UBaseType_t uxReturn = 0;
1057 UBaseType_t xIsTaskStatusArrayWriteable = pdFALSE;
1058 UBaseType_t xIsTotalRunTimeWriteable = pdFALSE;
1059 uint32_t ulArraySize = ( uint32_t ) uxArraySize;
1060 uint32_t ulTaskStatusSize = ( uint32_t ) sizeof( TaskStatus_t );
1062 if( mpuMULTIPLY_UINT32_WILL_OVERFLOW( ulTaskStatusSize, ulArraySize ) == 0 )
1064 xIsTaskStatusArrayWriteable = xPortIsAuthorizedToAccessBuffer( pxTaskStatusArray,
1065 ulTaskStatusSize * ulArraySize,
1066 tskMPU_WRITE_PERMISSION );
1068 if( pulTotalRunTime != NULL )
1070 xIsTotalRunTimeWriteable = xPortIsAuthorizedToAccessBuffer( pulTotalRunTime,
1071 sizeof( configRUN_TIME_COUNTER_TYPE ),
1072 tskMPU_WRITE_PERMISSION );
1075 if( ( xIsTaskStatusArrayWriteable == pdTRUE ) &&
1076 ( ( pulTotalRunTime == NULL ) || ( xIsTotalRunTimeWriteable == pdTRUE ) ) )
1078 uxReturn = uxTaskGetSystemState( pxTaskStatusArray, ( UBaseType_t ) ulArraySize, pulTotalRunTime );
1085 #endif /* if ( configUSE_TRACE_FACILITY == 1 ) */
1086 /*-----------------------------------------------------------*/
1088 #if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )
1090 UBaseType_t MPU_uxTaskGetStackHighWaterMarkImpl( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1092 UBaseType_t MPU_uxTaskGetStackHighWaterMarkImpl( TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
1094 UBaseType_t uxReturn = 0;
1096 TaskHandle_t xInternalTaskHandle = NULL;
1097 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
1101 uxReturn = uxTaskGetStackHighWaterMark( xTask );
1105 lIndex = ( int32_t ) xTask;
1107 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1109 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1111 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
1113 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1115 if( xInternalTaskHandle != NULL )
1117 uxReturn = uxTaskGetStackHighWaterMark( xInternalTaskHandle );
1126 #endif /* if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) */
1127 /*-----------------------------------------------------------*/
1129 #if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 )
1131 configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2Impl( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
1133 configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2Impl( TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
1135 configSTACK_DEPTH_TYPE uxReturn = 0;
1137 TaskHandle_t xInternalTaskHandle = NULL;
1138 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
1142 uxReturn = uxTaskGetStackHighWaterMark2( xTask );
1146 lIndex = ( int32_t ) xTask;
1148 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1150 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1152 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
1154 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1156 if( xInternalTaskHandle != NULL )
1158 uxReturn = uxTaskGetStackHighWaterMark2( xInternalTaskHandle );
1167 #endif /* if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) */
1168 /*-----------------------------------------------------------*/
1170 #if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) )
1172 TaskHandle_t MPU_xTaskGetCurrentTaskHandleImpl( void ) PRIVILEGED_FUNCTION;
1174 TaskHandle_t MPU_xTaskGetCurrentTaskHandleImpl( void ) /* PRIVILEGED_FUNCTION */
1176 TaskHandle_t xInternalTaskHandle = NULL;
1177 TaskHandle_t xExternalTaskHandle = NULL;
1180 xInternalTaskHandle = xTaskGetCurrentTaskHandle();
1182 if( xInternalTaskHandle != NULL )
1184 lIndex = MPU_GetIndexForTaskHandle( xInternalTaskHandle );
1188 xExternalTaskHandle = ( TaskHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
1192 return xExternalTaskHandle;
1195 #endif /* if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) ) */
1196 /*-----------------------------------------------------------*/
1198 #if ( INCLUDE_xTaskGetSchedulerState == 1 )
1200 BaseType_t MPU_xTaskGetSchedulerStateImpl( void ) PRIVILEGED_FUNCTION;
1202 BaseType_t MPU_xTaskGetSchedulerStateImpl( void ) /* PRIVILEGED_FUNCTION */
1204 BaseType_t xReturn = taskSCHEDULER_NOT_STARTED;
1206 xReturn = xTaskGetSchedulerState();
1211 #endif /* if ( INCLUDE_xTaskGetSchedulerState == 1 ) */
1212 /*-----------------------------------------------------------*/
1214 void MPU_vTaskSetTimeOutStateImpl( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
1216 void MPU_vTaskSetTimeOutStateImpl( TimeOut_t * const pxTimeOut ) /* PRIVILEGED_FUNCTION */
1218 BaseType_t xIsTimeOutWriteable = pdFALSE;
1220 if( pxTimeOut != NULL )
1222 xIsTimeOutWriteable = xPortIsAuthorizedToAccessBuffer( pxTimeOut,
1223 sizeof( TimeOut_t ),
1224 tskMPU_WRITE_PERMISSION );
1226 if( xIsTimeOutWriteable == pdTRUE )
1228 vTaskSetTimeOutState( pxTimeOut );
1232 /*-----------------------------------------------------------*/
1234 BaseType_t MPU_xTaskCheckForTimeOutImpl( TimeOut_t * const pxTimeOut,
1235 TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION;
1237 BaseType_t MPU_xTaskCheckForTimeOutImpl( TimeOut_t * const pxTimeOut,
1238 TickType_t * const pxTicksToWait ) /* PRIVILEGED_FUNCTION */
1240 BaseType_t xReturn = pdFALSE;
1241 BaseType_t xIsTimeOutWriteable = pdFALSE;
1242 BaseType_t xIsTicksToWaitWriteable = pdFALSE;
1244 if( ( pxTimeOut != NULL ) && ( pxTicksToWait != NULL ) )
1246 xIsTimeOutWriteable = xPortIsAuthorizedToAccessBuffer( pxTimeOut,
1247 sizeof( TimeOut_t ),
1248 tskMPU_WRITE_PERMISSION );
1249 xIsTicksToWaitWriteable = xPortIsAuthorizedToAccessBuffer( pxTicksToWait,
1250 sizeof( TickType_t ),
1251 tskMPU_WRITE_PERMISSION );
1253 if( ( xIsTimeOutWriteable == pdTRUE ) && ( xIsTicksToWaitWriteable == pdTRUE ) )
1255 xReturn = xTaskCheckForTimeOut( pxTimeOut, pxTicksToWait );
1261 /*-----------------------------------------------------------*/
1263 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
1265 BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify,
1266 UBaseType_t uxIndexToNotify,
1268 eNotifyAction eAction,
1269 uint32_t * pulPreviousNotificationValue ) /* FREERTOS_SYSTEM_CALL */
1271 BaseType_t xReturn = pdFAIL;
1272 xTaskGenericNotifyParams_t xParams;
1274 xParams.xTaskToNotify = xTaskToNotify;
1275 xParams.uxIndexToNotify = uxIndexToNotify;
1276 xParams.ulValue = ulValue;
1277 xParams.eAction = eAction;
1278 xParams.pulPreviousNotificationValue = pulPreviousNotificationValue;
1280 xReturn = MPU_xTaskGenericNotifyEntry( &( xParams ) );
1285 BaseType_t MPU_xTaskGenericNotifyImpl( const xTaskGenericNotifyParams_t * pxParams ) PRIVILEGED_FUNCTION;
1287 BaseType_t MPU_xTaskGenericNotifyImpl( const xTaskGenericNotifyParams_t * pxParams ) /* PRIVILEGED_FUNCTION */
1289 BaseType_t xReturn = pdFAIL;
1291 TaskHandle_t xInternalTaskHandle = NULL;
1292 BaseType_t xIsPreviousNotificationValueWriteable = pdFALSE;
1293 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
1294 BaseType_t xAreParamsReadable = pdFALSE;
1296 if( pxParams != NULL )
1298 xAreParamsReadable = xPortIsAuthorizedToAccessBuffer( pxParams,
1299 sizeof( xTaskGenericNotifyParams_t ),
1300 tskMPU_READ_PERMISSION );
1303 if( xAreParamsReadable == pdTRUE )
1305 if( ( pxParams->uxIndexToNotify < configTASK_NOTIFICATION_ARRAY_ENTRIES ) &&
1306 ( ( pxParams->eAction == eNoAction ) ||
1307 ( pxParams->eAction == eSetBits ) ||
1308 ( pxParams->eAction == eIncrement ) ||
1309 ( pxParams->eAction == eSetValueWithOverwrite ) ||
1310 ( pxParams->eAction == eSetValueWithoutOverwrite ) ) )
1312 if( pxParams->pulPreviousNotificationValue != NULL )
1314 xIsPreviousNotificationValueWriteable = xPortIsAuthorizedToAccessBuffer( pxParams->pulPreviousNotificationValue,
1316 tskMPU_WRITE_PERMISSION );
1319 if( ( pxParams->pulPreviousNotificationValue == NULL ) ||
1320 ( xIsPreviousNotificationValueWriteable == pdTRUE ) )
1322 lIndex = ( int32_t ) ( pxParams->xTaskToNotify );
1324 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1326 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1328 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
1330 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1332 if( xInternalTaskHandle != NULL )
1334 xReturn = xTaskGenericNotify( xInternalTaskHandle,
1335 pxParams->uxIndexToNotify,
1338 pxParams->pulPreviousNotificationValue );
1349 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
1350 /*-----------------------------------------------------------*/
1352 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
1354 BaseType_t MPU_xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn,
1355 uint32_t ulBitsToClearOnEntry,
1356 uint32_t ulBitsToClearOnExit,
1357 uint32_t * pulNotificationValue,
1358 TickType_t xTicksToWait )
1360 BaseType_t xReturn = pdFAIL;
1361 xTaskGenericNotifyWaitParams_t xParams;
1363 xParams.uxIndexToWaitOn = uxIndexToWaitOn;
1364 xParams.ulBitsToClearOnEntry = ulBitsToClearOnEntry;
1365 xParams.ulBitsToClearOnExit = ulBitsToClearOnExit;
1366 xParams.pulNotificationValue = pulNotificationValue;
1367 xParams.xTicksToWait = xTicksToWait;
1369 xReturn = MPU_xTaskGenericNotifyWaitEntry( &( xParams ) );
1374 BaseType_t MPU_xTaskGenericNotifyWaitImpl( const xTaskGenericNotifyWaitParams_t * pxParams ) PRIVILEGED_FUNCTION;
1376 BaseType_t MPU_xTaskGenericNotifyWaitImpl( const xTaskGenericNotifyWaitParams_t * pxParams ) /* PRIVILEGED_FUNCTION */
1378 BaseType_t xReturn = pdFAIL;
1379 BaseType_t xIsNotificationValueWritable = pdFALSE;
1380 BaseType_t xAreParamsReadable = pdFALSE;
1382 if( pxParams != NULL )
1384 xAreParamsReadable = xPortIsAuthorizedToAccessBuffer( pxParams,
1385 sizeof( xTaskGenericNotifyWaitParams_t ),
1386 tskMPU_READ_PERMISSION );
1389 if( xAreParamsReadable == pdTRUE )
1391 if( pxParams->uxIndexToWaitOn < configTASK_NOTIFICATION_ARRAY_ENTRIES )
1393 if( pxParams->pulNotificationValue != NULL )
1395 xIsNotificationValueWritable = xPortIsAuthorizedToAccessBuffer( pxParams->pulNotificationValue,
1397 tskMPU_WRITE_PERMISSION );
1400 if( ( pxParams->pulNotificationValue == NULL ) ||
1401 ( xIsNotificationValueWritable == pdTRUE ) )
1403 xReturn = xTaskGenericNotifyWait( pxParams->uxIndexToWaitOn,
1404 pxParams->ulBitsToClearOnEntry,
1405 pxParams->ulBitsToClearOnExit,
1406 pxParams->pulNotificationValue,
1407 pxParams->xTicksToWait );
1415 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
1416 /*-----------------------------------------------------------*/
1418 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
1420 uint32_t MPU_ulTaskGenericNotifyTakeImpl( UBaseType_t uxIndexToWaitOn,
1421 BaseType_t xClearCountOnExit,
1422 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
1424 uint32_t MPU_ulTaskGenericNotifyTakeImpl( UBaseType_t uxIndexToWaitOn,
1425 BaseType_t xClearCountOnExit,
1426 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
1428 uint32_t ulReturn = 0;
1430 if( uxIndexToWaitOn < configTASK_NOTIFICATION_ARRAY_ENTRIES )
1432 ulReturn = ulTaskGenericNotifyTake( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait );
1438 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
1439 /*-----------------------------------------------------------*/
1441 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
1443 BaseType_t MPU_xTaskGenericNotifyStateClearImpl( TaskHandle_t xTask,
1444 UBaseType_t uxIndexToClear ) PRIVILEGED_FUNCTION;
1446 BaseType_t MPU_xTaskGenericNotifyStateClearImpl( TaskHandle_t xTask,
1447 UBaseType_t uxIndexToClear ) /* PRIVILEGED_FUNCTION */
1449 BaseType_t xReturn = pdFAIL;
1451 TaskHandle_t xInternalTaskHandle = NULL;
1452 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
1454 if( uxIndexToClear < configTASK_NOTIFICATION_ARRAY_ENTRIES )
1458 xReturn = xTaskGenericNotifyStateClear( xTask, uxIndexToClear );
1462 lIndex = ( int32_t ) xTask;
1464 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1466 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1468 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
1470 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1472 if( xInternalTaskHandle != NULL )
1474 xReturn = xTaskGenericNotifyStateClear( xInternalTaskHandle, uxIndexToClear );
1484 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
1485 /*-----------------------------------------------------------*/
1487 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
1489 uint32_t MPU_ulTaskGenericNotifyValueClearImpl( TaskHandle_t xTask,
1490 UBaseType_t uxIndexToClear,
1491 uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;
1493 uint32_t MPU_ulTaskGenericNotifyValueClearImpl( TaskHandle_t xTask,
1494 UBaseType_t uxIndexToClear,
1495 uint32_t ulBitsToClear ) /* PRIVILEGED_FUNCTION */
1497 uint32_t ulReturn = 0;
1499 TaskHandle_t xInternalTaskHandle = NULL;
1500 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE;
1502 if( uxIndexToClear < configTASK_NOTIFICATION_ARRAY_ENTRIES )
1506 ulReturn = ulTaskGenericNotifyValueClear( xTask, uxIndexToClear, ulBitsToClear );
1510 lIndex = ( int32_t ) xTask;
1512 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1514 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1516 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE )
1518 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1520 if( xInternalTaskHandle != NULL )
1522 ulReturn = ulTaskGenericNotifyValueClear( xInternalTaskHandle, uxIndexToClear, ulBitsToClear );
1532 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
1533 /*-----------------------------------------------------------*/
1535 /* Privileged only wrappers for Task APIs. These are needed so that
1536 * the application can use opaque handles maintained in mpu_wrappers.c
1537 * with all the APIs. */
1538 /*-----------------------------------------------------------*/
1540 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
1542 BaseType_t MPU_xTaskCreate( TaskFunction_t pvTaskCode,
1543 const char * const pcName,
1544 uint16_t usStackDepth,
1545 void * pvParameters,
1546 UBaseType_t uxPriority,
1547 TaskHandle_t * pxCreatedTask ) /* PRIVILEGED_FUNCTION */
1549 BaseType_t xReturn = pdFAIL;
1551 TaskHandle_t xInternalTaskHandle = NULL;
1553 lIndex = MPU_GetFreeIndexInKernelObjectPool();
1557 /* xTaskCreate() can only be used to create privileged tasks in MPU port. */
1558 if( ( uxPriority & portPRIVILEGE_BIT ) != 0 )
1560 xReturn = xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, &( xInternalTaskHandle ) );
1562 if( ( xReturn == pdPASS ) && ( xInternalTaskHandle != NULL ) )
1564 MPU_StoreTaskHandleAtIndex( lIndex, xInternalTaskHandle );
1566 if( pxCreatedTask != NULL )
1568 *pxCreatedTask = ( TaskHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
1573 MPU_SetIndexFreeInKernelObjectPool( lIndex );
1581 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
1582 /*-----------------------------------------------------------*/
1584 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1586 TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode,
1587 const char * const pcName,
1588 const uint32_t ulStackDepth,
1589 void * const pvParameters,
1590 UBaseType_t uxPriority,
1591 StackType_t * const puxStackBuffer,
1592 StaticTask_t * const pxTaskBuffer ) /* PRIVILEGED_FUNCTION */
1594 TaskHandle_t xExternalTaskHandle = NULL;
1595 TaskHandle_t xInternalTaskHandle = NULL;
1598 lIndex = MPU_GetFreeIndexInKernelObjectPool();
1602 xInternalTaskHandle = xTaskCreateStatic( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer );
1604 if( xInternalTaskHandle != NULL )
1606 MPU_StoreTaskHandleAtIndex( lIndex, xInternalTaskHandle );
1608 #if ( configENABLE_ACCESS_CONTROL_LIST == 1 )
1610 /* By default, an unprivileged task has access to itself. */
1611 if( ( uxPriority & portPRIVILEGE_BIT ) == 0 )
1613 vPortGrantAccessToKernelObject( xInternalTaskHandle, lIndex );
1618 xExternalTaskHandle = ( TaskHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
1622 MPU_SetIndexFreeInKernelObjectPool( lIndex );
1626 return xExternalTaskHandle;
1629 #endif /* configSUPPORT_STATIC_ALLOCATION */
1630 /*-----------------------------------------------------------*/
1632 #if ( INCLUDE_vTaskDelete == 1 )
1634 void MPU_vTaskDelete( TaskHandle_t pxTaskToDelete ) /* PRIVILEGED_FUNCTION */
1636 TaskHandle_t xInternalTaskHandle = NULL;
1639 if( pxTaskToDelete == NULL )
1641 xInternalTaskHandle = xTaskGetCurrentTaskHandle();
1642 lIndex = MPU_GetIndexForTaskHandle( xInternalTaskHandle );
1646 MPU_SetIndexFreeInKernelObjectPool( lIndex );
1649 vTaskDelete( xInternalTaskHandle );
1653 lIndex = ( int32_t ) pxTaskToDelete;
1655 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1657 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1659 if( xInternalTaskHandle != NULL )
1661 MPU_SetIndexFreeInKernelObjectPool( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1662 vTaskDelete( xInternalTaskHandle );
1668 #endif /* #if ( INCLUDE_vTaskDelete == 1 ) */
1669 /*-----------------------------------------------------------*/
1672 #if ( INCLUDE_vTaskPrioritySet == 1 )
1674 void MPU_vTaskPrioritySet( TaskHandle_t pxTask,
1675 UBaseType_t uxNewPriority ) /* PRIVILEGED_FUNCTION */
1677 TaskHandle_t xInternalTaskHandle = NULL;
1680 if( pxTask == NULL )
1682 vTaskPrioritySet( pxTask, uxNewPriority );
1686 lIndex = ( int32_t ) pxTask;
1688 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1690 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1692 if( xInternalTaskHandle != NULL )
1694 vTaskPrioritySet( xInternalTaskHandle, uxNewPriority );
1700 #endif /* if ( INCLUDE_vTaskPrioritySet == 1 ) */
1701 /*-----------------------------------------------------------*/
1703 #if ( INCLUDE_xTaskGetHandle == 1 )
1705 TaskHandle_t MPU_xTaskGetHandle( const char * pcNameToQuery ) /* PRIVILEGED_FUNCTION */
1707 TaskHandle_t xInternalTaskHandle = NULL;
1708 TaskHandle_t xExternalTaskHandle = NULL;
1711 xInternalTaskHandle = xTaskGetHandle( pcNameToQuery );
1713 if( xInternalTaskHandle != NULL )
1715 lIndex = MPU_GetIndexForTaskHandle( xInternalTaskHandle );
1719 xExternalTaskHandle = ( TaskHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
1723 return xExternalTaskHandle;
1726 #endif /* if ( INCLUDE_xTaskGetHandle == 1 ) */
1727 /*-----------------------------------------------------------*/
1730 #if ( configUSE_APPLICATION_TASK_TAG == 1 )
1732 BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask,
1733 void * pvParameter ) /* PRIVILEGED_FUNCTION */
1735 BaseType_t xReturn = pdFAIL;
1737 TaskHandle_t xInternalTaskHandle = NULL;
1741 xReturn = xTaskCallApplicationTaskHook( xTask, pvParameter );
1745 lIndex = ( int32_t ) xTask;
1747 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1749 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1751 if( xInternalTaskHandle != NULL )
1753 xReturn = xTaskCallApplicationTaskHook( xInternalTaskHandle, pvParameter );
1761 #endif /* if ( configUSE_APPLICATION_TASK_TAG == 1 ) */
1762 /*-----------------------------------------------------------*/
1764 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
1766 BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition,
1767 TaskHandle_t * pxCreatedTask ) /* PRIVILEGED_FUNCTION */
1769 BaseType_t xReturn = pdFAIL;
1771 TaskHandle_t xInternalTaskHandle = NULL;
1773 lIndex = MPU_GetFreeIndexInKernelObjectPool();
1777 xReturn = xTaskCreateRestricted( pxTaskDefinition, &( xInternalTaskHandle ) );
1779 if( ( xReturn == pdPASS ) && ( xInternalTaskHandle != NULL ) )
1781 MPU_StoreTaskHandleAtIndex( lIndex, xInternalTaskHandle );
1783 #if ( configENABLE_ACCESS_CONTROL_LIST == 1 )
1785 /* By default, an unprivileged task has access to itself. */
1786 if( ( pxTaskDefinition->uxPriority & portPRIVILEGE_BIT ) == 0 )
1788 vPortGrantAccessToKernelObject( xInternalTaskHandle, lIndex );
1793 if( pxCreatedTask != NULL )
1795 *pxCreatedTask = ( TaskHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
1800 MPU_SetIndexFreeInKernelObjectPool( lIndex );
1807 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
1808 /*-----------------------------------------------------------*/
1810 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1812 BaseType_t MPU_xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition,
1813 TaskHandle_t * pxCreatedTask ) /* PRIVILEGED_FUNCTION */
1815 BaseType_t xReturn = pdFAIL;
1817 TaskHandle_t xInternalTaskHandle = NULL;
1819 lIndex = MPU_GetFreeIndexInKernelObjectPool();
1823 xReturn = xTaskCreateRestrictedStatic( pxTaskDefinition, &( xInternalTaskHandle ) );
1825 if( ( xReturn == pdPASS ) && ( xInternalTaskHandle != NULL ) )
1827 MPU_StoreTaskHandleAtIndex( lIndex, xInternalTaskHandle );
1829 #if ( configENABLE_ACCESS_CONTROL_LIST == 1 )
1831 /* By default, an unprivileged task has access to itself. */
1832 if( ( pxTaskDefinition->uxPriority & portPRIVILEGE_BIT ) == 0 )
1834 vPortGrantAccessToKernelObject( xInternalTaskHandle, lIndex );
1839 if( pxCreatedTask != NULL )
1841 *pxCreatedTask = ( TaskHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
1846 MPU_SetIndexFreeInKernelObjectPool( lIndex );
1853 #endif /* configSUPPORT_STATIC_ALLOCATION */
1854 /*-----------------------------------------------------------*/
1856 void MPU_vTaskAllocateMPURegions( TaskHandle_t xTaskToModify,
1857 const MemoryRegion_t * const xRegions ) /* PRIVILEGED_FUNCTION */
1859 TaskHandle_t xInternalTaskHandle = NULL;
1862 if( xTaskToModify == NULL )
1864 vTaskAllocateMPURegions( xTaskToModify, xRegions );
1868 lIndex = ( int32_t ) xTaskToModify;
1870 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1872 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1874 if( xInternalTaskHandle != NULL )
1876 vTaskAllocateMPURegions( xInternalTaskHandle, xRegions );
1881 /*-----------------------------------------------------------*/
1883 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
1885 BaseType_t MPU_xTaskGetStaticBuffers( TaskHandle_t xTask,
1886 StackType_t ** ppuxStackBuffer,
1887 StaticTask_t ** ppxTaskBuffer ) /* PRIVILEGED_FUNCTION */
1889 TaskHandle_t xInternalTaskHandle = NULL;
1891 BaseType_t xReturn = pdFALSE;
1895 xInternalTaskHandle = xTaskGetCurrentTaskHandle();
1896 xReturn = xTaskGetStaticBuffers( xInternalTaskHandle, ppuxStackBuffer, ppxTaskBuffer );
1900 lIndex = ( int32_t ) xTask;
1902 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1904 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1906 if( xInternalTaskHandle != NULL )
1908 xReturn = xTaskGetStaticBuffers( xInternalTaskHandle, ppuxStackBuffer, ppxTaskBuffer );
1916 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
1917 /*-----------------------------------------------------------*/
1919 char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) /* PRIVILEGED_FUNCTION */
1921 char * pcReturn = NULL;
1923 TaskHandle_t xInternalTaskHandle = NULL;
1925 if( xTaskToQuery == NULL )
1927 pcReturn = pcTaskGetName( xTaskToQuery );
1931 lIndex = ( int32_t ) xTaskToQuery;
1933 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1935 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1937 if( xInternalTaskHandle != NULL )
1939 pcReturn = pcTaskGetName( xInternalTaskHandle );
1946 /*-----------------------------------------------------------*/
1948 #if ( INCLUDE_uxTaskPriorityGet == 1 )
1950 UBaseType_t MPU_uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
1952 UBaseType_t uxReturn = configMAX_PRIORITIES;
1954 TaskHandle_t xInternalTaskHandle = NULL;
1958 uxReturn = uxTaskPriorityGetFromISR( xTask );
1962 lIndex = ( int32_t ) xTask;
1964 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1966 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
1968 if( xInternalTaskHandle != NULL )
1970 uxReturn = uxTaskPriorityGetFromISR( xInternalTaskHandle );
1978 #endif /* #if ( INCLUDE_uxTaskPriorityGet == 1 ) */
1979 /*-----------------------------------------------------------*/
1981 #if ( ( INCLUDE_uxTaskPriorityGet == 1 ) && ( configUSE_MUTEXES == 1 ) )
1983 UBaseType_t MPU_uxTaskBasePriorityGet( const TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
1985 UBaseType_t uxReturn = configMAX_PRIORITIES;
1987 TaskHandle_t xInternalTaskHandle = NULL;
1991 uxReturn = uxTaskBasePriorityGet( xTask );
1995 lIndex = ( int32_t ) xTask;
1997 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
1999 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2001 if( xInternalTaskHandle != NULL )
2003 uxReturn = uxTaskBasePriorityGet( xInternalTaskHandle );
2011 #endif /* #if ( ( INCLUDE_uxTaskPriorityGet == 1 ) && ( configUSE_MUTEXES == 1 ) ) */
2012 /*-----------------------------------------------------------*/
2014 #if ( ( INCLUDE_uxTaskPriorityGet == 1 ) && ( configUSE_MUTEXES == 1 ) )
2016 UBaseType_t MPU_uxTaskBasePriorityGetFromISR( const TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
2018 UBaseType_t uxReturn = configMAX_PRIORITIES;
2020 TaskHandle_t xInternalTaskHandle = NULL;
2024 uxReturn = uxTaskBasePriorityGetFromISR( xTask );
2028 lIndex = ( int32_t ) xTask;
2030 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2032 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2034 if( xInternalTaskHandle != NULL )
2036 uxReturn = uxTaskBasePriorityGetFromISR( xInternalTaskHandle );
2044 #endif /* #if ( ( INCLUDE_uxTaskPriorityGet == 1 ) && ( configUSE_MUTEXES == 1 ) ) */
2045 /*-----------------------------------------------------------*/
2047 #if ( ( INCLUDE_xTaskResumeFromISR == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) )
2049 BaseType_t MPU_xTaskResumeFromISR( TaskHandle_t xTaskToResume ) /* PRIVILEGED_FUNCTION */
2051 BaseType_t xReturn = pdFAIL;
2053 TaskHandle_t xInternalTaskHandle = NULL;
2055 lIndex = ( int32_t ) xTaskToResume;
2057 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2059 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2061 if( xInternalTaskHandle != NULL )
2063 xReturn = xTaskResumeFromISR( xInternalTaskHandle );
2070 #endif /* #if ( ( INCLUDE_xTaskResumeFromISR == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) )*/
2071 /*---------------------------------------------------------------------------------------*/
2073 #if ( configUSE_APPLICATION_TASK_TAG == 1 )
2075 TaskHookFunction_t MPU_xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */
2077 TaskHookFunction_t xReturn = NULL;
2079 TaskHandle_t xInternalTaskHandle = NULL;
2083 xReturn = xTaskGetApplicationTaskTagFromISR( xTask );
2087 lIndex = ( int32_t ) xTask;
2089 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2091 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2093 if( xInternalTaskHandle != NULL )
2095 xReturn = xTaskGetApplicationTaskTagFromISR( xInternalTaskHandle );
2103 #endif /* #if ( configUSE_APPLICATION_TASK_TAG == 1 ) */
2104 /*---------------------------------------------------------------------------------------*/
2106 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
2108 BaseType_t MPU_xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify,
2109 UBaseType_t uxIndexToNotify,
2111 eNotifyAction eAction,
2112 uint32_t * pulPreviousNotificationValue,
2113 BaseType_t * pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
2115 BaseType_t xReturn = pdFAIL;
2117 TaskHandle_t xInternalTaskHandle = NULL;
2119 lIndex = ( int32_t ) xTaskToNotify;
2121 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2123 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2125 if( xInternalTaskHandle != NULL )
2127 xReturn = xTaskGenericNotifyFromISR( xInternalTaskHandle, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken );
2134 #endif /* #if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
2135 /*---------------------------------------------------------------------------------------*/
2137 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
2139 void MPU_vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify,
2140 UBaseType_t uxIndexToNotify,
2141 BaseType_t * pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
2144 TaskHandle_t xInternalTaskHandle = NULL;
2146 lIndex = ( int32_t ) xTaskToNotify;
2148 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2150 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2152 if( xInternalTaskHandle != NULL )
2154 vTaskGenericNotifyGiveFromISR( xInternalTaskHandle, uxIndexToNotify, pxHigherPriorityTaskWoken );
2158 #endif /*#if ( configUSE_TASK_NOTIFICATIONS == 1 )*/
2159 /*-----------------------------------------------------------*/
2161 /*-----------------------------------------------------------*/
2162 /* MPU wrappers for queue APIs. */
2163 /*-----------------------------------------------------------*/
2165 BaseType_t MPU_xQueueGenericSendImpl( QueueHandle_t xQueue,
2166 const void * const pvItemToQueue,
2167 TickType_t xTicksToWait,
2168 BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION;
2170 BaseType_t MPU_xQueueGenericSendImpl( QueueHandle_t xQueue,
2171 const void * const pvItemToQueue,
2172 TickType_t xTicksToWait,
2173 BaseType_t xCopyPosition ) /* PRIVILEGED_FUNCTION */
2176 QueueHandle_t xInternalQueueHandle = NULL;
2177 BaseType_t xReturn = pdFAIL;
2178 BaseType_t xIsItemToQueueReadable = pdFALSE;
2179 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2180 UBaseType_t uxQueueItemSize, uxQueueLength;
2182 lIndex = ( int32_t ) xQueue;
2184 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2186 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2188 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2190 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2192 if( xInternalQueueHandle != NULL )
2194 uxQueueItemSize = uxQueueGetQueueItemSize( xInternalQueueHandle );
2195 uxQueueLength = uxQueueGetQueueLength( xInternalQueueHandle );
2197 if( ( !( ( pvItemToQueue == NULL ) && ( uxQueueItemSize != ( UBaseType_t ) 0U ) ) ) &&
2198 ( !( ( xCopyPosition == queueOVERWRITE ) && ( uxQueueLength != ( UBaseType_t ) 1U ) ) )
2199 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
2200 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) )
2204 if( pvItemToQueue != NULL )
2206 xIsItemToQueueReadable = xPortIsAuthorizedToAccessBuffer( pvItemToQueue,
2208 tskMPU_READ_PERMISSION );
2211 if( ( pvItemToQueue == NULL ) || ( xIsItemToQueueReadable == pdTRUE ) )
2213 xReturn = xQueueGenericSend( xInternalQueueHandle, pvItemToQueue, xTicksToWait, xCopyPosition );
2222 /*-----------------------------------------------------------*/
2224 UBaseType_t MPU_uxQueueMessagesWaitingImpl( const QueueHandle_t pxQueue ) PRIVILEGED_FUNCTION;
2226 UBaseType_t MPU_uxQueueMessagesWaitingImpl( const QueueHandle_t pxQueue ) /* PRIVILEGED_FUNCTION */
2229 QueueHandle_t xInternalQueueHandle = NULL;
2230 UBaseType_t uxReturn = 0;
2231 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2233 lIndex = ( int32_t ) pxQueue;
2235 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2237 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2239 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2241 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2243 if( xInternalQueueHandle != NULL )
2245 uxReturn = uxQueueMessagesWaiting( xInternalQueueHandle );
2252 /*-----------------------------------------------------------*/
2254 UBaseType_t MPU_uxQueueSpacesAvailableImpl( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
2256 UBaseType_t MPU_uxQueueSpacesAvailableImpl( const QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */
2259 QueueHandle_t xInternalQueueHandle = NULL;
2260 UBaseType_t uxReturn = 0;
2261 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2263 lIndex = ( int32_t ) xQueue;
2265 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2267 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2269 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2271 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2273 if( xInternalQueueHandle != NULL )
2275 uxReturn = uxQueueSpacesAvailable( xInternalQueueHandle );
2282 /*-----------------------------------------------------------*/
2284 BaseType_t MPU_xQueueReceiveImpl( QueueHandle_t pxQueue,
2285 void * const pvBuffer,
2286 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2288 BaseType_t MPU_xQueueReceiveImpl( QueueHandle_t pxQueue,
2289 void * const pvBuffer,
2290 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
2293 QueueHandle_t xInternalQueueHandle = NULL;
2294 BaseType_t xReturn = pdFAIL;
2295 BaseType_t xIsReceiveBufferWritable = pdFALSE;
2296 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2297 UBaseType_t uxQueueItemSize;
2299 lIndex = ( int32_t ) pxQueue;
2301 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2303 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2305 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2307 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2309 if( xInternalQueueHandle != NULL )
2311 uxQueueItemSize = uxQueueGetQueueItemSize( xInternalQueueHandle );
2313 if( ( !( ( ( pvBuffer ) == NULL ) && ( uxQueueItemSize != ( UBaseType_t ) 0U ) ) )
2314 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
2315 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) )
2319 xIsReceiveBufferWritable = xPortIsAuthorizedToAccessBuffer( pvBuffer,
2321 tskMPU_WRITE_PERMISSION );
2323 if( xIsReceiveBufferWritable == pdTRUE )
2325 xReturn = xQueueReceive( xInternalQueueHandle, pvBuffer, xTicksToWait );
2334 /*-----------------------------------------------------------*/
2336 BaseType_t MPU_xQueuePeekImpl( QueueHandle_t xQueue,
2337 void * const pvBuffer,
2338 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2340 BaseType_t MPU_xQueuePeekImpl( QueueHandle_t xQueue,
2341 void * const pvBuffer,
2342 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
2345 QueueHandle_t xInternalQueueHandle = NULL;
2346 BaseType_t xReturn = pdFAIL;
2347 BaseType_t xIsReceiveBufferWritable = pdFALSE;
2348 UBaseType_t uxQueueItemSize;
2349 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2351 lIndex = ( int32_t ) xQueue;
2353 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2355 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2357 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2359 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2361 if( xInternalQueueHandle != NULL )
2363 uxQueueItemSize = uxQueueGetQueueItemSize( xInternalQueueHandle );
2365 if( ( !( ( ( pvBuffer ) == NULL ) && ( uxQueueItemSize != ( UBaseType_t ) 0U ) ) )
2366 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
2367 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) )
2371 xIsReceiveBufferWritable = xPortIsAuthorizedToAccessBuffer( pvBuffer,
2373 tskMPU_WRITE_PERMISSION );
2375 if( xIsReceiveBufferWritable == pdTRUE )
2377 xReturn = xQueuePeek( xInternalQueueHandle, pvBuffer, xTicksToWait );
2386 /*-----------------------------------------------------------*/
2388 BaseType_t MPU_xQueueSemaphoreTakeImpl( QueueHandle_t xQueue,
2389 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
2391 BaseType_t MPU_xQueueSemaphoreTakeImpl( QueueHandle_t xQueue,
2392 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
2395 QueueHandle_t xInternalQueueHandle = NULL;
2396 BaseType_t xReturn = pdFAIL;
2397 UBaseType_t uxQueueItemSize;
2398 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2400 lIndex = ( int32_t ) xQueue;
2402 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2404 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2406 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2408 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2410 if( xInternalQueueHandle != NULL )
2412 uxQueueItemSize = uxQueueGetQueueItemSize( xInternalQueueHandle );
2414 if( ( uxQueueItemSize == 0 )
2415 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
2416 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) )
2420 xReturn = xQueueSemaphoreTake( xInternalQueueHandle, xTicksToWait );
2428 /*-----------------------------------------------------------*/
2430 #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )
2432 TaskHandle_t MPU_xQueueGetMutexHolderImpl( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION;
2434 TaskHandle_t MPU_xQueueGetMutexHolderImpl( QueueHandle_t xSemaphore ) /* PRIVILEGED_FUNCTION */
2436 TaskHandle_t xMutexHolderTaskInternalHandle = NULL;
2437 TaskHandle_t xMutexHolderTaskExternalHandle = NULL;
2438 int32_t lIndex, lMutexHolderTaskIndex;
2439 QueueHandle_t xInternalQueueHandle = NULL;
2440 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2443 lIndex = ( int32_t ) xSemaphore;
2445 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2447 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2449 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2451 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2453 if( xInternalQueueHandle != NULL )
2455 xMutexHolderTaskInternalHandle = xQueueGetMutexHolder( xInternalQueueHandle );
2457 if( xMutexHolderTaskInternalHandle != NULL )
2459 lMutexHolderTaskIndex = MPU_GetIndexForTaskHandle( xMutexHolderTaskInternalHandle );
2461 if( lMutexHolderTaskIndex != -1 )
2463 xMutexHolderTaskExternalHandle = ( TaskHandle_t ) ( CONVERT_TO_EXTERNAL_INDEX( lMutexHolderTaskIndex ) );
2470 return xMutexHolderTaskExternalHandle;
2473 #endif /* if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) */
2474 /*-----------------------------------------------------------*/
2476 #if ( configUSE_RECURSIVE_MUTEXES == 1 )
2478 BaseType_t MPU_xQueueTakeMutexRecursiveImpl( QueueHandle_t xMutex,
2479 TickType_t xBlockTime ) PRIVILEGED_FUNCTION;
2481 BaseType_t MPU_xQueueTakeMutexRecursiveImpl( QueueHandle_t xMutex,
2482 TickType_t xBlockTime ) /* PRIVILEGED_FUNCTION */
2484 BaseType_t xReturn = pdFAIL;
2485 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2487 QueueHandle_t xInternalQueueHandle = NULL;
2488 UBaseType_t uxQueueItemSize;
2490 lIndex = ( int32_t ) xMutex;
2492 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2494 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2496 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2498 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2500 if( xInternalQueueHandle != NULL )
2502 uxQueueItemSize = uxQueueGetQueueItemSize( xInternalQueueHandle );
2504 if( uxQueueItemSize == 0 )
2506 xReturn = xQueueTakeMutexRecursive( xInternalQueueHandle, xBlockTime );
2515 #endif /* if ( configUSE_RECURSIVE_MUTEXES == 1 ) */
2516 /*-----------------------------------------------------------*/
2518 #if ( configUSE_RECURSIVE_MUTEXES == 1 )
2520 BaseType_t MPU_xQueueGiveMutexRecursiveImpl( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION;
2522 BaseType_t MPU_xQueueGiveMutexRecursiveImpl( QueueHandle_t xMutex ) /* PRIVILEGED_FUNCTION */
2524 BaseType_t xReturn = pdFAIL;
2525 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2527 QueueHandle_t xInternalQueueHandle = NULL;
2529 lIndex = ( int32_t ) xMutex;
2531 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2533 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2535 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2537 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2539 if( xInternalQueueHandle != NULL )
2541 xReturn = xQueueGiveMutexRecursive( xInternalQueueHandle );
2549 #endif /* if ( configUSE_RECURSIVE_MUTEXES == 1 ) */
2550 /*-----------------------------------------------------------*/
2552 #if ( configUSE_QUEUE_SETS == 1 )
2554 QueueSetMemberHandle_t MPU_xQueueSelectFromSetImpl( QueueSetHandle_t xQueueSet,
2555 TickType_t xBlockTimeTicks ) PRIVILEGED_FUNCTION;
2557 QueueSetMemberHandle_t MPU_xQueueSelectFromSetImpl( QueueSetHandle_t xQueueSet,
2558 TickType_t xBlockTimeTicks ) /* PRIVILEGED_FUNCTION */
2560 QueueSetHandle_t xInternalQueueSetHandle = NULL;
2561 QueueSetMemberHandle_t xSelectedMemberInternal = NULL;
2562 QueueSetMemberHandle_t xSelectedMemberExternal = NULL;
2563 int32_t lIndexQueueSet, lIndexSelectedMember;
2564 BaseType_t xCallingTaskIsAuthorizedToAccessQueueSet = pdFALSE;
2566 lIndexQueueSet = ( int32_t ) xQueueSet;
2568 if( IS_EXTERNAL_INDEX_VALID( lIndexQueueSet ) != pdFALSE )
2570 xCallingTaskIsAuthorizedToAccessQueueSet = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) );
2572 if( xCallingTaskIsAuthorizedToAccessQueueSet == pdTRUE )
2574 xInternalQueueSetHandle = MPU_GetQueueSetHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) );
2576 if( xInternalQueueSetHandle != NULL )
2578 xSelectedMemberInternal = xQueueSelectFromSet( xInternalQueueSetHandle, xBlockTimeTicks );
2580 if( xSelectedMemberInternal != NULL )
2582 lIndexSelectedMember = MPU_GetIndexForQueueSetMemberHandle( xSelectedMemberInternal );
2584 if( lIndexSelectedMember != -1 )
2586 xSelectedMemberExternal = ( QueueSetMemberHandle_t ) ( CONVERT_TO_EXTERNAL_INDEX( lIndexSelectedMember ) );
2593 return xSelectedMemberExternal;
2596 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */
2597 /*-----------------------------------------------------------*/
2599 #if ( configUSE_QUEUE_SETS == 1 )
2601 BaseType_t MPU_xQueueAddToSetImpl( QueueSetMemberHandle_t xQueueOrSemaphore,
2602 QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
2604 BaseType_t MPU_xQueueAddToSetImpl( QueueSetMemberHandle_t xQueueOrSemaphore,
2605 QueueSetHandle_t xQueueSet ) /* PRIVILEGED_FUNCTION */
2607 BaseType_t xReturn = pdFAIL;
2608 QueueSetMemberHandle_t xInternalQueueSetMemberHandle = NULL;
2609 QueueSetHandle_t xInternalQueueSetHandle = NULL;
2610 int32_t lIndexQueueSet, lIndexQueueSetMember;
2611 BaseType_t xCallingTaskIsAuthorizedToAccessQueueSet = pdFALSE;
2612 BaseType_t xCallingTaskIsAuthorizedToAccessQueueSetMember = pdFALSE;
2614 lIndexQueueSet = ( int32_t ) xQueueSet;
2615 lIndexQueueSetMember = ( int32_t ) xQueueOrSemaphore;
2617 if( ( IS_EXTERNAL_INDEX_VALID( lIndexQueueSet ) != pdFALSE ) &&
2618 ( IS_EXTERNAL_INDEX_VALID( lIndexQueueSetMember ) != pdFALSE ) )
2620 xCallingTaskIsAuthorizedToAccessQueueSet = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) );
2621 xCallingTaskIsAuthorizedToAccessQueueSetMember = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSetMember ) );
2623 if( ( xCallingTaskIsAuthorizedToAccessQueueSet == pdTRUE ) && ( xCallingTaskIsAuthorizedToAccessQueueSetMember == pdTRUE ) )
2625 xInternalQueueSetHandle = MPU_GetQueueSetHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) );
2626 xInternalQueueSetMemberHandle = MPU_GetQueueSetMemberHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSetMember ) );
2628 if( ( xInternalQueueSetHandle != NULL ) && ( xInternalQueueSetMemberHandle != NULL ) )
2630 xReturn = xQueueAddToSet( xInternalQueueSetMemberHandle, xInternalQueueSetHandle );
2638 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */
2639 /*-----------------------------------------------------------*/
2641 #if configQUEUE_REGISTRY_SIZE > 0
2643 void MPU_vQueueAddToRegistryImpl( QueueHandle_t xQueue,
2644 const char * pcName ) PRIVILEGED_FUNCTION;
2646 void MPU_vQueueAddToRegistryImpl( QueueHandle_t xQueue,
2647 const char * pcName ) /* PRIVILEGED_FUNCTION */
2650 QueueHandle_t xInternalQueueHandle = NULL;
2651 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2653 lIndex = ( int32_t ) xQueue;
2655 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2657 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2659 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2661 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2663 if( xInternalQueueHandle != NULL )
2665 vQueueAddToRegistry( xInternalQueueHandle, pcName );
2671 #endif /* if configQUEUE_REGISTRY_SIZE > 0 */
2672 /*-----------------------------------------------------------*/
2674 #if configQUEUE_REGISTRY_SIZE > 0
2676 void MPU_vQueueUnregisterQueueImpl( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
2678 void MPU_vQueueUnregisterQueueImpl( QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */
2681 QueueHandle_t xInternalQueueHandle = NULL;
2682 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2684 lIndex = ( int32_t ) xQueue;
2686 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2688 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2690 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2692 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2694 if( xInternalQueueHandle != NULL )
2696 vQueueUnregisterQueue( xInternalQueueHandle );
2702 #endif /* if configQUEUE_REGISTRY_SIZE > 0 */
2703 /*-----------------------------------------------------------*/
2705 #if configQUEUE_REGISTRY_SIZE > 0
2707 const char * MPU_pcQueueGetNameImpl( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
2709 const char * MPU_pcQueueGetNameImpl( QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */
2711 const char * pcReturn = NULL;
2712 QueueHandle_t xInternalQueueHandle = NULL;
2714 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE;
2716 lIndex = ( int32_t ) xQueue;
2718 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2720 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2722 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE )
2724 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2726 if( xInternalQueueHandle != NULL )
2728 pcReturn = pcQueueGetName( xInternalQueueHandle );
2736 #endif /* if configQUEUE_REGISTRY_SIZE > 0 */
2737 /*-----------------------------------------------------------*/
2739 /* Privileged only wrappers for Queue APIs. These are needed so that
2740 * the application can use opaque handles maintained in mpu_wrappers.c
2741 * with all the APIs. */
2742 /*-----------------------------------------------------------*/
2744 void MPU_vQueueDelete( QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */
2746 QueueHandle_t xInternalQueueHandle = NULL;
2749 lIndex = ( int32_t ) xQueue;
2751 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2753 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2755 if( xInternalQueueHandle != NULL )
2757 vQueueDelete( xInternalQueueHandle );
2758 MPU_SetIndexFreeInKernelObjectPool( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2762 /*-----------------------------------------------------------*/
2764 #if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
2766 QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) /* PRIVILEGED_FUNCTION */
2768 QueueHandle_t xInternalQueueHandle = NULL;
2769 QueueHandle_t xExternalQueueHandle = NULL;
2772 lIndex = MPU_GetFreeIndexInKernelObjectPool();
2776 xInternalQueueHandle = xQueueCreateMutex( ucQueueType );
2778 if( xInternalQueueHandle != NULL )
2780 MPU_StoreQueueHandleAtIndex( lIndex, xInternalQueueHandle );
2781 xExternalQueueHandle = ( QueueHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
2785 MPU_SetIndexFreeInKernelObjectPool( lIndex );
2789 return xExternalQueueHandle;
2792 #endif /* if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */
2793 /*-----------------------------------------------------------*/
2795 #if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
2797 QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType,
2798 StaticQueue_t * pxStaticQueue ) /* PRIVILEGED_FUNCTION */
2800 QueueHandle_t xInternalQueueHandle = NULL;
2801 QueueHandle_t xExternalQueueHandle = NULL;
2804 lIndex = MPU_GetFreeIndexInKernelObjectPool();
2808 xInternalQueueHandle = xQueueCreateMutexStatic( ucQueueType, pxStaticQueue );
2810 if( xInternalQueueHandle != NULL )
2812 MPU_StoreQueueHandleAtIndex( lIndex, xInternalQueueHandle );
2813 xExternalQueueHandle = ( QueueHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
2817 MPU_SetIndexFreeInKernelObjectPool( lIndex );
2821 return xExternalQueueHandle;
2824 #endif /* if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) */
2825 /*-----------------------------------------------------------*/
2827 #if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
2829 QueueHandle_t MPU_xQueueCreateCountingSemaphore( UBaseType_t uxCountValue,
2830 UBaseType_t uxInitialCount ) /* PRIVILEGED_FUNCTION */
2832 QueueHandle_t xInternalQueueHandle = NULL;
2833 QueueHandle_t xExternalQueueHandle = NULL;
2836 lIndex = MPU_GetFreeIndexInKernelObjectPool();
2840 xInternalQueueHandle = xQueueCreateCountingSemaphore( uxCountValue, uxInitialCount );
2842 if( xInternalQueueHandle != NULL )
2844 MPU_StoreQueueHandleAtIndex( lIndex, xInternalQueueHandle );
2845 xExternalQueueHandle = ( QueueHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
2849 MPU_SetIndexFreeInKernelObjectPool( lIndex );
2853 return xExternalQueueHandle;
2856 #endif /* if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */
2857 /*-----------------------------------------------------------*/
2859 #if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
2861 QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
2862 const UBaseType_t uxInitialCount,
2863 StaticQueue_t * pxStaticQueue ) /* PRIVILEGED_FUNCTION */
2865 QueueHandle_t xInternalQueueHandle = NULL;
2866 QueueHandle_t xExternalQueueHandle = NULL;
2869 lIndex = MPU_GetFreeIndexInKernelObjectPool();
2873 xInternalQueueHandle = xQueueCreateCountingSemaphoreStatic( uxMaxCount, uxInitialCount, pxStaticQueue );
2875 if( xInternalQueueHandle != NULL )
2877 MPU_StoreQueueHandleAtIndex( lIndex, xInternalQueueHandle );
2878 xExternalQueueHandle = ( QueueHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
2882 MPU_SetIndexFreeInKernelObjectPool( lIndex );
2886 return xExternalQueueHandle;
2889 #endif /* if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) */
2890 /*-----------------------------------------------------------*/
2892 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
2894 QueueHandle_t MPU_xQueueGenericCreate( UBaseType_t uxQueueLength,
2895 UBaseType_t uxItemSize,
2896 uint8_t ucQueueType ) /* PRIVILEGED_FUNCTION */
2898 QueueHandle_t xInternalQueueHandle = NULL;
2899 QueueHandle_t xExternalQueueHandle = NULL;
2902 lIndex = MPU_GetFreeIndexInKernelObjectPool();
2906 xInternalQueueHandle = xQueueGenericCreate( uxQueueLength, uxItemSize, ucQueueType );
2908 if( xInternalQueueHandle != NULL )
2910 MPU_StoreQueueHandleAtIndex( lIndex, xInternalQueueHandle );
2911 xExternalQueueHandle = ( QueueHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
2915 MPU_SetIndexFreeInKernelObjectPool( lIndex );
2919 return xExternalQueueHandle;
2922 #endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) */
2923 /*-----------------------------------------------------------*/
2925 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
2927 QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength,
2928 const UBaseType_t uxItemSize,
2929 uint8_t * pucQueueStorage,
2930 StaticQueue_t * pxStaticQueue,
2931 const uint8_t ucQueueType ) /* PRIVILEGED_FUNCTION */
2933 QueueHandle_t xInternalQueueHandle = NULL;
2934 QueueHandle_t xExternalQueueHandle = NULL;
2937 lIndex = MPU_GetFreeIndexInKernelObjectPool();
2941 xInternalQueueHandle = xQueueGenericCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxStaticQueue, ucQueueType );
2943 if( xInternalQueueHandle != NULL )
2945 MPU_StoreQueueHandleAtIndex( lIndex, xInternalQueueHandle );
2946 xExternalQueueHandle = ( QueueHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
2950 MPU_SetIndexFreeInKernelObjectPool( lIndex );
2954 return xExternalQueueHandle;
2957 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
2958 /*-----------------------------------------------------------*/
2960 BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue,
2961 BaseType_t xNewQueue ) /* PRIVILEGED_FUNCTION */
2964 QueueHandle_t xInternalQueueHandle = NULL;
2965 BaseType_t xReturn = pdFAIL;
2967 lIndex = ( uint32_t ) xQueue;
2969 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
2971 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
2973 if( xInternalQueueHandle != NULL )
2975 xReturn = xQueueGenericReset( xInternalQueueHandle, xNewQueue );
2981 /*-----------------------------------------------------------*/
2983 #if ( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
2985 QueueSetHandle_t MPU_xQueueCreateSet( UBaseType_t uxEventQueueLength ) /* PRIVILEGED_FUNCTION */
2987 QueueSetHandle_t xInternalQueueSetHandle = NULL;
2988 QueueSetHandle_t xExternalQueueSetHandle = NULL;
2991 lIndex = MPU_GetFreeIndexInKernelObjectPool();
2995 xInternalQueueSetHandle = xQueueCreateSet( uxEventQueueLength );
2997 if( xInternalQueueSetHandle != NULL )
2999 MPU_StoreQueueSetHandleAtIndex( lIndex, xInternalQueueSetHandle );
3000 xExternalQueueSetHandle = ( QueueSetHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
3004 MPU_SetIndexFreeInKernelObjectPool( lIndex );
3008 return xExternalQueueSetHandle;
3011 #endif /* if ( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */
3012 /*-----------------------------------------------------------*/
3014 #if ( configUSE_QUEUE_SETS == 1 )
3016 BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
3017 QueueSetHandle_t xQueueSet ) /* PRIVILEGED_FUNCTION */
3019 BaseType_t xReturn = pdFAIL;
3020 QueueSetMemberHandle_t xInternalQueueSetMemberHandle = NULL;
3021 QueueSetHandle_t xInternalQueueSetHandle = NULL;
3022 int32_t lIndexQueueSet, lIndexQueueSetMember;
3024 lIndexQueueSet = ( int32_t ) xQueueSet;
3025 lIndexQueueSetMember = ( int32_t ) xQueueOrSemaphore;
3027 if( ( IS_EXTERNAL_INDEX_VALID( lIndexQueueSet ) != pdFALSE ) &&
3028 ( IS_EXTERNAL_INDEX_VALID( lIndexQueueSetMember ) != pdFALSE ) )
3030 xInternalQueueSetHandle = MPU_GetQueueSetHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) );
3031 xInternalQueueSetMemberHandle = MPU_GetQueueSetMemberHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSetMember ) );
3033 if( ( xInternalQueueSetHandle != NULL ) && ( xInternalQueueSetMemberHandle != NULL ) )
3035 xReturn = xQueueRemoveFromSet( xInternalQueueSetMemberHandle, xInternalQueueSetHandle );
3042 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */
3043 /*-----------------------------------------------------------*/
3045 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
3047 BaseType_t MPU_xQueueGenericGetStaticBuffers( QueueHandle_t xQueue,
3048 uint8_t ** ppucQueueStorage,
3049 StaticQueue_t ** ppxStaticQueue ) /* PRIVILEGED_FUNCTION */
3052 QueueHandle_t xInternalQueueHandle = NULL;
3053 BaseType_t xReturn = pdFALSE;
3055 lIndex = ( int32_t ) xQueue;
3057 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3059 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3061 if( xInternalQueueHandle != NULL )
3063 xReturn = xQueueGenericGetStaticBuffers( xInternalQueueHandle, ppucQueueStorage, ppxStaticQueue );
3070 #endif /*if ( configSUPPORT_STATIC_ALLOCATION == 1 )*/
3071 /*-----------------------------------------------------------*/
3073 BaseType_t MPU_xQueueGenericSendFromISR( QueueHandle_t xQueue,
3074 const void * const pvItemToQueue,
3075 BaseType_t * const pxHigherPriorityTaskWoken,
3076 const BaseType_t xCopyPosition ) /* PRIVILEGED_FUNCTION */
3078 BaseType_t xReturn = pdFAIL;
3080 QueueHandle_t xInternalQueueHandle = NULL;
3082 lIndex = ( int32_t ) xQueue;
3084 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3086 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3088 if( xInternalQueueHandle != NULL )
3090 xReturn = xQueueGenericSendFromISR( xInternalQueueHandle, pvItemToQueue, pxHigherPriorityTaskWoken, xCopyPosition );
3097 /*-----------------------------------------------------------*/
3099 BaseType_t MPU_xQueueGiveFromISR( QueueHandle_t xQueue,
3100 BaseType_t * const pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
3102 BaseType_t xReturn = pdFAIL;
3104 QueueHandle_t xInternalQueueHandle = NULL;
3106 lIndex = ( int32_t ) xQueue;
3108 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3110 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3112 if( xInternalQueueHandle != NULL )
3114 xReturn = xQueueGiveFromISR( xInternalQueueHandle, pxHigherPriorityTaskWoken );
3121 /*-----------------------------------------------------------*/
3123 BaseType_t MPU_xQueuePeekFromISR( QueueHandle_t xQueue,
3124 void * const pvBuffer ) /* PRIVILEGED_FUNCTION */
3126 BaseType_t xReturn = pdFAIL;
3128 QueueHandle_t xInternalQueueHandle = NULL;
3130 lIndex = ( int32_t ) xQueue;
3132 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3134 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3136 if( xInternalQueueHandle != NULL )
3138 xReturn = xQueuePeekFromISR( xInternalQueueHandle, pvBuffer );
3145 /*-----------------------------------------------------------*/
3147 BaseType_t MPU_xQueueReceiveFromISR( QueueHandle_t xQueue,
3148 void * const pvBuffer,
3149 BaseType_t * const pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
3151 BaseType_t xReturn = pdFAIL;
3153 QueueHandle_t xInternalQueueHandle = NULL;
3155 lIndex = ( int32_t ) xQueue;
3157 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3159 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3161 if( xInternalQueueHandle != NULL )
3163 xReturn = xQueueReceiveFromISR( xInternalQueueHandle, pvBuffer, pxHigherPriorityTaskWoken );
3170 /*-----------------------------------------------------------*/
3172 BaseType_t MPU_xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */
3174 BaseType_t xReturn = pdFAIL;
3176 QueueHandle_t xInternalQueueHandle = NULL;
3178 lIndex = ( int32_t ) xQueue;
3180 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3182 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3184 if( xInternalQueueHandle != NULL )
3186 xReturn = xQueueIsQueueEmptyFromISR( xInternalQueueHandle );
3192 /*-----------------------------------------------------------*/
3194 BaseType_t MPU_xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */
3196 BaseType_t xReturn = pdFAIL;
3198 QueueHandle_t xInternalQueueHandle = NULL;
3200 lIndex = ( int32_t ) xQueue;
3202 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3204 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3206 if( xInternalQueueHandle != NULL )
3208 xReturn = xQueueIsQueueFullFromISR( xInternalQueueHandle );
3215 /*-----------------------------------------------------------*/
3217 UBaseType_t MPU_uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */
3219 UBaseType_t uxReturn = 0;
3221 QueueHandle_t xInternalQueueHandle = NULL;
3223 lIndex = ( int32_t ) xQueue;
3225 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3227 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3229 if( xInternalQueueHandle != NULL )
3231 uxReturn = uxQueueMessagesWaitingFromISR( xInternalQueueHandle );
3238 /*-----------------------------------------------------------*/
3240 #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )
3242 TaskHandle_t MPU_xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) /* PRIVILEGED_FUNCTION */
3244 TaskHandle_t xMutexHolderTaskInternalHandle = NULL;
3245 TaskHandle_t xMutexHolderTaskExternalHandle = NULL;
3246 int32_t lIndex, lMutexHolderTaskIndex;
3247 QueueHandle_t xInternalSemaphoreHandle = NULL;
3249 lIndex = ( int32_t ) xSemaphore;
3251 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3253 xInternalSemaphoreHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3255 if( xInternalSemaphoreHandle != NULL )
3257 xMutexHolderTaskInternalHandle = xQueueGetMutexHolder( xInternalSemaphoreHandle );
3259 if( xMutexHolderTaskInternalHandle != NULL )
3261 lMutexHolderTaskIndex = MPU_GetIndexForTaskHandle( xMutexHolderTaskInternalHandle );
3263 if( lMutexHolderTaskIndex != -1 )
3265 xMutexHolderTaskExternalHandle = ( TaskHandle_t ) ( CONVERT_TO_EXTERNAL_INDEX( lMutexHolderTaskIndex ) );
3271 return xMutexHolderTaskExternalHandle;
3274 #endif /* #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) */
3275 /*-----------------------------------------------------------*/
3277 #if ( configUSE_QUEUE_SETS == 1 )
3279 QueueSetMemberHandle_t MPU_xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) /* PRIVILEGED_FUNCTION */
3281 QueueSetHandle_t xInternalQueueSetHandle = NULL;
3282 QueueSetMemberHandle_t xSelectedMemberInternal = NULL;
3283 QueueSetMemberHandle_t xSelectedMemberExternal = NULL;
3284 int32_t lIndexQueueSet, lIndexSelectedMember;
3286 lIndexQueueSet = ( int32_t ) xQueueSet;
3288 if( IS_EXTERNAL_INDEX_VALID( lIndexQueueSet ) != pdFALSE )
3290 xInternalQueueSetHandle = MPU_GetQueueSetHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) );
3292 if( xInternalQueueSetHandle != NULL )
3294 xSelectedMemberInternal = xQueueSelectFromSetFromISR( xInternalQueueSetHandle );
3296 if( xSelectedMemberInternal != NULL )
3298 lIndexSelectedMember = MPU_GetIndexForQueueSetMemberHandle( xSelectedMemberInternal );
3300 if( lIndexSelectedMember != -1 )
3302 xSelectedMemberExternal = ( QueueSetMemberHandle_t ) ( CONVERT_TO_EXTERNAL_INDEX( lIndexSelectedMember ) );
3308 return xSelectedMemberExternal;
3311 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */
3312 /*-----------------------------------------------------------*/
3314 /*-----------------------------------------------------------*/
3315 /* MPU wrappers for timers APIs. */
3316 /*-----------------------------------------------------------*/
3318 #if ( configUSE_TIMERS == 1 )
3320 void * MPU_pvTimerGetTimerIDImpl( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3322 void * MPU_pvTimerGetTimerIDImpl( const TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3324 void * pvReturn = NULL;
3325 TimerHandle_t xInternalTimerHandle = NULL;
3327 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3329 lIndex = ( int32_t ) xTimer;
3331 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3333 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3335 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3337 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3339 if( xInternalTimerHandle != NULL )
3341 pvReturn = pvTimerGetTimerID( xInternalTimerHandle );
3349 #endif /* if ( configUSE_TIMERS == 1 ) */
3350 /*-----------------------------------------------------------*/
3352 #if ( configUSE_TIMERS == 1 )
3354 void MPU_vTimerSetTimerIDImpl( TimerHandle_t xTimer,
3355 void * pvNewID ) PRIVILEGED_FUNCTION;
3357 void MPU_vTimerSetTimerIDImpl( TimerHandle_t xTimer,
3358 void * pvNewID ) /* PRIVILEGED_FUNCTION */
3360 TimerHandle_t xInternalTimerHandle = NULL;
3362 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3364 lIndex = ( int32_t ) xTimer;
3366 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3368 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3370 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3372 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3374 if( xInternalTimerHandle != NULL )
3376 vTimerSetTimerID( xInternalTimerHandle, pvNewID );
3382 #endif /* if ( configUSE_TIMERS == 1 ) */
3383 /*-----------------------------------------------------------*/
3385 #if ( configUSE_TIMERS == 1 )
3387 BaseType_t MPU_xTimerIsTimerActiveImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3389 BaseType_t MPU_xTimerIsTimerActiveImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3391 BaseType_t xReturn = pdFALSE;
3392 TimerHandle_t xInternalTimerHandle = NULL;
3394 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3396 lIndex = ( int32_t ) xTimer;
3398 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3400 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3402 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3404 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3406 if( xInternalTimerHandle != NULL )
3408 xReturn = xTimerIsTimerActive( xInternalTimerHandle );
3416 #endif /* if ( configUSE_TIMERS == 1 ) */
3417 /*-----------------------------------------------------------*/
3419 #if ( configUSE_TIMERS == 1 )
3421 TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandleImpl( void ) PRIVILEGED_FUNCTION;
3423 TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandleImpl( void ) /* PRIVILEGED_FUNCTION */
3425 TaskHandle_t xReturn;
3427 xReturn = xTimerGetTimerDaemonTaskHandle();
3432 #endif /* if ( configUSE_TIMERS == 1 ) */
3433 /*-----------------------------------------------------------*/
3435 #if ( configUSE_TIMERS == 1 )
3437 BaseType_t MPU_xTimerGenericCommandFromTask( TimerHandle_t xTimer,
3438 const BaseType_t xCommandID,
3439 const TickType_t xOptionalValue,
3440 BaseType_t * const pxHigherPriorityTaskWoken,
3441 const TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
3443 BaseType_t xReturn = pdFALSE;
3444 xTimerGenericCommandFromTaskParams_t xParams;
3446 xParams.xTimer = xTimer;
3447 xParams.xCommandID = xCommandID;
3448 xParams.xOptionalValue = xOptionalValue;
3449 xParams.pxHigherPriorityTaskWoken = pxHigherPriorityTaskWoken;
3450 xParams.xTicksToWait = xTicksToWait;
3452 xReturn = MPU_xTimerGenericCommandFromTaskEntry( &( xParams ) );
3457 BaseType_t MPU_xTimerGenericCommandFromTaskImpl( const xTimerGenericCommandFromTaskParams_t * pxParams ) PRIVILEGED_FUNCTION;
3459 BaseType_t MPU_xTimerGenericCommandFromTaskImpl( const xTimerGenericCommandFromTaskParams_t * pxParams ) /* PRIVILEGED_FUNCTION */
3461 BaseType_t xReturn = pdFALSE;
3462 TimerHandle_t xInternalTimerHandle = NULL;
3464 BaseType_t xIsHigherPriorityTaskWokenWriteable = pdFALSE;
3465 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3466 BaseType_t xAreParamsReadable = pdFALSE;
3468 if( pxParams != NULL )
3470 xAreParamsReadable = xPortIsAuthorizedToAccessBuffer( pxParams,
3471 sizeof( xTimerGenericCommandFromTaskParams_t ),
3472 tskMPU_READ_PERMISSION );
3475 if( xAreParamsReadable == pdTRUE )
3477 if( pxParams->xCommandID < tmrFIRST_FROM_ISR_COMMAND )
3479 if( pxParams->pxHigherPriorityTaskWoken != NULL )
3481 xIsHigherPriorityTaskWokenWriteable = xPortIsAuthorizedToAccessBuffer( pxParams->pxHigherPriorityTaskWoken,
3482 sizeof( BaseType_t ),
3483 tskMPU_WRITE_PERMISSION );
3486 if( ( pxParams->pxHigherPriorityTaskWoken == NULL ) ||
3487 ( xIsHigherPriorityTaskWokenWriteable == pdTRUE ) )
3489 lIndex = ( int32_t ) ( pxParams->xTimer );
3491 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3493 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3495 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3497 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3499 if( xInternalTimerHandle != NULL )
3501 xReturn = xTimerGenericCommandFromTask( xInternalTimerHandle,
3502 pxParams->xCommandID,
3503 pxParams->xOptionalValue,
3504 pxParams->pxHigherPriorityTaskWoken,
3505 pxParams->xTicksToWait );
3516 #endif /* if ( configUSE_TIMERS == 1 ) */
3517 /*-----------------------------------------------------------*/
3519 #if ( configUSE_TIMERS == 1 )
3521 const char * MPU_pcTimerGetNameImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3523 const char * MPU_pcTimerGetNameImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3525 const char * pcReturn = NULL;
3526 TimerHandle_t xInternalTimerHandle = NULL;
3528 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3530 lIndex = ( int32_t ) xTimer;
3532 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3534 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3536 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3538 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3540 if( xInternalTimerHandle != NULL )
3542 pcReturn = pcTimerGetName( xInternalTimerHandle );
3550 #endif /* if ( configUSE_TIMERS == 1 ) */
3551 /*-----------------------------------------------------------*/
3553 #if ( configUSE_TIMERS == 1 )
3555 void MPU_vTimerSetReloadModeImpl( TimerHandle_t xTimer,
3556 const UBaseType_t uxAutoReload ) PRIVILEGED_FUNCTION;
3558 void MPU_vTimerSetReloadModeImpl( TimerHandle_t xTimer,
3559 const UBaseType_t uxAutoReload ) /* PRIVILEGED_FUNCTION */
3561 TimerHandle_t xInternalTimerHandle = NULL;
3563 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3565 lIndex = ( int32_t ) xTimer;
3567 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3569 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3571 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3573 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3575 if( xInternalTimerHandle != NULL )
3577 vTimerSetReloadMode( xInternalTimerHandle, uxAutoReload );
3583 #endif /* if ( configUSE_TIMERS == 1 ) */
3584 /*-----------------------------------------------------------*/
3586 #if ( configUSE_TIMERS == 1 )
3588 BaseType_t MPU_xTimerGetReloadModeImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3590 BaseType_t MPU_xTimerGetReloadModeImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3592 BaseType_t xReturn = pdFALSE;
3593 TimerHandle_t xInternalTimerHandle = NULL;
3595 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3597 lIndex = ( int32_t ) xTimer;
3599 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3601 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3603 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3605 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3607 if( xInternalTimerHandle != NULL )
3609 xReturn = xTimerGetReloadMode( xInternalTimerHandle );
3617 #endif /* if ( configUSE_TIMERS == 1 ) */
3618 /*-----------------------------------------------------------*/
3620 #if ( configUSE_TIMERS == 1 )
3622 UBaseType_t MPU_uxTimerGetReloadModeImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3624 UBaseType_t MPU_uxTimerGetReloadModeImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3626 UBaseType_t uxReturn = 0;
3627 TimerHandle_t xInternalTimerHandle = NULL;
3629 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3631 lIndex = ( int32_t ) xTimer;
3633 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3635 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3637 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3639 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3641 if( xInternalTimerHandle != NULL )
3643 uxReturn = uxTimerGetReloadMode( xInternalTimerHandle );
3651 #endif /* if ( configUSE_TIMERS == 1 ) */
3652 /*-----------------------------------------------------------*/
3654 #if ( configUSE_TIMERS == 1 )
3656 TickType_t MPU_xTimerGetPeriodImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3658 TickType_t MPU_xTimerGetPeriodImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3660 TickType_t xReturn = 0;
3661 TimerHandle_t xInternalTimerHandle = NULL;
3663 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3665 lIndex = ( int32_t ) xTimer;
3667 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3669 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3671 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3673 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3675 if( xInternalTimerHandle != NULL )
3677 xReturn = xTimerGetPeriod( xInternalTimerHandle );
3685 #endif /* if ( configUSE_TIMERS == 1 ) */
3686 /*-----------------------------------------------------------*/
3688 #if ( configUSE_TIMERS == 1 )
3690 TickType_t MPU_xTimerGetExpiryTimeImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
3692 TickType_t MPU_xTimerGetExpiryTimeImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */
3694 TickType_t xReturn = 0;
3695 TimerHandle_t xInternalTimerHandle = NULL;
3697 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE;
3699 lIndex = ( int32_t ) xTimer;
3701 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3703 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3705 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE )
3707 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3709 if( xInternalTimerHandle != NULL )
3711 xReturn = xTimerGetExpiryTime( xInternalTimerHandle );
3719 #endif /* if ( configUSE_TIMERS == 1 ) */
3720 /*-----------------------------------------------------------*/
3722 /* Privileged only wrappers for Timer APIs. These are needed so that
3723 * the application can use opaque handles maintained in mpu_wrappers.c
3724 * with all the APIs. */
3725 /*-----------------------------------------------------------*/
3727 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 )
3729 TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName,
3730 const TickType_t xTimerPeriodInTicks,
3731 const UBaseType_t uxAutoReload,
3732 void * const pvTimerID,
3733 TimerCallbackFunction_t pxCallbackFunction ) /* PRIVILEGED_FUNCTION */
3735 TimerHandle_t xInternalTimerHandle = NULL;
3736 TimerHandle_t xExternalTimerHandle = NULL;
3739 lIndex = MPU_GetFreeIndexInKernelObjectPool();
3743 xInternalTimerHandle = xTimerCreate( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, MPU_TimerCallback );
3745 if( xInternalTimerHandle != NULL )
3747 MPU_StoreTimerHandleAtIndex( lIndex, xInternalTimerHandle, pxCallbackFunction );
3748 xExternalTimerHandle = ( TimerHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
3752 MPU_SetIndexFreeInKernelObjectPool( lIndex );
3756 return xExternalTimerHandle;
3759 #endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) */
3760 /*-----------------------------------------------------------*/
3762 #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 )
3764 TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName,
3765 const TickType_t xTimerPeriodInTicks,
3766 const UBaseType_t uxAutoReload,
3767 void * const pvTimerID,
3768 TimerCallbackFunction_t pxCallbackFunction,
3769 StaticTimer_t * pxTimerBuffer ) /* PRIVILEGED_FUNCTION */
3771 TimerHandle_t xInternalTimerHandle = NULL;
3772 TimerHandle_t xExternalTimerHandle = NULL;
3775 lIndex = MPU_GetFreeIndexInKernelObjectPool();
3779 xInternalTimerHandle = xTimerCreateStatic( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, MPU_TimerCallback, pxTimerBuffer );
3781 if( xInternalTimerHandle != NULL )
3783 MPU_StoreTimerHandleAtIndex( lIndex, xInternalTimerHandle, pxCallbackFunction );
3784 xExternalTimerHandle = ( TimerHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
3788 MPU_SetIndexFreeInKernelObjectPool( lIndex );
3792 return xExternalTimerHandle;
3795 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) */
3796 /*-----------------------------------------------------------*/
3798 #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 )
3800 BaseType_t MPU_xTimerGetStaticBuffer( TimerHandle_t xTimer,
3801 StaticTimer_t ** ppxTimerBuffer ) /* PRIVILEGED_FUNCTION */
3803 TimerHandle_t xInternalTimerHandle = NULL;
3805 BaseType_t xReturn = pdFALSE;
3807 lIndex = ( int32_t ) xTimer;
3809 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3811 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3813 if( xInternalTimerHandle != NULL )
3815 xReturn = xTimerGetStaticBuffer( xInternalTimerHandle, ppxTimerBuffer );
3822 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) */
3823 /*-----------------------------------------------------------*/
3825 #if ( configUSE_TIMERS == 1 )
3827 BaseType_t MPU_xTimerGenericCommandFromISR( TimerHandle_t xTimer,
3828 const BaseType_t xCommandID,
3829 const TickType_t xOptionalValue,
3830 BaseType_t * const pxHigherPriorityTaskWoken,
3831 const TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
3833 BaseType_t xReturn = pdFALSE;
3834 TimerHandle_t xInternalTimerHandle = NULL;
3836 BaseType_t xIsHigherPriorityTaskWokenWriteable = pdFALSE;
3838 if( pxHigherPriorityTaskWoken != NULL )
3840 xIsHigherPriorityTaskWokenWriteable = xPortIsAuthorizedToAccessBuffer( pxHigherPriorityTaskWoken,
3841 sizeof( BaseType_t ),
3842 tskMPU_WRITE_PERMISSION );
3845 if( ( pxHigherPriorityTaskWoken == NULL ) || ( xIsHigherPriorityTaskWokenWriteable == pdTRUE ) )
3847 lIndex = ( int32_t ) xTimer;
3849 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3851 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3853 if( xInternalTimerHandle != NULL )
3855 xReturn = xTimerGenericCommandFromISR( xInternalTimerHandle, xCommandID, xOptionalValue, pxHigherPriorityTaskWoken, xTicksToWait );
3863 #endif /* if ( configUSE_TIMERS == 1 ) */
3864 /*-----------------------------------------------------------*/
3866 /*-----------------------------------------------------------*/
3867 /* MPU wrappers for event group APIs. */
3868 /*-----------------------------------------------------------*/
3870 EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
3871 const EventBits_t uxBitsToWaitFor,
3872 const BaseType_t xClearOnExit,
3873 const BaseType_t xWaitForAllBits,
3874 TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
3876 EventBits_t xReturn = 0;
3877 xEventGroupWaitBitsParams_t xParams;
3879 xParams.xEventGroup = xEventGroup;
3880 xParams.uxBitsToWaitFor = uxBitsToWaitFor;
3881 xParams.xClearOnExit = xClearOnExit;
3882 xParams.xWaitForAllBits = xWaitForAllBits;
3883 xParams.xTicksToWait = xTicksToWait;
3885 xReturn = MPU_xEventGroupWaitBitsEntry( &( xParams ) );
3890 EventBits_t MPU_xEventGroupWaitBitsImpl( const xEventGroupWaitBitsParams_t * pxParams ) PRIVILEGED_FUNCTION;
3892 EventBits_t MPU_xEventGroupWaitBitsImpl( const xEventGroupWaitBitsParams_t * pxParams ) /* PRIVILEGED_FUNCTION */
3894 EventBits_t xReturn = 0;
3895 EventGroupHandle_t xInternalEventGroupHandle = NULL;
3897 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE;
3898 BaseType_t xAreParamsReadable = pdFALSE;
3900 if( pxParams != NULL )
3902 xAreParamsReadable = xPortIsAuthorizedToAccessBuffer( pxParams,
3903 sizeof( xEventGroupWaitBitsParams_t ),
3904 tskMPU_READ_PERMISSION );
3907 if( xAreParamsReadable == pdTRUE )
3909 if( ( ( pxParams->uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 ) &&
3910 ( pxParams->uxBitsToWaitFor != 0 )
3911 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
3912 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( pxParams->xTicksToWait != 0 ) ) )
3916 lIndex = ( int32_t ) ( pxParams->xEventGroup );
3918 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3920 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3922 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE )
3924 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3926 if( xInternalEventGroupHandle != NULL )
3928 xReturn = xEventGroupWaitBits( xInternalEventGroupHandle,
3929 pxParams->uxBitsToWaitFor,
3930 pxParams->xClearOnExit,
3931 pxParams->xWaitForAllBits,
3932 pxParams->xTicksToWait );
3941 /*-----------------------------------------------------------*/
3943 EventBits_t MPU_xEventGroupClearBitsImpl( EventGroupHandle_t xEventGroup,
3944 const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION;
3946 EventBits_t MPU_xEventGroupClearBitsImpl( EventGroupHandle_t xEventGroup,
3947 const EventBits_t uxBitsToClear ) /* PRIVILEGED_FUNCTION */
3949 EventBits_t xReturn = 0;
3950 EventGroupHandle_t xInternalEventGroupHandle = NULL;
3952 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE;
3954 if( ( uxBitsToClear & eventEVENT_BITS_CONTROL_BYTES ) == 0 )
3956 lIndex = ( int32_t ) xEventGroup;
3958 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3960 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3962 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE )
3964 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3966 if( xInternalEventGroupHandle != NULL )
3968 xReturn = xEventGroupClearBits( xInternalEventGroupHandle, uxBitsToClear );
3976 /*-----------------------------------------------------------*/
3978 EventBits_t MPU_xEventGroupSetBitsImpl( EventGroupHandle_t xEventGroup,
3979 const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION;
3981 EventBits_t MPU_xEventGroupSetBitsImpl( EventGroupHandle_t xEventGroup,
3982 const EventBits_t uxBitsToSet ) /* PRIVILEGED_FUNCTION */
3984 EventBits_t xReturn = 0;
3985 EventGroupHandle_t xInternalEventGroupHandle = NULL;
3987 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE;
3989 if( ( uxBitsToSet & eventEVENT_BITS_CONTROL_BYTES ) == 0 )
3991 lIndex = ( int32_t ) xEventGroup;
3993 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
3995 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
3997 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE )
3999 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4001 if( xInternalEventGroupHandle != NULL )
4003 xReturn = xEventGroupSetBits( xInternalEventGroupHandle, uxBitsToSet );
4011 /*-----------------------------------------------------------*/
4013 EventBits_t MPU_xEventGroupSyncImpl( EventGroupHandle_t xEventGroup,
4014 const EventBits_t uxBitsToSet,
4015 const EventBits_t uxBitsToWaitFor,
4016 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
4018 EventBits_t MPU_xEventGroupSyncImpl( EventGroupHandle_t xEventGroup,
4019 const EventBits_t uxBitsToSet,
4020 const EventBits_t uxBitsToWaitFor,
4021 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
4023 EventBits_t xReturn = 0;
4024 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4026 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE;
4028 if( ( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 ) &&
4029 ( uxBitsToWaitFor != 0 )
4030 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
4031 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) )
4035 lIndex = ( int32_t ) xEventGroup;
4037 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4039 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4041 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE )
4043 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4045 if( xInternalEventGroupHandle != NULL )
4047 xReturn = xEventGroupSync( xInternalEventGroupHandle, uxBitsToSet, uxBitsToWaitFor, xTicksToWait );
4055 /*-----------------------------------------------------------*/
4057 #if ( configUSE_TRACE_FACILITY == 1 )
4059 UBaseType_t MPU_uxEventGroupGetNumberImpl( void * xEventGroup ) PRIVILEGED_FUNCTION;
4061 UBaseType_t MPU_uxEventGroupGetNumberImpl( void * xEventGroup ) /* PRIVILEGED_FUNCTION */
4063 UBaseType_t xReturn = 0;
4064 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4066 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE;
4068 lIndex = ( int32_t ) xEventGroup;
4070 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4072 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4074 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE )
4076 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4078 if( xInternalEventGroupHandle != NULL )
4080 xReturn = uxEventGroupGetNumber( xInternalEventGroupHandle );
4088 #endif /*( configUSE_TRACE_FACILITY == 1 )*/
4089 /*-----------------------------------------------------------*/
4091 #if ( configUSE_TRACE_FACILITY == 1 )
4093 void MPU_vEventGroupSetNumberImpl( void * xEventGroup,
4094 UBaseType_t uxEventGroupNumber ) PRIVILEGED_FUNCTION;
4096 void MPU_vEventGroupSetNumberImpl( void * xEventGroup,
4097 UBaseType_t uxEventGroupNumber ) /* PRIVILEGED_FUNCTION */
4099 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4101 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE;
4103 lIndex = ( int32_t ) xEventGroup;
4105 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4107 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4109 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE )
4111 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4113 if( xInternalEventGroupHandle != NULL )
4115 vEventGroupSetNumber( xInternalEventGroupHandle, uxEventGroupNumber );
4121 #endif /*( configUSE_TRACE_FACILITY == 1 )*/
4122 /*-----------------------------------------------------------*/
4124 /* Privileged only wrappers for Event Group APIs. These are needed so that
4125 * the application can use opaque handles maintained in mpu_wrappers.c
4126 * with all the APIs. */
4127 /*-----------------------------------------------------------*/
4129 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
4131 EventGroupHandle_t MPU_xEventGroupCreate( void ) /* PRIVILEGED_FUNCTION */
4133 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4134 EventGroupHandle_t xExternalEventGroupHandle = NULL;
4137 lIndex = MPU_GetFreeIndexInKernelObjectPool();
4141 xInternalEventGroupHandle = xEventGroupCreate();
4143 if( xInternalEventGroupHandle != NULL )
4145 MPU_StoreEventGroupHandleAtIndex( lIndex, xInternalEventGroupHandle );
4146 xExternalEventGroupHandle = ( EventGroupHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
4150 MPU_SetIndexFreeInKernelObjectPool( lIndex );
4154 return xExternalEventGroupHandle;
4157 #endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) */
4158 /*-----------------------------------------------------------*/
4160 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
4162 EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) /* PRIVILEGED_FUNCTION */
4164 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4165 EventGroupHandle_t xExternalEventGroupHandle = NULL;
4168 lIndex = MPU_GetFreeIndexInKernelObjectPool();
4172 xInternalEventGroupHandle = xEventGroupCreateStatic( pxEventGroupBuffer );
4174 if( xInternalEventGroupHandle != NULL )
4176 MPU_StoreEventGroupHandleAtIndex( lIndex, xInternalEventGroupHandle );
4177 xExternalEventGroupHandle = ( EventGroupHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
4181 MPU_SetIndexFreeInKernelObjectPool( lIndex );
4185 return xExternalEventGroupHandle;
4188 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
4189 /*-----------------------------------------------------------*/
4191 void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) /* PRIVILEGED_FUNCTION */
4193 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4196 lIndex = ( int32_t ) xEventGroup;
4198 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4200 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4202 if( xInternalEventGroupHandle != NULL )
4204 vEventGroupDelete( xInternalEventGroupHandle );
4205 MPU_SetIndexFreeInKernelObjectPool( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4209 /*-----------------------------------------------------------*/
4211 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
4213 BaseType_t MPU_xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup,
4214 StaticEventGroup_t ** ppxEventGroupBuffer ) /* PRIVILEGED_FUNCTION */
4216 BaseType_t xReturn = pdFALSE;
4217 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4220 lIndex = ( int32_t ) xEventGroup;
4222 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4224 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4226 if( xInternalEventGroupHandle != NULL )
4228 xReturn = xEventGroupGetStaticBuffer( xInternalEventGroupHandle, ppxEventGroupBuffer );
4235 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
4236 /*-----------------------------------------------------------*/
4238 #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )
4240 BaseType_t MPU_xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup,
4241 const EventBits_t uxBitsToClear ) /* PRIVILEGED_FUNCTION */
4243 BaseType_t xReturn = pdFALSE;
4244 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4247 lIndex = ( int32_t ) xEventGroup;
4249 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4251 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4253 if( xInternalEventGroupHandle != NULL )
4255 xReturn = xEventGroupClearBitsFromISR( xInternalEventGroupHandle, uxBitsToClear );
4262 #endif /* #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) ) */
4263 /*-----------------------------------------------------------*/
4265 #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )
4267 BaseType_t MPU_xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup,
4268 const EventBits_t uxBitsToSet,
4269 BaseType_t * pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
4271 BaseType_t xReturn = pdFALSE;
4272 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4275 lIndex = ( int32_t ) xEventGroup;
4277 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4279 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4281 if( xInternalEventGroupHandle != NULL )
4283 xReturn = xEventGroupSetBitsFromISR( xInternalEventGroupHandle, uxBitsToSet, pxHigherPriorityTaskWoken );
4290 #endif /* #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) ) */
4291 /*-----------------------------------------------------------*/
4293 EventBits_t MPU_xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ) /* PRIVILEGED_FUNCTION */
4295 EventBits_t xReturn = 0;
4296 EventGroupHandle_t xInternalEventGroupHandle = NULL;
4299 lIndex = ( int32_t ) xEventGroup;
4301 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4303 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4305 if( xInternalEventGroupHandle != NULL )
4307 xReturn = xEventGroupGetBitsFromISR( xInternalEventGroupHandle );
4313 /*-----------------------------------------------------------*/
4315 /*-----------------------------------------------------------*/
4316 /* MPU wrappers for stream buffer APIs. */
4317 /*-----------------------------------------------------------*/
4319 size_t MPU_xStreamBufferSendImpl( StreamBufferHandle_t xStreamBuffer,
4320 const void * pvTxData,
4321 size_t xDataLengthBytes,
4322 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
4324 size_t MPU_xStreamBufferSendImpl( StreamBufferHandle_t xStreamBuffer,
4325 const void * pvTxData,
4326 size_t xDataLengthBytes,
4327 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
4330 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4332 BaseType_t xIsTxDataBufferReadable = pdFALSE;
4333 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4335 if( pvTxData != NULL )
4337 xIsTxDataBufferReadable = xPortIsAuthorizedToAccessBuffer( pvTxData,
4339 tskMPU_READ_PERMISSION );
4341 if( xIsTxDataBufferReadable == pdTRUE )
4343 lIndex = ( int32_t ) xStreamBuffer;
4345 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4347 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4349 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4351 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4353 if( xInternalStreamBufferHandle != NULL )
4355 xReturn = xStreamBufferSend( xInternalStreamBufferHandle, pvTxData, xDataLengthBytes, xTicksToWait );
4364 /*-----------------------------------------------------------*/
4366 size_t MPU_xStreamBufferReceiveImpl( StreamBufferHandle_t xStreamBuffer,
4368 size_t xBufferLengthBytes,
4369 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
4371 size_t MPU_xStreamBufferReceiveImpl( StreamBufferHandle_t xStreamBuffer,
4373 size_t xBufferLengthBytes,
4374 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
4377 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4379 BaseType_t xIsRxDataBufferWriteable = pdFALSE;
4380 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4382 if( pvRxData != NULL )
4384 xIsRxDataBufferWriteable = xPortIsAuthorizedToAccessBuffer( pvRxData,
4386 tskMPU_WRITE_PERMISSION );
4388 if( xIsRxDataBufferWriteable == pdTRUE )
4390 lIndex = ( int32_t ) xStreamBuffer;
4392 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4394 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4396 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4398 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4400 if( xInternalStreamBufferHandle != NULL )
4402 xReturn = xStreamBufferReceive( xInternalStreamBufferHandle, pvRxData, xBufferLengthBytes, xTicksToWait );
4411 /*-----------------------------------------------------------*/
4413 BaseType_t MPU_xStreamBufferIsFullImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
4415 BaseType_t MPU_xStreamBufferIsFullImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4417 BaseType_t xReturn = pdFALSE;
4418 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4420 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4422 lIndex = ( int32_t ) xStreamBuffer;
4424 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4426 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4428 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4430 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4432 if( xInternalStreamBufferHandle != NULL )
4434 xReturn = xStreamBufferIsFull( xInternalStreamBufferHandle );
4441 /*-----------------------------------------------------------*/
4443 BaseType_t MPU_xStreamBufferIsEmptyImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
4445 BaseType_t MPU_xStreamBufferIsEmptyImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4447 BaseType_t xReturn = pdFALSE;
4448 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4450 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4452 lIndex = ( int32_t ) xStreamBuffer;
4454 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4456 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4458 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4460 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4462 if( xInternalStreamBufferHandle != NULL )
4464 xReturn = xStreamBufferIsEmpty( xInternalStreamBufferHandle );
4471 /*-----------------------------------------------------------*/
4473 size_t MPU_xStreamBufferSpacesAvailableImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
4475 size_t MPU_xStreamBufferSpacesAvailableImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4478 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4480 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4482 lIndex = ( int32_t ) xStreamBuffer;
4484 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4486 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4488 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4490 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4492 if( xInternalStreamBufferHandle != NULL )
4494 xReturn = xStreamBufferSpacesAvailable( xInternalStreamBufferHandle );
4501 /*-----------------------------------------------------------*/
4503 size_t MPU_xStreamBufferBytesAvailableImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
4505 size_t MPU_xStreamBufferBytesAvailableImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4508 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4510 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4512 lIndex = ( int32_t ) xStreamBuffer;
4514 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4516 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4518 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4520 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4522 if( xInternalStreamBufferHandle != NULL )
4524 xReturn = xStreamBufferBytesAvailable( xInternalStreamBufferHandle );
4531 /*-----------------------------------------------------------*/
4533 BaseType_t MPU_xStreamBufferSetTriggerLevelImpl( StreamBufferHandle_t xStreamBuffer,
4534 size_t xTriggerLevel ) PRIVILEGED_FUNCTION;
4536 BaseType_t MPU_xStreamBufferSetTriggerLevelImpl( StreamBufferHandle_t xStreamBuffer,
4537 size_t xTriggerLevel ) /* PRIVILEGED_FUNCTION */
4539 BaseType_t xReturn = pdFALSE;
4540 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4542 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4544 lIndex = ( int32_t ) xStreamBuffer;
4546 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4548 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4550 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4552 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4554 if( xInternalStreamBufferHandle != NULL )
4556 xReturn = xStreamBufferSetTriggerLevel( xInternalStreamBufferHandle, xTriggerLevel );
4563 /*-----------------------------------------------------------*/
4565 size_t MPU_xStreamBufferNextMessageLengthBytesImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
4567 size_t MPU_xStreamBufferNextMessageLengthBytesImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4570 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4572 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE;
4574 lIndex = ( int32_t ) xStreamBuffer;
4576 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4578 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4580 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE )
4582 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4584 if( xInternalStreamBufferHandle != NULL )
4586 xReturn = xStreamBufferNextMessageLengthBytes( xInternalStreamBufferHandle );
4593 /*-----------------------------------------------------------*/
4595 /* Privileged only wrappers for Stream Buffer APIs. These are needed so that
4596 * the application can use opaque handles maintained in mpu_wrappers.c
4597 * with all the APIs. */
4598 /*-----------------------------------------------------------*/
4600 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
4602 StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes,
4603 size_t xTriggerLevelBytes,
4604 BaseType_t xIsMessageBuffer,
4605 StreamBufferCallbackFunction_t pxSendCompletedCallback,
4606 StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) /* PRIVILEGED_FUNCTION */
4608 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4609 StreamBufferHandle_t xExternalStreamBufferHandle = NULL;
4613 * Stream buffer application level callback functionality is disabled for MPU
4616 configASSERT( ( pxSendCompletedCallback == NULL ) &&
4617 ( pxReceiveCompletedCallback == NULL ) );
4619 if( ( pxSendCompletedCallback == NULL ) &&
4620 ( pxReceiveCompletedCallback == NULL ) )
4622 lIndex = MPU_GetFreeIndexInKernelObjectPool();
4626 xInternalStreamBufferHandle = xStreamBufferGenericCreate( xBufferSizeBytes,
4632 if( xInternalStreamBufferHandle != NULL )
4634 MPU_StoreStreamBufferHandleAtIndex( lIndex, xInternalStreamBufferHandle );
4635 xExternalStreamBufferHandle = ( StreamBufferHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
4639 MPU_SetIndexFreeInKernelObjectPool( lIndex );
4645 traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer );
4646 xExternalStreamBufferHandle = NULL;
4649 return xExternalStreamBufferHandle;
4652 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
4653 /*-----------------------------------------------------------*/
4655 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
4657 StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
4658 size_t xTriggerLevelBytes,
4659 BaseType_t xIsMessageBuffer,
4660 uint8_t * const pucStreamBufferStorageArea,
4661 StaticStreamBuffer_t * const pxStaticStreamBuffer,
4662 StreamBufferCallbackFunction_t pxSendCompletedCallback,
4663 StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) /* PRIVILEGED_FUNCTION */
4665 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4666 StreamBufferHandle_t xExternalStreamBufferHandle = NULL;
4670 * Stream buffer application level callback functionality is disabled for MPU
4673 configASSERT( ( pxSendCompletedCallback == NULL ) &&
4674 ( pxReceiveCompletedCallback == NULL ) );
4676 if( ( pxSendCompletedCallback == NULL ) &&
4677 ( pxReceiveCompletedCallback == NULL ) )
4679 lIndex = MPU_GetFreeIndexInKernelObjectPool();
4683 xInternalStreamBufferHandle = xStreamBufferGenericCreateStatic( xBufferSizeBytes,
4686 pucStreamBufferStorageArea,
4687 pxStaticStreamBuffer,
4691 if( xInternalStreamBufferHandle != NULL )
4693 MPU_StoreStreamBufferHandleAtIndex( lIndex, xInternalStreamBufferHandle );
4694 xExternalStreamBufferHandle = ( StreamBufferHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex );
4698 MPU_SetIndexFreeInKernelObjectPool( lIndex );
4704 traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer );
4705 xExternalStreamBufferHandle = NULL;
4708 return xExternalStreamBufferHandle;
4711 #endif /* configSUPPORT_STATIC_ALLOCATION */
4712 /*-----------------------------------------------------------*/
4714 void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4716 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4719 lIndex = ( int32_t ) xStreamBuffer;
4721 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4723 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4725 if( xInternalStreamBufferHandle != NULL )
4727 vStreamBufferDelete( xInternalStreamBufferHandle );
4730 MPU_SetIndexFreeInKernelObjectPool( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4733 /*-----------------------------------------------------------*/
4735 BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */
4737 BaseType_t xReturn = pdFALSE;
4738 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4741 lIndex = ( int32_t ) xStreamBuffer;
4743 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4745 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4747 if( xInternalStreamBufferHandle != NULL )
4749 xReturn = xStreamBufferReset( xInternalStreamBufferHandle );
4755 /*-----------------------------------------------------------*/
4757 #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
4759 BaseType_t MPU_xStreamBufferGetStaticBuffers( StreamBufferHandle_t xStreamBuffers,
4760 uint8_t * ppucStreamBufferStorageArea,
4761 StaticStreamBuffer_t * ppxStaticStreamBuffer ) /* PRIVILEGED_FUNCTION */
4763 BaseType_t xReturn = pdFALSE;
4764 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4767 lIndex = ( int32_t ) xStreamBuffers;
4769 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4771 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4773 if( xInternalStreamBufferHandle != NULL )
4775 xReturn = MPU_xStreamBufferGetStaticBuffers( xInternalStreamBufferHandle, ppucStreamBufferStorageArea, ppxStaticStreamBuffer );
4782 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
4783 /*-----------------------------------------------------------*/
4785 size_t MPU_xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer,
4786 const void * pvTxData,
4787 size_t xDataLengthBytes,
4788 BaseType_t * const pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
4791 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4794 lIndex = ( int32_t ) xStreamBuffer;
4796 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4798 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4800 if( xInternalStreamBufferHandle != NULL )
4802 xReturn = xStreamBufferSendFromISR( xInternalStreamBufferHandle, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken );
4808 /*-----------------------------------------------------------*/
4810 size_t MPU_xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer,
4812 size_t xBufferLengthBytes,
4813 BaseType_t * const pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
4816 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4819 lIndex = ( int32_t ) xStreamBuffer;
4821 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4823 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4825 if( xInternalStreamBufferHandle != NULL )
4827 xReturn = xStreamBufferReceiveFromISR( xInternalStreamBufferHandle, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken );
4833 /*-----------------------------------------------------------*/
4835 BaseType_t MPU_xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer,
4836 BaseType_t * pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */
4838 BaseType_t xReturn = pdFALSE;
4839 StreamBufferHandle_t xInternalStreamBufferHandle = NULL;
4842 lIndex = ( int32_t ) xStreamBuffer;
4844 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
4846 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
4848 if( xInternalStreamBufferHandle != NULL )
4850 xReturn = xStreamBufferSendCompletedFromISR( xInternalStreamBufferHandle, pxHigherPriorityTaskWoken );
4856 /*-----------------------------------------------------------*/
4858 BaseType_t MPU_xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer,
4859 BaseType_t * pxHigherPriorityTaskWoken ) /*PRIVILEGED_FUNCTION */
4861 BaseType_t xReturn = pdFALSE;
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 = xStreamBufferReceiveCompletedFromISR( xInternalStreamBufferHandle, pxHigherPriorityTaskWoken );
4880 /*-----------------------------------------------------------*/
4882 /* Functions that the application writer wants to execute in privileged mode
4883 * can be defined in application_defined_privileged_functions.h. */
4885 #if configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS == 1
4886 #include "application_defined_privileged_functions.h"
4888 /*-----------------------------------------------------------*/
4891 * @brief Array of system call implementation functions.
4893 * The index in the array MUST match the corresponding system call number
4894 * defined in mpu_wrappers.h.
4896 PRIVILEGED_DATA UBaseType_t uxSystemCallImplementations[ NUM_SYSTEM_CALLS ] =
4898 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
4899 ( UBaseType_t ) MPU_xTaskGenericNotifyImpl, /* SYSTEM_CALL_xTaskGenericNotify. */
4900 ( UBaseType_t ) MPU_xTaskGenericNotifyWaitImpl, /* SYSTEM_CALL_xTaskGenericNotifyWait. */
4902 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGenericNotify. */
4903 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGenericNotifyWait. */
4906 #if ( configUSE_TIMERS == 1 )
4907 ( UBaseType_t ) MPU_xTimerGenericCommandFromTaskImpl, /* SYSTEM_CALL_xTimerGenericCommandFromTask. */
4909 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGenericCommandFromTask. */
4912 ( UBaseType_t ) MPU_xEventGroupWaitBitsImpl, /* SYSTEM_CALL_xEventGroupWaitBits. */
4914 /* The system calls above this line take 5 parameters. */
4916 #if ( INCLUDE_xTaskDelayUntil == 1 )
4917 ( UBaseType_t ) MPU_xTaskDelayUntilImpl, /* SYSTEM_CALL_xTaskDelayUntil. */
4919 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskDelayUntil. */
4922 #if ( INCLUDE_xTaskAbortDelay == 1 )
4923 ( UBaseType_t ) MPU_xTaskAbortDelayImpl, /* SYSTEM_CALL_xTaskAbortDelay. */
4925 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskAbortDelay. */
4928 #if ( INCLUDE_vTaskDelay == 1 )
4929 ( UBaseType_t ) MPU_vTaskDelayImpl, /* SYSTEM_CALL_vTaskDelay. */
4931 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskDelay. */
4934 #if ( INCLUDE_uxTaskPriorityGet == 1 )
4935 ( UBaseType_t ) MPU_uxTaskPriorityGetImpl, /* SYSTEM_CALL_uxTaskPriorityGet. */
4937 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTaskPriorityGet. */
4940 #if ( INCLUDE_eTaskGetState == 1 )
4941 ( UBaseType_t ) MPU_eTaskGetStateImpl, /* SYSTEM_CALL_eTaskGetState. */
4943 ( UBaseType_t ) 0, /* SYSTEM_CALL_eTaskGetState. */
4946 #if ( configUSE_TRACE_FACILITY == 1 )
4947 ( UBaseType_t ) MPU_vTaskGetInfoImpl, /* SYSTEM_CALL_vTaskGetInfo. */
4949 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskGetInfo. */
4952 #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
4953 ( UBaseType_t ) MPU_xTaskGetIdleTaskHandleImpl, /* SYSTEM_CALL_xTaskGetIdleTaskHandle. */
4955 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGetIdleTaskHandle. */
4958 #if ( INCLUDE_vTaskSuspend == 1 )
4959 ( UBaseType_t ) MPU_vTaskSuspendImpl, /* SYSTEM_CALL_vTaskSuspend. */
4960 ( UBaseType_t ) MPU_vTaskResumeImpl, /* SYSTEM_CALL_vTaskResume. */
4962 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskSuspend. */
4963 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskResume. */
4966 ( UBaseType_t ) MPU_xTaskGetTickCountImpl, /* SYSTEM_CALL_xTaskGetTickCount. */
4967 ( UBaseType_t ) MPU_uxTaskGetNumberOfTasksImpl, /* SYSTEM_CALL_uxTaskGetNumberOfTasks. */
4969 #if ( configGENERATE_RUN_TIME_STATS == 1 )
4970 ( UBaseType_t ) MPU_ulTaskGetRunTimeCounterImpl, /* SYSTEM_CALL_ulTaskGetRunTimeCounter. */
4971 ( UBaseType_t ) MPU_ulTaskGetRunTimePercentImpl, /* SYSTEM_CALL_ulTaskGetRunTimePercent. */
4973 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGetRunTimeCounter. */
4974 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGetRunTimePercent. */
4977 #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) )
4978 ( UBaseType_t ) MPU_ulTaskGetIdleRunTimePercentImpl, /* SYSTEM_CALL_ulTaskGetIdleRunTimePercent. */
4979 ( UBaseType_t ) MPU_ulTaskGetIdleRunTimeCounterImpl, /* SYSTEM_CALL_ulTaskGetIdleRunTimeCounter. */
4981 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGetIdleRunTimePercent. */
4982 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGetIdleRunTimeCounter. */
4985 #if ( configUSE_APPLICATION_TASK_TAG == 1 )
4986 ( UBaseType_t ) MPU_vTaskSetApplicationTaskTagImpl, /* SYSTEM_CALL_vTaskSetApplicationTaskTag. */
4987 ( UBaseType_t ) MPU_xTaskGetApplicationTaskTagImpl, /* SYSTEM_CALL_xTaskGetApplicationTaskTag. */
4989 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskSetApplicationTaskTag. */
4990 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGetApplicationTaskTag. */
4993 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
4994 ( UBaseType_t ) MPU_vTaskSetThreadLocalStoragePointerImpl, /* SYSTEM_CALL_vTaskSetThreadLocalStoragePointer. */
4995 ( UBaseType_t ) MPU_pvTaskGetThreadLocalStoragePointerImpl, /* SYSTEM_CALL_pvTaskGetThreadLocalStoragePointer. */
4997 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskSetThreadLocalStoragePointer. */
4998 ( UBaseType_t ) 0, /* SYSTEM_CALL_pvTaskGetThreadLocalStoragePointer. */
5001 #if ( configUSE_TRACE_FACILITY == 1 )
5002 ( UBaseType_t ) MPU_uxTaskGetSystemStateImpl, /* SYSTEM_CALL_uxTaskGetSystemState. */
5004 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTaskGetSystemState. */
5007 #if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )
5008 ( UBaseType_t ) MPU_uxTaskGetStackHighWaterMarkImpl, /* SYSTEM_CALL_uxTaskGetStackHighWaterMark. */
5010 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTaskGetStackHighWaterMark. */
5013 #if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 )
5014 ( UBaseType_t ) MPU_uxTaskGetStackHighWaterMark2Impl, /* SYSTEM_CALL_uxTaskGetStackHighWaterMark2. */
5016 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTaskGetStackHighWaterMark2. */
5019 #if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) )
5020 ( UBaseType_t ) MPU_xTaskGetCurrentTaskHandleImpl, /* SYSTEM_CALL_xTaskGetCurrentTaskHandle. */
5022 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGetCurrentTaskHandle. */
5025 #if ( INCLUDE_xTaskGetSchedulerState == 1 )
5026 ( UBaseType_t ) MPU_xTaskGetSchedulerStateImpl, /* SYSTEM_CALL_xTaskGetSchedulerState. */
5028 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGetSchedulerState. */
5031 ( UBaseType_t ) MPU_vTaskSetTimeOutStateImpl, /* SYSTEM_CALL_vTaskSetTimeOutState. */
5032 ( UBaseType_t ) MPU_xTaskCheckForTimeOutImpl, /* SYSTEM_CALL_xTaskCheckForTimeOut. */
5034 #if ( configUSE_TASK_NOTIFICATIONS == 1 )
5035 ( UBaseType_t ) MPU_ulTaskGenericNotifyTakeImpl, /* SYSTEM_CALL_ulTaskGenericNotifyTake. */
5036 ( UBaseType_t ) MPU_xTaskGenericNotifyStateClearImpl, /* SYSTEM_CALL_xTaskGenericNotifyStateClear. */
5037 ( UBaseType_t ) MPU_ulTaskGenericNotifyValueClearImpl, /* SYSTEM_CALL_ulTaskGenericNotifyValueClear. */
5039 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGenericNotifyTake. */
5040 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGenericNotifyStateClear. */
5041 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGenericNotifyValueClear. */
5044 ( UBaseType_t ) MPU_xQueueGenericSendImpl, /* SYSTEM_CALL_xQueueGenericSend. */
5045 ( UBaseType_t ) MPU_uxQueueMessagesWaitingImpl, /* SYSTEM_CALL_uxQueueMessagesWaiting. */
5046 ( UBaseType_t ) MPU_uxQueueSpacesAvailableImpl, /* SYSTEM_CALL_uxQueueSpacesAvailable. */
5047 ( UBaseType_t ) MPU_xQueueReceiveImpl, /* SYSTEM_CALL_xQueueReceive. */
5048 ( UBaseType_t ) MPU_xQueuePeekImpl, /* SYSTEM_CALL_xQueuePeek. */
5049 ( UBaseType_t ) MPU_xQueueSemaphoreTakeImpl, /* SYSTEM_CALL_xQueueSemaphoreTake. */
5051 #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )
5052 ( UBaseType_t ) MPU_xQueueGetMutexHolderImpl, /* SYSTEM_CALL_xQueueGetMutexHolder. */
5054 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueGetMutexHolder. */
5057 #if ( configUSE_RECURSIVE_MUTEXES == 1 )
5058 ( UBaseType_t ) MPU_xQueueTakeMutexRecursiveImpl, /* SYSTEM_CALL_xQueueTakeMutexRecursive. */
5059 ( UBaseType_t ) MPU_xQueueGiveMutexRecursiveImpl, /* SYSTEM_CALL_xQueueGiveMutexRecursive. */
5061 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueTakeMutexRecursive. */
5062 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueGiveMutexRecursive. */
5065 #if ( configUSE_QUEUE_SETS == 1 )
5066 ( UBaseType_t ) MPU_xQueueSelectFromSetImpl, /* SYSTEM_CALL_xQueueSelectFromSet. */
5067 ( UBaseType_t ) MPU_xQueueAddToSetImpl, /* SYSTEM_CALL_xQueueAddToSet. */
5069 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueSelectFromSet. */
5070 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueAddToSet. */
5073 #if configQUEUE_REGISTRY_SIZE > 0
5074 ( UBaseType_t ) MPU_vQueueAddToRegistryImpl, /* SYSTEM_CALL_vQueueAddToRegistry. */
5075 ( UBaseType_t ) MPU_vQueueUnregisterQueueImpl, /* SYSTEM_CALL_vQueueUnregisterQueue. */
5076 ( UBaseType_t ) MPU_pcQueueGetNameImpl, /* SYSTEM_CALL_pcQueueGetName. */
5078 ( UBaseType_t ) 0, /* SYSTEM_CALL_vQueueAddToRegistry. */
5079 ( UBaseType_t ) 0, /* SYSTEM_CALL_vQueueUnregisterQueue. */
5080 ( UBaseType_t ) 0, /* SYSTEM_CALL_pcQueueGetName. */
5083 #if ( configUSE_TIMERS == 1 )
5084 ( UBaseType_t ) MPU_pvTimerGetTimerIDImpl, /* SYSTEM_CALL_pvTimerGetTimerID. */
5085 ( UBaseType_t ) MPU_vTimerSetTimerIDImpl, /* SYSTEM_CALL_vTimerSetTimerID. */
5086 ( UBaseType_t ) MPU_xTimerIsTimerActiveImpl, /* SYSTEM_CALL_xTimerIsTimerActive. */
5087 ( UBaseType_t ) MPU_xTimerGetTimerDaemonTaskHandleImpl, /* SYSTEM_CALL_xTimerGetTimerDaemonTaskHandle. */
5088 ( UBaseType_t ) MPU_pcTimerGetNameImpl, /* SYSTEM_CALL_pcTimerGetName. */
5089 ( UBaseType_t ) MPU_vTimerSetReloadModeImpl, /* SYSTEM_CALL_vTimerSetReloadMode. */
5090 ( UBaseType_t ) MPU_xTimerGetReloadModeImpl, /* SYSTEM_CALL_xTimerGetReloadMode. */
5091 ( UBaseType_t ) MPU_uxTimerGetReloadModeImpl, /* SYSTEM_CALL_uxTimerGetReloadMode. */
5092 ( UBaseType_t ) MPU_xTimerGetPeriodImpl, /* SYSTEM_CALL_xTimerGetPeriod. */
5093 ( UBaseType_t ) MPU_xTimerGetExpiryTimeImpl, /* SYSTEM_CALL_xTimerGetExpiryTime. */
5095 ( UBaseType_t ) 0, /* SYSTEM_CALL_pvTimerGetTimerID. */
5096 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTimerSetTimerID. */
5097 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerIsTimerActive. */
5098 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGetTimerDaemonTaskHandle. */
5099 ( UBaseType_t ) 0, /* SYSTEM_CALL_pcTimerGetName. */
5100 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTimerSetReloadMode. */
5101 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGetReloadMode. */
5102 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTimerGetReloadMode. */
5103 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGetPeriod. */
5104 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGetExpiryTime. */
5107 ( UBaseType_t ) MPU_xEventGroupClearBitsImpl, /* SYSTEM_CALL_xEventGroupClearBits. */
5108 ( UBaseType_t ) MPU_xEventGroupSetBitsImpl, /* SYSTEM_CALL_xEventGroupSetBits. */
5109 ( UBaseType_t ) MPU_xEventGroupSyncImpl, /* SYSTEM_CALL_xEventGroupSync. */
5111 #if ( configUSE_TRACE_FACILITY == 1 )
5112 ( UBaseType_t ) MPU_uxEventGroupGetNumberImpl, /* SYSTEM_CALL_uxEventGroupGetNumber. */
5113 ( UBaseType_t ) MPU_vEventGroupSetNumberImpl, /* SYSTEM_CALL_vEventGroupSetNumber. */
5115 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxEventGroupGetNumber. */
5116 ( UBaseType_t ) 0, /* SYSTEM_CALL_vEventGroupSetNumber. */
5119 ( UBaseType_t ) MPU_xStreamBufferSendImpl, /* SYSTEM_CALL_xStreamBufferSend. */
5120 ( UBaseType_t ) MPU_xStreamBufferReceiveImpl, /* SYSTEM_CALL_xStreamBufferReceive. */
5121 ( UBaseType_t ) MPU_xStreamBufferIsFullImpl, /* SYSTEM_CALL_xStreamBufferIsFull. */
5122 ( UBaseType_t ) MPU_xStreamBufferIsEmptyImpl, /* SYSTEM_CALL_xStreamBufferIsEmpty. */
5123 ( UBaseType_t ) MPU_xStreamBufferSpacesAvailableImpl, /* SYSTEM_CALL_xStreamBufferSpacesAvailable. */
5124 ( UBaseType_t ) MPU_xStreamBufferBytesAvailableImpl, /* SYSTEM_CALL_xStreamBufferBytesAvailable. */
5125 ( UBaseType_t ) MPU_xStreamBufferSetTriggerLevelImpl, /* SYSTEM_CALL_xStreamBufferSetTriggerLevel. */
5126 ( UBaseType_t ) MPU_xStreamBufferNextMessageLengthBytesImpl /* SYSTEM_CALL_xStreamBufferNextMessageLengthBytes. */
5128 /*-----------------------------------------------------------*/
5130 #endif /* #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) ) */
5131 /*-----------------------------------------------------------*/