tx_api.h 119 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391
  1. /***************************************************************************
  2. * Copyright (c) 2024 Microsoft Corporation
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the MIT License which is available at
  6. * https://opensource.org/licenses/MIT.
  7. *
  8. * SPDX-License-Identifier: MIT
  9. **************************************************************************/
  10. /**************************************************************************/
  11. /**************************************************************************/
  12. /** */
  13. /** ThreadX Component */
  14. /** */
  15. /** Application Interface (API) */
  16. /** */
  17. /**************************************************************************/
  18. /**************************************************************************/
  19. /**************************************************************************/
  20. /* */
  21. /* APPLICATION INTERFACE DEFINITION RELEASE */
  22. /* */
  23. /* tx_api.h PORTABLE C */
  24. /* 6.4.1 */
  25. /* AUTHOR */
  26. /* */
  27. /* William E. Lamie, Microsoft Corporation */
  28. /* */
  29. /* DESCRIPTION */
  30. /* */
  31. /* This file defines the basic Application Interface (API) to the */
  32. /* high-performance ThreadX real-time kernel. All service prototypes */
  33. /* and data structure definitions are defined in this file. */
  34. /* Please note that basic data type definitions and other architecture-*/
  35. /* specific information is contained in the file tx_port.h. */
  36. /* */
  37. /* RELEASE HISTORY */
  38. /* */
  39. /* DATE NAME DESCRIPTION */
  40. /* */
  41. /* 05-19-2020 William E. Lamie Initial Version 6.0 */
  42. /* 09-30-2020 William E. Lamie Modified comment(s), and */
  43. /* updated product constants, */
  44. /* added new thread execution */
  45. /* state TX_PRIORITY_CHANGE, */
  46. /* added macros for casting */
  47. /* pointers to ALIGN_TYPE, */
  48. /* resulting in version 6.1 */
  49. /* 10-16-2020 William E. Lamie Modified comment(s), and */
  50. /* increased patch version, */
  51. /* resulting in version 6.1.1 */
  52. /* 11-09-2020 Yuxin Zhou Modified comment(s), and */
  53. /* moved TX_THREAD_GET_SYSTEM_ */
  54. /* STATE to tx_api.h, */
  55. /* resulting in version 6.1.2 */
  56. /* 12-31-2020 William E. Lamie Modified comment(s), and */
  57. /* increased patch version, */
  58. /* resulting in version 6.1.3 */
  59. /* 03-02-2021 Scott Larson Modified comment(s), and */
  60. /* order defines numerically, */
  61. /* add option to remove FileX */
  62. /* pointer, */
  63. /* resulting in version 6.1.5 */
  64. /* 04-02-2021 Scott Larson Modified comment(s), and */
  65. /* update patch number, */
  66. /* resulting in version 6.1.6 */
  67. /* 06-02-2021 Yuxin Zhou Modified comment(s), added */
  68. /* Execution Profile support, */
  69. /* resulting in version 6.1.7 */
  70. /* 08-02-2021 Scott Larson Modified comment(s), and */
  71. /* update patch number, */
  72. /* resulting in version 6.1.8 */
  73. /* 10-15-2021 Yuxin Zhou Modified comment(s), */
  74. /* update patch number, */
  75. /* resulting in version 6.1.9 */
  76. /* 01-31-2022 Scott Larson Modified comment(s), */
  77. /* add unused parameter macro, */
  78. /* update patch number, */
  79. /* resulting in version 6.1.10 */
  80. /* 04-25-2022 Wenhui Xie Modified comment(s), */
  81. /* optimized the definition of */
  82. /* TX_TIMER_TICKS_PER_SECOND, */
  83. /* resulting in version 6.1.11 */
  84. /* 07-29-2022 Scott Larson Modified comment(s), */
  85. /* update patch number, */
  86. /* resulting in version 6.1.12 */
  87. /* 10-31-2022 Scott Larson Modified comment(s), */
  88. /* add extension macros, */
  89. /* update EPK typedef, */
  90. /* update version numbers, */
  91. /* resulting in version 6.2.0 */
  92. /* 03-08-2023 Tiejun Zhou Modified comment(s), */
  93. /* update patch number, */
  94. /* resulting in version 6.2.1 */
  95. /* 10-31-2023 Xiuwen Cai Modified comment(s), */
  96. /* added option for random */
  97. /* number stack filling, */
  98. /* resulting in version 6.3.0 */
  99. /* 12-31-2023 Tiejun Zhou Modified comment(s), */
  100. /* update version number, */
  101. /* resulting in version 6.4.0 */
  102. /* 03-01-2024 Tiejun Zhou Modified comment(s), */
  103. /* update version number, */
  104. /* resulting in version 6.4.1 */
  105. /* */
  106. /**************************************************************************/
  107. #ifndef TX_API_H
  108. #define TX_API_H
  109. /* Determine if a C++ compiler is being used. If so, ensure that standard
  110. C is used to process the API information. */
  111. #ifdef __cplusplus
  112. /* Yes, C++ compiler is present. Use standard C. */
  113. extern "C" {
  114. #endif
  115. /* Disable warning of parameter not used. */
  116. #ifndef TX_PARAMETER_NOT_USED
  117. #define TX_PARAMETER_NOT_USED(p) ((void)(p))
  118. #endif /* TX_PARAMETER_NOT_USED */
  119. /* Include the port-specific data type file. */
  120. #include "tx_port.h"
  121. #if (defined(TX_EXECUTION_PROFILE_ENABLE) && !defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY))
  122. #include "tx_execution_profile.h"
  123. #endif
  124. /* Define basic constants for the ThreadX kernel. */
  125. /* Define the major/minor version information that can be used by the application
  126. and the ThreadX source as well. */
  127. #define AZURE_RTOS_THREADX
  128. #define THREADX_MAJOR_VERSION 6
  129. #define THREADX_MINOR_VERSION 4
  130. #define THREADX_PATCH_VERSION 1
  131. /* Define the following symbol for backward compatibility */
  132. #define EL_PRODUCT_THREADX
  133. /* API input parameters and general constants. */
  134. #define TX_NO_WAIT ((ULONG) 0)
  135. #define TX_WAIT_FOREVER ((ULONG) 0xFFFFFFFFUL)
  136. #define TX_AND ((UINT) 2)
  137. #define TX_AND_CLEAR ((UINT) 3)
  138. #define TX_OR ((UINT) 0)
  139. #define TX_OR_CLEAR ((UINT) 1)
  140. #define TX_1_ULONG ((UINT) 1)
  141. #define TX_2_ULONG ((UINT) 2)
  142. #define TX_4_ULONG ((UINT) 4)
  143. #define TX_8_ULONG ((UINT) 8)
  144. #define TX_16_ULONG ((UINT) 16)
  145. #define TX_NO_TIME_SLICE ((ULONG) 0)
  146. #define TX_AUTO_START ((UINT) 1)
  147. #define TX_DONT_START ((UINT) 0)
  148. #define TX_AUTO_ACTIVATE ((UINT) 1)
  149. #define TX_NO_ACTIVATE ((UINT) 0)
  150. #define TX_TRUE ((UINT) 1)
  151. #define TX_FALSE ((UINT) 0)
  152. #define TX_NULL ((void *) 0)
  153. #define TX_INHERIT ((UINT) 1)
  154. #define TX_NO_INHERIT ((UINT) 0)
  155. #define TX_THREAD_ENTRY ((UINT) 0)
  156. #define TX_THREAD_EXIT ((UINT) 1)
  157. #define TX_NO_SUSPENSIONS ((UINT) 0)
  158. #define TX_NO_MESSAGES ((UINT) 0)
  159. #define TX_EMPTY ((ULONG) 0)
  160. #define TX_CLEAR_ID ((ULONG) 0)
  161. #if defined(TX_ENABLE_RANDOM_NUMBER_STACK_FILLING) && defined(TX_ENABLE_STACK_CHECKING)
  162. #define TX_STACK_FILL (thread_ptr -> tx_thread_stack_fill_value)
  163. #else
  164. #define TX_STACK_FILL ((ULONG) 0xEFEFEFEFUL)
  165. #endif
  166. /* Thread execution state values. */
  167. #define TX_READY ((UINT) 0)
  168. #define TX_COMPLETED ((UINT) 1)
  169. #define TX_TERMINATED ((UINT) 2)
  170. #define TX_SUSPENDED ((UINT) 3)
  171. #define TX_SLEEP ((UINT) 4)
  172. #define TX_QUEUE_SUSP ((UINT) 5)
  173. #define TX_SEMAPHORE_SUSP ((UINT) 6)
  174. #define TX_EVENT_FLAG ((UINT) 7)
  175. #define TX_BLOCK_MEMORY ((UINT) 8)
  176. #define TX_BYTE_MEMORY ((UINT) 9)
  177. #define TX_IO_DRIVER ((UINT) 10)
  178. #define TX_FILE ((UINT) 11)
  179. #define TX_TCP_IP ((UINT) 12)
  180. #define TX_MUTEX_SUSP ((UINT) 13)
  181. #define TX_PRIORITY_CHANGE ((UINT) 14)
  182. /* API return values. */
  183. #define TX_SUCCESS ((UINT) 0x00)
  184. #define TX_DELETED ((UINT) 0x01)
  185. #define TX_POOL_ERROR ((UINT) 0x02)
  186. #define TX_PTR_ERROR ((UINT) 0x03)
  187. #define TX_WAIT_ERROR ((UINT) 0x04)
  188. #define TX_SIZE_ERROR ((UINT) 0x05)
  189. #define TX_GROUP_ERROR ((UINT) 0x06)
  190. #define TX_NO_EVENTS ((UINT) 0x07)
  191. #define TX_OPTION_ERROR ((UINT) 0x08)
  192. #define TX_QUEUE_ERROR ((UINT) 0x09)
  193. #define TX_QUEUE_EMPTY ((UINT) 0x0A)
  194. #define TX_QUEUE_FULL ((UINT) 0x0B)
  195. #define TX_SEMAPHORE_ERROR ((UINT) 0x0C)
  196. #define TX_NO_INSTANCE ((UINT) 0x0D)
  197. #define TX_THREAD_ERROR ((UINT) 0x0E)
  198. #define TX_PRIORITY_ERROR ((UINT) 0x0F)
  199. #define TX_NO_MEMORY ((UINT) 0x10)
  200. #define TX_START_ERROR ((UINT) 0x10)
  201. #define TX_DELETE_ERROR ((UINT) 0x11)
  202. #define TX_RESUME_ERROR ((UINT) 0x12)
  203. #define TX_CALLER_ERROR ((UINT) 0x13)
  204. #define TX_SUSPEND_ERROR ((UINT) 0x14)
  205. #define TX_TIMER_ERROR ((UINT) 0x15)
  206. #define TX_TICK_ERROR ((UINT) 0x16)
  207. #define TX_ACTIVATE_ERROR ((UINT) 0x17)
  208. #define TX_THRESH_ERROR ((UINT) 0x18)
  209. #define TX_SUSPEND_LIFTED ((UINT) 0x19)
  210. #define TX_WAIT_ABORTED ((UINT) 0x1A)
  211. #define TX_WAIT_ABORT_ERROR ((UINT) 0x1B)
  212. #define TX_MUTEX_ERROR ((UINT) 0x1C)
  213. #define TX_NOT_AVAILABLE ((UINT) 0x1D)
  214. #define TX_NOT_OWNED ((UINT) 0x1E)
  215. #define TX_INHERIT_ERROR ((UINT) 0x1F)
  216. #define TX_NOT_DONE ((UINT) 0x20)
  217. #define TX_CEILING_EXCEEDED ((UINT) 0x21)
  218. #define TX_INVALID_CEILING ((UINT) 0x22)
  219. #define TX_FEATURE_NOT_ENABLED ((UINT) 0xFF)
  220. #ifdef TX_64_BIT
  221. #ifndef TX_THREAD_EXTENSION_PTR_SET
  222. #define TX_THREAD_EXTENSION_PTR_SET(a, b) { \
  223. TX_THREAD *thread_ptr; \
  224. thread_ptr = (TX_THREAD *) (a); \
  225. (thread_ptr -> tx_thread_extension_ptr) = (VOID *)(b); \
  226. }
  227. #endif /* TX_THREAD_EXTENSION_PTR_SET */
  228. #ifndef TX_THREAD_EXTENSION_PTR_GET
  229. #define TX_THREAD_EXTENSION_PTR_GET(a, b, c) { \
  230. TX_PARAMETER_NOT_USED(c); \
  231. TX_THREAD *thread_ptr; \
  232. thread_ptr = tx_thread_identify(); \
  233. while(1)\
  234. { \
  235. if (thread_ptr -> tx_thread_extension_ptr) \
  236. { \
  237. (a) = (b *)(thread_ptr -> tx_thread_extension_ptr); \
  238. break; \
  239. } \
  240. tx_thread_sleep(1); \
  241. } \
  242. }
  243. #endif /* TX_THREAD_EXTENSION_PTR_GET */
  244. #ifndef TX_TIMER_EXTENSION_PTR_SET
  245. #define TX_TIMER_EXTENSION_PTR_SET(a, b) { \
  246. TX_TIMER *timer_ptr; \
  247. timer_ptr = (TX_TIMER *) (a); \
  248. (timer_ptr -> tx_timer_internal.tx_timer_internal_extension_ptr) = (VOID *)(b); \
  249. }
  250. #endif /* TX_TIMER_EXTENSION_PTR_SET */
  251. #ifndef TX_TIMER_EXTENSION_PTR_GET
  252. #define TX_TIMER_EXTENSION_PTR_GET(a, b, c) { \
  253. TX_PARAMETER_NOT_USED(c); \
  254. if (!_tx_timer_expired_timer_ptr -> tx_timer_internal_extension_ptr) \
  255. return; \
  256. (a) = (b *)(_tx_timer_expired_timer_ptr -> tx_timer_internal_extension_ptr); \
  257. }
  258. #endif /* TX_TIMER_EXTENSION_PTR_GET */
  259. #else /* not 64 bit */
  260. #ifndef TX_THREAD_EXTENSION_PTR_SET
  261. #define TX_THREAD_EXTENSION_PTR_SET(a, b)
  262. #endif /* TX_THREAD_EXTENSION_PTR_SET */
  263. #ifndef TX_THREAD_EXTENSION_PTR_GET
  264. #define TX_THREAD_EXTENSION_PTR_GET(a, b, c) { \
  265. (a) = (b *)(c); \
  266. }
  267. #endif /* TX_THREAD_EXTENSION_PTR_GET */
  268. #ifndef TX_TIMER_EXTENSION_PTR_SET
  269. #define TX_TIMER_EXTENSION_PTR_SET(a, b)
  270. #endif /* TX_TIMER_EXTENSION_PTR_SET */
  271. #ifndef TX_TIMER_EXTENSION_PTR_GET
  272. #define TX_TIMER_EXTENSION_PTR_GET(a, b, c) { \
  273. (a) = (b *)(c); \
  274. }
  275. #endif /* TX_TIMER_EXTENSION_PTR_GET */
  276. #endif /* TX_64_BIT */
  277. /* Define the common timer tick reference for use by other middleware components. The default
  278. value is 10ms, but may be replaced by a port specific version in tx_port.h or by the user
  279. as a compilation option. */
  280. #ifndef TX_TIMER_TICKS_PER_SECOND
  281. #define TX_TIMER_TICKS_PER_SECOND (100UL)
  282. #endif
  283. /* Event numbers 0 through 4095 are reserved by Azure RTOS. Specific event assignments are:
  284. ThreadX events: 1-199
  285. FileX events: 200-299
  286. NetX events: 300-599
  287. USBX events: 600-999
  288. GUIX events: 1000-1500
  289. User-defined event numbers start at 4096 and continue through 65535, as defined by the constants
  290. TX_TRACE_USER_EVENT_START and TX_TRACE_USER_EVENT_END, respectively. User events should be based
  291. on these constants in case the user event number assignment is changed in future releases. */
  292. #define TX_TRACE_USER_EVENT_START 4096 /* I1, I2, I3, I4 are user defined */
  293. #define TX_TRACE_USER_EVENT_END 65535 /* I1, I2, I3, I4 are user defined */
  294. /* Define event filters that can be used to selectively disable certain events or groups of events. */
  295. #define TX_TRACE_ALL_EVENTS 0x000007FF /* All ThreadX events */
  296. #define TX_TRACE_INTERNAL_EVENTS 0x00000001 /* ThreadX internal events */
  297. #define TX_TRACE_BLOCK_POOL_EVENTS 0x00000002 /* ThreadX Block Pool events */
  298. #define TX_TRACE_BYTE_POOL_EVENTS 0x00000004 /* ThreadX Byte Pool events */
  299. #define TX_TRACE_EVENT_FLAGS_EVENTS 0x00000008 /* ThreadX Event Flags events */
  300. #define TX_TRACE_INTERRUPT_CONTROL_EVENT 0x00000010 /* ThreadX Interrupt Control events */
  301. #define TX_TRACE_MUTEX_EVENTS 0x00000020 /* ThreadX Mutex events */
  302. #define TX_TRACE_QUEUE_EVENTS 0x00000040 /* ThreadX Queue events */
  303. #define TX_TRACE_SEMAPHORE_EVENTS 0x00000080 /* ThreadX Semaphore events */
  304. #define TX_TRACE_THREAD_EVENTS 0x00000100 /* ThreadX Thread events */
  305. #define TX_TRACE_TIME_EVENTS 0x00000200 /* ThreadX Time events */
  306. #define TX_TRACE_TIMER_EVENTS 0x00000400 /* ThreadX Timer events */
  307. #define TX_TRACE_USER_EVENTS 0x80000000UL /* ThreadX User Events */
  308. /* Define basic alignment type used in block and byte pool operations. This data type must
  309. be at least 32-bits in size and also be large enough to hold a pointer type. */
  310. #ifndef ALIGN_TYPE_DEFINED
  311. #define ALIGN_TYPE ULONG
  312. #endif
  313. /* Define the control block definitions for all system objects. */
  314. /* Define the basic timer management structures. These are the structures
  315. used to manage thread sleep, timeout, and user timer requests. */
  316. /* Determine if the internal timer control block has an extension defined. If not,
  317. define the extension to whitespace. */
  318. #ifndef TX_TIMER_INTERNAL_EXTENSION
  319. #define TX_TIMER_INTERNAL_EXTENSION
  320. #endif
  321. /* Define the common internal timer control block. */
  322. typedef struct TX_TIMER_INTERNAL_STRUCT
  323. {
  324. /* Define the remaining ticks and re-initialization tick values. */
  325. ULONG tx_timer_internal_remaining_ticks;
  326. ULONG tx_timer_internal_re_initialize_ticks;
  327. /* Define the timeout function and timeout function parameter. */
  328. VOID (*tx_timer_internal_timeout_function)(ULONG id);
  329. ULONG tx_timer_internal_timeout_param;
  330. /* Define the next and previous internal link pointers for active
  331. internal timers. */
  332. struct TX_TIMER_INTERNAL_STRUCT
  333. *tx_timer_internal_active_next,
  334. *tx_timer_internal_active_previous;
  335. /* Keep track of the pointer to the head of this list as well. */
  336. struct TX_TIMER_INTERNAL_STRUCT
  337. **tx_timer_internal_list_head;
  338. /* Define optional extension to internal timer control block. */
  339. TX_TIMER_INTERNAL_EXTENSION
  340. } TX_TIMER_INTERNAL;
  341. /* Determine if the timer control block has an extension defined. If not,
  342. define the extension to whitespace. */
  343. #ifndef TX_TIMER_EXTENSION
  344. #define TX_TIMER_EXTENSION
  345. #endif
  346. /* Define the timer structure utilized by the application. */
  347. typedef struct TX_TIMER_STRUCT
  348. {
  349. /* Define the timer ID used for error checking. */
  350. ULONG tx_timer_id;
  351. /* Define the timer's name. */
  352. CHAR *tx_timer_name;
  353. /* Define the actual contents of the timer. This is the block that
  354. is used in the actual timer expiration processing. */
  355. TX_TIMER_INTERNAL tx_timer_internal;
  356. /* Define the pointers for the created list. */
  357. struct TX_TIMER_STRUCT
  358. *tx_timer_created_next,
  359. *tx_timer_created_previous;
  360. /* Define optional extension to timer control block. */
  361. TX_TIMER_EXTENSION
  362. #ifdef TX_TIMER_ENABLE_PERFORMANCE_INFO
  363. /* Define the number of timer activations. */
  364. ULONG tx_timer_performance_activate_count;
  365. /* Define the number of timer reactivations. */
  366. ULONG tx_timer_performance_reactivate_count;
  367. /* Define the number of timer deactivations. */
  368. ULONG tx_timer_performance_deactivate_count;
  369. /* Define the number of timer expirations. */
  370. ULONG tx_timer_performance_expiration_count;
  371. /* Define the total number of timer expiration adjustments. */
  372. ULONG tx_timer_performance__expiration_adjust_count;
  373. #endif
  374. } TX_TIMER;
  375. /* ThreadX thread control block structure follows. Additional fields
  376. can be added providing they are added after the information that is
  377. referenced in the port-specific assembly code. */
  378. typedef struct TX_THREAD_STRUCT
  379. {
  380. /* The first section of the control block contains critical
  381. information that is referenced by the port-specific
  382. assembly language code. Any changes in this section could
  383. necessitate changes in the assembly language. */
  384. ULONG tx_thread_id; /* Control block ID */
  385. ULONG tx_thread_run_count; /* Thread's run counter */
  386. VOID *tx_thread_stack_ptr; /* Thread's stack pointer */
  387. VOID *tx_thread_stack_start; /* Stack starting address */
  388. VOID *tx_thread_stack_end; /* Stack ending address */
  389. ULONG tx_thread_stack_size; /* Stack size */
  390. ULONG tx_thread_time_slice; /* Current time-slice */
  391. ULONG tx_thread_new_time_slice; /* New time-slice */
  392. /* Define pointers to the next and previous ready threads. */
  393. struct TX_THREAD_STRUCT
  394. *tx_thread_ready_next,
  395. *tx_thread_ready_previous;
  396. /***************************************************************/
  397. /* Define the first port extension in the thread control block. This
  398. is typically defined to whitespace or a pointer type in tx_port.h. */
  399. TX_THREAD_EXTENSION_0
  400. CHAR *tx_thread_name; /* Pointer to thread's name */
  401. UINT tx_thread_priority; /* Priority of thread (0-1023) */
  402. UINT tx_thread_state; /* Thread's execution state */
  403. UINT tx_thread_delayed_suspend; /* Delayed suspend flag */
  404. UINT tx_thread_suspending; /* Thread suspending flag */
  405. UINT tx_thread_preempt_threshold; /* Preemption threshold */
  406. /* Define the thread schedule hook. The usage of this is port/application specific,
  407. but when used, the function pointer designated is called whenever the thread is
  408. scheduled and unscheduled. */
  409. VOID (*tx_thread_schedule_hook)(struct TX_THREAD_STRUCT *thread_ptr, ULONG id);
  410. /* Nothing after this point is referenced by the target-specific
  411. assembly language. Hence, information after this point can
  412. be added to the control block providing the complete system
  413. is recompiled. */
  414. /* Define the thread's entry point and input parameter. */
  415. VOID (*tx_thread_entry)(ULONG id);
  416. ULONG tx_thread_entry_parameter;
  417. /* Define the thread's timer block. This is used for thread
  418. sleep and timeout requests. */
  419. TX_TIMER_INTERNAL tx_thread_timer;
  420. /* Define the thread's cleanup function and associated data. This
  421. is used to cleanup various data structures when a thread
  422. suspension is lifted or terminated either by the user or
  423. a timeout. */
  424. VOID (*tx_thread_suspend_cleanup)(struct TX_THREAD_STRUCT *thread_ptr, ULONG suspension_sequence);
  425. VOID *tx_thread_suspend_control_block;
  426. struct TX_THREAD_STRUCT
  427. *tx_thread_suspended_next,
  428. *tx_thread_suspended_previous;
  429. ULONG tx_thread_suspend_info;
  430. VOID *tx_thread_additional_suspend_info;
  431. UINT tx_thread_suspend_option;
  432. UINT tx_thread_suspend_status;
  433. /* Define the second port extension in the thread control block. This
  434. is typically defined to whitespace or a pointer type in tx_port.h. */
  435. TX_THREAD_EXTENSION_1
  436. /* Define pointers to the next and previous threads in the
  437. created list. */
  438. struct TX_THREAD_STRUCT
  439. *tx_thread_created_next,
  440. *tx_thread_created_previous;
  441. /* Define the third port extension in the thread control block. This
  442. is typically defined to whitespace in tx_port.h. */
  443. TX_THREAD_EXTENSION_2
  444. /* Define a pointer type for FileX extensions. */
  445. #ifndef TX_NO_FILEX_POINTER
  446. VOID *tx_thread_filex_ptr;
  447. #endif
  448. /* Define the priority inheritance variables. These will be used
  449. to manage priority inheritance changes applied to this thread
  450. as a result of mutex get operations. */
  451. UINT tx_thread_user_priority;
  452. UINT tx_thread_user_preempt_threshold;
  453. UINT tx_thread_inherit_priority;
  454. /* Define the owned mutex count and list head pointer. */
  455. UINT tx_thread_owned_mutex_count;
  456. struct TX_MUTEX_STRUCT
  457. *tx_thread_owned_mutex_list;
  458. #ifdef TX_THREAD_ENABLE_PERFORMANCE_INFO
  459. /* Define the number of times this thread is resumed. */
  460. ULONG tx_thread_performance_resume_count;
  461. /* Define the number of times this thread suspends. */
  462. ULONG tx_thread_performance_suspend_count;
  463. /* Define the number of times this thread is preempted by calling
  464. a ThreadX API service. */
  465. ULONG tx_thread_performance_solicited_preemption_count;
  466. /* Define the number of times this thread is preempted by an
  467. ISR calling a ThreadX API service. */
  468. ULONG tx_thread_performance_interrupt_preemption_count;
  469. /* Define the number of priority inversions for this thread. */
  470. ULONG tx_thread_performance_priority_inversion_count;
  471. /* Define the last thread pointer to preempt this thread. */
  472. struct TX_THREAD_STRUCT
  473. *tx_thread_performance_last_preempting_thread;
  474. /* Define the total number of times this thread was time-sliced. */
  475. ULONG tx_thread_performance_time_slice_count;
  476. /* Define the total number of times this thread relinquishes. */
  477. ULONG tx_thread_performance_relinquish_count;
  478. /* Define the total number of times this thread had a timeout. */
  479. ULONG tx_thread_performance_timeout_count;
  480. /* Define the total number of times this thread had suspension lifted
  481. because of the tx_thread_wait_abort service. */
  482. ULONG tx_thread_performance_wait_abort_count;
  483. #endif
  484. /* Define the highest stack pointer variable. */
  485. VOID *tx_thread_stack_highest_ptr; /* Stack highest usage pointer */
  486. #ifndef TX_DISABLE_NOTIFY_CALLBACKS
  487. /* Define the application callback routine used to notify the application when
  488. the thread is entered or exits. */
  489. VOID (*tx_thread_entry_exit_notify)(struct TX_THREAD_STRUCT *thread_ptr, UINT type);
  490. #endif
  491. /* Define the fourth port extension in the thread control block. This
  492. is typically defined to whitespace in tx_port.h. */
  493. TX_THREAD_EXTENSION_3
  494. /* Define variables for supporting execution profile. */
  495. /* Note that in ThreadX 5.x, user would define TX_ENABLE_EXECUTION_CHANGE_NOTIFY and use TX_THREAD_EXTENSION_3
  496. to define the following two variables.
  497. For Azure RTOS 6, user shall use TX_EXECUTION_PROFILE_ENABLE instead of TX_ENABLE_EXECUTION_CHANGE_NOTIFY,
  498. and SHALL NOT add variables to TX_THREAD_EXTENSION_3. */
  499. #if (defined(TX_EXECUTION_PROFILE_ENABLE) && !defined(TX_ENABLE_EXECUTION_CHANGE_NOTIFY))
  500. EXECUTION_TIME tx_thread_execution_time_total;
  501. EXECUTION_TIME_SOURCE_TYPE tx_thread_execution_time_last_start;
  502. #endif
  503. /* Define suspension sequence number. This is used to ensure suspension is still valid when
  504. cleanup routine executes. */
  505. ULONG tx_thread_suspension_sequence;
  506. #if defined(TX_ENABLE_RANDOM_NUMBER_STACK_FILLING) && defined(TX_ENABLE_STACK_CHECKING)
  507. /* Define the random stack fill number. This can be used to detect stack overflow. */
  508. ULONG tx_thread_stack_fill_value;
  509. #endif
  510. /* Define the user extension field. This typically is defined
  511. to white space, but some ports of ThreadX may need to have
  512. additional fields in the thread control block. This is
  513. defined in the file tx_port.h. */
  514. TX_THREAD_USER_EXTENSION
  515. } TX_THREAD;
  516. /* Define the block memory pool structure utilized by the application. */
  517. typedef struct TX_BLOCK_POOL_STRUCT
  518. {
  519. /* Define the block pool ID used for error checking. */
  520. ULONG tx_block_pool_id;
  521. /* Define the block pool's name. */
  522. CHAR *tx_block_pool_name;
  523. /* Define the number of available memory blocks in the pool. */
  524. UINT tx_block_pool_available;
  525. /* Save the initial number of blocks. */
  526. UINT tx_block_pool_total;
  527. /* Define the head pointer of the available block pool. */
  528. UCHAR *tx_block_pool_available_list;
  529. /* Save the start address of the block pool's memory area. */
  530. UCHAR *tx_block_pool_start;
  531. /* Save the block pool's size in bytes. */
  532. ULONG tx_block_pool_size;
  533. /* Save the individual memory block size - rounded for alignment. */
  534. UINT tx_block_pool_block_size;
  535. /* Define the block pool suspension list head along with a count of
  536. how many threads are suspended. */
  537. struct TX_THREAD_STRUCT
  538. *tx_block_pool_suspension_list;
  539. UINT tx_block_pool_suspended_count;
  540. /* Define the created list next and previous pointers. */
  541. struct TX_BLOCK_POOL_STRUCT
  542. *tx_block_pool_created_next,
  543. *tx_block_pool_created_previous;
  544. #ifdef TX_BLOCK_POOL_ENABLE_PERFORMANCE_INFO
  545. /* Define the number of block allocates. */
  546. ULONG tx_block_pool_performance_allocate_count;
  547. /* Define the number of block releases. */
  548. ULONG tx_block_pool_performance_release_count;
  549. /* Define the number of block pool suspensions. */
  550. ULONG tx_block_pool_performance_suspension_count;
  551. /* Define the number of block pool timeouts. */
  552. ULONG tx_block_pool_performance_timeout_count;
  553. #endif
  554. /* Define the port extension in the block pool control block. This
  555. is typically defined to whitespace in tx_port.h. */
  556. TX_BLOCK_POOL_EXTENSION
  557. } TX_BLOCK_POOL;
  558. /* Determine if the byte allocate extension is defined. If not, define the
  559. extension to whitespace. */
  560. #ifndef TX_BYTE_ALLOCATE_EXTENSION
  561. #define TX_BYTE_ALLOCATE_EXTENSION
  562. #endif
  563. /* Determine if the byte release extension is defined. If not, define the
  564. extension to whitespace. */
  565. #ifndef TX_BYTE_RELEASE_EXTENSION
  566. #define TX_BYTE_RELEASE_EXTENSION
  567. #endif
  568. /* Define the byte memory pool structure utilized by the application. */
  569. typedef struct TX_BYTE_POOL_STRUCT
  570. {
  571. /* Define the byte pool ID used for error checking. */
  572. ULONG tx_byte_pool_id;
  573. /* Define the byte pool's name. */
  574. CHAR *tx_byte_pool_name;
  575. /* Define the number of available bytes in the pool. */
  576. ULONG tx_byte_pool_available;
  577. /* Define the number of fragments in the pool. */
  578. UINT tx_byte_pool_fragments;
  579. /* Define the head pointer of byte pool. */
  580. UCHAR *tx_byte_pool_list;
  581. /* Define the search pointer used for initial searching for memory
  582. in a byte pool. */
  583. UCHAR *tx_byte_pool_search;
  584. /* Save the start address of the byte pool's memory area. */
  585. UCHAR *tx_byte_pool_start;
  586. /* Save the byte pool's size in bytes. */
  587. ULONG tx_byte_pool_size;
  588. /* This is used to mark the owner of the byte memory pool during
  589. a search. If this value changes during the search, the local search
  590. pointer must be reset. */
  591. struct TX_THREAD_STRUCT
  592. *tx_byte_pool_owner;
  593. /* Define the byte pool suspension list head along with a count of
  594. how many threads are suspended. */
  595. struct TX_THREAD_STRUCT
  596. *tx_byte_pool_suspension_list;
  597. UINT tx_byte_pool_suspended_count;
  598. /* Define the created list next and previous pointers. */
  599. struct TX_BYTE_POOL_STRUCT
  600. *tx_byte_pool_created_next,
  601. *tx_byte_pool_created_previous;
  602. #ifdef TX_BYTE_POOL_ENABLE_PERFORMANCE_INFO
  603. /* Define the number of allocates. */
  604. ULONG tx_byte_pool_performance_allocate_count;
  605. /* Define the number of releases. */
  606. ULONG tx_byte_pool_performance_release_count;
  607. /* Define the number of adjacent memory fragment merges. */
  608. ULONG tx_byte_pool_performance_merge_count;
  609. /* Define the number of memory fragment splits. */
  610. ULONG tx_byte_pool_performance_split_count;
  611. /* Define the number of memory fragments searched that either were not free or could not satisfy the
  612. request. */
  613. ULONG tx_byte_pool_performance_search_count;
  614. /* Define the number of byte pool suspensions. */
  615. ULONG tx_byte_pool_performance_suspension_count;
  616. /* Define the number of byte pool timeouts. */
  617. ULONG tx_byte_pool_performance_timeout_count;
  618. #endif
  619. /* Define the port extension in the byte pool control block. This
  620. is typically defined to whitespace in tx_port.h. */
  621. TX_BYTE_POOL_EXTENSION
  622. } TX_BYTE_POOL;
  623. /* Define the event flags group structure utilized by the application. */
  624. typedef struct TX_EVENT_FLAGS_GROUP_STRUCT
  625. {
  626. /* Define the event flags group ID used for error checking. */
  627. ULONG tx_event_flags_group_id;
  628. /* Define the event flags group's name. */
  629. CHAR *tx_event_flags_group_name;
  630. /* Define the actual current event flags in this group. A zero in a
  631. particular bit indicates the event flag is not set. */
  632. ULONG tx_event_flags_group_current;
  633. /* Define the reset search flag that is set when an ISR sets flags during
  634. the search of the suspended threads list. */
  635. UINT tx_event_flags_group_reset_search;
  636. /* Define the event flags group suspension list head along with a count of
  637. how many threads are suspended. */
  638. struct TX_THREAD_STRUCT
  639. *tx_event_flags_group_suspension_list;
  640. UINT tx_event_flags_group_suspended_count;
  641. /* Define the created list next and previous pointers. */
  642. struct TX_EVENT_FLAGS_GROUP_STRUCT
  643. *tx_event_flags_group_created_next,
  644. *tx_event_flags_group_created_previous;
  645. /* Define the delayed clearing event flags. */
  646. ULONG tx_event_flags_group_delayed_clear;
  647. #ifdef TX_EVENT_FLAGS_ENABLE_PERFORMANCE_INFO
  648. /* Define the number of event flag sets. */
  649. ULONG tx_event_flags_group_performance_set_count;
  650. /* Define the number of event flag gets. */
  651. ULONG tx_event_flags_group__performance_get_count;
  652. /* Define the number of event flag suspensions. */
  653. ULONG tx_event_flags_group___performance_suspension_count;
  654. /* Define the number of event flag timeouts. */
  655. ULONG tx_event_flags_group____performance_timeout_count;
  656. #endif
  657. #ifndef TX_DISABLE_NOTIFY_CALLBACKS
  658. /* Define the application callback routine used to notify the application when
  659. an event flag is set. */
  660. VOID (*tx_event_flags_group_set_notify)(struct TX_EVENT_FLAGS_GROUP_STRUCT *group_ptr);
  661. #endif
  662. /* Define the port extension in the event flags group control block. This
  663. is typically defined to whitespace in tx_port.h. */
  664. TX_EVENT_FLAGS_GROUP_EXTENSION
  665. } TX_EVENT_FLAGS_GROUP;
  666. /* Determine if the mutex put extension 1 is defined. If not, define the
  667. extension to whitespace. */
  668. #ifndef TX_MUTEX_PUT_EXTENSION_1
  669. #define TX_MUTEX_PUT_EXTENSION_1
  670. #endif
  671. /* Determine if the mutex put extension 2 is defined. If not, define the
  672. extension to whitespace. */
  673. #ifndef TX_MUTEX_PUT_EXTENSION_2
  674. #define TX_MUTEX_PUT_EXTENSION_2
  675. #endif
  676. /* Determine if the mutex priority change extension is defined. If not, define the
  677. extension to whitespace. */
  678. #ifndef TX_MUTEX_PRIORITY_CHANGE_EXTENSION
  679. #define TX_MUTEX_PRIORITY_CHANGE_EXTENSION
  680. #endif
  681. /* Define the mutex structure utilized by the application. */
  682. typedef struct TX_MUTEX_STRUCT
  683. {
  684. /* Define the mutex ID used for error checking. */
  685. ULONG tx_mutex_id;
  686. /* Define the mutex's name. */
  687. CHAR *tx_mutex_name;
  688. /* Define the mutex ownership count. */
  689. UINT tx_mutex_ownership_count;
  690. /* Define the mutex ownership pointer. This pointer points to the
  691. the thread that owns the mutex. */
  692. TX_THREAD *tx_mutex_owner;
  693. /* Define the priority inheritance flag. If this flag is set, priority
  694. inheritance will be in effect. */
  695. UINT tx_mutex_inherit;
  696. /* Define the save area for the owning thread's original priority. */
  697. UINT tx_mutex_original_priority;
  698. /* Define the mutex suspension list head along with a count of
  699. how many threads are suspended. */
  700. struct TX_THREAD_STRUCT
  701. *tx_mutex_suspension_list;
  702. UINT tx_mutex_suspended_count;
  703. /* Define the created list next and previous pointers. */
  704. struct TX_MUTEX_STRUCT
  705. *tx_mutex_created_next,
  706. *tx_mutex_created_previous;
  707. /* Define the priority of the highest priority thread waiting for
  708. this mutex. */
  709. UINT tx_mutex_highest_priority_waiting;
  710. /* Define the owned list next and previous pointers. */
  711. struct TX_MUTEX_STRUCT
  712. *tx_mutex_owned_next,
  713. *tx_mutex_owned_previous;
  714. #ifdef TX_MUTEX_ENABLE_PERFORMANCE_INFO
  715. /* Define the number of mutex puts. */
  716. ULONG tx_mutex_performance_put_count;
  717. /* Define the total number of mutex gets. */
  718. ULONG tx_mutex_performance_get_count;
  719. /* Define the total number of mutex suspensions. */
  720. ULONG tx_mutex_performance_suspension_count;
  721. /* Define the total number of mutex timeouts. */
  722. ULONG tx_mutex_performance_timeout_count;
  723. /* Define the total number of priority inversions. */
  724. ULONG tx_mutex_performance_priority_inversion_count;
  725. /* Define the total number of priority inheritance conditions. */
  726. ULONG tx_mutex_performance__priority_inheritance_count;
  727. #endif
  728. /* Define the port extension in the mutex control block. This
  729. is typically defined to whitespace in tx_port.h. */
  730. TX_MUTEX_EXTENSION
  731. } TX_MUTEX;
  732. /* Define the queue structure utilized by the application. */
  733. typedef struct TX_QUEUE_STRUCT
  734. {
  735. /* Define the queue ID used for error checking. */
  736. ULONG tx_queue_id;
  737. /* Define the queue's name. */
  738. CHAR *tx_queue_name;
  739. /* Define the message size that was specified in queue creation. */
  740. UINT tx_queue_message_size;
  741. /* Define the total number of messages in the queue. */
  742. UINT tx_queue_capacity;
  743. /* Define the current number of messages enqueued and the available
  744. queue storage space. */
  745. UINT tx_queue_enqueued;
  746. UINT tx_queue_available_storage;
  747. /* Define pointers that represent the start and end for the queue's
  748. message area. */
  749. ULONG *tx_queue_start;
  750. ULONG *tx_queue_end;
  751. /* Define the queue read and write pointers. Send requests use the write
  752. pointer while receive requests use the read pointer. */
  753. ULONG *tx_queue_read;
  754. ULONG *tx_queue_write;
  755. /* Define the queue suspension list head along with a count of
  756. how many threads are suspended. */
  757. struct TX_THREAD_STRUCT
  758. *tx_queue_suspension_list;
  759. UINT tx_queue_suspended_count;
  760. /* Define the created list next and previous pointers. */
  761. struct TX_QUEUE_STRUCT
  762. *tx_queue_created_next,
  763. *tx_queue_created_previous;
  764. #ifdef TX_QUEUE_ENABLE_PERFORMANCE_INFO
  765. /* Define the number of messages sent to this queue. */
  766. ULONG tx_queue_performance_messages_sent_count;
  767. /* Define the number of messages received from this queue. */
  768. ULONG tx_queue_performance_messages_received_count;
  769. /* Define the number of empty suspensions on this queue. */
  770. ULONG tx_queue_performance_empty_suspension_count;
  771. /* Define the number of full suspensions on this queue. */
  772. ULONG tx_queue_performance_full_suspension_count;
  773. /* Define the number of full non-suspensions on this queue. These
  774. messages are rejected with an appropriate error code. */
  775. ULONG tx_queue_performance_full_error_count;
  776. /* Define the number of queue timeouts. */
  777. ULONG tx_queue_performance_timeout_count;
  778. #endif
  779. #ifndef TX_DISABLE_NOTIFY_CALLBACKS
  780. /* Define the application callback routine used to notify the application when
  781. the a message is sent to the queue. */
  782. VOID (*tx_queue_send_notify)(struct TX_QUEUE_STRUCT *queue_ptr);
  783. #endif
  784. /* Define the port extension in the queue control block. This
  785. is typically defined to whitespace in tx_port.h. */
  786. TX_QUEUE_EXTENSION
  787. } TX_QUEUE;
  788. /* Define the semaphore structure utilized by the application. */
  789. typedef struct TX_SEMAPHORE_STRUCT
  790. {
  791. /* Define the semaphore ID used for error checking. */
  792. ULONG tx_semaphore_id;
  793. /* Define the semaphore's name. */
  794. CHAR *tx_semaphore_name;
  795. /* Define the actual semaphore count. A zero means that no semaphore
  796. instance is available. */
  797. ULONG tx_semaphore_count;
  798. /* Define the semaphore suspension list head along with a count of
  799. how many threads are suspended. */
  800. struct TX_THREAD_STRUCT
  801. *tx_semaphore_suspension_list;
  802. UINT tx_semaphore_suspended_count;
  803. /* Define the created list next and previous pointers. */
  804. struct TX_SEMAPHORE_STRUCT
  805. *tx_semaphore_created_next,
  806. *tx_semaphore_created_previous;
  807. #ifdef TX_SEMAPHORE_ENABLE_PERFORMANCE_INFO
  808. /* Define the number of semaphore puts. */
  809. ULONG tx_semaphore_performance_put_count;
  810. /* Define the number of semaphore gets. */
  811. ULONG tx_semaphore_performance_get_count;
  812. /* Define the number of semaphore suspensions. */
  813. ULONG tx_semaphore_performance_suspension_count;
  814. /* Define the number of semaphore timeouts. */
  815. ULONG tx_semaphore_performance_timeout_count;
  816. #endif
  817. #ifndef TX_DISABLE_NOTIFY_CALLBACKS
  818. /* Define the application callback routine used to notify the application when
  819. the a semaphore is put. */
  820. VOID (*tx_semaphore_put_notify)(struct TX_SEMAPHORE_STRUCT *semaphore_ptr);
  821. #endif
  822. /* Define the port extension in the semaphore control block. This
  823. is typically defined to whitespace in tx_port.h. */
  824. TX_SEMAPHORE_EXTENSION
  825. } TX_SEMAPHORE;
  826. /* Define the system API mappings based on the error checking
  827. selected by the user. Note: this section is only applicable to
  828. application source code, hence the conditional that turns off this
  829. stuff when the include file is processed by the ThreadX source. */
  830. #ifndef TX_SOURCE_CODE
  831. /* Determine if error checking is desired. If so, map API functions
  832. to the appropriate error checking front-ends. Otherwise, map API
  833. functions to the core functions that actually perform the work.
  834. Note: error checking is enabled by default. */
  835. #ifdef TX_DISABLE_ERROR_CHECKING
  836. /* Services without error checking. */
  837. #define tx_kernel_enter _tx_initialize_kernel_enter
  838. #define tx_block_allocate _tx_block_allocate
  839. #define tx_block_pool_create _tx_block_pool_create
  840. #define tx_block_pool_delete _tx_block_pool_delete
  841. #define tx_block_pool_info_get _tx_block_pool_info_get
  842. #define tx_block_pool_performance_info_get _tx_block_pool_performance_info_get
  843. #define tx_block_pool_performance_system_info_get _tx_block_pool_performance_system_info_get
  844. #define tx_block_pool_prioritize _tx_block_pool_prioritize
  845. #define tx_block_release _tx_block_release
  846. #define tx_byte_allocate _tx_byte_allocate
  847. #define tx_byte_pool_create _tx_byte_pool_create
  848. #define tx_byte_pool_delete _tx_byte_pool_delete
  849. #define tx_byte_pool_info_get _tx_byte_pool_info_get
  850. #define tx_byte_pool_performance_info_get _tx_byte_pool_performance_info_get
  851. #define tx_byte_pool_performance_system_info_get _tx_byte_pool_performance_system_info_get
  852. #define tx_byte_pool_prioritize _tx_byte_pool_prioritize
  853. #define tx_byte_release _tx_byte_release
  854. #define tx_event_flags_create _tx_event_flags_create
  855. #define tx_event_flags_delete _tx_event_flags_delete
  856. #define tx_event_flags_get _tx_event_flags_get
  857. #define tx_event_flags_info_get _tx_event_flags_info_get
  858. #define tx_event_flags_performance_info_get _tx_event_flags_performance_info_get
  859. #define tx_event_flags_performance_system_info_get _tx_event_flags_performance_system_info_get
  860. #define tx_event_flags_set _tx_event_flags_set
  861. #define tx_event_flags_set_notify _tx_event_flags_set_notify
  862. #ifdef TX_ENABLE_EVENT_LOGGING
  863. UINT _tx_el_interrupt_control(UINT new_posture);
  864. #define tx_interrupt_control _tx_el_interrupt_control
  865. #else
  866. #ifdef TX_ENABLE_EVENT_TRACE
  867. UINT _tx_trace_interrupt_control(UINT new_posture);
  868. #define tx_interrupt_control _tx_trace_interrupt_control
  869. #else
  870. #define tx_interrupt_control _tx_thread_interrupt_control
  871. #endif
  872. #endif
  873. #define tx_mutex_create _tx_mutex_create
  874. #define tx_mutex_delete _tx_mutex_delete
  875. #define tx_mutex_get _tx_mutex_get
  876. #define tx_mutex_info_get _tx_mutex_info_get
  877. #define tx_mutex_performance_info_get _tx_mutex_performance_info_get
  878. #define tx_mutex_performance_system_info_get _tx_mutex_performance_system_info_get
  879. #define tx_mutex_prioritize _tx_mutex_prioritize
  880. #define tx_mutex_put _tx_mutex_put
  881. #define tx_queue_create _tx_queue_create
  882. #define tx_queue_delete _tx_queue_delete
  883. #define tx_queue_flush _tx_queue_flush
  884. #define tx_queue_info_get _tx_queue_info_get
  885. #define tx_queue_performance_info_get _tx_queue_performance_info_get
  886. #define tx_queue_performance_system_info_get _tx_queue_performance_system_info_get
  887. #define tx_queue_receive _tx_queue_receive
  888. #define tx_queue_send _tx_queue_send
  889. #define tx_queue_send_notify _tx_queue_send_notify
  890. #define tx_queue_front_send _tx_queue_front_send
  891. #define tx_queue_prioritize _tx_queue_prioritize
  892. #define tx_semaphore_ceiling_put _tx_semaphore_ceiling_put
  893. #define tx_semaphore_create _tx_semaphore_create
  894. #define tx_semaphore_delete _tx_semaphore_delete
  895. #define tx_semaphore_get _tx_semaphore_get
  896. #define tx_semaphore_info_get _tx_semaphore_info_get
  897. #define tx_semaphore_performance_info_get _tx_semaphore_performance_info_get
  898. #define tx_semaphore_performance_system_info_get _tx_semaphore_performance_system_info_get
  899. #define tx_semaphore_prioritize _tx_semaphore_prioritize
  900. #define tx_semaphore_put _tx_semaphore_put
  901. #define tx_semaphore_put_notify _tx_semaphore_put_notify
  902. #define tx_thread_create _tx_thread_create
  903. #define tx_thread_delete _tx_thread_delete
  904. #define tx_thread_entry_exit_notify _tx_thread_entry_exit_notify
  905. #define tx_thread_identify _tx_thread_identify
  906. #define tx_thread_info_get _tx_thread_info_get
  907. #define tx_thread_performance_info_get _tx_thread_performance_info_get
  908. #define tx_thread_performance_system_info_get _tx_thread_performance_system_info_get
  909. #define tx_thread_preemption_change _tx_thread_preemption_change
  910. #define tx_thread_priority_change _tx_thread_priority_change
  911. #define tx_thread_relinquish _tx_thread_relinquish
  912. #define tx_thread_reset _tx_thread_reset
  913. #define tx_thread_resume _tx_thread_resume
  914. #define tx_thread_sleep _tx_thread_sleep
  915. #define tx_thread_stack_error_notify _tx_thread_stack_error_notify
  916. #define tx_thread_suspend _tx_thread_suspend
  917. #define tx_thread_terminate _tx_thread_terminate
  918. #define tx_thread_time_slice_change _tx_thread_time_slice_change
  919. #define tx_thread_wait_abort _tx_thread_wait_abort
  920. #define tx_time_get _tx_time_get
  921. #define tx_time_set _tx_time_set
  922. #define tx_timer_activate _tx_timer_activate
  923. #define tx_timer_change _tx_timer_change
  924. #define tx_timer_create _tx_timer_create
  925. #define tx_timer_deactivate _tx_timer_deactivate
  926. #define tx_timer_delete _tx_timer_delete
  927. #define tx_timer_info_get _tx_timer_info_get
  928. #define tx_timer_performance_info_get _tx_timer_performance_info_get
  929. #define tx_timer_performance_system_info_get _tx_timer_performance_system_info_get
  930. #define tx_trace_enable _tx_trace_enable
  931. #define tx_trace_event_filter _tx_trace_event_filter
  932. #define tx_trace_event_unfilter _tx_trace_event_unfilter
  933. #define tx_trace_disable _tx_trace_disable
  934. #define tx_trace_isr_enter_insert _tx_trace_isr_enter_insert
  935. #define tx_trace_isr_exit_insert _tx_trace_isr_exit_insert
  936. #define tx_trace_buffer_full_notify _tx_trace_buffer_full_notify
  937. #define tx_trace_user_event_insert _tx_trace_user_event_insert
  938. #else
  939. /* Services with error checking. */
  940. #define tx_kernel_enter _tx_initialize_kernel_enter
  941. /* Define the system API mappings depending on the runtime error
  942. checking behavior selected by the user. */
  943. #ifdef TX_ENABLE_MULTI_ERROR_CHECKING
  944. /* Services with MULTI runtime error checking ThreadX. */
  945. #define tx_block_allocate _txr_block_allocate
  946. #define tx_block_pool_create(p,n,b,s,l) _txr_block_pool_create((p),(n),(b),(s),(l),(sizeof(TX_BLOCK_POOL)))
  947. #define tx_block_pool_delete _txr_block_pool_delete
  948. #define tx_block_pool_info_get _txr_block_pool_info_get
  949. #define tx_block_pool_performance_info_get _tx_block_pool_performance_info_get
  950. #define tx_block_pool_performance_system_info_get _tx_block_pool_performance_system_info_get
  951. #define tx_block_pool_prioritize _txr_block_pool_prioritize
  952. #define tx_block_release _txr_block_release
  953. #define tx_byte_allocate _txr_byte_allocate
  954. #define tx_byte_pool_create(p,n,s,l) _txr_byte_pool_create((p),(n),(s),(l),(sizeof(TX_BYTE_POOL)))
  955. #define tx_byte_pool_delete _txr_byte_pool_delete
  956. #define tx_byte_pool_info_get _txr_byte_pool_info_get
  957. #define tx_byte_pool_performance_info_get _tx_byte_pool_performance_info_get
  958. #define tx_byte_pool_performance_system_info_get _tx_byte_pool_performance_system_info_get
  959. #define tx_byte_pool_prioritize _txr_byte_pool_prioritize
  960. #define tx_byte_release _txr_byte_release
  961. #define tx_event_flags_create(g,n) _txr_event_flags_create((g),(n),(sizeof(TX_EVENT_FLAGS_GROUP)))
  962. #define tx_event_flags_delete _txr_event_flags_delete
  963. #define tx_event_flags_get _txr_event_flags_get
  964. #define tx_event_flags_info_get _txr_event_flags_info_get
  965. #define tx_event_flags_performance_info_get _tx_event_flags_performance_info_get
  966. #define tx_event_flags_performance_system_info_get _tx_event_flags_performance_system_info_get
  967. #define tx_event_flags_set _txr_event_flags_set
  968. #define tx_event_flags_set_notify _txr_event_flags_set_notify
  969. #ifdef TX_ENABLE_EVENT_LOGGING
  970. UINT _tx_el_interrupt_control(UINT new_posture);
  971. #define tx_interrupt_control _tx_el_interrupt_control
  972. #else
  973. #ifdef TX_ENABLE_EVENT_TRACE
  974. UINT _tx_trace_interrupt_control(UINT new_posture);
  975. #define tx_interrupt_control _tx_trace_interrupt_control
  976. #else
  977. #define tx_interrupt_control _tx_thread_interrupt_control
  978. #endif
  979. #endif
  980. #define tx_mutex_create(m,n,i) _txr_mutex_create((m),(n),(i),(sizeof(TX_MUTEX)))
  981. #define tx_mutex_delete _txr_mutex_delete
  982. #define tx_mutex_get _txr_mutex_get
  983. #define tx_mutex_info_get _txr_mutex_info_get
  984. #define tx_mutex_performance_info_get _tx_mutex_performance_info_get
  985. #define tx_mutex_performance_system_info_get _tx_mutex_performance_system_info_get
  986. #define tx_mutex_prioritize _txr_mutex_prioritize
  987. #define tx_mutex_put _txr_mutex_put
  988. #define tx_queue_create(q,n,m,s,l) _txr_queue_create((q),(n),(m),(s),(l),(sizeof(TX_QUEUE)))
  989. #define tx_queue_delete _txr_queue_delete
  990. #define tx_queue_flush _txr_queue_flush
  991. #define tx_queue_info_get _txr_queue_info_get
  992. #define tx_queue_performance_info_get _tx_queue_performance_info_get
  993. #define tx_queue_performance_system_info_get _tx_queue_performance_system_info_get
  994. #define tx_queue_receive _txr_queue_receive
  995. #define tx_queue_send _txr_queue_send
  996. #define tx_queue_send_notify _txr_queue_send_notify
  997. #define tx_queue_front_send _txr_queue_front_send
  998. #define tx_queue_prioritize _txr_queue_prioritize
  999. #define tx_semaphore_ceiling_put _txr_semaphore_ceiling_put
  1000. #define tx_semaphore_create(s,n,i) _txr_semaphore_create((s),(n),(i),(sizeof(TX_SEMAPHORE)))
  1001. #define tx_semaphore_delete _txr_semaphore_delete
  1002. #define tx_semaphore_get _txr_semaphore_get
  1003. #define tx_semaphore_info_get _txr_semaphore_info_get
  1004. #define tx_semaphore_performance_info_get _tx_semaphore_performance_info_get
  1005. #define tx_semaphore_performance_system_info_get _tx_semaphore_performance_system_info_get
  1006. #define tx_semaphore_prioritize _txr_semaphore_prioritize
  1007. #define tx_semaphore_put _txr_semaphore_put
  1008. #define tx_semaphore_put_notify _txr_semaphore_put_notify
  1009. #define tx_thread_create(t,n,e,i,s,l,p,r,c,a) _txr_thread_create((t),(n),(e),(i),(s),(l),(p),(r),(c),(a),(sizeof(TX_THREAD)))
  1010. #define tx_thread_delete _txr_thread_delete
  1011. #define tx_thread_entry_exit_notify _txr_thread_entry_exit_notify
  1012. #define tx_thread_identify _tx_thread_identify
  1013. #define tx_thread_info_get _txr_thread_info_get
  1014. #define tx_thread_performance_info_get _tx_thread_performance_info_get
  1015. #define tx_thread_performance_system_info_get _tx_thread_performance_system_info_get
  1016. #define tx_thread_preemption_change _txr_thread_preemption_change
  1017. #define tx_thread_priority_change _txr_thread_priority_change
  1018. #define tx_thread_relinquish _txe_thread_relinquish
  1019. #define tx_thread_reset _txr_thread_reset
  1020. #define tx_thread_resume _txr_thread_resume
  1021. #define tx_thread_sleep _tx_thread_sleep
  1022. #define tx_thread_stack_error_notify _tx_thread_stack_error_notify
  1023. #define tx_thread_suspend _txr_thread_suspend
  1024. #define tx_thread_terminate _txr_thread_terminate
  1025. #define tx_thread_time_slice_change _txr_thread_time_slice_change
  1026. #define tx_thread_wait_abort _txr_thread_wait_abort
  1027. #define tx_time_get _tx_time_get
  1028. #define tx_time_set _tx_time_set
  1029. #define tx_timer_activate _txr_timer_activate
  1030. #define tx_timer_change _txr_timer_change
  1031. #define tx_timer_create(t,n,e,i,c,r,a) _txr_timer_create((t),(n),(e),(i),(c),(r),(a),(sizeof(TX_TIMER)))
  1032. #define tx_timer_deactivate _txr_timer_deactivate
  1033. #define tx_timer_delete _txr_timer_delete
  1034. #define tx_timer_info_get _txr_timer_info_get
  1035. #define tx_timer_performance_info_get _tx_timer_performance_info_get
  1036. #define tx_timer_performance_system_info_get _tx_timer_performance_system_info_get
  1037. #define tx_trace_enable _tx_trace_enable
  1038. #define tx_trace_event_filter _tx_trace_event_filter
  1039. #define tx_trace_event_unfilter _tx_trace_event_unfilter
  1040. #define tx_trace_disable _tx_trace_disable
  1041. #define tx_trace_isr_enter_insert _tx_trace_isr_enter_insert
  1042. #define tx_trace_isr_exit_insert _tx_trace_isr_exit_insert
  1043. #define tx_trace_buffer_full_notify _tx_trace_buffer_full_notify
  1044. #define tx_trace_user_event_insert _tx_trace_user_event_insert
  1045. #else
  1046. #define tx_block_allocate _txe_block_allocate
  1047. #define tx_block_pool_create(p,n,b,s,l) _txe_block_pool_create((p),(n),(b),(s),(l),(sizeof(TX_BLOCK_POOL)))
  1048. #define tx_block_pool_delete _txe_block_pool_delete
  1049. #define tx_block_pool_info_get _txe_block_pool_info_get
  1050. #define tx_block_pool_performance_info_get _tx_block_pool_performance_info_get
  1051. #define tx_block_pool_performance_system_info_get _tx_block_pool_performance_system_info_get
  1052. #define tx_block_pool_prioritize _txe_block_pool_prioritize
  1053. #define tx_block_release _txe_block_release
  1054. #define tx_byte_allocate _txe_byte_allocate
  1055. #define tx_byte_pool_create(p,n,s,l) _txe_byte_pool_create((p),(n),(s),(l),(sizeof(TX_BYTE_POOL)))
  1056. #define tx_byte_pool_delete _txe_byte_pool_delete
  1057. #define tx_byte_pool_info_get _txe_byte_pool_info_get
  1058. #define tx_byte_pool_performance_info_get _tx_byte_pool_performance_info_get
  1059. #define tx_byte_pool_performance_system_info_get _tx_byte_pool_performance_system_info_get
  1060. #define tx_byte_pool_prioritize _txe_byte_pool_prioritize
  1061. #define tx_byte_release _txe_byte_release
  1062. #define tx_event_flags_create(g,n) _txe_event_flags_create((g),(n),(sizeof(TX_EVENT_FLAGS_GROUP)))
  1063. #define tx_event_flags_delete _txe_event_flags_delete
  1064. #define tx_event_flags_get _txe_event_flags_get
  1065. #define tx_event_flags_info_get _txe_event_flags_info_get
  1066. #define tx_event_flags_performance_info_get _tx_event_flags_performance_info_get
  1067. #define tx_event_flags_performance_system_info_get _tx_event_flags_performance_system_info_get
  1068. #define tx_event_flags_set _txe_event_flags_set
  1069. #define tx_event_flags_set_notify _txe_event_flags_set_notify
  1070. #ifdef TX_ENABLE_EVENT_LOGGING
  1071. UINT _tx_el_interrupt_control(UINT new_posture);
  1072. #define tx_interrupt_control _tx_el_interrupt_control
  1073. #else
  1074. #ifdef TX_ENABLE_EVENT_TRACE
  1075. #define tx_interrupt_control _tx_trace_interrupt_control
  1076. #else
  1077. #define tx_interrupt_control _tx_thread_interrupt_control
  1078. #endif
  1079. #endif
  1080. #define tx_mutex_create(m,n,i) _txe_mutex_create((m),(n),(i),(sizeof(TX_MUTEX)))
  1081. #define tx_mutex_delete _txe_mutex_delete
  1082. #define tx_mutex_get _txe_mutex_get
  1083. #define tx_mutex_info_get _txe_mutex_info_get
  1084. #define tx_mutex_performance_info_get _tx_mutex_performance_info_get
  1085. #define tx_mutex_performance_system_info_get _tx_mutex_performance_system_info_get
  1086. #define tx_mutex_prioritize _txe_mutex_prioritize
  1087. #define tx_mutex_put _txe_mutex_put
  1088. #define tx_queue_create(q,n,m,s,l) _txe_queue_create((q),(n),(m),(s),(l),(sizeof(TX_QUEUE)))
  1089. #define tx_queue_delete _txe_queue_delete
  1090. #define tx_queue_flush _txe_queue_flush
  1091. #define tx_queue_info_get _txe_queue_info_get
  1092. #define tx_queue_performance_info_get _tx_queue_performance_info_get
  1093. #define tx_queue_performance_system_info_get _tx_queue_performance_system_info_get
  1094. #define tx_queue_receive _txe_queue_receive
  1095. #define tx_queue_send _txe_queue_send
  1096. #define tx_queue_send_notify _txe_queue_send_notify
  1097. #define tx_queue_front_send _txe_queue_front_send
  1098. #define tx_queue_prioritize _txe_queue_prioritize
  1099. #define tx_semaphore_ceiling_put _txe_semaphore_ceiling_put
  1100. #define tx_semaphore_create(s,n,i) _txe_semaphore_create((s),(n),(i),(sizeof(TX_SEMAPHORE)))
  1101. #define tx_semaphore_delete _txe_semaphore_delete
  1102. #define tx_semaphore_get _txe_semaphore_get
  1103. #define tx_semaphore_info_get _txe_semaphore_info_get
  1104. #define tx_semaphore_performance_info_get _tx_semaphore_performance_info_get
  1105. #define tx_semaphore_performance_system_info_get _tx_semaphore_performance_system_info_get
  1106. #define tx_semaphore_prioritize _txe_semaphore_prioritize
  1107. #define tx_semaphore_put _txe_semaphore_put
  1108. #define tx_semaphore_put_notify _txe_semaphore_put_notify
  1109. #define tx_thread_create(t,n,e,i,s,l,p,r,c,a) _txe_thread_create((t),(n),(e),(i),(s),(l),(p),(r),(c),(a),(sizeof(TX_THREAD)))
  1110. #define tx_thread_delete _txe_thread_delete
  1111. #define tx_thread_entry_exit_notify _txe_thread_entry_exit_notify
  1112. #define tx_thread_identify _tx_thread_identify
  1113. #define tx_thread_info_get _txe_thread_info_get
  1114. #define tx_thread_performance_info_get _tx_thread_performance_info_get
  1115. #define tx_thread_performance_system_info_get _tx_thread_performance_system_info_get
  1116. #define tx_thread_preemption_change _txe_thread_preemption_change
  1117. #define tx_thread_priority_change _txe_thread_priority_change
  1118. #define tx_thread_relinquish _txe_thread_relinquish
  1119. #define tx_thread_reset _txe_thread_reset
  1120. #define tx_thread_resume _txe_thread_resume
  1121. #define tx_thread_sleep _tx_thread_sleep
  1122. #define tx_thread_stack_error_notify _tx_thread_stack_error_notify
  1123. #define tx_thread_suspend _txe_thread_suspend
  1124. #define tx_thread_terminate _txe_thread_terminate
  1125. #define tx_thread_time_slice_change _txe_thread_time_slice_change
  1126. #define tx_thread_wait_abort _txe_thread_wait_abort
  1127. #define tx_time_get _tx_time_get
  1128. #define tx_time_set _tx_time_set
  1129. #define tx_timer_activate _txe_timer_activate
  1130. #define tx_timer_change _txe_timer_change
  1131. #define tx_timer_create(t,n,e,i,c,r,a) _txe_timer_create((t),(n),(e),(i),(c),(r),(a),(sizeof(TX_TIMER)))
  1132. #define tx_timer_deactivate _txe_timer_deactivate
  1133. #define tx_timer_delete _txe_timer_delete
  1134. #define tx_timer_info_get _txe_timer_info_get
  1135. #define tx_timer_performance_info_get _tx_timer_performance_info_get
  1136. #define tx_timer_performance_system_info_get _tx_timer_performance_system_info_get
  1137. #define tx_trace_enable _tx_trace_enable
  1138. #define tx_trace_event_filter _tx_trace_event_filter
  1139. #define tx_trace_event_unfilter _tx_trace_event_unfilter
  1140. #define tx_trace_disable _tx_trace_disable
  1141. #define tx_trace_isr_enter_insert _tx_trace_isr_enter_insert
  1142. #define tx_trace_isr_exit_insert _tx_trace_isr_exit_insert
  1143. #define tx_trace_buffer_full_notify _tx_trace_buffer_full_notify
  1144. #define tx_trace_user_event_insert _tx_trace_user_event_insert
  1145. #endif
  1146. #endif
  1147. #endif
  1148. /* Declare the tx_application_define function as having C linkage. */
  1149. VOID tx_application_define(VOID *first_unused_memory);
  1150. /* Define the function prototypes of the ThreadX API. */
  1151. /* Define block memory pool management function prototypes. */
  1152. UINT _tx_block_allocate(TX_BLOCK_POOL *pool_ptr, VOID **block_ptr, ULONG wait_option);
  1153. UINT _tx_block_pool_create(TX_BLOCK_POOL *pool_ptr, CHAR *name_ptr, ULONG block_size,
  1154. VOID *pool_start, ULONG pool_size);
  1155. UINT _tx_block_pool_delete(TX_BLOCK_POOL *pool_ptr);
  1156. UINT _tx_block_pool_info_get(TX_BLOCK_POOL *pool_ptr, CHAR **name, ULONG *available_blocks,
  1157. ULONG *total_blocks, TX_THREAD **first_suspended,
  1158. ULONG *suspended_count, TX_BLOCK_POOL **next_pool);
  1159. UINT _tx_block_pool_performance_info_get(TX_BLOCK_POOL *pool_ptr, ULONG *allocates, ULONG *releases,
  1160. ULONG *suspensions, ULONG *timeouts);
  1161. UINT _tx_block_pool_performance_system_info_get(ULONG *allocates, ULONG *releases,
  1162. ULONG *suspensions, ULONG *timeouts);
  1163. UINT _tx_block_pool_prioritize(TX_BLOCK_POOL *pool_ptr);
  1164. UINT _tx_block_release(VOID *block_ptr);
  1165. /* Define error checking shells for API services. These are only referenced by the
  1166. application. */
  1167. UINT _txe_block_allocate(TX_BLOCK_POOL *pool_ptr, VOID **block_ptr, ULONG wait_option);
  1168. UINT _txe_block_pool_create(TX_BLOCK_POOL *pool_ptr, CHAR *name_ptr, ULONG block_size,
  1169. VOID *pool_start, ULONG pool_size, UINT pool_control_block_size);
  1170. UINT _txe_block_pool_delete(TX_BLOCK_POOL *pool_ptr);
  1171. UINT _txe_block_pool_info_get(TX_BLOCK_POOL *pool_ptr, CHAR **name, ULONG *available_blocks,
  1172. ULONG *total_blocks, TX_THREAD **first_suspended,
  1173. ULONG *suspended_count, TX_BLOCK_POOL **next_pool);
  1174. UINT _txe_block_pool_prioritize(TX_BLOCK_POOL *pool_ptr);
  1175. UINT _txe_block_release(VOID *block_ptr);
  1176. #ifdef TX_ENABLE_MULTI_ERROR_CHECKING
  1177. UINT _txr_block_allocate(TX_BLOCK_POOL *pool_ptr, VOID **block_ptr, ULONG wait_option);
  1178. UINT _txr_block_pool_create(TX_BLOCK_POOL *pool_ptr, CHAR *name_ptr, ULONG block_size,
  1179. VOID *pool_start, ULONG pool_size, UINT pool_control_block_size);
  1180. UINT _txr_block_pool_delete(TX_BLOCK_POOL *pool_ptr);
  1181. UINT _txr_block_pool_info_get(TX_BLOCK_POOL *pool_ptr, CHAR **name, ULONG *available_blocks,
  1182. ULONG *total_blocks, TX_THREAD **first_suspended,
  1183. ULONG *suspended_count, TX_BLOCK_POOL **next_pool);
  1184. UINT _txr_block_pool_prioritize(TX_BLOCK_POOL *pool_ptr);
  1185. UINT _txr_block_release(VOID *block_ptr);
  1186. #endif
  1187. /* Define byte memory pool management function prototypes. */
  1188. UINT _tx_byte_allocate(TX_BYTE_POOL *pool_ptr, VOID **memory_ptr, ULONG memory_size,
  1189. ULONG wait_option);
  1190. UINT _tx_byte_pool_create(TX_BYTE_POOL *pool_ptr, CHAR *name_ptr, VOID *pool_start,
  1191. ULONG pool_size);
  1192. UINT _tx_byte_pool_delete(TX_BYTE_POOL *pool_ptr);
  1193. UINT _tx_byte_pool_info_get(TX_BYTE_POOL *pool_ptr, CHAR **name, ULONG *available_bytes,
  1194. ULONG *fragments, TX_THREAD **first_suspended,
  1195. ULONG *suspended_count, TX_BYTE_POOL **next_pool);
  1196. UINT _tx_byte_pool_performance_info_get(TX_BYTE_POOL *pool_ptr, ULONG *allocates, ULONG *releases,
  1197. ULONG *fragments_searched, ULONG *merges, ULONG *splits, ULONG *suspensions, ULONG *timeouts);
  1198. UINT _tx_byte_pool_performance_system_info_get(ULONG *allocates, ULONG *releases,
  1199. ULONG *fragments_searched, ULONG *merges, ULONG *splits, ULONG *suspensions, ULONG *timeouts);
  1200. UINT _tx_byte_pool_prioritize(TX_BYTE_POOL *pool_ptr);
  1201. UINT _tx_byte_release(VOID *memory_ptr);
  1202. /* Define error checking shells for API services. These are only referenced by the
  1203. application. */
  1204. UINT _txe_byte_allocate(TX_BYTE_POOL *pool_ptr, VOID **memory_ptr, ULONG memory_size,
  1205. ULONG wait_option);
  1206. UINT _txe_byte_pool_create(TX_BYTE_POOL *pool_ptr, CHAR *name_ptr, VOID *pool_start,
  1207. ULONG pool_size, UINT pool_control_block_size);
  1208. UINT _txe_byte_pool_delete(TX_BYTE_POOL *pool_ptr);
  1209. UINT _txe_byte_pool_info_get(TX_BYTE_POOL *pool_ptr, CHAR **name, ULONG *available_bytes,
  1210. ULONG *fragments, TX_THREAD **first_suspended,
  1211. ULONG *suspended_count, TX_BYTE_POOL **next_pool);
  1212. UINT _txe_byte_pool_prioritize(TX_BYTE_POOL *pool_ptr);
  1213. UINT _txe_byte_release(VOID *memory_ptr);
  1214. #ifdef TX_ENABLE_MULTI_ERROR_CHECKING
  1215. UINT _txr_byte_allocate(TX_BYTE_POOL *pool_ptr, VOID **memory_ptr, ULONG memory_size,
  1216. ULONG wait_option);
  1217. UINT _txr_byte_pool_create(TX_BYTE_POOL *pool_ptr, CHAR *name_ptr, VOID *pool_start,
  1218. ULONG pool_size, UINT pool_control_block_size);
  1219. UINT _txr_byte_pool_delete(TX_BYTE_POOL *pool_ptr);
  1220. UINT _txr_byte_pool_info_get(TX_BYTE_POOL *pool_ptr, CHAR **name, ULONG *available_bytes,
  1221. ULONG *fragments, TX_THREAD **first_suspended,
  1222. ULONG *suspended_count, TX_BYTE_POOL **next_pool);
  1223. UINT _txr_byte_pool_prioritize(TX_BYTE_POOL *pool_ptr);
  1224. UINT _txr_byte_release(VOID *memory_ptr);
  1225. #endif
  1226. /* Define event flags management function prototypes. */
  1227. UINT _tx_event_flags_create(TX_EVENT_FLAGS_GROUP *group_ptr, CHAR *name_ptr);
  1228. UINT _tx_event_flags_delete(TX_EVENT_FLAGS_GROUP *group_ptr);
  1229. UINT _tx_event_flags_get(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG requested_flags,
  1230. UINT get_option, ULONG *actual_flags_ptr, ULONG wait_option);
  1231. UINT _tx_event_flags_info_get(TX_EVENT_FLAGS_GROUP *group_ptr, CHAR **name, ULONG *current_flags,
  1232. TX_THREAD **first_suspended, ULONG *suspended_count,
  1233. TX_EVENT_FLAGS_GROUP **next_group);
  1234. UINT _tx_event_flags_performance_info_get(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG *sets, ULONG *gets,
  1235. ULONG *suspensions, ULONG *timeouts);
  1236. UINT _tx_event_flags_performance_system_info_get(ULONG *sets, ULONG *gets,
  1237. ULONG *suspensions, ULONG *timeouts);
  1238. UINT _tx_event_flags_set(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG flags_to_set,
  1239. UINT set_option);
  1240. UINT _tx_event_flags_set_notify(TX_EVENT_FLAGS_GROUP *group_ptr, VOID (*events_set_notify)(TX_EVENT_FLAGS_GROUP *notify_group_ptr));
  1241. /* Define error checking shells for API services. These are only referenced by the
  1242. application. */
  1243. UINT _txe_event_flags_create(TX_EVENT_FLAGS_GROUP *group_ptr, CHAR *name_ptr, UINT event_control_block_size);
  1244. UINT _txe_event_flags_delete(TX_EVENT_FLAGS_GROUP *group_ptr);
  1245. UINT _txe_event_flags_get(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG requested_flags,
  1246. UINT get_option, ULONG *actual_flags_ptr, ULONG wait_option);
  1247. UINT _txe_event_flags_info_get(TX_EVENT_FLAGS_GROUP *group_ptr, CHAR **name, ULONG *current_flags,
  1248. TX_THREAD **first_suspended, ULONG *suspended_count,
  1249. TX_EVENT_FLAGS_GROUP **next_group);
  1250. UINT _txe_event_flags_set(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG flags_to_set,
  1251. UINT set_option);
  1252. UINT _txe_event_flags_set_notify(TX_EVENT_FLAGS_GROUP *group_ptr, VOID (*events_set_notify)(TX_EVENT_FLAGS_GROUP *notify_group_ptr));
  1253. #ifdef TX_ENABLE_MULTI_ERROR_CHECKING
  1254. UINT _txr_event_flags_create(TX_EVENT_FLAGS_GROUP *group_ptr, CHAR *name_ptr, UINT event_control_block_size);
  1255. UINT _txr_event_flags_delete(TX_EVENT_FLAGS_GROUP *group_ptr);
  1256. UINT _txr_event_flags_get(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG requested_flags,
  1257. UINT get_option, ULONG *actual_flags_ptr, ULONG wait_option);
  1258. UINT _txr_event_flags_info_get(TX_EVENT_FLAGS_GROUP *group_ptr, CHAR **name, ULONG *current_flags,
  1259. TX_THREAD **first_suspended, ULONG *suspended_count,
  1260. TX_EVENT_FLAGS_GROUP **next_group);
  1261. UINT _txr_event_flags_set(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG flags_to_set,
  1262. UINT set_option);
  1263. UINT _txr_event_flags_set_notify(TX_EVENT_FLAGS_GROUP *group_ptr, VOID (*events_set_notify)(TX_EVENT_FLAGS_GROUP *notify_group_ptr));
  1264. #endif
  1265. /* Define initialization function prototypes. */
  1266. VOID _tx_initialize_kernel_enter(VOID);
  1267. /* Define mutex management function prototypes. */
  1268. UINT _tx_mutex_create(TX_MUTEX *mutex_ptr, CHAR *name_ptr, UINT inherit);
  1269. UINT _tx_mutex_delete(TX_MUTEX *mutex_ptr);
  1270. UINT _tx_mutex_get(TX_MUTEX *mutex_ptr, ULONG wait_option);
  1271. UINT _tx_mutex_info_get(TX_MUTEX *mutex_ptr, CHAR **name, ULONG *count, TX_THREAD **owner,
  1272. TX_THREAD **first_suspended, ULONG *suspended_count,
  1273. TX_MUTEX **next_mutex);
  1274. UINT _tx_mutex_performance_info_get(TX_MUTEX *mutex_ptr, ULONG *puts, ULONG *gets,
  1275. ULONG *suspensions, ULONG *timeouts, ULONG *inversions, ULONG *inheritances);
  1276. UINT _tx_mutex_performance_system_info_get(ULONG *puts, ULONG *gets, ULONG *suspensions, ULONG *timeouts,
  1277. ULONG *inversions, ULONG *inheritances);
  1278. UINT _tx_mutex_prioritize(TX_MUTEX *mutex_ptr);
  1279. UINT _tx_mutex_put(TX_MUTEX *mutex_ptr);
  1280. /* Define error checking shells for API services. These are only referenced by the
  1281. application. */
  1282. UINT _txe_mutex_create(TX_MUTEX *mutex_ptr, CHAR *name_ptr, UINT inherit, UINT mutex_control_block_size);
  1283. UINT _txe_mutex_delete(TX_MUTEX *mutex_ptr);
  1284. UINT _txe_mutex_get(TX_MUTEX *mutex_ptr, ULONG wait_option);
  1285. UINT _txe_mutex_info_get(TX_MUTEX *mutex_ptr, CHAR **name, ULONG *count, TX_THREAD **owner,
  1286. TX_THREAD **first_suspended, ULONG *suspended_count,
  1287. TX_MUTEX **next_mutex);
  1288. UINT _txe_mutex_prioritize(TX_MUTEX *mutex_ptr);
  1289. UINT _txe_mutex_put(TX_MUTEX *mutex_ptr);
  1290. #ifdef TX_ENABLE_MULTI_ERROR_CHECKING
  1291. UINT _txr_mutex_create(TX_MUTEX *mutex_ptr, CHAR *name_ptr, UINT inherit, UINT mutex_control_block_size);
  1292. UINT _txr_mutex_delete(TX_MUTEX *mutex_ptr);
  1293. UINT _txr_mutex_get(TX_MUTEX *mutex_ptr, ULONG wait_option);
  1294. UINT _txr_mutex_info_get(TX_MUTEX *mutex_ptr, CHAR **name, ULONG *count, TX_THREAD **owner,
  1295. TX_THREAD **first_suspended, ULONG *suspended_count,
  1296. TX_MUTEX **next_mutex);
  1297. UINT _txr_mutex_prioritize(TX_MUTEX *mutex_ptr);
  1298. UINT _txr_mutex_put(TX_MUTEX *mutex_ptr);
  1299. #endif
  1300. /* Define queue management function prototypes. */
  1301. UINT _tx_queue_create(TX_QUEUE *queue_ptr, CHAR *name_ptr, UINT message_size,
  1302. VOID *queue_start, ULONG queue_size);
  1303. UINT _tx_queue_delete(TX_QUEUE *queue_ptr);
  1304. UINT _tx_queue_flush(TX_QUEUE *queue_ptr);
  1305. UINT _tx_queue_info_get(TX_QUEUE *queue_ptr, CHAR **name, ULONG *enqueued, ULONG *available_storage,
  1306. TX_THREAD **first_suspended, ULONG *suspended_count, TX_QUEUE **next_queue);
  1307. UINT _tx_queue_performance_info_get(TX_QUEUE *queue_ptr, ULONG *messages_sent, ULONG *messages_received,
  1308. ULONG *empty_suspensions, ULONG *full_suspensions, ULONG *full_errors, ULONG *timeouts);
  1309. UINT _tx_queue_performance_system_info_get(ULONG *messages_sent, ULONG *messages_received,
  1310. ULONG *empty_suspensions, ULONG *full_suspensions, ULONG *full_errors, ULONG *timeouts);
  1311. UINT _tx_queue_prioritize(TX_QUEUE *queue_ptr);
  1312. UINT _tx_queue_receive(TX_QUEUE *queue_ptr, VOID *destination_ptr, ULONG wait_option);
  1313. UINT _tx_queue_send(TX_QUEUE *queue_ptr, VOID *source_ptr, ULONG wait_option);
  1314. UINT _tx_queue_send_notify(TX_QUEUE *queue_ptr, VOID (*queue_send_notify)(TX_QUEUE *notify_queue_ptr));
  1315. UINT _tx_queue_front_send(TX_QUEUE *queue_ptr, VOID *source_ptr, ULONG wait_option);
  1316. /* Define error checking shells for API services. These are only referenced by the
  1317. application. */
  1318. UINT _txe_queue_create(TX_QUEUE *queue_ptr, CHAR *name_ptr, UINT message_size,
  1319. VOID *queue_start, ULONG queue_size, UINT queue_control_block_size);
  1320. UINT _txe_queue_delete(TX_QUEUE *queue_ptr);
  1321. UINT _txe_queue_flush(TX_QUEUE *queue_ptr);
  1322. UINT _txe_queue_info_get(TX_QUEUE *queue_ptr, CHAR **name, ULONG *enqueued, ULONG *available_storage,
  1323. TX_THREAD **first_suspended, ULONG *suspended_count, TX_QUEUE **next_queue);
  1324. UINT _txe_queue_prioritize(TX_QUEUE *queue_ptr);
  1325. UINT _txe_queue_receive(TX_QUEUE *queue_ptr, VOID *destination_ptr, ULONG wait_option);
  1326. UINT _txe_queue_send(TX_QUEUE *queue_ptr, VOID *source_ptr, ULONG wait_option);
  1327. UINT _txe_queue_send_notify(TX_QUEUE *queue_ptr, VOID (*queue_send_notify)(TX_QUEUE *notify_queue_ptr));
  1328. UINT _txe_queue_front_send(TX_QUEUE *queue_ptr, VOID *source_ptr, ULONG wait_option);
  1329. #ifdef TX_ENABLE_MULTI_ERROR_CHECKING
  1330. UINT _txr_queue_create(TX_QUEUE *queue_ptr, CHAR *name_ptr, UINT message_size,
  1331. VOID *queue_start, ULONG queue_size, UINT queue_control_block_size);
  1332. UINT _txr_queue_delete(TX_QUEUE *queue_ptr);
  1333. UINT _txr_queue_flush(TX_QUEUE *queue_ptr);
  1334. UINT _txr_queue_info_get(TX_QUEUE *queue_ptr, CHAR **name, ULONG *enqueued, ULONG *available_storage,
  1335. TX_THREAD **first_suspended, ULONG *suspended_count, TX_QUEUE **next_queue);
  1336. UINT _txr_queue_prioritize(TX_QUEUE *queue_ptr);
  1337. UINT _txr_queue_receive(TX_QUEUE *queue_ptr, VOID *destination_ptr, ULONG wait_option);
  1338. UINT _txr_queue_send(TX_QUEUE *queue_ptr, VOID *source_ptr, ULONG wait_option);
  1339. UINT _txr_queue_send_notify(TX_QUEUE *queue_ptr, VOID (*queue_send_notify)(TX_QUEUE *notify_queue_ptr));
  1340. UINT _txr_queue_front_send(TX_QUEUE *queue_ptr, VOID *source_ptr, ULONG wait_option);
  1341. #endif
  1342. /* Define semaphore management function prototypes. */
  1343. UINT _tx_semaphore_ceiling_put(TX_SEMAPHORE *semaphore_ptr, ULONG ceiling);
  1344. UINT _tx_semaphore_create(TX_SEMAPHORE *semaphore_ptr, CHAR *name_ptr, ULONG initial_count);
  1345. UINT _tx_semaphore_delete(TX_SEMAPHORE *semaphore_ptr);
  1346. UINT _tx_semaphore_get(TX_SEMAPHORE *semaphore_ptr, ULONG wait_option);
  1347. UINT _tx_semaphore_info_get(TX_SEMAPHORE *semaphore_ptr, CHAR **name, ULONG *current_value,
  1348. TX_THREAD **first_suspended, ULONG *suspended_count,
  1349. TX_SEMAPHORE **next_semaphore);
  1350. UINT _tx_semaphore_performance_info_get(TX_SEMAPHORE *semaphore_ptr, ULONG *puts, ULONG *gets,
  1351. ULONG *suspensions, ULONG *timeouts);
  1352. UINT _tx_semaphore_performance_system_info_get(ULONG *puts, ULONG *gets, ULONG *suspensions, ULONG *timeouts);
  1353. UINT _tx_semaphore_prioritize(TX_SEMAPHORE *semaphore_ptr);
  1354. UINT _tx_semaphore_put(TX_SEMAPHORE *semaphore_ptr);
  1355. UINT _tx_semaphore_put_notify(TX_SEMAPHORE *semaphore_ptr, VOID (*semaphore_put_notify)(TX_SEMAPHORE *notify_semaphore_ptr));
  1356. /* Define error checking shells for API services. These are only referenced by the
  1357. application. */
  1358. UINT _txe_semaphore_ceiling_put(TX_SEMAPHORE *semaphore_ptr, ULONG ceiling);
  1359. UINT _txe_semaphore_create(TX_SEMAPHORE *semaphore_ptr, CHAR *name_ptr, ULONG initial_count, UINT semaphore_control_block_size);
  1360. UINT _txe_semaphore_delete(TX_SEMAPHORE *semaphore_ptr);
  1361. UINT _txe_semaphore_get(TX_SEMAPHORE *semaphore_ptr, ULONG wait_option);
  1362. UINT _txe_semaphore_info_get(TX_SEMAPHORE *semaphore_ptr, CHAR **name, ULONG *current_value,
  1363. TX_THREAD **first_suspended, ULONG *suspended_count,
  1364. TX_SEMAPHORE **next_semaphore);
  1365. UINT _txe_semaphore_prioritize(TX_SEMAPHORE *semaphore_ptr);
  1366. UINT _txe_semaphore_put(TX_SEMAPHORE *semaphore_ptr);
  1367. UINT _txe_semaphore_put_notify(TX_SEMAPHORE *semaphore_ptr, VOID (*semaphore_put_notify)(TX_SEMAPHORE *notify_semaphore_ptr));
  1368. #ifdef TX_ENABLE_MULTI_ERROR_CHECKING
  1369. UINT _txr_semaphore_ceiling_put(TX_SEMAPHORE *semaphore_ptr, ULONG ceiling);
  1370. UINT _txr_semaphore_create(TX_SEMAPHORE *semaphore_ptr, CHAR *name_ptr, ULONG initial_count, UINT semaphore_control_block_size);
  1371. UINT _txr_semaphore_delete(TX_SEMAPHORE *semaphore_ptr);
  1372. UINT _txr_semaphore_get(TX_SEMAPHORE *semaphore_ptr, ULONG wait_option);
  1373. UINT _txr_semaphore_info_get(TX_SEMAPHORE *semaphore_ptr, CHAR **name, ULONG *current_value,
  1374. TX_THREAD **first_suspended, ULONG *suspended_count,
  1375. TX_SEMAPHORE **next_semaphore);
  1376. UINT _txr_semaphore_prioritize(TX_SEMAPHORE *semaphore_ptr);
  1377. UINT _txr_semaphore_put(TX_SEMAPHORE *semaphore_ptr);
  1378. UINT _txr_semaphore_put_notify(TX_SEMAPHORE *semaphore_ptr, VOID (*semaphore_put_notify)(TX_SEMAPHORE *notify_semaphore_ptr));
  1379. #endif
  1380. /* Define thread control function prototypes. */
  1381. VOID _tx_thread_context_save(VOID);
  1382. VOID _tx_thread_context_restore(VOID);
  1383. UINT _tx_thread_create(TX_THREAD *thread_ptr, CHAR *name_ptr,
  1384. VOID (*entry_function)(ULONG entry_input), ULONG entry_input,
  1385. VOID *stack_start, ULONG stack_size,
  1386. UINT priority, UINT preempt_threshold,
  1387. ULONG time_slice, UINT auto_start);
  1388. UINT _tx_thread_delete(TX_THREAD *thread_ptr);
  1389. UINT _tx_thread_entry_exit_notify(TX_THREAD *thread_ptr, VOID (*thread_entry_exit_notify)(TX_THREAD *notify_thread_ptr, UINT type));
  1390. TX_THREAD *_tx_thread_identify(VOID);
  1391. UINT _tx_thread_info_get(TX_THREAD *thread_ptr, CHAR **name, UINT *state, ULONG *run_count,
  1392. UINT *priority, UINT *preemption_threshold, ULONG *time_slice,
  1393. TX_THREAD **next_thread, TX_THREAD **next_suspended_thread);
  1394. UINT _tx_thread_interrupt_control(UINT new_posture);
  1395. UINT _tx_thread_performance_info_get(TX_THREAD *thread_ptr, ULONG *resumptions, ULONG *suspensions,
  1396. ULONG *solicited_preemptions, ULONG *interrupt_preemptions, ULONG *priority_inversions,
  1397. ULONG *time_slices, ULONG *relinquishes, ULONG *timeouts, ULONG *wait_aborts, TX_THREAD **last_preempted_by);
  1398. UINT _tx_thread_performance_system_info_get(ULONG *resumptions, ULONG *suspensions,
  1399. ULONG *solicited_preemptions, ULONG *interrupt_preemptions, ULONG *priority_inversions,
  1400. ULONG *time_slices, ULONG *relinquishes, ULONG *timeouts, ULONG *wait_aborts,
  1401. ULONG *non_idle_returns, ULONG *idle_returns);
  1402. UINT _tx_thread_preemption_change(TX_THREAD *thread_ptr, UINT new_threshold,
  1403. UINT *old_threshold);
  1404. UINT _tx_thread_priority_change(TX_THREAD *thread_ptr, UINT new_priority,
  1405. UINT *old_priority);
  1406. VOID _tx_thread_relinquish(VOID);
  1407. UINT _tx_thread_reset(TX_THREAD *thread_ptr);
  1408. UINT _tx_thread_resume(TX_THREAD *thread_ptr);
  1409. UINT _tx_thread_sleep(ULONG timer_ticks);
  1410. UINT _tx_thread_stack_error_notify(VOID (*stack_error_handler)(TX_THREAD *thread_ptr));
  1411. UINT _tx_thread_suspend(TX_THREAD *thread_ptr);
  1412. UINT _tx_thread_terminate(TX_THREAD *thread_ptr);
  1413. UINT _tx_thread_time_slice_change(TX_THREAD *thread_ptr, ULONG new_time_slice, ULONG *old_time_slice);
  1414. UINT _tx_thread_wait_abort(TX_THREAD *thread_ptr);
  1415. /* Define error checking shells for API services. These are only referenced by the
  1416. application. */
  1417. UINT _txe_thread_create(TX_THREAD *thread_ptr, CHAR *name_ptr,
  1418. VOID (*entry_function)(ULONG entry_input), ULONG entry_input,
  1419. VOID *stack_start, ULONG stack_size,
  1420. UINT priority, UINT preempt_threshold,
  1421. ULONG time_slice, UINT auto_start, UINT thread_control_block_size);
  1422. UINT _txe_thread_delete(TX_THREAD *thread_ptr);
  1423. UINT _txe_thread_entry_exit_notify(TX_THREAD *thread_ptr, VOID (*thread_entry_exit_notify)(TX_THREAD *notify_thread_ptr, UINT type));
  1424. UINT _txe_thread_info_get(TX_THREAD *thread_ptr, CHAR **name, UINT *state, ULONG *run_count,
  1425. UINT *priority, UINT *preemption_threshold, ULONG *time_slice,
  1426. TX_THREAD **next_thread, TX_THREAD **next_suspended_thread);
  1427. UINT _txe_thread_preemption_change(TX_THREAD *thread_ptr, UINT new_threshold,
  1428. UINT *old_threshold);
  1429. UINT _txe_thread_priority_change(TX_THREAD *thread_ptr, UINT new_priority,
  1430. UINT *old_priority);
  1431. VOID _txe_thread_relinquish(VOID);
  1432. UINT _txe_thread_reset(TX_THREAD *thread_ptr);
  1433. UINT _txe_thread_resume(TX_THREAD *thread_ptr);
  1434. UINT _txe_thread_suspend(TX_THREAD *thread_ptr);
  1435. UINT _txe_thread_terminate(TX_THREAD *thread_ptr);
  1436. UINT _txe_thread_time_slice_change(TX_THREAD *thread_ptr, ULONG new_time_slice, ULONG *old_time_slice);
  1437. UINT _txe_thread_wait_abort(TX_THREAD *thread_ptr);
  1438. #ifdef TX_ENABLE_MULTI_ERROR_CHECKING
  1439. UINT _txr_thread_create(TX_THREAD *thread_ptr, CHAR *name_ptr,
  1440. VOID (*entry_function)(ULONG entry_input), ULONG entry_input,
  1441. VOID *stack_start, ULONG stack_size,
  1442. UINT priority, UINT preempt_threshold,
  1443. ULONG time_slice, UINT auto_start, UINT thread_control_block_size);
  1444. UINT _txr_thread_delete(TX_THREAD *thread_ptr);
  1445. UINT _txr_thread_entry_exit_notify(TX_THREAD *thread_ptr, VOID (*thread_entry_exit_notify)(TX_THREAD *notify_thread_ptr, UINT type));
  1446. UINT _txr_thread_info_get(TX_THREAD *thread_ptr, CHAR **name, UINT *state, ULONG *run_count,
  1447. UINT *priority, UINT *preemption_threshold, ULONG *time_slice,
  1448. TX_THREAD **next_thread, TX_THREAD **next_suspended_thread);
  1449. UINT _txr_thread_preemption_change(TX_THREAD *thread_ptr, UINT new_threshold,
  1450. UINT *old_threshold);
  1451. UINT _txr_thread_priority_change(TX_THREAD *thread_ptr, UINT new_priority,
  1452. UINT *old_priority);
  1453. UINT _txr_thread_reset(TX_THREAD *thread_ptr);
  1454. UINT _txr_thread_resume(TX_THREAD *thread_ptr);
  1455. UINT _txr_thread_suspend(TX_THREAD *thread_ptr);
  1456. UINT _txr_thread_terminate(TX_THREAD *thread_ptr);
  1457. UINT _txr_thread_time_slice_change(TX_THREAD *thread_ptr, ULONG new_time_slice, ULONG *old_time_slice);
  1458. UINT _txr_thread_wait_abort(TX_THREAD *thread_ptr);
  1459. #endif
  1460. /* Define timer management function prototypes. */
  1461. UINT _tx_timer_activate(TX_TIMER *timer_ptr);
  1462. UINT _tx_timer_change(TX_TIMER *timer_ptr, ULONG initial_ticks, ULONG reschedule_ticks);
  1463. UINT _tx_timer_create(TX_TIMER *timer_ptr, CHAR *name_ptr,
  1464. VOID (*expiration_function)(ULONG input), ULONG expiration_input,
  1465. ULONG initial_ticks, ULONG reschedule_ticks, UINT auto_activate);
  1466. UINT _tx_timer_deactivate(TX_TIMER *timer_ptr);
  1467. UINT _tx_timer_delete(TX_TIMER *timer_ptr);
  1468. UINT _tx_timer_info_get(TX_TIMER *timer_ptr, CHAR **name, UINT *active, ULONG *remaining_ticks,
  1469. ULONG *reschedule_ticks, TX_TIMER **next_timer);
  1470. UINT _tx_timer_performance_info_get(TX_TIMER *timer_ptr, ULONG *activates, ULONG *reactivates,
  1471. ULONG *deactivates, ULONG *expirations, ULONG *expiration_adjusts);
  1472. UINT _tx_timer_performance_system_info_get(ULONG *activates, ULONG *reactivates,
  1473. ULONG *deactivates, ULONG *expirations, ULONG *expiration_adjusts);
  1474. ULONG _tx_time_get(VOID);
  1475. VOID _tx_time_set(ULONG new_time);
  1476. /* Define error checking shells for API services. These are only referenced by the
  1477. application. */
  1478. UINT _txe_timer_activate(TX_TIMER *timer_ptr);
  1479. UINT _txe_timer_change(TX_TIMER *timer_ptr, ULONG initial_ticks, ULONG reschedule_ticks);
  1480. UINT _txe_timer_create(TX_TIMER *timer_ptr, CHAR *name_ptr,
  1481. VOID (*expiration_function)(ULONG input), ULONG expiration_input,
  1482. ULONG initial_ticks, ULONG reschedule_ticks, UINT auto_activate, UINT timer_control_block_size);
  1483. UINT _txe_timer_deactivate(TX_TIMER *timer_ptr);
  1484. UINT _txe_timer_delete(TX_TIMER *timer_ptr);
  1485. UINT _txe_timer_info_get(TX_TIMER *timer_ptr, CHAR **name, UINT *active, ULONG *remaining_ticks,
  1486. ULONG *reschedule_ticks, TX_TIMER **next_timer);
  1487. #ifdef TX_ENABLE_MULTI_ERROR_CHECKING
  1488. UINT _txr_timer_activate(TX_TIMER *timer_ptr);
  1489. UINT _txr_timer_change(TX_TIMER *timer_ptr, ULONG initial_ticks, ULONG reschedule_ticks);
  1490. UINT _txr_timer_create(TX_TIMER *timer_ptr, CHAR *name_ptr,
  1491. VOID (*expiration_function)(ULONG input), ULONG expiration_input,
  1492. ULONG initial_ticks, ULONG reschedule_ticks, UINT auto_activate, UINT timer_control_block_size);
  1493. UINT _txr_timer_deactivate(TX_TIMER *timer_ptr);
  1494. UINT _txr_timer_delete(TX_TIMER *timer_ptr);
  1495. UINT _txr_timer_info_get(TX_TIMER *timer_ptr, CHAR **name, UINT *active, ULONG *remaining_ticks,
  1496. ULONG *reschedule_ticks, TX_TIMER **next_timer);
  1497. #endif
  1498. /* Define trace API function prototypes. */
  1499. UINT _tx_trace_enable(VOID *trace_buffer_start, ULONG trace_buffer_size, ULONG registry_entries);
  1500. UINT _tx_trace_event_filter(ULONG event_filter_bits);
  1501. UINT _tx_trace_event_unfilter(ULONG event_unfilter_bits);
  1502. UINT _tx_trace_disable(VOID);
  1503. VOID _tx_trace_isr_enter_insert(ULONG isr_id);
  1504. VOID _tx_trace_isr_exit_insert(ULONG isr_id);
  1505. UINT _tx_trace_buffer_full_notify(VOID (*full_buffer_callback)(VOID *buffer));
  1506. UINT _tx_trace_user_event_insert(ULONG event_id, ULONG info_field_1, ULONG info_field_2, ULONG info_field_3, ULONG info_field_4);
  1507. UINT _tx_trace_interrupt_control(UINT new_posture);
  1508. /* Add a default macro that can be re-defined in tx_port.h to add default processing when a thread starts. Common usage
  1509. would be for enabling floating point for a thread by default, however, the additional processing could be anything
  1510. defined in tx_port.h. */
  1511. #ifndef TX_THREAD_STARTED_EXTENSION
  1512. #define TX_THREAD_STARTED_EXTENSION(thread_ptr)
  1513. #endif
  1514. /* Add a default macro that can be re-defined in tx_port.h to add processing to the thread stack analyze function.
  1515. By default, this is simply defined as whitespace. */
  1516. #ifndef TX_THREAD_STACK_ANALYZE_EXTENSION
  1517. #define TX_THREAD_STACK_ANALYZE_EXTENSION
  1518. #endif
  1519. /* Add a default macro that can be re-defined in tx_port.h to add processing to the initialize kernel enter function.
  1520. By default, this is simply defined as whitespace. */
  1521. #ifndef TX_INITIALIZE_KERNEL_ENTER_EXTENSION
  1522. #define TX_INITIALIZE_KERNEL_ENTER_EXTENSION
  1523. #endif
  1524. /* Add a default macro that can be re-defined in tx_port.h to add processing to the initialize random number generator.
  1525. By default, this is simply defined as whitespace. */
  1526. #ifndef TX_INITIALIZE_RANDOM_GENERATOR_INITIALIZATION
  1527. #define TX_INITIALIZE_RANDOM_GENERATOR_INITIALIZATION
  1528. #endif
  1529. /* Define the TX_RAND macro to the standard library function, if not already defined. */
  1530. #ifndef TX_RAND
  1531. #define TX_RAND() rand()
  1532. #endif
  1533. /* Check for MISRA compliance requirements. */
  1534. #ifdef TX_MISRA_ENABLE
  1535. /* Define MISRA-specific routines. */
  1536. VOID _tx_misra_memset(VOID *ptr, UINT value, UINT size);
  1537. UCHAR *_tx_misra_uchar_pointer_add(UCHAR *ptr, ULONG amount);
  1538. UCHAR *_tx_misra_uchar_pointer_sub(UCHAR *ptr, ULONG amount);
  1539. ULONG _tx_misra_uchar_pointer_dif(UCHAR *ptr1, UCHAR *ptr2);
  1540. ULONG _tx_misra_pointer_to_ulong_convert(VOID *ptr);
  1541. ULONG *_tx_misra_ulong_pointer_add(ULONG *ptr, ULONG amount);
  1542. ULONG *_tx_misra_ulong_pointer_sub(ULONG *ptr, ULONG amount);
  1543. ULONG _tx_misra_ulong_pointer_dif(ULONG *ptr1, ULONG *ptr2);
  1544. VOID *_tx_misra_ulong_to_pointer_convert(ULONG input);
  1545. VOID _tx_misra_message_copy(ULONG **source, ULONG **destination, UINT size);
  1546. ULONG _tx_misra_timer_pointer_dif(TX_TIMER_INTERNAL **ptr1, TX_TIMER_INTERNAL **ptr2);
  1547. TX_TIMER_INTERNAL **_tx_misra_timer_pointer_add(TX_TIMER_INTERNAL **ptr1, ULONG size);
  1548. VOID _tx_misra_user_timer_pointer_get(TX_TIMER_INTERNAL *internal_timer, TX_TIMER **user_timer);
  1549. VOID _tx_misra_thread_stack_check(TX_THREAD *thread_ptr, VOID **highest_stack);
  1550. VOID _tx_misra_trace_event_insert(ULONG event_id, VOID *info_field_1, ULONG info_field_2, ULONG info_field_3, ULONG info_field_4, ULONG filter, ULONG time_stamp);
  1551. UINT _tx_misra_always_true(void);
  1552. UCHAR **_tx_misra_indirect_void_to_uchar_pointer_convert(VOID **pointer);
  1553. UCHAR **_tx_misra_uchar_to_indirect_uchar_pointer_convert(UCHAR *pointer);
  1554. UCHAR *_tx_misra_block_pool_to_uchar_pointer_convert(TX_BLOCK_POOL *pool);
  1555. TX_BLOCK_POOL *_tx_misra_void_to_block_pool_pointer_convert(VOID *pointer);
  1556. UCHAR *_tx_misra_void_to_uchar_pointer_convert(VOID *pointer);
  1557. TX_BLOCK_POOL *_tx_misra_uchar_to_block_pool_pointer_convert(UCHAR *pointer);
  1558. UCHAR **_tx_misra_void_to_indirect_uchar_pointer_convert(VOID *pointer);
  1559. TX_BYTE_POOL *_tx_misra_void_to_byte_pool_pointer_convert(VOID *pointer);
  1560. UCHAR *_tx_misra_byte_pool_to_uchar_pointer_convert(TX_BYTE_POOL *pool);
  1561. ALIGN_TYPE *_tx_misra_uchar_to_align_type_pointer_convert(UCHAR *pointer);
  1562. TX_BYTE_POOL **_tx_misra_uchar_to_indirect_byte_pool_pointer_convert(UCHAR *pointer);
  1563. TX_EVENT_FLAGS_GROUP *_tx_misra_void_to_event_flags_pointer_convert(VOID *pointer);
  1564. ULONG *_tx_misra_void_to_ulong_pointer_convert(VOID *pointer);
  1565. TX_MUTEX *_tx_misra_void_to_mutex_pointer_convert(VOID *pointer);
  1566. UINT _tx_misra_status_get(UINT status);
  1567. TX_QUEUE *_tx_misra_void_to_queue_pointer_convert(VOID *pointer);
  1568. TX_SEMAPHORE *_tx_misra_void_to_semaphore_pointer_convert(VOID *pointer);
  1569. VOID *_tx_misra_uchar_to_void_pointer_convert(UCHAR *pointer);
  1570. TX_THREAD *_tx_misra_ulong_to_thread_pointer_convert(ULONG value);
  1571. VOID *_tx_misra_timer_indirect_to_void_pointer_convert(TX_TIMER_INTERNAL **pointer);
  1572. CHAR *_tx_misra_const_char_to_char_pointer_convert(const char *pointer);
  1573. TX_THREAD *_tx_misra_void_to_thread_pointer_convert(VOID *pointer);
  1574. UCHAR *_tx_misra_char_to_uchar_pointer_convert(CHAR *pointer);
  1575. VOID _tx_misra_event_flags_group_not_used(TX_EVENT_FLAGS_GROUP *group_ptr);
  1576. VOID _tx_misra_event_flags_set_notify_not_used(VOID (*events_set_notify)(TX_EVENT_FLAGS_GROUP *notify_group_ptr));
  1577. VOID _tx_misra_queue_not_used(TX_QUEUE *queue_ptr);
  1578. VOID _tx_misra_queue_send_notify_not_used(VOID (*queue_send_notify)(TX_QUEUE *notify_queue_ptr));
  1579. VOID _tx_misra_semaphore_not_used(TX_SEMAPHORE *semaphore_ptr);
  1580. VOID _tx_misra_semaphore_put_notify_not_used(VOID (*semaphore_put_notify)(TX_SEMAPHORE *notify_semaphore_ptr));
  1581. VOID _tx_misra_thread_not_used(TX_THREAD *thread_ptr);
  1582. VOID _tx_misra_thread_entry_exit_notify_not_used(VOID (*thread_entry_exit_notify)(TX_THREAD *notify_thread_ptr, UINT id));
  1583. #define TX_MEMSET(a,b,c) _tx_misra_memset((a), (UINT) (b), (UINT) (c))
  1584. #define TX_UCHAR_POINTER_ADD(a,b) _tx_misra_uchar_pointer_add((UCHAR *) (a), (ULONG) (b))
  1585. #define TX_UCHAR_POINTER_SUB(a,b) _tx_misra_uchar_pointer_sub((UCHAR *) (a), (ULONG) (b))
  1586. #define TX_UCHAR_POINTER_DIF(a,b) _tx_misra_uchar_pointer_dif((UCHAR *) (a), (UCHAR *) (b))
  1587. #define TX_ULONG_POINTER_ADD(a,b) _tx_misra_ulong_pointer_add((ULONG *) (a), (ULONG) (b))
  1588. #define TX_ULONG_POINTER_SUB(a,b) _tx_misra_ulong_pointer_sub((ULONG *) (a), (ULONG) (b))
  1589. #define TX_ULONG_POINTER_DIF(a,b) _tx_misra_ulong_pointer_dif((ULONG *) (a), (ULONG *) (b))
  1590. #define TX_POINTER_TO_ULONG_CONVERT(a) _tx_misra_pointer_to_ulong_convert((VOID *) (a))
  1591. #define TX_ULONG_TO_POINTER_CONVERT(a) _tx_misra_ulong_to_pointer_convert((ULONG) (a))
  1592. #define TX_QUEUE_MESSAGE_COPY(s,d,z) _tx_misra_message_copy(&(s), &(d), (z));
  1593. #define TX_TIMER_POINTER_DIF(a,b) _tx_misra_timer_pointer_dif((TX_TIMER_INTERNAL **) (a), (TX_TIMER_INTERNAL **) (b))
  1594. #define TX_TIMER_POINTER_ADD(a,b) _tx_misra_timer_pointer_add((TX_TIMER_INTERNAL **) (a), (ULONG) (b))
  1595. #define TX_USER_TIMER_POINTER_GET(a,b) _tx_misra_user_timer_pointer_get((TX_TIMER_INTERNAL *) (a), (TX_TIMER **) &(b));
  1596. #define TX_THREAD_STACK_CHECK(a) _tx_misra_thread_stack_check((a), &((a)->tx_thread_stack_highest_ptr));
  1597. #ifdef TX_ENABLE_EVENT_TRACE
  1598. #define TX_TRACE_IN_LINE_INSERT(i,a,b,c,d,e) _tx_misra_trace_event_insert((ULONG) (i), (VOID *) (a), (ULONG) (b), (ULONG) (c), (ULONG) (d), (ULONG) (e), ((ULONG) TX_TRACE_TIME_SOURCE));
  1599. #endif
  1600. #define TX_LOOP_FOREVER (_tx_misra_always_true() == TX_TRUE)
  1601. #define TX_INDIRECT_VOID_TO_UCHAR_POINTER_CONVERT(a) _tx_misra_indirect_void_to_uchar_pointer_convert((a))
  1602. #define TX_UCHAR_TO_INDIRECT_UCHAR_POINTER_CONVERT(a) _tx_misra_uchar_to_indirect_uchar_pointer_convert((a))
  1603. #define TX_BLOCK_POOL_TO_UCHAR_POINTER_CONVERT(a) _tx_misra_block_pool_to_uchar_pointer_convert((a))
  1604. #define TX_VOID_TO_BLOCK_POOL_POINTER_CONVERT(a) _tx_misra_void_to_block_pool_pointer_convert((a))
  1605. #define TX_VOID_TO_UCHAR_POINTER_CONVERT(a) _tx_misra_void_to_uchar_pointer_convert((a))
  1606. #define TX_UCHAR_TO_BLOCK_POOL_POINTER_CONVERT(a) _tx_misra_uchar_to_block_pool_pointer_convert((a))
  1607. #define TX_VOID_TO_INDIRECT_UCHAR_POINTER_CONVERT(a) _tx_misra_void_to_indirect_uchar_pointer_convert((a))
  1608. #define TX_VOID_TO_BYTE_POOL_POINTER_CONVERT(a) _tx_misra_void_to_byte_pool_pointer_convert((a))
  1609. #define TX_BYTE_POOL_TO_UCHAR_POINTER_CONVERT(a) _tx_misra_byte_pool_to_uchar_pointer_convert((a))
  1610. #define TX_UCHAR_TO_ALIGN_TYPE_POINTER_CONVERT(a) _tx_misra_uchar_to_align_type_pointer_convert((a))
  1611. #define TX_UCHAR_TO_INDIRECT_BYTE_POOL_POINTER(a) _tx_misra_uchar_to_indirect_byte_pool_pointer_convert((a))
  1612. #define TX_VOID_TO_EVENT_FLAGS_POINTER_CONVERT(a) _tx_misra_void_to_event_flags_pointer_convert((a))
  1613. #define TX_VOID_TO_ULONG_POINTER_CONVERT(a) _tx_misra_void_to_ulong_pointer_convert((a))
  1614. #define TX_VOID_TO_MUTEX_POINTER_CONVERT(a) _tx_misra_void_to_mutex_pointer_convert((a))
  1615. #define TX_MUTEX_PRIORITIZE_MISRA_EXTENSION(a) _tx_misra_status_get((a))
  1616. #define TX_VOID_TO_QUEUE_POINTER_CONVERT(a) _tx_misra_void_to_queue_pointer_convert((a))
  1617. #define TX_VOID_TO_SEMAPHORE_POINTER_CONVERT(a) _tx_misra_void_to_semaphore_pointer_convert((a))
  1618. #define TX_UCHAR_TO_VOID_POINTER_CONVERT(a) _tx_misra_uchar_to_void_pointer_convert((a))
  1619. #define TX_ULONG_TO_THREAD_POINTER_CONVERT(a) _tx_misra_ulong_to_thread_pointer_convert((a))
  1620. #define TX_TIMER_INDIRECT_TO_VOID_POINTER_CONVERT(a) _tx_misra_timer_indirect_to_void_pointer_convert((a))
  1621. #ifndef TX_TIMER_INITIALIZE_EXTENSION
  1622. #define TX_TIMER_INITIALIZE_EXTENSION(a) status = _tx_misra_status_get((a));
  1623. #endif
  1624. #define TX_CONST_CHAR_TO_CHAR_POINTER_CONVERT(a) _tx_misra_const_char_to_char_pointer_convert((a))
  1625. #define TX_VOID_TO_THREAD_POINTER_CONVERT(a) _tx_misra_void_to_thread_pointer_convert((a))
  1626. #define TX_CHAR_TO_UCHAR_POINTER_CONVERT(a) _tx_misra_char_to_uchar_pointer_convert((a))
  1627. #define TX_EVENT_FLAGS_GROUP_NOT_USED(a) _tx_misra_event_flags_group_not_used((a))
  1628. #define TX_EVENT_FLAGS_SET_NOTIFY_NOT_USED(a) _tx_misra_event_flags_set_notify_not_used((a))
  1629. #define TX_QUEUE_NOT_USED(a) _tx_misra_queue_not_used((a))
  1630. #define TX_QUEUE_SEND_NOTIFY_NOT_USED(a) _tx_misra_queue_send_notify_not_used((a))
  1631. #define TX_SEMAPHORE_NOT_USED(a) _tx_misra_semaphore_not_used((a))
  1632. #define TX_SEMAPHORE_PUT_NOTIFY_NOT_USED(a) _tx_misra_semaphore_put_notify_not_used((a))
  1633. #define TX_THREAD_NOT_USED(a) _tx_misra_thread_not_used((a))
  1634. #define TX_THREAD_ENTRY_EXIT_NOTIFY_NOT_USED(a) _tx_misra_thread_entry_exit_notify_not_used((a))
  1635. #else
  1636. /* Define the TX_MEMSET macro to the standard library function, if not already defined. */
  1637. #ifndef TX_MEMSET
  1638. #define TX_MEMSET(a,b,c) memset((a),(b),(c))
  1639. #endif
  1640. #define TX_UCHAR_POINTER_ADD(a,b) (((UCHAR *) (a)) + ((UINT) (b)))
  1641. #define TX_UCHAR_POINTER_SUB(a,b) (((UCHAR *) (a)) - ((UINT) (b)))
  1642. #define TX_UCHAR_POINTER_DIF(a,b) ((ULONG)(((UCHAR *) (a)) - ((UCHAR *) (b))))
  1643. #define TX_ULONG_POINTER_ADD(a,b) (((ULONG *) (a)) + ((UINT) (b)))
  1644. #define TX_ULONG_POINTER_SUB(a,b) (((ULONG *) (a)) - ((UINT) (b)))
  1645. #define TX_ULONG_POINTER_DIF(a,b) ((ULONG)(((ULONG *) (a)) - ((ULONG *) (b))))
  1646. #define TX_POINTER_TO_ULONG_CONVERT(a) ((ULONG) ((VOID *) (a)))
  1647. #define TX_ULONG_TO_POINTER_CONVERT(a) ((VOID *) ((ULONG) (a)))
  1648. #define TX_POINTER_TO_ALIGN_TYPE_CONVERT(a) ((ALIGN_TYPE) ((VOID *) (a)))
  1649. #define TX_ALIGN_TYPE_TO_POINTER_CONVERT(a) ((VOID *) ((ALIGN_TYPE) (a)))
  1650. #define TX_TIMER_POINTER_DIF(a,b) ((ULONG)(((TX_TIMER_INTERNAL **) (a)) - ((TX_TIMER_INTERNAL **) (b))))
  1651. #define TX_TIMER_POINTER_ADD(a,b) (((TX_TIMER_INTERNAL **) (a)) + ((ULONG) (b)))
  1652. #define TX_USER_TIMER_POINTER_GET(a,b) { \
  1653. UCHAR *working_ptr; \
  1654. working_ptr = (UCHAR *) (a); \
  1655. (b) = (TX_TIMER *) working_ptr; \
  1656. working_ptr = working_ptr - (((UCHAR *) &(b) -> tx_timer_internal) - ((UCHAR *) &(b) -> tx_timer_id)); \
  1657. (b) = (TX_TIMER *) working_ptr; \
  1658. }
  1659. #define TX_LOOP_FOREVER ((UINT) 1)
  1660. #define TX_INDIRECT_VOID_TO_UCHAR_POINTER_CONVERT(a) ((UCHAR **) ((VOID *) (a)))
  1661. #define TX_UCHAR_TO_INDIRECT_UCHAR_POINTER_CONVERT(a) ((UCHAR **) ((VOID *) (a)))
  1662. #define TX_BLOCK_POOL_TO_UCHAR_POINTER_CONVERT(a) ((UCHAR *) ((VOID *) (a)))
  1663. #define TX_VOID_TO_BLOCK_POOL_POINTER_CONVERT(a) ((TX_BLOCK_POOL *) ((VOID *) (a)))
  1664. #define TX_VOID_TO_UCHAR_POINTER_CONVERT(a) ((UCHAR *) ((VOID *) (a)))
  1665. #define TX_UCHAR_TO_BLOCK_POOL_POINTER_CONVERT(a) ((TX_BLOCK_POOL *) ((VOID *) (a)))
  1666. #define TX_VOID_TO_INDIRECT_UCHAR_POINTER_CONVERT(a) ((UCHAR **) ((VOID *) (a)))
  1667. #define TX_VOID_TO_BYTE_POOL_POINTER_CONVERT(a) ((TX_BYTE_POOL *) ((VOID *) (a)))
  1668. #define TX_BYTE_POOL_TO_UCHAR_POINTER_CONVERT(a) ((UCHAR *) ((VOID *) (a)))
  1669. #ifndef TX_UCHAR_TO_ALIGN_TYPE_POINTER_CONVERT
  1670. #define TX_UCHAR_TO_ALIGN_TYPE_POINTER_CONVERT(a) ((ALIGN_TYPE *) ((VOID *) (a)))
  1671. #endif
  1672. #define TX_UCHAR_TO_INDIRECT_BYTE_POOL_POINTER(a) ((TX_BYTE_POOL **) ((VOID *) (a)))
  1673. #define TX_VOID_TO_EVENT_FLAGS_POINTER_CONVERT(a) ((TX_EVENT_FLAGS_GROUP *) ((VOID *) (a)))
  1674. #define TX_VOID_TO_ULONG_POINTER_CONVERT(a) ((ULONG *) ((VOID *) (a)))
  1675. #define TX_VOID_TO_MUTEX_POINTER_CONVERT(a) ((TX_MUTEX *) ((VOID *) (a)))
  1676. #define TX_VOID_TO_QUEUE_POINTER_CONVERT(a) ((TX_QUEUE *) ((VOID *) (a)))
  1677. #define TX_VOID_TO_SEMAPHORE_POINTER_CONVERT(a) ((TX_SEMAPHORE *) ((VOID *) (a)))
  1678. #define TX_UCHAR_TO_VOID_POINTER_CONVERT(a) ((VOID *) (a))
  1679. #define TX_ULONG_TO_THREAD_POINTER_CONVERT(a) ((TX_THREAD *) ((VOID *) (a)))
  1680. #ifndef TX_TIMER_INDIRECT_TO_VOID_POINTER_CONVERT
  1681. #define TX_TIMER_INDIRECT_TO_VOID_POINTER_CONVERT(a) ((VOID *) (a))
  1682. #endif
  1683. #ifndef TX_TIMER_INITIALIZE_EXTENSION
  1684. #define TX_TIMER_INITIALIZE_EXTENSION(a)
  1685. #endif
  1686. #define TX_CONST_CHAR_TO_CHAR_POINTER_CONVERT(a) ((CHAR *) ((VOID *) (a)))
  1687. #define TX_VOID_TO_THREAD_POINTER_CONVERT(a) ((TX_THREAD *) ((VOID *) (a)))
  1688. #define TX_CHAR_TO_UCHAR_POINTER_CONVERT(a) ((UCHAR *) ((VOID *) (a)))
  1689. #ifndef TX_EVENT_FLAGS_GROUP_NOT_USED
  1690. #define TX_EVENT_FLAGS_GROUP_NOT_USED(a) ((void)(a))
  1691. #endif
  1692. #ifndef TX_EVENT_FLAGS_SET_NOTIFY_NOT_USED
  1693. #define TX_EVENT_FLAGS_SET_NOTIFY_NOT_USED(a) ((void)(a))
  1694. #endif
  1695. #ifndef TX_QUEUE_NOT_USED
  1696. #define TX_QUEUE_NOT_USED(a) ((void)(a))
  1697. #endif
  1698. #ifndef TX_QUEUE_SEND_NOTIFY_NOT_USED
  1699. #define TX_QUEUE_SEND_NOTIFY_NOT_USED(a) ((void)(a))
  1700. #endif
  1701. #ifndef TX_SEMAPHORE_NOT_USED
  1702. #define TX_SEMAPHORE_NOT_USED(a) ((void)(a))
  1703. #endif
  1704. #ifndef TX_SEMAPHORE_PUT_NOTIFY_NOT_USED
  1705. #define TX_SEMAPHORE_PUT_NOTIFY_NOT_USED(a) ((void)(a))
  1706. #endif
  1707. #ifndef TX_THREAD_NOT_USED
  1708. #define TX_THREAD_NOT_USED(a) ((void)(a))
  1709. #endif
  1710. #ifndef TX_THREAD_ENTRY_EXIT_NOTIFY_NOT_USED
  1711. #define TX_THREAD_ENTRY_EXIT_NOTIFY_NOT_USED(a) ((void)(a))
  1712. #endif
  1713. #endif
  1714. /* Determine if there is an tx_api.h extension file to include. */
  1715. #ifdef TX_THREAD_API_EXTENSION
  1716. /* Yes, bring in the tx_api.h extension file. */
  1717. #include "tx_api_extension.h"
  1718. #endif
  1719. /* Define safety critical configuration and exception handling. */
  1720. #ifdef TX_SAFETY_CRITICAL
  1721. /* Ensure the maximum number of priorities is defined in safety critical mode. */
  1722. #ifndef TX_MAX_PRIORITIES
  1723. #error "tx_port.h: TX_MAX_PRIORITIES not defined."
  1724. #endif
  1725. /* Ensure the maximum number of priorities is a multiple of 32. */
  1726. #if (TX_MAX_PRIORITIES %32) != 0
  1727. #error "tx_port.h: TX_MAX_PRIORITIES must be a multiple of 32."
  1728. #endif
  1729. /* Ensure error checking is enabled. */
  1730. #ifdef TX_DISABLE_ERROR_CHECKING
  1731. #error "TX_DISABLE_ERROR_CHECKING must not be defined."
  1732. #endif
  1733. /* Ensure timer ISR processing is not defined. */
  1734. #ifdef TX_TIMER_PROCESS_IN_ISR
  1735. #error "TX_TIMER_PROCESS_IN_ISR must not be defined."
  1736. #endif
  1737. /* Ensure timer reactivation in-line is not defined. */
  1738. #ifdef TX_REACTIVATE_INLINE
  1739. #error "TX_REACTIVATE_INLINE must not be defined."
  1740. #endif
  1741. /* Ensure disable stack filling is not defined. */
  1742. #ifdef TX_DISABLE_STACK_FILLING
  1743. #error "TX_DISABLE_STACK_FILLING must not be defined."
  1744. #endif
  1745. /* Ensure enable stack checking is not defined. */
  1746. #ifdef TX_ENABLE_STACK_CHECKING
  1747. #error "TX_ENABLE_STACK_CHECKING must not be defined."
  1748. #endif
  1749. /* Ensure disable preemption-threshold is not defined. */
  1750. #ifdef TX_DISABLE_PREEMPTION_THRESHOLD
  1751. #error "TX_DISABLE_PREEMPTION_THRESHOLD must not be defined."
  1752. #endif
  1753. /* Ensure disable redundant clearing is not defined. */
  1754. #ifdef TX_DISABLE_REDUNDANT_CLEARING
  1755. #error "TX_DISABLE_REDUNDANT_CLEARING must not be defined."
  1756. #endif
  1757. /* Ensure no timer is not defined. */
  1758. #ifdef TX_NO_TIMER
  1759. #error "TX_NO_TIMER must not be defined."
  1760. #endif
  1761. /* Ensure disable notify callbacks is not defined. */
  1762. #ifdef TX_DISABLE_NOTIFY_CALLBACKS
  1763. #error "TX_DISABLE_NOTIFY_CALLBACKS must not be defined."
  1764. #endif
  1765. /* Ensure in-line thread suspend/resume is not defined. */
  1766. #ifdef TX_INLINE_THREAD_RESUME_SUSPEND
  1767. #error "TX_INLINE_THREAD_RESUME_SUSPEND must not be defined."
  1768. #endif
  1769. /* Ensure not interruptable is not defined. */
  1770. #ifdef TX_NOT_INTERRUPTABLE
  1771. #error "TX_NOT_INTERRUPTABLE must not be defined."
  1772. #endif
  1773. /* Ensure event trace enable is not defined. */
  1774. #ifdef TX_ENABLE_EVENT_TRACE
  1775. #error "TX_ENABLE_EVENT_TRACE must not be defined."
  1776. #endif
  1777. /* Ensure block pool performance info enable is not defined. */
  1778. #ifdef TX_BLOCK_POOL_ENABLE_PERFORMANCE_INFO
  1779. #error "TX_BLOCK_POOL_ENABLE_PERFORMANCE_INFO must not be defined."
  1780. #endif
  1781. /* Ensure byte pool performance info enable is not defined. */
  1782. #ifdef TX_BYTE_POOL_ENABLE_PERFORMANCE_INFO
  1783. #error "TX_BYTE_POOL_ENABLE_PERFORMANCE_INFO must not be defined."
  1784. #endif
  1785. /* Ensure event flag performance info enable is not defined. */
  1786. #ifdef TX_EVENT_FLAGS_ENABLE_PERFORMANCE_INFO
  1787. #error "TX_EVENT_FLAGS_ENABLE_PERFORMANCE_INFO must not be defined."
  1788. #endif
  1789. /* Ensure mutex performance info enable is not defined. */
  1790. #ifdef TX_MUTEX_ENABLE_PERFORMANCE_INFO
  1791. #error "TX_MUTEX_ENABLE_PERFORMANCE_INFO must not be defined."
  1792. #endif
  1793. /* Ensure queue performance info enable is not defined. */
  1794. #ifdef TX_QUEUE_ENABLE_PERFORMANCE_INFO
  1795. #error "TX_QUEUE_ENABLE_PERFORMANCE_INFO must not be defined."
  1796. #endif
  1797. /* Ensure semaphore performance info enable is not defined. */
  1798. #ifdef TX_SEMAPHORE_ENABLE_PERFORMANCE_INFO
  1799. #error "TX_SEMAPHORE_ENABLE_PERFORMANCE_INFO must not be defined."
  1800. #endif
  1801. /* Ensure thread performance info enable is not defined. */
  1802. #ifdef TX_THREAD_ENABLE_PERFORMANCE_INFO
  1803. #error "TX_THREAD_ENABLE_PERFORMANCE_INFO must not be defined."
  1804. #endif
  1805. /* Ensure timer performance info enable is not defined. */
  1806. #ifdef TX_TIMER_ENABLE_PERFORMANCE_INFO
  1807. #error "TX_TIMER_ENABLE_PERFORMANCE_INFO must not be defined."
  1808. #endif
  1809. /* Now define the safety critical exception handler. */
  1810. VOID _tx_safety_critical_exception_handler(CHAR *file_name, INT line_number, UINT status);
  1811. #ifndef TX_SAFETY_CRITICAL_EXCEPTION
  1812. #define TX_SAFETY_CRITICAL_EXCEPTION(a, b, c) _tx_safety_critical_exception_handler(a, b, c);
  1813. #endif
  1814. #ifndef TX_SAFETY_CRITICAL_EXCEPTION_HANDLER
  1815. #define TX_SAFETY_CRITICAL_EXCEPTION_HANDLER VOID _tx_safety_critical_exception_handler(CHAR *file_name, INT line_number, UINT status) \
  1816. { \
  1817. while(1) \
  1818. { \
  1819. } \
  1820. }
  1821. #endif
  1822. #endif
  1823. #ifdef TX_ENABLE_MULTI_ERROR_CHECKING
  1824. /* Define ThreadX API MULTI run-time error checking function. */
  1825. void __ghs_rnerr(char *errMsg, int stackLevels, int stackTraceDisplay, void *hexVal);
  1826. #endif
  1827. /* Bring in the event logging constants and prototypes. Note that
  1828. TX_ENABLE_EVENT_LOGGING must be defined when building the ThreadX
  1829. library components in order to enable event logging. */
  1830. #ifdef TX_ENABLE_EVENT_LOGGING
  1831. #include "tx_el.h"
  1832. #else
  1833. #ifndef TX_SOURCE_CODE
  1834. #ifndef TX_MISRA_ENABLE
  1835. #define _tx_el_user_event_insert(a,b,c,d,e)
  1836. #endif
  1837. #endif
  1838. #define TX_EL_INITIALIZE
  1839. #define TX_EL_THREAD_REGISTER(a)
  1840. #define TX_EL_THREAD_UNREGISTER(a)
  1841. #define TX_EL_THREAD_STATUS_CHANGE_INSERT(a, b)
  1842. #define TX_EL_BYTE_ALLOCATE_INSERT
  1843. #define TX_EL_BYTE_POOL_CREATE_INSERT
  1844. #define TX_EL_BYTE_POOL_DELETE_INSERT
  1845. #define TX_EL_BYTE_RELEASE_INSERT
  1846. #define TX_EL_BLOCK_ALLOCATE_INSERT
  1847. #define TX_EL_BLOCK_POOL_CREATE_INSERT
  1848. #define TX_EL_BLOCK_POOL_DELETE_INSERT
  1849. #define TX_EL_BLOCK_RELEASE_INSERT
  1850. #define TX_EL_EVENT_FLAGS_CREATE_INSERT
  1851. #define TX_EL_EVENT_FLAGS_DELETE_INSERT
  1852. #define TX_EL_EVENT_FLAGS_GET_INSERT
  1853. #define TX_EL_EVENT_FLAGS_SET_INSERT
  1854. #define TX_EL_INTERRUPT_CONTROL_INSERT
  1855. #define TX_EL_QUEUE_CREATE_INSERT
  1856. #define TX_EL_QUEUE_DELETE_INSERT
  1857. #define TX_EL_QUEUE_FLUSH_INSERT
  1858. #define TX_EL_QUEUE_RECEIVE_INSERT
  1859. #define TX_EL_QUEUE_SEND_INSERT
  1860. #define TX_EL_SEMAPHORE_CREATE_INSERT
  1861. #define TX_EL_SEMAPHORE_DELETE_INSERT
  1862. #define TX_EL_SEMAPHORE_GET_INSERT
  1863. #define TX_EL_SEMAPHORE_PUT_INSERT
  1864. #define TX_EL_THREAD_CREATE_INSERT
  1865. #define TX_EL_THREAD_DELETE_INSERT
  1866. #define TX_EL_THREAD_IDENTIFY_INSERT
  1867. #define TX_EL_THREAD_PREEMPTION_CHANGE_INSERT
  1868. #define TX_EL_THREAD_PRIORITY_CHANGE_INSERT
  1869. #define TX_EL_THREAD_RELINQUISH_INSERT
  1870. #define TX_EL_THREAD_RESUME_INSERT
  1871. #define TX_EL_THREAD_SLEEP_INSERT
  1872. #define TX_EL_THREAD_SUSPEND_INSERT
  1873. #define TX_EL_THREAD_TERMINATE_INSERT
  1874. #define TX_EL_THREAD_TIME_SLICE_CHANGE_INSERT
  1875. #define TX_EL_TIME_GET_INSERT
  1876. #define TX_EL_TIME_SET_INSERT
  1877. #define TX_EL_TIMER_ACTIVATE_INSERT
  1878. #define TX_EL_TIMER_CHANGE_INSERT
  1879. #define TX_EL_TIMER_CREATE_INSERT
  1880. #define TX_EL_TIMER_DEACTIVATE_INSERT
  1881. #define TX_EL_TIMER_DELETE_INSERT
  1882. #define TX_EL_BLOCK_POOL_INFO_GET_INSERT
  1883. #define TX_EL_BLOCK_POOL_PRIORITIZE_INSERT
  1884. #define TX_EL_BYTE_POOL_INFO_GET_INSERT
  1885. #define TX_EL_BYTE_POOL_PRIORITIZE_INSERT
  1886. #define TX_EL_EVENT_FLAGS_INFO_GET_INSERT
  1887. #define TX_EL_MUTEX_CREATE_INSERT
  1888. #define TX_EL_MUTEX_DELETE_INSERT
  1889. #define TX_EL_MUTEX_GET_INSERT
  1890. #define TX_EL_MUTEX_INFO_GET_INSERT
  1891. #define TX_EL_MUTEX_PRIORITIZE_INSERT
  1892. #define TX_EL_MUTEX_PUT_INSERT
  1893. #define TX_EL_QUEUE_INFO_GET_INSERT
  1894. #define TX_EL_QUEUE_FRONT_SEND_INSERT
  1895. #define TX_EL_QUEUE_PRIORITIZE_INSERT
  1896. #define TX_EL_SEMAPHORE_INFO_GET_INSERT
  1897. #define TX_EL_SEMAPHORE_PRIORITIZE_INSERT
  1898. #define TX_EL_THREAD_INFO_GET_INSERT
  1899. #define TX_EL_THREAD_WAIT_ABORT_INSERT
  1900. #define TX_EL_TIMER_INFO_GET_INSERT
  1901. #define TX_EL_BLOCK_POOL_PERFORMANCE_INFO_GET_INSERT
  1902. #define TX_EL_BLOCK_POOL_PERFORMANCE_SYSTEM_INFO_GET_INSERT
  1903. #define TX_EL_BYTE_POOL_PERFORMANCE_INFO_GET_INSERT
  1904. #define TX_EL_BYTE_POOL_PERFORMANCE_SYSTEM_INFO_GET_INSERT
  1905. #define TX_EL_EVENT_FLAGS_PERFORMANCE_INFO_GET_INSERT
  1906. #define TX_EL_EVENT_FLAGS__PERFORMANCE_SYSTEM_INFO_GET_INSERT
  1907. #define TX_EL_EVENT_FLAGS_SET_NOTIFY_INSERT
  1908. #define TX_EL_MUTEX_PERFORMANCE_INFO_GET_INSERT
  1909. #define TX_EL_MUTEX_PERFORMANCE_SYSTEM_INFO_GET_INSERT
  1910. #define TX_EL_QUEUE_PERFORMANCE_INFO_GET_INSERT
  1911. #define TX_EL_QUEUE_PERFORMANCE_SYSTEM_INFO_GET_INSERT
  1912. #define TX_EL_QUEUE_SEND_NOTIFY_INSERT
  1913. #define TX_EL_SEMAPHORE_CEILING_PUT_INSERT
  1914. #define TX_EL_SEMAPHORE_PERFORMANCE_INFO_GET_INSERT
  1915. #define TX_EL_SEMAPHORE_PERFORMANCE_SYSTEM_INFO_GET_INSERT
  1916. #define TX_EL_SEMAPHORE_PUT_NOTIFY_INSERT
  1917. #define TX_EL_THREAD_ENTRY_EXIT_NOTIFY_INSERT
  1918. #define TX_EL_THREAD_RESET_INSERT
  1919. #define TX_EL_THREAD_PERFORMANCE_INFO_GET_INSERT
  1920. #define TX_EL_THREAD_PERFORMANCE_SYSTEM_INFO_GET_INSERT
  1921. #define TX_EL_THREAD_STACK_ERROR_NOTIFY_INSERT
  1922. #define TX_EL_TIMER_PERFORMANCE_INFO_GET_INSERT
  1923. #define TX_EL_TIMER_PERFORMANCE_SYSTEM_INFO_GET_INSERT
  1924. #endif
  1925. /* Define the get system state macro. By default, it simply maps to the variable _tx_thread_system_state. */
  1926. /* Note that prior to Azure RTOS 6.1, this symbol was defined in tx_thread.h. */
  1927. #ifndef TX_THREAD_GET_SYSTEM_STATE
  1928. #define TX_THREAD_GET_SYSTEM_STATE() _tx_thread_system_state
  1929. #endif
  1930. /* Determine if a C++ compiler is being used. If so, complete the standard
  1931. C conditional started above. */
  1932. #ifdef __cplusplus
  1933. }
  1934. #endif
  1935. #endif