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