1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** ThreadX Component                                                     */
16 /**                                                                       */
17 /**   Port Specific                                                       */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 
23 /**************************************************************************/
24 /*                                                                        */
25 /*  PORT SPECIFIC C INFORMATION                            RELEASE        */
26 /*                                                                        */
27 /*    tx_port.h                                         SMP/Linux/GCC     */
28 /*                                                           6.1.9        */
29 /*                                                                        */
30 /*  AUTHOR                                                                */
31 /*                                                                        */
32 /*    William E. Lamie, Microsoft Corporation                             */
33 /*                                                                        */
34 /*  DESCRIPTION                                                           */
35 /*                                                                        */
36 /*    This file contains data type definitions that make the ThreadX      */
37 /*    real-time kernel function identically on a variety of different     */
38 /*    processor architectures.  For example, the size or number of bits   */
39 /*    in an "int" data type vary between microprocessor architectures and */
40 /*    even C compilers for the same microprocessor.  ThreadX does not     */
41 /*    directly use native C data types.  Instead, ThreadX creates its     */
42 /*    own special types that can be mapped to actual data types by this   */
43 /*    file to guarantee consistency in the interface and functionality.   */
44 /*                                                                        */
45 /*  RELEASE HISTORY                                                       */
46 /*                                                                        */
47 /*    DATE              NAME                      DESCRIPTION             */
48 /*                                                                        */
49 /*  09-30-2020     William E. Lamie         Initial Version 6.1           */
50 /*  04-02-2021     Bhupendra Naphade        Modified comment(s),updated   */
51 /*                                            macro definition,           */
52 /*                                            resulting in version 6.1.6  */
53 /*  10-15-2021     William E. Lamie         Modified comment(s), added    */
54 /*                                            symbol ULONG64_DEFINED,     */
55 /*                                            resulting in version 6.1.9  */
56 /*                                                                        */
57 /**************************************************************************/
58 
59 #ifndef TX_PORT_H
60 #define TX_PORT_H
61 
62 
63 
64 /************* Define ThreadX SMP constants.  *************/
65 
66 #define TX_DISABLE_INLINE
67 
68 
69 /* Define the ThreadX SMP maximum number of cores.  */
70 
71 #ifndef TX_THREAD_SMP_MAX_CORES
72 #define TX_THREAD_SMP_MAX_CORES                 4
73 #endif
74 
75 
76 
77 /* Define the ThreadX SMP core mask. */
78 
79 #ifndef TX_THREAD_SMP_CORE_MASK
80 #define TX_THREAD_SMP_CORE_MASK                 0xF            /* Where bit 0 represents Core 0, bit 1 represents Core 1, etc.  */
81 #endif
82 
83 /* Define dynamic number of cores option.  When commented out, the number of cores is static.  */
84 
85 /* #define TX_THREAD_SMP_DYNAMIC_CORE_MAX  */
86 
87 
88 /* Define ThreadX SMP initialization macro.  */
89 
90 #define TX_PORT_SPECIFIC_PRE_INITIALIZATION
91 
92 
93 /* Enable the inter-core interrupt logic.  */
94 
95 #define TX_THREAD_SMP_INTER_CORE_INTERRUPT
96 
97 
98 /* Determine if there is customer-specific wakeup logic needed.  */
99 
100 #ifdef TX_THREAD_SMP_WAKEUP_LOGIC
101 
102 /* Include customer-specific wakeup code.  */
103 
104 #include "tx_thread_smp_core_wakeup.h"
105 #else
106 
107 #ifdef TX_THREAD_SMP_DEFAULT_WAKEUP_LOGIC
108 
109 /* Default wakeup code.  */
110 #define TX_THREAD_SMP_WAKEUP_LOGIC
111 #define TX_THREAD_SMP_WAKEUP(i)                _tx_thread_smp_core_preempt(i)
112 #endif
113 #endif
114 
115 
116 /* Ensure that the in-line resume/suspend define is not allowed.  */
117 
118 #ifdef TX_INLINE_THREAD_RESUME_SUSPEND
119 #undef TX_INLINE_THREAD_RESUME_SUSPEND
120 #endif
121 
122 
123 /* Overide inline keyword.  */
124 
125 #define INLINE_DECLARE  __inline
126 
127 
128 /************* End ThreadX SMP constants.  *************/
129 
130 
131 /* Determine if the optional ThreadX user define file should be used.  */
132 
133 #ifdef TX_INCLUDE_USER_DEFINE_FILE
134 
135 
136 /* Yes, include the user defines in tx_user.h. The defines in this file may
137    alternately be defined on the command line.  */
138 
139 #include "tx_user.h"
140 #endif
141 
142 
143 /* Define compiler library include files.  */
144 
145 #include <stdlib.h>
146 #include <string.h>
147 #include <stdint.h>
148 #ifndef __USE_POSIX199309
149 #define __USE_POSIX199309
150 #include <pthread.h>
151 #include <semaphore.h>
152 #include <time.h>
153 #undef __USE_POSIX199309
154 #else /* __USE_POSIX199309 */
155 #include <pthread.h>
156 #include <semaphore.h>
157 #include <time.h>
158 #endif /* __USE_POSIX199309 */
159 
160 
161 /* Define ThreadX basic types for this port.  */
162 
163 typedef void                                    VOID;
164 typedef char                                    CHAR;
165 typedef unsigned char                           UCHAR;
166 typedef int                                     INT;
167 typedef unsigned int                            UINT;
168 typedef long                                    LONG;
169 typedef unsigned long                           ULONG;
170 typedef short                                   SHORT;
171 typedef unsigned short                          USHORT;
172 typedef uint64_t                                ULONG64;
173 #define ULONG64_DEFINED
174 
175 
176 /* Define automated coverage test extensions...  These are required for the
177    ThreadX regression test.  */
178 
179 typedef unsigned int    TEST_FLAG;
180 extern TEST_FLAG        threadx_byte_allocate_loop_test;
181 extern TEST_FLAG        threadx_byte_release_loop_test;
182 extern TEST_FLAG        threadx_mutex_suspension_put_test;
183 extern TEST_FLAG        threadx_mutex_suspension_priority_test;
184 #ifndef TX_TIMER_PROCESS_IN_ISR
185 extern TEST_FLAG        threadx_delete_timer_thread;
186 #endif
187 
188 extern void             abort_and_resume_byte_allocating_thread(void);
189 extern void             abort_all_threads_suspended_on_mutex(void);
190 extern void             suspend_lowest_priority(void);
191 #ifndef TX_TIMER_PROCESS_IN_ISR
192 extern void             delete_timer_thread(void);
193 #endif
194 extern TEST_FLAG        test_stack_analyze_flag;
195 extern TEST_FLAG        test_initialize_flag;
196 extern TEST_FLAG        test_forced_mutex_timeout;
197 extern UINT             mutex_priority_change_extension_selection;
198 extern UINT             priority_change_extension_selection;
199 
200 
201 #ifdef TX_REGRESSION_TEST
202 
203 /* Define extension macros for automated coverage tests.  */
204 
205 
206 #define TX_PORT_SPECIFIC_MEMORY_SYNCHRONIZATION other_core_status =  other_core_status + _tx_thread_system_state[0]; \
207                                                 _tx_thread_system_state[0] =  0;
208 
209 
210 #define TX_BYTE_ALLOCATE_EXTENSION              if (threadx_byte_allocate_loop_test == ((TEST_FLAG) 1))         \
211                                                 {                                                               \
212                                                     pool_ptr -> tx_byte_pool_owner =  TX_NULL;                  \
213                                                     threadx_byte_allocate_loop_test = ((TEST_FLAG) 0);          \
214                                                 }
215 
216 #define TX_BYTE_RELEASE_EXTENSION               if (threadx_byte_release_loop_test == ((TEST_FLAG) 1))          \
217                                                 {                                                               \
218                                                     threadx_byte_release_loop_test = ((TEST_FLAG) 0);           \
219                                                     abort_and_resume_byte_allocating_thread();                  \
220                                                 }
221 
222 #define TX_MUTEX_PUT_EXTENSION_1                if (threadx_mutex_suspension_put_test == ((TEST_FLAG) 1))       \
223                                                 {                                                               \
224                                                     threadx_mutex_suspension_put_test = ((TEST_FLAG) 0);        \
225                                                     abort_all_threads_suspended_on_mutex();                     \
226                                                 }
227 
228 
229 #define TX_MUTEX_PUT_EXTENSION_2                if (test_forced_mutex_timeout == ((TEST_FLAG) 1))               \
230                                                 {                                                               \
231                                                     test_forced_mutex_timeout = ((TEST_FLAG) 0);                \
232                                                     _tx_thread_wait_abort(mutex_ptr -> tx_mutex_suspension_list); \
233                                                 }
234 
235 
236 #define TX_MUTEX_PRIORITY_CHANGE_EXTENSION      if (threadx_mutex_suspension_priority_test == ((TEST_FLAG) 1))  \
237                                                 {                                                               \
238                                                     threadx_mutex_suspension_priority_test = ((TEST_FLAG) 0);   \
239                                                     if (mutex_priority_change_extension_selection == 2)         \
240                                                         original_priority = new_priority;                       \
241                                                     if (mutex_priority_change_extension_selection == 3)         \
242                                                         original_pt_thread =  thread_ptr;                       \
243                                                     if (mutex_priority_change_extension_selection == 4)         \
244                                                     {                                                           \
245                                                         execute_ptr =  thread_ptr;                              \
246                                                         _tx_thread_preemption__threshold_scheduled = TX_NULL;   \
247                                                     }                                                           \
248                                                     suspend_lowest_priority();                                  \
249                                                 }
250 
251 #define TX_THREAD_PRIORITY_CHANGE_EXTENSION     if (priority_change_extension_selection != ((TEST_FLAG) 0))     \
252                                                 {                                                               \
253                                                     if (priority_change_extension_selection == 1)               \
254                                                         thread_ptr -> tx_thread_smp_core_mapped =  TX_THREAD_SMP_MAX_CORES; \
255                                                     else if (priority_change_extension_selection == 2)          \
256                                                     {                                                           \
257                                                         original_priority =  new_priority;                      \
258                                                         _tx_thread_execute_ptr[0] =  TX_NULL;                   \
259                                                     }                                                           \
260                                                     else if (priority_change_extension_selection == 3)          \
261                                                     {                                                           \
262                                                         original_pt_thread =  thread_ptr;                       \
263                                                     }                                                           \
264                                                     else                                                        \
265                                                     {                                                           \
266                                                         _tx_thread_preemption__threshold_scheduled = TX_NULL;   \
267                                                     }                                                           \
268                                                     priority_change_extension_selection =  0;                   \
269                                                 }
270 
271 
272 #ifndef TX_TIMER_PROCESS_IN_ISR
273 
274 #define TX_TIMER_INITIALIZE_EXTENSION(a)        if (threadx_delete_timer_thread == ((TEST_FLAG) 1))             \
275                                                 {                                                               \
276                                                     threadx_delete_timer_thread = ((TEST_FLAG) 0);              \
277                                                     delete_timer_thread();                                      \
278                                                     (a) =  ((UINT) 1);                                          \
279                                                 }
280 
281 #endif
282 
283 #define TX_THREAD_STACK_ANALYZE_EXTENSION       if (test_stack_analyze_flag == ((TEST_FLAG) 1))                 \
284                                                 {                                                               \
285                                                     thread_ptr -> tx_thread_id =  ((TEST_FLAG) 0);              \
286                                                     test_stack_analyze_flag =     ((TEST_FLAG) 0);              \
287                                                 }                                                               \
288                                                 else if (test_stack_analyze_flag == ((TEST_FLAG) 2))            \
289                                                 {                                                               \
290                                                     stack_ptr =  thread_ptr -> tx_thread_stack_start;           \
291                                                     test_stack_analyze_flag =     ((TEST_FLAG) 0);              \
292                                                 }                                                               \
293                                                 else if (test_stack_analyze_flag == ((TEST_FLAG) 3))            \
294                                                 {                                                               \
295                                                     *stack_ptr =  TX_STACK_FILL;                                \
296                                                     test_stack_analyze_flag =     ((TEST_FLAG) 0);              \
297                                                 }                                                               \
298                                                 else                                                            \
299                                                 {                                                               \
300                                                     test_stack_analyze_flag =     ((TEST_FLAG) 0);              \
301                                                 }
302 
303 #define TX_INITIALIZE_KERNEL_ENTER_EXTENSION    if (test_initialize_flag == ((TEST_FLAG) 1))                    \
304                                                 {                                                               \
305                                                     test_initialize_flag =  ((TEST_FLAG) 0);                    \
306                                                     return;                                                     \
307                                                 }
308 
309 #endif
310 
311 
312 /* Add Linux debug insert prototype.  */
313 
314 void    _tx_linux_debug_entry_insert(char *action, char *file, unsigned long line);
315 
316 #ifndef TX_LINUX_DEBUG_ENABLE
317 
318 /* If Linux debug is not enabled, turn logging into white-space.  */
319 
320 #define _tx_linux_debug_entry_insert(a, b, c)
321 
322 #endif
323 
324 
325 
326 /* Define the TX_MEMSET macro to remove library reference.  */
327 
328 #ifndef TX_MISRA_ENABLE
329 #define TX_MEMSET(a,b,c)                        {                                       \
330                                                 UCHAR *ptr;                             \
331                                                 UCHAR value;                            \
332                                                 UINT  i, size;                          \
333                                                     ptr =    (UCHAR *) ((VOID *) a);    \
334                                                     value =  (UCHAR) b;                 \
335                                                     size =   (UINT) c;                  \
336                                                     for (i = 0; i < size; i++)          \
337                                                     {                                   \
338                                                         *ptr++ =  value;                \
339                                                     }                                   \
340                                                 }
341 #endif
342 
343 
344 /* Define the priority levels for ThreadX.  Legal values range
345    from 32 to 1024 and MUST be evenly divisible by 32.  */
346 
347 #ifndef TX_MAX_PRIORITIES
348 #define TX_MAX_PRIORITIES                       32
349 #endif
350 
351 
352 /* Define the minimum stack for a ThreadX thread on this processor. If the size supplied during
353    thread creation is less than this value, the thread create call will return an error.  */
354 
355 #ifndef TX_MINIMUM_STACK
356 #define TX_MINIMUM_STACK                        200         /* Minimum stack size for this port */
357 #endif
358 
359 
360 /* Define the system timer thread's default stack size and priority.  These are only applicable
361    if TX_TIMER_PROCESS_IN_ISR is not defined.  */
362 
363 #ifndef TX_TIMER_THREAD_STACK_SIZE
364 #define TX_TIMER_THREAD_STACK_SIZE              400         /* Default timer thread stack size - Not used in Linux port!  */
365 #endif
366 
367 #ifndef TX_TIMER_THREAD_PRIORITY
368 #define TX_TIMER_THREAD_PRIORITY                0           /* Default timer thread priority    */
369 #endif
370 
371 
372 /* Define various constants for the ThreadX  port.  */
373 
374 #define TX_INT_DISABLE                          1           /* Disable interrupts               */
375 #define TX_INT_ENABLE                           0           /* Enable interrupts                */
376 
377 
378 /* Define the clock source for trace event entry time stamp. The following two item are port specific.
379    For example, if the time source is at the address 0x0a800024 and is 16-bits in size, the clock
380    source constants would be:
381 
382 #define TX_TRACE_TIME_SOURCE                    *((ULONG *) 0x0a800024)
383 #define TX_TRACE_TIME_MASK                      0x0000FFFFUL
384 
385 */
386 
387 #ifndef TX_MISRA_ENABLE
388 #ifndef TX_TRACE_TIME_SOURCE
389 #define TX_TRACE_TIME_SOURCE                    ((ULONG) (_tx_linux_time_stamp.tv_nsec))
390 #endif
391 #else
392 ULONG   _tx_misra_time_stamp_get(VOID);
393 #define TX_TRACE_TIME_SOURCE                    _tx_misra_time_stamp_get()
394 #endif
395 
396 #ifndef TX_TRACE_TIME_MASK
397 #define TX_TRACE_TIME_MASK                      0xFFFFFFFFUL
398 #endif
399 
400 
401 /* Define the port-specific trace extension to pickup the Windows timer.  */
402 
403 #define TX_TRACE_PORT_EXTENSION                 clock_gettime(CLOCK_REALTIME, &_tx_linux_time_stamp);
404 
405 
406 /* Define the port specific options for the _tx_build_options variable. This variable indicates
407    how the ThreadX library was built.  */
408 
409 #define TX_PORT_SPECIFIC_BUILD_OPTIONS          0
410 
411 
412 /* Define the in-line initialization constant so that modules with in-line
413    initialization capabilities can prevent their initialization from being
414    a function call.  */
415 
416 #ifdef TX_MISRA_ENABLE
417 #define TX_DISABLE_INLINE
418 #else
419 #define TX_INLINE_INITIALIZATION
420 #endif
421 
422 
423 /* Define the Linux-specific initialization code that is expanded in the generic source.  */
424 
425 void    _tx_initialize_start_interrupts(void);
426 
427 
428 #define TX_PORT_SPECIFIC_PRE_SCHEDULER_INITIALIZATION                       _tx_initialize_start_interrupts();                  \
429                                                                             {                                                   \
430                                                                             UINT k;                                             \
431                                                                                 for (k = 1; k < TX_THREAD_SMP_MAX_CORES; k++)   \
432                                                                                 {                                               \
433                                                                                     _tx_thread_system_state[k] =  0;            \
434                                                                                 }                                               \
435                                                                             }
436 
437 /* Determine whether or not stack checking is enabled. By default, ThreadX stack checking is
438    disabled. When the following is defined, ThreadX thread stack checking is enabled.  If stack
439    checking is enabled (TX_ENABLE_STACK_CHECKING is defined), the TX_DISABLE_STACK_FILLING
440    define is negated, thereby forcing the stack fill which is necessary for the stack checking
441    logic.  */
442 
443 #ifndef TX_MISRA_ENABLE
444 #ifdef TX_ENABLE_STACK_CHECKING
445 #undef TX_DISABLE_STACK_FILLING
446 #endif
447 #endif
448 
449 
450 /* Define the TX_THREAD control block extensions for this port. The main reason
451    for the multiple macros is so that backward compatibility can be maintained with
452    existing ThreadX kernel awareness modules.  */
453 
454 #define TX_THREAD_EXTENSION_0                                               pthread_t   tx_thread_linux_thread_id; \
455                                                                             sem_t       tx_thread_linux_thread_run_semaphore; \
456                                                                             UINT        tx_thread_linux_suspension_type; \
457                                                                             UINT        tx_thread_linux_mutex_access; \
458                                                                             UINT        tx_thread_linux_int_disabled_flag; \
459                                                                             UINT        tx_thread_linux_deferred_preempt; \
460                                                                             UINT        tx_thread_linux_virtual_core;
461 
462 #define TX_THREAD_EXTENSION_1
463 #define TX_THREAD_EXTENSION_2
464 #define TX_THREAD_EXTENSION_3
465 
466 
467 /* Define the port extensions of the remaining ThreadX objects.  */
468 
469 #define TX_BLOCK_POOL_EXTENSION
470 #define TX_BYTE_POOL_EXTENSION
471 #define TX_EVENT_FLAGS_GROUP_EXTENSION
472 #define TX_MUTEX_EXTENSION
473 #define TX_QUEUE_EXTENSION
474 #define TX_SEMAPHORE_EXTENSION
475 #define TX_TIMER_EXTENSION
476 
477 
478 /* Define the user extension field of the thread control block.  Nothing
479    additional is needed for this port so it is defined as white space.  */
480 
481 #ifndef TX_THREAD_USER_EXTENSION
482 #define TX_THREAD_USER_EXTENSION
483 #endif
484 
485 
486 /* Define the macros for processing extensions in tx_thread_create, tx_thread_delete,
487    tx_thread_shell_entry, and tx_thread_terminate.  */
488 
489 
490 #define TX_THREAD_CREATE_EXTENSION(thread_ptr)
491 #define TX_THREAD_DELETE_EXTENSION(thread_ptr)
492 #define TX_THREAD_COMPLETED_EXTENSION(thread_ptr)
493 #define TX_THREAD_TERMINATED_EXTENSION(thread_ptr)
494 
495 
496 /* Define the ThreadX object creation extensions for the remaining objects.  */
497 
498 #define TX_BLOCK_POOL_CREATE_EXTENSION(pool_ptr)
499 #define TX_BYTE_POOL_CREATE_EXTENSION(pool_ptr)
500 #define TX_EVENT_FLAGS_GROUP_CREATE_EXTENSION(group_ptr)
501 #define TX_MUTEX_CREATE_EXTENSION(mutex_ptr)
502 #define TX_QUEUE_CREATE_EXTENSION(queue_ptr)
503 #define TX_SEMAPHORE_CREATE_EXTENSION(semaphore_ptr)
504 #define TX_TIMER_CREATE_EXTENSION(timer_ptr)
505 
506 
507 /* Define the Linux mutex data structure.  */
508 
509 typedef struct
510 {
511     pthread_mutex_t tx_linux_mutex;
512     pthread_t       tx_linux_mutex_owner;
513     ULONG           tx_linux_mutex_nested_count;
514 } TX_LINUX_MUTEX;
515 
516 
517 /* Define Linux-specific critical section APIs.  */
518 
519 void _tx_linux_mutex_obtain(TX_LINUX_MUTEX *mutex);
520 void _tx_linux_mutex_release(TX_LINUX_MUTEX *mutex);
521 void _tx_linux_mutex_release_all(TX_LINUX_MUTEX *mutex);
522 
523 typedef struct TX_THREAD_STRUCT TX_THREAD;
524 
525 /* Define post completion processing for tx_thread_delete, so that the Linux thread resources are properly removed.  */
526 
527 void _tx_thread_delete_port_completion(TX_THREAD *thread_ptr, UINT tx_interrupt_save);
528 #define TX_THREAD_DELETE_PORT_COMPLETION(thread_ptr) _tx_thread_delete_port_completion(thread_ptr, tx_interrupt_save);
529 
530 
531 /* Define post completion processing for tx_thread_reset, so that the Linux thread resources are properly removed.  */
532 
533 void _tx_thread_reset_port_completion(TX_THREAD *thread_ptr, UINT tx_interrupt_save);
534 #define TX_THREAD_RESET_PORT_COMPLETION(thread_ptr) _tx_thread_reset_port_completion(thread_ptr, tx_interrupt_save);
535 
536 
537 /************* Define ThreadX SMP data types and function prototypes.  *************/
538 
539 struct TX_THREAD_STRUCT;
540 
541 
542 /* Define the ThreadX SMP protection structure.   */
543 
544 typedef struct TX_THREAD_SMP_PROTECT_STRUCT
545 {
546     ULONG                   tx_thread_smp_protect_in_force;
547     struct TX_THREAD_STRUCT *tx_thread_smp_protect_thread;
548     ULONG                   tx_thread_smp_protect_core;
549     ULONG                   tx_thread_smp_protect_count;
550     pthread_t               tx_thread_smp_protect_linux_thread_id;
551 } TX_THREAD_SMP_PROTECT;
552 
553 
554 /* Define the virtual core structure for ThreadX SMP Linux.  This is where we keep the mapping of the core to
555    the actual thread running.  All ISRs are assumed to be running on core 0 for Linux.  */
556 
557 typedef struct TX_THREAD_SMP_CORE_MAPPING_STRUCT
558 {
559     pthread_t               tx_thread_smp_core_mapping_linux_thread_id;
560     struct TX_THREAD_STRUCT *tx_thread_smp_core_mapping_thread;
561 } TX_THREAD_SMP_CORE_MAPPING;
562 
563 
564 /* Define ThreadX SMP low-level assembly routines.   */
565 
566 struct TX_THREAD_STRUCT *   _tx_thread_smp_current_thread_get(void);
567 UINT                        _tx_thread_smp_protect(void);
568 void                        _tx_thread_smp_unprotect(UINT interrupt_save);
569 ULONG                       _tx_thread_smp_current_state_get(void);
570 ULONG                       _tx_thread_smp_time_get(void);
571 
572 
573 /* Determine if SMP Debug is selected.  If so, the function prototype is setup. Otherwise, the debug call is
574    simply mapped to whitespace.  */
575 
576 #ifdef TX_THREAD_SMP_DEBUG_ENABLE
577 void                        _tx_thread_smp_debug_entry_insert(ULONG id, ULONG suspend, VOID *thread_ptr);
578 #else
579 #define                     _tx_thread_smp_debug_entry_insert(a, b, c)
580 #endif
581 
582 
583 /* Define the get core ID macro.  */
584 
585 #define TX_SMP_CORE_ID                          _tx_thread_smp_core_get()
586 
587 
588 
589 
590 /* Define the ThreadX object deletion extensions for the remaining objects.  */
591 
592 #define TX_BLOCK_POOL_DELETE_EXTENSION(pool_ptr)
593 #define TX_BYTE_POOL_DELETE_EXTENSION(pool_ptr)
594 #define TX_EVENT_FLAGS_GROUP_DELETE_EXTENSION(group_ptr)
595 #define TX_MUTEX_DELETE_EXTENSION(mutex_ptr)
596 #define TX_QUEUE_DELETE_EXTENSION(queue_ptr)
597 #define TX_SEMAPHORE_DELETE_EXTENSION(semaphore_ptr)
598 #define TX_TIMER_DELETE_EXTENSION(timer_ptr)
599 
600 
601 /* Define ThreadX interrupt lockout and restore macros for protection on
602    access of critical kernel information.  The restore interrupt macro must
603    restore the interrupt posture of the running thread prior to the value
604    present prior to the disable macro.  In most cases, the save area macro
605    is used to define a local function save area for the disable and restore
606    macros.  */
607 
608 #define TX_INTERRUPT_SAVE_AREA                  UINT tx_interrupt_save;
609 
610 #define TX_DISABLE                              tx_interrupt_save =  _tx_thread_smp_protect();
611 #define TX_RESTORE                              _tx_thread_smp_unprotect(tx_interrupt_save);
612 
613 
614 /************* End ThreadX SMP data type and function prototype definitions.  *************/
615 
616 
617 #define tx_linux_sem_post(p)                sem_post(p)
618 #define tx_linux_sem_wait(p)                sem_wait(p)
619 #define tx_linux_sem_timedwait(p, t)        sem_timedwait(p, t)
620 
621 
622 /* Define the interrupt lockout macros for each ThreadX object.  */
623 
624 #define TX_BLOCK_POOL_DISABLE               TX_DISABLE
625 #define TX_BYTE_POOL_DISABLE                TX_DISABLE
626 #define TX_EVENT_FLAGS_GROUP_DISABLE        TX_DISABLE
627 #define TX_MUTEX_DISABLE                    TX_DISABLE
628 #define TX_QUEUE_DISABLE                    TX_DISABLE
629 #define TX_SEMAPHORE_DISABLE                TX_DISABLE
630 
631 
632 /* Define the version ID of ThreadX.  This may be utilized by the application.  */
633 
634 #ifdef TX_THREAD_INIT
635 CHAR                            _tx_version_id[] =
636                                     "Copyright (c) 2024 Microsoft Corporation.  *  ThreadX SMP/Linux/gcc Version 6.4.1 *";
637 #else
638 extern  CHAR                    _tx_version_id[];
639 #endif
640 
641 
642 /* Define externals for the Linux port of ThreadX.  */
643 
644 extern TX_LINUX_MUTEX                           _tx_linux_mutex;
645 extern sem_t                                    _tx_linux_scheduler_semaphore;
646 extern pthread_t                                _tx_linux_scheduler_id;
647 extern ULONG                                    _tx_linux_global_int_disabled_flag;
648 extern struct timespec                          _tx_linux_time_stamp;
649 extern ULONG                                    _tx_linux_system_error;
650 extern TX_THREAD_SMP_CORE_MAPPING               _tx_linux_virtual_cores[TX_THREAD_SMP_MAX_CORES];
651 extern __thread int                             _tx_linux_threadx_thread;
652 
653 /* Define functions for linux thread. */
654 void    _tx_linux_thread_suspend(pthread_t thread_id);
655 void    _tx_linux_thread_resume(pthread_t thread_id);
656 void    _tx_linux_thread_init();
657 void    _tx_linux_thread_sleep(long ns);
658 
659 #ifndef TX_LINUX_MEMORY_SIZE
660 #define TX_LINUX_MEMORY_SIZE                    100000
661 #endif
662 
663 #ifndef TX_TIMER_TICKS_PER_SECOND
664 #define TX_TIMER_TICKS_PER_SECOND               100UL
665 #endif
666 
667 #ifndef TX_LINUX_THREAD_STACK_SIZE
668 #define TX_LINUX_THREAD_STACK_SIZE              65536
669 #endif
670 
671 /* Define priorities of pthreads. */
672 #define TX_LINUX_PRIORITY_SCHEDULE              (3)
673 #define TX_LINUX_PRIORITY_ISR                   (2)
674 #define TX_LINUX_PRIORITY_USER_THREAD           (1)
675 
676 #endif
677 
678 
679 
680 
681 
682 
683 
684