tx_api.h 115 KB

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