mpu_wrappers.c 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290
  1. /*
  2. * FreeRTOS Kernel V10.0.1
  3. * Copyright (C) 2017 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. * http://www.FreeRTOS.org
  23. * http://aws.amazon.com/freertos
  24. *
  25. * 1 tab == 4 spaces!
  26. */
  27. /*
  28. * Implementation of the wrapper functions used to raise the processor privilege
  29. * before calling a standard FreeRTOS API function.
  30. */
  31. /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
  32. all the API functions to use the MPU wrappers. That should only be done when
  33. task.h is included from an application file. */
  34. #define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
  35. /* Scheduler includes. */
  36. #include "FreeRTOS.h"
  37. #include "task.h"
  38. #include "queue.h"
  39. #include "timers.h"
  40. #include "event_groups.h"
  41. #include "stream_buffer.h"
  42. #include "mpu_prototypes.h"
  43. #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
  44. /*
  45. * Checks to see if being called from the context of an unprivileged task, and
  46. * if so raises the privilege level and returns false - otherwise does nothing
  47. * other than return true.
  48. */
  49. extern BaseType_t xPortRaisePrivilege( void );
  50. /*-----------------------------------------------------------*/
  51. #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
  52. BaseType_t MPU_xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask )
  53. {
  54. BaseType_t xReturn;
  55. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  56. xReturn = xTaskCreateRestricted( pxTaskDefinition, pxCreatedTask );
  57. vPortResetPrivilege( xRunningPrivileged );
  58. return xReturn;
  59. }
  60. #endif /* conifgSUPPORT_DYNAMIC_ALLOCATION */
  61. /*-----------------------------------------------------------*/
  62. #if( configSUPPORT_STATIC_ALLOCATION == 1 )
  63. BaseType_t MPU_xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask )
  64. {
  65. BaseType_t xReturn;
  66. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  67. xReturn = xTaskCreateRestrictedStatic( pxTaskDefinition, pxCreatedTask );
  68. vPortResetPrivilege( xRunningPrivileged );
  69. return xReturn;
  70. }
  71. #endif /* conifgSUPPORT_DYNAMIC_ALLOCATION */
  72. /*-----------------------------------------------------------*/
  73. #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
  74. BaseType_t MPU_xTaskCreate( TaskFunction_t pvTaskCode, const char * const pcName, uint16_t usStackDepth, void *pvParameters, UBaseType_t uxPriority, TaskHandle_t *pxCreatedTask )
  75. {
  76. BaseType_t xReturn;
  77. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  78. xReturn = xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask );
  79. vPortResetPrivilege( xRunningPrivileged );
  80. return xReturn;
  81. }
  82. #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
  83. /*-----------------------------------------------------------*/
  84. #if( configSUPPORT_STATIC_ALLOCATION == 1 )
  85. TaskHandle_t MPU_xTaskCreateStatic( TaskFunction_t pxTaskCode, const char * const pcName, const uint32_t ulStackDepth, void * const pvParameters, UBaseType_t uxPriority, StackType_t * const puxStackBuffer, StaticTask_t * const pxTaskBuffer )
  86. {
  87. TaskHandle_t xReturn;
  88. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  89. xReturn = xTaskCreateStatic( pxTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer );
  90. vPortResetPrivilege( xRunningPrivileged );
  91. return xReturn;
  92. }
  93. #endif /* configSUPPORT_STATIC_ALLOCATION */
  94. /*-----------------------------------------------------------*/
  95. void MPU_vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const xRegions )
  96. {
  97. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  98. vTaskAllocateMPURegions( xTask, xRegions );
  99. vPortResetPrivilege( xRunningPrivileged );
  100. }
  101. /*-----------------------------------------------------------*/
  102. #if ( INCLUDE_vTaskDelete == 1 )
  103. void MPU_vTaskDelete( TaskHandle_t pxTaskToDelete )
  104. {
  105. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  106. vTaskDelete( pxTaskToDelete );
  107. vPortResetPrivilege( xRunningPrivileged );
  108. }
  109. #endif
  110. /*-----------------------------------------------------------*/
  111. #if ( INCLUDE_vTaskDelayUntil == 1 )
  112. void MPU_vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, TickType_t xTimeIncrement )
  113. {
  114. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  115. vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement );
  116. vPortResetPrivilege( xRunningPrivileged );
  117. }
  118. #endif
  119. /*-----------------------------------------------------------*/
  120. #if ( INCLUDE_xTaskAbortDelay == 1 )
  121. BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask )
  122. {
  123. BaseType_t xReturn;
  124. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  125. xReturn = xTaskAbortDelay( xTask );
  126. vPortResetPrivilege( xRunningPrivileged );
  127. return xReturn;
  128. }
  129. #endif
  130. /*-----------------------------------------------------------*/
  131. #if ( INCLUDE_vTaskDelay == 1 )
  132. void MPU_vTaskDelay( TickType_t xTicksToDelay )
  133. {
  134. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  135. vTaskDelay( xTicksToDelay );
  136. vPortResetPrivilege( xRunningPrivileged );
  137. }
  138. #endif
  139. /*-----------------------------------------------------------*/
  140. #if ( INCLUDE_uxTaskPriorityGet == 1 )
  141. UBaseType_t MPU_uxTaskPriorityGet( TaskHandle_t pxTask )
  142. {
  143. UBaseType_t uxReturn;
  144. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  145. uxReturn = uxTaskPriorityGet( pxTask );
  146. vPortResetPrivilege( xRunningPrivileged );
  147. return uxReturn;
  148. }
  149. #endif
  150. /*-----------------------------------------------------------*/
  151. #if ( INCLUDE_vTaskPrioritySet == 1 )
  152. void MPU_vTaskPrioritySet( TaskHandle_t pxTask, UBaseType_t uxNewPriority )
  153. {
  154. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  155. vTaskPrioritySet( pxTask, uxNewPriority );
  156. vPortResetPrivilege( xRunningPrivileged );
  157. }
  158. #endif
  159. /*-----------------------------------------------------------*/
  160. #if ( INCLUDE_eTaskGetState == 1 )
  161. eTaskState MPU_eTaskGetState( TaskHandle_t pxTask )
  162. {
  163. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  164. eTaskState eReturn;
  165. eReturn = eTaskGetState( pxTask );
  166. vPortResetPrivilege( xRunningPrivileged );
  167. return eReturn;
  168. }
  169. #endif
  170. /*-----------------------------------------------------------*/
  171. #if( configUSE_TRACE_FACILITY == 1 )
  172. void MPU_vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState )
  173. {
  174. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  175. vTaskGetInfo( xTask, pxTaskStatus, xGetFreeStackSpace, eState );
  176. vPortResetPrivilege( xRunningPrivileged );
  177. }
  178. #endif
  179. /*-----------------------------------------------------------*/
  180. #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
  181. TaskHandle_t MPU_xTaskGetIdleTaskHandle( void )
  182. {
  183. TaskHandle_t xReturn;
  184. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  185. xReturn = xTaskGetIdleTaskHandle();
  186. vPortResetPrivilege( xRunningPrivileged );
  187. return xReturn;
  188. }
  189. #endif
  190. /*-----------------------------------------------------------*/
  191. #if ( INCLUDE_vTaskSuspend == 1 )
  192. void MPU_vTaskSuspend( TaskHandle_t pxTaskToSuspend )
  193. {
  194. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  195. vTaskSuspend( pxTaskToSuspend );
  196. vPortResetPrivilege( xRunningPrivileged );
  197. }
  198. #endif
  199. /*-----------------------------------------------------------*/
  200. #if ( INCLUDE_vTaskSuspend == 1 )
  201. void MPU_vTaskResume( TaskHandle_t pxTaskToResume )
  202. {
  203. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  204. vTaskResume( pxTaskToResume );
  205. vPortResetPrivilege( xRunningPrivileged );
  206. }
  207. #endif
  208. /*-----------------------------------------------------------*/
  209. void MPU_vTaskSuspendAll( void )
  210. {
  211. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  212. vTaskSuspendAll();
  213. vPortResetPrivilege( xRunningPrivileged );
  214. }
  215. /*-----------------------------------------------------------*/
  216. BaseType_t MPU_xTaskResumeAll( void )
  217. {
  218. BaseType_t xReturn;
  219. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  220. xReturn = xTaskResumeAll();
  221. vPortResetPrivilege( xRunningPrivileged );
  222. return xReturn;
  223. }
  224. /*-----------------------------------------------------------*/
  225. TickType_t MPU_xTaskGetTickCount( void )
  226. {
  227. TickType_t xReturn;
  228. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  229. xReturn = xTaskGetTickCount();
  230. vPortResetPrivilege( xRunningPrivileged );
  231. return xReturn;
  232. }
  233. /*-----------------------------------------------------------*/
  234. UBaseType_t MPU_uxTaskGetNumberOfTasks( void )
  235. {
  236. UBaseType_t uxReturn;
  237. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  238. uxReturn = uxTaskGetNumberOfTasks();
  239. vPortResetPrivilege( xRunningPrivileged );
  240. return uxReturn;
  241. }
  242. /*-----------------------------------------------------------*/
  243. char * MPU_pcTaskGetName( TaskHandle_t xTaskToQuery )
  244. {
  245. char *pcReturn;
  246. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  247. pcReturn = pcTaskGetName( xTaskToQuery );
  248. vPortResetPrivilege( xRunningPrivileged );
  249. return pcReturn;
  250. }
  251. /*-----------------------------------------------------------*/
  252. #if ( INCLUDE_xTaskGetHandle == 1 )
  253. TaskHandle_t MPU_xTaskGetHandle( const char *pcNameToQuery )
  254. {
  255. TaskHandle_t xReturn;
  256. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  257. xReturn = xTaskGetHandle( pcNameToQuery );
  258. vPortResetPrivilege( xRunningPrivileged );
  259. return xReturn;
  260. }
  261. #endif
  262. /*-----------------------------------------------------------*/
  263. #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
  264. void MPU_vTaskList( char *pcWriteBuffer )
  265. {
  266. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  267. vTaskList( pcWriteBuffer );
  268. vPortResetPrivilege( xRunningPrivileged );
  269. }
  270. #endif
  271. /*-----------------------------------------------------------*/
  272. #if ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
  273. void MPU_vTaskGetRunTimeStats( char *pcWriteBuffer )
  274. {
  275. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  276. vTaskGetRunTimeStats( pcWriteBuffer );
  277. vPortResetPrivilege( xRunningPrivileged );
  278. }
  279. #endif
  280. /*-----------------------------------------------------------*/
  281. #if ( configUSE_APPLICATION_TASK_TAG == 1 )
  282. void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxTagValue )
  283. {
  284. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  285. vTaskSetApplicationTaskTag( xTask, pxTagValue );
  286. vPortResetPrivilege( xRunningPrivileged );
  287. }
  288. #endif
  289. /*-----------------------------------------------------------*/
  290. #if ( configUSE_APPLICATION_TASK_TAG == 1 )
  291. TaskHookFunction_t MPU_xTaskGetApplicationTaskTag( TaskHandle_t xTask )
  292. {
  293. TaskHookFunction_t xReturn;
  294. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  295. xReturn = xTaskGetApplicationTaskTag( xTask );
  296. vPortResetPrivilege( xRunningPrivileged );
  297. return xReturn;
  298. }
  299. #endif
  300. /*-----------------------------------------------------------*/
  301. #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
  302. void MPU_vTaskSetThreadLocalStoragePointer( TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue )
  303. {
  304. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  305. vTaskSetThreadLocalStoragePointer( xTaskToSet, xIndex, pvValue );
  306. vPortResetPrivilege( xRunningPrivileged );
  307. }
  308. #endif
  309. /*-----------------------------------------------------------*/
  310. #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS != 0 )
  311. void *MPU_pvTaskGetThreadLocalStoragePointer( TaskHandle_t xTaskToQuery, BaseType_t xIndex )
  312. {
  313. void *pvReturn;
  314. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  315. pvReturn = pvTaskGetThreadLocalStoragePointer( xTaskToQuery, xIndex );
  316. vPortResetPrivilege( xRunningPrivileged );
  317. return pvReturn;
  318. }
  319. #endif
  320. /*-----------------------------------------------------------*/
  321. #if ( configUSE_APPLICATION_TASK_TAG == 1 )
  322. BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter )
  323. {
  324. BaseType_t xReturn;
  325. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  326. xReturn = xTaskCallApplicationTaskHook( xTask, pvParameter );
  327. vPortResetPrivilege( xRunningPrivileged );
  328. return xReturn;
  329. }
  330. #endif
  331. /*-----------------------------------------------------------*/
  332. #if ( configUSE_TRACE_FACILITY == 1 )
  333. UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t *pxTaskStatusArray, UBaseType_t uxArraySize, uint32_t *pulTotalRunTime )
  334. {
  335. UBaseType_t uxReturn;
  336. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  337. uxReturn = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, pulTotalRunTime );
  338. vPortResetPrivilege( xRunningPrivileged );
  339. return uxReturn;
  340. }
  341. #endif
  342. /*-----------------------------------------------------------*/
  343. #if ( INCLUDE_uxTaskGetStackHighWaterMark == 1 )
  344. UBaseType_t MPU_uxTaskGetStackHighWaterMark( TaskHandle_t xTask )
  345. {
  346. UBaseType_t uxReturn;
  347. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  348. uxReturn = uxTaskGetStackHighWaterMark( xTask );
  349. vPortResetPrivilege( xRunningPrivileged );
  350. return uxReturn;
  351. }
  352. #endif
  353. /*-----------------------------------------------------------*/
  354. #if ( INCLUDE_xTaskGetCurrentTaskHandle == 1 )
  355. TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void )
  356. {
  357. TaskHandle_t xReturn;
  358. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  359. xReturn = xTaskGetCurrentTaskHandle();
  360. vPortResetPrivilege( xRunningPrivileged );
  361. return xReturn;
  362. }
  363. #endif
  364. /*-----------------------------------------------------------*/
  365. #if ( INCLUDE_xTaskGetSchedulerState == 1 )
  366. BaseType_t MPU_xTaskGetSchedulerState( void )
  367. {
  368. BaseType_t xReturn;
  369. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  370. xReturn = xTaskGetSchedulerState();
  371. vPortResetPrivilege( xRunningPrivileged );
  372. return xReturn;
  373. }
  374. #endif
  375. /*-----------------------------------------------------------*/
  376. void MPU_vTaskSetTimeOutState( TimeOut_t * const pxTimeOut )
  377. {
  378. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  379. vTaskSetTimeOutState( pxTimeOut );
  380. vPortResetPrivilege( xRunningPrivileged );
  381. }
  382. /*-----------------------------------------------------------*/
  383. BaseType_t MPU_xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait )
  384. {
  385. BaseType_t xReturn;
  386. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  387. xReturn = xTaskCheckForTimeOut( pxTimeOut, pxTicksToWait );
  388. vPortResetPrivilege( xRunningPrivileged );
  389. return xReturn;
  390. }
  391. /*-----------------------------------------------------------*/
  392. #if( configUSE_TASK_NOTIFICATIONS == 1 )
  393. BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue )
  394. {
  395. BaseType_t xReturn;
  396. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  397. xReturn = xTaskGenericNotify( xTaskToNotify, ulValue, eAction, pulPreviousNotificationValue );
  398. vPortResetPrivilege( xRunningPrivileged );
  399. return xReturn;
  400. }
  401. #endif
  402. /*-----------------------------------------------------------*/
  403. #if( configUSE_TASK_NOTIFICATIONS == 1 )
  404. BaseType_t MPU_xTaskNotifyWait( uint32_t ulBitsToClearOnEntry, uint32_t ulBitsToClearOnExit, uint32_t *pulNotificationValue, TickType_t xTicksToWait )
  405. {
  406. BaseType_t xReturn;
  407. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  408. xReturn = xTaskNotifyWait( ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait );
  409. vPortResetPrivilege( xRunningPrivileged );
  410. return xReturn;
  411. }
  412. #endif
  413. /*-----------------------------------------------------------*/
  414. #if( configUSE_TASK_NOTIFICATIONS == 1 )
  415. uint32_t MPU_ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait )
  416. {
  417. uint32_t ulReturn;
  418. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  419. ulReturn = ulTaskNotifyTake( xClearCountOnExit, xTicksToWait );
  420. vPortResetPrivilege( xRunningPrivileged );
  421. return ulReturn;
  422. }
  423. #endif
  424. /*-----------------------------------------------------------*/
  425. #if( configUSE_TASK_NOTIFICATIONS == 1 )
  426. BaseType_t MPU_xTaskNotifyStateClear( TaskHandle_t xTask )
  427. {
  428. BaseType_t xReturn;
  429. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  430. xReturn = xTaskNotifyStateClear( xTask );
  431. vPortResetPrivilege( xRunningPrivileged );
  432. return xReturn;
  433. }
  434. #endif
  435. /*-----------------------------------------------------------*/
  436. #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
  437. QueueHandle_t MPU_xQueueGenericCreate( UBaseType_t uxQueueLength, UBaseType_t uxItemSize, uint8_t ucQueueType )
  438. {
  439. QueueHandle_t xReturn;
  440. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  441. xReturn = xQueueGenericCreate( uxQueueLength, uxItemSize, ucQueueType );
  442. vPortResetPrivilege( xRunningPrivileged );
  443. return xReturn;
  444. }
  445. #endif
  446. /*-----------------------------------------------------------*/
  447. #if( configSUPPORT_STATIC_ALLOCATION == 1 )
  448. QueueHandle_t MPU_xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType )
  449. {
  450. QueueHandle_t xReturn;
  451. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  452. xReturn = xQueueGenericCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxStaticQueue, ucQueueType );
  453. vPortResetPrivilege( xRunningPrivileged );
  454. return xReturn;
  455. }
  456. #endif
  457. /*-----------------------------------------------------------*/
  458. BaseType_t MPU_xQueueGenericReset( QueueHandle_t pxQueue, BaseType_t xNewQueue )
  459. {
  460. BaseType_t xReturn;
  461. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  462. xReturn = xQueueGenericReset( pxQueue, xNewQueue );
  463. vPortResetPrivilege( xRunningPrivileged );
  464. return xReturn;
  465. }
  466. /*-----------------------------------------------------------*/
  467. BaseType_t MPU_xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, BaseType_t xCopyPosition )
  468. {
  469. BaseType_t xReturn;
  470. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  471. xReturn = xQueueGenericSend( xQueue, pvItemToQueue, xTicksToWait, xCopyPosition );
  472. vPortResetPrivilege( xRunningPrivileged );
  473. return xReturn;
  474. }
  475. /*-----------------------------------------------------------*/
  476. UBaseType_t MPU_uxQueueMessagesWaiting( const QueueHandle_t pxQueue )
  477. {
  478. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  479. UBaseType_t uxReturn;
  480. uxReturn = uxQueueMessagesWaiting( pxQueue );
  481. vPortResetPrivilege( xRunningPrivileged );
  482. return uxReturn;
  483. }
  484. /*-----------------------------------------------------------*/
  485. UBaseType_t MPU_uxQueueSpacesAvailable( const QueueHandle_t xQueue )
  486. {
  487. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  488. UBaseType_t uxReturn;
  489. uxReturn = uxQueueSpacesAvailable( xQueue );
  490. vPortResetPrivilege( xRunningPrivileged );
  491. return uxReturn;
  492. }
  493. /*-----------------------------------------------------------*/
  494. BaseType_t MPU_xQueueReceive( QueueHandle_t pxQueue, void * const pvBuffer, TickType_t xTicksToWait )
  495. {
  496. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  497. BaseType_t xReturn;
  498. xReturn = xQueueReceive( pxQueue, pvBuffer, xTicksToWait );
  499. vPortResetPrivilege( xRunningPrivileged );
  500. return xReturn;
  501. }
  502. /*-----------------------------------------------------------*/
  503. BaseType_t MPU_xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait )
  504. {
  505. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  506. BaseType_t xReturn;
  507. xReturn = xQueuePeek( xQueue, pvBuffer, xTicksToWait );
  508. vPortResetPrivilege( xRunningPrivileged );
  509. return xReturn;
  510. }
  511. /*-----------------------------------------------------------*/
  512. BaseType_t MPU_xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait )
  513. {
  514. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  515. BaseType_t xReturn;
  516. xReturn = xQueueSemaphoreTake( xQueue, xTicksToWait );
  517. vPortResetPrivilege( xRunningPrivileged );
  518. return xReturn;
  519. }
  520. /*-----------------------------------------------------------*/
  521. BaseType_t MPU_xQueuePeekFromISR( QueueHandle_t pxQueue, void * const pvBuffer )
  522. {
  523. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  524. BaseType_t xReturn;
  525. xReturn = xQueuePeekFromISR( pxQueue, pvBuffer );
  526. vPortResetPrivilege( xRunningPrivileged );
  527. return xReturn;
  528. }
  529. /*-----------------------------------------------------------*/
  530. void* MPU_xQueueGetMutexHolder( QueueHandle_t xSemaphore )
  531. {
  532. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  533. void * xReturn;
  534. xReturn = ( void * ) xQueueGetMutexHolder( xSemaphore );
  535. vPortResetPrivilege( xRunningPrivileged );
  536. return xReturn;
  537. }
  538. /*-----------------------------------------------------------*/
  539. #if( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
  540. QueueHandle_t MPU_xQueueCreateMutex( const uint8_t ucQueueType )
  541. {
  542. QueueHandle_t xReturn;
  543. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  544. xReturn = xQueueCreateMutex( ucQueueType );
  545. vPortResetPrivilege( xRunningPrivileged );
  546. return xReturn;
  547. }
  548. #endif
  549. /*-----------------------------------------------------------*/
  550. #if( ( configUSE_MUTEXES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
  551. QueueHandle_t MPU_xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue )
  552. {
  553. QueueHandle_t xReturn;
  554. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  555. xReturn = xQueueCreateMutexStatic( ucQueueType, pxStaticQueue );
  556. vPortResetPrivilege( xRunningPrivileged );
  557. return xReturn;
  558. }
  559. #endif
  560. /*-----------------------------------------------------------*/
  561. #if( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
  562. QueueHandle_t MPU_xQueueCreateCountingSemaphore( UBaseType_t uxCountValue, UBaseType_t uxInitialCount )
  563. {
  564. QueueHandle_t xReturn;
  565. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  566. xReturn = xQueueCreateCountingSemaphore( uxCountValue, uxInitialCount );
  567. vPortResetPrivilege( xRunningPrivileged );
  568. return xReturn;
  569. }
  570. #endif
  571. /*-----------------------------------------------------------*/
  572. #if( ( configUSE_COUNTING_SEMAPHORES == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
  573. QueueHandle_t MPU_xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue )
  574. {
  575. QueueHandle_t xReturn;
  576. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  577. xReturn = xQueueCreateCountingSemaphoreStatic( uxMaxCount, uxInitialCount, pxStaticQueue );
  578. vPortResetPrivilege( xRunningPrivileged );
  579. return xReturn;
  580. }
  581. #endif
  582. /*-----------------------------------------------------------*/
  583. #if ( configUSE_RECURSIVE_MUTEXES == 1 )
  584. BaseType_t MPU_xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xBlockTime )
  585. {
  586. BaseType_t xReturn;
  587. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  588. xReturn = xQueueTakeMutexRecursive( xMutex, xBlockTime );
  589. vPortResetPrivilege( xRunningPrivileged );
  590. return xReturn;
  591. }
  592. #endif
  593. /*-----------------------------------------------------------*/
  594. #if ( configUSE_RECURSIVE_MUTEXES == 1 )
  595. BaseType_t MPU_xQueueGiveMutexRecursive( QueueHandle_t xMutex )
  596. {
  597. BaseType_t xReturn;
  598. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  599. xReturn = xQueueGiveMutexRecursive( xMutex );
  600. vPortResetPrivilege( xRunningPrivileged );
  601. return xReturn;
  602. }
  603. #endif
  604. /*-----------------------------------------------------------*/
  605. #if( ( configUSE_QUEUE_SETS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
  606. QueueSetHandle_t MPU_xQueueCreateSet( UBaseType_t uxEventQueueLength )
  607. {
  608. QueueSetHandle_t xReturn;
  609. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  610. xReturn = xQueueCreateSet( uxEventQueueLength );
  611. vPortResetPrivilege( xRunningPrivileged );
  612. return xReturn;
  613. }
  614. #endif
  615. /*-----------------------------------------------------------*/
  616. #if ( configUSE_QUEUE_SETS == 1 )
  617. QueueSetMemberHandle_t MPU_xQueueSelectFromSet( QueueSetHandle_t xQueueSet, TickType_t xBlockTimeTicks )
  618. {
  619. QueueSetMemberHandle_t xReturn;
  620. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  621. xReturn = xQueueSelectFromSet( xQueueSet, xBlockTimeTicks );
  622. vPortResetPrivilege( xRunningPrivileged );
  623. return xReturn;
  624. }
  625. #endif
  626. /*-----------------------------------------------------------*/
  627. #if ( configUSE_QUEUE_SETS == 1 )
  628. BaseType_t MPU_xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet )
  629. {
  630. BaseType_t xReturn;
  631. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  632. xReturn = xQueueAddToSet( xQueueOrSemaphore, xQueueSet );
  633. vPortResetPrivilege( xRunningPrivileged );
  634. return xReturn;
  635. }
  636. #endif
  637. /*-----------------------------------------------------------*/
  638. #if ( configUSE_QUEUE_SETS == 1 )
  639. BaseType_t MPU_xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet )
  640. {
  641. BaseType_t xReturn;
  642. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  643. xReturn = xQueueRemoveFromSet( xQueueOrSemaphore, xQueueSet );
  644. vPortResetPrivilege( xRunningPrivileged );
  645. return xReturn;
  646. }
  647. #endif
  648. /*-----------------------------------------------------------*/
  649. #if configQUEUE_REGISTRY_SIZE > 0
  650. void MPU_vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcName )
  651. {
  652. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  653. vQueueAddToRegistry( xQueue, pcName );
  654. vPortResetPrivilege( xRunningPrivileged );
  655. }
  656. #endif
  657. /*-----------------------------------------------------------*/
  658. #if configQUEUE_REGISTRY_SIZE > 0
  659. void MPU_vQueueUnregisterQueue( QueueHandle_t xQueue )
  660. {
  661. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  662. vQueueUnregisterQueue( xQueue );
  663. vPortResetPrivilege( xRunningPrivileged );
  664. }
  665. #endif
  666. /*-----------------------------------------------------------*/
  667. #if configQUEUE_REGISTRY_SIZE > 0
  668. const char *MPU_pcQueueGetName( QueueHandle_t xQueue )
  669. {
  670. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  671. const char *pcReturn;
  672. pcReturn = pcQueueGetName( xQueue );
  673. vPortResetPrivilege( xRunningPrivileged );
  674. return pcReturn;
  675. }
  676. #endif
  677. /*-----------------------------------------------------------*/
  678. void MPU_vQueueDelete( QueueHandle_t xQueue )
  679. {
  680. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  681. vQueueDelete( xQueue );
  682. vPortResetPrivilege( xRunningPrivileged );
  683. }
  684. /*-----------------------------------------------------------*/
  685. #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
  686. void *MPU_pvPortMalloc( size_t xSize )
  687. {
  688. void *pvReturn;
  689. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  690. pvReturn = pvPortMalloc( xSize );
  691. vPortResetPrivilege( xRunningPrivileged );
  692. return pvReturn;
  693. }
  694. #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
  695. /*-----------------------------------------------------------*/
  696. #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
  697. void MPU_vPortFree( void *pv )
  698. {
  699. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  700. vPortFree( pv );
  701. vPortResetPrivilege( xRunningPrivileged );
  702. }
  703. #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
  704. /*-----------------------------------------------------------*/
  705. #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
  706. void MPU_vPortInitialiseBlocks( void )
  707. {
  708. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  709. vPortInitialiseBlocks();
  710. vPortResetPrivilege( xRunningPrivileged );
  711. }
  712. #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
  713. /*-----------------------------------------------------------*/
  714. #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
  715. size_t MPU_xPortGetFreeHeapSize( void )
  716. {
  717. size_t xReturn;
  718. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  719. xReturn = xPortGetFreeHeapSize();
  720. vPortResetPrivilege( xRunningPrivileged );
  721. return xReturn;
  722. }
  723. #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
  724. /*-----------------------------------------------------------*/
  725. #if( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) )
  726. TimerHandle_t MPU_xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction )
  727. {
  728. TimerHandle_t xReturn;
  729. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  730. xReturn = xTimerCreate( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction );
  731. vPortResetPrivilege( xRunningPrivileged );
  732. return xReturn;
  733. }
  734. #endif
  735. /*-----------------------------------------------------------*/
  736. #if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_TIMERS == 1 ) )
  737. TimerHandle_t MPU_xTimerCreateStatic( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction, StaticTimer_t *pxTimerBuffer )
  738. {
  739. TimerHandle_t xReturn;
  740. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  741. xReturn = xTimerCreateStatic( pcTimerName, xTimerPeriodInTicks, uxAutoReload, pvTimerID, pxCallbackFunction, pxTimerBuffer );
  742. vPortResetPrivilege( xRunningPrivileged );
  743. return xReturn;
  744. }
  745. #endif
  746. /*-----------------------------------------------------------*/
  747. #if( configUSE_TIMERS == 1 )
  748. void *MPU_pvTimerGetTimerID( const TimerHandle_t xTimer )
  749. {
  750. void * pvReturn;
  751. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  752. pvReturn = pvTimerGetTimerID( xTimer );
  753. vPortResetPrivilege( xRunningPrivileged );
  754. return pvReturn;
  755. }
  756. #endif
  757. /*-----------------------------------------------------------*/
  758. #if( configUSE_TIMERS == 1 )
  759. void MPU_vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID )
  760. {
  761. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  762. vTimerSetTimerID( xTimer, pvNewID );
  763. vPortResetPrivilege( xRunningPrivileged );
  764. }
  765. #endif
  766. /*-----------------------------------------------------------*/
  767. #if( configUSE_TIMERS == 1 )
  768. BaseType_t MPU_xTimerIsTimerActive( TimerHandle_t xTimer )
  769. {
  770. BaseType_t xReturn;
  771. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  772. xReturn = xTimerIsTimerActive( xTimer );
  773. vPortResetPrivilege( xRunningPrivileged );
  774. return xReturn;
  775. }
  776. #endif
  777. /*-----------------------------------------------------------*/
  778. #if( configUSE_TIMERS == 1 )
  779. TaskHandle_t MPU_xTimerGetTimerDaemonTaskHandle( void )
  780. {
  781. TaskHandle_t xReturn;
  782. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  783. xReturn = xTimerGetTimerDaemonTaskHandle();
  784. vPortResetPrivilege( xRunningPrivileged );
  785. return xReturn;
  786. }
  787. #endif
  788. /*-----------------------------------------------------------*/
  789. #if( ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 1 ) )
  790. BaseType_t MPU_xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait )
  791. {
  792. BaseType_t xReturn;
  793. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  794. xReturn = xTimerPendFunctionCall( xFunctionToPend, pvParameter1, ulParameter2, xTicksToWait );
  795. vPortResetPrivilege( xRunningPrivileged );
  796. return xReturn;
  797. }
  798. #endif
  799. /*-----------------------------------------------------------*/
  800. #if( configUSE_TIMERS == 1 )
  801. const char * MPU_pcTimerGetName( TimerHandle_t xTimer )
  802. {
  803. const char * pcReturn;
  804. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  805. pcReturn = pcTimerGetName( xTimer );
  806. vPortResetPrivilege( xRunningPrivileged );
  807. return pcReturn;
  808. }
  809. #endif
  810. /*-----------------------------------------------------------*/
  811. #if( configUSE_TIMERS == 1 )
  812. TickType_t MPU_xTimerGetPeriod( TimerHandle_t xTimer )
  813. {
  814. TickType_t xReturn;
  815. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  816. xReturn = xTimerGetPeriod( xTimer );
  817. vPortResetPrivilege( xRunningPrivileged );
  818. return xReturn;
  819. }
  820. #endif
  821. /*-----------------------------------------------------------*/
  822. #if( configUSE_TIMERS == 1 )
  823. TickType_t MPU_xTimerGetExpiryTime( TimerHandle_t xTimer )
  824. {
  825. TickType_t xReturn;
  826. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  827. xReturn = xTimerGetExpiryTime( xTimer );
  828. vPortResetPrivilege( xRunningPrivileged );
  829. return xReturn;
  830. }
  831. #endif
  832. /*-----------------------------------------------------------*/
  833. #if( configUSE_TIMERS == 1 )
  834. BaseType_t MPU_xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait )
  835. {
  836. BaseType_t xReturn;
  837. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  838. xReturn = xTimerGenericCommand( xTimer, xCommandID, xOptionalValue, pxHigherPriorityTaskWoken, xTicksToWait );
  839. vPortResetPrivilege( xRunningPrivileged );
  840. return xReturn;
  841. }
  842. #endif
  843. /*-----------------------------------------------------------*/
  844. #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
  845. EventGroupHandle_t MPU_xEventGroupCreate( void )
  846. {
  847. EventGroupHandle_t xReturn;
  848. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  849. xReturn = xEventGroupCreate();
  850. vPortResetPrivilege( xRunningPrivileged );
  851. return xReturn;
  852. }
  853. #endif
  854. /*-----------------------------------------------------------*/
  855. #if( configSUPPORT_STATIC_ALLOCATION == 1 )
  856. EventGroupHandle_t MPU_xEventGroupCreateStatic( StaticEventGroup_t *pxEventGroupBuffer )
  857. {
  858. EventGroupHandle_t xReturn;
  859. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  860. xReturn = xEventGroupCreateStatic( pxEventGroupBuffer );
  861. vPortResetPrivilege( xRunningPrivileged );
  862. return xReturn;
  863. }
  864. #endif
  865. /*-----------------------------------------------------------*/
  866. EventBits_t MPU_xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait )
  867. {
  868. EventBits_t xReturn;
  869. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  870. xReturn = xEventGroupWaitBits( xEventGroup, uxBitsToWaitFor, xClearOnExit, xWaitForAllBits, xTicksToWait );
  871. vPortResetPrivilege( xRunningPrivileged );
  872. return xReturn;
  873. }
  874. /*-----------------------------------------------------------*/
  875. EventBits_t MPU_xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear )
  876. {
  877. EventBits_t xReturn;
  878. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  879. xReturn = xEventGroupClearBits( xEventGroup, uxBitsToClear );
  880. vPortResetPrivilege( xRunningPrivileged );
  881. return xReturn;
  882. }
  883. /*-----------------------------------------------------------*/
  884. EventBits_t MPU_xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet )
  885. {
  886. EventBits_t xReturn;
  887. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  888. xReturn = xEventGroupSetBits( xEventGroup, uxBitsToSet );
  889. vPortResetPrivilege( xRunningPrivileged );
  890. return xReturn;
  891. }
  892. /*-----------------------------------------------------------*/
  893. EventBits_t MPU_xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait )
  894. {
  895. EventBits_t xReturn;
  896. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  897. xReturn = xEventGroupSync( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTicksToWait );
  898. vPortResetPrivilege( xRunningPrivileged );
  899. return xReturn;
  900. }
  901. /*-----------------------------------------------------------*/
  902. void MPU_vEventGroupDelete( EventGroupHandle_t xEventGroup )
  903. {
  904. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  905. vEventGroupDelete( xEventGroup );
  906. vPortResetPrivilege( xRunningPrivileged );
  907. }
  908. /*-----------------------------------------------------------*/
  909. size_t MPU_xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, TickType_t xTicksToWait )
  910. {
  911. size_t xReturn;
  912. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  913. xReturn = xStreamBufferSend( xStreamBuffer, pvTxData, xDataLengthBytes, xTicksToWait );
  914. vPortResetPrivilege( xRunningPrivileged );
  915. return xReturn;
  916. }
  917. /*-----------------------------------------------------------*/
  918. size_t MPU_xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, const void *pvTxData, size_t xDataLengthBytes, BaseType_t * const pxHigherPriorityTaskWoken )
  919. {
  920. size_t xReturn;
  921. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  922. xReturn = xStreamBufferSendFromISR( xStreamBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken );
  923. vPortResetPrivilege( xRunningPrivileged );
  924. return xReturn;
  925. }
  926. /*-----------------------------------------------------------*/
  927. size_t MPU_xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, TickType_t xTicksToWait )
  928. {
  929. size_t xReturn;
  930. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  931. xReturn = xStreamBufferReceive( xStreamBuffer, pvRxData, xBufferLengthBytes, xTicksToWait );
  932. vPortResetPrivilege( xRunningPrivileged );
  933. return xReturn;
  934. }
  935. /*-----------------------------------------------------------*/
  936. size_t MPU_xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, void *pvRxData, size_t xBufferLengthBytes, BaseType_t * const pxHigherPriorityTaskWoken )
  937. {
  938. size_t xReturn;
  939. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  940. xReturn = xStreamBufferReceiveFromISR( xStreamBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken );
  941. vPortResetPrivilege( xRunningPrivileged );
  942. return xReturn;
  943. }
  944. /*-----------------------------------------------------------*/
  945. void MPU_vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer )
  946. {
  947. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  948. vStreamBufferDelete( xStreamBuffer );
  949. vPortResetPrivilege( xRunningPrivileged );
  950. }
  951. /*-----------------------------------------------------------*/
  952. BaseType_t MPU_xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer )
  953. {
  954. BaseType_t xReturn;
  955. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  956. xReturn = xStreamBufferIsFull( xStreamBuffer );
  957. vPortResetPrivilege( xRunningPrivileged );
  958. return xReturn;
  959. }
  960. /*-----------------------------------------------------------*/
  961. BaseType_t MPU_xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer )
  962. {
  963. BaseType_t xReturn;
  964. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  965. xReturn = xStreamBufferIsEmpty( xStreamBuffer );
  966. vPortResetPrivilege( xRunningPrivileged );
  967. return xReturn;
  968. }
  969. /*-----------------------------------------------------------*/
  970. BaseType_t MPU_xStreamBufferReset( StreamBufferHandle_t xStreamBuffer )
  971. {
  972. BaseType_t xReturn;
  973. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  974. xReturn = xStreamBufferReset( xStreamBuffer );
  975. vPortResetPrivilege( xRunningPrivileged );
  976. return xReturn;
  977. }
  978. /*-----------------------------------------------------------*/
  979. size_t MPU_xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer )
  980. {
  981. size_t xReturn;
  982. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  983. xReturn = xStreamBufferSpacesAvailable( xStreamBuffer );
  984. vPortResetPrivilege( xRunningPrivileged );
  985. return xReturn;
  986. }
  987. /*-----------------------------------------------------------*/
  988. size_t MPU_xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer )
  989. {
  990. size_t xReturn;
  991. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  992. xReturn = xStreamBufferBytesAvailable( xStreamBuffer );
  993. vPortResetPrivilege( xRunningPrivileged );
  994. return xReturn;
  995. }
  996. /*-----------------------------------------------------------*/
  997. BaseType_t MPU_xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel )
  998. {
  999. BaseType_t xReturn;
  1000. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  1001. xReturn = xStreamBufferSetTriggerLevel( xStreamBuffer, xTriggerLevel );
  1002. vPortResetPrivilege( xRunningPrivileged );
  1003. return xReturn;
  1004. }
  1005. /*-----------------------------------------------------------*/
  1006. #if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
  1007. StreamBufferHandle_t MPU_xStreamBufferGenericCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer )
  1008. {
  1009. StreamBufferHandle_t xReturn;
  1010. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  1011. xReturn = xStreamBufferGenericCreate( xBufferSizeBytes, xTriggerLevelBytes, xIsMessageBuffer );
  1012. vPortResetPrivilege( xRunningPrivileged );
  1013. return xReturn;
  1014. }
  1015. #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
  1016. /*-----------------------------------------------------------*/
  1017. #if( configSUPPORT_STATIC_ALLOCATION == 1 )
  1018. StreamBufferHandle_t MPU_xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes, size_t xTriggerLevelBytes, BaseType_t xIsMessageBuffer, uint8_t * const pucStreamBufferStorageArea, StaticStreamBuffer_t * const pxStaticStreamBuffer )
  1019. {
  1020. StreamBufferHandle_t xReturn;
  1021. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  1022. xReturn = xStreamBufferGenericCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, xIsMessageBuffer, pucStreamBufferStorageArea, pxStaticStreamBuffer );
  1023. vPortResetPrivilege( xRunningPrivileged );
  1024. return xReturn;
  1025. }
  1026. #endif /* configSUPPORT_STATIC_ALLOCATION */
  1027. /*-----------------------------------------------------------*/
  1028. /* Functions that the application writer wants to execute in privileged mode
  1029. can be defined in application_defined_privileged_functions.h. The functions
  1030. must take the same format as those above whereby the privilege state on exit
  1031. equals the privilege state on entry. For example:
  1032. void MPU_FunctionName( [parameters ] )
  1033. {
  1034. BaseType_t xRunningPrivileged = xPortRaisePrivilege();
  1035. FunctionName( [parameters ] );
  1036. vPortResetPrivilege( xRunningPrivileged );
  1037. }
  1038. */
  1039. #if configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS == 1
  1040. #include "application_defined_privileged_functions.h"
  1041. #endif