1 /* 2 * FreeRTOS Kernel V11.1.0 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 48 #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE 49 /*-----------------------------------------------------------*/ 50 51 #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 1 ) ) 52 53 #if ( configENABLE_ACCESS_CONTROL_LIST == 1 ) 54 #error Access control list is not available with this MPU wrapper. Please set configENABLE_ACCESS_CONTROL_LIST to 0. 55 #endif 56 57 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) MPU_xTaskCreate(TaskFunction_t pvTaskCode,const char * const pcName,const configSTACK_DEPTH_TYPE uxStackDepth,void * pvParameters,UBaseType_t uxPriority,TaskHandle_t * pxCreatedTask)58 BaseType_t MPU_xTaskCreate( TaskFunction_t pvTaskCode, 59 const char * const pcName, 60 const configSTACK_DEPTH_TYPE uxStackDepth, 61 void * pvParameters, 62 UBaseType_t uxPriority, 63 TaskHandle_t * pxCreatedTask ) /* FREERTOS_SYSTEM_CALL */ 64 { 65 BaseType_t xReturn; 66 67 if( portIS_PRIVILEGED() == pdFALSE ) 68 { 69 portRAISE_PRIVILEGE(); 70 portMEMORY_BARRIER(); 71 72 uxPriority = uxPriority & ~( portPRIVILEGE_BIT ); 73 portMEMORY_BARRIER(); 74 75 xReturn = xTaskCreate( pvTaskCode, pcName, uxStackDepth, pvParameters, uxPriority, pxCreatedTask ); 76 portMEMORY_BARRIER(); 77 78 portRESET_PRIVILEGE(); 79 portMEMORY_BARRIER(); 80 } 81 else 82 { 83 xReturn = xTaskCreate( pvTaskCode, pcName, uxStackDepth, pvParameters, uxPriority, pxCreatedTask ); 84 } 85 86 return xReturn; 87 } 88 #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ 89 /*-----------------------------------------------------------*/ 90 91 #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) MPU_xTaskCreateStatic(TaskFunction_t pxTaskCode,const char * const pcName,const configSTACK_DEPTH_TYPE uxStackDepth,void * const pvParameters,UBaseType_t uxPriority,StackType_t * const puxStackBuffer,StaticTask_t * const pxTaskBuffer)92 TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode, 93 const char * const pcName, 94 const configSTACK_DEPTH_TYPE uxStackDepth, 95 void * const pvParameters, 96 UBaseType_t uxPriority, 97 StackType_t * const puxStackBuffer, 98 StaticTask_t * const pxTaskBuffer ) /* FREERTOS_SYSTEM_CALL */ 99 { 100 TaskHandle_t xReturn; 101 102 if( portIS_PRIVILEGED() == pdFALSE ) 103 { 104 portRAISE_PRIVILEGE(); 105 portMEMORY_BARRIER(); 106 107 uxPriority = uxPriority & ~( portPRIVILEGE_BIT ); 108 portMEMORY_BARRIER(); 109 110 xReturn = xTaskCreateStatic( pxTaskCode, pcName, uxStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer ); 111 portMEMORY_BARRIER(); 112 113 portRESET_PRIVILEGE(); 114 portMEMORY_BARRIER(); 115 } 116 else 117 { 118 xReturn = xTaskCreateStatic( pxTaskCode, pcName, uxStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer ); 119 } 120 121 return xReturn; 122 } 123 #endif /* configSUPPORT_STATIC_ALLOCATION */ 124 /*-----------------------------------------------------------*/ 125 126 #if ( INCLUDE_vTaskDelete == 1 ) MPU_vTaskDelete(TaskHandle_t pxTaskToDelete)127 void MPU_vTaskDelete( TaskHandle_t pxTaskToDelete ) /* FREERTOS_SYSTEM_CALL */ 128 { 129 if( portIS_PRIVILEGED() == pdFALSE ) 130 { 131 portRAISE_PRIVILEGE(); 132 portMEMORY_BARRIER(); 133 134 vTaskDelete( pxTaskToDelete ); 135 portMEMORY_BARRIER(); 136 137 portRESET_PRIVILEGE(); 138 portMEMORY_BARRIER(); 139 } 140 else 141 { 142 vTaskDelete( pxTaskToDelete ); 143 } 144 } 145 #endif /* if ( INCLUDE_vTaskDelete == 1 ) */ 146 /*-----------------------------------------------------------*/ 147 148 #if ( INCLUDE_xTaskDelayUntil == 1 ) MPU_xTaskDelayUntil(TickType_t * const pxPreviousWakeTime,TickType_t xTimeIncrement)149 BaseType_t MPU_xTaskDelayUntil( TickType_t * const pxPreviousWakeTime, 150 TickType_t xTimeIncrement ) /* FREERTOS_SYSTEM_CALL */ 151 { 152 BaseType_t xReturn; 153 154 if( portIS_PRIVILEGED() == pdFALSE ) 155 { 156 portRAISE_PRIVILEGE(); 157 portMEMORY_BARRIER(); 158 159 xReturn = xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ); 160 portMEMORY_BARRIER(); 161 162 portRESET_PRIVILEGE(); 163 portMEMORY_BARRIER(); 164 } 165 else 166 { 167 xReturn = xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ); 168 } 169 170 return xReturn; 171 } 172 #endif /* if ( INCLUDE_xTaskDelayUntil == 1 ) */ 173 /*-----------------------------------------------------------*/ 174 175 #if ( INCLUDE_xTaskAbortDelay == 1 ) MPU_xTaskAbortDelay(TaskHandle_t xTask)176 BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */ 177 { 178 BaseType_t xReturn; 179 180 if( portIS_PRIVILEGED() == pdFALSE ) 181 { 182 portRAISE_PRIVILEGE(); 183 portMEMORY_BARRIER(); 184 185 xReturn = xTaskAbortDelay( xTask ); 186 portMEMORY_BARRIER(); 187 188 portRESET_PRIVILEGE(); 189 portMEMORY_BARRIER(); 190 } 191 else 192 { 193 xReturn = xTaskAbortDelay( xTask ); 194 } 195 196 return xReturn; 197 } 198 #endif /* if ( INCLUDE_xTaskAbortDelay == 1 ) */ 199 /*-----------------------------------------------------------*/ 200 201 #if ( INCLUDE_vTaskDelay == 1 ) MPU_vTaskDelay(TickType_t xTicksToDelay)202 void MPU_vTaskDelay( TickType_t xTicksToDelay ) /* FREERTOS_SYSTEM_CALL */ 203 { 204 if( portIS_PRIVILEGED() == pdFALSE ) 205 { 206 portRAISE_PRIVILEGE(); 207 portMEMORY_BARRIER(); 208 209 vTaskDelay( xTicksToDelay ); 210 portMEMORY_BARRIER(); 211 212 portRESET_PRIVILEGE(); 213 portMEMORY_BARRIER(); 214 } 215 else 216 { 217 vTaskDelay( xTicksToDelay ); 218 } 219 } 220 #endif /* if ( INCLUDE_vTaskDelay == 1 ) */ 221 /*-----------------------------------------------------------*/ 222 223 #if ( INCLUDE_uxTaskPriorityGet == 1 ) MPU_uxTaskPriorityGet(const TaskHandle_t pxTask)224 UBaseType_t MPU_uxTaskPriorityGet( const TaskHandle_t pxTask ) /* FREERTOS_SYSTEM_CALL */ 225 { 226 UBaseType_t uxReturn; 227 228 if( portIS_PRIVILEGED() == pdFALSE ) 229 { 230 portRAISE_PRIVILEGE(); 231 portMEMORY_BARRIER(); 232 233 uxReturn = uxTaskPriorityGet( pxTask ); 234 portMEMORY_BARRIER(); 235 236 portRESET_PRIVILEGE(); 237 portMEMORY_BARRIER(); 238 } 239 else 240 { 241 uxReturn = uxTaskPriorityGet( pxTask ); 242 } 243 244 return uxReturn; 245 } 246 #endif /* if ( INCLUDE_uxTaskPriorityGet == 1 ) */ 247 /*-----------------------------------------------------------*/ 248 249 #if ( INCLUDE_vTaskPrioritySet == 1 ) MPU_vTaskPrioritySet(TaskHandle_t pxTask,UBaseType_t uxNewPriority)250 void MPU_vTaskPrioritySet( TaskHandle_t pxTask, 251 UBaseType_t uxNewPriority ) /* FREERTOS_SYSTEM_CALL */ 252 { 253 if( portIS_PRIVILEGED() == pdFALSE ) 254 { 255 portRAISE_PRIVILEGE(); 256 portMEMORY_BARRIER(); 257 258 vTaskPrioritySet( pxTask, uxNewPriority ); 259 portMEMORY_BARRIER(); 260 261 portRESET_PRIVILEGE(); 262 portMEMORY_BARRIER(); 263 } 264 else 265 { 266 vTaskPrioritySet( pxTask, uxNewPriority ); 267 } 268 } 269 #endif /* if ( INCLUDE_vTaskPrioritySet == 1 ) */ 270 /*-----------------------------------------------------------*/ 271 272 #if ( INCLUDE_eTaskGetState == 1 ) MPU_eTaskGetState(TaskHandle_t pxTask)273 eTaskState MPU_eTaskGetState( TaskHandle_t pxTask ) /* FREERTOS_SYSTEM_CALL */ 274 { 275 eTaskState eReturn; 276 277 if( portIS_PRIVILEGED() == pdFALSE ) 278 { 279 portRAISE_PRIVILEGE(); 280 portMEMORY_BARRIER(); 281 282 eReturn = eTaskGetState( pxTask ); 283 portMEMORY_BARRIER(); 284 285 portRESET_PRIVILEGE(); 286 portMEMORY_BARRIER(); 287 } 288 else 289 { 290 eReturn = eTaskGetState( pxTask ); 291 } 292 293 return eReturn; 294 } 295 #endif /* if ( INCLUDE_eTaskGetState == 1 ) */ 296 /*-----------------------------------------------------------*/ 297 298 #if ( configUSE_TRACE_FACILITY == 1 ) MPU_vTaskGetInfo(TaskHandle_t xTask,TaskStatus_t * pxTaskStatus,BaseType_t xGetFreeStackSpace,eTaskState eState)299 void MPU_vTaskGetInfo( TaskHandle_t xTask, 300 TaskStatus_t * pxTaskStatus, 301 BaseType_t xGetFreeStackSpace, 302 eTaskState eState ) /* FREERTOS_SYSTEM_CALL */ 303 { 304 if( portIS_PRIVILEGED() == pdFALSE ) 305 { 306 portRAISE_PRIVILEGE(); 307 portMEMORY_BARRIER(); 308 309 vTaskGetInfo( xTask, pxTaskStatus, xGetFreeStackSpace, eState ); 310 portMEMORY_BARRIER(); 311 312 portRESET_PRIVILEGE(); 313 portMEMORY_BARRIER(); 314 } 315 else 316 { 317 vTaskGetInfo( xTask, pxTaskStatus, xGetFreeStackSpace, eState ); 318 } 319 } 320 #endif /* if ( configUSE_TRACE_FACILITY == 1 ) */ 321 /*-----------------------------------------------------------*/ 322 323 #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) MPU_xTaskGetIdleTaskHandle(void)324 TaskHandle_t MPU_xTaskGetIdleTaskHandle( void ) /* FREERTOS_SYSTEM_CALL */ 325 { 326 TaskHandle_t xReturn; 327 328 if( portIS_PRIVILEGED() == pdFALSE ) 329 { 330 portRAISE_PRIVILEGE(); 331 portMEMORY_BARRIER(); 332 xReturn = xTaskGetIdleTaskHandle(); 333 portMEMORY_BARRIER(); 334 335 portRESET_PRIVILEGE(); 336 portMEMORY_BARRIER(); 337 } 338 else 339 { 340 xReturn = xTaskGetIdleTaskHandle(); 341 } 342 343 return xReturn; 344 } 345 #endif /* if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) */ 346 /*-----------------------------------------------------------*/ 347 348 #if ( INCLUDE_vTaskSuspend == 1 ) MPU_vTaskSuspend(TaskHandle_t pxTaskToSuspend)349 void MPU_vTaskSuspend( TaskHandle_t pxTaskToSuspend ) /* FREERTOS_SYSTEM_CALL */ 350 { 351 if( portIS_PRIVILEGED() == pdFALSE ) 352 { 353 portRAISE_PRIVILEGE(); 354 portMEMORY_BARRIER(); 355 356 vTaskSuspend( pxTaskToSuspend ); 357 portMEMORY_BARRIER(); 358 359 portRESET_PRIVILEGE(); 360 portMEMORY_BARRIER(); 361 } 362 else 363 { 364 vTaskSuspend( pxTaskToSuspend ); 365 } 366 } 367 #endif /* if ( INCLUDE_vTaskSuspend == 1 ) */ 368 /*-----------------------------------------------------------*/ 369 370 #if ( INCLUDE_vTaskSuspend == 1 ) MPU_vTaskResume(TaskHandle_t pxTaskToResume)371 void MPU_vTaskResume( TaskHandle_t pxTaskToResume ) /* FREERTOS_SYSTEM_CALL */ 372 { 373 if( portIS_PRIVILEGED() == pdFALSE ) 374 { 375 portRAISE_PRIVILEGE(); 376 portMEMORY_BARRIER(); 377 378 vTaskResume( pxTaskToResume ); 379 portMEMORY_BARRIER(); 380 381 portRESET_PRIVILEGE(); 382 portMEMORY_BARRIER(); 383 } 384 else 385 { 386 vTaskResume( pxTaskToResume ); 387 } 388 } 389 #endif /* if ( INCLUDE_vTaskSuspend == 1 ) */ 390 /*-----------------------------------------------------------*/ 391 MPU_vTaskSuspendAll(void)392 void MPU_vTaskSuspendAll( void ) /* FREERTOS_SYSTEM_CALL */ 393 { 394 if( portIS_PRIVILEGED() == pdFALSE ) 395 { 396 portRAISE_PRIVILEGE(); 397 portMEMORY_BARRIER(); 398 399 vTaskSuspendAll(); 400 portMEMORY_BARRIER(); 401 402 portRESET_PRIVILEGE(); 403 portMEMORY_BARRIER(); 404 } 405 else 406 { 407 vTaskSuspendAll(); 408 } 409 } 410 /*-----------------------------------------------------------*/ 411 MPU_xTaskResumeAll(void)412 BaseType_t MPU_xTaskResumeAll( void ) /* FREERTOS_SYSTEM_CALL */ 413 { 414 BaseType_t xReturn; 415 416 if( portIS_PRIVILEGED() == pdFALSE ) 417 { 418 portRAISE_PRIVILEGE(); 419 portMEMORY_BARRIER(); 420 421 xReturn = xTaskResumeAll(); 422 portMEMORY_BARRIER(); 423 424 portRESET_PRIVILEGE(); 425 portMEMORY_BARRIER(); 426 } 427 else 428 { 429 xReturn = xTaskResumeAll(); 430 } 431 432 return xReturn; 433 } 434 /*-----------------------------------------------------------*/ 435 MPU_xTaskGetTickCount(void)436 TickType_t MPU_xTaskGetTickCount( void ) /* FREERTOS_SYSTEM_CALL */ 437 { 438 TickType_t xReturn; 439 440 if( portIS_PRIVILEGED() == pdFALSE ) 441 { 442 portRAISE_PRIVILEGE(); 443 portMEMORY_BARRIER(); 444 445 xReturn = xTaskGetTickCount(); 446 portMEMORY_BARRIER(); 447 448 portRESET_PRIVILEGE(); 449 portMEMORY_BARRIER(); 450 } 451 else 452 { 453 xReturn = xTaskGetTickCount(); 454 } 455 456 return xReturn; 457 } 458 /*-----------------------------------------------------------*/ 459 MPU_uxTaskGetNumberOfTasks(void)460 UBaseType_t MPU_uxTaskGetNumberOfTasks( void ) /* FREERTOS_SYSTEM_CALL */ 461 { 462 UBaseType_t uxReturn; 463 464 if( portIS_PRIVILEGED() == pdFALSE ) 465 { 466 portRAISE_PRIVILEGE(); 467 portMEMORY_BARRIER(); 468 469 uxReturn = uxTaskGetNumberOfTasks(); 470 portMEMORY_BARRIER(); 471 472 portRESET_PRIVILEGE(); 473 portMEMORY_BARRIER(); 474 } 475 else 476 { 477 uxReturn = uxTaskGetNumberOfTasks(); 478 } 479 480 return uxReturn; 481 } 482 /*-----------------------------------------------------------*/ 483 484 #if ( INCLUDE_xTaskGetHandle == 1 ) MPU_xTaskGetHandle(const char * pcNameToQuery)485 TaskHandle_t MPU_xTaskGetHandle( const char * pcNameToQuery ) /* FREERTOS_SYSTEM_CALL */ 486 { 487 TaskHandle_t xReturn; 488 489 if( portIS_PRIVILEGED() == pdFALSE ) 490 { 491 portRAISE_PRIVILEGE(); 492 portMEMORY_BARRIER(); 493 494 xReturn = xTaskGetHandle( pcNameToQuery ); 495 portMEMORY_BARRIER(); 496 497 portRESET_PRIVILEGE(); 498 portMEMORY_BARRIER(); 499 } 500 else 501 { 502 xReturn = xTaskGetHandle( pcNameToQuery ); 503 } 504 505 return xReturn; 506 } 507 #endif /* if ( INCLUDE_xTaskGetHandle == 1 ) */ 508 /*-----------------------------------------------------------*/ 509 510 #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) MPU_vTaskList(char * pcWriteBuffer)511 void MPU_vTaskList( char * pcWriteBuffer ) /* FREERTOS_SYSTEM_CALL */ 512 { 513 if( portIS_PRIVILEGED() == pdFALSE ) 514 { 515 portRAISE_PRIVILEGE(); 516 portMEMORY_BARRIER(); 517 518 vTaskList( pcWriteBuffer ); 519 portMEMORY_BARRIER(); 520 521 portRESET_PRIVILEGE(); 522 portMEMORY_BARRIER(); 523 } 524 else 525 { 526 vTaskList( pcWriteBuffer ); 527 } 528 } 529 #endif /* if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */ 530 /*-----------------------------------------------------------*/ 531 532 #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) MPU_vTaskGetRunTimeStats(char * pcWriteBuffer)533 void MPU_vTaskGetRunTimeStats( char * pcWriteBuffer ) /* FREERTOS_SYSTEM_CALL */ 534 { 535 if( portIS_PRIVILEGED() == pdFALSE ) 536 { 537 portRAISE_PRIVILEGE(); 538 portMEMORY_BARRIER(); 539 540 vTaskGetRunTimeStats( pcWriteBuffer ); 541 portMEMORY_BARRIER(); 542 543 portRESET_PRIVILEGE(); 544 portMEMORY_BARRIER(); 545 } 546 else 547 { 548 vTaskGetRunTimeStats( pcWriteBuffer ); 549 } 550 } 551 #endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */ 552 /*-----------------------------------------------------------*/ 553 554 #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) MPU_ulTaskGetIdleRunTimePercent(void)555 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimePercent( void ) /* FREERTOS_SYSTEM_CALL */ 556 { 557 configRUN_TIME_COUNTER_TYPE xReturn; 558 559 if( portIS_PRIVILEGED() == pdFALSE ) 560 { 561 portRAISE_PRIVILEGE(); 562 portMEMORY_BARRIER(); 563 564 xReturn = ulTaskGetIdleRunTimePercent(); 565 portMEMORY_BARRIER(); 566 567 portRESET_PRIVILEGE(); 568 portMEMORY_BARRIER(); 569 } 570 else 571 { 572 xReturn = ulTaskGetIdleRunTimePercent(); 573 } 574 575 return xReturn; 576 } 577 #endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) */ 578 /*-----------------------------------------------------------*/ 579 580 #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) MPU_ulTaskGetIdleRunTimeCounter(void)581 configRUN_TIME_COUNTER_TYPE MPU_ulTaskGetIdleRunTimeCounter( void ) /* FREERTOS_SYSTEM_CALL */ 582 { 583 configRUN_TIME_COUNTER_TYPE xReturn; 584 585 if( portIS_PRIVILEGED() == pdFALSE ) 586 { 587 portRAISE_PRIVILEGE(); 588 portMEMORY_BARRIER(); 589 590 xReturn = ulTaskGetIdleRunTimeCounter(); 591 portMEMORY_BARRIER(); 592 593 portRESET_PRIVILEGE(); 594 portMEMORY_BARRIER(); 595 } 596 else 597 { 598 xReturn = ulTaskGetIdleRunTimeCounter(); 599 } 600 601 return xReturn; 602 } 603 #endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) */ 604 /*-----------------------------------------------------------*/ 605 606 #if ( configUSE_APPLICATION_TASK_TAG == 1 ) MPU_vTaskSetApplicationTaskTag(TaskHandle_t xTask,TaskHookFunction_t pxTagValue)607 void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask, 608 TaskHookFunction_t pxTagValue ) /* FREERTOS_SYSTEM_CALL */ 609 { 610 if( portIS_PRIVILEGED() == pdFALSE ) 611 { 612 portRAISE_PRIVILEGE(); 613 portMEMORY_BARRIER(); 614 615 vTaskSetApplicationTaskTag( xTask, pxTagValue ); 616 portMEMORY_BARRIER(); 617 618 portRESET_PRIVILEGE(); 619 portMEMORY_BARRIER(); 620 } 621 else 622 { 623 vTaskSetApplicationTaskTag( xTask, pxTagValue ); 624 } 625 } 626 #endif /* if ( configUSE_APPLICATION_TASK_TAG == 1 ) */ 627 /*-----------------------------------------------------------*/ 628 629 #if ( configUSE_APPLICATION_TASK_TAG == 1 ) MPU_xTaskGetApplicationTaskTag(TaskHandle_t xTask)630 TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */ 631 { 632 TaskHookFunction_t xReturn; 633 634 if( portIS_PRIVILEGED() == pdFALSE ) 635 { 636 portRAISE_PRIVILEGE(); 637 portMEMORY_BARRIER(); 638 639 xReturn = xTaskGetApplicationTaskTag( xTask ); 640 portMEMORY_BARRIER(); 641 642 portRESET_PRIVILEGE(); 643 portMEMORY_BARRIER(); 644 } 645 else 646 { 647 xReturn = xTaskGetApplicationTaskTag( xTask ); 648 } 649 650 return xReturn; 651 } 652 #endif /* if ( configUSE_APPLICATION_TASK_TAG == 1 ) */ 653 /*-----------------------------------------------------------*/ 654 655 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) MPU_vTaskSetThreadLocalStoragePointer(TaskHandle_t xTaskToSet,BaseType_t xIndex,void * pvValue)656 void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, 657 BaseType_t xIndex, 658 void * pvValue ) /* FREERTOS_SYSTEM_CALL */ 659 { 660 if( portIS_PRIVILEGED() == pdFALSE ) 661 { 662 portRAISE_PRIVILEGE(); 663 portMEMORY_BARRIER(); 664 665 vTaskSetThreadLocalStoragePointer( xTaskToSet, xIndex, pvValue ); 666 portMEMORY_BARRIER(); 667 668 portRESET_PRIVILEGE(); 669 portMEMORY_BARRIER(); 670 } 671 else 672 { 673 vTaskSetThreadLocalStoragePointer( xTaskToSet, xIndex, pvValue ); 674 } 675 } 676 #endif /* if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) */ 677 /*-----------------------------------------------------------*/ 678 679 #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) MPU_pvTaskGetThreadLocalStoragePointer(TaskHandle_t xTaskToQuery,BaseType_t xIndex)680 void * MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, 681 BaseType_t xIndex ) /* FREERTOS_SYSTEM_CALL */ 682 { 683 void * pvReturn; 684 685 if( portIS_PRIVILEGED() == pdFALSE ) 686 { 687 portRAISE_PRIVILEGE(); 688 portMEMORY_BARRIER(); 689 690 pvReturn = pvTaskGetThreadLocalStoragePointer( xTaskToQuery, xIndex ); 691 portMEMORY_BARRIER(); 692 693 portRESET_PRIVILEGE(); 694 portMEMORY_BARRIER(); 695 } 696 else 697 { 698 pvReturn = pvTaskGetThreadLocalStoragePointer( xTaskToQuery, xIndex ); 699 } 700 701 return pvReturn; 702 } 703 #endif /* if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) */ 704 /*-----------------------------------------------------------*/ 705 706 #if ( configUSE_APPLICATION_TASK_TAG == 1 ) MPU_xTaskCallApplicationTaskHook(TaskHandle_t xTask,void * pvParameter)707 BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, 708 void * pvParameter ) /* FREERTOS_SYSTEM_CALL */ 709 { 710 BaseType_t xReturn; 711 712 if( portIS_PRIVILEGED() == pdFALSE ) 713 { 714 portRAISE_PRIVILEGE(); 715 portMEMORY_BARRIER(); 716 717 xReturn = xTaskCallApplicationTaskHook( xTask, pvParameter ); 718 portMEMORY_BARRIER(); 719 720 portRESET_PRIVILEGE(); 721 portMEMORY_BARRIER(); 722 } 723 else 724 { 725 xReturn = xTaskCallApplicationTaskHook( xTask, pvParameter ); 726 } 727 728 return xReturn; 729 } 730 #endif /* if ( configUSE_APPLICATION_TASK_TAG == 1 ) */ 731 /*-----------------------------------------------------------*/ 732 733 #if ( configUSE_TRACE_FACILITY == 1 ) MPU_uxTaskGetSystemState(TaskStatus_t * pxTaskStatusArray,UBaseType_t uxArraySize,configRUN_TIME_COUNTER_TYPE * pulTotalRunTime)734 UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t * pxTaskStatusArray, 735 UBaseType_t uxArraySize, 736 configRUN_TIME_COUNTER_TYPE * pulTotalRunTime ) /* FREERTOS_SYSTEM_CALL */ 737 { 738 UBaseType_t uxReturn; 739 740 if( portIS_PRIVILEGED() == pdFALSE ) 741 { 742 portRAISE_PRIVILEGE(); 743 portMEMORY_BARRIER(); 744 745 uxReturn = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, pulTotalRunTime ); 746 portMEMORY_BARRIER(); 747 748 portRESET_PRIVILEGE(); 749 portMEMORY_BARRIER(); 750 } 751 else 752 { 753 uxReturn = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, pulTotalRunTime ); 754 } 755 756 return uxReturn; 757 } 758 #endif /* if ( configUSE_TRACE_FACILITY == 1 ) */ 759 /*-----------------------------------------------------------*/ 760 MPU_xTaskCatchUpTicks(TickType_t xTicksToCatchUp)761 BaseType_t MPU_xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) /* FREERTOS_SYSTEM_CALL */ 762 { 763 BaseType_t xReturn; 764 765 if( portIS_PRIVILEGED() == pdFALSE ) 766 { 767 portRAISE_PRIVILEGE(); 768 portMEMORY_BARRIER(); 769 770 xReturn = xTaskCatchUpTicks( xTicksToCatchUp ); 771 portMEMORY_BARRIER(); 772 773 portRESET_PRIVILEGE(); 774 portMEMORY_BARRIER(); 775 } 776 else 777 { 778 xReturn = xTaskCatchUpTicks( xTicksToCatchUp ); 779 } 780 781 return xReturn; 782 } 783 /*-----------------------------------------------------------*/ 784 785 #if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) MPU_uxTaskGetStackHighWaterMark(TaskHandle_t xTask)786 UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */ 787 { 788 UBaseType_t uxReturn; 789 790 if( portIS_PRIVILEGED() == pdFALSE ) 791 { 792 portRAISE_PRIVILEGE(); 793 portMEMORY_BARRIER(); 794 795 uxReturn = uxTaskGetStackHighWaterMark( xTask ); 796 portMEMORY_BARRIER(); 797 798 portRESET_PRIVILEGE(); 799 portMEMORY_BARRIER(); 800 } 801 else 802 { 803 uxReturn = uxTaskGetStackHighWaterMark( xTask ); 804 } 805 806 return uxReturn; 807 } 808 #endif /* if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) */ 809 /*-----------------------------------------------------------*/ 810 811 #if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) MPU_uxTaskGetStackHighWaterMark2(TaskHandle_t xTask)812 configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */ 813 { 814 configSTACK_DEPTH_TYPE uxReturn; 815 816 if( portIS_PRIVILEGED() == pdFALSE ) 817 { 818 portRAISE_PRIVILEGE(); 819 portMEMORY_BARRIER(); 820 821 uxReturn = uxTaskGetStackHighWaterMark2( xTask ); 822 portMEMORY_BARRIER(); 823 824 portRESET_PRIVILEGE(); 825 portMEMORY_BARRIER(); 826 } 827 else 828 { 829 uxReturn = uxTaskGetStackHighWaterMark2( xTask ); 830 } 831 832 return uxReturn; 833 } 834 #endif /* if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) */ 835 /*-----------------------------------------------------------*/ 836 837 #if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) ) MPU_xTaskGetCurrentTaskHandle(void)838 TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ) /* FREERTOS_SYSTEM_CALL */ 839 { 840 TaskHandle_t xReturn; 841 842 if( portIS_PRIVILEGED() == pdFALSE ) 843 { 844 portRAISE_PRIVILEGE(); 845 portMEMORY_BARRIER(); 846 xReturn = xTaskGetCurrentTaskHandle(); 847 portMEMORY_BARRIER(); 848 849 portRESET_PRIVILEGE(); 850 portMEMORY_BARRIER(); 851 } 852 else 853 { 854 xReturn = xTaskGetCurrentTaskHandle(); 855 } 856 857 return xReturn; 858 } 859 #endif /* if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) ) */ 860 /*-----------------------------------------------------------*/ 861 862 #if ( INCLUDE_xTaskGetSchedulerState == 1 ) MPU_xTaskGetSchedulerState(void)863 BaseType_t MPU_xTaskGetSchedulerState( void ) /* FREERTOS_SYSTEM_CALL */ 864 { 865 BaseType_t xReturn; 866 867 if( portIS_PRIVILEGED() == pdFALSE ) 868 { 869 portRAISE_PRIVILEGE(); 870 portMEMORY_BARRIER(); 871 872 xReturn = xTaskGetSchedulerState(); 873 portMEMORY_BARRIER(); 874 875 portRESET_PRIVILEGE(); 876 portMEMORY_BARRIER(); 877 } 878 else 879 { 880 xReturn = xTaskGetSchedulerState(); 881 } 882 883 return xReturn; 884 } 885 #endif /* if ( INCLUDE_xTaskGetSchedulerState == 1 ) */ 886 /*-----------------------------------------------------------*/ 887 MPU_vTaskSetTimeOutState(TimeOut_t * const pxTimeOut)888 void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) /* FREERTOS_SYSTEM_CALL */ 889 { 890 if( portIS_PRIVILEGED() == pdFALSE ) 891 { 892 portRAISE_PRIVILEGE(); 893 portMEMORY_BARRIER(); 894 895 vTaskSetTimeOutState( pxTimeOut ); 896 portMEMORY_BARRIER(); 897 898 portRESET_PRIVILEGE(); 899 portMEMORY_BARRIER(); 900 } 901 else 902 { 903 vTaskSetTimeOutState( pxTimeOut ); 904 } 905 } 906 /*-----------------------------------------------------------*/ 907 MPU_xTaskCheckForTimeOut(TimeOut_t * const pxTimeOut,TickType_t * const pxTicksToWait)908 BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, 909 TickType_t * const pxTicksToWait ) /* FREERTOS_SYSTEM_CALL */ 910 { 911 BaseType_t xReturn; 912 913 if( portIS_PRIVILEGED() == pdFALSE ) 914 { 915 portRAISE_PRIVILEGE(); 916 portMEMORY_BARRIER(); 917 918 xReturn = xTaskCheckForTimeOut( pxTimeOut, pxTicksToWait ); 919 portMEMORY_BARRIER(); 920 921 portRESET_PRIVILEGE(); 922 portMEMORY_BARRIER(); 923 } 924 else 925 { 926 xReturn = xTaskCheckForTimeOut( pxTimeOut, pxTicksToWait ); 927 } 928 929 return xReturn; 930 } 931 /*-----------------------------------------------------------*/ 932 933 #if ( configUSE_TASK_NOTIFICATIONS == 1 ) MPU_xTaskGenericNotify(TaskHandle_t xTaskToNotify,UBaseType_t uxIndexToNotify,uint32_t ulValue,eNotifyAction eAction,uint32_t * pulPreviousNotificationValue)934 BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, 935 UBaseType_t uxIndexToNotify, 936 uint32_t ulValue, 937 eNotifyAction eAction, 938 uint32_t * pulPreviousNotificationValue ) /* FREERTOS_SYSTEM_CALL */ 939 { 940 BaseType_t xReturn; 941 942 if( portIS_PRIVILEGED() == pdFALSE ) 943 { 944 portRAISE_PRIVILEGE(); 945 portMEMORY_BARRIER(); 946 947 xReturn = xTaskGenericNotify( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue ); 948 portMEMORY_BARRIER(); 949 950 portRESET_PRIVILEGE(); 951 portMEMORY_BARRIER(); 952 } 953 else 954 { 955 xReturn = xTaskGenericNotify( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue ); 956 } 957 958 return xReturn; 959 } 960 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */ 961 /*-----------------------------------------------------------*/ 962 963 #if ( configUSE_TASK_NOTIFICATIONS == 1 ) MPU_xTaskGenericNotifyWait(UBaseType_t uxIndexToWaitOn,uint32_t ulBitsToClearOnEntry,uint32_t ulBitsToClearOnExit,uint32_t * pulNotificationValue,TickType_t xTicksToWait)964 BaseType_t MPU_xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn, 965 uint32_t ulBitsToClearOnEntry, 966 uint32_t ulBitsToClearOnExit, 967 uint32_t * pulNotificationValue, 968 TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ 969 { 970 BaseType_t xReturn; 971 972 if( portIS_PRIVILEGED() == pdFALSE ) 973 { 974 portRAISE_PRIVILEGE(); 975 portMEMORY_BARRIER(); 976 977 xReturn = xTaskGenericNotifyWait( uxIndexToWaitOn, ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ); 978 portMEMORY_BARRIER(); 979 980 portRESET_PRIVILEGE(); 981 portMEMORY_BARRIER(); 982 } 983 else 984 { 985 xReturn = xTaskGenericNotifyWait( uxIndexToWaitOn, ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ); 986 } 987 988 return xReturn; 989 } 990 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */ 991 /*-----------------------------------------------------------*/ 992 993 #if ( configUSE_TASK_NOTIFICATIONS == 1 ) MPU_ulTaskGenericNotifyTake(UBaseType_t uxIndexToWaitOn,BaseType_t xClearCountOnExit,TickType_t xTicksToWait)994 uint32_t MPU_ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn, 995 BaseType_t xClearCountOnExit, 996 TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ 997 { 998 uint32_t ulReturn; 999 1000 if( portIS_PRIVILEGED() == pdFALSE ) 1001 { 1002 portRAISE_PRIVILEGE(); 1003 portMEMORY_BARRIER(); 1004 1005 ulReturn = ulTaskGenericNotifyTake( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait ); 1006 portMEMORY_BARRIER(); 1007 1008 portRESET_PRIVILEGE(); 1009 portMEMORY_BARRIER(); 1010 } 1011 else 1012 { 1013 ulReturn = ulTaskGenericNotifyTake( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait ); 1014 } 1015 1016 return ulReturn; 1017 } 1018 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */ 1019 /*-----------------------------------------------------------*/ 1020 1021 #if ( configUSE_TASK_NOTIFICATIONS == 1 ) MPU_xTaskGenericNotifyStateClear(TaskHandle_t xTask,UBaseType_t uxIndexToClear)1022 BaseType_t MPU_xTaskGenericNotifyStateClear( TaskHandle_t xTask, 1023 UBaseType_t uxIndexToClear ) /* FREERTOS_SYSTEM_CALL */ 1024 { 1025 BaseType_t xReturn; 1026 1027 if( portIS_PRIVILEGED() == pdFALSE ) 1028 { 1029 portRAISE_PRIVILEGE(); 1030 portMEMORY_BARRIER(); 1031 1032 xReturn = xTaskGenericNotifyStateClear( xTask, uxIndexToClear ); 1033 portMEMORY_BARRIER(); 1034 1035 portRESET_PRIVILEGE(); 1036 portMEMORY_BARRIER(); 1037 } 1038 else 1039 { 1040 xReturn = xTaskGenericNotifyStateClear( xTask, uxIndexToClear ); 1041 } 1042 1043 return xReturn; 1044 } 1045 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */ 1046 /*-----------------------------------------------------------*/ 1047 1048 #if ( configUSE_TASK_NOTIFICATIONS == 1 ) MPU_ulTaskGenericNotifyValueClear(TaskHandle_t xTask,UBaseType_t uxIndexToClear,uint32_t ulBitsToClear)1049 uint32_t MPU_ulTaskGenericNotifyValueClear( TaskHandle_t xTask, 1050 UBaseType_t uxIndexToClear, 1051 uint32_t ulBitsToClear ) /* FREERTOS_SYSTEM_CALL */ 1052 { 1053 uint32_t ulReturn; 1054 1055 if( portIS_PRIVILEGED() == pdFALSE ) 1056 { 1057 portRAISE_PRIVILEGE(); 1058 portMEMORY_BARRIER(); 1059 1060 ulReturn = ulTaskGenericNotifyValueClear( xTask, uxIndexToClear, ulBitsToClear ); 1061 portMEMORY_BARRIER(); 1062 1063 portRESET_PRIVILEGE(); 1064 portMEMORY_BARRIER(); 1065 } 1066 else 1067 { 1068 ulReturn = ulTaskGenericNotifyValueClear( xTask, uxIndexToClear, ulBitsToClear ); 1069 } 1070 1071 return ulReturn; 1072 } 1073 #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */ 1074 /*-----------------------------------------------------------*/ 1075 1076 #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) MPU_xQueueGenericCreate(UBaseType_t uxQueueLength,UBaseType_t uxItemSize,uint8_t ucQueueType)1077 QueueHandle_t MPU_xQueueGenericCreate( UBaseType_t uxQueueLength, 1078 UBaseType_t uxItemSize, 1079 uint8_t ucQueueType ) /* FREERTOS_SYSTEM_CALL */ 1080 { 1081 QueueHandle_t xReturn; 1082 1083 if( portIS_PRIVILEGED() == pdFALSE ) 1084 { 1085 portRAISE_PRIVILEGE(); 1086 portMEMORY_BARRIER(); 1087 1088 xReturn = xQueueGenericCreate( uxQueueLength, uxItemSize, ucQueueType ); 1089 portMEMORY_BARRIER(); 1090 1091 portRESET_PRIVILEGE(); 1092 portMEMORY_BARRIER(); 1093 } 1094 else 1095 { 1096 xReturn = xQueueGenericCreate( uxQueueLength, uxItemSize, ucQueueType ); 1097 } 1098 1099 return xReturn; 1100 } 1101 #endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) */ 1102 /*-----------------------------------------------------------*/ 1103 1104 #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) MPU_xQueueGenericCreateStatic(const UBaseType_t uxQueueLength,const UBaseType_t uxItemSize,uint8_t * pucQueueStorage,StaticQueue_t * pxStaticQueue,const uint8_t ucQueueType)1105 QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, 1106 const UBaseType_t uxItemSize, 1107 uint8_t * pucQueueStorage, 1108 StaticQueue_t * pxStaticQueue, 1109 const uint8_t ucQueueType ) /* FREERTOS_SYSTEM_CALL */ 1110 { 1111 QueueHandle_t xReturn; 1112 1113 if( portIS_PRIVILEGED() == pdFALSE ) 1114 { 1115 portRAISE_PRIVILEGE(); 1116 portMEMORY_BARRIER(); 1117 1118 xReturn = xQueueGenericCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxStaticQueue, ucQueueType ); 1119 portMEMORY_BARRIER(); 1120 1121 portRESET_PRIVILEGE(); 1122 portMEMORY_BARRIER(); 1123 } 1124 else 1125 { 1126 xReturn = xQueueGenericCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxStaticQueue, ucQueueType ); 1127 } 1128 1129 return xReturn; 1130 } 1131 #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */ 1132 /*-----------------------------------------------------------*/ 1133 MPU_xQueueGenericReset(QueueHandle_t pxQueue,BaseType_t xNewQueue)1134 BaseType_t MPU_xQueueGenericReset( QueueHandle_t pxQueue, 1135 BaseType_t xNewQueue ) /* FREERTOS_SYSTEM_CALL */ 1136 { 1137 BaseType_t xReturn; 1138 1139 if( portIS_PRIVILEGED() == pdFALSE ) 1140 { 1141 portRAISE_PRIVILEGE(); 1142 portMEMORY_BARRIER(); 1143 1144 xReturn = xQueueGenericReset( pxQueue, xNewQueue ); 1145 portMEMORY_BARRIER(); 1146 1147 portRESET_PRIVILEGE(); 1148 portMEMORY_BARRIER(); 1149 } 1150 else 1151 { 1152 xReturn = xQueueGenericReset( pxQueue, xNewQueue ); 1153 } 1154 1155 return xReturn; 1156 } 1157 /*-----------------------------------------------------------*/ 1158 MPU_xQueueGenericSend(QueueHandle_t xQueue,const void * const pvItemToQueue,TickType_t xTicksToWait,BaseType_t xCopyPosition)1159 BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue, 1160 const void * const pvItemToQueue, 1161 TickType_t xTicksToWait, 1162 BaseType_t xCopyPosition ) /* FREERTOS_SYSTEM_CALL */ 1163 { 1164 BaseType_t xReturn; 1165 1166 if( portIS_PRIVILEGED() == pdFALSE ) 1167 { 1168 portRAISE_PRIVILEGE(); 1169 portMEMORY_BARRIER(); 1170 1171 xReturn = xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, xCopyPosition ); 1172 portMEMORY_BARRIER(); 1173 1174 portRESET_PRIVILEGE(); 1175 portMEMORY_BARRIER(); 1176 } 1177 else 1178 { 1179 xReturn = xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, xCopyPosition ); 1180 } 1181 1182 return xReturn; 1183 } 1184 /*-----------------------------------------------------------*/ 1185 MPU_uxQueueMessagesWaiting(const QueueHandle_t pxQueue)1186 UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t pxQueue ) /* FREERTOS_SYSTEM_CALL */ 1187 { 1188 UBaseType_t uxReturn; 1189 1190 if( portIS_PRIVILEGED() == pdFALSE ) 1191 { 1192 portRAISE_PRIVILEGE(); 1193 portMEMORY_BARRIER(); 1194 1195 uxReturn = uxQueueMessagesWaiting( pxQueue ); 1196 portMEMORY_BARRIER(); 1197 1198 portRESET_PRIVILEGE(); 1199 portMEMORY_BARRIER(); 1200 } 1201 else 1202 { 1203 uxReturn = uxQueueMessagesWaiting( pxQueue ); 1204 } 1205 1206 return uxReturn; 1207 } 1208 /*-----------------------------------------------------------*/ 1209 MPU_uxQueueSpacesAvailable(const QueueHandle_t xQueue)1210 UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */ 1211 { 1212 UBaseType_t uxReturn; 1213 1214 if( portIS_PRIVILEGED() == pdFALSE ) 1215 { 1216 portRAISE_PRIVILEGE(); 1217 portMEMORY_BARRIER(); 1218 1219 uxReturn = uxQueueSpacesAvailable( xQueue ); 1220 portMEMORY_BARRIER(); 1221 1222 portRESET_PRIVILEGE(); 1223 portMEMORY_BARRIER(); 1224 } 1225 else 1226 { 1227 uxReturn = uxQueueSpacesAvailable( xQueue ); 1228 } 1229 1230 return uxReturn; 1231 } 1232 /*-----------------------------------------------------------*/ 1233 MPU_xQueueReceive(QueueHandle_t pxQueue,void * const pvBuffer,TickType_t xTicksToWait)1234 BaseType_t MPU_xQueueReceive( QueueHandle_t pxQueue, 1235 void * const pvBuffer, 1236 TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ 1237 { 1238 BaseType_t xReturn; 1239 1240 if( portIS_PRIVILEGED() == pdFALSE ) 1241 { 1242 portRAISE_PRIVILEGE(); 1243 portMEMORY_BARRIER(); 1244 1245 xReturn = xQueueReceive( pxQueue, pvBuffer, xTicksToWait ); 1246 portMEMORY_BARRIER(); 1247 1248 portRESET_PRIVILEGE(); 1249 portMEMORY_BARRIER(); 1250 } 1251 else 1252 { 1253 xReturn = xQueueReceive( pxQueue, pvBuffer, xTicksToWait ); 1254 } 1255 1256 return xReturn; 1257 } 1258 /*-----------------------------------------------------------*/ 1259 MPU_xQueuePeek(QueueHandle_t xQueue,void * const pvBuffer,TickType_t xTicksToWait)1260 BaseType_t MPU_xQueuePeek( QueueHandle_t xQueue, 1261 void * const pvBuffer, 1262 TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ 1263 { 1264 BaseType_t xReturn; 1265 1266 if( portIS_PRIVILEGED() == pdFALSE ) 1267 { 1268 portRAISE_PRIVILEGE(); 1269 portMEMORY_BARRIER(); 1270 1271 xReturn = xQueuePeek( xQueue, pvBuffer, xTicksToWait ); 1272 portMEMORY_BARRIER(); 1273 1274 portRESET_PRIVILEGE(); 1275 portMEMORY_BARRIER(); 1276 } 1277 else 1278 { 1279 xReturn = xQueuePeek( xQueue, pvBuffer, xTicksToWait ); 1280 } 1281 1282 return xReturn; 1283 } 1284 /*-----------------------------------------------------------*/ 1285 MPU_xQueueSemaphoreTake(QueueHandle_t xQueue,TickType_t xTicksToWait)1286 BaseType_t MPU_xQueueSemaphoreTake( QueueHandle_t xQueue, 1287 TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ 1288 { 1289 BaseType_t xReturn; 1290 1291 if( portIS_PRIVILEGED() == pdFALSE ) 1292 { 1293 portRAISE_PRIVILEGE(); 1294 portMEMORY_BARRIER(); 1295 1296 xReturn = xQueueSemaphoreTake( xQueue, xTicksToWait ); 1297 portMEMORY_BARRIER(); 1298 1299 portRESET_PRIVILEGE(); 1300 portMEMORY_BARRIER(); 1301 } 1302 else 1303 { 1304 xReturn = xQueueSemaphoreTake( xQueue, xTicksToWait ); 1305 } 1306 1307 return xReturn; 1308 } 1309 /*-----------------------------------------------------------*/ 1310 1311 #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) MPU_xQueueGetMutexHolder(QueueHandle_t xSemaphore)1312 TaskHandle_t MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ) /* FREERTOS_SYSTEM_CALL */ 1313 { 1314 void * xReturn; 1315 1316 if( portIS_PRIVILEGED() == pdFALSE ) 1317 { 1318 portRAISE_PRIVILEGE(); 1319 portMEMORY_BARRIER(); 1320 1321 xReturn = xQueueGetMutexHolder( xSemaphore ); 1322 portMEMORY_BARRIER(); 1323 1324 portRESET_PRIVILEGE(); 1325 portMEMORY_BARRIER(); 1326 } 1327 else 1328 { 1329 xReturn = xQueueGetMutexHolder( xSemaphore ); 1330 } 1331 1332 return xReturn; 1333 } 1334 #endif /* if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) */ 1335 /*-----------------------------------------------------------*/ 1336 1337 #if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) MPU_xQueueCreateMutex(const uint8_t ucQueueType)1338 QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) /* FREERTOS_SYSTEM_CALL */ 1339 { 1340 QueueHandle_t xReturn; 1341 1342 if( portIS_PRIVILEGED() == pdFALSE ) 1343 { 1344 portRAISE_PRIVILEGE(); 1345 portMEMORY_BARRIER(); 1346 1347 xReturn = xQueueCreateMutex( ucQueueType ); 1348 portMEMORY_BARRIER(); 1349 1350 portRESET_PRIVILEGE(); 1351 portMEMORY_BARRIER(); 1352 } 1353 else 1354 { 1355 xReturn = xQueueCreateMutex( ucQueueType ); 1356 } 1357 1358 return xReturn; 1359 } 1360 #endif /* if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */ 1361 /*-----------------------------------------------------------*/ 1362 1363 #if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) MPU_xQueueCreateMutexStatic(const uint8_t ucQueueType,StaticQueue_t * pxStaticQueue)1364 QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType, 1365 StaticQueue_t * pxStaticQueue ) /* FREERTOS_SYSTEM_CALL */ 1366 { 1367 QueueHandle_t xReturn; 1368 1369 if( portIS_PRIVILEGED() == pdFALSE ) 1370 { 1371 portRAISE_PRIVILEGE(); 1372 portMEMORY_BARRIER(); 1373 1374 xReturn = xQueueCreateMutexStatic( ucQueueType, pxStaticQueue ); 1375 portMEMORY_BARRIER(); 1376 1377 portRESET_PRIVILEGE(); 1378 portMEMORY_BARRIER(); 1379 } 1380 else 1381 { 1382 xReturn = xQueueCreateMutexStatic( ucQueueType, pxStaticQueue ); 1383 } 1384 1385 return xReturn; 1386 } 1387 #endif /* if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) */ 1388 /*-----------------------------------------------------------*/ 1389 1390 #if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) MPU_xQueueCreateCountingSemaphore(UBaseType_t uxCountValue,UBaseType_t uxInitialCount)1391 QueueHandle_t MPU_xQueueCreateCountingSemaphore( UBaseType_t uxCountValue, 1392 UBaseType_t uxInitialCount ) /* FREERTOS_SYSTEM_CALL */ 1393 { 1394 QueueHandle_t xReturn; 1395 1396 if( portIS_PRIVILEGED() == pdFALSE ) 1397 { 1398 portRAISE_PRIVILEGE(); 1399 portMEMORY_BARRIER(); 1400 1401 xReturn = xQueueCreateCountingSemaphore( uxCountValue, uxInitialCount ); 1402 portMEMORY_BARRIER(); 1403 1404 portRESET_PRIVILEGE(); 1405 portMEMORY_BARRIER(); 1406 } 1407 else 1408 { 1409 xReturn = xQueueCreateCountingSemaphore( uxCountValue, uxInitialCount ); 1410 } 1411 1412 return xReturn; 1413 } 1414 #endif /* if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */ 1415 /*-----------------------------------------------------------*/ 1416 1417 #if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) 1418 MPU_xQueueCreateCountingSemaphoreStatic(const UBaseType_t uxMaxCount,const UBaseType_t uxInitialCount,StaticQueue_t * pxStaticQueue)1419 QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, 1420 const UBaseType_t uxInitialCount, 1421 StaticQueue_t * pxStaticQueue ) /* FREERTOS_SYSTEM_CALL */ 1422 { 1423 QueueHandle_t xReturn; 1424 1425 if( portIS_PRIVILEGED() == pdFALSE ) 1426 { 1427 portRAISE_PRIVILEGE(); 1428 portMEMORY_BARRIER(); 1429 1430 xReturn = xQueueCreateCountingSemaphoreStatic( uxMaxCount, uxInitialCount, pxStaticQueue ); 1431 portMEMORY_BARRIER(); 1432 1433 portRESET_PRIVILEGE(); 1434 portMEMORY_BARRIER(); 1435 } 1436 else 1437 { 1438 xReturn = xQueueCreateCountingSemaphoreStatic( uxMaxCount, uxInitialCount, pxStaticQueue ); 1439 } 1440 1441 return xReturn; 1442 } 1443 #endif /* if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) */ 1444 /*-----------------------------------------------------------*/ 1445 1446 #if ( configUSE_RECURSIVE_MUTEXES == 1 ) MPU_xQueueTakeMutexRecursive(QueueHandle_t xMutex,TickType_t xBlockTime)1447 BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex, 1448 TickType_t xBlockTime ) /* FREERTOS_SYSTEM_CALL */ 1449 { 1450 BaseType_t xReturn; 1451 1452 if( portIS_PRIVILEGED() == pdFALSE ) 1453 { 1454 portRAISE_PRIVILEGE(); 1455 portMEMORY_BARRIER(); 1456 1457 xReturn = xQueueTakeMutexRecursive( xMutex, xBlockTime ); 1458 portMEMORY_BARRIER(); 1459 1460 portRESET_PRIVILEGE(); 1461 portMEMORY_BARRIER(); 1462 } 1463 else 1464 { 1465 xReturn = xQueueTakeMutexRecursive( xMutex, xBlockTime ); 1466 } 1467 1468 return xReturn; 1469 } 1470 #endif /* if ( configUSE_RECURSIVE_MUTEXES == 1 ) */ 1471 /*-----------------------------------------------------------*/ 1472 1473 #if ( configUSE_RECURSIVE_MUTEXES == 1 ) MPU_xQueueGiveMutexRecursive(QueueHandle_t xMutex)1474 BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t xMutex ) /* FREERTOS_SYSTEM_CALL */ 1475 { 1476 BaseType_t xReturn; 1477 1478 if( portIS_PRIVILEGED() == pdFALSE ) 1479 { 1480 portRAISE_PRIVILEGE(); 1481 portMEMORY_BARRIER(); 1482 1483 xReturn = xQueueGiveMutexRecursive( xMutex ); 1484 portMEMORY_BARRIER(); 1485 1486 portRESET_PRIVILEGE(); 1487 portMEMORY_BARRIER(); 1488 } 1489 else 1490 { 1491 xReturn = xQueueGiveMutexRecursive( xMutex ); 1492 } 1493 1494 return xReturn; 1495 } 1496 #endif /* if ( configUSE_RECURSIVE_MUTEXES == 1 ) */ 1497 /*-----------------------------------------------------------*/ 1498 1499 #if ( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) MPU_xQueueCreateSet(UBaseType_t uxEventQueueLength)1500 QueueSetHandle_t MPU_xQueueCreateSet( UBaseType_t uxEventQueueLength ) /* FREERTOS_SYSTEM_CALL */ 1501 { 1502 QueueSetHandle_t xReturn; 1503 1504 if( portIS_PRIVILEGED() == pdFALSE ) 1505 { 1506 portRAISE_PRIVILEGE(); 1507 portMEMORY_BARRIER(); 1508 1509 xReturn = xQueueCreateSet( uxEventQueueLength ); 1510 portMEMORY_BARRIER(); 1511 1512 portRESET_PRIVILEGE(); 1513 portMEMORY_BARRIER(); 1514 } 1515 else 1516 { 1517 xReturn = xQueueCreateSet( uxEventQueueLength ); 1518 } 1519 1520 return xReturn; 1521 } 1522 #endif /* if ( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */ 1523 /*-----------------------------------------------------------*/ 1524 1525 #if ( configUSE_QUEUE_SETS == 1 ) MPU_xQueueSelectFromSet(QueueSetHandle_t xQueueSet,TickType_t xBlockTimeTicks)1526 QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet, 1527 TickType_t xBlockTimeTicks ) /* FREERTOS_SYSTEM_CALL */ 1528 { 1529 QueueSetMemberHandle_t xReturn; 1530 1531 if( portIS_PRIVILEGED() == pdFALSE ) 1532 { 1533 portRAISE_PRIVILEGE(); 1534 portMEMORY_BARRIER(); 1535 1536 xReturn = xQueueSelectFromSet( xQueueSet, xBlockTimeTicks ); 1537 portMEMORY_BARRIER(); 1538 1539 portRESET_PRIVILEGE(); 1540 portMEMORY_BARRIER(); 1541 } 1542 else 1543 { 1544 xReturn = xQueueSelectFromSet( xQueueSet, xBlockTimeTicks ); 1545 } 1546 1547 return xReturn; 1548 } 1549 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */ 1550 /*-----------------------------------------------------------*/ 1551 1552 #if ( configUSE_QUEUE_SETS == 1 ) MPU_xQueueAddToSet(QueueSetMemberHandle_t xQueueOrSemaphore,QueueSetHandle_t xQueueSet)1553 BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, 1554 QueueSetHandle_t xQueueSet ) /* FREERTOS_SYSTEM_CALL */ 1555 { 1556 BaseType_t xReturn; 1557 1558 if( portIS_PRIVILEGED() == pdFALSE ) 1559 { 1560 portRAISE_PRIVILEGE(); 1561 portMEMORY_BARRIER(); 1562 1563 xReturn = xQueueAddToSet( xQueueOrSemaphore, xQueueSet ); 1564 portMEMORY_BARRIER(); 1565 1566 portRESET_PRIVILEGE(); 1567 portMEMORY_BARRIER(); 1568 } 1569 else 1570 { 1571 xReturn = xQueueAddToSet( xQueueOrSemaphore, xQueueSet ); 1572 } 1573 1574 return xReturn; 1575 } 1576 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */ 1577 /*-----------------------------------------------------------*/ 1578 1579 #if ( configUSE_QUEUE_SETS == 1 ) MPU_xQueueRemoveFromSet(QueueSetMemberHandle_t xQueueOrSemaphore,QueueSetHandle_t xQueueSet)1580 BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, 1581 QueueSetHandle_t xQueueSet ) /* FREERTOS_SYSTEM_CALL */ 1582 { 1583 BaseType_t xReturn; 1584 1585 if( portIS_PRIVILEGED() == pdFALSE ) 1586 { 1587 portRAISE_PRIVILEGE(); 1588 portMEMORY_BARRIER(); 1589 1590 xReturn = xQueueRemoveFromSet( xQueueOrSemaphore, xQueueSet ); 1591 portMEMORY_BARRIER(); 1592 1593 portRESET_PRIVILEGE(); 1594 portMEMORY_BARRIER(); 1595 } 1596 else 1597 { 1598 xReturn = xQueueRemoveFromSet( xQueueOrSemaphore, xQueueSet ); 1599 } 1600 1601 return xReturn; 1602 } 1603 #endif /* if ( configUSE_QUEUE_SETS == 1 ) */ 1604 /*-----------------------------------------------------------*/ 1605 1606 #if configQUEUE_REGISTRY_SIZE > 0 MPU_vQueueAddToRegistry(QueueHandle_t xQueue,const char * pcName)1607 void MPU_vQueueAddToRegistry( QueueHandle_t xQueue, 1608 const char * pcName ) /* FREERTOS_SYSTEM_CALL */ 1609 { 1610 if( portIS_PRIVILEGED() == pdFALSE ) 1611 { 1612 portRAISE_PRIVILEGE(); 1613 portMEMORY_BARRIER(); 1614 1615 vQueueAddToRegistry( xQueue, pcName ); 1616 portMEMORY_BARRIER(); 1617 1618 portRESET_PRIVILEGE(); 1619 portMEMORY_BARRIER(); 1620 } 1621 else 1622 { 1623 vQueueAddToRegistry( xQueue, pcName ); 1624 } 1625 } 1626 #endif /* if configQUEUE_REGISTRY_SIZE > 0 */ 1627 /*-----------------------------------------------------------*/ 1628 1629 #if configQUEUE_REGISTRY_SIZE > 0 MPU_vQueueUnregisterQueue(QueueHandle_t xQueue)1630 void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */ 1631 { 1632 if( portIS_PRIVILEGED() == pdFALSE ) 1633 { 1634 portRAISE_PRIVILEGE(); 1635 portMEMORY_BARRIER(); 1636 1637 vQueueUnregisterQueue( xQueue ); 1638 portMEMORY_BARRIER(); 1639 1640 portRESET_PRIVILEGE(); 1641 portMEMORY_BARRIER(); 1642 } 1643 else 1644 { 1645 vQueueUnregisterQueue( xQueue ); 1646 } 1647 } 1648 #endif /* if configQUEUE_REGISTRY_SIZE > 0 */ 1649 /*-----------------------------------------------------------*/ 1650 1651 #if configQUEUE_REGISTRY_SIZE > 0 MPU_pcQueueGetName(QueueHandle_t xQueue)1652 const char * MPU_pcQueueGetName( QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */ 1653 { 1654 const char * pcReturn; 1655 1656 if( portIS_PRIVILEGED() == pdFALSE ) 1657 { 1658 portRAISE_PRIVILEGE(); 1659 portMEMORY_BARRIER(); 1660 1661 pcReturn = pcQueueGetName( xQueue ); 1662 portMEMORY_BARRIER(); 1663 1664 portRESET_PRIVILEGE(); 1665 portMEMORY_BARRIER(); 1666 } 1667 else 1668 { 1669 pcReturn = pcQueueGetName( xQueue ); 1670 } 1671 1672 return pcReturn; 1673 } 1674 #endif /* if configQUEUE_REGISTRY_SIZE > 0 */ 1675 /*-----------------------------------------------------------*/ 1676 MPU_vQueueDelete(QueueHandle_t xQueue)1677 void MPU_vQueueDelete( QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */ 1678 { 1679 if( portIS_PRIVILEGED() == pdFALSE ) 1680 { 1681 portRAISE_PRIVILEGE(); 1682 portMEMORY_BARRIER(); 1683 1684 vQueueDelete( xQueue ); 1685 portMEMORY_BARRIER(); 1686 1687 portRESET_PRIVILEGE(); 1688 portMEMORY_BARRIER(); 1689 } 1690 else 1691 { 1692 vQueueDelete( xQueue ); 1693 } 1694 } 1695 /*-----------------------------------------------------------*/ 1696 1697 #if ( configUSE_TIMERS == 1 ) MPU_pvTimerGetTimerID(const TimerHandle_t xTimer)1698 void * MPU_pvTimerGetTimerID( const TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */ 1699 { 1700 void * pvReturn; 1701 1702 if( portIS_PRIVILEGED() == pdFALSE ) 1703 { 1704 portRAISE_PRIVILEGE(); 1705 portMEMORY_BARRIER(); 1706 1707 pvReturn = pvTimerGetTimerID( xTimer ); 1708 portMEMORY_BARRIER(); 1709 1710 portRESET_PRIVILEGE(); 1711 portMEMORY_BARRIER(); 1712 } 1713 else 1714 { 1715 pvReturn = pvTimerGetTimerID( xTimer ); 1716 } 1717 1718 return pvReturn; 1719 } 1720 #endif /* if ( configUSE_TIMERS == 1 ) */ 1721 /*-----------------------------------------------------------*/ 1722 1723 #if ( configUSE_TIMERS == 1 ) MPU_vTimerSetTimerID(TimerHandle_t xTimer,void * pvNewID)1724 void MPU_vTimerSetTimerID( TimerHandle_t xTimer, 1725 void * pvNewID ) /* FREERTOS_SYSTEM_CALL */ 1726 { 1727 if( portIS_PRIVILEGED() == pdFALSE ) 1728 { 1729 portRAISE_PRIVILEGE(); 1730 portMEMORY_BARRIER(); 1731 1732 vTimerSetTimerID( xTimer, pvNewID ); 1733 portMEMORY_BARRIER(); 1734 1735 portRESET_PRIVILEGE(); 1736 portMEMORY_BARRIER(); 1737 } 1738 else 1739 { 1740 vTimerSetTimerID( xTimer, pvNewID ); 1741 } 1742 } 1743 #endif /* if ( configUSE_TIMERS == 1 ) */ 1744 /*-----------------------------------------------------------*/ 1745 1746 #if ( configUSE_TIMERS == 1 ) MPU_xTimerIsTimerActive(TimerHandle_t xTimer)1747 BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */ 1748 { 1749 BaseType_t xReturn; 1750 1751 if( portIS_PRIVILEGED() == pdFALSE ) 1752 { 1753 portRAISE_PRIVILEGE(); 1754 portMEMORY_BARRIER(); 1755 1756 xReturn = xTimerIsTimerActive( xTimer ); 1757 portMEMORY_BARRIER(); 1758 1759 portRESET_PRIVILEGE(); 1760 portMEMORY_BARRIER(); 1761 } 1762 else 1763 { 1764 xReturn = xTimerIsTimerActive( xTimer ); 1765 } 1766 1767 return xReturn; 1768 } 1769 #endif /* if ( configUSE_TIMERS == 1 ) */ 1770 /*-----------------------------------------------------------*/ 1771 1772 #if ( configUSE_TIMERS == 1 ) MPU_xTimerGetTimerDaemonTaskHandle(void)1773 TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void ) /* FREERTOS_SYSTEM_CALL */ 1774 { 1775 TaskHandle_t xReturn; 1776 1777 if( portIS_PRIVILEGED() == pdFALSE ) 1778 { 1779 portRAISE_PRIVILEGE(); 1780 portMEMORY_BARRIER(); 1781 1782 xReturn = xTimerGetTimerDaemonTaskHandle(); 1783 portMEMORY_BARRIER(); 1784 1785 portRESET_PRIVILEGE(); 1786 portMEMORY_BARRIER(); 1787 } 1788 else 1789 { 1790 xReturn = xTimerGetTimerDaemonTaskHandle(); 1791 } 1792 1793 return xReturn; 1794 } 1795 #endif /* if ( configUSE_TIMERS == 1 ) */ 1796 /*-----------------------------------------------------------*/ 1797 1798 #if ( configUSE_TIMERS == 1 ) MPU_vTimerSetReloadMode(TimerHandle_t xTimer,const BaseType_t uxAutoReload)1799 void MPU_vTimerSetReloadMode( TimerHandle_t xTimer, 1800 const BaseType_t uxAutoReload ) /* FREERTOS_SYSTEM_CALL */ 1801 { 1802 if( portIS_PRIVILEGED() == pdFALSE ) 1803 { 1804 portRAISE_PRIVILEGE(); 1805 portMEMORY_BARRIER(); 1806 1807 vTimerSetReloadMode( xTimer, uxAutoReload ); 1808 portMEMORY_BARRIER(); 1809 1810 portRESET_PRIVILEGE(); 1811 portMEMORY_BARRIER(); 1812 } 1813 else 1814 { 1815 vTimerSetReloadMode( xTimer, uxAutoReload ); 1816 } 1817 } 1818 #endif /* if ( configUSE_TIMERS == 1 ) */ 1819 /*-----------------------------------------------------------*/ 1820 1821 #if ( configUSE_TIMERS == 1 ) MPU_uxTimerGetReloadMode(TimerHandle_t xTimer)1822 UBaseType_t MPU_uxTimerGetReloadMode( TimerHandle_t xTimer ) 1823 { 1824 UBaseType_t uxReturn; 1825 1826 if( portIS_PRIVILEGED() == pdFALSE ) 1827 { 1828 portRAISE_PRIVILEGE(); 1829 portMEMORY_BARRIER(); 1830 1831 uxReturn = uxTimerGetReloadMode( xTimer ); 1832 portMEMORY_BARRIER(); 1833 1834 portRESET_PRIVILEGE(); 1835 portMEMORY_BARRIER(); 1836 } 1837 else 1838 { 1839 uxReturn = uxTimerGetReloadMode( xTimer ); 1840 } 1841 1842 return uxReturn; 1843 } 1844 #endif /* if ( configUSE_TIMERS == 1 ) */ 1845 /*-----------------------------------------------------------*/ 1846 1847 #if ( configUSE_TIMERS == 1 ) MPU_pcTimerGetName(TimerHandle_t xTimer)1848 const char * MPU_pcTimerGetName( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */ 1849 { 1850 const char * pcReturn; 1851 1852 if( portIS_PRIVILEGED() == pdFALSE ) 1853 { 1854 portRAISE_PRIVILEGE(); 1855 portMEMORY_BARRIER(); 1856 1857 pcReturn = pcTimerGetName( xTimer ); 1858 portMEMORY_BARRIER(); 1859 1860 portRESET_PRIVILEGE(); 1861 portMEMORY_BARRIER(); 1862 } 1863 else 1864 { 1865 pcReturn = pcTimerGetName( xTimer ); 1866 } 1867 1868 return pcReturn; 1869 } 1870 #endif /* if ( configUSE_TIMERS == 1 ) */ 1871 /*-----------------------------------------------------------*/ 1872 1873 #if ( configUSE_TIMERS == 1 ) MPU_xTimerGetPeriod(TimerHandle_t xTimer)1874 TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */ 1875 { 1876 TickType_t xReturn; 1877 1878 if( portIS_PRIVILEGED() == pdFALSE ) 1879 { 1880 portRAISE_PRIVILEGE(); 1881 portMEMORY_BARRIER(); 1882 1883 xReturn = xTimerGetPeriod( xTimer ); 1884 portMEMORY_BARRIER(); 1885 1886 portRESET_PRIVILEGE(); 1887 portMEMORY_BARRIER(); 1888 } 1889 else 1890 { 1891 xReturn = xTimerGetPeriod( xTimer ); 1892 } 1893 1894 return xReturn; 1895 } 1896 #endif /* if ( configUSE_TIMERS == 1 ) */ 1897 /*-----------------------------------------------------------*/ 1898 1899 #if ( configUSE_TIMERS == 1 ) MPU_xTimerGetExpiryTime(TimerHandle_t xTimer)1900 TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */ 1901 { 1902 TickType_t xReturn; 1903 1904 if( portIS_PRIVILEGED() == pdFALSE ) 1905 { 1906 portRAISE_PRIVILEGE(); 1907 portMEMORY_BARRIER(); 1908 1909 xReturn = xTimerGetExpiryTime( xTimer ); 1910 portMEMORY_BARRIER(); 1911 1912 portRESET_PRIVILEGE(); 1913 portMEMORY_BARRIER(); 1914 } 1915 else 1916 { 1917 xReturn = xTimerGetExpiryTime( xTimer ); 1918 } 1919 1920 return xReturn; 1921 } 1922 #endif /* if ( configUSE_TIMERS == 1 ) */ 1923 /*-----------------------------------------------------------*/ 1924 1925 #if ( configUSE_TIMERS == 1 ) MPU_xTimerGenericCommandFromTask(TimerHandle_t xTimer,const BaseType_t xCommandID,const TickType_t xOptionalValue,BaseType_t * const pxHigherPriorityTaskWoken,const TickType_t xTicksToWait)1926 BaseType_t MPU_xTimerGenericCommandFromTask( TimerHandle_t xTimer, 1927 const BaseType_t xCommandID, 1928 const TickType_t xOptionalValue, 1929 BaseType_t * const pxHigherPriorityTaskWoken, 1930 const TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ 1931 { 1932 BaseType_t xReturn; 1933 1934 if( portIS_PRIVILEGED() == pdFALSE ) 1935 { 1936 portRAISE_PRIVILEGE(); 1937 portMEMORY_BARRIER(); 1938 1939 xReturn = xTimerGenericCommandFromTask( xTimer, xCommandID, xOptionalValue, pxHigherPriorityTaskWoken, xTicksToWait ); 1940 portMEMORY_BARRIER(); 1941 1942 portRESET_PRIVILEGE(); 1943 portMEMORY_BARRIER(); 1944 } 1945 else 1946 { 1947 xReturn = xTimerGenericCommandFromTask( xTimer, xCommandID, xOptionalValue, pxHigherPriorityTaskWoken, xTicksToWait ); 1948 } 1949 1950 return xReturn; 1951 } 1952 #endif /* if ( configUSE_TIMERS == 1 ) */ 1953 /*-----------------------------------------------------------*/ 1954 1955 #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_EVENT_GROUPS == 1 ) ) MPU_xEventGroupCreate(void)1956 EventGroupHandle_t MPU_xEventGroupCreate( void ) /* FREERTOS_SYSTEM_CALL */ 1957 { 1958 EventGroupHandle_t xReturn; 1959 1960 if( portIS_PRIVILEGED() == pdFALSE ) 1961 { 1962 portRAISE_PRIVILEGE(); 1963 portMEMORY_BARRIER(); 1964 1965 xReturn = xEventGroupCreate(); 1966 portMEMORY_BARRIER(); 1967 1968 portRESET_PRIVILEGE(); 1969 portMEMORY_BARRIER(); 1970 } 1971 else 1972 { 1973 xReturn = xEventGroupCreate(); 1974 } 1975 1976 return xReturn; 1977 } 1978 #endif /* #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_EVENT_GROUPS == 1 ) ) */ 1979 /*-----------------------------------------------------------*/ 1980 1981 #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_EVENT_GROUPS == 1 ) ) MPU_xEventGroupCreateStatic(StaticEventGroup_t * pxEventGroupBuffer)1982 EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) /* FREERTOS_SYSTEM_CALL */ 1983 { 1984 EventGroupHandle_t xReturn; 1985 1986 if( portIS_PRIVILEGED() == pdFALSE ) 1987 { 1988 portRAISE_PRIVILEGE(); 1989 portMEMORY_BARRIER(); 1990 1991 xReturn = xEventGroupCreateStatic( pxEventGroupBuffer ); 1992 portMEMORY_BARRIER(); 1993 1994 portRESET_PRIVILEGE(); 1995 portMEMORY_BARRIER(); 1996 } 1997 else 1998 { 1999 xReturn = xEventGroupCreateStatic( pxEventGroupBuffer ); 2000 } 2001 2002 return xReturn; 2003 } 2004 #endif /* #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_EVENT_GROUPS == 1 ) ) */ 2005 /*-----------------------------------------------------------*/ 2006 2007 #if ( configUSE_EVENT_GROUPS == 1 ) MPU_xEventGroupWaitBits(EventGroupHandle_t xEventGroup,const EventBits_t uxBitsToWaitFor,const BaseType_t xClearOnExit,const BaseType_t xWaitForAllBits,TickType_t xTicksToWait)2008 EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup, 2009 const EventBits_t uxBitsToWaitFor, 2010 const BaseType_t xClearOnExit, 2011 const BaseType_t xWaitForAllBits, 2012 TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ 2013 { 2014 EventBits_t xReturn; 2015 2016 if( portIS_PRIVILEGED() == pdFALSE ) 2017 { 2018 portRAISE_PRIVILEGE(); 2019 portMEMORY_BARRIER(); 2020 2021 xReturn = xEventGroupWaitBits( xEventGroup, uxBitsToWaitFor, xClearOnExit, xWaitForAllBits, xTicksToWait ); 2022 portMEMORY_BARRIER(); 2023 2024 portRESET_PRIVILEGE(); 2025 portMEMORY_BARRIER(); 2026 } 2027 else 2028 { 2029 xReturn = xEventGroupWaitBits( xEventGroup, uxBitsToWaitFor, xClearOnExit, xWaitForAllBits, xTicksToWait ); 2030 } 2031 2032 return xReturn; 2033 } 2034 #endif /* #if ( configUSE_EVENT_GROUPS == 1 ) */ 2035 /*-----------------------------------------------------------*/ 2036 2037 #if ( configUSE_EVENT_GROUPS == 1 ) MPU_xEventGroupClearBits(EventGroupHandle_t xEventGroup,const EventBits_t uxBitsToClear)2038 EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup, 2039 const EventBits_t uxBitsToClear ) /* FREERTOS_SYSTEM_CALL */ 2040 { 2041 EventBits_t xReturn; 2042 2043 if( portIS_PRIVILEGED() == pdFALSE ) 2044 { 2045 portRAISE_PRIVILEGE(); 2046 portMEMORY_BARRIER(); 2047 2048 xReturn = xEventGroupClearBits( xEventGroup, uxBitsToClear ); 2049 portMEMORY_BARRIER(); 2050 2051 portRESET_PRIVILEGE(); 2052 portMEMORY_BARRIER(); 2053 } 2054 else 2055 { 2056 xReturn = xEventGroupClearBits( xEventGroup, uxBitsToClear ); 2057 } 2058 2059 return xReturn; 2060 } 2061 #endif /* #if ( configUSE_EVENT_GROUPS == 1 ) */ 2062 /*-----------------------------------------------------------*/ 2063 2064 #if ( configUSE_EVENT_GROUPS == 1 ) MPU_xEventGroupSetBits(EventGroupHandle_t xEventGroup,const EventBits_t uxBitsToSet)2065 EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup, 2066 const EventBits_t uxBitsToSet ) /* FREERTOS_SYSTEM_CALL */ 2067 { 2068 EventBits_t xReturn; 2069 2070 if( portIS_PRIVILEGED() == pdFALSE ) 2071 { 2072 portRAISE_PRIVILEGE(); 2073 portMEMORY_BARRIER(); 2074 2075 xReturn = xEventGroupSetBits( xEventGroup, uxBitsToSet ); 2076 portMEMORY_BARRIER(); 2077 2078 portRESET_PRIVILEGE(); 2079 portMEMORY_BARRIER(); 2080 } 2081 else 2082 { 2083 xReturn = xEventGroupSetBits( xEventGroup, uxBitsToSet ); 2084 } 2085 2086 return xReturn; 2087 } 2088 #endif /* #if ( configUSE_EVENT_GROUPS == 1 ) */ 2089 /*-----------------------------------------------------------*/ 2090 2091 #if ( configUSE_EVENT_GROUPS == 1 ) MPU_xEventGroupSync(EventGroupHandle_t xEventGroup,const EventBits_t uxBitsToSet,const EventBits_t uxBitsToWaitFor,TickType_t xTicksToWait)2092 EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup, 2093 const EventBits_t uxBitsToSet, 2094 const EventBits_t uxBitsToWaitFor, 2095 TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ 2096 { 2097 EventBits_t xReturn; 2098 2099 if( portIS_PRIVILEGED() == pdFALSE ) 2100 { 2101 portRAISE_PRIVILEGE(); 2102 portMEMORY_BARRIER(); 2103 2104 xReturn = xEventGroupSync( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTicksToWait ); 2105 portMEMORY_BARRIER(); 2106 2107 portRESET_PRIVILEGE(); 2108 portMEMORY_BARRIER(); 2109 } 2110 else 2111 { 2112 xReturn = xEventGroupSync( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTicksToWait ); 2113 } 2114 2115 return xReturn; 2116 } 2117 #endif /* #if ( configUSE_EVENT_GROUPS == 1 ) */ 2118 /*-----------------------------------------------------------*/ 2119 2120 #if ( configUSE_EVENT_GROUPS == 1 ) MPU_vEventGroupDelete(EventGroupHandle_t xEventGroup)2121 void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) /* FREERTOS_SYSTEM_CALL */ 2122 { 2123 if( portIS_PRIVILEGED() == pdFALSE ) 2124 { 2125 portRAISE_PRIVILEGE(); 2126 portMEMORY_BARRIER(); 2127 2128 vEventGroupDelete( xEventGroup ); 2129 portMEMORY_BARRIER(); 2130 2131 portRESET_PRIVILEGE(); 2132 portMEMORY_BARRIER(); 2133 } 2134 else 2135 { 2136 vEventGroupDelete( xEventGroup ); 2137 } 2138 } 2139 #endif /* #if ( configUSE_EVENT_GROUPS == 1 ) */ 2140 /*-----------------------------------------------------------*/ 2141 2142 #if ( configUSE_STREAM_BUFFERS == 1 ) MPU_xStreamBufferSend(StreamBufferHandle_t xStreamBuffer,const void * pvTxData,size_t xDataLengthBytes,TickType_t xTicksToWait)2143 size_t MPU_xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, 2144 const void * pvTxData, 2145 size_t xDataLengthBytes, 2146 TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ 2147 { 2148 size_t xReturn; 2149 2150 if( portIS_PRIVILEGED() == pdFALSE ) 2151 { 2152 portRAISE_PRIVILEGE(); 2153 portMEMORY_BARRIER(); 2154 2155 xReturn = xStreamBufferSend( xStreamBuffer, pvTxData, xDataLengthBytes, xTicksToWait ); 2156 portMEMORY_BARRIER(); 2157 2158 portRESET_PRIVILEGE(); 2159 portMEMORY_BARRIER(); 2160 } 2161 else 2162 { 2163 xReturn = xStreamBufferSend( xStreamBuffer, pvTxData, xDataLengthBytes, xTicksToWait ); 2164 } 2165 2166 return xReturn; 2167 } 2168 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */ 2169 /*-----------------------------------------------------------*/ 2170 2171 #if ( configUSE_STREAM_BUFFERS == 1 ) MPU_xStreamBufferNextMessageLengthBytes(StreamBufferHandle_t xStreamBuffer)2172 size_t MPU_xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */ 2173 { 2174 size_t xReturn; 2175 2176 if( portIS_PRIVILEGED() == pdFALSE ) 2177 { 2178 portRAISE_PRIVILEGE(); 2179 portMEMORY_BARRIER(); 2180 2181 xReturn = xStreamBufferNextMessageLengthBytes( xStreamBuffer ); 2182 portMEMORY_BARRIER(); 2183 2184 portRESET_PRIVILEGE(); 2185 portMEMORY_BARRIER(); 2186 } 2187 else 2188 { 2189 xReturn = xStreamBufferNextMessageLengthBytes( xStreamBuffer ); 2190 } 2191 2192 return xReturn; 2193 } 2194 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */ 2195 /*-----------------------------------------------------------*/ 2196 2197 #if ( configUSE_STREAM_BUFFERS == 1 ) MPU_xStreamBufferReceive(StreamBufferHandle_t xStreamBuffer,void * pvRxData,size_t xBufferLengthBytes,TickType_t xTicksToWait)2198 size_t MPU_xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, 2199 void * pvRxData, 2200 size_t xBufferLengthBytes, 2201 TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */ 2202 { 2203 size_t xReturn; 2204 2205 if( portIS_PRIVILEGED() == pdFALSE ) 2206 { 2207 portRAISE_PRIVILEGE(); 2208 portMEMORY_BARRIER(); 2209 2210 xReturn = xStreamBufferReceive( xStreamBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ); 2211 portMEMORY_BARRIER(); 2212 2213 portRESET_PRIVILEGE(); 2214 portMEMORY_BARRIER(); 2215 } 2216 else 2217 { 2218 xReturn = xStreamBufferReceive( xStreamBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ); 2219 } 2220 2221 return xReturn; 2222 } 2223 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */ 2224 /*-----------------------------------------------------------*/ 2225 2226 #if ( configUSE_STREAM_BUFFERS == 1 ) MPU_vStreamBufferDelete(StreamBufferHandle_t xStreamBuffer)2227 void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */ 2228 { 2229 if( portIS_PRIVILEGED() == pdFALSE ) 2230 { 2231 portRAISE_PRIVILEGE(); 2232 portMEMORY_BARRIER(); 2233 2234 vStreamBufferDelete( xStreamBuffer ); 2235 portMEMORY_BARRIER(); 2236 2237 portRESET_PRIVILEGE(); 2238 portMEMORY_BARRIER(); 2239 } 2240 else 2241 { 2242 vStreamBufferDelete( xStreamBuffer ); 2243 } 2244 } 2245 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */ 2246 /*-----------------------------------------------------------*/ 2247 2248 #if ( configUSE_STREAM_BUFFERS == 1 ) MPU_xStreamBufferIsFull(StreamBufferHandle_t xStreamBuffer)2249 BaseType_t MPU_xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */ 2250 { 2251 BaseType_t xReturn; 2252 2253 if( portIS_PRIVILEGED() == pdFALSE ) 2254 { 2255 portRAISE_PRIVILEGE(); 2256 portMEMORY_BARRIER(); 2257 2258 xReturn = xStreamBufferIsFull( xStreamBuffer ); 2259 portMEMORY_BARRIER(); 2260 2261 portRESET_PRIVILEGE(); 2262 portMEMORY_BARRIER(); 2263 } 2264 else 2265 { 2266 xReturn = xStreamBufferIsFull( xStreamBuffer ); 2267 } 2268 2269 return xReturn; 2270 } 2271 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */ 2272 /*-----------------------------------------------------------*/ 2273 2274 #if ( configUSE_STREAM_BUFFERS == 1 ) MPU_xStreamBufferIsEmpty(StreamBufferHandle_t xStreamBuffer)2275 BaseType_t MPU_xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */ 2276 { 2277 BaseType_t xReturn; 2278 2279 if( portIS_PRIVILEGED() == pdFALSE ) 2280 { 2281 portRAISE_PRIVILEGE(); 2282 portMEMORY_BARRIER(); 2283 2284 xReturn = xStreamBufferIsEmpty( xStreamBuffer ); 2285 portMEMORY_BARRIER(); 2286 2287 portRESET_PRIVILEGE(); 2288 portMEMORY_BARRIER(); 2289 } 2290 else 2291 { 2292 xReturn = xStreamBufferIsEmpty( xStreamBuffer ); 2293 } 2294 2295 return xReturn; 2296 } 2297 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */ 2298 /*-----------------------------------------------------------*/ 2299 2300 #if ( configUSE_STREAM_BUFFERS == 1 ) MPU_xStreamBufferReset(StreamBufferHandle_t xStreamBuffer)2301 BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */ 2302 { 2303 BaseType_t xReturn; 2304 2305 if( portIS_PRIVILEGED() == pdFALSE ) 2306 { 2307 portRAISE_PRIVILEGE(); 2308 portMEMORY_BARRIER(); 2309 2310 xReturn = xStreamBufferReset( xStreamBuffer ); 2311 portMEMORY_BARRIER(); 2312 2313 portRESET_PRIVILEGE(); 2314 portMEMORY_BARRIER(); 2315 } 2316 else 2317 { 2318 xReturn = xStreamBufferReset( xStreamBuffer ); 2319 } 2320 2321 return xReturn; 2322 } 2323 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */ 2324 /*-----------------------------------------------------------*/ 2325 2326 #if ( configUSE_STREAM_BUFFERS == 1 ) MPU_xStreamBufferSpacesAvailable(StreamBufferHandle_t xStreamBuffer)2327 size_t MPU_xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */ 2328 { 2329 size_t xReturn; 2330 2331 if( portIS_PRIVILEGED() == pdFALSE ) 2332 { 2333 portRAISE_PRIVILEGE(); 2334 portMEMORY_BARRIER(); 2335 xReturn = xStreamBufferSpacesAvailable( xStreamBuffer ); 2336 portMEMORY_BARRIER(); 2337 2338 portRESET_PRIVILEGE(); 2339 portMEMORY_BARRIER(); 2340 } 2341 else 2342 { 2343 xReturn = xStreamBufferSpacesAvailable( xStreamBuffer ); 2344 } 2345 2346 return xReturn; 2347 } 2348 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */ 2349 /*-----------------------------------------------------------*/ 2350 2351 #if ( configUSE_STREAM_BUFFERS == 1 ) MPU_xStreamBufferBytesAvailable(StreamBufferHandle_t xStreamBuffer)2352 size_t MPU_xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */ 2353 { 2354 size_t xReturn; 2355 2356 if( portIS_PRIVILEGED() == pdFALSE ) 2357 { 2358 portRAISE_PRIVILEGE(); 2359 portMEMORY_BARRIER(); 2360 2361 xReturn = xStreamBufferBytesAvailable( xStreamBuffer ); 2362 portMEMORY_BARRIER(); 2363 2364 portRESET_PRIVILEGE(); 2365 portMEMORY_BARRIER(); 2366 } 2367 else 2368 { 2369 xReturn = xStreamBufferBytesAvailable( xStreamBuffer ); 2370 } 2371 2372 return xReturn; 2373 } 2374 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */ 2375 /*-----------------------------------------------------------*/ 2376 2377 #if ( configUSE_STREAM_BUFFERS == 1 ) MPU_xStreamBufferSetTriggerLevel(StreamBufferHandle_t xStreamBuffer,size_t xTriggerLevel)2378 BaseType_t MPU_xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, 2379 size_t xTriggerLevel ) /* FREERTOS_SYSTEM_CALL */ 2380 { 2381 BaseType_t xReturn; 2382 2383 if( portIS_PRIVILEGED() == pdFALSE ) 2384 { 2385 portRAISE_PRIVILEGE(); 2386 portMEMORY_BARRIER(); 2387 2388 xReturn = xStreamBufferSetTriggerLevel( xStreamBuffer, xTriggerLevel ); 2389 portMEMORY_BARRIER(); 2390 2391 portRESET_PRIVILEGE(); 2392 portMEMORY_BARRIER(); 2393 } 2394 else 2395 { 2396 xReturn = xStreamBufferSetTriggerLevel( xStreamBuffer, xTriggerLevel ); 2397 } 2398 2399 return xReturn; 2400 } 2401 #endif /* #if ( configUSE_STREAM_BUFFERS == 1 ) */ 2402 /*-----------------------------------------------------------*/ 2403 2404 #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_STREAM_BUFFERS == 1 ) ) MPU_xStreamBufferGenericCreate(size_t xBufferSizeBytes,size_t xTriggerLevelBytes,BaseType_t xStreamBufferType,StreamBufferCallbackFunction_t pxSendCompletedCallback,StreamBufferCallbackFunction_t pxReceiveCompletedCallback)2405 StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes, 2406 size_t xTriggerLevelBytes, 2407 BaseType_t xStreamBufferType, 2408 StreamBufferCallbackFunction_t pxSendCompletedCallback, 2409 StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) /* FREERTOS_SYSTEM_CALL */ 2410 { 2411 StreamBufferHandle_t xReturn; 2412 2413 /** 2414 * Stream buffer application level callback functionality is disabled for MPU 2415 * enabled ports. 2416 */ 2417 configASSERT( ( pxSendCompletedCallback == NULL ) && 2418 ( pxReceiveCompletedCallback == NULL ) ); 2419 2420 if( ( pxSendCompletedCallback == NULL ) && 2421 ( pxReceiveCompletedCallback == NULL ) ) 2422 { 2423 if( portIS_PRIVILEGED() == pdFALSE ) 2424 { 2425 portRAISE_PRIVILEGE(); 2426 portMEMORY_BARRIER(); 2427 2428 xReturn = xStreamBufferGenericCreate( xBufferSizeBytes, 2429 xTriggerLevelBytes, 2430 xStreamBufferType, 2431 NULL, 2432 NULL ); 2433 portMEMORY_BARRIER(); 2434 2435 portRESET_PRIVILEGE(); 2436 portMEMORY_BARRIER(); 2437 } 2438 else 2439 { 2440 xReturn = xStreamBufferGenericCreate( xBufferSizeBytes, 2441 xTriggerLevelBytes, 2442 xStreamBufferType, 2443 NULL, 2444 NULL ); 2445 } 2446 } 2447 else 2448 { 2449 traceSTREAM_BUFFER_CREATE_FAILED( xStreamBufferType ); 2450 xReturn = NULL; 2451 } 2452 2453 return xReturn; 2454 } 2455 #endif /* #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_STREAM_BUFFERS == 1 ) ) */ 2456 /*-----------------------------------------------------------*/ 2457 2458 #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_STREAM_BUFFERS == 1 ) ) MPU_xStreamBufferGenericCreateStatic(size_t xBufferSizeBytes,size_t xTriggerLevelBytes,BaseType_t xStreamBufferType,uint8_t * const pucStreamBufferStorageArea,StaticStreamBuffer_t * const pxStaticStreamBuffer,StreamBufferCallbackFunction_t pxSendCompletedCallback,StreamBufferCallbackFunction_t pxReceiveCompletedCallback)2459 StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, 2460 size_t xTriggerLevelBytes, 2461 BaseType_t xStreamBufferType, 2462 uint8_t * const pucStreamBufferStorageArea, 2463 StaticStreamBuffer_t * const pxStaticStreamBuffer, 2464 StreamBufferCallbackFunction_t pxSendCompletedCallback, 2465 StreamBufferCallbackFunction_t pxReceiveCompletedCallback ) /* FREERTOS_SYSTEM_CALL */ 2466 { 2467 StreamBufferHandle_t xReturn; 2468 2469 /** 2470 * Stream buffer application level callback functionality is disabled for MPU 2471 * enabled ports. 2472 */ 2473 configASSERT( ( pxSendCompletedCallback == NULL ) && 2474 ( pxReceiveCompletedCallback == NULL ) ); 2475 2476 if( ( pxSendCompletedCallback == NULL ) && 2477 ( pxReceiveCompletedCallback == NULL ) ) 2478 { 2479 if( portIS_PRIVILEGED() == pdFALSE ) 2480 { 2481 portRAISE_PRIVILEGE(); 2482 portMEMORY_BARRIER(); 2483 2484 xReturn = xStreamBufferGenericCreateStatic( xBufferSizeBytes, 2485 xTriggerLevelBytes, 2486 xStreamBufferType, 2487 pucStreamBufferStorageArea, 2488 pxStaticStreamBuffer, 2489 NULL, 2490 NULL ); 2491 portMEMORY_BARRIER(); 2492 2493 portRESET_PRIVILEGE(); 2494 portMEMORY_BARRIER(); 2495 } 2496 else 2497 { 2498 xReturn = xStreamBufferGenericCreateStatic( xBufferSizeBytes, 2499 xTriggerLevelBytes, 2500 xStreamBufferType, 2501 pucStreamBufferStorageArea, 2502 pxStaticStreamBuffer, 2503 NULL, 2504 NULL ); 2505 } 2506 } 2507 else 2508 { 2509 traceSTREAM_BUFFER_CREATE_STATIC_FAILED( xReturn, xStreamBufferType ); 2510 xReturn = NULL; 2511 } 2512 2513 return xReturn; 2514 } 2515 #endif /* #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_STREAM_BUFFERS == 1 ) ) */ 2516 /*-----------------------------------------------------------*/ 2517 2518 2519 /* Functions that the application writer wants to execute in privileged mode 2520 * can be defined in application_defined_privileged_functions.h. The functions 2521 * must take the same format as those above whereby the privilege state on exit 2522 * equals the privilege state on entry. For example: 2523 * 2524 * void MPU_FunctionName( [parameters ] ) FREERTOS_SYSTEM_CALL; 2525 * void MPU_FunctionName( [parameters ] ) 2526 * { 2527 * if( portIS_PRIVILEGED() == pdFALSE ) 2528 * { 2529 * portRAISE_PRIVILEGE(); 2530 * portMEMORY_BARRIER(); 2531 * 2532 * FunctionName( [parameters ] ); 2533 * portMEMORY_BARRIER(); 2534 * 2535 * portRESET_PRIVILEGE(); 2536 * portMEMORY_BARRIER(); 2537 * } 2538 * else 2539 * { 2540 * FunctionName( [parameters ] ); 2541 * } 2542 * } 2543 */ 2544 2545 #if configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS == 1 2546 #include "application_defined_privileged_functions.h" 2547 #endif 2548 /*-----------------------------------------------------------*/ 2549 2550 #endif /* #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 1 ) ) */ 2551 /*-----------------------------------------------------------*/ 2552