1 /* 2 * FreeRTOS Kernel V10.6.2 3 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. 4 * 5 * SPDX-License-Identifier: MIT 6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy of 8 * this software and associated documentation files (the "Software"), to deal in 9 * the Software without restriction, including without limitation the rights to 10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 * the Software, and to permit persons to whom the Software is furnished to do so, 12 * subject to the following conditions: 13 * 14 * The above copyright notice and this permission notice shall be included in all 15 * copies or substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 * 24 * https://www.FreeRTOS.org 25 * https://github.com/FreeRTOS 26 * 27 */ 28 29 /* 30 * Implementation of the wrapper functions used to raise the processor privilege 31 * before calling a standard FreeRTOS API function. 32 */ 33 34 /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining 35 * all the API functions to use the MPU wrappers. That should only be done when 36 * task.h is included from an application file. */ 37 #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE 38 39 /* Scheduler includes. */ 40 #include "FreeRTOS.h" 41 #include "task.h" 42 #include "queue.h" 43 #include "timers.h" 44 #include "event_groups.h" 45 #include "stream_buffer.h" 46 #include "mpu_prototypes.h" 47 #include "mpu_syscall_numbers.h" 48 49 #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE 50 /*-----------------------------------------------------------*/ 51 52 #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) ) 53 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. 56 #endif 57 58 /** 59 * @brief Offset added to the index before returning to the user. 60 * 61 * If the actual handle is stored at index i, ( i + INDEX_OFFSET ) 62 * is returned to the user. 63 */ 64 #define INDEX_OFFSET 1 65 66 /** 67 * @brief Opaque type for a kernel object. 68 */ 69 struct OpaqueObject; 70 typedef struct OpaqueObject * OpaqueObjectHandle_t; 71 72 /** 73 * @brief Defines kernel object in the kernel object pool. 74 */ 75 typedef struct KernelObject 76 { 77 OpaqueObjectHandle_t xInternalObjectHandle; 78 uint32_t ulKernelObjectType; 79 void * pvKernelObjectData; 80 } KernelObject_t; 81 82 /** 83 * @brief Kernel object types. 84 */ 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 ) 91 92 /** 93 * @brief Checks whether an external index is valid or not. 94 */ 95 #define IS_EXTERNAL_INDEX_VALID( lIndex ) \ 96 ( ( ( lIndex ) >= INDEX_OFFSET ) && \ 97 ( ( lIndex ) < ( configPROTECTED_KERNEL_OBJECT_POOL_SIZE + INDEX_OFFSET ) ) ) 98 99 /** 100 * @brief Checks whether an internal index is valid or not. 101 */ 102 #define IS_INTERNAL_INDEX_VALID( lIndex ) \ 103 ( ( ( lIndex ) >= 0 ) && \ 104 ( ( lIndex ) < ( configPROTECTED_KERNEL_OBJECT_POOL_SIZE ) ) ) 105 106 /** 107 * @brief Converts an internal index into external. 108 */ 109 #define CONVERT_TO_EXTERNAL_INDEX( lIndex ) ( ( lIndex ) + INDEX_OFFSET ) 110 111 /** 112 * @brief Converts an external index into internal. 113 */ 114 #define CONVERT_TO_INTERNAL_INDEX( lIndex ) ( ( lIndex ) - INDEX_OFFSET ) 115 116 /** 117 * @brief Max value that fits in a uint32_t type. 118 */ 119 #define mpuUINT32_MAX ( ~( ( uint32_t ) 0 ) ) 120 121 /** 122 * @brief Check if multiplying a and b will result in overflow. 123 */ 124 #define mpuMULTIPLY_UINT32_WILL_OVERFLOW( a, b ) ( ( ( a ) > 0 ) && ( ( b ) > ( mpuUINT32_MAX / ( a ) ) ) ) 125 126 /** 127 * @brief Get the index of a free slot in the kernel object pool. 128 * 129 * If a free slot is found, this function marks the slot as 130 * "not free". 131 * 132 * @return Index of a free slot is returned, if a free slot is 133 * found. Otherwise -1 is returned. 134 */ 135 static int32_t MPU_GetFreeIndexInKernelObjectPool( void ) PRIVILEGED_FUNCTION; 136 137 /** 138 * @brief Set the given index as free in the kernel object pool. 139 * 140 * @param lIndex The index to set as free. 141 */ 142 static void MPU_SetIndexFreeInKernelObjectPool( int32_t lIndex ) PRIVILEGED_FUNCTION; 143 144 /** 145 * @brief Get the index at which a given kernel object is stored. 146 * 147 * @param xHandle The given kernel object handle. 148 * @param ulKernelObjectType The kernel object type. 149 * 150 * @return Index at which the kernel object is stored if it is a valid 151 * handle, -1 otherwise. 152 */ 153 static int32_t MPU_GetIndexForHandle( OpaqueObjectHandle_t xHandle, 154 uint32_t ulKernelObjectType ) PRIVILEGED_FUNCTION; 155 156 /** 157 * @brief Store the given kernel object handle at the given index in 158 * the kernel object pool. 159 * 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. 165 */ 166 static void MPU_StoreHandleAndDataAtIndex( int32_t lIndex, 167 OpaqueObjectHandle_t xHandle, 168 void * pvKernelObjectData, 169 uint32_t ulKernelObjectType ) PRIVILEGED_FUNCTION; 170 171 /** 172 * @brief Get the kernel object handle at the given index from 173 * the kernel object pool. 174 * 175 * @param lIndex Index at which to get the kernel object handle. 176 * @param ulKernelObjectType The kernel object type. 177 * 178 * @return The kernel object handle at the index. 179 */ 180 static OpaqueObjectHandle_t MPU_GetHandleAtIndex( int32_t lIndex, 181 uint32_t ulKernelObjectType ) PRIVILEGED_FUNCTION; 182 183 #if ( configUSE_TIMERS == 1 ) 184 185 /** 186 * @brief The function registered as callback for all the timers. 187 * 188 * We intercept all the timer callbacks so that we can call application 189 * callbacks with opaque handle. 190 * 191 * @param xInternalHandle The internal timer handle. 192 */ 193 static void MPU_TimerCallback( TimerHandle_t xInternalHandle ) PRIVILEGED_FUNCTION; 194 195 #endif /* #if ( configUSE_TIMERS == 1 ) */ 196 197 /* 198 * Wrappers to keep all the casting in one place. 199 */ 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 ) 202 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 ) 209 #endif 210 211 /* 212 * Wrappers to keep all the casting in one place for Task APIs. 213 */ 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 ) 217 218 /* 219 * Wrappers to keep all the casting in one place for Event Group APIs. 220 */ 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 ) 224 225 /* 226 * Wrappers to keep all the casting in one place for Stream Buffer APIs. 227 */ 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 ) 231 232 #if ( configUSE_TIMERS == 1 ) 233 234 /* 235 * Wrappers to keep all the casting in one place for Timer APIs. 236 */ 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 ) 240 241 #endif /* #if ( configUSE_TIMERS == 1 ) */ 242 243 /*-----------------------------------------------------------*/ 244 245 /** 246 * @brief Kernel object pool. 247 */ 248 PRIVILEGED_DATA static KernelObject_t xKernelObjectPool[ configPROTECTED_KERNEL_OBJECT_POOL_SIZE ] = { NULL }; 249 /*-----------------------------------------------------------*/ 250 MPU_GetFreeIndexInKernelObjectPool(void)251 static int32_t MPU_GetFreeIndexInKernelObjectPool( void ) /* PRIVILEGED_FUNCTION */ 252 { 253 int32_t i, lFreeIndex = -1; 254 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. */ 259 vTaskSuspendAll(); 260 { 261 for( i = 0; i < configPROTECTED_KERNEL_OBJECT_POOL_SIZE; i++ ) 262 { 263 if( xKernelObjectPool[ i ].xInternalObjectHandle == NULL ) 264 { 265 /* Mark this index as not free. */ 266 xKernelObjectPool[ i ].xInternalObjectHandle = ( OpaqueObjectHandle_t ) ( ~0 ); 267 lFreeIndex = i; 268 break; 269 } 270 } 271 } 272 xTaskResumeAll(); 273 274 return lFreeIndex; 275 } 276 /*-----------------------------------------------------------*/ 277 MPU_SetIndexFreeInKernelObjectPool(int32_t lIndex)278 static void MPU_SetIndexFreeInKernelObjectPool( int32_t lIndex ) /* PRIVILEGED_FUNCTION */ 279 { 280 configASSERT( IS_INTERNAL_INDEX_VALID( lIndex ) != pdFALSE ); 281 282 taskENTER_CRITICAL(); 283 { 284 xKernelObjectPool[ lIndex ].xInternalObjectHandle = NULL; 285 xKernelObjectPool[ lIndex ].ulKernelObjectType = KERNEL_OBJECT_TYPE_INVALID; 286 xKernelObjectPool[ lIndex ].pvKernelObjectData = NULL; 287 } 288 taskEXIT_CRITICAL(); 289 } 290 /*-----------------------------------------------------------*/ 291 MPU_GetIndexForHandle(OpaqueObjectHandle_t xHandle,uint32_t ulKernelObjectType)292 static int32_t MPU_GetIndexForHandle( OpaqueObjectHandle_t xHandle, 293 uint32_t ulKernelObjectType ) /* PRIVILEGED_FUNCTION */ 294 { 295 int32_t i, lIndex = -1; 296 297 configASSERT( xHandle != NULL ); 298 299 for( i = 0; i < configPROTECTED_KERNEL_OBJECT_POOL_SIZE; i++ ) 300 { 301 if( ( xKernelObjectPool[ i ].xInternalObjectHandle == xHandle ) && 302 ( xKernelObjectPool[ i ].ulKernelObjectType == ulKernelObjectType ) ) 303 { 304 lIndex = i; 305 break; 306 } 307 } 308 309 return lIndex; 310 } 311 /*-----------------------------------------------------------*/ 312 MPU_StoreHandleAndDataAtIndex(int32_t lIndex,OpaqueObjectHandle_t xHandle,void * pvKernelObjectData,uint32_t ulKernelObjectType)313 static void MPU_StoreHandleAndDataAtIndex( int32_t lIndex, 314 OpaqueObjectHandle_t xHandle, 315 void * pvKernelObjectData, 316 uint32_t ulKernelObjectType ) /* PRIVILEGED_FUNCTION */ 317 { 318 configASSERT( IS_INTERNAL_INDEX_VALID( lIndex ) != pdFALSE ); 319 xKernelObjectPool[ lIndex ].xInternalObjectHandle = xHandle; 320 xKernelObjectPool[ lIndex ].ulKernelObjectType = ulKernelObjectType; 321 xKernelObjectPool[ lIndex ].pvKernelObjectData = pvKernelObjectData; 322 } 323 /*-----------------------------------------------------------*/ 324 MPU_GetHandleAtIndex(int32_t lIndex,uint32_t ulKernelObjectType)325 static OpaqueObjectHandle_t MPU_GetHandleAtIndex( int32_t lIndex, 326 uint32_t ulKernelObjectType ) /* PRIVILEGED_FUNCTION */ 327 { 328 OpaqueObjectHandle_t xObjectHandle = NULL; 329 330 configASSERT( IS_INTERNAL_INDEX_VALID( lIndex ) != pdFALSE ); 331 332 if( xKernelObjectPool[ lIndex ].ulKernelObjectType == ulKernelObjectType ) 333 { 334 xObjectHandle = xKernelObjectPool[ lIndex ].xInternalObjectHandle; 335 } 336 337 return xObjectHandle; 338 } 339 /*-----------------------------------------------------------*/ 340 341 #if ( configENABLE_ACCESS_CONTROL_LIST == 1 ) 342 vGrantAccessToKernelObject(TaskHandle_t xExternalTaskHandle,int32_t lExternalKernelObjectHandle)343 void vGrantAccessToKernelObject( TaskHandle_t xExternalTaskHandle, 344 int32_t lExternalKernelObjectHandle ) /* PRIVILEGED_FUNCTION */ 345 { 346 int32_t lExternalTaskIndex; 347 TaskHandle_t xInternalTaskHandle = NULL; 348 349 if( IS_EXTERNAL_INDEX_VALID( lExternalKernelObjectHandle ) != pdFALSE ) 350 { 351 if( xExternalTaskHandle == NULL ) 352 { 353 vPortGrantAccessToKernelObject( xExternalTaskHandle, CONVERT_TO_INTERNAL_INDEX( lExternalKernelObjectHandle ) ); 354 } 355 else 356 { 357 lExternalTaskIndex = ( int32_t ) xExternalTaskHandle; 358 359 if( IS_EXTERNAL_INDEX_VALID( lExternalTaskIndex ) != pdFALSE ) 360 { 361 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lExternalTaskIndex ) ); 362 363 if( xInternalTaskHandle != NULL ) 364 { 365 vPortGrantAccessToKernelObject( xInternalTaskHandle, 366 CONVERT_TO_INTERNAL_INDEX( lExternalKernelObjectHandle ) ); 367 } 368 } 369 } 370 } 371 } 372 373 #endif /* #if ( configENABLE_ACCESS_CONTROL_LIST == 1 ) */ 374 /*-----------------------------------------------------------*/ 375 376 #if ( configENABLE_ACCESS_CONTROL_LIST == 1 ) 377 vRevokeAccessToKernelObject(TaskHandle_t xExternalTaskHandle,int32_t lExternalKernelObjectHandle)378 void vRevokeAccessToKernelObject( TaskHandle_t xExternalTaskHandle, 379 int32_t lExternalKernelObjectHandle ) /* PRIVILEGED_FUNCTION */ 380 { 381 int32_t lExternalTaskIndex; 382 TaskHandle_t xInternalTaskHandle = NULL; 383 384 if( IS_EXTERNAL_INDEX_VALID( lExternalKernelObjectHandle ) != pdFALSE ) 385 { 386 if( xExternalTaskHandle == NULL ) 387 { 388 vPortRevokeAccessToKernelObject( xExternalTaskHandle, CONVERT_TO_INTERNAL_INDEX( lExternalKernelObjectHandle ) ); 389 } 390 else 391 { 392 lExternalTaskIndex = ( int32_t ) xExternalTaskHandle; 393 394 if( IS_EXTERNAL_INDEX_VALID( lExternalTaskIndex ) != pdFALSE ) 395 { 396 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lExternalTaskIndex ) ); 397 398 if( xInternalTaskHandle != NULL ) 399 { 400 vPortRevokeAccessToKernelObject( xInternalTaskHandle, 401 CONVERT_TO_INTERNAL_INDEX( lExternalKernelObjectHandle ) ); 402 } 403 } 404 } 405 } 406 } 407 408 #endif /* #if ( configENABLE_ACCESS_CONTROL_LIST == 1 ) */ 409 /*-----------------------------------------------------------*/ 410 411 #if ( configUSE_TIMERS == 1 ) 412 MPU_TimerCallback(TimerHandle_t xInternalHandle)413 static void MPU_TimerCallback( TimerHandle_t xInternalHandle ) /* PRIVILEGED_FUNCTION */ 414 { 415 int32_t i, lIndex = -1; 416 TimerHandle_t xExternalHandle = NULL; 417 TimerCallbackFunction_t pxApplicationCallBack = NULL; 418 419 /* Coming from the timer task and therefore, should be valid. */ 420 configASSERT( xInternalHandle != NULL ); 421 422 for( i = 0; i < configPROTECTED_KERNEL_OBJECT_POOL_SIZE; i++ ) 423 { 424 if( ( ( TimerHandle_t ) xKernelObjectPool[ i ].xInternalObjectHandle == xInternalHandle ) && 425 ( xKernelObjectPool[ i ].ulKernelObjectType == KERNEL_OBJECT_TYPE_TIMER ) ) 426 { 427 lIndex = i; 428 break; 429 } 430 } 431 432 configASSERT( lIndex != -1 ); 433 xExternalHandle = ( TimerHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 434 435 pxApplicationCallBack = ( TimerCallbackFunction_t ) xKernelObjectPool[ lIndex ].pvKernelObjectData; 436 pxApplicationCallBack( xExternalHandle ); 437 } 438 439 #endif /* #if ( configUSE_TIMERS == 1 ) */ 440 /*-----------------------------------------------------------*/ 441 442 /*-----------------------------------------------------------*/ 443 /* MPU wrappers for tasks APIs. */ 444 /*-----------------------------------------------------------*/ 445 446 #if ( INCLUDE_xTaskDelayUntil == 1 ) 447 448 BaseType_t MPU_xTaskDelayUntilImpl( TickType_t * const pxPreviousWakeTime, 449 TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION; 450 MPU_xTaskDelayUntilImpl(TickType_t * const pxPreviousWakeTime,TickType_t xTimeIncrement)451 BaseType_t MPU_xTaskDelayUntilImpl( TickType_t * const pxPreviousWakeTime, 452 TickType_t xTimeIncrement ) /* PRIVILEGED_FUNCTION */ 453 { 454 BaseType_t xReturn = pdFAIL; 455 BaseType_t xIsPreviousWakeTimeAccessible = pdFALSE; 456 457 if( ( pxPreviousWakeTime != NULL ) && ( xTimeIncrement > 0U ) ) 458 { 459 xIsPreviousWakeTimeAccessible = xPortIsAuthorizedToAccessBuffer( pxPreviousWakeTime, 460 sizeof( TickType_t ), 461 ( tskMPU_WRITE_PERMISSION | tskMPU_READ_PERMISSION ) ); 462 463 if( xIsPreviousWakeTimeAccessible == pdTRUE ) 464 { 465 xReturn = xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ); 466 } 467 } 468 469 return xReturn; 470 } 471 472 #endif /* if ( INCLUDE_xTaskDelayUntil == 1 ) */ 473 /*-----------------------------------------------------------*/ 474 475 #if ( INCLUDE_xTaskAbortDelay == 1 ) 476 477 BaseType_t MPU_xTaskAbortDelayImpl( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; 478 MPU_xTaskAbortDelayImpl(TaskHandle_t xTask)479 BaseType_t MPU_xTaskAbortDelayImpl( TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */ 480 { 481 BaseType_t xReturn = pdFAIL; 482 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE; 483 TaskHandle_t xInternalTaskHandle = NULL; 484 int32_t lIndex; 485 486 lIndex = ( int32_t ) xTask; 487 488 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 489 { 490 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 491 492 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE ) 493 { 494 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 495 496 if( xInternalTaskHandle != NULL ) 497 { 498 xReturn = xTaskAbortDelay( xInternalTaskHandle ); 499 } 500 } 501 } 502 503 return xReturn; 504 } 505 506 #endif /* if ( INCLUDE_xTaskAbortDelay == 1 ) */ 507 /*-----------------------------------------------------------*/ 508 509 #if ( INCLUDE_vTaskDelay == 1 ) 510 511 void MPU_vTaskDelayImpl( TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; 512 MPU_vTaskDelayImpl(TickType_t xTicksToDelay)513 void MPU_vTaskDelayImpl( TickType_t xTicksToDelay ) /* PRIVILEGED_FUNCTION */ 514 { 515 vTaskDelay( xTicksToDelay ); 516 } 517 518 #endif /* if ( INCLUDE_vTaskDelay == 1 ) */ 519 /*-----------------------------------------------------------*/ 520 521 #if ( INCLUDE_uxTaskPriorityGet == 1 ) 522 523 UBaseType_t MPU_uxTaskPriorityGetImpl( const TaskHandle_t pxTask ) PRIVILEGED_FUNCTION; 524 MPU_uxTaskPriorityGetImpl(const TaskHandle_t pxTask)525 UBaseType_t MPU_uxTaskPriorityGetImpl( const TaskHandle_t pxTask ) /* PRIVILEGED_FUNCTION */ 526 { 527 UBaseType_t uxReturn = configMAX_PRIORITIES; 528 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE; 529 int32_t lIndex; 530 TaskHandle_t xInternalTaskHandle = NULL; 531 532 if( pxTask == NULL ) 533 { 534 uxReturn = uxTaskPriorityGet( pxTask ); 535 } 536 else 537 { 538 lIndex = ( int32_t ) pxTask; 539 540 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 541 { 542 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 543 544 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE ) 545 { 546 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 547 548 if( xInternalTaskHandle != NULL ) 549 { 550 uxReturn = uxTaskPriorityGet( xInternalTaskHandle ); 551 } 552 } 553 } 554 } 555 556 return uxReturn; 557 } 558 559 #endif /* if ( INCLUDE_uxTaskPriorityGet == 1 ) */ 560 /*-----------------------------------------------------------*/ 561 562 #if ( INCLUDE_eTaskGetState == 1 ) 563 564 eTaskState MPU_eTaskGetStateImpl( TaskHandle_t pxTask ) PRIVILEGED_FUNCTION; 565 MPU_eTaskGetStateImpl(TaskHandle_t pxTask)566 eTaskState MPU_eTaskGetStateImpl( TaskHandle_t pxTask ) /* PRIVILEGED_FUNCTION */ 567 { 568 eTaskState eReturn = eInvalid; 569 TaskHandle_t xInternalTaskHandle = NULL; 570 int32_t lIndex; 571 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE; 572 573 lIndex = ( int32_t ) pxTask; 574 575 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 576 { 577 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 578 579 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE ) 580 { 581 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 582 583 if( xInternalTaskHandle != NULL ) 584 { 585 eReturn = eTaskGetState( xInternalTaskHandle ); 586 } 587 } 588 } 589 590 return eReturn; 591 } 592 593 #endif /* if ( INCLUDE_eTaskGetState == 1 ) */ 594 /*-----------------------------------------------------------*/ 595 596 #if ( configUSE_TRACE_FACILITY == 1 ) 597 598 void MPU_vTaskGetInfoImpl( TaskHandle_t xTask, 599 TaskStatus_t * pxTaskStatus, 600 BaseType_t xGetFreeStackSpace, 601 eTaskState eState ) PRIVILEGED_FUNCTION; 602 MPU_vTaskGetInfoImpl(TaskHandle_t xTask,TaskStatus_t * pxTaskStatus,BaseType_t xGetFreeStackSpace,eTaskState eState)603 void MPU_vTaskGetInfoImpl( TaskHandle_t xTask, 604 TaskStatus_t * pxTaskStatus, 605 BaseType_t xGetFreeStackSpace, 606 eTaskState eState ) /* PRIVILEGED_FUNCTION */ 607 { 608 int32_t lIndex; 609 TaskHandle_t xInternalTaskHandle = NULL; 610 BaseType_t xIsTaskStatusWriteable = pdFALSE; 611 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE; 612 613 xIsTaskStatusWriteable = xPortIsAuthorizedToAccessBuffer( pxTaskStatus, 614 sizeof( TaskStatus_t ), 615 tskMPU_WRITE_PERMISSION ); 616 617 if( xIsTaskStatusWriteable == pdTRUE ) 618 { 619 if( xTask == NULL ) 620 { 621 vTaskGetInfo( xTask, pxTaskStatus, xGetFreeStackSpace, eState ); 622 } 623 else 624 { 625 lIndex = ( int32_t ) xTask; 626 627 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 628 { 629 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 630 631 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE ) 632 { 633 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 634 635 if( xInternalTaskHandle != NULL ) 636 { 637 vTaskGetInfo( xInternalTaskHandle, pxTaskStatus, xGetFreeStackSpace, eState ); 638 } 639 } 640 } 641 } 642 } 643 } 644 645 #endif /* if ( configUSE_TRACE_FACILITY == 1 ) */ 646 /*-----------------------------------------------------------*/ 647 648 #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) 649 650 TaskHandle_t MPU_xTaskGetIdleTaskHandleImpl( void ) PRIVILEGED_FUNCTION; 651 MPU_xTaskGetIdleTaskHandleImpl(void)652 TaskHandle_t MPU_xTaskGetIdleTaskHandleImpl( void ) /* PRIVILEGED_FUNCTION */ 653 { 654 TaskHandle_t xIdleTaskHandle = NULL; 655 656 xIdleTaskHandle = xTaskGetIdleTaskHandle(); 657 658 return xIdleTaskHandle; 659 } 660 661 #endif /* if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) */ 662 /*-----------------------------------------------------------*/ 663 664 #if ( INCLUDE_vTaskSuspend == 1 ) 665 666 void MPU_vTaskSuspendImpl( TaskHandle_t pxTaskToSuspend ) PRIVILEGED_FUNCTION; 667 MPU_vTaskSuspendImpl(TaskHandle_t pxTaskToSuspend)668 void MPU_vTaskSuspendImpl( TaskHandle_t pxTaskToSuspend ) /* PRIVILEGED_FUNCTION */ 669 { 670 int32_t lIndex; 671 TaskHandle_t xInternalTaskHandle = NULL; 672 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE; 673 674 if( pxTaskToSuspend == NULL ) 675 { 676 vTaskSuspend( pxTaskToSuspend ); 677 } 678 else 679 { 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 ) ) 684 #else 685 if( portIS_TASK_PRIVILEGED() == pdTRUE ) 686 #endif 687 { 688 lIndex = ( int32_t ) pxTaskToSuspend; 689 690 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 691 { 692 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 693 694 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE ) 695 { 696 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 697 698 if( xInternalTaskHandle != NULL ) 699 { 700 vTaskSuspend( xInternalTaskHandle ); 701 } 702 } 703 } 704 } 705 } 706 } 707 708 #endif /* if ( INCLUDE_vTaskSuspend == 1 ) */ 709 /*-----------------------------------------------------------*/ 710 711 #if ( INCLUDE_vTaskSuspend == 1 ) 712 713 void MPU_vTaskResumeImpl( TaskHandle_t pxTaskToResume ) PRIVILEGED_FUNCTION; 714 MPU_vTaskResumeImpl(TaskHandle_t pxTaskToResume)715 void MPU_vTaskResumeImpl( TaskHandle_t pxTaskToResume ) /* PRIVILEGED_FUNCTION */ 716 { 717 int32_t lIndex; 718 TaskHandle_t xInternalTaskHandle = NULL; 719 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE; 720 721 lIndex = ( int32_t ) pxTaskToResume; 722 723 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 724 { 725 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 726 727 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE ) 728 { 729 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 730 731 if( xInternalTaskHandle != NULL ) 732 { 733 vTaskResume( xInternalTaskHandle ); 734 } 735 } 736 } 737 } 738 739 #endif /* if ( INCLUDE_vTaskSuspend == 1 ) */ 740 /*-----------------------------------------------------------*/ 741 742 TickType_t MPU_xTaskGetTickCountImpl( void ) PRIVILEGED_FUNCTION; 743 MPU_xTaskGetTickCountImpl(void)744 TickType_t MPU_xTaskGetTickCountImpl( void ) /* PRIVILEGED_FUNCTION */ 745 { 746 TickType_t xReturn; 747 748 xReturn = xTaskGetTickCount(); 749 750 return xReturn; 751 } 752 /*-----------------------------------------------------------*/ 753 754 UBaseType_t MPU_uxTaskGetNumberOfTasksImpl( void ) PRIVILEGED_FUNCTION; 755 MPU_uxTaskGetNumberOfTasksImpl(void)756 UBaseType_t MPU_uxTaskGetNumberOfTasksImpl( void ) /* PRIVILEGED_FUNCTION */ 757 { 758 UBaseType_t uxReturn; 759 760 uxReturn = uxTaskGetNumberOfTasks(); 761 762 return uxReturn; 763 } 764 /*-----------------------------------------------------------*/ 765 766 char * MPU_pcTaskGetNameImpl( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; 767 MPU_pcTaskGetNameImpl(TaskHandle_t xTaskToQuery)768 char * MPU_pcTaskGetNameImpl( TaskHandle_t xTaskToQuery ) /* PRIVILEGED_FUNCTION */ 769 { 770 char * pcReturn = NULL; 771 int32_t lIndex; 772 TaskHandle_t xInternalTaskHandle = NULL; 773 774 if( xTaskToQuery == NULL ) 775 { 776 pcReturn = pcTaskGetName( xTaskToQuery ); 777 } 778 else 779 { 780 lIndex = ( int32_t ) xTaskToQuery; 781 782 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 783 { 784 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 785 786 if( xInternalTaskHandle != NULL ) 787 { 788 pcReturn = pcTaskGetName( xInternalTaskHandle ); 789 } 790 } 791 } 792 793 return pcReturn; 794 } 795 /*-----------------------------------------------------------*/ 796 797 #if ( configGENERATE_RUN_TIME_STATS == 1 ) 798 799 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetRunTimeCounterImpl( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION; 800 MPU_ulTaskGetRunTimeCounterImpl(const TaskHandle_t xTask)801 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetRunTimeCounterImpl( const TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */ 802 { 803 configRUN_TIME_COUNTER_TYPE xReturn = 0; 804 int32_t lIndex; 805 TaskHandle_t xInternalTaskHandle = NULL; 806 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE; 807 808 if( xTask == NULL ) 809 { 810 xReturn = ulTaskGetRunTimeCounter( xTask ); 811 } 812 else 813 { 814 lIndex = ( int32_t ) xTask; 815 816 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 817 { 818 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 819 820 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE ) 821 { 822 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 823 824 if( xInternalTaskHandle != NULL ) 825 { 826 xReturn = ulTaskGetRunTimeCounter( xInternalTaskHandle ); 827 } 828 } 829 } 830 } 831 832 return xReturn; 833 } 834 835 #endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) */ 836 /*-----------------------------------------------------------*/ 837 838 #if ( configGENERATE_RUN_TIME_STATS == 1 ) 839 840 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetRunTimePercentImpl( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION; 841 MPU_ulTaskGetRunTimePercentImpl(const TaskHandle_t xTask)842 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetRunTimePercentImpl( const TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */ 843 { 844 configRUN_TIME_COUNTER_TYPE xReturn = 0; 845 int32_t lIndex; 846 TaskHandle_t xInternalTaskHandle = NULL; 847 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE; 848 849 if( xTask == NULL ) 850 { 851 xReturn = ulTaskGetRunTimePercent( xTask ); 852 } 853 else 854 { 855 lIndex = ( int32_t ) xTask; 856 857 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 858 { 859 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 860 861 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE ) 862 { 863 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 864 865 if( xInternalTaskHandle != NULL ) 866 { 867 xReturn = ulTaskGetRunTimePercent( xInternalTaskHandle ); 868 } 869 } 870 } 871 } 872 873 return xReturn; 874 } 875 876 #endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) */ 877 /*-----------------------------------------------------------*/ 878 879 #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) 880 881 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimePercentImpl( void ) PRIVILEGED_FUNCTION; 882 MPU_ulTaskGetIdleRunTimePercentImpl(void)883 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimePercentImpl( void ) /* PRIVILEGED_FUNCTION */ 884 { 885 configRUN_TIME_COUNTER_TYPE xReturn; 886 887 xReturn = ulTaskGetIdleRunTimePercent(); 888 889 return xReturn; 890 } 891 892 #endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) */ 893 /*-----------------------------------------------------------*/ 894 895 #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) 896 897 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimeCounterImpl( void ) PRIVILEGED_FUNCTION; 898 MPU_ulTaskGetIdleRunTimeCounterImpl(void)899 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimeCounterImpl( void ) /* PRIVILEGED_FUNCTION */ 900 { 901 configRUN_TIME_COUNTER_TYPE xReturn; 902 903 xReturn = ulTaskGetIdleRunTimeCounter(); 904 905 return xReturn; 906 } 907 908 #endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) */ 909 /*-----------------------------------------------------------*/ 910 911 #if ( configUSE_APPLICATION_TASK_TAG == 1 ) 912 913 void MPU_vTaskSetApplicationTaskTagImpl( TaskHandle_t xTask, 914 TaskHookFunction_t pxTagValue ) PRIVILEGED_FUNCTION; 915 MPU_vTaskSetApplicationTaskTagImpl(TaskHandle_t xTask,TaskHookFunction_t pxTagValue)916 void MPU_vTaskSetApplicationTaskTagImpl( TaskHandle_t xTask, 917 TaskHookFunction_t pxTagValue ) /* PRIVILEGED_FUNCTION */ 918 { 919 TaskHandle_t xInternalTaskHandle = NULL; 920 int32_t lIndex; 921 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE; 922 923 if( xTask == NULL ) 924 { 925 vTaskSetApplicationTaskTag( xTask, pxTagValue ); 926 } 927 else 928 { 929 lIndex = ( int32_t ) xTask; 930 931 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 932 { 933 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 934 935 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE ) 936 { 937 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 938 939 if( xInternalTaskHandle != NULL ) 940 { 941 vTaskSetApplicationTaskTag( xInternalTaskHandle, pxTagValue ); 942 } 943 } 944 } 945 } 946 } 947 948 #endif /* if ( configUSE_APPLICATION_TASK_TAG == 1 ) */ 949 /*-----------------------------------------------------------*/ 950 951 #if ( configUSE_APPLICATION_TASK_TAG == 1 ) 952 953 TaskHookFunction_t MPU_xTaskGetApplicationTaskTagImpl( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; 954 MPU_xTaskGetApplicationTaskTagImpl(TaskHandle_t xTask)955 TaskHookFunction_t MPU_xTaskGetApplicationTaskTagImpl( TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */ 956 { 957 TaskHookFunction_t xReturn = NULL; 958 int32_t lIndex; 959 TaskHandle_t xInternalTaskHandle = NULL; 960 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE; 961 962 if( xTask == NULL ) 963 { 964 xReturn = xTaskGetApplicationTaskTag( xTask ); 965 } 966 else 967 { 968 lIndex = ( int32_t ) xTask; 969 970 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 971 { 972 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 973 974 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE ) 975 { 976 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 977 978 if( xInternalTaskHandle != NULL ) 979 { 980 xReturn = xTaskGetApplicationTaskTag( xInternalTaskHandle ); 981 } 982 } 983 } 984 } 985 986 return xReturn; 987 } 988 989 #endif /* if ( configUSE_APPLICATION_TASK_TAG == 1 ) */ 990 /*-----------------------------------------------------------*/ 991 992 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) 993 994 void MPU_vTaskSetThreadLocalStoragePointerImpl( TaskHandle_t xTaskToSet, 995 BaseType_t xIndex, 996 void * pvValue ) PRIVILEGED_FUNCTION; 997 MPU_vTaskSetThreadLocalStoragePointerImpl(TaskHandle_t xTaskToSet,BaseType_t xIndex,void * pvValue)998 void MPU_vTaskSetThreadLocalStoragePointerImpl( TaskHandle_t xTaskToSet, 999 BaseType_t xIndex, 1000 void * pvValue ) /* PRIVILEGED_FUNCTION */ 1001 { 1002 int32_t lIndex; 1003 TaskHandle_t xInternalTaskHandle = NULL; 1004 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE; 1005 1006 if( xTaskToSet == NULL ) 1007 { 1008 vTaskSetThreadLocalStoragePointer( xTaskToSet, xIndex, pvValue ); 1009 } 1010 else 1011 { 1012 lIndex = ( int32_t ) xTaskToSet; 1013 1014 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 1015 { 1016 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1017 1018 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE ) 1019 { 1020 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1021 1022 if( xInternalTaskHandle != NULL ) 1023 { 1024 vTaskSetThreadLocalStoragePointer( xInternalTaskHandle, xIndex, pvValue ); 1025 } 1026 } 1027 } 1028 } 1029 } 1030 1031 #endif /* if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) */ 1032 /*-----------------------------------------------------------*/ 1033 1034 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) 1035 1036 void * MPU_pvTaskGetThreadLocalStoragePointerImpl( TaskHandle_t xTaskToQuery, 1037 BaseType_t xIndex ) PRIVILEGED_FUNCTION; 1038 MPU_pvTaskGetThreadLocalStoragePointerImpl(TaskHandle_t xTaskToQuery,BaseType_t xIndex)1039 void * MPU_pvTaskGetThreadLocalStoragePointerImpl( TaskHandle_t xTaskToQuery, 1040 BaseType_t xIndex ) /* PRIVILEGED_FUNCTION */ 1041 { 1042 void * pvReturn = NULL; 1043 int32_t lIndex; 1044 TaskHandle_t xInternalTaskHandle = NULL; 1045 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE; 1046 1047 if( xTaskToQuery == NULL ) 1048 { 1049 pvReturn = pvTaskGetThreadLocalStoragePointer( xTaskToQuery, xIndex ); 1050 } 1051 else 1052 { 1053 lIndex = ( int32_t ) xTaskToQuery; 1054 1055 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 1056 { 1057 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1058 1059 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE ) 1060 { 1061 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1062 1063 if( xInternalTaskHandle != NULL ) 1064 { 1065 pvReturn = pvTaskGetThreadLocalStoragePointer( xInternalTaskHandle, xIndex ); 1066 } 1067 } 1068 } 1069 } 1070 1071 return pvReturn; 1072 } 1073 1074 #endif /* if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) */ 1075 /*-----------------------------------------------------------*/ 1076 1077 #if ( configUSE_TRACE_FACILITY == 1 ) 1078 1079 UBaseType_t MPU_uxTaskGetSystemStateImpl( TaskStatus_t * pxTaskStatusArray, 1080 UBaseType_t uxArraySize, 1081 configRUN_TIME_COUNTER_TYPE * pulTotalRunTime ) PRIVILEGED_FUNCTION; 1082 MPU_uxTaskGetSystemStateImpl(TaskStatus_t * pxTaskStatusArray,UBaseType_t uxArraySize,configRUN_TIME_COUNTER_TYPE * pulTotalRunTime)1083 UBaseType_t MPU_uxTaskGetSystemStateImpl( TaskStatus_t * pxTaskStatusArray, 1084 UBaseType_t uxArraySize, 1085 configRUN_TIME_COUNTER_TYPE * pulTotalRunTime ) /* PRIVILEGED_FUNCTION */ 1086 { 1087 UBaseType_t uxReturn = 0; 1088 UBaseType_t xIsTaskStatusArrayWriteable = pdFALSE; 1089 UBaseType_t xIsTotalRunTimeWriteable = pdFALSE; 1090 uint32_t ulArraySize = ( uint32_t ) uxArraySize; 1091 uint32_t ulTaskStatusSize = ( uint32_t ) sizeof( TaskStatus_t ); 1092 1093 if( mpuMULTIPLY_UINT32_WILL_OVERFLOW( ulTaskStatusSize, ulArraySize ) == 0 ) 1094 { 1095 xIsTaskStatusArrayWriteable = xPortIsAuthorizedToAccessBuffer( pxTaskStatusArray, 1096 ulTaskStatusSize * ulArraySize, 1097 tskMPU_WRITE_PERMISSION ); 1098 1099 if( pulTotalRunTime != NULL ) 1100 { 1101 xIsTotalRunTimeWriteable = xPortIsAuthorizedToAccessBuffer( pulTotalRunTime, 1102 sizeof( configRUN_TIME_COUNTER_TYPE ), 1103 tskMPU_WRITE_PERMISSION ); 1104 } 1105 1106 if( ( xIsTaskStatusArrayWriteable == pdTRUE ) && 1107 ( ( pulTotalRunTime == NULL ) || ( xIsTotalRunTimeWriteable == pdTRUE ) ) ) 1108 { 1109 uxReturn = uxTaskGetSystemState( pxTaskStatusArray, ( UBaseType_t ) ulArraySize, pulTotalRunTime ); 1110 } 1111 } 1112 1113 return uxReturn; 1114 } 1115 1116 #endif /* if ( configUSE_TRACE_FACILITY == 1 ) */ 1117 /*-----------------------------------------------------------*/ 1118 1119 #if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) 1120 1121 UBaseType_t MPU_uxTaskGetStackHighWaterMarkImpl( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; 1122 MPU_uxTaskGetStackHighWaterMarkImpl(TaskHandle_t xTask)1123 UBaseType_t MPU_uxTaskGetStackHighWaterMarkImpl( TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */ 1124 { 1125 UBaseType_t uxReturn = 0; 1126 int32_t lIndex; 1127 TaskHandle_t xInternalTaskHandle = NULL; 1128 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE; 1129 1130 if( xTask == NULL ) 1131 { 1132 uxReturn = uxTaskGetStackHighWaterMark( xTask ); 1133 } 1134 else 1135 { 1136 lIndex = ( int32_t ) xTask; 1137 1138 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 1139 { 1140 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1141 1142 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE ) 1143 { 1144 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1145 1146 if( xInternalTaskHandle != NULL ) 1147 { 1148 uxReturn = uxTaskGetStackHighWaterMark( xInternalTaskHandle ); 1149 } 1150 } 1151 } 1152 } 1153 1154 return uxReturn; 1155 } 1156 1157 #endif /* if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) */ 1158 /*-----------------------------------------------------------*/ 1159 1160 #if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) 1161 1162 configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2Impl( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; 1163 MPU_uxTaskGetStackHighWaterMark2Impl(TaskHandle_t xTask)1164 configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2Impl( TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */ 1165 { 1166 configSTACK_DEPTH_TYPE uxReturn = 0; 1167 int32_t lIndex; 1168 TaskHandle_t xInternalTaskHandle = NULL; 1169 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE; 1170 1171 if( xTask == NULL ) 1172 { 1173 uxReturn = uxTaskGetStackHighWaterMark2( xTask ); 1174 } 1175 else 1176 { 1177 lIndex = ( int32_t ) xTask; 1178 1179 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 1180 { 1181 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1182 1183 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE ) 1184 { 1185 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1186 1187 if( xInternalTaskHandle != NULL ) 1188 { 1189 uxReturn = uxTaskGetStackHighWaterMark2( xInternalTaskHandle ); 1190 } 1191 } 1192 } 1193 } 1194 1195 return uxReturn; 1196 } 1197 1198 #endif /* if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) */ 1199 /*-----------------------------------------------------------*/ 1200 1201 #if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) ) 1202 1203 TaskHandle_t MPU_xTaskGetCurrentTaskHandleImpl( void ) PRIVILEGED_FUNCTION; 1204 MPU_xTaskGetCurrentTaskHandleImpl(void)1205 TaskHandle_t MPU_xTaskGetCurrentTaskHandleImpl( void ) /* PRIVILEGED_FUNCTION */ 1206 { 1207 TaskHandle_t xInternalTaskHandle = NULL; 1208 TaskHandle_t xExternalTaskHandle = NULL; 1209 int32_t lIndex; 1210 1211 xInternalTaskHandle = xTaskGetCurrentTaskHandle(); 1212 1213 if( xInternalTaskHandle != NULL ) 1214 { 1215 lIndex = MPU_GetIndexForTaskHandle( xInternalTaskHandle ); 1216 1217 if( lIndex != -1 ) 1218 { 1219 xExternalTaskHandle = ( TaskHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 1220 } 1221 } 1222 1223 return xExternalTaskHandle; 1224 } 1225 1226 #endif /* if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) ) */ 1227 /*-----------------------------------------------------------*/ 1228 1229 #if ( INCLUDE_xTaskGetSchedulerState == 1 ) 1230 1231 BaseType_t MPU_xTaskGetSchedulerStateImpl( void ) PRIVILEGED_FUNCTION; 1232 MPU_xTaskGetSchedulerStateImpl(void)1233 BaseType_t MPU_xTaskGetSchedulerStateImpl( void ) /* PRIVILEGED_FUNCTION */ 1234 { 1235 BaseType_t xReturn = taskSCHEDULER_NOT_STARTED; 1236 1237 xReturn = xTaskGetSchedulerState(); 1238 1239 return xReturn; 1240 } 1241 1242 #endif /* if ( INCLUDE_xTaskGetSchedulerState == 1 ) */ 1243 /*-----------------------------------------------------------*/ 1244 1245 void MPU_vTaskSetTimeOutStateImpl( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION; 1246 MPU_vTaskSetTimeOutStateImpl(TimeOut_t * const pxTimeOut)1247 void MPU_vTaskSetTimeOutStateImpl( TimeOut_t * const pxTimeOut ) /* PRIVILEGED_FUNCTION */ 1248 { 1249 BaseType_t xIsTimeOutWriteable = pdFALSE; 1250 1251 if( pxTimeOut != NULL ) 1252 { 1253 xIsTimeOutWriteable = xPortIsAuthorizedToAccessBuffer( pxTimeOut, 1254 sizeof( TimeOut_t ), 1255 tskMPU_WRITE_PERMISSION ); 1256 1257 if( xIsTimeOutWriteable == pdTRUE ) 1258 { 1259 vTaskSetTimeOutState( pxTimeOut ); 1260 } 1261 } 1262 } 1263 /*-----------------------------------------------------------*/ 1264 1265 BaseType_t MPU_xTaskCheckForTimeOutImpl( TimeOut_t * const pxTimeOut, 1266 TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION; 1267 MPU_xTaskCheckForTimeOutImpl(TimeOut_t * const pxTimeOut,TickType_t * const pxTicksToWait)1268 BaseType_t MPU_xTaskCheckForTimeOutImpl( TimeOut_t * const pxTimeOut, 1269 TickType_t * const pxTicksToWait ) /* PRIVILEGED_FUNCTION */ 1270 { 1271 BaseType_t xReturn = pdFALSE; 1272 BaseType_t xIsTimeOutWriteable = pdFALSE; 1273 BaseType_t xIsTicksToWaitWriteable = pdFALSE; 1274 1275 if( ( pxTimeOut != NULL ) && ( pxTicksToWait != NULL ) ) 1276 { 1277 xIsTimeOutWriteable = xPortIsAuthorizedToAccessBuffer( pxTimeOut, 1278 sizeof( TimeOut_t ), 1279 tskMPU_WRITE_PERMISSION ); 1280 xIsTicksToWaitWriteable = xPortIsAuthorizedToAccessBuffer( pxTicksToWait, 1281 sizeof( TickType_t ), 1282 tskMPU_WRITE_PERMISSION ); 1283 1284 if( ( xIsTimeOutWriteable == pdTRUE ) && ( xIsTicksToWaitWriteable == pdTRUE ) ) 1285 { 1286 xReturn = xTaskCheckForTimeOut( pxTimeOut, pxTicksToWait ); 1287 } 1288 } 1289 1290 return xReturn; 1291 } 1292 /*-----------------------------------------------------------*/ 1293 1294 #if ( configUSE_TASK_NOTIFICATIONS == 1 ) 1295 MPU_xTaskGenericNotify(TaskHandle_t xTaskToNotify,UBaseType_t uxIndexToNotify,uint32_t ulValue,eNotifyAction eAction,uint32_t * pulPreviousNotificationValue)1296 BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, 1297 UBaseType_t uxIndexToNotify, 1298 uint32_t ulValue, 1299 eNotifyAction eAction, 1300 uint32_t * pulPreviousNotificationValue ) /* FREERTOS_SYSTEM_CALL */ 1301 { 1302 BaseType_t xReturn = pdFAIL; 1303 xTaskGenericNotifyParams_t xParams; 1304 1305 xParams.xTaskToNotify = xTaskToNotify; 1306 xParams.uxIndexToNotify = uxIndexToNotify; 1307 xParams.ulValue = ulValue; 1308 xParams.eAction = eAction; 1309 xParams.pulPreviousNotificationValue = pulPreviousNotificationValue; 1310 1311 xReturn = MPU_xTaskGenericNotifyEntry( &( xParams ) ); 1312 1313 return xReturn; 1314 } 1315 1316 BaseType_t MPU_xTaskGenericNotifyImpl( const xTaskGenericNotifyParams_t * pxParams ) PRIVILEGED_FUNCTION; 1317 MPU_xTaskGenericNotifyImpl(const xTaskGenericNotifyParams_t * pxParams)1318 BaseType_t MPU_xTaskGenericNotifyImpl( const xTaskGenericNotifyParams_t * pxParams ) /* PRIVILEGED_FUNCTION */ 1319 { 1320 BaseType_t xReturn = pdFAIL; 1321 int32_t lIndex; 1322 TaskHandle_t xInternalTaskHandle = NULL; 1323 BaseType_t xIsPreviousNotificationValueWriteable = pdFALSE; 1324 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE; 1325 BaseType_t xAreParamsReadable = pdFALSE; 1326 1327 if( pxParams != NULL ) 1328 { 1329 xAreParamsReadable = xPortIsAuthorizedToAccessBuffer( pxParams, 1330 sizeof( xTaskGenericNotifyParams_t ), 1331 tskMPU_READ_PERMISSION ); 1332 } 1333 1334 if( xAreParamsReadable == pdTRUE ) 1335 { 1336 if( ( pxParams->uxIndexToNotify < configTASK_NOTIFICATION_ARRAY_ENTRIES ) && 1337 ( ( pxParams->eAction == eNoAction ) || 1338 ( pxParams->eAction == eSetBits ) || 1339 ( pxParams->eAction == eIncrement ) || 1340 ( pxParams->eAction == eSetValueWithOverwrite ) || 1341 ( pxParams->eAction == eSetValueWithoutOverwrite ) ) ) 1342 { 1343 if( pxParams->pulPreviousNotificationValue != NULL ) 1344 { 1345 xIsPreviousNotificationValueWriteable = xPortIsAuthorizedToAccessBuffer( pxParams->pulPreviousNotificationValue, 1346 sizeof( uint32_t ), 1347 tskMPU_WRITE_PERMISSION ); 1348 } 1349 1350 if( ( pxParams->pulPreviousNotificationValue == NULL ) || 1351 ( xIsPreviousNotificationValueWriteable == pdTRUE ) ) 1352 { 1353 lIndex = ( int32_t ) ( pxParams->xTaskToNotify ); 1354 1355 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 1356 { 1357 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1358 1359 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE ) 1360 { 1361 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1362 1363 if( xInternalTaskHandle != NULL ) 1364 { 1365 xReturn = xTaskGenericNotify( xInternalTaskHandle, 1366 pxParams->uxIndexToNotify, 1367 pxParams->ulValue, 1368 pxParams->eAction, 1369 pxParams->pulPreviousNotificationValue ); 1370 } 1371 } 1372 } 1373 } 1374 } 1375 } 1376 1377 return xReturn; 1378 } 1379 1380 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */ 1381 /*-----------------------------------------------------------*/ 1382 1383 #if ( configUSE_TASK_NOTIFICATIONS == 1 ) 1384 MPU_xTaskGenericNotifyWait(UBaseType_t uxIndexToWaitOn,uint32_t ulBitsToClearOnEntry,uint32_t ulBitsToClearOnExit,uint32_t * pulNotificationValue,TickType_t xTicksToWait)1385 BaseType_t MPU_xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn, 1386 uint32_t ulBitsToClearOnEntry, 1387 uint32_t ulBitsToClearOnExit, 1388 uint32_t * pulNotificationValue, 1389 TickType_t xTicksToWait ) 1390 { 1391 BaseType_t xReturn = pdFAIL; 1392 xTaskGenericNotifyWaitParams_t xParams; 1393 1394 xParams.uxIndexToWaitOn = uxIndexToWaitOn; 1395 xParams.ulBitsToClearOnEntry = ulBitsToClearOnEntry; 1396 xParams.ulBitsToClearOnExit = ulBitsToClearOnExit; 1397 xParams.pulNotificationValue = pulNotificationValue; 1398 xParams.xTicksToWait = xTicksToWait; 1399 1400 xReturn = MPU_xTaskGenericNotifyWaitEntry( &( xParams ) ); 1401 1402 return xReturn; 1403 } 1404 1405 BaseType_t MPU_xTaskGenericNotifyWaitImpl( const xTaskGenericNotifyWaitParams_t * pxParams ) PRIVILEGED_FUNCTION; 1406 MPU_xTaskGenericNotifyWaitImpl(const xTaskGenericNotifyWaitParams_t * pxParams)1407 BaseType_t MPU_xTaskGenericNotifyWaitImpl( const xTaskGenericNotifyWaitParams_t * pxParams ) /* PRIVILEGED_FUNCTION */ 1408 { 1409 BaseType_t xReturn = pdFAIL; 1410 BaseType_t xIsNotificationValueWritable = pdFALSE; 1411 BaseType_t xAreParamsReadable = pdFALSE; 1412 1413 if( pxParams != NULL ) 1414 { 1415 xAreParamsReadable = xPortIsAuthorizedToAccessBuffer( pxParams, 1416 sizeof( xTaskGenericNotifyWaitParams_t ), 1417 tskMPU_READ_PERMISSION ); 1418 } 1419 1420 if( xAreParamsReadable == pdTRUE ) 1421 { 1422 if( pxParams->uxIndexToWaitOn < configTASK_NOTIFICATION_ARRAY_ENTRIES ) 1423 { 1424 if( pxParams->pulNotificationValue != NULL ) 1425 { 1426 xIsNotificationValueWritable = xPortIsAuthorizedToAccessBuffer( pxParams->pulNotificationValue, 1427 sizeof( uint32_t ), 1428 tskMPU_WRITE_PERMISSION ); 1429 } 1430 1431 if( ( pxParams->pulNotificationValue == NULL ) || 1432 ( xIsNotificationValueWritable == pdTRUE ) ) 1433 { 1434 xReturn = xTaskGenericNotifyWait( pxParams->uxIndexToWaitOn, 1435 pxParams->ulBitsToClearOnEntry, 1436 pxParams->ulBitsToClearOnExit, 1437 pxParams->pulNotificationValue, 1438 pxParams->xTicksToWait ); 1439 } 1440 } 1441 } 1442 1443 return xReturn; 1444 } 1445 1446 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */ 1447 /*-----------------------------------------------------------*/ 1448 1449 #if ( configUSE_TASK_NOTIFICATIONS == 1 ) 1450 1451 uint32_t MPU_ulTaskGenericNotifyTakeImpl( UBaseType_t uxIndexToWaitOn, 1452 BaseType_t xClearCountOnExit, 1453 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; 1454 MPU_ulTaskGenericNotifyTakeImpl(UBaseType_t uxIndexToWaitOn,BaseType_t xClearCountOnExit,TickType_t xTicksToWait)1455 uint32_t MPU_ulTaskGenericNotifyTakeImpl( UBaseType_t uxIndexToWaitOn, 1456 BaseType_t xClearCountOnExit, 1457 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */ 1458 { 1459 uint32_t ulReturn = 0; 1460 1461 if( uxIndexToWaitOn < configTASK_NOTIFICATION_ARRAY_ENTRIES ) 1462 { 1463 ulReturn = ulTaskGenericNotifyTake( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait ); 1464 } 1465 1466 return ulReturn; 1467 } 1468 1469 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */ 1470 /*-----------------------------------------------------------*/ 1471 1472 #if ( configUSE_TASK_NOTIFICATIONS == 1 ) 1473 1474 BaseType_t MPU_xTaskGenericNotifyStateClearImpl( TaskHandle_t xTask, 1475 UBaseType_t uxIndexToClear ) PRIVILEGED_FUNCTION; 1476 MPU_xTaskGenericNotifyStateClearImpl(TaskHandle_t xTask,UBaseType_t uxIndexToClear)1477 BaseType_t MPU_xTaskGenericNotifyStateClearImpl( TaskHandle_t xTask, 1478 UBaseType_t uxIndexToClear ) /* PRIVILEGED_FUNCTION */ 1479 { 1480 BaseType_t xReturn = pdFAIL; 1481 int32_t lIndex; 1482 TaskHandle_t xInternalTaskHandle = NULL; 1483 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE; 1484 1485 if( uxIndexToClear < configTASK_NOTIFICATION_ARRAY_ENTRIES ) 1486 { 1487 if( xTask == NULL ) 1488 { 1489 xReturn = xTaskGenericNotifyStateClear( xTask, uxIndexToClear ); 1490 } 1491 else 1492 { 1493 lIndex = ( int32_t ) xTask; 1494 1495 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 1496 { 1497 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1498 1499 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE ) 1500 { 1501 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1502 1503 if( xInternalTaskHandle != NULL ) 1504 { 1505 xReturn = xTaskGenericNotifyStateClear( xInternalTaskHandle, uxIndexToClear ); 1506 } 1507 } 1508 } 1509 } 1510 } 1511 1512 return xReturn; 1513 } 1514 1515 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */ 1516 /*-----------------------------------------------------------*/ 1517 1518 #if ( configUSE_TASK_NOTIFICATIONS == 1 ) 1519 1520 uint32_t MPU_ulTaskGenericNotifyValueClearImpl( TaskHandle_t xTask, 1521 UBaseType_t uxIndexToClear, 1522 uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION; 1523 MPU_ulTaskGenericNotifyValueClearImpl(TaskHandle_t xTask,UBaseType_t uxIndexToClear,uint32_t ulBitsToClear)1524 uint32_t MPU_ulTaskGenericNotifyValueClearImpl( TaskHandle_t xTask, 1525 UBaseType_t uxIndexToClear, 1526 uint32_t ulBitsToClear ) /* PRIVILEGED_FUNCTION */ 1527 { 1528 uint32_t ulReturn = 0; 1529 int32_t lIndex; 1530 TaskHandle_t xInternalTaskHandle = NULL; 1531 BaseType_t xCallingTaskIsAuthorizedToAccessTask = pdFALSE; 1532 1533 if( uxIndexToClear < configTASK_NOTIFICATION_ARRAY_ENTRIES ) 1534 { 1535 if( xTask == NULL ) 1536 { 1537 ulReturn = ulTaskGenericNotifyValueClear( xTask, uxIndexToClear, ulBitsToClear ); 1538 } 1539 else 1540 { 1541 lIndex = ( int32_t ) xTask; 1542 1543 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 1544 { 1545 xCallingTaskIsAuthorizedToAccessTask = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1546 1547 if( xCallingTaskIsAuthorizedToAccessTask == pdTRUE ) 1548 { 1549 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1550 1551 if( xInternalTaskHandle != NULL ) 1552 { 1553 ulReturn = ulTaskGenericNotifyValueClear( xInternalTaskHandle, uxIndexToClear, ulBitsToClear ); 1554 } 1555 } 1556 } 1557 } 1558 } 1559 1560 return ulReturn; 1561 } 1562 1563 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */ 1564 /*-----------------------------------------------------------*/ 1565 1566 /* Privileged only wrappers for Task APIs. These are needed so that 1567 * the application can use opaque handles maintained in mpu_wrappers.c 1568 * with all the APIs. */ 1569 /*-----------------------------------------------------------*/ 1570 1571 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) 1572 MPU_xTaskCreate(TaskFunction_t pvTaskCode,const char * const pcName,uint16_t usStackDepth,void * pvParameters,UBaseType_t uxPriority,TaskHandle_t * pxCreatedTask)1573 BaseType_t MPU_xTaskCreate( TaskFunction_t pvTaskCode, 1574 const char * const pcName, 1575 uint16_t usStackDepth, 1576 void * pvParameters, 1577 UBaseType_t uxPriority, 1578 TaskHandle_t * pxCreatedTask ) /* PRIVILEGED_FUNCTION */ 1579 { 1580 BaseType_t xReturn = pdFAIL; 1581 int32_t lIndex; 1582 TaskHandle_t xInternalTaskHandle = NULL; 1583 1584 lIndex = MPU_GetFreeIndexInKernelObjectPool(); 1585 1586 if( lIndex != -1 ) 1587 { 1588 /* xTaskCreate() can only be used to create privileged tasks in MPU port. */ 1589 if( ( uxPriority & portPRIVILEGE_BIT ) != 0 ) 1590 { 1591 xReturn = xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, &( xInternalTaskHandle ) ); 1592 1593 if( ( xReturn == pdPASS ) && ( xInternalTaskHandle != NULL ) ) 1594 { 1595 MPU_StoreTaskHandleAtIndex( lIndex, xInternalTaskHandle ); 1596 1597 if( pxCreatedTask != NULL ) 1598 { 1599 *pxCreatedTask = ( TaskHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 1600 } 1601 } 1602 else 1603 { 1604 MPU_SetIndexFreeInKernelObjectPool( lIndex ); 1605 } 1606 } 1607 } 1608 1609 return xReturn; 1610 } 1611 1612 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ 1613 /*-----------------------------------------------------------*/ 1614 1615 #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) 1616 MPU_xTaskCreateStatic(TaskFunction_t pxTaskCode,const char * const pcName,const uint32_t ulStackDepth,void * const pvParameters,UBaseType_t uxPriority,StackType_t * const puxStackBuffer,StaticTask_t * const pxTaskBuffer)1617 TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode, 1618 const char * const pcName, 1619 const uint32_t ulStackDepth, 1620 void * const pvParameters, 1621 UBaseType_t uxPriority, 1622 StackType_t * const puxStackBuffer, 1623 StaticTask_t * const pxTaskBuffer ) /* PRIVILEGED_FUNCTION */ 1624 { 1625 TaskHandle_t xExternalTaskHandle = NULL; 1626 TaskHandle_t xInternalTaskHandle = NULL; 1627 int32_t lIndex; 1628 1629 lIndex = MPU_GetFreeIndexInKernelObjectPool(); 1630 1631 if( lIndex != -1 ) 1632 { 1633 xInternalTaskHandle = xTaskCreateStatic( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer ); 1634 1635 if( xInternalTaskHandle != NULL ) 1636 { 1637 MPU_StoreTaskHandleAtIndex( lIndex, xInternalTaskHandle ); 1638 1639 #if ( configENABLE_ACCESS_CONTROL_LIST == 1 ) 1640 { 1641 /* By default, an unprivileged task has access to itself. */ 1642 if( ( uxPriority & portPRIVILEGE_BIT ) == 0 ) 1643 { 1644 vPortGrantAccessToKernelObject( xInternalTaskHandle, lIndex ); 1645 } 1646 } 1647 #endif 1648 1649 xExternalTaskHandle = ( TaskHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 1650 } 1651 else 1652 { 1653 MPU_SetIndexFreeInKernelObjectPool( lIndex ); 1654 } 1655 } 1656 1657 return xExternalTaskHandle; 1658 } 1659 1660 #endif /* configSUPPORT_STATIC_ALLOCATION */ 1661 /*-----------------------------------------------------------*/ 1662 1663 #if ( INCLUDE_vTaskDelete == 1 ) 1664 MPU_vTaskDelete(TaskHandle_t pxTaskToDelete)1665 void MPU_vTaskDelete( TaskHandle_t pxTaskToDelete ) /* PRIVILEGED_FUNCTION */ 1666 { 1667 TaskHandle_t xInternalTaskHandle = NULL; 1668 int32_t lIndex; 1669 1670 if( pxTaskToDelete == NULL ) 1671 { 1672 xInternalTaskHandle = xTaskGetCurrentTaskHandle(); 1673 lIndex = MPU_GetIndexForTaskHandle( xInternalTaskHandle ); 1674 1675 vTaskDelete( xInternalTaskHandle ); 1676 1677 if( lIndex != -1 ) 1678 { 1679 MPU_SetIndexFreeInKernelObjectPool( lIndex ); 1680 } 1681 } 1682 else 1683 { 1684 lIndex = ( int32_t ) pxTaskToDelete; 1685 1686 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 1687 { 1688 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1689 1690 if( xInternalTaskHandle != NULL ) 1691 { 1692 vTaskDelete( xInternalTaskHandle ); 1693 MPU_SetIndexFreeInKernelObjectPool( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1694 } 1695 } 1696 } 1697 } 1698 1699 #endif /* #if ( INCLUDE_vTaskDelete == 1 ) */ 1700 /*-----------------------------------------------------------*/ 1701 1702 1703 #if ( INCLUDE_vTaskPrioritySet == 1 ) 1704 MPU_vTaskPrioritySet(TaskHandle_t pxTask,UBaseType_t uxNewPriority)1705 void MPU_vTaskPrioritySet( TaskHandle_t pxTask, 1706 UBaseType_t uxNewPriority ) /* PRIVILEGED_FUNCTION */ 1707 { 1708 TaskHandle_t xInternalTaskHandle = NULL; 1709 int32_t lIndex; 1710 1711 if( pxTask == NULL ) 1712 { 1713 vTaskPrioritySet( pxTask, uxNewPriority ); 1714 } 1715 else 1716 { 1717 lIndex = ( int32_t ) pxTask; 1718 1719 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 1720 { 1721 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1722 1723 if( xInternalTaskHandle != NULL ) 1724 { 1725 vTaskPrioritySet( xInternalTaskHandle, uxNewPriority ); 1726 } 1727 } 1728 } 1729 } 1730 1731 #endif /* if ( INCLUDE_vTaskPrioritySet == 1 ) */ 1732 /*-----------------------------------------------------------*/ 1733 1734 #if ( INCLUDE_xTaskGetHandle == 1 ) 1735 MPU_xTaskGetHandle(const char * pcNameToQuery)1736 TaskHandle_t MPU_xTaskGetHandle( const char * pcNameToQuery ) /* PRIVILEGED_FUNCTION */ 1737 { 1738 TaskHandle_t xInternalTaskHandle = NULL; 1739 TaskHandle_t xExternalTaskHandle = NULL; 1740 int32_t lIndex; 1741 1742 xInternalTaskHandle = xTaskGetHandle( pcNameToQuery ); 1743 1744 if( xInternalTaskHandle != NULL ) 1745 { 1746 lIndex = MPU_GetIndexForTaskHandle( xInternalTaskHandle ); 1747 1748 if( lIndex != -1 ) 1749 { 1750 xExternalTaskHandle = ( TaskHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 1751 } 1752 } 1753 1754 return xExternalTaskHandle; 1755 } 1756 1757 #endif /* if ( INCLUDE_xTaskGetHandle == 1 ) */ 1758 /*-----------------------------------------------------------*/ 1759 1760 1761 #if ( configUSE_APPLICATION_TASK_TAG == 1 ) 1762 MPU_xTaskCallApplicationTaskHook(TaskHandle_t xTask,void * pvParameter)1763 BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, 1764 void * pvParameter ) /* PRIVILEGED_FUNCTION */ 1765 { 1766 BaseType_t xReturn = pdFAIL; 1767 int32_t lIndex; 1768 TaskHandle_t xInternalTaskHandle = NULL; 1769 1770 if( xTask == NULL ) 1771 { 1772 xReturn = xTaskCallApplicationTaskHook( xTask, pvParameter ); 1773 } 1774 else 1775 { 1776 lIndex = ( int32_t ) xTask; 1777 1778 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 1779 { 1780 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1781 1782 if( xInternalTaskHandle != NULL ) 1783 { 1784 xReturn = xTaskCallApplicationTaskHook( xInternalTaskHandle, pvParameter ); 1785 } 1786 } 1787 } 1788 1789 return xReturn; 1790 } 1791 1792 #endif /* if ( configUSE_APPLICATION_TASK_TAG == 1 ) */ 1793 /*-----------------------------------------------------------*/ 1794 1795 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) 1796 MPU_xTaskCreateRestricted(const TaskParameters_t * const pxTaskDefinition,TaskHandle_t * pxCreatedTask)1797 BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, 1798 TaskHandle_t * pxCreatedTask ) /* PRIVILEGED_FUNCTION */ 1799 { 1800 BaseType_t xReturn = pdFAIL; 1801 int32_t lIndex; 1802 TaskHandle_t xInternalTaskHandle = NULL; 1803 1804 lIndex = MPU_GetFreeIndexInKernelObjectPool(); 1805 1806 if( lIndex != -1 ) 1807 { 1808 xReturn = xTaskCreateRestricted( pxTaskDefinition, &( xInternalTaskHandle ) ); 1809 1810 if( ( xReturn == pdPASS ) && ( xInternalTaskHandle != NULL ) ) 1811 { 1812 MPU_StoreTaskHandleAtIndex( lIndex, xInternalTaskHandle ); 1813 1814 #if ( configENABLE_ACCESS_CONTROL_LIST == 1 ) 1815 { 1816 /* By default, an unprivileged task has access to itself. */ 1817 if( ( pxTaskDefinition->uxPriority & portPRIVILEGE_BIT ) == 0 ) 1818 { 1819 vPortGrantAccessToKernelObject( xInternalTaskHandle, lIndex ); 1820 } 1821 } 1822 #endif 1823 1824 if( pxCreatedTask != NULL ) 1825 { 1826 *pxCreatedTask = ( TaskHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 1827 } 1828 } 1829 else 1830 { 1831 MPU_SetIndexFreeInKernelObjectPool( lIndex ); 1832 } 1833 } 1834 1835 return xReturn; 1836 } 1837 1838 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ 1839 /*-----------------------------------------------------------*/ 1840 1841 #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) 1842 MPU_xTaskCreateRestrictedStatic(const TaskParameters_t * const pxTaskDefinition,TaskHandle_t * pxCreatedTask)1843 BaseType_t MPU_xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, 1844 TaskHandle_t * pxCreatedTask ) /* PRIVILEGED_FUNCTION */ 1845 { 1846 BaseType_t xReturn = pdFAIL; 1847 int32_t lIndex; 1848 TaskHandle_t xInternalTaskHandle = NULL; 1849 1850 lIndex = MPU_GetFreeIndexInKernelObjectPool(); 1851 1852 if( lIndex != -1 ) 1853 { 1854 xReturn = xTaskCreateRestrictedStatic( pxTaskDefinition, &( xInternalTaskHandle ) ); 1855 1856 if( ( xReturn == pdPASS ) && ( xInternalTaskHandle != NULL ) ) 1857 { 1858 MPU_StoreTaskHandleAtIndex( lIndex, xInternalTaskHandle ); 1859 1860 #if ( configENABLE_ACCESS_CONTROL_LIST == 1 ) 1861 { 1862 /* By default, an unprivileged task has access to itself. */ 1863 if( ( pxTaskDefinition->uxPriority & portPRIVILEGE_BIT ) == 0 ) 1864 { 1865 vPortGrantAccessToKernelObject( xInternalTaskHandle, lIndex ); 1866 } 1867 } 1868 #endif 1869 1870 if( pxCreatedTask != NULL ) 1871 { 1872 *pxCreatedTask = ( TaskHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 1873 } 1874 } 1875 else 1876 { 1877 MPU_SetIndexFreeInKernelObjectPool( lIndex ); 1878 } 1879 } 1880 1881 return xReturn; 1882 } 1883 1884 #endif /* configSUPPORT_STATIC_ALLOCATION */ 1885 /*-----------------------------------------------------------*/ 1886 MPU_vTaskAllocateMPURegions(TaskHandle_t xTaskToModify,const MemoryRegion_t * const xRegions)1887 void MPU_vTaskAllocateMPURegions( TaskHandle_t xTaskToModify, 1888 const MemoryRegion_t * const xRegions ) /* PRIVILEGED_FUNCTION */ 1889 { 1890 TaskHandle_t xInternalTaskHandle = NULL; 1891 int32_t lIndex; 1892 1893 if( xTaskToModify == NULL ) 1894 { 1895 vTaskAllocateMPURegions( xTaskToModify, xRegions ); 1896 } 1897 else 1898 { 1899 lIndex = ( int32_t ) xTaskToModify; 1900 1901 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 1902 { 1903 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1904 1905 if( xInternalTaskHandle != NULL ) 1906 { 1907 vTaskAllocateMPURegions( xInternalTaskHandle, xRegions ); 1908 } 1909 } 1910 } 1911 } 1912 /*-----------------------------------------------------------*/ 1913 1914 #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) 1915 MPU_xTaskGetStaticBuffers(TaskHandle_t xTask,StackType_t ** ppuxStackBuffer,StaticTask_t ** ppxTaskBuffer)1916 BaseType_t MPU_xTaskGetStaticBuffers( TaskHandle_t xTask, 1917 StackType_t ** ppuxStackBuffer, 1918 StaticTask_t ** ppxTaskBuffer ) /* PRIVILEGED_FUNCTION */ 1919 { 1920 TaskHandle_t xInternalTaskHandle = NULL; 1921 int32_t lIndex; 1922 BaseType_t xReturn = pdFALSE; 1923 1924 if( xTask == NULL ) 1925 { 1926 xInternalTaskHandle = xTaskGetCurrentTaskHandle(); 1927 xReturn = xTaskGetStaticBuffers( xInternalTaskHandle, ppuxStackBuffer, ppxTaskBuffer ); 1928 } 1929 else 1930 { 1931 lIndex = ( int32_t ) xTask; 1932 1933 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 1934 { 1935 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1936 1937 if( xInternalTaskHandle != NULL ) 1938 { 1939 xReturn = xTaskGetStaticBuffers( xInternalTaskHandle, ppuxStackBuffer, ppxTaskBuffer ); 1940 } 1941 } 1942 } 1943 1944 return xReturn; 1945 } 1946 1947 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */ 1948 /*-----------------------------------------------------------*/ 1949 1950 #if ( INCLUDE_uxTaskPriorityGet == 1 ) 1951 MPU_uxTaskPriorityGetFromISR(const TaskHandle_t xTask)1952 UBaseType_t MPU_uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */ 1953 { 1954 UBaseType_t uxReturn = configMAX_PRIORITIES; 1955 int32_t lIndex; 1956 TaskHandle_t xInternalTaskHandle = NULL; 1957 1958 if( xTask == NULL ) 1959 { 1960 uxReturn = uxTaskPriorityGetFromISR( xTask ); 1961 } 1962 else 1963 { 1964 lIndex = ( int32_t ) xTask; 1965 1966 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 1967 { 1968 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1969 1970 if( xInternalTaskHandle != NULL ) 1971 { 1972 uxReturn = uxTaskPriorityGetFromISR( xInternalTaskHandle ); 1973 } 1974 } 1975 } 1976 1977 return uxReturn; 1978 } 1979 1980 #endif /* #if ( INCLUDE_uxTaskPriorityGet == 1 ) */ 1981 /*-----------------------------------------------------------*/ 1982 1983 #if ( ( INCLUDE_xTaskResumeFromISR == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) ) 1984 MPU_xTaskResumeFromISR(TaskHandle_t xTaskToResume)1985 BaseType_t MPU_xTaskResumeFromISR( TaskHandle_t xTaskToResume ) /* PRIVILEGED_FUNCTION */ 1986 { 1987 BaseType_t xReturn = pdFAIL; 1988 int32_t lIndex; 1989 TaskHandle_t xInternalTaskHandle = NULL; 1990 1991 lIndex = ( int32_t ) xTaskToResume; 1992 1993 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 1994 { 1995 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 1996 1997 if( xInternalTaskHandle != NULL ) 1998 { 1999 xReturn = xTaskResumeFromISR( xInternalTaskHandle ); 2000 } 2001 } 2002 2003 return xReturn; 2004 } 2005 2006 #endif /* #if ( ( INCLUDE_xTaskResumeFromISR == 1 ) && ( INCLUDE_vTaskSuspend == 1 ) )*/ 2007 /*---------------------------------------------------------------------------------------*/ 2008 2009 #if ( configUSE_APPLICATION_TASK_TAG == 1 ) 2010 MPU_xTaskGetApplicationTaskTagFromISR(TaskHandle_t xTask)2011 TaskHookFunction_t MPU_xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask ) /* PRIVILEGED_FUNCTION */ 2012 { 2013 TaskHookFunction_t xReturn = NULL; 2014 int32_t lIndex; 2015 TaskHandle_t xInternalTaskHandle = NULL; 2016 2017 if( xTask == NULL ) 2018 { 2019 xReturn = xTaskGetApplicationTaskTagFromISR( xTask ); 2020 } 2021 else 2022 { 2023 lIndex = ( int32_t ) xTask; 2024 2025 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 2026 { 2027 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2028 2029 if( xInternalTaskHandle != NULL ) 2030 { 2031 xReturn = xTaskGetApplicationTaskTagFromISR( xInternalTaskHandle ); 2032 } 2033 } 2034 } 2035 2036 return xReturn; 2037 } 2038 2039 #endif /* #if ( configUSE_APPLICATION_TASK_TAG == 1 ) */ 2040 /*---------------------------------------------------------------------------------------*/ 2041 2042 #if ( configUSE_TASK_NOTIFICATIONS == 1 ) 2043 MPU_xTaskGenericNotifyFromISR(TaskHandle_t xTaskToNotify,UBaseType_t uxIndexToNotify,uint32_t ulValue,eNotifyAction eAction,uint32_t * pulPreviousNotificationValue,BaseType_t * pxHigherPriorityTaskWoken)2044 BaseType_t MPU_xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify, 2045 UBaseType_t uxIndexToNotify, 2046 uint32_t ulValue, 2047 eNotifyAction eAction, 2048 uint32_t * pulPreviousNotificationValue, 2049 BaseType_t * pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */ 2050 { 2051 BaseType_t xReturn = pdFAIL; 2052 int32_t lIndex; 2053 TaskHandle_t xInternalTaskHandle = NULL; 2054 2055 lIndex = ( int32_t ) xTaskToNotify; 2056 2057 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 2058 { 2059 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2060 2061 if( xInternalTaskHandle != NULL ) 2062 { 2063 xReturn = xTaskGenericNotifyFromISR( xInternalTaskHandle, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue, pxHigherPriorityTaskWoken ); 2064 } 2065 } 2066 2067 return xReturn; 2068 } 2069 2070 #endif /* #if ( configUSE_TASK_NOTIFICATIONS == 1 ) */ 2071 /*---------------------------------------------------------------------------------------*/ 2072 2073 #if ( configUSE_TASK_NOTIFICATIONS == 1 ) 2074 MPU_vTaskGenericNotifyGiveFromISR(TaskHandle_t xTaskToNotify,UBaseType_t uxIndexToNotify,BaseType_t * pxHigherPriorityTaskWoken)2075 void MPU_vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify, 2076 UBaseType_t uxIndexToNotify, 2077 BaseType_t * pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */ 2078 { 2079 int32_t lIndex; 2080 TaskHandle_t xInternalTaskHandle = NULL; 2081 2082 lIndex = ( int32_t ) xTaskToNotify; 2083 2084 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 2085 { 2086 xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2087 2088 if( xInternalTaskHandle != NULL ) 2089 { 2090 vTaskGenericNotifyGiveFromISR( xInternalTaskHandle, uxIndexToNotify, pxHigherPriorityTaskWoken ); 2091 } 2092 } 2093 } 2094 #endif /*#if ( configUSE_TASK_NOTIFICATIONS == 1 )*/ 2095 /*-----------------------------------------------------------*/ 2096 2097 /*-----------------------------------------------------------*/ 2098 /* MPU wrappers for queue APIs. */ 2099 /*-----------------------------------------------------------*/ 2100 2101 BaseType_t MPU_xQueueGenericSendImpl( QueueHandle_t xQueue, 2102 const void * const pvItemToQueue, 2103 TickType_t xTicksToWait, 2104 BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION; 2105 MPU_xQueueGenericSendImpl(QueueHandle_t xQueue,const void * const pvItemToQueue,TickType_t xTicksToWait,BaseType_t xCopyPosition)2106 BaseType_t MPU_xQueueGenericSendImpl( QueueHandle_t xQueue, 2107 const void * const pvItemToQueue, 2108 TickType_t xTicksToWait, 2109 BaseType_t xCopyPosition ) /* PRIVILEGED_FUNCTION */ 2110 { 2111 int32_t lIndex; 2112 QueueHandle_t xInternalQueueHandle = NULL; 2113 BaseType_t xReturn = pdFAIL; 2114 BaseType_t xIsItemToQueueReadable = pdFALSE; 2115 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE; 2116 UBaseType_t uxQueueItemSize, uxQueueLength; 2117 2118 lIndex = ( int32_t ) xQueue; 2119 2120 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 2121 { 2122 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2123 2124 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE ) 2125 { 2126 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2127 2128 if( xInternalQueueHandle != NULL ) 2129 { 2130 uxQueueItemSize = uxQueueGetQueueItemSize( xInternalQueueHandle ); 2131 uxQueueLength = uxQueueGetQueueLength( xInternalQueueHandle ); 2132 2133 if( ( !( ( pvItemToQueue == NULL ) && ( uxQueueItemSize != ( UBaseType_t ) 0U ) ) ) && 2134 ( !( ( xCopyPosition == queueOVERWRITE ) && ( uxQueueLength != ( UBaseType_t ) 1U ) ) ) 2135 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) 2136 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ) 2137 #endif 2138 ) 2139 { 2140 if( pvItemToQueue != NULL ) 2141 { 2142 xIsItemToQueueReadable = xPortIsAuthorizedToAccessBuffer( pvItemToQueue, 2143 uxQueueGetQueueItemSize( xInternalQueueHandle ), 2144 tskMPU_READ_PERMISSION ); 2145 } 2146 2147 if( ( pvItemToQueue == NULL ) || ( xIsItemToQueueReadable == pdTRUE ) ) 2148 { 2149 xReturn = xQueueGenericSend( xInternalQueueHandle, pvItemToQueue, xTicksToWait, xCopyPosition ); 2150 } 2151 } 2152 } 2153 } 2154 } 2155 2156 return xReturn; 2157 } 2158 /*-----------------------------------------------------------*/ 2159 2160 UBaseType_t MPU_uxQueueMessagesWaitingImpl( const QueueHandle_t pxQueue ) PRIVILEGED_FUNCTION; 2161 MPU_uxQueueMessagesWaitingImpl(const QueueHandle_t pxQueue)2162 UBaseType_t MPU_uxQueueMessagesWaitingImpl( const QueueHandle_t pxQueue ) /* PRIVILEGED_FUNCTION */ 2163 { 2164 int32_t lIndex; 2165 QueueHandle_t xInternalQueueHandle = NULL; 2166 UBaseType_t uxReturn = 0; 2167 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE; 2168 2169 lIndex = ( int32_t ) pxQueue; 2170 2171 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 2172 { 2173 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2174 2175 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE ) 2176 { 2177 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2178 2179 if( xInternalQueueHandle != NULL ) 2180 { 2181 uxReturn = uxQueueMessagesWaiting( xInternalQueueHandle ); 2182 } 2183 } 2184 } 2185 2186 return uxReturn; 2187 } 2188 /*-----------------------------------------------------------*/ 2189 2190 UBaseType_t MPU_uxQueueSpacesAvailableImpl( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; 2191 MPU_uxQueueSpacesAvailableImpl(const QueueHandle_t xQueue)2192 UBaseType_t MPU_uxQueueSpacesAvailableImpl( const QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */ 2193 { 2194 int32_t lIndex; 2195 QueueHandle_t xInternalQueueHandle = NULL; 2196 UBaseType_t uxReturn = 0; 2197 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE; 2198 2199 lIndex = ( int32_t ) xQueue; 2200 2201 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 2202 { 2203 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2204 2205 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE ) 2206 { 2207 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2208 2209 if( xInternalQueueHandle != NULL ) 2210 { 2211 uxReturn = uxQueueSpacesAvailable( xInternalQueueHandle ); 2212 } 2213 } 2214 } 2215 2216 return uxReturn; 2217 } 2218 /*-----------------------------------------------------------*/ 2219 2220 BaseType_t MPU_xQueueReceiveImpl( QueueHandle_t pxQueue, 2221 void * const pvBuffer, 2222 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; 2223 MPU_xQueueReceiveImpl(QueueHandle_t pxQueue,void * const pvBuffer,TickType_t xTicksToWait)2224 BaseType_t MPU_xQueueReceiveImpl( QueueHandle_t pxQueue, 2225 void * const pvBuffer, 2226 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */ 2227 { 2228 int32_t lIndex; 2229 QueueHandle_t xInternalQueueHandle = NULL; 2230 BaseType_t xReturn = pdFAIL; 2231 BaseType_t xIsReceiveBufferWritable = pdFALSE; 2232 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE; 2233 UBaseType_t uxQueueItemSize; 2234 2235 lIndex = ( int32_t ) pxQueue; 2236 2237 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 2238 { 2239 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2240 2241 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE ) 2242 { 2243 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2244 2245 if( xInternalQueueHandle != NULL ) 2246 { 2247 uxQueueItemSize = uxQueueGetQueueItemSize( xInternalQueueHandle ); 2248 2249 if( ( !( ( ( pvBuffer ) == NULL ) && ( uxQueueItemSize != ( UBaseType_t ) 0U ) ) ) 2250 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) 2251 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ) 2252 #endif 2253 ) 2254 { 2255 xIsReceiveBufferWritable = xPortIsAuthorizedToAccessBuffer( pvBuffer, 2256 uxQueueGetQueueItemSize( xInternalQueueHandle ), 2257 tskMPU_WRITE_PERMISSION ); 2258 2259 if( xIsReceiveBufferWritable == pdTRUE ) 2260 { 2261 xReturn = xQueueReceive( xInternalQueueHandle, pvBuffer, xTicksToWait ); 2262 } 2263 } 2264 } 2265 } 2266 } 2267 2268 return xReturn; 2269 } 2270 /*-----------------------------------------------------------*/ 2271 2272 BaseType_t MPU_xQueuePeekImpl( QueueHandle_t xQueue, 2273 void * const pvBuffer, 2274 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; 2275 MPU_xQueuePeekImpl(QueueHandle_t xQueue,void * const pvBuffer,TickType_t xTicksToWait)2276 BaseType_t MPU_xQueuePeekImpl( QueueHandle_t xQueue, 2277 void * const pvBuffer, 2278 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */ 2279 { 2280 int32_t lIndex; 2281 QueueHandle_t xInternalQueueHandle = NULL; 2282 BaseType_t xReturn = pdFAIL; 2283 BaseType_t xIsReceiveBufferWritable = pdFALSE; 2284 UBaseType_t uxQueueItemSize; 2285 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE; 2286 2287 lIndex = ( int32_t ) xQueue; 2288 2289 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 2290 { 2291 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2292 2293 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE ) 2294 { 2295 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2296 2297 if( xInternalQueueHandle != NULL ) 2298 { 2299 uxQueueItemSize = uxQueueGetQueueItemSize( xInternalQueueHandle ); 2300 2301 if( ( !( ( ( pvBuffer ) == NULL ) && ( uxQueueItemSize != ( UBaseType_t ) 0U ) ) ) 2302 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) 2303 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ) 2304 #endif 2305 ) 2306 { 2307 xIsReceiveBufferWritable = xPortIsAuthorizedToAccessBuffer( pvBuffer, 2308 uxQueueGetQueueItemSize( xInternalQueueHandle ), 2309 tskMPU_WRITE_PERMISSION ); 2310 2311 if( xIsReceiveBufferWritable == pdTRUE ) 2312 { 2313 xReturn = xQueuePeek( xInternalQueueHandle, pvBuffer, xTicksToWait ); 2314 } 2315 } 2316 } 2317 } 2318 } 2319 2320 return xReturn; 2321 } 2322 /*-----------------------------------------------------------*/ 2323 2324 BaseType_t MPU_xQueueSemaphoreTakeImpl( QueueHandle_t xQueue, 2325 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; 2326 MPU_xQueueSemaphoreTakeImpl(QueueHandle_t xQueue,TickType_t xTicksToWait)2327 BaseType_t MPU_xQueueSemaphoreTakeImpl( QueueHandle_t xQueue, 2328 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */ 2329 { 2330 int32_t lIndex; 2331 QueueHandle_t xInternalQueueHandle = NULL; 2332 BaseType_t xReturn = pdFAIL; 2333 UBaseType_t uxQueueItemSize; 2334 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE; 2335 2336 lIndex = ( int32_t ) xQueue; 2337 2338 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 2339 { 2340 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2341 2342 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE ) 2343 { 2344 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2345 2346 if( xInternalQueueHandle != NULL ) 2347 { 2348 uxQueueItemSize = uxQueueGetQueueItemSize( xInternalQueueHandle ); 2349 2350 if( ( uxQueueItemSize == 0 ) 2351 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) 2352 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ) 2353 #endif 2354 ) 2355 { 2356 xReturn = xQueueSemaphoreTake( xInternalQueueHandle, xTicksToWait ); 2357 } 2358 } 2359 } 2360 } 2361 2362 return xReturn; 2363 } 2364 /*-----------------------------------------------------------*/ 2365 2366 #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) 2367 2368 TaskHandle_t MPU_xQueueGetMutexHolderImpl( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; 2369 MPU_xQueueGetMutexHolderImpl(QueueHandle_t xSemaphore)2370 TaskHandle_t MPU_xQueueGetMutexHolderImpl( QueueHandle_t xSemaphore ) /* PRIVILEGED_FUNCTION */ 2371 { 2372 TaskHandle_t xMutexHolderTaskInternalHandle = NULL; 2373 TaskHandle_t xMutexHolderTaskExternalHandle = NULL; 2374 int32_t lIndex, lMutexHolderTaskIndex; 2375 QueueHandle_t xInternalQueueHandle = NULL; 2376 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE; 2377 2378 2379 lIndex = ( int32_t ) xSemaphore; 2380 2381 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 2382 { 2383 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2384 2385 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE ) 2386 { 2387 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2388 2389 if( xInternalQueueHandle != NULL ) 2390 { 2391 xMutexHolderTaskInternalHandle = xQueueGetMutexHolder( xInternalQueueHandle ); 2392 2393 if( xMutexHolderTaskInternalHandle != NULL ) 2394 { 2395 lMutexHolderTaskIndex = MPU_GetIndexForTaskHandle( xMutexHolderTaskInternalHandle ); 2396 2397 if( lMutexHolderTaskIndex != -1 ) 2398 { 2399 xMutexHolderTaskExternalHandle = ( TaskHandle_t ) ( CONVERT_TO_EXTERNAL_INDEX( lMutexHolderTaskIndex ) ); 2400 } 2401 } 2402 } 2403 } 2404 } 2405 2406 return xMutexHolderTaskExternalHandle; 2407 } 2408 2409 #endif /* if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) */ 2410 /*-----------------------------------------------------------*/ 2411 2412 #if ( configUSE_RECURSIVE_MUTEXES == 1 ) 2413 2414 BaseType_t MPU_xQueueTakeMutexRecursiveImpl( QueueHandle_t xMutex, 2415 TickType_t xBlockTime ) PRIVILEGED_FUNCTION; 2416 MPU_xQueueTakeMutexRecursiveImpl(QueueHandle_t xMutex,TickType_t xBlockTime)2417 BaseType_t MPU_xQueueTakeMutexRecursiveImpl( QueueHandle_t xMutex, 2418 TickType_t xBlockTime ) /* PRIVILEGED_FUNCTION */ 2419 { 2420 BaseType_t xReturn = pdFAIL; 2421 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE; 2422 int32_t lIndex; 2423 QueueHandle_t xInternalQueueHandle = NULL; 2424 UBaseType_t uxQueueItemSize; 2425 2426 lIndex = ( int32_t ) xMutex; 2427 2428 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 2429 { 2430 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2431 2432 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE ) 2433 { 2434 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2435 2436 if( xInternalQueueHandle != NULL ) 2437 { 2438 uxQueueItemSize = uxQueueGetQueueItemSize( xInternalQueueHandle ); 2439 2440 if( uxQueueItemSize == 0 ) 2441 { 2442 xReturn = xQueueTakeMutexRecursive( xInternalQueueHandle, xBlockTime ); 2443 } 2444 } 2445 } 2446 } 2447 2448 return xReturn; 2449 } 2450 2451 #endif /* if ( configUSE_RECURSIVE_MUTEXES == 1 ) */ 2452 /*-----------------------------------------------------------*/ 2453 2454 #if ( configUSE_RECURSIVE_MUTEXES == 1 ) 2455 2456 BaseType_t MPU_xQueueGiveMutexRecursiveImpl( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; 2457 MPU_xQueueGiveMutexRecursiveImpl(QueueHandle_t xMutex)2458 BaseType_t MPU_xQueueGiveMutexRecursiveImpl( QueueHandle_t xMutex ) /* PRIVILEGED_FUNCTION */ 2459 { 2460 BaseType_t xReturn = pdFAIL; 2461 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE; 2462 int32_t lIndex; 2463 QueueHandle_t xInternalQueueHandle = NULL; 2464 2465 lIndex = ( int32_t ) xMutex; 2466 2467 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 2468 { 2469 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2470 2471 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE ) 2472 { 2473 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2474 2475 if( xInternalQueueHandle != NULL ) 2476 { 2477 xReturn = xQueueGiveMutexRecursive( xInternalQueueHandle ); 2478 } 2479 } 2480 } 2481 2482 return xReturn; 2483 } 2484 2485 #endif /* if ( configUSE_RECURSIVE_MUTEXES == 1 ) */ 2486 /*-----------------------------------------------------------*/ 2487 2488 #if ( configUSE_QUEUE_SETS == 1 ) 2489 2490 QueueSetMemberHandle_t MPU_xQueueSelectFromSetImpl( QueueSetHandle_t xQueueSet, 2491 TickType_t xBlockTimeTicks ) PRIVILEGED_FUNCTION; 2492 MPU_xQueueSelectFromSetImpl(QueueSetHandle_t xQueueSet,TickType_t xBlockTimeTicks)2493 QueueSetMemberHandle_t MPU_xQueueSelectFromSetImpl( QueueSetHandle_t xQueueSet, 2494 TickType_t xBlockTimeTicks ) /* PRIVILEGED_FUNCTION */ 2495 { 2496 QueueSetHandle_t xInternalQueueSetHandle = NULL; 2497 QueueSetMemberHandle_t xSelectedMemberInternal = NULL; 2498 QueueSetMemberHandle_t xSelectedMemberExternal = NULL; 2499 int32_t lIndexQueueSet, lIndexSelectedMember; 2500 BaseType_t xCallingTaskIsAuthorizedToAccessQueueSet = pdFALSE; 2501 2502 lIndexQueueSet = ( int32_t ) xQueueSet; 2503 2504 if( IS_EXTERNAL_INDEX_VALID( lIndexQueueSet ) != pdFALSE ) 2505 { 2506 xCallingTaskIsAuthorizedToAccessQueueSet = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) ); 2507 2508 if( xCallingTaskIsAuthorizedToAccessQueueSet == pdTRUE ) 2509 { 2510 xInternalQueueSetHandle = MPU_GetQueueSetHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) ); 2511 2512 if( xInternalQueueSetHandle != NULL ) 2513 { 2514 xSelectedMemberInternal = xQueueSelectFromSet( xInternalQueueSetHandle, xBlockTimeTicks ); 2515 2516 if( xSelectedMemberInternal != NULL ) 2517 { 2518 lIndexSelectedMember = MPU_GetIndexForQueueSetMemberHandle( xSelectedMemberInternal ); 2519 2520 if( lIndexSelectedMember != -1 ) 2521 { 2522 xSelectedMemberExternal = ( QueueSetMemberHandle_t ) ( CONVERT_TO_EXTERNAL_INDEX( lIndexSelectedMember ) ); 2523 } 2524 } 2525 } 2526 } 2527 } 2528 2529 return xSelectedMemberExternal; 2530 } 2531 2532 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */ 2533 /*-----------------------------------------------------------*/ 2534 2535 #if ( configUSE_QUEUE_SETS == 1 ) 2536 2537 BaseType_t MPU_xQueueAddToSetImpl( QueueSetMemberHandle_t xQueueOrSemaphore, 2538 QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; 2539 MPU_xQueueAddToSetImpl(QueueSetMemberHandle_t xQueueOrSemaphore,QueueSetHandle_t xQueueSet)2540 BaseType_t MPU_xQueueAddToSetImpl( QueueSetMemberHandle_t xQueueOrSemaphore, 2541 QueueSetHandle_t xQueueSet ) /* PRIVILEGED_FUNCTION */ 2542 { 2543 BaseType_t xReturn = pdFAIL; 2544 QueueSetMemberHandle_t xInternalQueueSetMemberHandle = NULL; 2545 QueueSetHandle_t xInternalQueueSetHandle = NULL; 2546 int32_t lIndexQueueSet, lIndexQueueSetMember; 2547 BaseType_t xCallingTaskIsAuthorizedToAccessQueueSet = pdFALSE; 2548 BaseType_t xCallingTaskIsAuthorizedToAccessQueueSetMember = pdFALSE; 2549 2550 lIndexQueueSet = ( int32_t ) xQueueSet; 2551 lIndexQueueSetMember = ( int32_t ) xQueueOrSemaphore; 2552 2553 if( ( IS_EXTERNAL_INDEX_VALID( lIndexQueueSet ) != pdFALSE ) && 2554 ( IS_EXTERNAL_INDEX_VALID( lIndexQueueSetMember ) != pdFALSE ) ) 2555 { 2556 xCallingTaskIsAuthorizedToAccessQueueSet = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) ); 2557 xCallingTaskIsAuthorizedToAccessQueueSetMember = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSetMember ) ); 2558 2559 if( ( xCallingTaskIsAuthorizedToAccessQueueSet == pdTRUE ) && ( xCallingTaskIsAuthorizedToAccessQueueSetMember == pdTRUE ) ) 2560 { 2561 xInternalQueueSetHandle = MPU_GetQueueSetHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) ); 2562 xInternalQueueSetMemberHandle = MPU_GetQueueSetMemberHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSetMember ) ); 2563 2564 if( ( xInternalQueueSetHandle != NULL ) && ( xInternalQueueSetMemberHandle != NULL ) ) 2565 { 2566 xReturn = xQueueAddToSet( xInternalQueueSetMemberHandle, xInternalQueueSetHandle ); 2567 } 2568 } 2569 } 2570 2571 return xReturn; 2572 } 2573 2574 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */ 2575 /*-----------------------------------------------------------*/ 2576 2577 #if configQUEUE_REGISTRY_SIZE > 0 2578 2579 void MPU_vQueueAddToRegistryImpl( QueueHandle_t xQueue, 2580 const char * pcName ) PRIVILEGED_FUNCTION; 2581 MPU_vQueueAddToRegistryImpl(QueueHandle_t xQueue,const char * pcName)2582 void MPU_vQueueAddToRegistryImpl( QueueHandle_t xQueue, 2583 const char * pcName ) /* PRIVILEGED_FUNCTION */ 2584 { 2585 int32_t lIndex; 2586 QueueHandle_t xInternalQueueHandle = NULL; 2587 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE; 2588 2589 lIndex = ( int32_t ) xQueue; 2590 2591 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 2592 { 2593 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2594 2595 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE ) 2596 { 2597 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2598 2599 if( xInternalQueueHandle != NULL ) 2600 { 2601 vQueueAddToRegistry( xInternalQueueHandle, pcName ); 2602 } 2603 } 2604 } 2605 } 2606 2607 #endif /* if configQUEUE_REGISTRY_SIZE > 0 */ 2608 /*-----------------------------------------------------------*/ 2609 2610 #if configQUEUE_REGISTRY_SIZE > 0 2611 2612 void MPU_vQueueUnregisterQueueImpl( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; 2613 MPU_vQueueUnregisterQueueImpl(QueueHandle_t xQueue)2614 void MPU_vQueueUnregisterQueueImpl( QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */ 2615 { 2616 int32_t lIndex; 2617 QueueHandle_t xInternalQueueHandle = NULL; 2618 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE; 2619 2620 lIndex = ( int32_t ) xQueue; 2621 2622 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 2623 { 2624 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2625 2626 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE ) 2627 { 2628 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2629 2630 if( xInternalQueueHandle != NULL ) 2631 { 2632 vQueueUnregisterQueue( xInternalQueueHandle ); 2633 } 2634 } 2635 } 2636 } 2637 2638 #endif /* if configQUEUE_REGISTRY_SIZE > 0 */ 2639 /*-----------------------------------------------------------*/ 2640 2641 #if configQUEUE_REGISTRY_SIZE > 0 2642 2643 const char * MPU_pcQueueGetNameImpl( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; 2644 MPU_pcQueueGetNameImpl(QueueHandle_t xQueue)2645 const char * MPU_pcQueueGetNameImpl( QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */ 2646 { 2647 const char * pcReturn = NULL; 2648 QueueHandle_t xInternalQueueHandle = NULL; 2649 int32_t lIndex; 2650 BaseType_t xCallingTaskIsAuthorizedToAccessQueue = pdFALSE; 2651 2652 lIndex = ( int32_t ) xQueue; 2653 2654 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 2655 { 2656 xCallingTaskIsAuthorizedToAccessQueue = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2657 2658 if( xCallingTaskIsAuthorizedToAccessQueue == pdTRUE ) 2659 { 2660 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2661 2662 if( xInternalQueueHandle != NULL ) 2663 { 2664 pcReturn = pcQueueGetName( xInternalQueueHandle ); 2665 } 2666 } 2667 } 2668 2669 return pcReturn; 2670 } 2671 2672 #endif /* if configQUEUE_REGISTRY_SIZE > 0 */ 2673 /*-----------------------------------------------------------*/ 2674 2675 /* Privileged only wrappers for Queue APIs. These are needed so that 2676 * the application can use opaque handles maintained in mpu_wrappers.c 2677 * with all the APIs. */ 2678 /*-----------------------------------------------------------*/ 2679 MPU_vQueueDelete(QueueHandle_t xQueue)2680 void MPU_vQueueDelete( QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */ 2681 { 2682 QueueHandle_t xInternalQueueHandle = NULL; 2683 int32_t lIndex; 2684 2685 lIndex = ( int32_t ) xQueue; 2686 2687 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 2688 { 2689 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2690 2691 if( xInternalQueueHandle != NULL ) 2692 { 2693 vQueueDelete( xInternalQueueHandle ); 2694 MPU_SetIndexFreeInKernelObjectPool( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2695 } 2696 } 2697 } 2698 /*-----------------------------------------------------------*/ 2699 2700 #if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) 2701 MPU_xQueueCreateMutex(const uint8_t ucQueueType)2702 QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) /* PRIVILEGED_FUNCTION */ 2703 { 2704 QueueHandle_t xInternalQueueHandle = NULL; 2705 QueueHandle_t xExternalQueueHandle = NULL; 2706 int32_t lIndex; 2707 2708 lIndex = MPU_GetFreeIndexInKernelObjectPool(); 2709 2710 if( lIndex != -1 ) 2711 { 2712 xInternalQueueHandle = xQueueCreateMutex( ucQueueType ); 2713 2714 if( xInternalQueueHandle != NULL ) 2715 { 2716 MPU_StoreQueueHandleAtIndex( lIndex, xInternalQueueHandle ); 2717 xExternalQueueHandle = ( QueueHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 2718 } 2719 else 2720 { 2721 MPU_SetIndexFreeInKernelObjectPool( lIndex ); 2722 } 2723 } 2724 2725 return xExternalQueueHandle; 2726 } 2727 2728 #endif /* if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */ 2729 /*-----------------------------------------------------------*/ 2730 2731 #if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) 2732 MPU_xQueueCreateMutexStatic(const uint8_t ucQueueType,StaticQueue_t * pxStaticQueue)2733 QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType, 2734 StaticQueue_t * pxStaticQueue ) /* PRIVILEGED_FUNCTION */ 2735 { 2736 QueueHandle_t xInternalQueueHandle = NULL; 2737 QueueHandle_t xExternalQueueHandle = NULL; 2738 int32_t lIndex; 2739 2740 lIndex = MPU_GetFreeIndexInKernelObjectPool(); 2741 2742 if( lIndex != -1 ) 2743 { 2744 xInternalQueueHandle = xQueueCreateMutexStatic( ucQueueType, pxStaticQueue ); 2745 2746 if( xInternalQueueHandle != NULL ) 2747 { 2748 MPU_StoreQueueHandleAtIndex( lIndex, xInternalQueueHandle ); 2749 xExternalQueueHandle = ( QueueHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 2750 } 2751 else 2752 { 2753 MPU_SetIndexFreeInKernelObjectPool( lIndex ); 2754 } 2755 } 2756 2757 return xExternalQueueHandle; 2758 } 2759 2760 #endif /* if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) */ 2761 /*-----------------------------------------------------------*/ 2762 2763 #if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) 2764 MPU_xQueueCreateCountingSemaphore(UBaseType_t uxCountValue,UBaseType_t uxInitialCount)2765 QueueHandle_t MPU_xQueueCreateCountingSemaphore( UBaseType_t uxCountValue, 2766 UBaseType_t uxInitialCount ) /* PRIVILEGED_FUNCTION */ 2767 { 2768 QueueHandle_t xInternalQueueHandle = NULL; 2769 QueueHandle_t xExternalQueueHandle = NULL; 2770 int32_t lIndex; 2771 2772 lIndex = MPU_GetFreeIndexInKernelObjectPool(); 2773 2774 if( lIndex != -1 ) 2775 { 2776 xInternalQueueHandle = xQueueCreateCountingSemaphore( uxCountValue, uxInitialCount ); 2777 2778 if( xInternalQueueHandle != NULL ) 2779 { 2780 MPU_StoreQueueHandleAtIndex( lIndex, xInternalQueueHandle ); 2781 xExternalQueueHandle = ( QueueHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 2782 } 2783 else 2784 { 2785 MPU_SetIndexFreeInKernelObjectPool( lIndex ); 2786 } 2787 } 2788 2789 return xExternalQueueHandle; 2790 } 2791 2792 #endif /* if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */ 2793 /*-----------------------------------------------------------*/ 2794 2795 #if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) 2796 MPU_xQueueCreateCountingSemaphoreStatic(const UBaseType_t uxMaxCount,const UBaseType_t uxInitialCount,StaticQueue_t * pxStaticQueue)2797 QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, 2798 const UBaseType_t uxInitialCount, 2799 StaticQueue_t * pxStaticQueue ) /* PRIVILEGED_FUNCTION */ 2800 { 2801 QueueHandle_t xInternalQueueHandle = NULL; 2802 QueueHandle_t xExternalQueueHandle = NULL; 2803 int32_t lIndex; 2804 2805 lIndex = MPU_GetFreeIndexInKernelObjectPool(); 2806 2807 if( lIndex != -1 ) 2808 { 2809 xInternalQueueHandle = xQueueCreateCountingSemaphoreStatic( uxMaxCount, uxInitialCount, pxStaticQueue ); 2810 2811 if( xInternalQueueHandle != NULL ) 2812 { 2813 MPU_StoreQueueHandleAtIndex( lIndex, xInternalQueueHandle ); 2814 xExternalQueueHandle = ( QueueHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 2815 } 2816 else 2817 { 2818 MPU_SetIndexFreeInKernelObjectPool( lIndex ); 2819 } 2820 } 2821 2822 return xExternalQueueHandle; 2823 } 2824 2825 #endif /* if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) */ 2826 /*-----------------------------------------------------------*/ 2827 2828 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) 2829 MPU_xQueueGenericCreate(UBaseType_t uxQueueLength,UBaseType_t uxItemSize,uint8_t ucQueueType)2830 QueueHandle_t MPU_xQueueGenericCreate( UBaseType_t uxQueueLength, 2831 UBaseType_t uxItemSize, 2832 uint8_t ucQueueType ) /* PRIVILEGED_FUNCTION */ 2833 { 2834 QueueHandle_t xInternalQueueHandle = NULL; 2835 QueueHandle_t xExternalQueueHandle = NULL; 2836 int32_t lIndex; 2837 2838 lIndex = MPU_GetFreeIndexInKernelObjectPool(); 2839 2840 if( lIndex != -1 ) 2841 { 2842 xInternalQueueHandle = xQueueGenericCreate( uxQueueLength, uxItemSize, ucQueueType ); 2843 2844 if( xInternalQueueHandle != NULL ) 2845 { 2846 MPU_StoreQueueHandleAtIndex( lIndex, xInternalQueueHandle ); 2847 xExternalQueueHandle = ( QueueHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 2848 } 2849 else 2850 { 2851 MPU_SetIndexFreeInKernelObjectPool( lIndex ); 2852 } 2853 } 2854 2855 return xExternalQueueHandle; 2856 } 2857 2858 #endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) */ 2859 /*-----------------------------------------------------------*/ 2860 2861 #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) 2862 MPU_xQueueGenericCreateStatic(const UBaseType_t uxQueueLength,const UBaseType_t uxItemSize,uint8_t * pucQueueStorage,StaticQueue_t * pxStaticQueue,const uint8_t ucQueueType)2863 QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, 2864 const UBaseType_t uxItemSize, 2865 uint8_t * pucQueueStorage, 2866 StaticQueue_t * pxStaticQueue, 2867 const uint8_t ucQueueType ) /* PRIVILEGED_FUNCTION */ 2868 { 2869 QueueHandle_t xInternalQueueHandle = NULL; 2870 QueueHandle_t xExternalQueueHandle = NULL; 2871 int32_t lIndex; 2872 2873 lIndex = MPU_GetFreeIndexInKernelObjectPool(); 2874 2875 if( lIndex != -1 ) 2876 { 2877 xInternalQueueHandle = xQueueGenericCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxStaticQueue, ucQueueType ); 2878 2879 if( xInternalQueueHandle != NULL ) 2880 { 2881 MPU_StoreQueueHandleAtIndex( lIndex, xInternalQueueHandle ); 2882 xExternalQueueHandle = ( QueueHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 2883 } 2884 else 2885 { 2886 MPU_SetIndexFreeInKernelObjectPool( lIndex ); 2887 } 2888 } 2889 2890 return xExternalQueueHandle; 2891 } 2892 2893 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */ 2894 /*-----------------------------------------------------------*/ 2895 MPU_xQueueGenericReset(QueueHandle_t xQueue,BaseType_t xNewQueue)2896 BaseType_t MPU_xQueueGenericReset( QueueHandle_t xQueue, 2897 BaseType_t xNewQueue ) /* PRIVILEGED_FUNCTION */ 2898 { 2899 int32_t lIndex; 2900 QueueHandle_t xInternalQueueHandle = NULL; 2901 BaseType_t xReturn = pdFAIL; 2902 2903 lIndex = ( uint32_t ) xQueue; 2904 2905 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 2906 { 2907 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2908 2909 if( xInternalQueueHandle != NULL ) 2910 { 2911 xReturn = xQueueGenericReset( xInternalQueueHandle, xNewQueue ); 2912 } 2913 } 2914 2915 return xReturn; 2916 } 2917 /*-----------------------------------------------------------*/ 2918 2919 #if ( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) 2920 MPU_xQueueCreateSet(UBaseType_t uxEventQueueLength)2921 QueueSetHandle_t MPU_xQueueCreateSet( UBaseType_t uxEventQueueLength ) /* PRIVILEGED_FUNCTION */ 2922 { 2923 QueueSetHandle_t xInternalQueueSetHandle = NULL; 2924 QueueSetHandle_t xExternalQueueSetHandle = NULL; 2925 int32_t lIndex; 2926 2927 lIndex = MPU_GetFreeIndexInKernelObjectPool(); 2928 2929 if( lIndex != -1 ) 2930 { 2931 xInternalQueueSetHandle = xQueueCreateSet( uxEventQueueLength ); 2932 2933 if( xInternalQueueSetHandle != NULL ) 2934 { 2935 MPU_StoreQueueSetHandleAtIndex( lIndex, xInternalQueueSetHandle ); 2936 xExternalQueueSetHandle = ( QueueSetHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 2937 } 2938 else 2939 { 2940 MPU_SetIndexFreeInKernelObjectPool( lIndex ); 2941 } 2942 } 2943 2944 return xExternalQueueSetHandle; 2945 } 2946 2947 #endif /* if ( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */ 2948 /*-----------------------------------------------------------*/ 2949 2950 #if ( configUSE_QUEUE_SETS == 1 ) 2951 MPU_xQueueRemoveFromSet(QueueSetMemberHandle_t xQueueOrSemaphore,QueueSetHandle_t xQueueSet)2952 BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, 2953 QueueSetHandle_t xQueueSet ) /* PRIVILEGED_FUNCTION */ 2954 { 2955 BaseType_t xReturn = pdFAIL; 2956 QueueSetMemberHandle_t xInternalQueueSetMemberHandle = NULL; 2957 QueueSetHandle_t xInternalQueueSetHandle = NULL; 2958 int32_t lIndexQueueSet, lIndexQueueSetMember; 2959 2960 lIndexQueueSet = ( int32_t ) xQueueSet; 2961 lIndexQueueSetMember = ( int32_t ) xQueueOrSemaphore; 2962 2963 if( ( IS_EXTERNAL_INDEX_VALID( lIndexQueueSet ) != pdFALSE ) && 2964 ( IS_EXTERNAL_INDEX_VALID( lIndexQueueSetMember ) != pdFALSE ) ) 2965 { 2966 xInternalQueueSetHandle = MPU_GetQueueSetHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) ); 2967 xInternalQueueSetMemberHandle = MPU_GetQueueSetMemberHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSetMember ) ); 2968 2969 if( ( xInternalQueueSetHandle != NULL ) && ( xInternalQueueSetMemberHandle != NULL ) ) 2970 { 2971 xReturn = xQueueRemoveFromSet( xInternalQueueSetMemberHandle, xInternalQueueSetHandle ); 2972 } 2973 } 2974 2975 return xReturn; 2976 } 2977 2978 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */ 2979 /*-----------------------------------------------------------*/ 2980 2981 #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) 2982 MPU_xQueueGenericGetStaticBuffers(QueueHandle_t xQueue,uint8_t ** ppucQueueStorage,StaticQueue_t ** ppxStaticQueue)2983 BaseType_t MPU_xQueueGenericGetStaticBuffers( QueueHandle_t xQueue, 2984 uint8_t ** ppucQueueStorage, 2985 StaticQueue_t ** ppxStaticQueue ) /* PRIVILEGED_FUNCTION */ 2986 { 2987 int32_t lIndex; 2988 QueueHandle_t xInternalQueueHandle = NULL; 2989 BaseType_t xReturn = pdFALSE; 2990 2991 lIndex = ( int32_t ) xQueue; 2992 2993 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 2994 { 2995 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 2996 2997 if( xInternalQueueHandle != NULL ) 2998 { 2999 xReturn = xQueueGenericGetStaticBuffers( xInternalQueueHandle, ppucQueueStorage, ppxStaticQueue ); 3000 } 3001 } 3002 3003 return xReturn; 3004 } 3005 3006 #endif /*if ( configSUPPORT_STATIC_ALLOCATION == 1 )*/ 3007 /*-----------------------------------------------------------*/ 3008 MPU_xQueueGenericSendFromISR(QueueHandle_t xQueue,const void * const pvItemToQueue,BaseType_t * const pxHigherPriorityTaskWoken,const BaseType_t xCopyPosition)3009 BaseType_t MPU_xQueueGenericSendFromISR( QueueHandle_t xQueue, 3010 const void * const pvItemToQueue, 3011 BaseType_t * const pxHigherPriorityTaskWoken, 3012 const BaseType_t xCopyPosition ) /* PRIVILEGED_FUNCTION */ 3013 { 3014 BaseType_t xReturn = pdFAIL; 3015 int32_t lIndex; 3016 QueueHandle_t xInternalQueueHandle = NULL; 3017 3018 lIndex = ( int32_t ) xQueue; 3019 3020 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3021 { 3022 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3023 3024 if( xInternalQueueHandle != NULL ) 3025 { 3026 xReturn = xQueueGenericSendFromISR( xInternalQueueHandle, pvItemToQueue, pxHigherPriorityTaskWoken, xCopyPosition ); 3027 } 3028 } 3029 3030 return xReturn; 3031 } 3032 3033 /*-----------------------------------------------------------*/ 3034 MPU_xQueueGiveFromISR(QueueHandle_t xQueue,BaseType_t * const pxHigherPriorityTaskWoken)3035 BaseType_t MPU_xQueueGiveFromISR( QueueHandle_t xQueue, 3036 BaseType_t * const pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */ 3037 { 3038 BaseType_t xReturn = pdFAIL; 3039 int32_t lIndex; 3040 QueueHandle_t xInternalQueueHandle = NULL; 3041 3042 lIndex = ( int32_t ) xQueue; 3043 3044 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3045 { 3046 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3047 3048 if( xInternalQueueHandle != NULL ) 3049 { 3050 xReturn = xQueueGiveFromISR( xInternalQueueHandle, pxHigherPriorityTaskWoken ); 3051 } 3052 } 3053 3054 return xReturn; 3055 } 3056 3057 /*-----------------------------------------------------------*/ 3058 MPU_xQueuePeekFromISR(QueueHandle_t xQueue,void * const pvBuffer)3059 BaseType_t MPU_xQueuePeekFromISR( QueueHandle_t xQueue, 3060 void * const pvBuffer ) /* PRIVILEGED_FUNCTION */ 3061 { 3062 BaseType_t xReturn = pdFAIL; 3063 int32_t lIndex; 3064 QueueHandle_t xInternalQueueHandle = NULL; 3065 3066 lIndex = ( int32_t ) xQueue; 3067 3068 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3069 { 3070 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3071 3072 if( xInternalQueueHandle != NULL ) 3073 { 3074 xReturn = xQueuePeekFromISR( xInternalQueueHandle, pvBuffer ); 3075 } 3076 } 3077 3078 return xReturn; 3079 } 3080 3081 /*-----------------------------------------------------------*/ 3082 MPU_xQueueReceiveFromISR(QueueHandle_t xQueue,void * const pvBuffer,BaseType_t * const pxHigherPriorityTaskWoken)3083 BaseType_t MPU_xQueueReceiveFromISR( QueueHandle_t xQueue, 3084 void * const pvBuffer, 3085 BaseType_t * const pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */ 3086 { 3087 BaseType_t xReturn = pdFAIL; 3088 int32_t lIndex; 3089 QueueHandle_t xInternalQueueHandle = NULL; 3090 3091 lIndex = ( int32_t ) xQueue; 3092 3093 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3094 { 3095 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3096 3097 if( xInternalQueueHandle != NULL ) 3098 { 3099 xReturn = xQueueReceiveFromISR( xInternalQueueHandle, pvBuffer, pxHigherPriorityTaskWoken ); 3100 } 3101 } 3102 3103 return xReturn; 3104 } 3105 3106 /*-----------------------------------------------------------*/ 3107 MPU_xQueueIsQueueEmptyFromISR(const QueueHandle_t xQueue)3108 BaseType_t MPU_xQueueIsQueueEmptyFromISR( const QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */ 3109 { 3110 BaseType_t xReturn = pdFAIL; 3111 int32_t lIndex; 3112 QueueHandle_t xInternalQueueHandle = NULL; 3113 3114 lIndex = ( int32_t ) xQueue; 3115 3116 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3117 { 3118 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3119 3120 if( xInternalQueueHandle != NULL ) 3121 { 3122 xReturn = xQueueIsQueueEmptyFromISR( xInternalQueueHandle ); 3123 } 3124 } 3125 3126 return xReturn; 3127 } 3128 /*-----------------------------------------------------------*/ 3129 MPU_xQueueIsQueueFullFromISR(const QueueHandle_t xQueue)3130 BaseType_t MPU_xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */ 3131 { 3132 BaseType_t xReturn = pdFAIL; 3133 int32_t lIndex; 3134 QueueHandle_t xInternalQueueHandle = NULL; 3135 3136 lIndex = ( int32_t ) xQueue; 3137 3138 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3139 { 3140 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3141 3142 if( xInternalQueueHandle != NULL ) 3143 { 3144 xReturn = xQueueIsQueueFullFromISR( xInternalQueueHandle ); 3145 } 3146 } 3147 3148 return xReturn; 3149 } 3150 3151 /*-----------------------------------------------------------*/ 3152 MPU_uxQueueMessagesWaitingFromISR(const QueueHandle_t xQueue)3153 UBaseType_t MPU_uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */ 3154 { 3155 UBaseType_t uxReturn = 0; 3156 int32_t lIndex; 3157 QueueHandle_t xInternalQueueHandle = NULL; 3158 3159 lIndex = ( int32_t ) xQueue; 3160 3161 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3162 { 3163 xInternalQueueHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3164 3165 if( xInternalQueueHandle != NULL ) 3166 { 3167 uxReturn = uxQueueMessagesWaitingFromISR( xInternalQueueHandle ); 3168 } 3169 } 3170 3171 return uxReturn; 3172 } 3173 3174 /*-----------------------------------------------------------*/ 3175 3176 #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) 3177 MPU_xQueueGetMutexHolderFromISR(QueueHandle_t xSemaphore)3178 TaskHandle_t MPU_xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) /* PRIVILEGED_FUNCTION */ 3179 { 3180 TaskHandle_t xMutexHolderTaskInternalHandle = NULL; 3181 TaskHandle_t xMutexHolderTaskExternalHandle = NULL; 3182 int32_t lIndex, lMutexHolderTaskIndex; 3183 QueueHandle_t xInternalSemaphoreHandle = NULL; 3184 3185 lIndex = ( int32_t ) xSemaphore; 3186 3187 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3188 { 3189 xInternalSemaphoreHandle = MPU_GetQueueHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3190 3191 if( xInternalSemaphoreHandle != NULL ) 3192 { 3193 xMutexHolderTaskInternalHandle = xQueueGetMutexHolder( xInternalSemaphoreHandle ); 3194 3195 if( xMutexHolderTaskInternalHandle != NULL ) 3196 { 3197 lMutexHolderTaskIndex = MPU_GetIndexForTaskHandle( xMutexHolderTaskInternalHandle ); 3198 3199 if( lMutexHolderTaskIndex != -1 ) 3200 { 3201 xMutexHolderTaskExternalHandle = ( TaskHandle_t ) ( CONVERT_TO_EXTERNAL_INDEX( lMutexHolderTaskIndex ) ); 3202 } 3203 } 3204 } 3205 } 3206 3207 return xMutexHolderTaskExternalHandle; 3208 } 3209 3210 #endif /* #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) */ 3211 /*-----------------------------------------------------------*/ 3212 3213 #if ( configUSE_QUEUE_SETS == 1 ) 3214 MPU_xQueueSelectFromSetFromISR(QueueSetHandle_t xQueueSet)3215 QueueSetMemberHandle_t MPU_xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet ) /* PRIVILEGED_FUNCTION */ 3216 { 3217 QueueSetHandle_t xInternalQueueSetHandle = NULL; 3218 QueueSetMemberHandle_t xSelectedMemberInternal = NULL; 3219 QueueSetMemberHandle_t xSelectedMemberExternal = NULL; 3220 int32_t lIndexQueueSet, lIndexSelectedMember; 3221 3222 lIndexQueueSet = ( int32_t ) xQueueSet; 3223 3224 if( IS_EXTERNAL_INDEX_VALID( lIndexQueueSet ) != pdFALSE ) 3225 { 3226 xInternalQueueSetHandle = MPU_GetQueueSetHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndexQueueSet ) ); 3227 3228 if( xInternalQueueSetHandle != NULL ) 3229 { 3230 xSelectedMemberInternal = xQueueSelectFromSetFromISR( xInternalQueueSetHandle ); 3231 3232 if( xSelectedMemberInternal != NULL ) 3233 { 3234 lIndexSelectedMember = MPU_GetIndexForQueueSetMemberHandle( xSelectedMemberInternal ); 3235 3236 if( lIndexSelectedMember != -1 ) 3237 { 3238 xSelectedMemberExternal = ( QueueSetMemberHandle_t ) ( CONVERT_TO_EXTERNAL_INDEX( lIndexSelectedMember ) ); 3239 } 3240 } 3241 } 3242 } 3243 3244 return xSelectedMemberExternal; 3245 } 3246 3247 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */ 3248 /*-----------------------------------------------------------*/ 3249 3250 /*-----------------------------------------------------------*/ 3251 /* MPU wrappers for timers APIs. */ 3252 /*-----------------------------------------------------------*/ 3253 3254 #if ( configUSE_TIMERS == 1 ) 3255 3256 void * MPU_pvTimerGetTimerIDImpl( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; 3257 MPU_pvTimerGetTimerIDImpl(const TimerHandle_t xTimer)3258 void * MPU_pvTimerGetTimerIDImpl( const TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */ 3259 { 3260 void * pvReturn = NULL; 3261 TimerHandle_t xInternalTimerHandle = NULL; 3262 int32_t lIndex; 3263 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE; 3264 3265 lIndex = ( int32_t ) xTimer; 3266 3267 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3268 { 3269 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3270 3271 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE ) 3272 { 3273 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3274 3275 if( xInternalTimerHandle != NULL ) 3276 { 3277 pvReturn = pvTimerGetTimerID( xInternalTimerHandle ); 3278 } 3279 } 3280 } 3281 3282 return pvReturn; 3283 } 3284 3285 #endif /* if ( configUSE_TIMERS == 1 ) */ 3286 /*-----------------------------------------------------------*/ 3287 3288 #if ( configUSE_TIMERS == 1 ) 3289 3290 void MPU_vTimerSetTimerIDImpl( TimerHandle_t xTimer, 3291 void * pvNewID ) PRIVILEGED_FUNCTION; 3292 MPU_vTimerSetTimerIDImpl(TimerHandle_t xTimer,void * pvNewID)3293 void MPU_vTimerSetTimerIDImpl( TimerHandle_t xTimer, 3294 void * pvNewID ) /* PRIVILEGED_FUNCTION */ 3295 { 3296 TimerHandle_t xInternalTimerHandle = NULL; 3297 int32_t lIndex; 3298 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE; 3299 3300 lIndex = ( int32_t ) xTimer; 3301 3302 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3303 { 3304 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3305 3306 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE ) 3307 { 3308 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3309 3310 if( xInternalTimerHandle != NULL ) 3311 { 3312 vTimerSetTimerID( xInternalTimerHandle, pvNewID ); 3313 } 3314 } 3315 } 3316 } 3317 3318 #endif /* if ( configUSE_TIMERS == 1 ) */ 3319 /*-----------------------------------------------------------*/ 3320 3321 #if ( configUSE_TIMERS == 1 ) 3322 3323 BaseType_t MPU_xTimerIsTimerActiveImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; 3324 MPU_xTimerIsTimerActiveImpl(TimerHandle_t xTimer)3325 BaseType_t MPU_xTimerIsTimerActiveImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */ 3326 { 3327 BaseType_t xReturn = pdFALSE; 3328 TimerHandle_t xInternalTimerHandle = NULL; 3329 int32_t lIndex; 3330 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE; 3331 3332 lIndex = ( int32_t ) xTimer; 3333 3334 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3335 { 3336 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3337 3338 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE ) 3339 { 3340 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3341 3342 if( xInternalTimerHandle != NULL ) 3343 { 3344 xReturn = xTimerIsTimerActive( xInternalTimerHandle ); 3345 } 3346 } 3347 } 3348 3349 return xReturn; 3350 } 3351 3352 #endif /* if ( configUSE_TIMERS == 1 ) */ 3353 /*-----------------------------------------------------------*/ 3354 3355 #if ( configUSE_TIMERS == 1 ) 3356 3357 TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandleImpl( void ) PRIVILEGED_FUNCTION; 3358 MPU_xTimerGetTimerDaemonTaskHandleImpl(void)3359 TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandleImpl( void ) /* PRIVILEGED_FUNCTION */ 3360 { 3361 TaskHandle_t xReturn; 3362 3363 xReturn = xTimerGetTimerDaemonTaskHandle(); 3364 3365 return xReturn; 3366 } 3367 3368 #endif /* if ( configUSE_TIMERS == 1 ) */ 3369 /*-----------------------------------------------------------*/ 3370 3371 #if ( configUSE_TIMERS == 1 ) 3372 MPU_xTimerGenericCommand(TimerHandle_t xTimer,const BaseType_t xCommandID,const TickType_t xOptionalValue,BaseType_t * const pxHigherPriorityTaskWoken,const TickType_t xTicksToWait)3373 BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer, 3374 const BaseType_t xCommandID, 3375 const TickType_t xOptionalValue, 3376 BaseType_t * const pxHigherPriorityTaskWoken, 3377 const TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ 3378 { 3379 BaseType_t xReturn = pdFALSE; 3380 xTimerGenericCommandParams_t xParams; 3381 3382 xParams.xTimer = xTimer; 3383 xParams.xCommandID = xCommandID; 3384 xParams.xOptionalValue = xOptionalValue; 3385 xParams.pxHigherPriorityTaskWoken = pxHigherPriorityTaskWoken; 3386 xParams.xTicksToWait = xTicksToWait; 3387 3388 xReturn = MPU_xTimerGenericCommandEntry( &( xParams ) ); 3389 3390 return xReturn; 3391 } 3392 3393 BaseType_t MPU_xTimerGenericCommandImpl( const xTimerGenericCommandParams_t * pxParams ) PRIVILEGED_FUNCTION; 3394 MPU_xTimerGenericCommandImpl(const xTimerGenericCommandParams_t * pxParams)3395 BaseType_t MPU_xTimerGenericCommandImpl( const xTimerGenericCommandParams_t * pxParams ) /* PRIVILEGED_FUNCTION */ 3396 { 3397 BaseType_t xReturn = pdFALSE; 3398 TimerHandle_t xInternalTimerHandle = NULL; 3399 int32_t lIndex; 3400 BaseType_t xIsHigherPriorityTaskWokenWriteable = pdFALSE; 3401 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE; 3402 BaseType_t xAreParamsReadable = pdFALSE; 3403 3404 if( pxParams != NULL ) 3405 { 3406 xAreParamsReadable = xPortIsAuthorizedToAccessBuffer( pxParams, 3407 sizeof( xTimerGenericCommandParams_t ), 3408 tskMPU_READ_PERMISSION ); 3409 } 3410 3411 if( xAreParamsReadable == pdTRUE ) 3412 { 3413 if( pxParams->pxHigherPriorityTaskWoken != NULL ) 3414 { 3415 xIsHigherPriorityTaskWokenWriteable = xPortIsAuthorizedToAccessBuffer( pxParams->pxHigherPriorityTaskWoken, 3416 sizeof( BaseType_t ), 3417 tskMPU_WRITE_PERMISSION ); 3418 } 3419 3420 if( ( pxParams->pxHigherPriorityTaskWoken == NULL ) || 3421 ( xIsHigherPriorityTaskWokenWriteable == pdTRUE ) ) 3422 { 3423 lIndex = ( int32_t ) ( pxParams->xTimer ); 3424 3425 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3426 { 3427 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3428 3429 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE ) 3430 { 3431 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3432 3433 if( xInternalTimerHandle != NULL ) 3434 { 3435 xReturn = xTimerGenericCommand( xInternalTimerHandle, 3436 pxParams->xCommandID, 3437 pxParams->xOptionalValue, 3438 pxParams->pxHigherPriorityTaskWoken, 3439 pxParams->xTicksToWait ); 3440 } 3441 } 3442 } 3443 } 3444 } 3445 3446 return xReturn; 3447 } 3448 3449 BaseType_t MPU_xTimerGenericCommandPrivImpl( const xTimerGenericCommandParams_t * pxParams ) PRIVILEGED_FUNCTION; 3450 MPU_xTimerGenericCommandPrivImpl(const xTimerGenericCommandParams_t * pxParams)3451 BaseType_t MPU_xTimerGenericCommandPrivImpl( const xTimerGenericCommandParams_t * pxParams ) /* PRIVILEGED_FUNCTION */ 3452 { 3453 BaseType_t xReturn = pdFALSE; 3454 TimerHandle_t xInternalTimerHandle = NULL; 3455 int32_t lIndex; 3456 3457 if( pxParams != NULL ) 3458 { 3459 lIndex = ( int32_t ) ( pxParams->xTimer ); 3460 3461 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3462 { 3463 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3464 3465 if( xInternalTimerHandle != NULL ) 3466 { 3467 xReturn = xTimerGenericCommand( xInternalTimerHandle, 3468 pxParams->xCommandID, 3469 pxParams->xOptionalValue, 3470 pxParams->pxHigherPriorityTaskWoken, 3471 pxParams->xTicksToWait ); 3472 } 3473 } 3474 } 3475 3476 return xReturn; 3477 } 3478 3479 #endif /* if ( configUSE_TIMERS == 1 ) */ 3480 /*-----------------------------------------------------------*/ 3481 3482 #if ( configUSE_TIMERS == 1 ) 3483 3484 const char * MPU_pcTimerGetNameImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; 3485 MPU_pcTimerGetNameImpl(TimerHandle_t xTimer)3486 const char * MPU_pcTimerGetNameImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */ 3487 { 3488 const char * pcReturn = NULL; 3489 TimerHandle_t xInternalTimerHandle = NULL; 3490 int32_t lIndex; 3491 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE; 3492 3493 lIndex = ( int32_t ) xTimer; 3494 3495 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3496 { 3497 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3498 3499 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE ) 3500 { 3501 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3502 3503 if( xInternalTimerHandle != NULL ) 3504 { 3505 pcReturn = pcTimerGetName( xInternalTimerHandle ); 3506 } 3507 } 3508 } 3509 3510 return pcReturn; 3511 } 3512 3513 #endif /* if ( configUSE_TIMERS == 1 ) */ 3514 /*-----------------------------------------------------------*/ 3515 3516 #if ( configUSE_TIMERS == 1 ) 3517 3518 void MPU_vTimerSetReloadModeImpl( TimerHandle_t xTimer, 3519 const UBaseType_t uxAutoReload ) PRIVILEGED_FUNCTION; 3520 MPU_vTimerSetReloadModeImpl(TimerHandle_t xTimer,const UBaseType_t uxAutoReload)3521 void MPU_vTimerSetReloadModeImpl( TimerHandle_t xTimer, 3522 const UBaseType_t uxAutoReload ) /* PRIVILEGED_FUNCTION */ 3523 { 3524 TimerHandle_t xInternalTimerHandle = NULL; 3525 int32_t lIndex; 3526 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE; 3527 3528 lIndex = ( int32_t ) xTimer; 3529 3530 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3531 { 3532 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3533 3534 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE ) 3535 { 3536 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3537 3538 if( xInternalTimerHandle != NULL ) 3539 { 3540 vTimerSetReloadMode( xInternalTimerHandle, uxAutoReload ); 3541 } 3542 } 3543 } 3544 } 3545 3546 #endif /* if ( configUSE_TIMERS == 1 ) */ 3547 /*-----------------------------------------------------------*/ 3548 3549 #if ( configUSE_TIMERS == 1 ) 3550 3551 BaseType_t MPU_xTimerGetReloadModeImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; 3552 MPU_xTimerGetReloadModeImpl(TimerHandle_t xTimer)3553 BaseType_t MPU_xTimerGetReloadModeImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */ 3554 { 3555 BaseType_t xReturn = pdFALSE; 3556 TimerHandle_t xInternalTimerHandle = NULL; 3557 int32_t lIndex; 3558 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE; 3559 3560 lIndex = ( int32_t ) xTimer; 3561 3562 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3563 { 3564 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3565 3566 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE ) 3567 { 3568 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3569 3570 if( xInternalTimerHandle != NULL ) 3571 { 3572 xReturn = xTimerGetReloadMode( xInternalTimerHandle ); 3573 } 3574 } 3575 } 3576 3577 return xReturn; 3578 } 3579 3580 #endif /* if ( configUSE_TIMERS == 1 ) */ 3581 /*-----------------------------------------------------------*/ 3582 3583 #if ( configUSE_TIMERS == 1 ) 3584 3585 UBaseType_t MPU_uxTimerGetReloadModeImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; 3586 MPU_uxTimerGetReloadModeImpl(TimerHandle_t xTimer)3587 UBaseType_t MPU_uxTimerGetReloadModeImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */ 3588 { 3589 UBaseType_t uxReturn = 0; 3590 TimerHandle_t xInternalTimerHandle = NULL; 3591 int32_t lIndex; 3592 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE; 3593 3594 lIndex = ( int32_t ) xTimer; 3595 3596 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3597 { 3598 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3599 3600 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE ) 3601 { 3602 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3603 3604 if( xInternalTimerHandle != NULL ) 3605 { 3606 uxReturn = uxTimerGetReloadMode( xInternalTimerHandle ); 3607 } 3608 } 3609 } 3610 3611 return uxReturn; 3612 } 3613 3614 #endif /* if ( configUSE_TIMERS == 1 ) */ 3615 /*-----------------------------------------------------------*/ 3616 3617 #if ( configUSE_TIMERS == 1 ) 3618 3619 TickType_t MPU_xTimerGetPeriodImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; 3620 MPU_xTimerGetPeriodImpl(TimerHandle_t xTimer)3621 TickType_t MPU_xTimerGetPeriodImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */ 3622 { 3623 TickType_t xReturn = 0; 3624 TimerHandle_t xInternalTimerHandle = NULL; 3625 int32_t lIndex; 3626 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE; 3627 3628 lIndex = ( int32_t ) xTimer; 3629 3630 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3631 { 3632 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3633 3634 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE ) 3635 { 3636 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3637 3638 if( xInternalTimerHandle != NULL ) 3639 { 3640 xReturn = xTimerGetPeriod( xInternalTimerHandle ); 3641 } 3642 } 3643 } 3644 3645 return xReturn; 3646 } 3647 3648 #endif /* if ( configUSE_TIMERS == 1 ) */ 3649 /*-----------------------------------------------------------*/ 3650 3651 #if ( configUSE_TIMERS == 1 ) 3652 3653 TickType_t MPU_xTimerGetExpiryTimeImpl( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; 3654 MPU_xTimerGetExpiryTimeImpl(TimerHandle_t xTimer)3655 TickType_t MPU_xTimerGetExpiryTimeImpl( TimerHandle_t xTimer ) /* PRIVILEGED_FUNCTION */ 3656 { 3657 TickType_t xReturn = 0; 3658 TimerHandle_t xInternalTimerHandle = NULL; 3659 int32_t lIndex; 3660 BaseType_t xCallingTaskIsAuthorizedToAccessTimer = pdFALSE; 3661 3662 lIndex = ( int32_t ) xTimer; 3663 3664 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3665 { 3666 xCallingTaskIsAuthorizedToAccessTimer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3667 3668 if( xCallingTaskIsAuthorizedToAccessTimer == pdTRUE ) 3669 { 3670 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3671 3672 if( xInternalTimerHandle != NULL ) 3673 { 3674 xReturn = xTimerGetExpiryTime( xInternalTimerHandle ); 3675 } 3676 } 3677 } 3678 3679 return xReturn; 3680 } 3681 3682 #endif /* if ( configUSE_TIMERS == 1 ) */ 3683 /*-----------------------------------------------------------*/ 3684 3685 /* Privileged only wrappers for Timer APIs. These are needed so that 3686 * the application can use opaque handles maintained in mpu_wrappers.c 3687 * with all the APIs. */ 3688 /*-----------------------------------------------------------*/ 3689 3690 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) 3691 MPU_xTimerCreate(const char * const pcTimerName,const TickType_t xTimerPeriodInTicks,const UBaseType_t uxAutoReload,void * const pvTimerID,TimerCallbackFunction_t pxCallbackFunction)3692 TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName, 3693 const TickType_t xTimerPeriodInTicks, 3694 const UBaseType_t uxAutoReload, 3695 void * const pvTimerID, 3696 TimerCallbackFunction_t pxCallbackFunction ) /* PRIVILEGED_FUNCTION */ 3697 { 3698 TimerHandle_t xInternalTimerHandle = NULL; 3699 TimerHandle_t xExternalTimerHandle = NULL; 3700 int32_t lIndex; 3701 3702 lIndex = MPU_GetFreeIndexInKernelObjectPool(); 3703 3704 if( lIndex != -1 ) 3705 { 3706 xInternalTimerHandle = xTimerCreate( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, MPU_TimerCallback ); 3707 3708 if( xInternalTimerHandle != NULL ) 3709 { 3710 MPU_StoreTimerHandleAtIndex( lIndex, xInternalTimerHandle, pxCallbackFunction ); 3711 xExternalTimerHandle = ( TimerHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 3712 } 3713 else 3714 { 3715 MPU_SetIndexFreeInKernelObjectPool( lIndex ); 3716 } 3717 } 3718 3719 return xExternalTimerHandle; 3720 } 3721 3722 #endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) */ 3723 /*-----------------------------------------------------------*/ 3724 3725 #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) 3726 MPU_xTimerCreateStatic(const char * const pcTimerName,const TickType_t xTimerPeriodInTicks,const UBaseType_t uxAutoReload,void * const pvTimerID,TimerCallbackFunction_t pxCallbackFunction,StaticTimer_t * pxTimerBuffer)3727 TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName, 3728 const TickType_t xTimerPeriodInTicks, 3729 const UBaseType_t uxAutoReload, 3730 void * const pvTimerID, 3731 TimerCallbackFunction_t pxCallbackFunction, 3732 StaticTimer_t * pxTimerBuffer ) /* PRIVILEGED_FUNCTION */ 3733 { 3734 TimerHandle_t xInternalTimerHandle = NULL; 3735 TimerHandle_t xExternalTimerHandle = NULL; 3736 int32_t lIndex; 3737 3738 lIndex = MPU_GetFreeIndexInKernelObjectPool(); 3739 3740 if( lIndex != -1 ) 3741 { 3742 xInternalTimerHandle = xTimerCreateStatic( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, MPU_TimerCallback, pxTimerBuffer ); 3743 3744 if( xInternalTimerHandle != NULL ) 3745 { 3746 MPU_StoreTimerHandleAtIndex( lIndex, xInternalTimerHandle, pxCallbackFunction ); 3747 xExternalTimerHandle = ( TimerHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 3748 } 3749 else 3750 { 3751 MPU_SetIndexFreeInKernelObjectPool( lIndex ); 3752 } 3753 } 3754 3755 return xExternalTimerHandle; 3756 } 3757 3758 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) */ 3759 /*-----------------------------------------------------------*/ 3760 3761 #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) 3762 MPU_xTimerGetStaticBuffer(TimerHandle_t xTimer,StaticTimer_t ** ppxTimerBuffer)3763 BaseType_t MPU_xTimerGetStaticBuffer( TimerHandle_t xTimer, 3764 StaticTimer_t ** ppxTimerBuffer ) /* PRIVILEGED_FUNCTION */ 3765 { 3766 TimerHandle_t xInternalTimerHandle = NULL; 3767 int32_t lIndex; 3768 BaseType_t xReturn = pdFALSE; 3769 3770 lIndex = ( int32_t ) xTimer; 3771 3772 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3773 { 3774 xInternalTimerHandle = MPU_GetTimerHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3775 3776 if( xInternalTimerHandle != NULL ) 3777 { 3778 xReturn = xTimerGetStaticBuffer( xInternalTimerHandle, ppxTimerBuffer ); 3779 } 3780 } 3781 3782 return xReturn; 3783 } 3784 3785 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) */ 3786 /*-----------------------------------------------------------*/ 3787 3788 /*-----------------------------------------------------------*/ 3789 /* MPU wrappers for event group APIs. */ 3790 /*-----------------------------------------------------------*/ 3791 MPU_xEventGroupWaitBits(EventGroupHandle_t xEventGroup,const EventBits_t uxBitsToWaitFor,const BaseType_t xClearOnExit,const BaseType_t xWaitForAllBits,TickType_t xTicksToWait)3792 EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup, 3793 const EventBits_t uxBitsToWaitFor, 3794 const BaseType_t xClearOnExit, 3795 const BaseType_t xWaitForAllBits, 3796 TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ 3797 { 3798 EventBits_t xReturn = 0; 3799 xEventGroupWaitBitsParams_t xParams; 3800 3801 xParams.xEventGroup = xEventGroup; 3802 xParams.uxBitsToWaitFor = uxBitsToWaitFor; 3803 xParams.xClearOnExit = xClearOnExit; 3804 xParams.xWaitForAllBits = xWaitForAllBits; 3805 xParams.xTicksToWait = xTicksToWait; 3806 3807 xReturn = MPU_xEventGroupWaitBitsEntry( &( xParams ) ); 3808 3809 return xReturn; 3810 } 3811 3812 EventBits_t MPU_xEventGroupWaitBitsImpl( const xEventGroupWaitBitsParams_t * pxParams ) PRIVILEGED_FUNCTION; 3813 MPU_xEventGroupWaitBitsImpl(const xEventGroupWaitBitsParams_t * pxParams)3814 EventBits_t MPU_xEventGroupWaitBitsImpl( const xEventGroupWaitBitsParams_t * pxParams ) /* PRIVILEGED_FUNCTION */ 3815 { 3816 EventBits_t xReturn = 0; 3817 EventGroupHandle_t xInternalEventGroupHandle = NULL; 3818 int32_t lIndex; 3819 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE; 3820 BaseType_t xAreParamsReadable = pdFALSE; 3821 3822 if( pxParams != NULL ) 3823 { 3824 xAreParamsReadable = xPortIsAuthorizedToAccessBuffer( pxParams, 3825 sizeof( xEventGroupWaitBitsParams_t ), 3826 tskMPU_READ_PERMISSION ); 3827 } 3828 3829 if( xAreParamsReadable == pdTRUE ) 3830 { 3831 if( ( ( pxParams->uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 ) && 3832 ( pxParams->uxBitsToWaitFor != 0 ) 3833 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) 3834 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( pxParams->xTicksToWait != 0 ) ) ) 3835 #endif 3836 ) 3837 { 3838 lIndex = ( int32_t ) ( pxParams->xEventGroup ); 3839 3840 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3841 { 3842 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3843 3844 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE ) 3845 { 3846 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3847 3848 if( xInternalEventGroupHandle != NULL ) 3849 { 3850 xReturn = xEventGroupWaitBits( xInternalEventGroupHandle, 3851 pxParams->uxBitsToWaitFor, 3852 pxParams->xClearOnExit, 3853 pxParams->xWaitForAllBits, 3854 pxParams->xTicksToWait ); 3855 } 3856 } 3857 } 3858 } 3859 } 3860 3861 return xReturn; 3862 } 3863 /*-----------------------------------------------------------*/ 3864 3865 EventBits_t MPU_xEventGroupClearBitsImpl( EventGroupHandle_t xEventGroup, 3866 const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION; 3867 MPU_xEventGroupClearBitsImpl(EventGroupHandle_t xEventGroup,const EventBits_t uxBitsToClear)3868 EventBits_t MPU_xEventGroupClearBitsImpl( EventGroupHandle_t xEventGroup, 3869 const EventBits_t uxBitsToClear ) /* PRIVILEGED_FUNCTION */ 3870 { 3871 EventBits_t xReturn = 0; 3872 EventGroupHandle_t xInternalEventGroupHandle = NULL; 3873 int32_t lIndex; 3874 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE; 3875 3876 if( ( uxBitsToClear & eventEVENT_BITS_CONTROL_BYTES ) == 0 ) 3877 { 3878 lIndex = ( int32_t ) xEventGroup; 3879 3880 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3881 { 3882 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3883 3884 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE ) 3885 { 3886 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3887 3888 if( xInternalEventGroupHandle != NULL ) 3889 { 3890 xReturn = xEventGroupClearBits( xInternalEventGroupHandle, uxBitsToClear ); 3891 } 3892 } 3893 } 3894 } 3895 3896 return xReturn; 3897 } 3898 /*-----------------------------------------------------------*/ 3899 3900 EventBits_t MPU_xEventGroupSetBitsImpl( EventGroupHandle_t xEventGroup, 3901 const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION; 3902 MPU_xEventGroupSetBitsImpl(EventGroupHandle_t xEventGroup,const EventBits_t uxBitsToSet)3903 EventBits_t MPU_xEventGroupSetBitsImpl( EventGroupHandle_t xEventGroup, 3904 const EventBits_t uxBitsToSet ) /* PRIVILEGED_FUNCTION */ 3905 { 3906 EventBits_t xReturn = 0; 3907 EventGroupHandle_t xInternalEventGroupHandle = NULL; 3908 int32_t lIndex; 3909 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE; 3910 3911 if( ( uxBitsToSet & eventEVENT_BITS_CONTROL_BYTES ) == 0 ) 3912 { 3913 lIndex = ( int32_t ) xEventGroup; 3914 3915 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3916 { 3917 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3918 3919 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE ) 3920 { 3921 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3922 3923 if( xInternalEventGroupHandle != NULL ) 3924 { 3925 xReturn = xEventGroupSetBits( xInternalEventGroupHandle, uxBitsToSet ); 3926 } 3927 } 3928 } 3929 } 3930 3931 return xReturn; 3932 } 3933 /*-----------------------------------------------------------*/ 3934 3935 EventBits_t MPU_xEventGroupSyncImpl( EventGroupHandle_t xEventGroup, 3936 const EventBits_t uxBitsToSet, 3937 const EventBits_t uxBitsToWaitFor, 3938 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; 3939 MPU_xEventGroupSyncImpl(EventGroupHandle_t xEventGroup,const EventBits_t uxBitsToSet,const EventBits_t uxBitsToWaitFor,TickType_t xTicksToWait)3940 EventBits_t MPU_xEventGroupSyncImpl( EventGroupHandle_t xEventGroup, 3941 const EventBits_t uxBitsToSet, 3942 const EventBits_t uxBitsToWaitFor, 3943 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */ 3944 { 3945 EventBits_t xReturn = 0; 3946 EventGroupHandle_t xInternalEventGroupHandle = NULL; 3947 int32_t lIndex; 3948 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE; 3949 3950 if( ( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 ) && 3951 ( uxBitsToWaitFor != 0 ) 3952 #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) ) 3953 && ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) ) 3954 #endif 3955 ) 3956 { 3957 lIndex = ( int32_t ) xEventGroup; 3958 3959 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3960 { 3961 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3962 3963 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE ) 3964 { 3965 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3966 3967 if( xInternalEventGroupHandle != NULL ) 3968 { 3969 xReturn = xEventGroupSync( xInternalEventGroupHandle, uxBitsToSet, uxBitsToWaitFor, xTicksToWait ); 3970 } 3971 } 3972 } 3973 } 3974 3975 return xReturn; 3976 } 3977 /*-----------------------------------------------------------*/ 3978 3979 #if ( configUSE_TRACE_FACILITY == 1 ) 3980 3981 UBaseType_t MPU_uxEventGroupGetNumberImpl( void * xEventGroup ) PRIVILEGED_FUNCTION; 3982 MPU_uxEventGroupGetNumberImpl(void * xEventGroup)3983 UBaseType_t MPU_uxEventGroupGetNumberImpl( void * xEventGroup ) /* PRIVILEGED_FUNCTION */ 3984 { 3985 UBaseType_t xReturn = 0; 3986 EventGroupHandle_t xInternalEventGroupHandle = NULL; 3987 int32_t lIndex; 3988 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE; 3989 3990 lIndex = ( int32_t ) xEventGroup; 3991 3992 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 3993 { 3994 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3995 3996 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE ) 3997 { 3998 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 3999 4000 if( xInternalEventGroupHandle != NULL ) 4001 { 4002 xReturn = uxEventGroupGetNumber( xInternalEventGroupHandle ); 4003 } 4004 } 4005 } 4006 4007 return xReturn; 4008 } 4009 4010 #endif /*( configUSE_TRACE_FACILITY == 1 )*/ 4011 /*-----------------------------------------------------------*/ 4012 4013 #if ( configUSE_TRACE_FACILITY == 1 ) 4014 4015 void MPU_vEventGroupSetNumberImpl( void * xEventGroup, 4016 UBaseType_t uxEventGroupNumber ) PRIVILEGED_FUNCTION; 4017 MPU_vEventGroupSetNumberImpl(void * xEventGroup,UBaseType_t uxEventGroupNumber)4018 void MPU_vEventGroupSetNumberImpl( void * xEventGroup, 4019 UBaseType_t uxEventGroupNumber ) /* PRIVILEGED_FUNCTION */ 4020 { 4021 EventGroupHandle_t xInternalEventGroupHandle = NULL; 4022 int32_t lIndex; 4023 BaseType_t xCallingTaskIsAuthorizedToAccessEventGroup = pdFALSE; 4024 4025 lIndex = ( int32_t ) xEventGroup; 4026 4027 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4028 { 4029 xCallingTaskIsAuthorizedToAccessEventGroup = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4030 4031 if( xCallingTaskIsAuthorizedToAccessEventGroup == pdTRUE ) 4032 { 4033 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4034 4035 if( xInternalEventGroupHandle != NULL ) 4036 { 4037 vEventGroupSetNumber( xInternalEventGroupHandle, uxEventGroupNumber ); 4038 } 4039 } 4040 } 4041 } 4042 4043 #endif /*( configUSE_TRACE_FACILITY == 1 )*/ 4044 /*-----------------------------------------------------------*/ 4045 4046 /* Privileged only wrappers for Event Group APIs. These are needed so that 4047 * the application can use opaque handles maintained in mpu_wrappers.c 4048 * with all the APIs. */ 4049 /*-----------------------------------------------------------*/ 4050 4051 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) 4052 MPU_xEventGroupCreate(void)4053 EventGroupHandle_t MPU_xEventGroupCreate( void ) /* PRIVILEGED_FUNCTION */ 4054 { 4055 EventGroupHandle_t xInternalEventGroupHandle = NULL; 4056 EventGroupHandle_t xExternalEventGroupHandle = NULL; 4057 int32_t lIndex; 4058 4059 lIndex = MPU_GetFreeIndexInKernelObjectPool(); 4060 4061 if( lIndex != -1 ) 4062 { 4063 xInternalEventGroupHandle = xEventGroupCreate(); 4064 4065 if( xInternalEventGroupHandle != NULL ) 4066 { 4067 MPU_StoreEventGroupHandleAtIndex( lIndex, xInternalEventGroupHandle ); 4068 xExternalEventGroupHandle = ( EventGroupHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 4069 } 4070 else 4071 { 4072 MPU_SetIndexFreeInKernelObjectPool( lIndex ); 4073 } 4074 } 4075 4076 return xExternalEventGroupHandle; 4077 } 4078 4079 #endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) */ 4080 /*-----------------------------------------------------------*/ 4081 4082 #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) 4083 MPU_xEventGroupCreateStatic(StaticEventGroup_t * pxEventGroupBuffer)4084 EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) /* PRIVILEGED_FUNCTION */ 4085 { 4086 EventGroupHandle_t xInternalEventGroupHandle = NULL; 4087 EventGroupHandle_t xExternalEventGroupHandle = NULL; 4088 int32_t lIndex; 4089 4090 lIndex = MPU_GetFreeIndexInKernelObjectPool(); 4091 4092 if( lIndex != -1 ) 4093 { 4094 xInternalEventGroupHandle = xEventGroupCreateStatic( pxEventGroupBuffer ); 4095 4096 if( xInternalEventGroupHandle != NULL ) 4097 { 4098 MPU_StoreEventGroupHandleAtIndex( lIndex, xInternalEventGroupHandle ); 4099 xExternalEventGroupHandle = ( EventGroupHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 4100 } 4101 else 4102 { 4103 MPU_SetIndexFreeInKernelObjectPool( lIndex ); 4104 } 4105 } 4106 4107 return xExternalEventGroupHandle; 4108 } 4109 4110 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */ 4111 /*-----------------------------------------------------------*/ 4112 MPU_vEventGroupDelete(EventGroupHandle_t xEventGroup)4113 void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) /* PRIVILEGED_FUNCTION */ 4114 { 4115 EventGroupHandle_t xInternalEventGroupHandle = NULL; 4116 int32_t lIndex; 4117 4118 lIndex = ( int32_t ) xEventGroup; 4119 4120 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4121 { 4122 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4123 4124 if( xInternalEventGroupHandle != NULL ) 4125 { 4126 vEventGroupDelete( xInternalEventGroupHandle ); 4127 MPU_SetIndexFreeInKernelObjectPool( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4128 } 4129 } 4130 } 4131 /*-----------------------------------------------------------*/ 4132 4133 #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) 4134 MPU_xEventGroupGetStaticBuffer(EventGroupHandle_t xEventGroup,StaticEventGroup_t ** ppxEventGroupBuffer)4135 BaseType_t MPU_xEventGroupGetStaticBuffer( EventGroupHandle_t xEventGroup, 4136 StaticEventGroup_t ** ppxEventGroupBuffer ) /* PRIVILEGED_FUNCTION */ 4137 { 4138 BaseType_t xReturn = pdFALSE; 4139 EventGroupHandle_t xInternalEventGroupHandle = NULL; 4140 int32_t lIndex; 4141 4142 lIndex = ( int32_t ) xEventGroup; 4143 4144 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4145 { 4146 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4147 4148 if( xInternalEventGroupHandle != NULL ) 4149 { 4150 xReturn = xEventGroupGetStaticBuffer( xInternalEventGroupHandle, ppxEventGroupBuffer ); 4151 } 4152 } 4153 4154 return xReturn; 4155 } 4156 4157 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */ 4158 /*-----------------------------------------------------------*/ 4159 4160 #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) ) 4161 MPU_xEventGroupClearBitsFromISR(EventGroupHandle_t xEventGroup,const EventBits_t uxBitsToClear)4162 BaseType_t MPU_xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, 4163 const EventBits_t uxBitsToClear ) /* PRIVILEGED_FUNCTION */ 4164 { 4165 BaseType_t xReturn = pdFALSE; 4166 EventGroupHandle_t xInternalEventGroupHandle = NULL; 4167 int32_t lIndex; 4168 4169 lIndex = ( int32_t ) xEventGroup; 4170 4171 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4172 { 4173 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4174 4175 if( xInternalEventGroupHandle != NULL ) 4176 { 4177 xReturn = xEventGroupClearBitsFromISR( xInternalEventGroupHandle, uxBitsToClear ); 4178 } 4179 } 4180 4181 return xReturn; 4182 } 4183 4184 #endif /* #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) ) */ 4185 /*-----------------------------------------------------------*/ 4186 4187 #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) ) 4188 MPU_xEventGroupSetBitsFromISR(EventGroupHandle_t xEventGroup,const EventBits_t uxBitsToSet,BaseType_t * pxHigherPriorityTaskWoken)4189 BaseType_t MPU_xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, 4190 const EventBits_t uxBitsToSet, 4191 BaseType_t * pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */ 4192 { 4193 BaseType_t xReturn = pdFALSE; 4194 EventGroupHandle_t xInternalEventGroupHandle = NULL; 4195 int32_t lIndex; 4196 4197 lIndex = ( int32_t ) xEventGroup; 4198 4199 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4200 { 4201 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4202 4203 if( xInternalEventGroupHandle != NULL ) 4204 { 4205 xReturn = xEventGroupSetBitsFromISR( xInternalEventGroupHandle, uxBitsToSet, pxHigherPriorityTaskWoken ); 4206 } 4207 } 4208 4209 return xReturn; 4210 } 4211 4212 #endif /* #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) ) */ 4213 /*-----------------------------------------------------------*/ 4214 MPU_xEventGroupGetBitsFromISR(EventGroupHandle_t xEventGroup)4215 EventBits_t MPU_xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ) /* PRIVILEGED_FUNCTION */ 4216 { 4217 EventBits_t xReturn = 0; 4218 EventGroupHandle_t xInternalEventGroupHandle = NULL; 4219 int32_t lIndex; 4220 4221 lIndex = ( int32_t ) xEventGroup; 4222 4223 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4224 { 4225 xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4226 4227 if( xInternalEventGroupHandle != NULL ) 4228 { 4229 xReturn = xEventGroupGetBitsFromISR( xInternalEventGroupHandle ); 4230 } 4231 } 4232 4233 return xReturn; 4234 } 4235 /*-----------------------------------------------------------*/ 4236 4237 /*-----------------------------------------------------------*/ 4238 /* MPU wrappers for stream buffer APIs. */ 4239 /*-----------------------------------------------------------*/ 4240 4241 size_t MPU_xStreamBufferSendImpl( StreamBufferHandle_t xStreamBuffer, 4242 const void * pvTxData, 4243 size_t xDataLengthBytes, 4244 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; 4245 MPU_xStreamBufferSendImpl(StreamBufferHandle_t xStreamBuffer,const void * pvTxData,size_t xDataLengthBytes,TickType_t xTicksToWait)4246 size_t MPU_xStreamBufferSendImpl( StreamBufferHandle_t xStreamBuffer, 4247 const void * pvTxData, 4248 size_t xDataLengthBytes, 4249 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */ 4250 { 4251 size_t xReturn = 0; 4252 StreamBufferHandle_t xInternalStreamBufferHandle = NULL; 4253 int32_t lIndex; 4254 BaseType_t xIsTxDataBufferReadable = pdFALSE; 4255 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE; 4256 4257 if( pvTxData != NULL ) 4258 { 4259 xIsTxDataBufferReadable = xPortIsAuthorizedToAccessBuffer( pvTxData, 4260 xDataLengthBytes, 4261 tskMPU_READ_PERMISSION ); 4262 4263 if( xIsTxDataBufferReadable == pdTRUE ) 4264 { 4265 lIndex = ( int32_t ) xStreamBuffer; 4266 4267 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4268 { 4269 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4270 4271 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE ) 4272 { 4273 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4274 4275 if( xInternalStreamBufferHandle != NULL ) 4276 { 4277 xReturn = xStreamBufferSend( xInternalStreamBufferHandle, pvTxData, xDataLengthBytes, xTicksToWait ); 4278 } 4279 } 4280 } 4281 } 4282 } 4283 4284 return xReturn; 4285 } 4286 /*-----------------------------------------------------------*/ 4287 4288 size_t MPU_xStreamBufferReceiveImpl( StreamBufferHandle_t xStreamBuffer, 4289 void * pvRxData, 4290 size_t xBufferLengthBytes, 4291 TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; 4292 MPU_xStreamBufferReceiveImpl(StreamBufferHandle_t xStreamBuffer,void * pvRxData,size_t xBufferLengthBytes,TickType_t xTicksToWait)4293 size_t MPU_xStreamBufferReceiveImpl( StreamBufferHandle_t xStreamBuffer, 4294 void * pvRxData, 4295 size_t xBufferLengthBytes, 4296 TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */ 4297 { 4298 size_t xReturn = 0; 4299 StreamBufferHandle_t xInternalStreamBufferHandle = NULL; 4300 int32_t lIndex; 4301 BaseType_t xIsRxDataBufferWriteable = pdFALSE; 4302 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE; 4303 4304 if( pvRxData != NULL ) 4305 { 4306 xIsRxDataBufferWriteable = xPortIsAuthorizedToAccessBuffer( pvRxData, 4307 xBufferLengthBytes, 4308 tskMPU_WRITE_PERMISSION ); 4309 4310 if( xIsRxDataBufferWriteable == pdTRUE ) 4311 { 4312 lIndex = ( int32_t ) xStreamBuffer; 4313 4314 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4315 { 4316 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4317 4318 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE ) 4319 { 4320 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4321 4322 if( xInternalStreamBufferHandle != NULL ) 4323 { 4324 xReturn = xStreamBufferReceive( xInternalStreamBufferHandle, pvRxData, xBufferLengthBytes, xTicksToWait ); 4325 } 4326 } 4327 } 4328 } 4329 } 4330 4331 return xReturn; 4332 } 4333 /*-----------------------------------------------------------*/ 4334 4335 BaseType_t MPU_xStreamBufferIsFullImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; 4336 MPU_xStreamBufferIsFullImpl(StreamBufferHandle_t xStreamBuffer)4337 BaseType_t MPU_xStreamBufferIsFullImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */ 4338 { 4339 BaseType_t xReturn = pdFALSE; 4340 StreamBufferHandle_t xInternalStreamBufferHandle = NULL; 4341 int32_t lIndex; 4342 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE; 4343 4344 lIndex = ( int32_t ) xStreamBuffer; 4345 4346 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4347 { 4348 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4349 4350 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE ) 4351 { 4352 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4353 4354 if( xInternalStreamBufferHandle != NULL ) 4355 { 4356 xReturn = xStreamBufferIsFull( xInternalStreamBufferHandle ); 4357 } 4358 } 4359 } 4360 4361 return xReturn; 4362 } 4363 /*-----------------------------------------------------------*/ 4364 4365 BaseType_t MPU_xStreamBufferIsEmptyImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; 4366 MPU_xStreamBufferIsEmptyImpl(StreamBufferHandle_t xStreamBuffer)4367 BaseType_t MPU_xStreamBufferIsEmptyImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */ 4368 { 4369 BaseType_t xReturn = pdFALSE; 4370 StreamBufferHandle_t xInternalStreamBufferHandle = NULL; 4371 int32_t lIndex; 4372 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE; 4373 4374 lIndex = ( int32_t ) xStreamBuffer; 4375 4376 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4377 { 4378 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4379 4380 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE ) 4381 { 4382 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4383 4384 if( xInternalStreamBufferHandle != NULL ) 4385 { 4386 xReturn = xStreamBufferIsEmpty( xInternalStreamBufferHandle ); 4387 } 4388 } 4389 } 4390 4391 return xReturn; 4392 } 4393 /*-----------------------------------------------------------*/ 4394 4395 size_t MPU_xStreamBufferSpacesAvailableImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; 4396 MPU_xStreamBufferSpacesAvailableImpl(StreamBufferHandle_t xStreamBuffer)4397 size_t MPU_xStreamBufferSpacesAvailableImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */ 4398 { 4399 size_t xReturn = 0; 4400 StreamBufferHandle_t xInternalStreamBufferHandle = NULL; 4401 int32_t lIndex; 4402 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE; 4403 4404 lIndex = ( int32_t ) xStreamBuffer; 4405 4406 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4407 { 4408 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4409 4410 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE ) 4411 { 4412 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4413 4414 if( xInternalStreamBufferHandle != NULL ) 4415 { 4416 xReturn = xStreamBufferSpacesAvailable( xInternalStreamBufferHandle ); 4417 } 4418 } 4419 } 4420 4421 return xReturn; 4422 } 4423 /*-----------------------------------------------------------*/ 4424 4425 size_t MPU_xStreamBufferBytesAvailableImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; 4426 MPU_xStreamBufferBytesAvailableImpl(StreamBufferHandle_t xStreamBuffer)4427 size_t MPU_xStreamBufferBytesAvailableImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */ 4428 { 4429 size_t xReturn = 0; 4430 StreamBufferHandle_t xInternalStreamBufferHandle = NULL; 4431 int32_t lIndex; 4432 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE; 4433 4434 lIndex = ( int32_t ) xStreamBuffer; 4435 4436 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4437 { 4438 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4439 4440 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE ) 4441 { 4442 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4443 4444 if( xInternalStreamBufferHandle != NULL ) 4445 { 4446 xReturn = xStreamBufferBytesAvailable( xInternalStreamBufferHandle ); 4447 } 4448 } 4449 } 4450 4451 return xReturn; 4452 } 4453 /*-----------------------------------------------------------*/ 4454 4455 BaseType_t MPU_xStreamBufferSetTriggerLevelImpl( StreamBufferHandle_t xStreamBuffer, 4456 size_t xTriggerLevel ) PRIVILEGED_FUNCTION; 4457 MPU_xStreamBufferSetTriggerLevelImpl(StreamBufferHandle_t xStreamBuffer,size_t xTriggerLevel)4458 BaseType_t MPU_xStreamBufferSetTriggerLevelImpl( StreamBufferHandle_t xStreamBuffer, 4459 size_t xTriggerLevel ) /* PRIVILEGED_FUNCTION */ 4460 { 4461 BaseType_t xReturn = pdFALSE; 4462 StreamBufferHandle_t xInternalStreamBufferHandle = NULL; 4463 int32_t lIndex; 4464 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE; 4465 4466 lIndex = ( int32_t ) xStreamBuffer; 4467 4468 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4469 { 4470 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4471 4472 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE ) 4473 { 4474 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4475 4476 if( xInternalStreamBufferHandle != NULL ) 4477 { 4478 xReturn = xStreamBufferSetTriggerLevel( xInternalStreamBufferHandle, xTriggerLevel ); 4479 } 4480 } 4481 } 4482 4483 return xReturn; 4484 } 4485 /*-----------------------------------------------------------*/ 4486 4487 size_t MPU_xStreamBufferNextMessageLengthBytesImpl( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; 4488 MPU_xStreamBufferNextMessageLengthBytesImpl(StreamBufferHandle_t xStreamBuffer)4489 size_t MPU_xStreamBufferNextMessageLengthBytesImpl( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */ 4490 { 4491 size_t xReturn = 0; 4492 StreamBufferHandle_t xInternalStreamBufferHandle = NULL; 4493 int32_t lIndex; 4494 BaseType_t xCallingTaskIsAuthorizedToAccessStreamBuffer = pdFALSE; 4495 4496 lIndex = ( int32_t ) xStreamBuffer; 4497 4498 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4499 { 4500 xCallingTaskIsAuthorizedToAccessStreamBuffer = xPortIsAuthorizedToAccessKernelObject( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4501 4502 if( xCallingTaskIsAuthorizedToAccessStreamBuffer == pdTRUE ) 4503 { 4504 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4505 4506 if( xInternalStreamBufferHandle != NULL ) 4507 { 4508 xReturn = xStreamBufferNextMessageLengthBytes( xInternalStreamBufferHandle ); 4509 } 4510 } 4511 } 4512 4513 return xReturn; 4514 } 4515 /*-----------------------------------------------------------*/ 4516 4517 /* Privileged only wrappers for Stream Buffer APIs. These are needed so that 4518 * the application can use opaque handles maintained in mpu_wrappers.c 4519 * with all the APIs. */ 4520 /*-----------------------------------------------------------*/ 4521 4522 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) 4523 MPU_xStreamBufferGenericCreate(size_t xBufferSizeBytes,size_t xTriggerLevelBytes,BaseType_t xIsMessageBuffer,StreamBufferCallbackFunction_t pxSendCompletedCallback,StreamBufferCallbackFunction_t pxReceiveCompletedCallback)4524 StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes, 4525 size_t xTriggerLevelBytes, 4526 BaseType_t xIsMessageBuffer, 4527 StreamBufferCallbackFunction_t pxSendCompletedCallback, 4528 StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) /* PRIVILEGED_FUNCTION */ 4529 { 4530 StreamBufferHandle_t xInternalStreamBufferHandle = NULL; 4531 StreamBufferHandle_t xExternalStreamBufferHandle = NULL; 4532 int32_t lIndex; 4533 4534 /** 4535 * Stream buffer application level callback functionality is disabled for MPU 4536 * enabled ports. 4537 */ 4538 configASSERT( ( pxSendCompletedCallback == NULL ) && 4539 ( pxReceiveCompletedCallback == NULL ) ); 4540 4541 if( ( pxSendCompletedCallback == NULL ) && 4542 ( pxReceiveCompletedCallback == NULL ) ) 4543 { 4544 lIndex = MPU_GetFreeIndexInKernelObjectPool(); 4545 4546 if( lIndex != -1 ) 4547 { 4548 xInternalStreamBufferHandle = xStreamBufferGenericCreate( xBufferSizeBytes, 4549 xTriggerLevelBytes, 4550 xIsMessageBuffer, 4551 NULL, 4552 NULL ); 4553 4554 if( xInternalStreamBufferHandle != NULL ) 4555 { 4556 MPU_StoreStreamBufferHandleAtIndex( lIndex, xInternalStreamBufferHandle ); 4557 xExternalStreamBufferHandle = ( StreamBufferHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 4558 } 4559 else 4560 { 4561 MPU_SetIndexFreeInKernelObjectPool( lIndex ); 4562 } 4563 } 4564 } 4565 else 4566 { 4567 traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer ); 4568 xExternalStreamBufferHandle = NULL; 4569 } 4570 4571 return xExternalStreamBufferHandle; 4572 } 4573 4574 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ 4575 /*-----------------------------------------------------------*/ 4576 4577 #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) 4578 MPU_xStreamBufferGenericCreateStatic(size_t xBufferSizeBytes,size_t xTriggerLevelBytes,BaseType_t xIsMessageBuffer,uint8_t * const pucStreamBufferStorageArea,StaticStreamBuffer_t * const pxStaticStreamBuffer,StreamBufferCallbackFunction_t pxSendCompletedCallback,StreamBufferCallbackFunction_t pxReceiveCompletedCallback)4579 StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, 4580 size_t xTriggerLevelBytes, 4581 BaseType_t xIsMessageBuffer, 4582 uint8_t * const pucStreamBufferStorageArea, 4583 StaticStreamBuffer_t * const pxStaticStreamBuffer, 4584 StreamBufferCallbackFunction_t pxSendCompletedCallback, 4585 StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) /* PRIVILEGED_FUNCTION */ 4586 { 4587 StreamBufferHandle_t xInternalStreamBufferHandle = NULL; 4588 StreamBufferHandle_t xExternalStreamBufferHandle = NULL; 4589 int32_t lIndex; 4590 4591 /** 4592 * Stream buffer application level callback functionality is disabled for MPU 4593 * enabled ports. 4594 */ 4595 configASSERT( ( pxSendCompletedCallback == NULL ) && 4596 ( pxReceiveCompletedCallback == NULL ) ); 4597 4598 if( ( pxSendCompletedCallback == NULL ) && 4599 ( pxReceiveCompletedCallback == NULL ) ) 4600 { 4601 lIndex = MPU_GetFreeIndexInKernelObjectPool(); 4602 4603 if( lIndex != -1 ) 4604 { 4605 xInternalStreamBufferHandle = xStreamBufferGenericCreateStatic( xBufferSizeBytes, 4606 xTriggerLevelBytes, 4607 xIsMessageBuffer, 4608 pucStreamBufferStorageArea, 4609 pxStaticStreamBuffer, 4610 NULL, 4611 NULL ); 4612 4613 if( xInternalStreamBufferHandle != NULL ) 4614 { 4615 MPU_StoreStreamBufferHandleAtIndex( lIndex, xInternalStreamBufferHandle ); 4616 xExternalStreamBufferHandle = ( StreamBufferHandle_t ) CONVERT_TO_EXTERNAL_INDEX( lIndex ); 4617 } 4618 else 4619 { 4620 MPU_SetIndexFreeInKernelObjectPool( lIndex ); 4621 } 4622 } 4623 } 4624 else 4625 { 4626 traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xIsMessageBuffer ); 4627 xExternalStreamBufferHandle = NULL; 4628 } 4629 4630 return xExternalStreamBufferHandle; 4631 } 4632 4633 #endif /* configSUPPORT_STATIC_ALLOCATION */ 4634 /*-----------------------------------------------------------*/ 4635 MPU_vStreamBufferDelete(StreamBufferHandle_t xStreamBuffer)4636 void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */ 4637 { 4638 StreamBufferHandle_t xInternalStreamBufferHandle = NULL; 4639 int32_t lIndex; 4640 4641 lIndex = ( int32_t ) xStreamBuffer; 4642 4643 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4644 { 4645 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4646 4647 if( xInternalStreamBufferHandle != NULL ) 4648 { 4649 vStreamBufferDelete( xInternalStreamBufferHandle ); 4650 } 4651 4652 MPU_SetIndexFreeInKernelObjectPool( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4653 } 4654 } 4655 /*-----------------------------------------------------------*/ 4656 MPU_xStreamBufferReset(StreamBufferHandle_t xStreamBuffer)4657 BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) /* PRIVILEGED_FUNCTION */ 4658 { 4659 BaseType_t xReturn = pdFALSE; 4660 StreamBufferHandle_t xInternalStreamBufferHandle = NULL; 4661 int32_t lIndex; 4662 4663 lIndex = ( int32_t ) xStreamBuffer; 4664 4665 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4666 { 4667 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4668 4669 if( xInternalStreamBufferHandle != NULL ) 4670 { 4671 xReturn = xStreamBufferReset( xInternalStreamBufferHandle ); 4672 } 4673 } 4674 4675 return xReturn; 4676 } 4677 /*-----------------------------------------------------------*/ 4678 4679 #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) 4680 MPU_xStreamBufferGetStaticBuffers(StreamBufferHandle_t xStreamBuffers,uint8_t * ppucStreamBufferStorageArea,StaticStreamBuffer_t * ppxStaticStreamBuffer)4681 BaseType_t MPU_xStreamBufferGetStaticBuffers( StreamBufferHandle_t xStreamBuffers, 4682 uint8_t * ppucStreamBufferStorageArea, 4683 StaticStreamBuffer_t * ppxStaticStreamBuffer ) /* PRIVILEGED_FUNCTION */ 4684 { 4685 BaseType_t xReturn = pdFALSE; 4686 StreamBufferHandle_t xInternalStreamBufferHandle = NULL; 4687 int32_t lIndex; 4688 4689 lIndex = ( int32_t ) xStreamBuffers; 4690 4691 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4692 { 4693 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4694 4695 if( xInternalStreamBufferHandle != NULL ) 4696 { 4697 xReturn = MPU_xStreamBufferGetStaticBuffers( xInternalStreamBufferHandle, ppucStreamBufferStorageArea, ppxStaticStreamBuffer ); 4698 } 4699 } 4700 4701 return xReturn; 4702 } 4703 4704 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */ 4705 /*-----------------------------------------------------------*/ 4706 MPU_xStreamBufferSendFromISR(StreamBufferHandle_t xStreamBuffer,const void * pvTxData,size_t xDataLengthBytes,BaseType_t * const pxHigherPriorityTaskWoken)4707 size_t MPU_xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, 4708 const void * pvTxData, 4709 size_t xDataLengthBytes, 4710 BaseType_t * const pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */ 4711 { 4712 size_t xReturn = 0; 4713 StreamBufferHandle_t xInternalStreamBufferHandle = NULL; 4714 int32_t lIndex; 4715 4716 lIndex = ( int32_t ) xStreamBuffer; 4717 4718 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4719 { 4720 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4721 4722 if( xInternalStreamBufferHandle != NULL ) 4723 { 4724 xReturn = xStreamBufferSendFromISR( xInternalStreamBufferHandle, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ); 4725 } 4726 } 4727 4728 return xReturn; 4729 } 4730 /*-----------------------------------------------------------*/ 4731 MPU_xStreamBufferReceiveFromISR(StreamBufferHandle_t xStreamBuffer,void * pvRxData,size_t xBufferLengthBytes,BaseType_t * const pxHigherPriorityTaskWoken)4732 size_t MPU_xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, 4733 void * pvRxData, 4734 size_t xBufferLengthBytes, 4735 BaseType_t * const pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */ 4736 { 4737 size_t xReturn = 0; 4738 StreamBufferHandle_t xInternalStreamBufferHandle = NULL; 4739 int32_t lIndex; 4740 4741 lIndex = ( int32_t ) xStreamBuffer; 4742 4743 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4744 { 4745 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4746 4747 if( xInternalStreamBufferHandle != NULL ) 4748 { 4749 xReturn = xStreamBufferReceiveFromISR( xInternalStreamBufferHandle, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ); 4750 } 4751 } 4752 4753 return xReturn; 4754 } 4755 /*-----------------------------------------------------------*/ 4756 MPU_xStreamBufferSendCompletedFromISR(StreamBufferHandle_t xStreamBuffer,BaseType_t * pxHigherPriorityTaskWoken)4757 BaseType_t MPU_xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer, 4758 BaseType_t * pxHigherPriorityTaskWoken ) /* PRIVILEGED_FUNCTION */ 4759 { 4760 BaseType_t xReturn = pdFALSE; 4761 StreamBufferHandle_t xInternalStreamBufferHandle = NULL; 4762 int32_t lIndex; 4763 4764 lIndex = ( int32_t ) xStreamBuffer; 4765 4766 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4767 { 4768 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4769 4770 if( xInternalStreamBufferHandle != NULL ) 4771 { 4772 xReturn = xStreamBufferSendCompletedFromISR( xInternalStreamBufferHandle, pxHigherPriorityTaskWoken ); 4773 } 4774 } 4775 4776 return xReturn; 4777 } 4778 /*-----------------------------------------------------------*/ 4779 MPU_xStreamBufferReceiveCompletedFromISR(StreamBufferHandle_t xStreamBuffer,BaseType_t * pxHigherPriorityTaskWoken)4780 BaseType_t MPU_xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer, 4781 BaseType_t * pxHigherPriorityTaskWoken ) /*PRIVILEGED_FUNCTION */ 4782 { 4783 BaseType_t xReturn = pdFALSE; 4784 StreamBufferHandle_t xInternalStreamBufferHandle = NULL; 4785 int32_t lIndex; 4786 4787 lIndex = ( int32_t ) xStreamBuffer; 4788 4789 if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) 4790 { 4791 xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); 4792 4793 if( xInternalStreamBufferHandle != NULL ) 4794 { 4795 xReturn = xStreamBufferReceiveCompletedFromISR( xInternalStreamBufferHandle, pxHigherPriorityTaskWoken ); 4796 } 4797 } 4798 4799 return xReturn; 4800 } 4801 4802 /*-----------------------------------------------------------*/ 4803 4804 /* Functions that the application writer wants to execute in privileged mode 4805 * can be defined in application_defined_privileged_functions.h. */ 4806 4807 #if configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS == 1 4808 #include "application_defined_privileged_functions.h" 4809 #endif 4810 /*-----------------------------------------------------------*/ 4811 4812 /** 4813 * @brief Array of system call implementation functions. 4814 * 4815 * The index in the array MUST match the corresponding system call number 4816 * defined in mpu_wrappers.h. 4817 */ 4818 PRIVILEGED_DATA UBaseType_t uxSystemCallImplementations[ NUM_SYSTEM_CALLS ] = 4819 { 4820 #if ( configUSE_TASK_NOTIFICATIONS == 1 ) 4821 ( UBaseType_t ) MPU_xTaskGenericNotifyImpl, /* SYSTEM_CALL_xTaskGenericNotify. */ 4822 ( UBaseType_t ) MPU_xTaskGenericNotifyWaitImpl, /* SYSTEM_CALL_xTaskGenericNotifyWait. */ 4823 #else 4824 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGenericNotify. */ 4825 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGenericNotifyWait. */ 4826 #endif 4827 4828 #if ( configUSE_TIMERS == 1 ) 4829 ( UBaseType_t ) MPU_xTimerGenericCommandImpl, /* SYSTEM_CALL_xTimerGenericCommand. */ 4830 #else 4831 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGenericCommand. */ 4832 #endif 4833 4834 ( UBaseType_t ) MPU_xEventGroupWaitBitsImpl, /* SYSTEM_CALL_xEventGroupWaitBits. */ 4835 4836 /* The system calls above this line take 5 parameters. */ 4837 4838 #if ( INCLUDE_xTaskDelayUntil == 1 ) 4839 ( UBaseType_t ) MPU_xTaskDelayUntilImpl, /* SYSTEM_CALL_xTaskDelayUntil. */ 4840 #else 4841 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskDelayUntil. */ 4842 #endif 4843 4844 #if ( INCLUDE_xTaskAbortDelay == 1 ) 4845 ( UBaseType_t ) MPU_xTaskAbortDelayImpl, /* SYSTEM_CALL_xTaskAbortDelay. */ 4846 #else 4847 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskAbortDelay. */ 4848 #endif 4849 4850 #if ( INCLUDE_vTaskDelay == 1 ) 4851 ( UBaseType_t ) MPU_vTaskDelayImpl, /* SYSTEM_CALL_vTaskDelay. */ 4852 #else 4853 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskDelay. */ 4854 #endif 4855 4856 #if ( INCLUDE_uxTaskPriorityGet == 1 ) 4857 ( UBaseType_t ) MPU_uxTaskPriorityGetImpl, /* SYSTEM_CALL_uxTaskPriorityGet. */ 4858 #else 4859 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTaskPriorityGet. */ 4860 #endif 4861 4862 #if ( INCLUDE_eTaskGetState == 1 ) 4863 ( UBaseType_t ) MPU_eTaskGetStateImpl, /* SYSTEM_CALL_eTaskGetState. */ 4864 #else 4865 ( UBaseType_t ) 0, /* SYSTEM_CALL_eTaskGetState. */ 4866 #endif 4867 4868 #if ( configUSE_TRACE_FACILITY == 1 ) 4869 ( UBaseType_t ) MPU_vTaskGetInfoImpl, /* SYSTEM_CALL_vTaskGetInfo. */ 4870 #else 4871 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskGetInfo. */ 4872 #endif 4873 4874 #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) 4875 ( UBaseType_t ) MPU_xTaskGetIdleTaskHandleImpl, /* SYSTEM_CALL_xTaskGetIdleTaskHandle. */ 4876 #else 4877 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGetIdleTaskHandle. */ 4878 #endif 4879 4880 #if ( INCLUDE_vTaskSuspend == 1 ) 4881 ( UBaseType_t ) MPU_vTaskSuspendImpl, /* SYSTEM_CALL_vTaskSuspend. */ 4882 ( UBaseType_t ) MPU_vTaskResumeImpl, /* SYSTEM_CALL_vTaskResume. */ 4883 #else 4884 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskSuspend. */ 4885 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskResume. */ 4886 #endif 4887 4888 ( UBaseType_t ) MPU_xTaskGetTickCountImpl, /* SYSTEM_CALL_xTaskGetTickCount. */ 4889 ( UBaseType_t ) MPU_uxTaskGetNumberOfTasksImpl, /* SYSTEM_CALL_uxTaskGetNumberOfTasks. */ 4890 ( UBaseType_t ) MPU_pcTaskGetNameImpl, /* SYSTEM_CALL_pcTaskGetName. */ 4891 4892 #if ( configGENERATE_RUN_TIME_STATS == 1 ) 4893 ( UBaseType_t ) MPU_ulTaskGetRunTimeCounterImpl, /* SYSTEM_CALL_ulTaskGetRunTimeCounter. */ 4894 ( UBaseType_t ) MPU_ulTaskGetRunTimePercentImpl, /* SYSTEM_CALL_ulTaskGetRunTimePercent. */ 4895 #else 4896 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGetRunTimeCounter. */ 4897 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGetRunTimePercent. */ 4898 #endif 4899 4900 #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) 4901 ( UBaseType_t ) MPU_ulTaskGetIdleRunTimePercentImpl, /* SYSTEM_CALL_ulTaskGetIdleRunTimePercent. */ 4902 ( UBaseType_t ) MPU_ulTaskGetIdleRunTimeCounterImpl, /* SYSTEM_CALL_ulTaskGetIdleRunTimeCounter. */ 4903 #else 4904 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGetIdleRunTimePercent. */ 4905 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGetIdleRunTimeCounter. */ 4906 #endif 4907 4908 #if ( configUSE_APPLICATION_TASK_TAG == 1 ) 4909 ( UBaseType_t ) MPU_vTaskSetApplicationTaskTagImpl, /* SYSTEM_CALL_vTaskSetApplicationTaskTag. */ 4910 ( UBaseType_t ) MPU_xTaskGetApplicationTaskTagImpl, /* SYSTEM_CALL_xTaskGetApplicationTaskTag. */ 4911 #else 4912 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskSetApplicationTaskTag. */ 4913 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGetApplicationTaskTag. */ 4914 #endif 4915 4916 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) 4917 ( UBaseType_t ) MPU_vTaskSetThreadLocalStoragePointerImpl, /* SYSTEM_CALL_vTaskSetThreadLocalStoragePointer. */ 4918 ( UBaseType_t ) MPU_pvTaskGetThreadLocalStoragePointerImpl, /* SYSTEM_CALL_pvTaskGetThreadLocalStoragePointer. */ 4919 #else 4920 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTaskSetThreadLocalStoragePointer. */ 4921 ( UBaseType_t ) 0, /* SYSTEM_CALL_pvTaskGetThreadLocalStoragePointer. */ 4922 #endif 4923 4924 #if ( configUSE_TRACE_FACILITY == 1 ) 4925 ( UBaseType_t ) MPU_uxTaskGetSystemStateImpl, /* SYSTEM_CALL_uxTaskGetSystemState. */ 4926 #else 4927 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTaskGetSystemState. */ 4928 #endif 4929 4930 #if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) 4931 ( UBaseType_t ) MPU_uxTaskGetStackHighWaterMarkImpl, /* SYSTEM_CALL_uxTaskGetStackHighWaterMark. */ 4932 #else 4933 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTaskGetStackHighWaterMark. */ 4934 #endif 4935 4936 #if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) 4937 ( UBaseType_t ) MPU_uxTaskGetStackHighWaterMark2Impl, /* SYSTEM_CALL_uxTaskGetStackHighWaterMark2. */ 4938 #else 4939 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTaskGetStackHighWaterMark2. */ 4940 #endif 4941 4942 #if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) ) 4943 ( UBaseType_t ) MPU_xTaskGetCurrentTaskHandleImpl, /* SYSTEM_CALL_xTaskGetCurrentTaskHandle. */ 4944 #else 4945 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGetCurrentTaskHandle. */ 4946 #endif 4947 4948 #if ( INCLUDE_xTaskGetSchedulerState == 1 ) 4949 ( UBaseType_t ) MPU_xTaskGetSchedulerStateImpl, /* SYSTEM_CALL_xTaskGetSchedulerState. */ 4950 #else 4951 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGetSchedulerState. */ 4952 #endif 4953 4954 ( UBaseType_t ) MPU_vTaskSetTimeOutStateImpl, /* SYSTEM_CALL_vTaskSetTimeOutState. */ 4955 ( UBaseType_t ) MPU_xTaskCheckForTimeOutImpl, /* SYSTEM_CALL_xTaskCheckForTimeOut. */ 4956 4957 #if ( configUSE_TASK_NOTIFICATIONS == 1 ) 4958 ( UBaseType_t ) MPU_ulTaskGenericNotifyTakeImpl, /* SYSTEM_CALL_ulTaskGenericNotifyTake. */ 4959 ( UBaseType_t ) MPU_xTaskGenericNotifyStateClearImpl, /* SYSTEM_CALL_xTaskGenericNotifyStateClear. */ 4960 ( UBaseType_t ) MPU_ulTaskGenericNotifyValueClearImpl, /* SYSTEM_CALL_ulTaskGenericNotifyValueClear. */ 4961 #else 4962 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGenericNotifyTake. */ 4963 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTaskGenericNotifyStateClear. */ 4964 ( UBaseType_t ) 0, /* SYSTEM_CALL_ulTaskGenericNotifyValueClear. */ 4965 #endif 4966 4967 ( UBaseType_t ) MPU_xQueueGenericSendImpl, /* SYSTEM_CALL_xQueueGenericSend. */ 4968 ( UBaseType_t ) MPU_uxQueueMessagesWaitingImpl, /* SYSTEM_CALL_uxQueueMessagesWaiting. */ 4969 ( UBaseType_t ) MPU_uxQueueSpacesAvailableImpl, /* SYSTEM_CALL_uxQueueSpacesAvailable. */ 4970 ( UBaseType_t ) MPU_xQueueReceiveImpl, /* SYSTEM_CALL_xQueueReceive. */ 4971 ( UBaseType_t ) MPU_xQueuePeekImpl, /* SYSTEM_CALL_xQueuePeek. */ 4972 ( UBaseType_t ) MPU_xQueueSemaphoreTakeImpl, /* SYSTEM_CALL_xQueueSemaphoreTake. */ 4973 4974 #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) 4975 ( UBaseType_t ) MPU_xQueueGetMutexHolderImpl, /* SYSTEM_CALL_xQueueGetMutexHolder. */ 4976 #else 4977 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueGetMutexHolder. */ 4978 #endif 4979 4980 #if ( configUSE_RECURSIVE_MUTEXES == 1 ) 4981 ( UBaseType_t ) MPU_xQueueTakeMutexRecursiveImpl, /* SYSTEM_CALL_xQueueTakeMutexRecursive. */ 4982 ( UBaseType_t ) MPU_xQueueGiveMutexRecursiveImpl, /* SYSTEM_CALL_xQueueGiveMutexRecursive. */ 4983 #else 4984 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueTakeMutexRecursive. */ 4985 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueGiveMutexRecursive. */ 4986 #endif 4987 4988 #if ( configUSE_QUEUE_SETS == 1 ) 4989 ( UBaseType_t ) MPU_xQueueSelectFromSetImpl, /* SYSTEM_CALL_xQueueSelectFromSet. */ 4990 ( UBaseType_t ) MPU_xQueueAddToSetImpl, /* SYSTEM_CALL_xQueueAddToSet. */ 4991 #else 4992 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueSelectFromSet. */ 4993 ( UBaseType_t ) 0, /* SYSTEM_CALL_xQueueAddToSet. */ 4994 #endif 4995 4996 #if configQUEUE_REGISTRY_SIZE > 0 4997 ( UBaseType_t ) MPU_vQueueAddToRegistryImpl, /* SYSTEM_CALL_vQueueAddToRegistry. */ 4998 ( UBaseType_t ) MPU_vQueueUnregisterQueueImpl, /* SYSTEM_CALL_vQueueUnregisterQueue. */ 4999 ( UBaseType_t ) MPU_pcQueueGetNameImpl, /* SYSTEM_CALL_pcQueueGetName. */ 5000 #else 5001 ( UBaseType_t ) 0, /* SYSTEM_CALL_vQueueAddToRegistry. */ 5002 ( UBaseType_t ) 0, /* SYSTEM_CALL_vQueueUnregisterQueue. */ 5003 ( UBaseType_t ) 0, /* SYSTEM_CALL_pcQueueGetName. */ 5004 #endif 5005 5006 #if ( configUSE_TIMERS == 1 ) 5007 ( UBaseType_t ) MPU_pvTimerGetTimerIDImpl, /* SYSTEM_CALL_pvTimerGetTimerID. */ 5008 ( UBaseType_t ) MPU_vTimerSetTimerIDImpl, /* SYSTEM_CALL_vTimerSetTimerID. */ 5009 ( UBaseType_t ) MPU_xTimerIsTimerActiveImpl, /* SYSTEM_CALL_xTimerIsTimerActive. */ 5010 ( UBaseType_t ) MPU_xTimerGetTimerDaemonTaskHandleImpl, /* SYSTEM_CALL_xTimerGetTimerDaemonTaskHandle. */ 5011 ( UBaseType_t ) MPU_pcTimerGetNameImpl, /* SYSTEM_CALL_pcTimerGetName. */ 5012 ( UBaseType_t ) MPU_vTimerSetReloadModeImpl, /* SYSTEM_CALL_vTimerSetReloadMode. */ 5013 ( UBaseType_t ) MPU_xTimerGetReloadModeImpl, /* SYSTEM_CALL_xTimerGetReloadMode. */ 5014 ( UBaseType_t ) MPU_uxTimerGetReloadModeImpl, /* SYSTEM_CALL_uxTimerGetReloadMode. */ 5015 ( UBaseType_t ) MPU_xTimerGetPeriodImpl, /* SYSTEM_CALL_xTimerGetPeriod. */ 5016 ( UBaseType_t ) MPU_xTimerGetExpiryTimeImpl, /* SYSTEM_CALL_xTimerGetExpiryTime. */ 5017 #else /* if ( configUSE_TIMERS == 1 ) */ 5018 ( UBaseType_t ) 0, /* SYSTEM_CALL_pvTimerGetTimerID. */ 5019 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTimerSetTimerID. */ 5020 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerIsTimerActive. */ 5021 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGetTimerDaemonTaskHandle. */ 5022 ( UBaseType_t ) 0, /* SYSTEM_CALL_pcTimerGetName. */ 5023 ( UBaseType_t ) 0, /* SYSTEM_CALL_vTimerSetReloadMode. */ 5024 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGetReloadMode. */ 5025 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxTimerGetReloadMode. */ 5026 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGetPeriod. */ 5027 ( UBaseType_t ) 0, /* SYSTEM_CALL_xTimerGetExpiryTime. */ 5028 #endif /* if ( configUSE_TIMERS == 1 ) */ 5029 5030 ( UBaseType_t ) MPU_xEventGroupClearBitsImpl, /* SYSTEM_CALL_xEventGroupClearBits. */ 5031 ( UBaseType_t ) MPU_xEventGroupSetBitsImpl, /* SYSTEM_CALL_xEventGroupSetBits. */ 5032 ( UBaseType_t ) MPU_xEventGroupSyncImpl, /* SYSTEM_CALL_xEventGroupSync. */ 5033 5034 #if ( configUSE_TRACE_FACILITY == 1 ) 5035 ( UBaseType_t ) MPU_uxEventGroupGetNumberImpl, /* SYSTEM_CALL_uxEventGroupGetNumber. */ 5036 ( UBaseType_t ) MPU_vEventGroupSetNumberImpl, /* SYSTEM_CALL_vEventGroupSetNumber. */ 5037 #else 5038 ( UBaseType_t ) 0, /* SYSTEM_CALL_uxEventGroupGetNumber. */ 5039 ( UBaseType_t ) 0, /* SYSTEM_CALL_vEventGroupSetNumber. */ 5040 #endif 5041 5042 ( UBaseType_t ) MPU_xStreamBufferSendImpl, /* SYSTEM_CALL_xStreamBufferSend. */ 5043 ( UBaseType_t ) MPU_xStreamBufferReceiveImpl, /* SYSTEM_CALL_xStreamBufferReceive. */ 5044 ( UBaseType_t ) MPU_xStreamBufferIsFullImpl, /* SYSTEM_CALL_xStreamBufferIsFull. */ 5045 ( UBaseType_t ) MPU_xStreamBufferIsEmptyImpl, /* SYSTEM_CALL_xStreamBufferIsEmpty. */ 5046 ( UBaseType_t ) MPU_xStreamBufferSpacesAvailableImpl, /* SYSTEM_CALL_xStreamBufferSpacesAvailable. */ 5047 ( UBaseType_t ) MPU_xStreamBufferBytesAvailableImpl, /* SYSTEM_CALL_xStreamBufferBytesAvailable. */ 5048 ( UBaseType_t ) MPU_xStreamBufferSetTriggerLevelImpl, /* SYSTEM_CALL_xStreamBufferSetTriggerLevel. */ 5049 ( UBaseType_t ) MPU_xStreamBufferNextMessageLengthBytesImpl /* SYSTEM_CALL_xStreamBufferNextMessageLengthBytes. */ 5050 }; 5051 /*-----------------------------------------------------------*/ 5052 5053 #endif /* #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) ) */ 5054 /*-----------------------------------------------------------*/ 5055