mpu_wrappers.c 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465
  1. /*
  2. * FreeRTOS Kernel V10.4.3 LTS Patch 2
  3. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  6. * this software and associated documentation files (the "Software"), to deal in
  7. * the Software without restriction, including without limitation the rights to
  8. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  9. * the Software, and to permit persons to whom the Software is furnished to do so,
  10. * subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in all
  13. * copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  17. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  18. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  19. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  20. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * https://www.FreeRTOS.org
  23. * https://github.com/FreeRTOS
  24. *
  25. */
  26. /*
  27. * Implementation of the wrapper functions used to raise the processor privilege
  28. * before calling a standard FreeRTOS API function.
  29. */
  30. /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
  31. * all the API functions to use the MPU wrappers. That should only be done when
  32. * task.h is included from an application file. */
  33. #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
  34. /* Scheduler includes. */
  35. #include "FreeRTOS.h"
  36. #include "task.h"
  37. #include "queue.h"
  38. #include "timers.h"
  39. #include "event_groups.h"
  40. #include "stream_buffer.h"
  41. #include "mpu_prototypes.h"
  42. #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
  43. /*-----------------------------------------------------------*/
  44. #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
  45. BaseType_t MPU_xTaskCreate( TaskFunction_t pvTaskCode,
  46. const char * const pcName,
  47. uint16_t usStackDepth,
  48. void * pvParameters,
  49. UBaseType_t uxPriority,
  50. TaskHandle_t * pxCreatedTask ) /* FREERTOS_SYSTEM_CALL */
  51. {
  52. BaseType_t xReturn, xRunningPrivileged;
  53. xPortRaisePrivilege( xRunningPrivileged );
  54. xReturn = xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask );
  55. vPortResetPrivilege( xRunningPrivileged );
  56. return xReturn;
  57. }
  58. #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
  59. /*-----------------------------------------------------------*/
  60. #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
  61. TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode,
  62. const char * const pcName,
  63. const uint32_t ulStackDepth,
  64. void * const pvParameters,
  65. UBaseType_t uxPriority,
  66. StackType_t * const puxStackBuffer,
  67. StaticTask_t * const pxTaskBuffer ) /* FREERTOS_SYSTEM_CALL */
  68. {
  69. TaskHandle_t xReturn;
  70. BaseType_t xRunningPrivileged;
  71. xPortRaisePrivilege( xRunningPrivileged );
  72. xReturn = xTaskCreateStatic( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer );
  73. vPortResetPrivilege( xRunningPrivileged );
  74. return xReturn;
  75. }
  76. #endif /* configSUPPORT_STATIC_ALLOCATION */
  77. /*-----------------------------------------------------------*/
  78. #if ( INCLUDE_vTaskDelete == 1 )
  79. void MPU_vTaskDelete( TaskHandle_t pxTaskToDelete ) /* FREERTOS_SYSTEM_CALL */
  80. {
  81. BaseType_t xRunningPrivileged;
  82. xPortRaisePrivilege( xRunningPrivileged );
  83. vTaskDelete( pxTaskToDelete );
  84. vPortResetPrivilege( xRunningPrivileged );
  85. }
  86. #endif
  87. /*-----------------------------------------------------------*/
  88. #if ( INCLUDE_xTaskDelayUntil == 1 )
  89. BaseType_t MPU_xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
  90. TickType_t xTimeIncrement ) /* FREERTOS_SYSTEM_CALL */
  91. {
  92. BaseType_t xRunningPrivileged, xReturn;
  93. xPortRaisePrivilege( xRunningPrivileged );
  94. xReturn = xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement );
  95. vPortResetPrivilege( xRunningPrivileged );
  96. return xReturn;
  97. }
  98. #endif /* if ( INCLUDE_xTaskDelayUntil == 1 ) */
  99. /*-----------------------------------------------------------*/
  100. #if ( INCLUDE_xTaskAbortDelay == 1 )
  101. BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */
  102. {
  103. BaseType_t xReturn, xRunningPrivileged;
  104. xPortRaisePrivilege( xRunningPrivileged );
  105. xReturn = xTaskAbortDelay( xTask );
  106. vPortResetPrivilege( xRunningPrivileged );
  107. return xReturn;
  108. }
  109. #endif /* if ( INCLUDE_xTaskAbortDelay == 1 ) */
  110. /*-----------------------------------------------------------*/
  111. #if ( INCLUDE_vTaskDelay == 1 )
  112. void MPU_vTaskDelay( TickType_t xTicksToDelay ) /* FREERTOS_SYSTEM_CALL */
  113. {
  114. BaseType_t xRunningPrivileged;
  115. xPortRaisePrivilege( xRunningPrivileged );
  116. vTaskDelay( xTicksToDelay );
  117. vPortResetPrivilege( xRunningPrivileged );
  118. }
  119. #endif
  120. /*-----------------------------------------------------------*/
  121. #if ( INCLUDE_uxTaskPriorityGet == 1 )
  122. UBaseType_t MPU_uxTaskPriorityGet( const TaskHandle_t pxTask ) /* FREERTOS_SYSTEM_CALL */
  123. {
  124. UBaseType_t uxReturn;
  125. BaseType_t xRunningPrivileged;
  126. xPortRaisePrivilege( xRunningPrivileged );
  127. uxReturn = uxTaskPriorityGet( pxTask );
  128. vPortResetPrivilege( xRunningPrivileged );
  129. return uxReturn;
  130. }
  131. #endif /* if ( INCLUDE_uxTaskPriorityGet == 1 ) */
  132. /*-----------------------------------------------------------*/
  133. #if ( INCLUDE_vTaskPrioritySet == 1 )
  134. void MPU_vTaskPrioritySet( TaskHandle_t pxTask,
  135. UBaseType_t uxNewPriority ) /* FREERTOS_SYSTEM_CALL */
  136. {
  137. BaseType_t xRunningPrivileged;
  138. xPortRaisePrivilege( xRunningPrivileged );
  139. vTaskPrioritySet( pxTask, uxNewPriority );
  140. vPortResetPrivilege( xRunningPrivileged );
  141. }
  142. #endif /* if ( INCLUDE_vTaskPrioritySet == 1 ) */
  143. /*-----------------------------------------------------------*/
  144. #if ( INCLUDE_eTaskGetState == 1 )
  145. eTaskState MPU_eTaskGetState( TaskHandle_t pxTask ) /* FREERTOS_SYSTEM_CALL */
  146. {
  147. eTaskState eReturn;
  148. BaseType_t xRunningPrivileged;
  149. xPortRaisePrivilege( xRunningPrivileged );
  150. eReturn = eTaskGetState( pxTask );
  151. vPortResetPrivilege( xRunningPrivileged );
  152. return eReturn;
  153. }
  154. #endif /* if ( INCLUDE_eTaskGetState == 1 ) */
  155. /*-----------------------------------------------------------*/
  156. #if ( configUSE_TRACE_FACILITY == 1 )
  157. void MPU_vTaskGetInfo( TaskHandle_t xTask,
  158. TaskStatus_t * pxTaskStatus,
  159. BaseType_t xGetFreeStackSpace,
  160. eTaskState eState ) /* FREERTOS_SYSTEM_CALL */
  161. {
  162. BaseType_t xRunningPrivileged;
  163. xPortRaisePrivilege( xRunningPrivileged );
  164. vTaskGetInfo( xTask, pxTaskStatus, xGetFreeStackSpace, eState );
  165. vPortResetPrivilege( xRunningPrivileged );
  166. }
  167. #endif /* if ( configUSE_TRACE_FACILITY == 1 ) */
  168. /*-----------------------------------------------------------*/
  169. #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
  170. TaskHandle_t MPU_xTaskGetIdleTaskHandle( void ) /* FREERTOS_SYSTEM_CALL */
  171. {
  172. TaskHandle_t xReturn;
  173. BaseType_t xRunningPrivileged;
  174. xPortRaisePrivilege( xRunningPrivileged );
  175. xReturn = xTaskGetIdleTaskHandle();
  176. vPortResetPrivilege( xRunningPrivileged );
  177. return xReturn;
  178. }
  179. #endif /* if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) */
  180. /*-----------------------------------------------------------*/
  181. #if ( INCLUDE_vTaskSuspend == 1 )
  182. void MPU_vTaskSuspend( TaskHandle_t pxTaskToSuspend ) /* FREERTOS_SYSTEM_CALL */
  183. {
  184. BaseType_t xRunningPrivileged;
  185. xPortRaisePrivilege( xRunningPrivileged );
  186. vTaskSuspend( pxTaskToSuspend );
  187. vPortResetPrivilege( xRunningPrivileged );
  188. }
  189. #endif
  190. /*-----------------------------------------------------------*/
  191. #if ( INCLUDE_vTaskSuspend == 1 )
  192. void MPU_vTaskResume( TaskHandle_t pxTaskToResume ) /* FREERTOS_SYSTEM_CALL */
  193. {
  194. BaseType_t xRunningPrivileged;
  195. xPortRaisePrivilege( xRunningPrivileged );
  196. vTaskResume( pxTaskToResume );
  197. vPortResetPrivilege( xRunningPrivileged );
  198. }
  199. #endif
  200. /*-----------------------------------------------------------*/
  201. void MPU_vTaskSuspendAll( void ) /* FREERTOS_SYSTEM_CALL */
  202. {
  203. BaseType_t xRunningPrivileged;
  204. xPortRaisePrivilege( xRunningPrivileged );
  205. vTaskSuspendAll();
  206. vPortResetPrivilege( xRunningPrivileged );
  207. }
  208. /*-----------------------------------------------------------*/
  209. BaseType_t MPU_xTaskResumeAll( void ) /* FREERTOS_SYSTEM_CALL */
  210. {
  211. BaseType_t xReturn, xRunningPrivileged;
  212. xPortRaisePrivilege( xRunningPrivileged );
  213. xReturn = xTaskResumeAll();
  214. vPortResetPrivilege( xRunningPrivileged );
  215. return xReturn;
  216. }
  217. /*-----------------------------------------------------------*/
  218. TickType_t MPU_xTaskGetTickCount( void ) /* FREERTOS_SYSTEM_CALL */
  219. {
  220. TickType_t xReturn;
  221. BaseType_t xRunningPrivileged;
  222. xPortRaisePrivilege( xRunningPrivileged );
  223. xReturn = xTaskGetTickCount();
  224. vPortResetPrivilege( xRunningPrivileged );
  225. return xReturn;
  226. }
  227. /*-----------------------------------------------------------*/
  228. UBaseType_t MPU_uxTaskGetNumberOfTasks( void ) /* FREERTOS_SYSTEM_CALL */
  229. {
  230. UBaseType_t uxReturn;
  231. BaseType_t xRunningPrivileged;
  232. xPortRaisePrivilege( xRunningPrivileged );
  233. uxReturn = uxTaskGetNumberOfTasks();
  234. vPortResetPrivilege( xRunningPrivileged );
  235. return uxReturn;
  236. }
  237. /*-----------------------------------------------------------*/
  238. char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery ) /* FREERTOS_SYSTEM_CALL */
  239. {
  240. char * pcReturn;
  241. BaseType_t xRunningPrivileged;
  242. xPortRaisePrivilege( xRunningPrivileged );
  243. pcReturn = pcTaskGetName( xTaskToQuery );
  244. vPortResetPrivilege( xRunningPrivileged );
  245. return pcReturn;
  246. }
  247. /*-----------------------------------------------------------*/
  248. #if ( INCLUDE_xTaskGetHandle == 1 )
  249. TaskHandle_t MPU_xTaskGetHandle( const char * pcNameToQuery ) /* FREERTOS_SYSTEM_CALL */
  250. {
  251. TaskHandle_t xReturn;
  252. BaseType_t xRunningPrivileged;
  253. xPortRaisePrivilege( xRunningPrivileged );
  254. xReturn = xTaskGetHandle( pcNameToQuery );
  255. vPortResetPrivilege( xRunningPrivileged );
  256. return xReturn;
  257. }
  258. #endif /* if ( INCLUDE_xTaskGetHandle == 1 ) */
  259. /*-----------------------------------------------------------*/
  260. #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
  261. void MPU_vTaskList( char * pcWriteBuffer ) /* FREERTOS_SYSTEM_CALL */
  262. {
  263. BaseType_t xRunningPrivileged;
  264. xPortRaisePrivilege( xRunningPrivileged );
  265. vTaskList( pcWriteBuffer );
  266. vPortResetPrivilege( xRunningPrivileged );
  267. }
  268. #endif
  269. /*-----------------------------------------------------------*/
  270. #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
  271. void MPU_vTaskGetRunTimeStats( char * pcWriteBuffer ) /* FREERTOS_SYSTEM_CALL */
  272. {
  273. BaseType_t xRunningPrivileged;
  274. xPortRaisePrivilege( xRunningPrivileged );
  275. vTaskGetRunTimeStats( pcWriteBuffer );
  276. vPortResetPrivilege( xRunningPrivileged );
  277. }
  278. #endif
  279. /*-----------------------------------------------------------*/
  280. #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) )
  281. uint32_t MPU_ulTaskGetIdleRunTimeCounter( void ) /* FREERTOS_SYSTEM_CALL */
  282. {
  283. uint32_t xReturn;
  284. BaseType_t xRunningPrivileged;
  285. xPortRaisePrivilege( xRunningPrivileged );
  286. xReturn = ulTaskGetIdleRunTimeCounter();
  287. vPortResetPrivilege( xRunningPrivileged );
  288. return xReturn;
  289. }
  290. #endif /* if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) ) */
  291. /*-----------------------------------------------------------*/
  292. #if ( configUSE_APPLICATION_TASK_TAG == 1 )
  293. void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask,
  294. TaskHookFunction_t pxTagValue ) /* FREERTOS_SYSTEM_CALL */
  295. {
  296. BaseType_t xRunningPrivileged;
  297. xPortRaisePrivilege( xRunningPrivileged );
  298. vTaskSetApplicationTaskTag( xTask, pxTagValue );
  299. vPortResetPrivilege( xRunningPrivileged );
  300. }
  301. #endif /* if ( configUSE_APPLICATION_TASK_TAG == 1 ) */
  302. /*-----------------------------------------------------------*/
  303. #if ( configUSE_APPLICATION_TASK_TAG == 1 )
  304. TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */
  305. {
  306. TaskHookFunction_t xReturn;
  307. BaseType_t xRunningPrivileged;
  308. xPortRaisePrivilege( xRunningPrivileged );
  309. xReturn = xTaskGetApplicationTaskTag( xTask );
  310. vPortResetPrivilege( xRunningPrivileged );
  311. return xReturn;
  312. }
  313. #endif /* if ( configUSE_APPLICATION_TASK_TAG == 1 ) */
  314. /*-----------------------------------------------------------*/
  315. #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
  316. void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet,
  317. BaseType_t xIndex,
  318. void * pvValue ) /* FREERTOS_SYSTEM_CALL */
  319. {
  320. BaseType_t xRunningPrivileged;
  321. xPortRaisePrivilege( xRunningPrivileged );
  322. vTaskSetThreadLocalStoragePointer( xTaskToSet, xIndex, pvValue );
  323. vPortResetPrivilege( xRunningPrivileged );
  324. }
  325. #endif /* if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) */
  326. /*-----------------------------------------------------------*/
  327. #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
  328. void * MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery,
  329. BaseType_t xIndex ) /* FREERTOS_SYSTEM_CALL */
  330. {
  331. void * pvReturn;
  332. BaseType_t xRunningPrivileged;
  333. xPortRaisePrivilege( xRunningPrivileged );
  334. pvReturn = pvTaskGetThreadLocalStoragePointer( xTaskToQuery, xIndex );
  335. vPortResetPrivilege( xRunningPrivileged );
  336. return pvReturn;
  337. }
  338. #endif /* if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 ) */
  339. /*-----------------------------------------------------------*/
  340. #if ( configUSE_APPLICATION_TASK_TAG == 1 )
  341. BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask,
  342. void * pvParameter ) /* FREERTOS_SYSTEM_CALL */
  343. {
  344. BaseType_t xReturn, xRunningPrivileged;
  345. xPortRaisePrivilege( xRunningPrivileged );
  346. xReturn = xTaskCallApplicationTaskHook( xTask, pvParameter );
  347. vPortResetPrivilege( xRunningPrivileged );
  348. return xReturn;
  349. }
  350. #endif /* if ( configUSE_APPLICATION_TASK_TAG == 1 ) */
  351. /*-----------------------------------------------------------*/
  352. #if ( configUSE_TRACE_FACILITY == 1 )
  353. UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t * pxTaskStatusArray,
  354. UBaseType_t uxArraySize,
  355. uint32_t * pulTotalRunTime ) /* FREERTOS_SYSTEM_CALL */
  356. {
  357. UBaseType_t uxReturn;
  358. BaseType_t xRunningPrivileged;
  359. xPortRaisePrivilege( xRunningPrivileged );
  360. uxReturn = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, pulTotalRunTime );
  361. vPortResetPrivilege( xRunningPrivileged );
  362. return uxReturn;
  363. }
  364. #endif /* if ( configUSE_TRACE_FACILITY == 1 ) */
  365. /*-----------------------------------------------------------*/
  366. BaseType_t MPU_xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) /* FREERTOS_SYSTEM_CALL */
  367. {
  368. BaseType_t xReturn, xRunningPrivileged;
  369. xPortRaisePrivilege( xRunningPrivileged );
  370. xReturn = xTaskCatchUpTicks( xTicksToCatchUp );
  371. vPortResetPrivilege( xRunningPrivileged );
  372. return xReturn;
  373. }
  374. /*-----------------------------------------------------------*/
  375. #if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )
  376. UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */
  377. {
  378. UBaseType_t uxReturn;
  379. BaseType_t xRunningPrivileged;
  380. xPortRaisePrivilege( xRunningPrivileged );
  381. uxReturn = uxTaskGetStackHighWaterMark( xTask );
  382. vPortResetPrivilege( xRunningPrivileged );
  383. return uxReturn;
  384. }
  385. #endif /* if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 ) */
  386. /*-----------------------------------------------------------*/
  387. #if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 )
  388. configSTACK_DEPTH_TYPE MPU_uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) /* FREERTOS_SYSTEM_CALL */
  389. {
  390. configSTACK_DEPTH_TYPE uxReturn;
  391. BaseType_t xRunningPrivileged;
  392. xPortRaisePrivilege( xRunningPrivileged );
  393. uxReturn = uxTaskGetStackHighWaterMark2( xTask );
  394. vPortResetPrivilege( xRunningPrivileged );
  395. return uxReturn;
  396. }
  397. #endif /* if ( INCLUDE_uxTaskGetStackHighWaterMark2 == 1 ) */
  398. /*-----------------------------------------------------------*/
  399. #if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) )
  400. TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ) /* FREERTOS_SYSTEM_CALL */
  401. {
  402. TaskHandle_t xReturn;
  403. BaseType_t xRunningPrivileged;
  404. xPortRaisePrivilege( xRunningPrivileged );
  405. xReturn = xTaskGetCurrentTaskHandle();
  406. vPortResetPrivilege( xRunningPrivileged );
  407. return xReturn;
  408. }
  409. #endif /* if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ) ) */
  410. /*-----------------------------------------------------------*/
  411. #if ( INCLUDE_xTaskGetSchedulerState == 1 )
  412. BaseType_t MPU_xTaskGetSchedulerState( void ) /* FREERTOS_SYSTEM_CALL */
  413. {
  414. BaseType_t xReturn, xRunningPrivileged;
  415. xPortRaisePrivilege( xRunningPrivileged );
  416. xReturn = xTaskGetSchedulerState();
  417. vPortResetPrivilege( xRunningPrivileged );
  418. return xReturn;
  419. }
  420. #endif /* if ( INCLUDE_xTaskGetSchedulerState == 1 ) */
  421. /*-----------------------------------------------------------*/
  422. void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) /* FREERTOS_SYSTEM_CALL */
  423. {
  424. BaseType_t xRunningPrivileged;
  425. xPortRaisePrivilege( xRunningPrivileged );
  426. vTaskSetTimeOutState( pxTimeOut );
  427. vPortResetPrivilege( xRunningPrivileged );
  428. }
  429. /*-----------------------------------------------------------*/
  430. BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut,
  431. TickType_t * const pxTicksToWait ) /* FREERTOS_SYSTEM_CALL */
  432. {
  433. BaseType_t xReturn, xRunningPrivileged;
  434. xPortRaisePrivilege( xRunningPrivileged );
  435. xReturn = xTaskCheckForTimeOut( pxTimeOut, pxTicksToWait );
  436. vPortResetPrivilege( xRunningPrivileged );
  437. return xReturn;
  438. }
  439. /*-----------------------------------------------------------*/
  440. #if ( configUSE_TASK_NOTIFICATIONS == 1 )
  441. BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify,
  442. UBaseType_t uxIndexToNotify,
  443. uint32_t ulValue,
  444. eNotifyAction eAction,
  445. uint32_t * pulPreviousNotificationValue ) /* FREERTOS_SYSTEM_CALL */
  446. {
  447. BaseType_t xReturn, xRunningPrivileged;
  448. xPortRaisePrivilege( xRunningPrivileged );
  449. xReturn = xTaskGenericNotify( xTaskToNotify, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue );
  450. vPortResetPrivilege( xRunningPrivileged );
  451. return xReturn;
  452. }
  453. #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
  454. /*-----------------------------------------------------------*/
  455. #if ( configUSE_TASK_NOTIFICATIONS == 1 )
  456. BaseType_t MPU_xTaskGenericNotifyWait( UBaseType_t uxIndexToWaitOn,
  457. uint32_t ulBitsToClearOnEntry,
  458. uint32_t ulBitsToClearOnExit,
  459. uint32_t * pulNotificationValue,
  460. TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
  461. {
  462. BaseType_t xReturn, xRunningPrivileged;
  463. xPortRaisePrivilege( xRunningPrivileged );
  464. xReturn = xTaskGenericNotifyWait( uxIndexToWaitOn, ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait );
  465. vPortResetPrivilege( xRunningPrivileged );
  466. return xReturn;
  467. }
  468. #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
  469. /*-----------------------------------------------------------*/
  470. #if ( configUSE_TASK_NOTIFICATIONS == 1 )
  471. uint32_t MPU_ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn,
  472. BaseType_t xClearCountOnExit,
  473. TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
  474. {
  475. uint32_t ulReturn;
  476. BaseType_t xRunningPrivileged;
  477. xPortRaisePrivilege( xRunningPrivileged );
  478. ulReturn = ulTaskGenericNotifyTake( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait );
  479. vPortResetPrivilege( xRunningPrivileged );
  480. return ulReturn;
  481. }
  482. #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
  483. /*-----------------------------------------------------------*/
  484. #if ( configUSE_TASK_NOTIFICATIONS == 1 )
  485. BaseType_t MPU_xTaskGenericNotifyStateClear( TaskHandle_t xTask,
  486. UBaseType_t uxIndexToClear ) /* FREERTOS_SYSTEM_CALL */
  487. {
  488. BaseType_t xReturn, xRunningPrivileged;
  489. xPortRaisePrivilege( xRunningPrivileged );
  490. xReturn = xTaskGenericNotifyStateClear( xTask, uxIndexToClear );
  491. vPortResetPrivilege( xRunningPrivileged );
  492. return xReturn;
  493. }
  494. #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
  495. /*-----------------------------------------------------------*/
  496. #if ( configUSE_TASK_NOTIFICATIONS == 1 )
  497. uint32_t MPU_ulTaskGenericNotifyValueClear( TaskHandle_t xTask,
  498. UBaseType_t uxIndexToClear,
  499. uint32_t ulBitsToClear ) /* FREERTOS_SYSTEM_CALL */
  500. {
  501. uint32_t ulReturn;
  502. BaseType_t xRunningPrivileged;
  503. xPortRaisePrivilege( xRunningPrivileged );
  504. ulReturn = ulTaskGenericNotifyValueClear( xTask, uxIndexToClear, ulBitsToClear );
  505. vPortResetPrivilege( xRunningPrivileged );
  506. return ulReturn;
  507. }
  508. #endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
  509. /*-----------------------------------------------------------*/
  510. #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
  511. QueueHandle_t MPU_xQueueGenericCreate( UBaseType_t uxQueueLength,
  512. UBaseType_t uxItemSize,
  513. uint8_t ucQueueType ) /* FREERTOS_SYSTEM_CALL */
  514. {
  515. QueueHandle_t xReturn;
  516. BaseType_t xRunningPrivileged;
  517. xPortRaisePrivilege( xRunningPrivileged );
  518. xReturn = xQueueGenericCreate( uxQueueLength, uxItemSize, ucQueueType );
  519. vPortResetPrivilege( xRunningPrivileged );
  520. return xReturn;
  521. }
  522. #endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) */
  523. /*-----------------------------------------------------------*/
  524. #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
  525. QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength,
  526. const UBaseType_t uxItemSize,
  527. uint8_t * pucQueueStorage,
  528. StaticQueue_t * pxStaticQueue,
  529. const uint8_t ucQueueType ) /* FREERTOS_SYSTEM_CALL */
  530. {
  531. QueueHandle_t xReturn;
  532. BaseType_t xRunningPrivileged;
  533. xPortRaisePrivilege( xRunningPrivileged );
  534. xReturn = xQueueGenericCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxStaticQueue, ucQueueType );
  535. vPortResetPrivilege( xRunningPrivileged );
  536. return xReturn;
  537. }
  538. #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
  539. /*-----------------------------------------------------------*/
  540. BaseType_t MPU_xQueueGenericReset( QueueHandle_t pxQueue,
  541. BaseType_t xNewQueue ) /* FREERTOS_SYSTEM_CALL */
  542. {
  543. BaseType_t xReturn, xRunningPrivileged;
  544. xPortRaisePrivilege( xRunningPrivileged );
  545. xReturn = xQueueGenericReset( pxQueue, xNewQueue );
  546. vPortResetPrivilege( xRunningPrivileged );
  547. return xReturn;
  548. }
  549. /*-----------------------------------------------------------*/
  550. BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue,
  551. const void * const pvItemToQueue,
  552. TickType_t xTicksToWait,
  553. BaseType_t xCopyPosition ) /* FREERTOS_SYSTEM_CALL */
  554. {
  555. BaseType_t xReturn, xRunningPrivileged;
  556. xPortRaisePrivilege( xRunningPrivileged );
  557. xReturn = xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, xCopyPosition );
  558. vPortResetPrivilege( xRunningPrivileged );
  559. return xReturn;
  560. }
  561. /*-----------------------------------------------------------*/
  562. UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t pxQueue ) /* FREERTOS_SYSTEM_CALL */
  563. {
  564. UBaseType_t uxReturn;
  565. BaseType_t xRunningPrivileged;
  566. xPortRaisePrivilege( xRunningPrivileged );
  567. uxReturn = uxQueueMessagesWaiting( pxQueue );
  568. vPortResetPrivilege( xRunningPrivileged );
  569. return uxReturn;
  570. }
  571. /*-----------------------------------------------------------*/
  572. UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */
  573. {
  574. UBaseType_t uxReturn;
  575. BaseType_t xRunningPrivileged;
  576. xPortRaisePrivilege( xRunningPrivileged );
  577. uxReturn = uxQueueSpacesAvailable( xQueue );
  578. vPortResetPrivilege( xRunningPrivileged );
  579. return uxReturn;
  580. }
  581. /*-----------------------------------------------------------*/
  582. BaseType_t MPU_xQueueReceive( QueueHandle_t pxQueue,
  583. void * const pvBuffer,
  584. TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
  585. {
  586. BaseType_t xReturn, xRunningPrivileged;
  587. xPortRaisePrivilege( xRunningPrivileged );
  588. xReturn = xQueueReceive( pxQueue, pvBuffer, xTicksToWait );
  589. vPortResetPrivilege( xRunningPrivileged );
  590. return xReturn;
  591. }
  592. /*-----------------------------------------------------------*/
  593. BaseType_t MPU_xQueuePeek( QueueHandle_t xQueue,
  594. void * const pvBuffer,
  595. TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
  596. {
  597. BaseType_t xReturn, xRunningPrivileged;
  598. xPortRaisePrivilege( xRunningPrivileged );
  599. xReturn = xQueuePeek( xQueue, pvBuffer, xTicksToWait );
  600. vPortResetPrivilege( xRunningPrivileged );
  601. return xReturn;
  602. }
  603. /*-----------------------------------------------------------*/
  604. BaseType_t MPU_xQueueSemaphoreTake( QueueHandle_t xQueue,
  605. TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
  606. {
  607. BaseType_t xReturn, xRunningPrivileged;
  608. xPortRaisePrivilege( xRunningPrivileged );
  609. xReturn = xQueueSemaphoreTake( xQueue, xTicksToWait );
  610. vPortResetPrivilege( xRunningPrivileged );
  611. return xReturn;
  612. }
  613. /*-----------------------------------------------------------*/
  614. #if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) )
  615. TaskHandle_t MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore ) /* FREERTOS_SYSTEM_CALL */
  616. {
  617. void * xReturn;
  618. BaseType_t xRunningPrivileged;
  619. xPortRaisePrivilege( xRunningPrivileged );
  620. xReturn = xQueueGetMutexHolder( xSemaphore );
  621. vPortResetPrivilege( xRunningPrivileged );
  622. return xReturn;
  623. }
  624. #endif /* if ( ( configUSE_MUTEXES == 1 ) && ( INCLUDE_xSemaphoreGetMutexHolder == 1 ) ) */
  625. /*-----------------------------------------------------------*/
  626. #if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
  627. QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType ) /* FREERTOS_SYSTEM_CALL */
  628. {
  629. QueueHandle_t xReturn;
  630. BaseType_t xRunningPrivileged;
  631. xPortRaisePrivilege( xRunningPrivileged );
  632. xReturn = xQueueCreateMutex( ucQueueType );
  633. vPortResetPrivilege( xRunningPrivileged );
  634. return xReturn;
  635. }
  636. #endif /* if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */
  637. /*-----------------------------------------------------------*/
  638. #if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
  639. QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType,
  640. StaticQueue_t * pxStaticQueue ) /* FREERTOS_SYSTEM_CALL */
  641. {
  642. QueueHandle_t xReturn;
  643. BaseType_t xRunningPrivileged;
  644. xPortRaisePrivilege( xRunningPrivileged );
  645. xReturn = xQueueCreateMutexStatic( ucQueueType, pxStaticQueue );
  646. vPortResetPrivilege( xRunningPrivileged );
  647. return xReturn;
  648. }
  649. #endif /* if ( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) */
  650. /*-----------------------------------------------------------*/
  651. #if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
  652. QueueHandle_t MPU_xQueueCreateCountingSemaphore( UBaseType_t uxCountValue,
  653. UBaseType_t uxInitialCount ) /* FREERTOS_SYSTEM_CALL */
  654. {
  655. QueueHandle_t xReturn;
  656. BaseType_t xRunningPrivileged;
  657. xPortRaisePrivilege( xRunningPrivileged );
  658. xReturn = xQueueCreateCountingSemaphore( uxCountValue, uxInitialCount );
  659. vPortResetPrivilege( xRunningPrivileged );
  660. return xReturn;
  661. }
  662. #endif /* if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */
  663. /*-----------------------------------------------------------*/
  664. #if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
  665. QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
  666. const UBaseType_t uxInitialCount,
  667. StaticQueue_t * pxStaticQueue ) /* FREERTOS_SYSTEM_CALL */
  668. {
  669. QueueHandle_t xReturn;
  670. BaseType_t xRunningPrivileged;
  671. xPortRaisePrivilege( xRunningPrivileged );
  672. xReturn = xQueueCreateCountingSemaphoreStatic( uxMaxCount, uxInitialCount, pxStaticQueue );
  673. vPortResetPrivilege( xRunningPrivileged );
  674. return xReturn;
  675. }
  676. #endif /* if ( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) */
  677. /*-----------------------------------------------------------*/
  678. #if ( configUSE_RECURSIVE_MUTEXES == 1 )
  679. BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex,
  680. TickType_t xBlockTime ) /* FREERTOS_SYSTEM_CALL */
  681. {
  682. BaseType_t xReturn, xRunningPrivileged;
  683. xPortRaisePrivilege( xRunningPrivileged );
  684. xReturn = xQueueTakeMutexRecursive( xMutex, xBlockTime );
  685. vPortResetPrivilege( xRunningPrivileged );
  686. return xReturn;
  687. }
  688. #endif /* if ( configUSE_RECURSIVE_MUTEXES == 1 ) */
  689. /*-----------------------------------------------------------*/
  690. #if ( configUSE_RECURSIVE_MUTEXES == 1 )
  691. BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t xMutex ) /* FREERTOS_SYSTEM_CALL */
  692. {
  693. BaseType_t xReturn, xRunningPrivileged;
  694. xPortRaisePrivilege( xRunningPrivileged );
  695. xReturn = xQueueGiveMutexRecursive( xMutex );
  696. vPortResetPrivilege( xRunningPrivileged );
  697. return xReturn;
  698. }
  699. #endif /* if ( configUSE_RECURSIVE_MUTEXES == 1 ) */
  700. /*-----------------------------------------------------------*/
  701. #if ( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
  702. QueueSetHandle_t MPU_xQueueCreateSet( UBaseType_t uxEventQueueLength ) /* FREERTOS_SYSTEM_CALL */
  703. {
  704. QueueSetHandle_t xReturn;
  705. BaseType_t xRunningPrivileged;
  706. xPortRaisePrivilege( xRunningPrivileged );
  707. xReturn = xQueueCreateSet( uxEventQueueLength );
  708. vPortResetPrivilege( xRunningPrivileged );
  709. return xReturn;
  710. }
  711. #endif /* if ( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */
  712. /*-----------------------------------------------------------*/
  713. #if ( configUSE_QUEUE_SETS == 1 )
  714. QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet,
  715. TickType_t xBlockTimeTicks ) /* FREERTOS_SYSTEM_CALL */
  716. {
  717. QueueSetMemberHandle_t xReturn;
  718. BaseType_t xRunningPrivileged;
  719. xPortRaisePrivilege( xRunningPrivileged );
  720. xReturn = xQueueSelectFromSet( xQueueSet, xBlockTimeTicks );
  721. vPortResetPrivilege( xRunningPrivileged );
  722. return xReturn;
  723. }
  724. #endif /* if ( configUSE_QUEUE_SETS == 1 ) */
  725. /*-----------------------------------------------------------*/
  726. #if ( configUSE_QUEUE_SETS == 1 )
  727. BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore,
  728. QueueSetHandle_t xQueueSet ) /* FREERTOS_SYSTEM_CALL */
  729. {
  730. BaseType_t xReturn, xRunningPrivileged;
  731. xPortRaisePrivilege( xRunningPrivileged );
  732. xReturn = xQueueAddToSet( xQueueOrSemaphore, xQueueSet );
  733. vPortResetPrivilege( xRunningPrivileged );
  734. return xReturn;
  735. }
  736. #endif /* if ( configUSE_QUEUE_SETS == 1 ) */
  737. /*-----------------------------------------------------------*/
  738. #if ( configUSE_QUEUE_SETS == 1 )
  739. BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
  740. QueueSetHandle_t xQueueSet ) /* FREERTOS_SYSTEM_CALL */
  741. {
  742. BaseType_t xReturn, xRunningPrivileged;
  743. xPortRaisePrivilege( xRunningPrivileged );
  744. xReturn = xQueueRemoveFromSet( xQueueOrSemaphore, xQueueSet );
  745. vPortResetPrivilege( xRunningPrivileged );
  746. return xReturn;
  747. }
  748. #endif /* if ( configUSE_QUEUE_SETS == 1 ) */
  749. /*-----------------------------------------------------------*/
  750. #if configQUEUE_REGISTRY_SIZE > 0
  751. void MPU_vQueueAddToRegistry( QueueHandle_t xQueue,
  752. const char * pcName ) /* FREERTOS_SYSTEM_CALL */
  753. {
  754. BaseType_t xRunningPrivileged;
  755. xPortRaisePrivilege( xRunningPrivileged );
  756. vQueueAddToRegistry( xQueue, pcName );
  757. vPortResetPrivilege( xRunningPrivileged );
  758. }
  759. #endif /* if configQUEUE_REGISTRY_SIZE > 0 */
  760. /*-----------------------------------------------------------*/
  761. #if configQUEUE_REGISTRY_SIZE > 0
  762. void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */
  763. {
  764. BaseType_t xRunningPrivileged;
  765. xPortRaisePrivilege( xRunningPrivileged );
  766. vQueueUnregisterQueue( xQueue );
  767. vPortResetPrivilege( xRunningPrivileged );
  768. }
  769. #endif /* if configQUEUE_REGISTRY_SIZE > 0 */
  770. /*-----------------------------------------------------------*/
  771. #if configQUEUE_REGISTRY_SIZE > 0
  772. const char * MPU_pcQueueGetName( QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */
  773. {
  774. const char * pcReturn;
  775. BaseType_t xRunningPrivileged;
  776. xPortRaisePrivilege( xRunningPrivileged );
  777. pcReturn = pcQueueGetName( xQueue );
  778. vPortResetPrivilege( xRunningPrivileged );
  779. return pcReturn;
  780. }
  781. #endif /* if configQUEUE_REGISTRY_SIZE > 0 */
  782. /*-----------------------------------------------------------*/
  783. void MPU_vQueueDelete( QueueHandle_t xQueue ) /* FREERTOS_SYSTEM_CALL */
  784. {
  785. BaseType_t xRunningPrivileged;
  786. xPortRaisePrivilege( xRunningPrivileged );
  787. vQueueDelete( xQueue );
  788. vPortResetPrivilege( xRunningPrivileged );
  789. }
  790. /*-----------------------------------------------------------*/
  791. #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) )
  792. TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName,
  793. const TickType_t xTimerPeriodInTicks,
  794. const UBaseType_t uxAutoReload,
  795. void * const pvTimerID,
  796. TimerCallbackFunction_t pxCallbackFunction ) /* FREERTOS_SYSTEM_CALL */
  797. {
  798. TimerHandle_t xReturn;
  799. BaseType_t xRunningPrivileged;
  800. xPortRaisePrivilege( xRunningPrivileged );
  801. xReturn = xTimerCreate( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction );
  802. vPortResetPrivilege( xRunningPrivileged );
  803. return xReturn;
  804. }
  805. #endif /* if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) ) */
  806. /*-----------------------------------------------------------*/
  807. #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) )
  808. TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName,
  809. const TickType_t xTimerPeriodInTicks,
  810. const UBaseType_t uxAutoReload,
  811. void * const pvTimerID,
  812. TimerCallbackFunction_t pxCallbackFunction,
  813. StaticTimer_t * pxTimerBuffer ) /* FREERTOS_SYSTEM_CALL */
  814. {
  815. TimerHandle_t xReturn;
  816. BaseType_t xRunningPrivileged;
  817. xPortRaisePrivilege( xRunningPrivileged );
  818. xReturn = xTimerCreateStatic( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction, pxTimerBuffer );
  819. vPortResetPrivilege( xRunningPrivileged );
  820. return xReturn;
  821. }
  822. #endif /* if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) ) */
  823. /*-----------------------------------------------------------*/
  824. #if ( configUSE_TIMERS == 1 )
  825. void * MPU_pvTimerGetTimerID( const TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */
  826. {
  827. void * pvReturn;
  828. BaseType_t xRunningPrivileged;
  829. xPortRaisePrivilege( xRunningPrivileged );
  830. pvReturn = pvTimerGetTimerID( xTimer );
  831. vPortResetPrivilege( xRunningPrivileged );
  832. return pvReturn;
  833. }
  834. #endif /* if ( configUSE_TIMERS == 1 ) */
  835. /*-----------------------------------------------------------*/
  836. #if ( configUSE_TIMERS == 1 )
  837. void MPU_vTimerSetTimerID( TimerHandle_t xTimer,
  838. void * pvNewID ) /* FREERTOS_SYSTEM_CALL */
  839. {
  840. BaseType_t xRunningPrivileged;
  841. xPortRaisePrivilege( xRunningPrivileged );
  842. vTimerSetTimerID( xTimer, pvNewID );
  843. vPortResetPrivilege( xRunningPrivileged );
  844. }
  845. #endif /* if ( configUSE_TIMERS == 1 ) */
  846. /*-----------------------------------------------------------*/
  847. #if ( configUSE_TIMERS == 1 )
  848. BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */
  849. {
  850. BaseType_t xReturn, xRunningPrivileged;
  851. xPortRaisePrivilege( xRunningPrivileged );
  852. xReturn = xTimerIsTimerActive( xTimer );
  853. vPortResetPrivilege( xRunningPrivileged );
  854. return xReturn;
  855. }
  856. #endif /* if ( configUSE_TIMERS == 1 ) */
  857. /*-----------------------------------------------------------*/
  858. #if ( configUSE_TIMERS == 1 )
  859. TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void ) /* FREERTOS_SYSTEM_CALL */
  860. {
  861. TaskHandle_t xReturn;
  862. BaseType_t xRunningPrivileged;
  863. xPortRaisePrivilege( xRunningPrivileged );
  864. xReturn = xTimerGetTimerDaemonTaskHandle();
  865. vPortResetPrivilege( xRunningPrivileged );
  866. return xReturn;
  867. }
  868. #endif /* if ( configUSE_TIMERS == 1 ) */
  869. /*-----------------------------------------------------------*/
  870. #if ( ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )
  871. BaseType_t MPU_xTimerPendFunctionCall( PendedFunction_t xFunctionToPend,
  872. void * pvParameter1,
  873. uint32_t ulParameter2,
  874. TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
  875. {
  876. BaseType_t xReturn, xRunningPrivileged;
  877. xPortRaisePrivilege( xRunningPrivileged );
  878. xReturn = xTimerPendFunctionCall( xFunctionToPend, pvParameter1, ulParameter2, xTicksToWait );
  879. vPortResetPrivilege( xRunningPrivileged );
  880. return xReturn;
  881. }
  882. #endif /* if ( ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) ) */
  883. /*-----------------------------------------------------------*/
  884. #if ( configUSE_TIMERS == 1 )
  885. void MPU_vTimerSetReloadMode( TimerHandle_t xTimer,
  886. const UBaseType_t uxAutoReload ) /* FREERTOS_SYSTEM_CALL */
  887. {
  888. BaseType_t xRunningPrivileged;
  889. xPortRaisePrivilege( xRunningPrivileged );
  890. vTimerSetReloadMode( xTimer, uxAutoReload );
  891. vPortResetPrivilege( xRunningPrivileged );
  892. }
  893. #endif /* if ( configUSE_TIMERS == 1 ) */
  894. /*-----------------------------------------------------------*/
  895. #if ( configUSE_TIMERS == 1 )
  896. UBaseType_t MPU_uxTimerGetReloadMode( TimerHandle_t xTimer )
  897. {
  898. UBaseType_t uxReturn;
  899. BaseType_t xRunningPrivileged;
  900. xPortRaisePrivilege( xRunningPrivileged );
  901. uxReturn = uxTimerGetReloadMode( xTimer );
  902. vPortResetPrivilege( xRunningPrivileged );
  903. return uxReturn;
  904. }
  905. #endif /* if ( configUSE_TIMERS == 1 ) */
  906. /*-----------------------------------------------------------*/
  907. #if ( configUSE_TIMERS == 1 )
  908. const char * MPU_pcTimerGetName( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */
  909. {
  910. const char * pcReturn;
  911. BaseType_t xRunningPrivileged;
  912. xPortRaisePrivilege( xRunningPrivileged );
  913. pcReturn = pcTimerGetName( xTimer );
  914. vPortResetPrivilege( xRunningPrivileged );
  915. return pcReturn;
  916. }
  917. #endif /* if ( configUSE_TIMERS == 1 ) */
  918. /*-----------------------------------------------------------*/
  919. #if ( configUSE_TIMERS == 1 )
  920. TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */
  921. {
  922. TickType_t xReturn;
  923. BaseType_t xRunningPrivileged;
  924. xPortRaisePrivilege( xRunningPrivileged );
  925. xReturn = xTimerGetPeriod( xTimer );
  926. vPortResetPrivilege( xRunningPrivileged );
  927. return xReturn;
  928. }
  929. #endif /* if ( configUSE_TIMERS == 1 ) */
  930. /*-----------------------------------------------------------*/
  931. #if ( configUSE_TIMERS == 1 )
  932. TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer ) /* FREERTOS_SYSTEM_CALL */
  933. {
  934. TickType_t xReturn;
  935. BaseType_t xRunningPrivileged;
  936. xPortRaisePrivilege( xRunningPrivileged );
  937. xReturn = xTimerGetExpiryTime( xTimer );
  938. vPortResetPrivilege( xRunningPrivileged );
  939. return xReturn;
  940. }
  941. #endif /* if ( configUSE_TIMERS == 1 ) */
  942. /*-----------------------------------------------------------*/
  943. #if ( configUSE_TIMERS == 1 )
  944. BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer,
  945. const BaseType_t xCommandID,
  946. const TickType_t xOptionalValue,
  947. BaseType_t * const pxHigherPriorityTaskWoken,
  948. const TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
  949. {
  950. BaseType_t xReturn;
  951. BaseType_t xRunningPrivileged;
  952. xPortRaisePrivilege( xRunningPrivileged );
  953. xReturn = xTimerGenericCommand( xTimer, xCommandID, xOptionalValue, pxHigherPriorityTaskWoken, xTicksToWait );
  954. vPortResetPrivilege( xRunningPrivileged );
  955. return xReturn;
  956. }
  957. #endif /* if ( configUSE_TIMERS == 1 ) */
  958. /*-----------------------------------------------------------*/
  959. #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
  960. EventGroupHandle_t MPU_xEventGroupCreate( void ) /* FREERTOS_SYSTEM_CALL */
  961. {
  962. EventGroupHandle_t xReturn;
  963. BaseType_t xRunningPrivileged;
  964. xPortRaisePrivilege( xRunningPrivileged );
  965. xReturn = xEventGroupCreate();
  966. vPortResetPrivilege( xRunningPrivileged );
  967. return xReturn;
  968. }
  969. #endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) */
  970. /*-----------------------------------------------------------*/
  971. #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
  972. EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) /* FREERTOS_SYSTEM_CALL */
  973. {
  974. EventGroupHandle_t xReturn;
  975. BaseType_t xRunningPrivileged;
  976. xPortRaisePrivilege( xRunningPrivileged );
  977. xReturn = xEventGroupCreateStatic( pxEventGroupBuffer );
  978. vPortResetPrivilege( xRunningPrivileged );
  979. return xReturn;
  980. }
  981. #endif /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */
  982. /*-----------------------------------------------------------*/
  983. EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
  984. const EventBits_t uxBitsToWaitFor,
  985. const BaseType_t xClearOnExit,
  986. const BaseType_t xWaitForAllBits,
  987. TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
  988. {
  989. EventBits_t xReturn;
  990. BaseType_t xRunningPrivileged;
  991. xPortRaisePrivilege( xRunningPrivileged );
  992. xReturn = xEventGroupWaitBits( xEventGroup, uxBitsToWaitFor, xClearOnExit, xWaitForAllBits, xTicksToWait );
  993. vPortResetPrivilege( xRunningPrivileged );
  994. return xReturn;
  995. }
  996. /*-----------------------------------------------------------*/
  997. EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup,
  998. const EventBits_t uxBitsToClear ) /* FREERTOS_SYSTEM_CALL */
  999. {
  1000. EventBits_t xReturn;
  1001. BaseType_t xRunningPrivileged;
  1002. xPortRaisePrivilege( xRunningPrivileged );
  1003. xReturn = xEventGroupClearBits( xEventGroup, uxBitsToClear );
  1004. vPortResetPrivilege( xRunningPrivileged );
  1005. return xReturn;
  1006. }
  1007. /*-----------------------------------------------------------*/
  1008. EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup,
  1009. const EventBits_t uxBitsToSet ) /* FREERTOS_SYSTEM_CALL */
  1010. {
  1011. EventBits_t xReturn;
  1012. BaseType_t xRunningPrivileged;
  1013. xPortRaisePrivilege( xRunningPrivileged );
  1014. xReturn = xEventGroupSetBits( xEventGroup, uxBitsToSet );
  1015. vPortResetPrivilege( xRunningPrivileged );
  1016. return xReturn;
  1017. }
  1018. /*-----------------------------------------------------------*/
  1019. EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup,
  1020. const EventBits_t uxBitsToSet,
  1021. const EventBits_t uxBitsToWaitFor,
  1022. TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
  1023. {
  1024. EventBits_t xReturn;
  1025. BaseType_t xRunningPrivileged;
  1026. xPortRaisePrivilege( xRunningPrivileged );
  1027. xReturn = xEventGroupSync( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTicksToWait );
  1028. vPortResetPrivilege( xRunningPrivileged );
  1029. return xReturn;
  1030. }
  1031. /*-----------------------------------------------------------*/
  1032. void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup ) /* FREERTOS_SYSTEM_CALL */
  1033. {
  1034. BaseType_t xRunningPrivileged;
  1035. xPortRaisePrivilege( xRunningPrivileged );
  1036. vEventGroupDelete( xEventGroup );
  1037. vPortResetPrivilege( xRunningPrivileged );
  1038. }
  1039. /*-----------------------------------------------------------*/
  1040. size_t MPU_xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
  1041. const void * pvTxData,
  1042. size_t xDataLengthBytes,
  1043. TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
  1044. {
  1045. size_t xReturn;
  1046. BaseType_t xRunningPrivileged;
  1047. xPortRaisePrivilege( xRunningPrivileged );
  1048. xReturn = xStreamBufferSend( xStreamBuffer, pvTxData, xDataLengthBytes, xTicksToWait );
  1049. vPortResetPrivilege( xRunningPrivileged );
  1050. return xReturn;
  1051. }
  1052. /*-----------------------------------------------------------*/
  1053. size_t MPU_xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
  1054. {
  1055. size_t xReturn;
  1056. BaseType_t xRunningPrivileged;
  1057. xPortRaisePrivilege( xRunningPrivileged );
  1058. xReturn = xStreamBufferNextMessageLengthBytes( xStreamBuffer );
  1059. vPortResetPrivilege( xRunningPrivileged );
  1060. return xReturn;
  1061. }
  1062. /*-----------------------------------------------------------*/
  1063. size_t MPU_xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer,
  1064. void * pvRxData,
  1065. size_t xBufferLengthBytes,
  1066. TickType_t xTicksToWait ) /* FREERTOS_SYSTEM_CALL */
  1067. {
  1068. size_t xReturn;
  1069. BaseType_t xRunningPrivileged;
  1070. xPortRaisePrivilege( xRunningPrivileged );
  1071. xReturn = xStreamBufferReceive( xStreamBuffer, pvRxData, xBufferLengthBytes, xTicksToWait );
  1072. vPortResetPrivilege( xRunningPrivileged );
  1073. return xReturn;
  1074. }
  1075. /*-----------------------------------------------------------*/
  1076. void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
  1077. {
  1078. BaseType_t xRunningPrivileged;
  1079. xPortRaisePrivilege( xRunningPrivileged );
  1080. vStreamBufferDelete( xStreamBuffer );
  1081. vPortResetPrivilege( xRunningPrivileged );
  1082. }
  1083. /*-----------------------------------------------------------*/
  1084. BaseType_t MPU_xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
  1085. {
  1086. BaseType_t xReturn, xRunningPrivileged;
  1087. xPortRaisePrivilege( xRunningPrivileged );
  1088. xReturn = xStreamBufferIsFull( xStreamBuffer );
  1089. vPortResetPrivilege( xRunningPrivileged );
  1090. return xReturn;
  1091. }
  1092. /*-----------------------------------------------------------*/
  1093. BaseType_t MPU_xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
  1094. {
  1095. BaseType_t xReturn, xRunningPrivileged;
  1096. xPortRaisePrivilege( xRunningPrivileged );
  1097. xReturn = xStreamBufferIsEmpty( xStreamBuffer );
  1098. vPortResetPrivilege( xRunningPrivileged );
  1099. return xReturn;
  1100. }
  1101. /*-----------------------------------------------------------*/
  1102. BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
  1103. {
  1104. BaseType_t xReturn, xRunningPrivileged;
  1105. xPortRaisePrivilege( xRunningPrivileged );
  1106. xReturn = xStreamBufferReset( xStreamBuffer );
  1107. vPortResetPrivilege( xRunningPrivileged );
  1108. return xReturn;
  1109. }
  1110. /*-----------------------------------------------------------*/
  1111. size_t MPU_xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
  1112. {
  1113. size_t xReturn;
  1114. BaseType_t xRunningPrivileged;
  1115. xPortRaisePrivilege( xRunningPrivileged );
  1116. xReturn = xStreamBufferSpacesAvailable( xStreamBuffer );
  1117. vPortResetPrivilege( xRunningPrivileged );
  1118. return xReturn;
  1119. }
  1120. /*-----------------------------------------------------------*/
  1121. size_t MPU_xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
  1122. {
  1123. size_t xReturn;
  1124. BaseType_t xRunningPrivileged;
  1125. xPortRaisePrivilege( xRunningPrivileged );
  1126. xReturn = xStreamBufferBytesAvailable( xStreamBuffer );
  1127. vPortResetPrivilege( xRunningPrivileged );
  1128. return xReturn;
  1129. }
  1130. /*-----------------------------------------------------------*/
  1131. BaseType_t MPU_xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer,
  1132. size_t xTriggerLevel ) /* FREERTOS_SYSTEM_CALL */
  1133. {
  1134. BaseType_t xReturn, xRunningPrivileged;
  1135. xPortRaisePrivilege( xRunningPrivileged );
  1136. xReturn = xStreamBufferSetTriggerLevel( xStreamBuffer, xTriggerLevel );
  1137. vPortResetPrivilege( xRunningPrivileged );
  1138. return xReturn;
  1139. }
  1140. /*-----------------------------------------------------------*/
  1141. #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
  1142. StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes,
  1143. size_t xTriggerLevelBytes,
  1144. BaseType_t xIsMessageBuffer ) /* FREERTOS_SYSTEM_CALL */
  1145. {
  1146. StreamBufferHandle_t xReturn;
  1147. BaseType_t xRunningPrivileged;
  1148. xPortRaisePrivilege( xRunningPrivileged );
  1149. xReturn = xStreamBufferGenericCreate( xBufferSizeBytes, xTriggerLevelBytes, xIsMessageBuffer );
  1150. vPortResetPrivilege( xRunningPrivileged );
  1151. return xReturn;
  1152. }
  1153. #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
  1154. /*-----------------------------------------------------------*/
  1155. #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
  1156. StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
  1157. size_t xTriggerLevelBytes,
  1158. BaseType_t xIsMessageBuffer,
  1159. uint8_t * const pucStreamBufferStorageArea,
  1160. StaticStreamBuffer_t * const pxStaticStreamBuffer ) /* FREERTOS_SYSTEM_CALL */
  1161. {
  1162. StreamBufferHandle_t xReturn;
  1163. BaseType_t xRunningPrivileged;
  1164. xPortRaisePrivilege( xRunningPrivileged );
  1165. xReturn = xStreamBufferGenericCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, xIsMessageBuffer, pucStreamBufferStorageArea, pxStaticStreamBuffer );
  1166. vPortResetPrivilege( xRunningPrivileged );
  1167. return xReturn;
  1168. }
  1169. #endif /* configSUPPORT_STATIC_ALLOCATION */
  1170. /*-----------------------------------------------------------*/
  1171. /* Functions that the application writer wants to execute in privileged mode
  1172. * can be defined in application_defined_privileged_functions.h. The functions
  1173. * must take the same format as those above whereby the privilege state on exit
  1174. * equals the privilege state on entry. For example:
  1175. *
  1176. * void MPU_FunctionName( [parameters ] ) FREERTOS_SYSTEM_CALL;
  1177. * void MPU_FunctionName( [parameters ] )
  1178. * {
  1179. * BaseType_t xRunningPrivileged;
  1180. *
  1181. * xPortRaisePrivilege( xRunningPrivileged );
  1182. * FunctionName( [parameters ] );
  1183. * vPortResetPrivilege( xRunningPrivileged );
  1184. * }
  1185. */
  1186. #if configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS == 1
  1187. #include "application_defined_privileged_functions.h"
  1188. #endif