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