mpu_wrappers_v2.c 223 KB

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