generated from Template/H563ZI-HAL-CMake-Template
	开启 ThreadX
This commit is contained in:
		
							
								
								
									
										2389
									
								
								Middlewares/ST/threadx/common/inc/tx_api.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2389
									
								
								Middlewares/ST/threadx/common/inc/tx_api.h
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										148
									
								
								Middlewares/ST/threadx/common/inc/tx_block_pool.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										148
									
								
								Middlewares/ST/threadx/common/inc/tx_block_pool.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,148 @@ | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*       Copyright (c) Microsoft Corporation. All rights reserved.        */ | ||||
| /*                                                                        */ | ||||
| /*       This software is licensed under the Microsoft Software License   */ | ||||
| /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */ | ||||
| /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */ | ||||
| /*       and in the root directory of this software.                      */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
| /**                                                                       */ | ||||
| /** ThreadX Component                                                     */ | ||||
| /**                                                                       */ | ||||
| /**   Block Memory                                                        */ | ||||
| /**                                                                       */ | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*  COMPONENT DEFINITION                                   RELEASE        */ | ||||
| /*                                                                        */ | ||||
| /*    tx_block_pool.h                                     PORTABLE C      */ | ||||
| /*                                                           6.1          */ | ||||
| /*  AUTHOR                                                                */ | ||||
| /*                                                                        */ | ||||
| /*    William E. Lamie, Microsoft Corporation                             */ | ||||
| /*                                                                        */ | ||||
| /*  DESCRIPTION                                                           */ | ||||
| /*                                                                        */ | ||||
| /*    This file defines the ThreadX block memory management component,    */ | ||||
| /*    including all data types and external references.  It is assumed    */ | ||||
| /*    that tx_api.h and tx_port.h have already been included.             */ | ||||
| /*                                                                        */ | ||||
| /*  RELEASE HISTORY                                                       */ | ||||
| /*                                                                        */ | ||||
| /*    DATE              NAME                      DESCRIPTION             */ | ||||
| /*                                                                        */ | ||||
| /*  05-19-2020     William E. Lamie         Initial Version 6.0           */ | ||||
| /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */ | ||||
| /*                                            resulting in version 6.1    */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
| #ifndef TX_BLOCK_POOL_H | ||||
| #define TX_BLOCK_POOL_H | ||||
|  | ||||
|  | ||||
| /* Define block memory control specific data definitions.  */ | ||||
|  | ||||
| #define TX_BLOCK_POOL_ID                        ((ULONG) 0x424C4F43) | ||||
|  | ||||
|  | ||||
| /* Determine if in-line component initialization is supported by the | ||||
|    caller.  */ | ||||
|  | ||||
| #ifdef TX_INVOKE_INLINE_INITIALIZATION | ||||
|  | ||||
| /* Yes, in-line initialization is supported, remap the block memory pool | ||||
|    initialization function.  */ | ||||
|  | ||||
| #ifndef TX_BLOCK_POOL_ENABLE_PERFORMANCE_INFO | ||||
| #define _tx_block_pool_initialize() \ | ||||
|                     _tx_block_pool_created_ptr =                   TX_NULL;     \ | ||||
|                     _tx_block_pool_created_count =                 TX_EMPTY | ||||
| #else | ||||
| #define _tx_block_pool_initialize() \ | ||||
|                     _tx_block_pool_created_ptr =                   TX_NULL;     \ | ||||
|                     _tx_block_pool_created_count =                 TX_EMPTY;    \ | ||||
|                     _tx_block_pool_performance_allocate_count =    ((ULONG) 0); \ | ||||
|                     _tx_block_pool_performance_release_count =     ((ULONG) 0); \ | ||||
|                     _tx_block_pool_performance_suspension_count =  ((ULONG) 0); \ | ||||
|                     _tx_block_pool_performance_timeout_count =     ((ULONG) 0) | ||||
| #endif | ||||
| #define TX_BLOCK_POOL_INIT | ||||
| #else | ||||
|  | ||||
| /* No in-line initialization is supported, use standard function call.  */ | ||||
| VOID        _tx_block_pool_initialize(VOID); | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define internal block memory pool management function prototypes.  */ | ||||
|  | ||||
| VOID        _tx_block_pool_cleanup(TX_THREAD *thread_ptr, ULONG suspension_sequence); | ||||
|  | ||||
|  | ||||
| /* Block pool management component data declarations follow.  */ | ||||
|  | ||||
| /* Determine if the initialization function of this component is including | ||||
|    this file.  If so, make the data definitions really happen.  Otherwise, | ||||
|    make them extern so other functions in the component can access them.  */ | ||||
|  | ||||
| #ifdef TX_BLOCK_POOL_INIT | ||||
| #define BLOCK_POOL_DECLARE | ||||
| #else | ||||
| #define BLOCK_POOL_DECLARE extern | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the head pointer of the created block pool list.  */ | ||||
|  | ||||
| BLOCK_POOL_DECLARE  TX_BLOCK_POOL *         _tx_block_pool_created_ptr; | ||||
|  | ||||
|  | ||||
| /* Define the variable that holds the number of created block pools. */ | ||||
|  | ||||
| BLOCK_POOL_DECLARE  ULONG                   _tx_block_pool_created_count; | ||||
|  | ||||
|  | ||||
| #ifdef TX_BLOCK_POOL_ENABLE_PERFORMANCE_INFO | ||||
|  | ||||
| /* Define the total number of block allocates.  */ | ||||
|  | ||||
| BLOCK_POOL_DECLARE  ULONG                  _tx_block_pool_performance_allocate_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of block releases.  */ | ||||
|  | ||||
| BLOCK_POOL_DECLARE  ULONG                  _tx_block_pool_performance_release_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of block pool suspensions.  */ | ||||
|  | ||||
| BLOCK_POOL_DECLARE  ULONG                  _tx_block_pool_performance_suspension_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of block pool timeouts.  */ | ||||
|  | ||||
| BLOCK_POOL_DECLARE  ULONG                  _tx_block_pool_performance_timeout_count; | ||||
|  | ||||
|  | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define default post block pool delete macro to whitespace, if it hasn't been defined previously (typically in tx_port.h).  */ | ||||
|  | ||||
| #ifndef TX_BLOCK_POOL_DELETE_PORT_COMPLETION | ||||
| #define TX_BLOCK_POOL_DELETE_PORT_COMPLETION(p) | ||||
| #endif | ||||
|  | ||||
|  | ||||
| #endif | ||||
							
								
								
									
										179
									
								
								Middlewares/ST/threadx/common/inc/tx_byte_pool.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										179
									
								
								Middlewares/ST/threadx/common/inc/tx_byte_pool.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,179 @@ | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*       Copyright (c) Microsoft Corporation. All rights reserved.        */ | ||||
| /*                                                                        */ | ||||
| /*       This software is licensed under the Microsoft Software License   */ | ||||
| /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */ | ||||
| /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */ | ||||
| /*       and in the root directory of this software.                      */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
| /**                                                                       */ | ||||
| /** ThreadX Component                                                     */ | ||||
| /**                                                                       */ | ||||
| /**   Byte Memory                                                         */ | ||||
| /**                                                                       */ | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*  COMPONENT DEFINITION                                   RELEASE        */ | ||||
| /*                                                                        */ | ||||
| /*    tx_byte_pool.h                                      PORTABLE C      */ | ||||
| /*                                                           6.1          */ | ||||
| /*  AUTHOR                                                                */ | ||||
| /*                                                                        */ | ||||
| /*    William E. Lamie, Microsoft Corporation                             */ | ||||
| /*                                                                        */ | ||||
| /*  DESCRIPTION                                                           */ | ||||
| /*                                                                        */ | ||||
| /*    This file defines the ThreadX byte memory management component,     */ | ||||
| /*    including all data types and external references.  It is assumed    */ | ||||
| /*    that tx_api.h and tx_port.h have already been included.             */ | ||||
| /*                                                                        */ | ||||
| /*  RELEASE HISTORY                                                       */ | ||||
| /*                                                                        */ | ||||
| /*    DATE              NAME                      DESCRIPTION             */ | ||||
| /*                                                                        */ | ||||
| /*  05-19-2020     William E. Lamie         Initial Version 6.0           */ | ||||
| /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */ | ||||
| /*                                            resulting in version 6.1    */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
| #ifndef TX_BYTE_POOL_H | ||||
| #define TX_BYTE_POOL_H | ||||
|  | ||||
|  | ||||
| /* Define byte memory control specific data definitions.  */ | ||||
|  | ||||
| #define TX_BYTE_POOL_ID                         ((ULONG) 0x42595445) | ||||
|  | ||||
| #ifndef TX_BYTE_BLOCK_FREE | ||||
| #define TX_BYTE_BLOCK_FREE                      ((ULONG) 0xFFFFEEEEUL) | ||||
| #endif | ||||
|  | ||||
| #ifndef TX_BYTE_BLOCK_MIN | ||||
| #define TX_BYTE_BLOCK_MIN                       ((ULONG) 20) | ||||
| #endif | ||||
|  | ||||
| #ifndef TX_BYTE_POOL_MIN | ||||
| #define TX_BYTE_POOL_MIN                        ((ULONG) 100) | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Determine if in-line component initialization is supported by the | ||||
|    caller.  */ | ||||
|  | ||||
| #ifdef TX_INVOKE_INLINE_INITIALIZATION | ||||
|  | ||||
| /* Yes, in-line initialization is supported, remap the byte memory pool | ||||
|    initialization function.  */ | ||||
|  | ||||
| #ifndef TX_BYTE_POOL_ENABLE_PERFORMANCE_INFO | ||||
| #define _tx_byte_pool_initialize() \ | ||||
|                     _tx_byte_pool_created_ptr =                   TX_NULL;      \ | ||||
|                     _tx_byte_pool_created_count =                 TX_EMPTY | ||||
| #else | ||||
| #define _tx_byte_pool_initialize() \ | ||||
|                     _tx_byte_pool_created_ptr =                   TX_NULL;      \ | ||||
|                     _tx_byte_pool_created_count =                 TX_EMPTY;     \ | ||||
|                     _tx_byte_pool_performance_allocate_count =    ((ULONG) 0);  \ | ||||
|                     _tx_byte_pool_performance_release_count =     ((ULONG) 0);  \ | ||||
|                     _tx_byte_pool_performance_merge_count =       ((ULONG) 0);  \ | ||||
|                     _tx_byte_pool_performance_split_count =       ((ULONG) 0);  \ | ||||
|                     _tx_byte_pool_performance_search_count =      ((ULONG) 0);  \ | ||||
|                     _tx_byte_pool_performance_suspension_count =  ((ULONG) 0);  \ | ||||
|                     _tx_byte_pool_performance_timeout_count =     ((ULONG) 0) | ||||
| #endif | ||||
| #define TX_BYTE_POOL_INIT | ||||
| #else | ||||
|  | ||||
| /* No in-line initialization is supported, use standard function call.  */ | ||||
| VOID        _tx_byte_pool_initialize(VOID); | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define internal byte memory pool management function prototypes.  */ | ||||
|  | ||||
| UCHAR       *_tx_byte_pool_search(TX_BYTE_POOL *pool_ptr, ULONG memory_size); | ||||
| VOID        _tx_byte_pool_cleanup(TX_THREAD *thread_ptr, ULONG suspension_sequence); | ||||
|  | ||||
|  | ||||
| /* Byte pool management component data declarations follow.  */ | ||||
|  | ||||
| /* Determine if the initialization function of this component is including | ||||
|    this file.  If so, make the data definitions really happen.  Otherwise, | ||||
|    make them extern so other functions in the component can access them.  */ | ||||
|  | ||||
| #ifdef TX_BYTE_POOL_INIT | ||||
| #define BYTE_POOL_DECLARE | ||||
| #else | ||||
| #define BYTE_POOL_DECLARE extern | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the head pointer of the created byte pool list.  */ | ||||
|  | ||||
| BYTE_POOL_DECLARE  TX_BYTE_POOL *   _tx_byte_pool_created_ptr; | ||||
|  | ||||
|  | ||||
| /* Define the variable that holds the number of created byte pools. */ | ||||
|  | ||||
| BYTE_POOL_DECLARE  ULONG            _tx_byte_pool_created_count; | ||||
|  | ||||
|  | ||||
| #ifdef TX_BYTE_POOL_ENABLE_PERFORMANCE_INFO | ||||
|  | ||||
| /* Define the total number of allocates.  */ | ||||
|  | ||||
| BYTE_POOL_DECLARE  ULONG            _tx_byte_pool_performance_allocate_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of releases.  */ | ||||
|  | ||||
| BYTE_POOL_DECLARE  ULONG            _tx_byte_pool_performance_release_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of adjacent memory fragment merges.  */ | ||||
|  | ||||
| BYTE_POOL_DECLARE  ULONG            _tx_byte_pool_performance_merge_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of memory fragment splits.  */ | ||||
|  | ||||
| BYTE_POOL_DECLARE  ULONG            _tx_byte_pool_performance_split_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of memory fragments searched during allocation.  */ | ||||
|  | ||||
| BYTE_POOL_DECLARE  ULONG            _tx_byte_pool_performance_search_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of byte pool suspensions.  */ | ||||
|  | ||||
| BYTE_POOL_DECLARE  ULONG            _tx_byte_pool_performance_suspension_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of byte pool timeouts.  */ | ||||
|  | ||||
| BYTE_POOL_DECLARE  ULONG            _tx_byte_pool_performance_timeout_count; | ||||
|  | ||||
|  | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define default post byte pool delete macro to whitespace, if it hasn't been defined previously (typically in tx_port.h).  */ | ||||
|  | ||||
| #ifndef TX_BYTE_POOL_DELETE_PORT_COMPLETION | ||||
| #define TX_BYTE_POOL_DELETE_PORT_COMPLETION(p) | ||||
| #endif | ||||
|  | ||||
|  | ||||
| #endif | ||||
							
								
								
									
										149
									
								
								Middlewares/ST/threadx/common/inc/tx_event_flags.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										149
									
								
								Middlewares/ST/threadx/common/inc/tx_event_flags.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,149 @@ | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*       Copyright (c) Microsoft Corporation. All rights reserved.        */ | ||||
| /*                                                                        */ | ||||
| /*       This software is licensed under the Microsoft Software License   */ | ||||
| /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */ | ||||
| /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */ | ||||
| /*       and in the root directory of this software.                      */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
| /**                                                                       */ | ||||
| /** ThreadX Component                                                     */ | ||||
| /**                                                                       */ | ||||
| /**   Event Flags                                                         */ | ||||
| /**                                                                       */ | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*  COMPONENT DEFINITION                                   RELEASE        */ | ||||
| /*                                                                        */ | ||||
| /*    tx_event_flags.h                                    PORTABLE C      */ | ||||
| /*                                                           6.1          */ | ||||
| /*  AUTHOR                                                                */ | ||||
| /*                                                                        */ | ||||
| /*    William E. Lamie, Microsoft Corporation                             */ | ||||
| /*                                                                        */ | ||||
| /*  DESCRIPTION                                                           */ | ||||
| /*                                                                        */ | ||||
| /*    This file defines the ThreadX event flags management component,     */ | ||||
| /*    including all data types and external references.  It is assumed    */ | ||||
| /*    that tx_api.h and tx_port.h have already been included.             */ | ||||
| /*                                                                        */ | ||||
| /*  RELEASE HISTORY                                                       */ | ||||
| /*                                                                        */ | ||||
| /*    DATE              NAME                      DESCRIPTION             */ | ||||
| /*                                                                        */ | ||||
| /*  05-19-2020     William E. Lamie         Initial Version 6.0           */ | ||||
| /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */ | ||||
| /*                                            resulting in version 6.1    */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
| #ifndef TX_EVENT_FLAGS_H | ||||
| #define TX_EVENT_FLAGS_H | ||||
|  | ||||
|  | ||||
| /* Define event flags control specific data definitions.  */ | ||||
|  | ||||
| #define TX_EVENT_FLAGS_ID                       ((ULONG) 0x4456444E) | ||||
| #define TX_EVENT_FLAGS_AND_MASK                 ((UINT) 0x2) | ||||
| #define TX_EVENT_FLAGS_CLEAR_MASK               ((UINT) 0x1) | ||||
|  | ||||
|  | ||||
| /* Determine if in-line component initialization is supported by the | ||||
|    caller.  */ | ||||
| #ifdef TX_INVOKE_INLINE_INITIALIZATION | ||||
|  | ||||
| /* Yes, in-line initialization is supported, remap the event flag initialization | ||||
|    function.  */ | ||||
|  | ||||
| #ifndef TX_EVENT_FLAGS_ENABLE_PERFORMANCE_INFO | ||||
| #define _tx_event_flags_initialize() \ | ||||
|                     _tx_event_flags_created_ptr =                   TX_NULL;     \ | ||||
|                     _tx_event_flags_created_count =                 TX_EMPTY | ||||
| #else | ||||
| #define _tx_event_flags_initialize() \ | ||||
|                     _tx_event_flags_created_ptr =                   TX_NULL;     \ | ||||
|                     _tx_event_flags_created_count =                 TX_EMPTY;    \ | ||||
|                     _tx_event_flags_performance_set_count =         ((ULONG) 0); \ | ||||
|                     _tx_event_flags_performance_get_count =         ((ULONG) 0); \ | ||||
|                     _tx_event_flags_performance_suspension_count =  ((ULONG) 0); \ | ||||
|                     _tx_event_flags_performance_timeout_count =     ((ULONG) 0) | ||||
| #endif | ||||
| #define TX_EVENT_FLAGS_INIT | ||||
| #else | ||||
|  | ||||
| /* No in-line initialization is supported, use standard function call.  */ | ||||
| VOID        _tx_event_flags_initialize(VOID); | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define internal event flags management function prototypes.  */ | ||||
|  | ||||
| VOID        _tx_event_flags_cleanup(TX_THREAD *thread_ptr, ULONG suspension_sequence); | ||||
|  | ||||
|  | ||||
| /* Event flags management component data declarations follow.  */ | ||||
|  | ||||
| /* Determine if the initialization function of this component is including | ||||
|    this file.  If so, make the data definitions really happen.  Otherwise, | ||||
|    make them extern so other functions in the component can access them.  */ | ||||
|  | ||||
| #ifdef TX_EVENT_FLAGS_INIT | ||||
| #define EVENT_FLAGS_DECLARE | ||||
| #else | ||||
| #define EVENT_FLAGS_DECLARE extern | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the head pointer of the created event flags list.  */ | ||||
|  | ||||
| EVENT_FLAGS_DECLARE  TX_EVENT_FLAGS_GROUP * _tx_event_flags_created_ptr; | ||||
|  | ||||
|  | ||||
| /* Define the variable that holds the number of created event flag groups. */ | ||||
|  | ||||
| EVENT_FLAGS_DECLARE  ULONG                  _tx_event_flags_created_count; | ||||
|  | ||||
|  | ||||
| #ifdef TX_EVENT_FLAGS_ENABLE_PERFORMANCE_INFO | ||||
|  | ||||
| /* Define the total number of event flag sets.  */ | ||||
|  | ||||
| EVENT_FLAGS_DECLARE  ULONG                  _tx_event_flags_performance_set_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of event flag gets.  */ | ||||
|  | ||||
| EVENT_FLAGS_DECLARE  ULONG                  _tx_event_flags_performance_get_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of event flag suspensions.  */ | ||||
|  | ||||
| EVENT_FLAGS_DECLARE  ULONG                  _tx_event_flags_performance_suspension_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of event flag timeouts.  */ | ||||
|  | ||||
| EVENT_FLAGS_DECLARE  ULONG                  _tx_event_flags_performance_timeout_count; | ||||
|  | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* Define default post event flag group delete macro to whitespace, if it hasn't been defined previously (typically in tx_port.h).  */ | ||||
|  | ||||
| #ifndef TX_EVENT_FLAGS_GROUP_DELETE_PORT_COMPLETION | ||||
| #define TX_EVENT_FLAGS_GROUP_DELETE_PORT_COMPLETION(g) | ||||
| #endif | ||||
|  | ||||
|  | ||||
| #endif | ||||
|  | ||||
							
								
								
									
										113
									
								
								Middlewares/ST/threadx/common/inc/tx_initialize.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								Middlewares/ST/threadx/common/inc/tx_initialize.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,113 @@ | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*       Copyright (c) Microsoft Corporation. All rights reserved.        */ | ||||
| /*                                                                        */ | ||||
| /*       This software is licensed under the Microsoft Software License   */ | ||||
| /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */ | ||||
| /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */ | ||||
| /*       and in the root directory of this software.                      */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
| /**                                                                       */ | ||||
| /** ThreadX Component                                                     */ | ||||
| /**                                                                       */ | ||||
| /**   Initialize                                                          */ | ||||
| /**                                                                       */ | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*  COMPONENT DEFINITION                                   RELEASE        */ | ||||
| /*                                                                        */ | ||||
| /*    tx_initialize.h                                     PORTABLE C      */ | ||||
| /*                                                           6.1          */ | ||||
| /*  AUTHOR                                                                */ | ||||
| /*                                                                        */ | ||||
| /*    William E. Lamie, Microsoft Corporation                             */ | ||||
| /*                                                                        */ | ||||
| /*  DESCRIPTION                                                           */ | ||||
| /*                                                                        */ | ||||
| /*    This file defines the ThreadX initialization component, including   */ | ||||
| /*    data types and external references.  It is assumed that tx_api.h    */ | ||||
| /*    and tx_port.h have already been included.                           */ | ||||
| /*                                                                        */ | ||||
| /*  RELEASE HISTORY                                                       */ | ||||
| /*                                                                        */ | ||||
| /*    DATE              NAME                      DESCRIPTION             */ | ||||
| /*                                                                        */ | ||||
| /*  05-19-2020     William E. Lamie         Initial Version 6.0           */ | ||||
| /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */ | ||||
| /*                                            resulting in version 6.1    */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
| #ifndef TX_INITIALIZE_H | ||||
| #define TX_INITIALIZE_H | ||||
|  | ||||
|  | ||||
| /* Define constants that indicate initialization is in progress.  */ | ||||
|  | ||||
| #define TX_INITIALIZE_IN_PROGRESS               ((ULONG) 0xF0F0F0F0UL) | ||||
| #define TX_INITIALIZE_ALMOST_DONE               ((ULONG) 0xF0F0F0F1UL) | ||||
| #define TX_INITIALIZE_IS_FINISHED               ((ULONG) 0x00000000UL) | ||||
|  | ||||
|  | ||||
| /* Define internal initialization function prototypes.  */ | ||||
|  | ||||
| VOID        _tx_initialize_high_level(VOID); | ||||
| VOID        _tx_initialize_kernel_setup(VOID); | ||||
| VOID        _tx_initialize_low_level(VOID); | ||||
|  | ||||
|  | ||||
| /* Define the macro for adding additional port-specific global data. This macro is defined | ||||
|    as white space, unless defined by tx_port.h.  */ | ||||
|  | ||||
| #ifndef TX_PORT_SPECIFIC_DATA | ||||
| #define TX_PORT_SPECIFIC_DATA | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the macro for adding additional port-specific pre and post initialization processing. | ||||
|    These macros is defined as white space, unless defined by tx_port.h.  */ | ||||
|  | ||||
| #ifndef TX_PORT_SPECIFIC_PRE_INITIALIZATION | ||||
| #define TX_PORT_SPECIFIC_PRE_INITIALIZATION | ||||
| #endif | ||||
|  | ||||
| #ifndef TX_PORT_SPECIFIC_POST_INITIALIZATION | ||||
| #define TX_PORT_SPECIFIC_POST_INITIALIZATION | ||||
| #endif | ||||
|  | ||||
| #ifndef TX_PORT_SPECIFIC_PRE_SCHEDULER_INITIALIZATION | ||||
| #define TX_PORT_SPECIFIC_PRE_SCHEDULER_INITIALIZATION | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Initialization component data declarations follow.  */ | ||||
|  | ||||
| /* Determine if the initialization function of this component is including | ||||
|    this file.  If so, make the data definitions really happen.  Otherwise, | ||||
|    make them extern so other functions in the component can access them.  */ | ||||
|  | ||||
| #ifdef TX_INITIALIZE_INIT | ||||
| #define INITIALIZE_DECLARE | ||||
| #else | ||||
| #define INITIALIZE_DECLARE extern | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the unused memory pointer.  The value of the first available | ||||
|    memory address is placed in this variable in the low-level | ||||
|    initialization function.  The content of this variable is passed | ||||
|    to the application's system definition function.  */ | ||||
|  | ||||
| INITIALIZE_DECLARE VOID     *_tx_initialize_unused_memory; | ||||
|  | ||||
|  | ||||
| #endif | ||||
							
								
								
									
										162
									
								
								Middlewares/ST/threadx/common/inc/tx_mutex.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										162
									
								
								Middlewares/ST/threadx/common/inc/tx_mutex.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,162 @@ | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*       Copyright (c) Microsoft Corporation. All rights reserved.        */ | ||||
| /*                                                                        */ | ||||
| /*       This software is licensed under the Microsoft Software License   */ | ||||
| /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */ | ||||
| /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */ | ||||
| /*       and in the root directory of this software.                      */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
| /**                                                                       */ | ||||
| /** ThreadX Component                                                     */ | ||||
| /**                                                                       */ | ||||
| /**   Mutex                                                               */ | ||||
| /**                                                                       */ | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*  COMPONENT DEFINITION                                   RELEASE        */ | ||||
| /*                                                                        */ | ||||
| /*    tx_mutex.h                                          PORTABLE C      */ | ||||
| /*                                                           6.1          */ | ||||
| /*  AUTHOR                                                                */ | ||||
| /*                                                                        */ | ||||
| /*    William E. Lamie, Microsoft Corporation                             */ | ||||
| /*                                                                        */ | ||||
| /*  DESCRIPTION                                                           */ | ||||
| /*                                                                        */ | ||||
| /*    This file defines the ThreadX mutex management component,           */ | ||||
| /*    including all data types and external references.  It is assumed    */ | ||||
| /*    that tx_api.h and tx_port.h have already been included.             */ | ||||
| /*                                                                        */ | ||||
| /*  RELEASE HISTORY                                                       */ | ||||
| /*                                                                        */ | ||||
| /*    DATE              NAME                      DESCRIPTION             */ | ||||
| /*                                                                        */ | ||||
| /*  05-19-2020     William E. Lamie         Initial Version 6.0           */ | ||||
| /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */ | ||||
| /*                                            resulting in version 6.1    */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
| #ifndef TX_MUTEX_H | ||||
| #define TX_MUTEX_H | ||||
|  | ||||
|  | ||||
| /* Define mutex control specific data definitions.  */ | ||||
|  | ||||
| #define TX_MUTEX_ID                             ((ULONG) 0x4D555445) | ||||
|  | ||||
|  | ||||
| /* Determine if in-line component initialization is supported by the | ||||
|    caller.  */ | ||||
|  | ||||
| #ifdef TX_INVOKE_INLINE_INITIALIZATION | ||||
|  | ||||
| /* Yes, in-line initialization is supported, remap the mutex initialization | ||||
|    function.  */ | ||||
|  | ||||
| #ifndef TX_MUTEX_ENABLE_PERFORMANCE_INFO | ||||
| #define _tx_mutex_initialize() \ | ||||
|                     _tx_mutex_created_ptr =                             TX_NULL;      \ | ||||
|                     _tx_mutex_created_count =                           TX_EMPTY | ||||
| #else | ||||
| #define _tx_mutex_initialize() \ | ||||
|                     _tx_mutex_created_ptr =                             TX_NULL;      \ | ||||
|                     _tx_mutex_created_count =                           TX_EMPTY;     \ | ||||
|                     _tx_mutex_performance_put_count =                   ((ULONG) 0);  \ | ||||
|                     _tx_mutex_performance_get_count =                   ((ULONG) 0);  \ | ||||
|                     _tx_mutex_performance_suspension_count =            ((ULONG) 0);  \ | ||||
|                     _tx_mutex_performance_timeout_count =               ((ULONG) 0);  \ | ||||
|                     _tx_mutex_performance_priority_inversion_count =    ((ULONG) 0);  \ | ||||
|                     _tx_mutex_performance__priority_inheritance_count = ((ULONG) 0) | ||||
| #endif | ||||
| #define TX_MUTEX_INIT | ||||
| #else | ||||
|  | ||||
| /* No in-line initialization is supported, use standard function call.  */ | ||||
| VOID        _tx_mutex_initialize(VOID); | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define internal mutex management function prototypes.  */ | ||||
|  | ||||
| VOID        _tx_mutex_cleanup(TX_THREAD *thread_ptr, ULONG suspension_sequence); | ||||
| VOID        _tx_mutex_thread_release(TX_THREAD *thread_ptr); | ||||
| VOID        _tx_mutex_priority_change(TX_THREAD *thread_ptr, UINT new_priority); | ||||
|  | ||||
|  | ||||
| /* Mutex management component data declarations follow.  */ | ||||
|  | ||||
| /* Determine if the initialization function of this component is including | ||||
|    this file.  If so, make the data definitions really happen.  Otherwise, | ||||
|    make them extern so other functions in the component can access them.  */ | ||||
|  | ||||
| #ifdef TX_MUTEX_INIT | ||||
| #define MUTEX_DECLARE | ||||
| #else | ||||
| #define MUTEX_DECLARE extern | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the head pointer of the created mutex list.  */ | ||||
|  | ||||
| MUTEX_DECLARE  TX_MUTEX *   _tx_mutex_created_ptr; | ||||
|  | ||||
|  | ||||
| /* Define the variable that holds the number of created mutexes. */ | ||||
|  | ||||
| MUTEX_DECLARE  ULONG        _tx_mutex_created_count; | ||||
|  | ||||
|  | ||||
| #ifdef TX_MUTEX_ENABLE_PERFORMANCE_INFO | ||||
|  | ||||
| /* Define the total number of mutex puts.  */ | ||||
|  | ||||
| MUTEX_DECLARE  ULONG        _tx_mutex_performance_put_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of mutex gets.  */ | ||||
|  | ||||
| MUTEX_DECLARE  ULONG        _tx_mutex_performance_get_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of mutex suspensions.  */ | ||||
|  | ||||
| MUTEX_DECLARE  ULONG        _tx_mutex_performance_suspension_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of mutex timeouts.  */ | ||||
|  | ||||
| MUTEX_DECLARE  ULONG        _tx_mutex_performance_timeout_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of priority inversions.  */ | ||||
|  | ||||
| MUTEX_DECLARE  ULONG        _tx_mutex_performance_priority_inversion_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of priority inheritance conditions.  */ | ||||
|  | ||||
| MUTEX_DECLARE  ULONG        _tx_mutex_performance__priority_inheritance_count; | ||||
|  | ||||
|  | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define default post mutex delete macro to whitespace, if it hasn't been defined previously (typically in tx_port.h).  */ | ||||
|  | ||||
| #ifndef TX_MUTEX_DELETE_PORT_COMPLETION | ||||
| #define TX_MUTEX_DELETE_PORT_COMPLETION(m) | ||||
| #endif | ||||
|  | ||||
|  | ||||
| #endif | ||||
							
								
								
									
										175
									
								
								Middlewares/ST/threadx/common/inc/tx_queue.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										175
									
								
								Middlewares/ST/threadx/common/inc/tx_queue.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,175 @@ | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*       Copyright (c) Microsoft Corporation. All rights reserved.        */ | ||||
| /*                                                                        */ | ||||
| /*       This software is licensed under the Microsoft Software License   */ | ||||
| /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */ | ||||
| /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */ | ||||
| /*       and in the root directory of this software.                      */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
| /**                                                                       */ | ||||
| /** ThreadX Component                                                     */ | ||||
| /**                                                                       */ | ||||
| /**   Queue                                                               */ | ||||
| /**                                                                       */ | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*  COMPONENT DEFINITION                                   RELEASE        */ | ||||
| /*                                                                        */ | ||||
| /*    tx_queue.h                                          PORTABLE C      */ | ||||
| /*                                                           6.1          */ | ||||
| /*  AUTHOR                                                                */ | ||||
| /*                                                                        */ | ||||
| /*    William E. Lamie, Microsoft Corporation                             */ | ||||
| /*                                                                        */ | ||||
| /*  DESCRIPTION                                                           */ | ||||
| /*                                                                        */ | ||||
| /*    This file defines the ThreadX queue management component,           */ | ||||
| /*    including all data types and external references.  It is assumed    */ | ||||
| /*    that tx_api.h and tx_port.h have already been included.             */ | ||||
| /*                                                                        */ | ||||
| /*  RELEASE HISTORY                                                       */ | ||||
| /*                                                                        */ | ||||
| /*    DATE              NAME                      DESCRIPTION             */ | ||||
| /*                                                                        */ | ||||
| /*  05-19-2020     William E. Lamie         Initial Version 6.0           */ | ||||
| /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */ | ||||
| /*                                            resulting in version 6.1    */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
| #ifndef TX_QUEUE_H | ||||
| #define TX_QUEUE_H | ||||
|  | ||||
|  | ||||
| /* Define queue control specific data definitions.  */ | ||||
|  | ||||
| #define TX_QUEUE_ID                             ((ULONG) 0x51554555) | ||||
|  | ||||
|  | ||||
| /* Determine if in-line component initialization is supported by the | ||||
|    caller.  */ | ||||
| #ifdef TX_INVOKE_INLINE_INITIALIZATION | ||||
|  | ||||
| /* Yes, in-line initialization is supported, remap the queue initialization | ||||
|    function.  */ | ||||
|  | ||||
| #ifndef TX_QUEUE_ENABLE_PERFORMANCE_INFO | ||||
| #define _tx_queue_initialize() \ | ||||
|                     _tx_queue_created_ptr =                          TX_NULL;     \ | ||||
|                     _tx_queue_created_count =                        TX_EMPTY | ||||
| #else | ||||
| #define _tx_queue_initialize() \ | ||||
|                     _tx_queue_created_ptr =                          TX_NULL;     \ | ||||
|                     _tx_queue_created_count =                        TX_EMPTY;    \ | ||||
|                     _tx_queue_performance_messages_sent_count =      ((ULONG) 0); \ | ||||
|                     _tx_queue_performance__messages_received_count = ((ULONG) 0); \ | ||||
|                     _tx_queue_performance_empty_suspension_count =   ((ULONG) 0); \ | ||||
|                     _tx_queue_performance_full_suspension_count =    ((ULONG) 0); \ | ||||
|                     _tx_queue_performance_timeout_count =            ((ULONG) 0) | ||||
| #endif | ||||
| #define TX_QUEUE_INIT | ||||
| #else | ||||
|  | ||||
| /* No in-line initialization is supported, use standard function call.  */ | ||||
| VOID        _tx_queue_initialize(VOID); | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the message copy macro. Note that the source and destination | ||||
|    pointers must be modified since they are used subsequently.  */ | ||||
|  | ||||
| #ifndef TX_QUEUE_MESSAGE_COPY | ||||
| #define TX_QUEUE_MESSAGE_COPY(s, d, z)          \ | ||||
|                     *(d)++ = *(s)++;            \ | ||||
|                     if ((z) > ((UINT) 1))       \ | ||||
|                     {                           \ | ||||
|                         while (--(z))           \ | ||||
|                         {                       \ | ||||
|                             *(d)++ =  *(s)++;   \ | ||||
|                          }                      \ | ||||
|                     } | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define internal queue management function prototypes.  */ | ||||
|  | ||||
| VOID        _tx_queue_cleanup(TX_THREAD *thread_ptr, ULONG suspension_sequence); | ||||
|  | ||||
|  | ||||
| /* Queue management component data declarations follow.  */ | ||||
|  | ||||
| /* Determine if the initialization function of this component is including | ||||
|    this file.  If so, make the data definitions really happen.  Otherwise, | ||||
|    make them extern so other functions in the component can access them.  */ | ||||
|  | ||||
| #ifdef TX_QUEUE_INIT | ||||
| #define QUEUE_DECLARE | ||||
| #else | ||||
| #define QUEUE_DECLARE extern | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the head pointer of the created queue list.  */ | ||||
|  | ||||
| QUEUE_DECLARE  TX_QUEUE *   _tx_queue_created_ptr; | ||||
|  | ||||
|  | ||||
| /* Define the variable that holds the number of created queues. */ | ||||
|  | ||||
| QUEUE_DECLARE  ULONG        _tx_queue_created_count; | ||||
|  | ||||
|  | ||||
| #ifdef TX_QUEUE_ENABLE_PERFORMANCE_INFO | ||||
|  | ||||
| /* Define the total number of messages sent.  */ | ||||
|  | ||||
| QUEUE_DECLARE  ULONG        _tx_queue_performance_messages_sent_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of messages received.  */ | ||||
|  | ||||
| QUEUE_DECLARE  ULONG        _tx_queue_performance__messages_received_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of queue empty suspensions.  */ | ||||
|  | ||||
| QUEUE_DECLARE  ULONG        _tx_queue_performance_empty_suspension_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of queue full suspensions.  */ | ||||
|  | ||||
| QUEUE_DECLARE  ULONG        _tx_queue_performance_full_suspension_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of queue full errors.  */ | ||||
|  | ||||
| QUEUE_DECLARE  ULONG        _tx_queue_performance_full_error_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of queue timeouts.  */ | ||||
|  | ||||
| QUEUE_DECLARE  ULONG        _tx_queue_performance_timeout_count; | ||||
|  | ||||
|  | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define default post queue delete macro to whitespace, if it hasn't been defined previously (typically in tx_port.h).  */ | ||||
|  | ||||
| #ifndef TX_QUEUE_DELETE_PORT_COMPLETION | ||||
| #define TX_QUEUE_DELETE_PORT_COMPLETION(q) | ||||
| #endif | ||||
|  | ||||
|  | ||||
| #endif | ||||
|  | ||||
							
								
								
									
										146
									
								
								Middlewares/ST/threadx/common/inc/tx_semaphore.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										146
									
								
								Middlewares/ST/threadx/common/inc/tx_semaphore.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,146 @@ | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*       Copyright (c) Microsoft Corporation. All rights reserved.        */ | ||||
| /*                                                                        */ | ||||
| /*       This software is licensed under the Microsoft Software License   */ | ||||
| /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */ | ||||
| /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */ | ||||
| /*       and in the root directory of this software.                      */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
| /**                                                                       */ | ||||
| /** ThreadX Component                                                     */ | ||||
| /**                                                                       */ | ||||
| /**   Semaphore                                                           */ | ||||
| /**                                                                       */ | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*  COMPONENT DEFINITION                                   RELEASE        */ | ||||
| /*                                                                        */ | ||||
| /*    tx_semaphore.h                                      PORTABLE C      */ | ||||
| /*                                                           6.1          */ | ||||
| /*  AUTHOR                                                                */ | ||||
| /*                                                                        */ | ||||
| /*    William E. Lamie, Microsoft Corporation                             */ | ||||
| /*                                                                        */ | ||||
| /*  DESCRIPTION                                                           */ | ||||
| /*                                                                        */ | ||||
| /*    This file defines the ThreadX semaphore management component,       */ | ||||
| /*    including all data types and external references.  It is assumed    */ | ||||
| /*    that tx_api.h and tx_port.h have already been included.             */ | ||||
| /*                                                                        */ | ||||
| /*  RELEASE HISTORY                                                       */ | ||||
| /*                                                                        */ | ||||
| /*    DATE              NAME                      DESCRIPTION             */ | ||||
| /*                                                                        */ | ||||
| /*  05-19-2020     William E. Lamie         Initial Version 6.0           */ | ||||
| /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */ | ||||
| /*                                            resulting in version 6.1    */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
| #ifndef TX_SEMAPHORE_H | ||||
| #define TX_SEMAPHORE_H | ||||
|  | ||||
|  | ||||
| /* Define semaphore control specific data definitions.  */ | ||||
|  | ||||
| #define TX_SEMAPHORE_ID                         ((ULONG) 0x53454D41) | ||||
|  | ||||
|  | ||||
| /* Determine if in-line component initialization is supported by the | ||||
|    caller.  */ | ||||
| #ifdef TX_INVOKE_INLINE_INITIALIZATION | ||||
|             /* Yes, in-line initialization is supported, remap the | ||||
|                semaphore initialization function.  */ | ||||
| #ifndef TX_SEMAPHORE_ENABLE_PERFORMANCE_INFO | ||||
| #define _tx_semaphore_initialize() \ | ||||
|                     _tx_semaphore_created_ptr =                   TX_NULL;     \ | ||||
|                     _tx_semaphore_created_count =                 TX_EMPTY | ||||
| #else | ||||
| #define _tx_semaphore_initialize() \ | ||||
|                     _tx_semaphore_created_ptr =                   TX_NULL;     \ | ||||
|                     _tx_semaphore_created_count =                 TX_EMPTY;    \ | ||||
|                     _tx_semaphore_performance_put_count =         ((ULONG) 0); \ | ||||
|                     _tx_semaphore_performance_get_count =         ((ULONG) 0); \ | ||||
|                     _tx_semaphore_performance_suspension_count =  ((ULONG) 0); \ | ||||
|                     _tx_semaphore_performance_timeout_count =     ((ULONG) 0) | ||||
| #endif | ||||
| #define TX_SEMAPHORE_INIT | ||||
| #else | ||||
|             /* No in-line initialization is supported, use standard | ||||
|                function call.  */ | ||||
| VOID        _tx_semaphore_initialize(VOID); | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define internal semaphore management function prototypes.  */ | ||||
|  | ||||
| VOID        _tx_semaphore_cleanup(TX_THREAD *thread_ptr, ULONG suspension_sequence); | ||||
|  | ||||
|  | ||||
| /* Semaphore management component data declarations follow.  */ | ||||
|  | ||||
| /* Determine if the initialization function of this component is including | ||||
|    this file.  If so, make the data definitions really happen.  Otherwise, | ||||
|    make them extern so other functions in the component can access them.  */ | ||||
|  | ||||
| #ifdef TX_SEMAPHORE_INIT | ||||
| #define SEMAPHORE_DECLARE | ||||
| #else | ||||
| #define SEMAPHORE_DECLARE extern | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the head pointer of the created semaphore list.  */ | ||||
|  | ||||
| SEMAPHORE_DECLARE  TX_SEMAPHORE *   _tx_semaphore_created_ptr; | ||||
|  | ||||
|  | ||||
| /* Define the variable that holds the number of created semaphores. */ | ||||
|  | ||||
| SEMAPHORE_DECLARE  ULONG            _tx_semaphore_created_count; | ||||
|  | ||||
|  | ||||
| #ifdef TX_SEMAPHORE_ENABLE_PERFORMANCE_INFO | ||||
|  | ||||
| /* Define the total number of semaphore puts.  */ | ||||
|  | ||||
| SEMAPHORE_DECLARE  ULONG            _tx_semaphore_performance_put_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of semaphore gets.  */ | ||||
|  | ||||
| SEMAPHORE_DECLARE  ULONG            _tx_semaphore_performance_get_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of semaphore suspensions.  */ | ||||
|  | ||||
| SEMAPHORE_DECLARE  ULONG            _tx_semaphore_performance_suspension_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of semaphore timeouts.  */ | ||||
|  | ||||
| SEMAPHORE_DECLARE  ULONG            _tx_semaphore_performance_timeout_count; | ||||
|  | ||||
|  | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define default post semaphore delete macro to whitespace, if it hasn't been defined previously (typically in tx_port.h).  */ | ||||
|  | ||||
| #ifndef TX_SEMAPHORE_DELETE_PORT_COMPLETION | ||||
| #define TX_SEMAPHORE_DELETE_PORT_COMPLETION(s) | ||||
| #endif | ||||
|  | ||||
|  | ||||
| #endif | ||||
|  | ||||
							
								
								
									
										534
									
								
								Middlewares/ST/threadx/common/inc/tx_thread.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										534
									
								
								Middlewares/ST/threadx/common/inc/tx_thread.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,534 @@ | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*       Copyright (c) Microsoft Corporation. All rights reserved.        */ | ||||
| /*                                                                        */ | ||||
| /*       This software is licensed under the Microsoft Software License   */ | ||||
| /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */ | ||||
| /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */ | ||||
| /*       and in the root directory of this software.                      */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
| /**                                                                       */ | ||||
| /** ThreadX Component                                                     */ | ||||
| /**                                                                       */ | ||||
| /**   Thread                                                              */ | ||||
| /**                                                                       */ | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*  COMPONENT DEFINITION                                   RELEASE        */ | ||||
| /*                                                                        */ | ||||
| /*    tx_thread.h                                         PORTABLE C      */ | ||||
| /*                                                           6.1.9        */ | ||||
| /*  AUTHOR                                                                */ | ||||
| /*                                                                        */ | ||||
| /*    William E. Lamie, Microsoft Corporation                             */ | ||||
| /*                                                                        */ | ||||
| /*  DESCRIPTION                                                           */ | ||||
| /*                                                                        */ | ||||
| /*    This file defines the ThreadX thread control component, including   */ | ||||
| /*    data types and external references.  It is assumed that tx_api.h    */ | ||||
| /*    and tx_port.h have already been included.                           */ | ||||
| /*                                                                        */ | ||||
| /*  RELEASE HISTORY                                                       */ | ||||
| /*                                                                        */ | ||||
| /*    DATE              NAME                      DESCRIPTION             */ | ||||
| /*                                                                        */ | ||||
| /*  05-19-2020     William E. Lamie         Initial Version 6.0           */ | ||||
| /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */ | ||||
| /*                                            resulting in version 6.1    */ | ||||
| /*  11-09-2020     Yuxin Zhou               Modified comment(s), and      */ | ||||
| /*                                            moved TX_THREAD_GET_SYSTEM_ */ | ||||
| /*                                            STATE to tx_api.h,          */ | ||||
| /*                                            resulting in version 6.1.2  */ | ||||
| /*  10-15-2021     Scott Larson             Modified comment(s), improved */ | ||||
| /*                                            stack check error handling, */ | ||||
| /*                                            resulting in version 6.1.9  */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
| #ifndef TX_THREAD_H | ||||
| #define TX_THREAD_H | ||||
|  | ||||
|  | ||||
| /* Define thread control specific data definitions.  */ | ||||
|  | ||||
| #define TX_THREAD_ID                            ((ULONG) 0x54485244) | ||||
| #define TX_THREAD_PRIORITY_GROUP_MASK           ((ULONG) 0xFF) | ||||
| #define TX_THREAD_EXECUTE_LOG_SIZE              ((UINT) 8) | ||||
|  | ||||
|  | ||||
| /* Define the MOD32 bit set macro that is used to set/clear a priority bit within a specific | ||||
|    priority group.  */ | ||||
|  | ||||
| #if TX_MAX_PRIORITIES > 32 | ||||
| #define MAP_INDEX                               (map_index) | ||||
| #ifndef TX_MOD32_BIT_SET | ||||
| #define TX_MOD32_BIT_SET(a,b)                   (b) = (((ULONG) 1) << ((a)%((UINT)32))); | ||||
| #endif | ||||
| #else | ||||
| #define MAP_INDEX                               (0) | ||||
| #ifndef TX_MOD32_BIT_SET | ||||
| #define TX_MOD32_BIT_SET(a,b)                   (b) = (((ULONG) 1) << ((a))); | ||||
| #endif | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the DIV32 bit set macro that is used to set/clear a priority group bit and is | ||||
|    only necessary when using priorities greater than 32.  */ | ||||
|  | ||||
| #if TX_MAX_PRIORITIES > 32 | ||||
| #ifndef TX_DIV32_BIT_SET | ||||
| #define TX_DIV32_BIT_SET(a,b)                   (b) = (((ULONG) 1) << ((a)/((UINT) 32))); | ||||
| #endif | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define state change macro that can be used by run-mode debug agents to keep track of thread | ||||
|    state changes. By default, it is mapped to white space.  */ | ||||
|  | ||||
| #ifndef TX_THREAD_STATE_CHANGE | ||||
| #define TX_THREAD_STATE_CHANGE(a, b) | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the macro to get the current thread pointer. This is particularly useful in SMP | ||||
|    versions of ThreadX to add additional processing.  The default implementation is to simply | ||||
|    access the global current thread pointer directly.  */ | ||||
|  | ||||
| #ifndef TX_THREAD_GET_CURRENT | ||||
| #define TX_THREAD_GET_CURRENT(a)            (a) =  _tx_thread_current_ptr; | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the macro to set the current thread pointer. This is particularly useful in SMP | ||||
|    versions of ThreadX to add additional processing.  The default implementation is to simply | ||||
|    access the global current thread pointer directly.  */ | ||||
|  | ||||
| #ifndef TX_THREAD_SET_CURRENT | ||||
| #define TX_THREAD_SET_CURRENT(a)            _tx_thread_current_ptr =  (a); | ||||
| #endif | ||||
|  | ||||
|  | ||||
|  | ||||
| /* Define the get system state macro. By default, it simply maps to the variable _tx_thread_system_state.  */ | ||||
| /* This symbol is moved to tx_api.h. Therefore removed from this file. | ||||
| #ifndef TX_THREAD_GET_SYSTEM_STATE | ||||
| #define TX_THREAD_GET_SYSTEM_STATE()        _tx_thread_system_state | ||||
| #endif | ||||
| */ | ||||
|  | ||||
| /* Define the check for whether or not to call the _tx_thread_system_return function.  A non-zero value | ||||
|    indicates that _tx_thread_system_return should not be called.  */ | ||||
|  | ||||
| #ifndef TX_THREAD_SYSTEM_RETURN_CHECK | ||||
| #define TX_THREAD_SYSTEM_RETURN_CHECK(c)    (c) = (ULONG) _tx_thread_preempt_disable; (c) = (c) | TX_THREAD_GET_SYSTEM_STATE(); | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the timeout setup macro used in _tx_thread_create.  */ | ||||
|  | ||||
| #ifndef TX_THREAD_CREATE_TIMEOUT_SETUP | ||||
| #define TX_THREAD_CREATE_TIMEOUT_SETUP(t)    (t) -> tx_thread_timer.tx_timer_internal_timeout_function =  &(_tx_thread_timeout);                \ | ||||
|                                              (t) -> tx_thread_timer.tx_timer_internal_timeout_param =     TX_POINTER_TO_ULONG_CONVERT((t)); | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the thread timeout pointer setup macro used in _tx_thread_timeout.  */ | ||||
|  | ||||
| #ifndef TX_THREAD_TIMEOUT_POINTER_SETUP | ||||
| #define TX_THREAD_TIMEOUT_POINTER_SETUP(t)   (t) =  TX_ULONG_TO_THREAD_POINTER_CONVERT(timeout_input); | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the lowest bit set macro. Note, that this may be overridden | ||||
|    by a port specific definition if there is supporting assembly language | ||||
|    instructions in the architecture.  */ | ||||
|  | ||||
| #ifndef TX_LOWEST_SET_BIT_CALCULATE | ||||
| #define TX_LOWEST_SET_BIT_CALCULATE(m, b)       \ | ||||
|     (b) =  ((ULONG) 0);                         \ | ||||
|     (m) =  (m) & ((~(m)) + ((ULONG) 1));        \ | ||||
|     if ((m) < ((ULONG) 0x10))                   \ | ||||
|     {                                           \ | ||||
|         if ((m) >= ((ULONG) 4))                 \ | ||||
|         {                                       \ | ||||
|             (m) = (m) >> ((ULONG) 2);           \ | ||||
|             (b) = (b) + ((ULONG) 2);            \ | ||||
|         }                                       \ | ||||
|         (b) = (b) + ((m) >> ((ULONG) 1));       \ | ||||
|     }                                           \ | ||||
|     else if ((m) < ((ULONG) 0x100))             \ | ||||
|     {                                           \ | ||||
|         (m) = (m) >> ((ULONG) 4);               \ | ||||
|         (b) = (b) + ((ULONG) 4);                \ | ||||
|         if ((m) >= ((ULONG) 4))                 \ | ||||
|         {                                       \ | ||||
|             (m) = (m) >> ((ULONG) 2);           \ | ||||
|             (b) = (b) + ((ULONG) 2);            \ | ||||
|         }                                       \ | ||||
|         (b) = (b) + ((m) >> ((ULONG) 1));       \ | ||||
|     }                                           \ | ||||
|     else if ((m) < ((ULONG) 0x10000))           \ | ||||
|     {                                           \ | ||||
|         (m) = (m) >> ((ULONG) 8);               \ | ||||
|         (b) = (b) + ((ULONG) 8);                \ | ||||
|         if ((m) >= ((ULONG) 0x10))              \ | ||||
|         {                                       \ | ||||
|             (m) = (m) >> ((ULONG) 4);           \ | ||||
|             (b) = (b) + ((ULONG) 4);            \ | ||||
|         }                                       \ | ||||
|         if ((m) >= ((ULONG) 4))                 \ | ||||
|         {                                       \ | ||||
|             (m) = (m) >> ((ULONG) 2);           \ | ||||
|             (b) = (b) + ((ULONG) 2);            \ | ||||
|         }                                       \ | ||||
|         (b) = (b) + ((m) >> ((ULONG) 1));       \ | ||||
|     }                                           \ | ||||
|     else                                        \ | ||||
|     {                                           \ | ||||
|         (m) = (m) >> ((ULONG) 16);              \ | ||||
|         (b) = (b) + ((ULONG) 16);               \ | ||||
|         if ((m) >= ((ULONG) 0x100))             \ | ||||
|         {                                       \ | ||||
|             (m) = (m) >> ((ULONG) 8);           \ | ||||
|             (b) = (b) + ((ULONG) 8);            \ | ||||
|         }                                       \ | ||||
|         if ((m) >= ((ULONG) 16))                \ | ||||
|         {                                       \ | ||||
|             (m) = (m) >> ((ULONG) 4);           \ | ||||
|             (b) = (b) + ((ULONG) 4);            \ | ||||
|         }                                       \ | ||||
|         if ((m) >= ((ULONG) 4))                 \ | ||||
|         {                                       \ | ||||
|             (m) = (m) >> ((ULONG) 2);           \ | ||||
|             (b) = (b) + ((ULONG) 2);            \ | ||||
|         }                                       \ | ||||
|         (b) = (b) + ((m) >> ((ULONG) 1));       \ | ||||
|     } | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the default thread stack checking. This can be overridden by | ||||
|    a particular port, which is necessary if the stack growth is from | ||||
|    low address to high address (the default logic is for stacks that | ||||
|    grow from high address to low address.  */ | ||||
|  | ||||
| #ifndef TX_THREAD_STACK_CHECK | ||||
| #define TX_THREAD_STACK_CHECK(thread_ptr)                                                                                       \ | ||||
|     {                                                                                                                           \ | ||||
|     TX_INTERRUPT_SAVE_AREA                                                                                                      \ | ||||
|         TX_DISABLE                                                                                                              \ | ||||
|         if (((thread_ptr)) && ((thread_ptr) -> tx_thread_id == TX_THREAD_ID))                                                   \ | ||||
|         {                                                                                                                       \ | ||||
|             if (((ULONG *) (thread_ptr) -> tx_thread_stack_ptr) < ((ULONG *) (thread_ptr) -> tx_thread_stack_highest_ptr))      \ | ||||
|             {                                                                                                                   \ | ||||
|                 (thread_ptr) -> tx_thread_stack_highest_ptr =  (thread_ptr) -> tx_thread_stack_ptr;                             \ | ||||
|             }                                                                                                                   \ | ||||
|             if ((*((ULONG *) (thread_ptr) -> tx_thread_stack_start) != TX_STACK_FILL) ||                                        \ | ||||
|                 (*((ULONG *) (((UCHAR *) (thread_ptr) -> tx_thread_stack_end) + 1)) != TX_STACK_FILL) ||                        \ | ||||
|                 (((ULONG *) (thread_ptr) -> tx_thread_stack_highest_ptr) < ((ULONG *) (thread_ptr) -> tx_thread_stack_start)))  \ | ||||
|             {                                                                                                                   \ | ||||
|                 TX_RESTORE                                                                                                      \ | ||||
|                 _tx_thread_stack_error_handler((thread_ptr));                                                                   \ | ||||
|                 TX_DISABLE                                                                                                      \ | ||||
|             }                                                                                                                   \ | ||||
|             if (*(((ULONG *) (thread_ptr) -> tx_thread_stack_highest_ptr) - 1) != TX_STACK_FILL)                                \ | ||||
|             {                                                                                                                   \ | ||||
|                 TX_RESTORE                                                                                                      \ | ||||
|                 _tx_thread_stack_analyze((thread_ptr));                                                                         \ | ||||
|                 TX_DISABLE                                                                                                      \ | ||||
|             }                                                                                                                   \ | ||||
|         }                                                                                                                       \ | ||||
|         TX_RESTORE                                                                                                              \ | ||||
|     } | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define default post thread delete macro to whitespace, if it hasn't been defined previously (typically in tx_port.h).  */ | ||||
|  | ||||
| #ifndef TX_THREAD_DELETE_PORT_COMPLETION | ||||
| #define TX_THREAD_DELETE_PORT_COMPLETION(t) | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define default post thread reset macro to whitespace, if it hasn't been defined previously (typically in tx_port.h).  */ | ||||
|  | ||||
| #ifndef TX_THREAD_RESET_PORT_COMPLETION | ||||
| #define TX_THREAD_RESET_PORT_COMPLETION(t) | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the thread create internal extension macro to whitespace, if it hasn't been defined previously (typically in tx_port.h).  */ | ||||
|  | ||||
| #ifndef TX_THREAD_CREATE_INTERNAL_EXTENSION | ||||
| #define TX_THREAD_CREATE_INTERNAL_EXTENSION(t) | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define internal thread control function prototypes.  */ | ||||
|  | ||||
| VOID        _tx_thread_initialize(VOID); | ||||
| VOID        _tx_thread_schedule(VOID); | ||||
| VOID        _tx_thread_shell_entry(VOID); | ||||
| VOID        _tx_thread_stack_analyze(TX_THREAD *thread_ptr); | ||||
| VOID        _tx_thread_stack_build(TX_THREAD *thread_ptr, VOID (*function_ptr)(VOID)); | ||||
| VOID        _tx_thread_stack_error(TX_THREAD *thread_ptr); | ||||
| VOID        _tx_thread_stack_error_handler(TX_THREAD *thread_ptr); | ||||
| VOID        _tx_thread_system_preempt_check(VOID); | ||||
| VOID        _tx_thread_system_resume(TX_THREAD *thread_ptr); | ||||
| VOID        _tx_thread_system_ni_resume(TX_THREAD *thread_ptr); | ||||
| VOID        _tx_thread_system_return(VOID); | ||||
| VOID        _tx_thread_system_suspend(TX_THREAD *thread_ptr); | ||||
| VOID        _tx_thread_system_ni_suspend(TX_THREAD *thread_ptr, ULONG wait_option); | ||||
| VOID        _tx_thread_time_slice(VOID); | ||||
| VOID        _tx_thread_timeout(ULONG timeout_input); | ||||
|  | ||||
|  | ||||
| /* Thread control component data declarations follow.  */ | ||||
|  | ||||
| /* Determine if the initialization function of this component is including | ||||
|    this file.  If so, make the data definitions really happen.  Otherwise, | ||||
|    make them extern so other functions in the component can access them.  */ | ||||
|  | ||||
| #define THREAD_DECLARE extern | ||||
|  | ||||
|  | ||||
| /* Define the pointer that contains the system stack pointer.  This is | ||||
|    utilized when control returns from a thread to the system to reset the | ||||
|    current stack.  This is setup in the low-level initialization function. */ | ||||
|  | ||||
| THREAD_DECLARE  VOID *          _tx_thread_system_stack_ptr; | ||||
|  | ||||
|  | ||||
| /* Define the current thread pointer.  This variable points to the currently | ||||
|    executing thread.  If this variable is NULL, no thread is executing.  */ | ||||
|  | ||||
| THREAD_DECLARE  TX_THREAD *     _tx_thread_current_ptr; | ||||
|  | ||||
|  | ||||
| /* Define the variable that holds the next thread to execute.  It is important | ||||
|    to remember that this is not necessarily equal to the current thread | ||||
|    pointer.  */ | ||||
|  | ||||
| THREAD_DECLARE  TX_THREAD *     _tx_thread_execute_ptr; | ||||
|  | ||||
|  | ||||
| /* Define the head pointer of the created thread list.  */ | ||||
|  | ||||
| THREAD_DECLARE  TX_THREAD *     _tx_thread_created_ptr; | ||||
|  | ||||
|  | ||||
| /* Define the variable that holds the number of created threads. */ | ||||
|  | ||||
| THREAD_DECLARE  ULONG           _tx_thread_created_count; | ||||
|  | ||||
|  | ||||
| /* Define the current state variable.  When this value is 0, a thread | ||||
|    is executing or the system is idle.  Other values indicate that | ||||
|    interrupt or initialization processing is active.  This variable is | ||||
|    initialized to TX_INITIALIZE_IN_PROGRESS to indicate initialization is | ||||
|    active.  */ | ||||
|  | ||||
| THREAD_DECLARE  volatile ULONG  _tx_thread_system_state; | ||||
|  | ||||
|  | ||||
| /* Define the 32-bit priority bit-maps. There is one priority bit map for each | ||||
|    32 priority levels supported. If only 32 priorities are supported there is | ||||
|    only one bit map. Each bit within a priority bit map represents that one | ||||
|    or more threads at the associated thread priority are ready.  */ | ||||
|  | ||||
| THREAD_DECLARE  ULONG           _tx_thread_priority_maps[TX_MAX_PRIORITIES/32]; | ||||
|  | ||||
|  | ||||
| /* Define the priority map active bit map that specifies which of the previously | ||||
|    defined priority maps have something set. This is only necessary if more than | ||||
|    32 priorities are supported.  */ | ||||
|  | ||||
| #if TX_MAX_PRIORITIES > 32 | ||||
| THREAD_DECLARE  ULONG           _tx_thread_priority_map_active; | ||||
| #endif | ||||
|  | ||||
|  | ||||
| #ifndef TX_DISABLE_PREEMPTION_THRESHOLD | ||||
|  | ||||
| /* Define the 32-bit preempt priority bit maps.  There is one preempt bit map | ||||
|    for each 32 priority levels supported. If only 32 priorities are supported | ||||
|    there is only one bit map. Each set set bit corresponds to a preempted priority | ||||
|    level that had preemption-threshold active to protect against preemption of a | ||||
|    range of relatively higher priority threads.  */ | ||||
|  | ||||
| THREAD_DECLARE  ULONG           _tx_thread_preempted_maps[TX_MAX_PRIORITIES/32]; | ||||
|  | ||||
|  | ||||
| /* Define the preempt map active bit map that specifies which of the previously | ||||
|    defined preempt maps have something set. This is only necessary if more than | ||||
|    32 priorities are supported.  */ | ||||
|  | ||||
| #if TX_MAX_PRIORITIES > 32 | ||||
| THREAD_DECLARE  ULONG           _tx_thread_preempted_map_active; | ||||
| #endif | ||||
| #endif | ||||
|  | ||||
| /* Define the variable that holds the highest priority group ready for | ||||
|    execution.  It is important to note that this is not necessarily the same | ||||
|    as the priority of the thread pointed to by _tx_execute_thread.  */ | ||||
|  | ||||
| THREAD_DECLARE  UINT            _tx_thread_highest_priority; | ||||
|  | ||||
|  | ||||
| /* Define the array of thread pointers.  Each entry represents the threads that | ||||
|    are ready at that priority group.  For example, index 10 in this array | ||||
|    represents the first thread ready at priority 10.  If this entry is NULL, | ||||
|    no threads are ready at that priority.  */ | ||||
|  | ||||
| THREAD_DECLARE  TX_THREAD *     _tx_thread_priority_list[TX_MAX_PRIORITIES]; | ||||
|  | ||||
|  | ||||
| /* Define the global preempt disable variable.  If this is non-zero, preemption is | ||||
|    disabled.  It is used internally by ThreadX to prevent preemption of a thread in | ||||
|    the middle of a service that is resuming or suspending another thread.  */ | ||||
|  | ||||
| THREAD_DECLARE  volatile UINT   _tx_thread_preempt_disable; | ||||
|  | ||||
|  | ||||
| /* Define the global function pointer for mutex cleanup on thread completion or | ||||
|    termination. This pointer is setup during mutex initialization.  */ | ||||
|  | ||||
| THREAD_DECLARE  VOID            (*_tx_thread_mutex_release)(TX_THREAD *thread_ptr); | ||||
|  | ||||
|  | ||||
| /* Define the global build options variable.  This contains a bit map representing | ||||
|    how the ThreadX library was built. The following are the bit field definitions: | ||||
|  | ||||
|                     Bit(s)                   Meaning | ||||
|  | ||||
|                     31                  TX_NOT_INTERRUPTABLE defined | ||||
|                     30                  TX_INLINE_THREAD_RESUME_SUSPEND define | ||||
|                     29-24               Priority groups 1  -> 32 priorities | ||||
|                                                         2  -> 64 priorities | ||||
|                                                         3  -> 96 priorities | ||||
|  | ||||
|                                                         ... | ||||
|  | ||||
|                                                         32 -> 1024 priorities | ||||
|                     23                  TX_TIMER_PROCESS_IN_ISR defined | ||||
|                     22                  TX_REACTIVATE_INLINE defined | ||||
|                     21                  TX_DISABLE_STACK_FILLING defined | ||||
|                     20                  TX_ENABLE_STACK_CHECKING defined | ||||
|                     19                  TX_DISABLE_PREEMPTION_THRESHOLD defined | ||||
|                     18                  TX_DISABLE_REDUNDANT_CLEARING defined | ||||
|                     17                  TX_DISABLE_NOTIFY_CALLBACKS defined | ||||
|                     16                  TX_BLOCK_POOL_ENABLE_PERFORMANCE_INFO defined | ||||
|                     15                  TX_BYTE_POOL_ENABLE_PERFORMANCE_INFO defined | ||||
|                     14                  TX_EVENT_FLAGS_ENABLE_PERFORMANCE_INFO defined | ||||
|                     13                  TX_MUTEX_ENABLE_PERFORMANCE_INFO defined | ||||
|                     12                  TX_QUEUE_ENABLE_PERFORMANCE_INFO defined | ||||
|                     11                  TX_SEMAPHORE_ENABLE_PERFORMANCE_INFO defined | ||||
|                     10                  TX_THREAD_ENABLE_PERFORMANCE_INFO defined | ||||
|                     9                   TX_TIMER_ENABLE_PERFORMANCE_INFO defined | ||||
|                     8                   TX_ENABLE_EVENT_TRACE defined | ||||
|                     7                   TX_ENABLE_EXECUTION_CHANGE_NOTIFY defined | ||||
|                     6-0                 Port Specific   */ | ||||
|  | ||||
| THREAD_DECLARE  ULONG           _tx_build_options; | ||||
|  | ||||
|  | ||||
| #if defined(TX_ENABLE_STACK_CHECKING) || defined(TX_PORT_THREAD_STACK_ERROR_HANDLING) | ||||
|  | ||||
| /* Define the global function pointer for stack error handling. If a stack error is | ||||
|    detected and the application has registered a stack error handler, it will be | ||||
|    called via this function pointer.  */ | ||||
|  | ||||
| THREAD_DECLARE  VOID            (*_tx_thread_application_stack_error_handler)(TX_THREAD *thread_ptr); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| #ifdef TX_THREAD_ENABLE_PERFORMANCE_INFO | ||||
|  | ||||
| /* Define the total number of thread resumptions. Each time a thread enters the | ||||
|    ready state this variable is incremented.  */ | ||||
|  | ||||
| THREAD_DECLARE  ULONG           _tx_thread_performance_resume_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of thread suspensions. Each time a thread enters a | ||||
|    suspended state this variable is incremented.  */ | ||||
|  | ||||
| THREAD_DECLARE  ULONG           _tx_thread_performance_suspend_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of solicited thread preemptions. Each time a thread is | ||||
|    preempted by directly calling a ThreadX service, this variable is incremented.  */ | ||||
|  | ||||
| THREAD_DECLARE  ULONG           _tx_thread_performance_solicited_preemption_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of interrupt thread preemptions. Each time a thread is | ||||
|    preempted as a result of an ISR calling a ThreadX service, this variable is | ||||
|    incremented.  */ | ||||
|  | ||||
| THREAD_DECLARE  ULONG           _tx_thread_performance_interrupt_preemption_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of priority inversions. Each time a thread is blocked by | ||||
|    a mutex owned by a lower-priority thread, this variable is incremented.  */ | ||||
|  | ||||
| THREAD_DECLARE  ULONG           _tx_thread_performance_priority_inversion_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of time-slices.  Each time a time-slice operation is | ||||
|    actually performed (another thread is setup for running) this variable is | ||||
|    incremented.  */ | ||||
|  | ||||
| THREAD_DECLARE  ULONG           _tx_thread_performance_time_slice_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of thread relinquish operations.  Each time a thread | ||||
|    relinquish operation is actually performed (another thread is setup for running) | ||||
|    this variable is incremented.  */ | ||||
|  | ||||
| THREAD_DECLARE  ULONG           _tx_thread_performance_relinquish_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of thread timeouts. Each time a thread has a | ||||
|    timeout this variable is incremented.  */ | ||||
|  | ||||
| THREAD_DECLARE  ULONG           _tx_thread_performance_timeout_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of thread wait aborts. Each time a thread's suspension | ||||
|    is lifted by the tx_thread_wait_abort call this variable is incremented.  */ | ||||
|  | ||||
| THREAD_DECLARE  ULONG           _tx_thread_performance_wait_abort_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of idle system thread returns. Each time a thread returns to | ||||
|    an idle system (no other thread is ready to run) this variable is incremented.  */ | ||||
|  | ||||
| THREAD_DECLARE  ULONG           _tx_thread_performance_idle_return_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of non-idle system thread returns. Each time a thread returns to | ||||
|    a non-idle system (another thread is ready to run) this variable is incremented.  */ | ||||
|  | ||||
| THREAD_DECLARE  ULONG           _tx_thread_performance_non_idle_return_count; | ||||
|  | ||||
|  | ||||
| /* Define the last TX_THREAD_EXECUTE_LOG_SIZE threads scheduled in ThreadX. This | ||||
|    is a circular list, where the index points to the oldest entry.  */ | ||||
|  | ||||
| THREAD_DECLARE  ULONG           _tx_thread_performance__execute_log_index; | ||||
| THREAD_DECLARE  TX_THREAD *     _tx_thread_performance_execute_log[TX_THREAD_EXECUTE_LOG_SIZE]; | ||||
|  | ||||
| #endif | ||||
|  | ||||
| #endif | ||||
|  | ||||
							
								
								
									
										215
									
								
								Middlewares/ST/threadx/common/inc/tx_timer.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										215
									
								
								Middlewares/ST/threadx/common/inc/tx_timer.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,215 @@ | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*       Copyright (c) Microsoft Corporation. All rights reserved.        */ | ||||
| /*                                                                        */ | ||||
| /*       This software is licensed under the Microsoft Software License   */ | ||||
| /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */ | ||||
| /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */ | ||||
| /*       and in the root directory of this software.                      */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
| /**                                                                       */ | ||||
| /** ThreadX Component                                                     */ | ||||
| /**                                                                       */ | ||||
| /**   Timer                                                               */ | ||||
| /**                                                                       */ | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*  COMPONENT DEFINITION                                   RELEASE        */ | ||||
| /*                                                                        */ | ||||
| /*    tx_timer.h                                          PORTABLE C      */ | ||||
| /*                                                           6.1          */ | ||||
| /*  AUTHOR                                                                */ | ||||
| /*                                                                        */ | ||||
| /*    William E. Lamie, Microsoft Corporation                             */ | ||||
| /*                                                                        */ | ||||
| /*  DESCRIPTION                                                           */ | ||||
| /*                                                                        */ | ||||
| /*    This file defines the ThreadX timer management component, including */ | ||||
| /*    data types and external references.  It is assumed that tx_api.h    */ | ||||
| /*    and tx_port.h have already been included.                           */ | ||||
| /*                                                                        */ | ||||
| /*  RELEASE HISTORY                                                       */ | ||||
| /*                                                                        */ | ||||
| /*    DATE              NAME                      DESCRIPTION             */ | ||||
| /*                                                                        */ | ||||
| /*  05-19-2020     William E. Lamie         Initial Version 6.0           */ | ||||
| /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */ | ||||
| /*                                            resulting in version 6.1    */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
| #ifndef TX_TIMER_H | ||||
| #define TX_TIMER_H | ||||
|  | ||||
|  | ||||
| /* Define timer management specific data definitions.  */ | ||||
|  | ||||
| #define TX_TIMER_ID                             ((ULONG) 0x4154494D) | ||||
| #define TX_TIMER_ENTRIES                        ((ULONG) 32) | ||||
|  | ||||
|  | ||||
| /* Define internal timer management function prototypes.  */ | ||||
|  | ||||
| VOID        _tx_timer_expiration_process(VOID); | ||||
| VOID        _tx_timer_initialize(VOID); | ||||
| VOID        _tx_timer_system_activate(TX_TIMER_INTERNAL *timer_ptr); | ||||
| VOID        _tx_timer_system_deactivate(TX_TIMER_INTERNAL *timer_ptr); | ||||
| VOID        _tx_timer_thread_entry(ULONG timer_thread_input); | ||||
|  | ||||
|  | ||||
| /* Timer management component data declarations follow.  */ | ||||
|  | ||||
| /* Determine if the initialization function of this component is including | ||||
|    this file.  If so, make the data definitions really happen.  Otherwise, | ||||
|    make them extern so other functions in the component can access them.  */ | ||||
|  | ||||
| #ifdef TX_TIMER_INIT | ||||
| #define TIMER_DECLARE | ||||
| #else | ||||
| #define TIMER_DECLARE extern | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the system clock value that is continually incremented by the | ||||
|    periodic timer interrupt processing.  */ | ||||
|  | ||||
| TIMER_DECLARE volatile ULONG    _tx_timer_system_clock; | ||||
|  | ||||
|  | ||||
| /* Define the current time slice value.  If non-zero, a time-slice is active. | ||||
|    Otherwise, the time_slice is not active.  */ | ||||
|  | ||||
| TIMER_DECLARE ULONG             _tx_timer_time_slice; | ||||
|  | ||||
|  | ||||
| /* Define the time-slice expiration flag.  This is used to indicate that a time-slice | ||||
|    has happened.  */ | ||||
|  | ||||
| TIMER_DECLARE UINT              _tx_timer_expired_time_slice; | ||||
|  | ||||
|  | ||||
| /* Define the thread and application timer entry list.  This list provides a direct access | ||||
|    method for insertion of times less than TX_TIMER_ENTRIES.  */ | ||||
|  | ||||
| TIMER_DECLARE TX_TIMER_INTERNAL *_tx_timer_list[TX_TIMER_ENTRIES]; | ||||
|  | ||||
|  | ||||
| /* Define the boundary pointers to the list.  These are setup to easily manage | ||||
|    wrapping the list.  */ | ||||
|  | ||||
| TIMER_DECLARE TX_TIMER_INTERNAL **_tx_timer_list_start; | ||||
| TIMER_DECLARE TX_TIMER_INTERNAL **_tx_timer_list_end; | ||||
|  | ||||
|  | ||||
| /* Define the current timer pointer in the list.  This pointer is moved sequentially | ||||
|    through the timer list by the timer interrupt handler.  */ | ||||
|  | ||||
| TIMER_DECLARE TX_TIMER_INTERNAL **_tx_timer_current_ptr; | ||||
|  | ||||
|  | ||||
| /* Define the timer expiration flag.  This is used to indicate that a timer | ||||
|    has expired.  */ | ||||
|  | ||||
| TIMER_DECLARE UINT              _tx_timer_expired; | ||||
|  | ||||
|  | ||||
| /* Define the created timer list head pointer.  */ | ||||
|  | ||||
| TIMER_DECLARE TX_TIMER          *_tx_timer_created_ptr; | ||||
|  | ||||
|  | ||||
| /* Define the created timer count.  */ | ||||
|  | ||||
| TIMER_DECLARE ULONG             _tx_timer_created_count; | ||||
|  | ||||
|  | ||||
| /* Define the pointer to the timer that has expired and is being processed.  */ | ||||
|  | ||||
| TIMER_DECLARE TX_TIMER_INTERNAL *_tx_timer_expired_timer_ptr; | ||||
|  | ||||
|  | ||||
| #ifndef TX_TIMER_PROCESS_IN_ISR | ||||
|  | ||||
| /* Define the timer thread's control block.  */ | ||||
|  | ||||
| TIMER_DECLARE TX_THREAD         _tx_timer_thread; | ||||
|  | ||||
|  | ||||
| /* Define the variable that holds the timer thread's starting stack address.  */ | ||||
|  | ||||
| TIMER_DECLARE VOID              *_tx_timer_stack_start; | ||||
|  | ||||
|  | ||||
| /* Define the variable that holds the timer thread's stack size.  */ | ||||
|  | ||||
| TIMER_DECLARE ULONG             _tx_timer_stack_size; | ||||
|  | ||||
|  | ||||
| /* Define the variable that holds the timer thread's priority.  */ | ||||
|  | ||||
| TIMER_DECLARE UINT              _tx_timer_priority; | ||||
|  | ||||
| /* Define the system timer thread's stack.   The default size is defined | ||||
|    in tx_port.h.  */ | ||||
|  | ||||
| TIMER_DECLARE ULONG             _tx_timer_thread_stack_area[(((UINT) TX_TIMER_THREAD_STACK_SIZE)+((sizeof(ULONG)) - ((UINT) 1)))/sizeof(ULONG)]; | ||||
|  | ||||
| #else | ||||
|  | ||||
|  | ||||
| /* Define the busy flag that will prevent nested timer ISR processing.  */ | ||||
|  | ||||
| TIMER_DECLARE UINT              _tx_timer_processing_active; | ||||
|  | ||||
| #endif | ||||
|  | ||||
| #ifdef TX_TIMER_ENABLE_PERFORMANCE_INFO | ||||
|  | ||||
| /* Define the total number of timer activations.  */ | ||||
|  | ||||
| TIMER_DECLARE  ULONG            _tx_timer_performance_activate_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of timer reactivations.  */ | ||||
|  | ||||
| TIMER_DECLARE  ULONG            _tx_timer_performance_reactivate_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of timer deactivations.  */ | ||||
|  | ||||
| TIMER_DECLARE  ULONG            _tx_timer_performance_deactivate_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of timer expirations.  */ | ||||
|  | ||||
| TIMER_DECLARE  ULONG            _tx_timer_performance_expiration_count; | ||||
|  | ||||
|  | ||||
| /* Define the total number of timer expiration adjustments. These are required | ||||
|    if the expiration time is greater than the size of the timer list. In such | ||||
|    cases, the timer is placed at the end of the list and then reactivated | ||||
|    as many times as necessary to finally achieve the resulting timeout. */ | ||||
|  | ||||
| TIMER_DECLARE  ULONG            _tx_timer_performance__expiration_adjust_count; | ||||
|  | ||||
|  | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define default post timer delete macro to whitespace, if it hasn't been defined previously (typically in tx_port.h).  */ | ||||
|  | ||||
| #ifndef TX_TIMER_DELETE_PORT_COMPLETION | ||||
| #define TX_TIMER_DELETE_PORT_COMPLETION(t) | ||||
| #endif | ||||
|  | ||||
|  | ||||
| #endif | ||||
							
								
								
									
										561
									
								
								Middlewares/ST/threadx/common/inc/tx_trace.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										561
									
								
								Middlewares/ST/threadx/common/inc/tx_trace.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,561 @@ | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*       Copyright (c) Microsoft Corporation. All rights reserved.        */ | ||||
| /*                                                                        */ | ||||
| /*       This software is licensed under the Microsoft Software License   */ | ||||
| /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */ | ||||
| /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */ | ||||
| /*       and in the root directory of this software.                      */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
| /**                                                                       */ | ||||
| /** ThreadX Component                                                     */ | ||||
| /**                                                                       */ | ||||
| /**   Trace                                                               */ | ||||
| /**                                                                       */ | ||||
| /**************************************************************************/ | ||||
| /**************************************************************************/ | ||||
|  | ||||
| /**************************************************************************/ | ||||
| /*                                                                        */ | ||||
| /*  COMPONENT DEFINITION                                   RELEASE        */ | ||||
| /*                                                                        */ | ||||
| /*    tx_trace.h                                          PORTABLE C      */ | ||||
| /*                                                           6.1          */ | ||||
| /*  AUTHOR                                                                */ | ||||
| /*                                                                        */ | ||||
| /*    William E. Lamie, Microsoft Corporation                             */ | ||||
| /*                                                                        */ | ||||
| /*  DESCRIPTION                                                           */ | ||||
| /*                                                                        */ | ||||
| /*    This file defines the ThreadX trace component, including constants  */ | ||||
| /*    and structure definitions as well as external references.  It is    */ | ||||
| /*    assumed that tx_api.h and tx_port.h have already been included.     */ | ||||
| /*                                                                        */ | ||||
| /*  RELEASE HISTORY                                                       */ | ||||
| /*                                                                        */ | ||||
| /*    DATE              NAME                      DESCRIPTION             */ | ||||
| /*                                                                        */ | ||||
| /*  05-19-2020     William E. Lamie         Initial Version 6.0           */ | ||||
| /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */ | ||||
| /*                                            resulting in version 6.1    */ | ||||
| /*                                                                        */ | ||||
| /**************************************************************************/ | ||||
|  | ||||
|  | ||||
| /* Include necessary system files.  */ | ||||
|  | ||||
| #ifndef TX_TRACE_H | ||||
| #define TX_TRACE_H | ||||
|  | ||||
|  | ||||
| /* Determine if tracing is enabled. If not, simply define the in-line trace | ||||
|    macros to whitespace.  */ | ||||
|  | ||||
| #ifndef TX_ENABLE_EVENT_TRACE | ||||
| #define TX_TRACE_INITIALIZE | ||||
| #define TX_TRACE_OBJECT_REGISTER(t,p,n,a,b) | ||||
| #define TX_TRACE_OBJECT_UNREGISTER(o) | ||||
| #define TX_TRACE_IN_LINE_INSERT(i,a,b,c,d,f) | ||||
| #else | ||||
|  | ||||
| /* Event tracing is enabled.  */ | ||||
|  | ||||
| /* Ensure that the thread component information is included.  */ | ||||
|  | ||||
| #include "tx_thread.h" | ||||
|  | ||||
|  | ||||
| /* Define trace port-specfic extension to white space if it isn't defined | ||||
|    already.  */ | ||||
|  | ||||
| #ifndef TX_TRACE_PORT_EXTENSION | ||||
| #define TX_TRACE_PORT_EXTENSION | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the default clock source for trace event entry time stamp. The following two item are port specific. | ||||
|    For example, if the time source is at the address 0x0a800024 and is 16-bits in size, the clock | ||||
|    source constants would be: | ||||
|  | ||||
| #define TX_TRACE_TIME_SOURCE                    *((ULONG *) 0x0a800024) | ||||
| #define TX_TRACE_TIME_MASK                      0x0000FFFFUL | ||||
|  | ||||
| */ | ||||
|  | ||||
| #ifndef TX_TRACE_TIME_SOURCE | ||||
| #define TX_TRACE_TIME_SOURCE                    ++_tx_trace_simulated_time | ||||
| #endif | ||||
| #ifndef TX_TRACE_TIME_MASK | ||||
| #define TX_TRACE_TIME_MASK                      0xFFFFFFFFUL | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the ID showing the event trace buffer is valid.  */ | ||||
|  | ||||
| #define TX_TRACE_VALID                                      0x54585442UL | ||||
|  | ||||
|  | ||||
| /* ThreadX Trace Description.  The ThreadX Trace feature is designed to capture | ||||
|    events in real-time in a circular event buffer. This buffer may be analyzed by other | ||||
|    tools.  The high-level format of the Trace structure is: | ||||
|  | ||||
|             [Trace Control Header              ] | ||||
|             [Trace Object Registry - Entry 0   ] | ||||
|                     ... | ||||
|             [Trace Object Registry - Entry "n" ] | ||||
|             [Trace Buffer - Entry 0            ] | ||||
|                     ... | ||||
|             [Trace Buffer - Entry "n"          ] | ||||
|  | ||||
| */ | ||||
|  | ||||
|  | ||||
| /* Trace Control Header. The Trace Control Header contains information that | ||||
|    defines the format of the Trace Object Registry as well as the location and | ||||
|    current entry of the Trace Buffer itself.  The high-level format of the | ||||
|    Trace Control Header is: | ||||
|  | ||||
|                 Entry                               Size                     Description | ||||
|  | ||||
|             [Trace ID]                              4       This 4-byte field contains the ThreadX Trace | ||||
|                                                             Identification. If the trace buffer is valid, the | ||||
|                                                             contents are 0x54585442 (TXTB). Since it is written as | ||||
|                                                             a 32-bit unsigned word, this value is also used to | ||||
|                                                             determine if the event trace information is in | ||||
|                                                             little or big endian format. | ||||
|             [Timer Valid Mask]                      4       Mask of valid bits in the 32-bit time stamp. This | ||||
|                                                             enables use of 32, 24, 16, or event 8-bit timers. | ||||
|                                                             If the time source is 32-bits, the mask is | ||||
|                                                             0xFFFFFFFF. If the time source is 16-bits, the | ||||
|                                                             mask is 0x0000FFFF. | ||||
|             [Trace Base Address]                    4       The base address for all trace pointer. Subtracting | ||||
|                                                             the pointer and this address will yield the proper | ||||
|                                                             offset into the trace buffer. | ||||
|             [Trace Object Registry Start Pointer]   4       Pointer to the start of Trace Object Registry | ||||
|             [Reserved]                              2       Reserved two bytes - should be 0x0000 | ||||
|             [Trace Object Object Name Size]         2       Number of bytes in object name | ||||
|             [Trace Object Registry End Pointer]     4       Pointer to the end of Trace Object Registry | ||||
|             [Trace Buffer Start Pointer]            4       Pointer to the start of the Trace Buffer Area | ||||
|             [Trace Buffer End Pointer]              4       Pointer to the end of the Trace Buffer Area | ||||
|             [Trace Buffer Current Pointer]          4       Pointer to the oldest entry in the Trace Buffer. | ||||
|                                                             This entry will be overwritten on the next event and | ||||
|                                                             incremented to the next event (wrapping to the top | ||||
|                                                             if the buffer end pointer is exceeded). | ||||
|             [Reserved]                              4       Reserved 4 bytes, should be 0xAAAAAAAA | ||||
|             [Reserved]                              4       Reserved 4 bytes, should be 0xBBBBBBBB | ||||
|             [Reserved]                              4       Reserved 4 bytes, should be 0xCCCCCCCC | ||||
| */ | ||||
|  | ||||
|  | ||||
| /* Define the Trace Control Header.  */ | ||||
|  | ||||
| typedef struct TX_TRACE_HEADER_STRUCT | ||||
| { | ||||
|  | ||||
|     ULONG                                                   tx_trace_header_id; | ||||
|     ULONG                                                   tx_trace_header_timer_valid_mask; | ||||
|     ULONG                                                   tx_trace_header_trace_base_address; | ||||
|     ULONG                                                   tx_trace_header_registry_start_pointer; | ||||
|     USHORT                                                  tx_trace_header_reserved1; | ||||
|     USHORT                                                  tx_trace_header_object_name_size; | ||||
|     ULONG                                                   tx_trace_header_registry_end_pointer; | ||||
|     ULONG                                                   tx_trace_header_buffer_start_pointer; | ||||
|     ULONG                                                   tx_trace_header_buffer_end_pointer; | ||||
|     ULONG                                                   tx_trace_header_buffer_current_pointer; | ||||
|     ULONG                                                   tx_trace_header_reserved2; | ||||
|     ULONG                                                   tx_trace_header_reserved3; | ||||
|     ULONG                                                   tx_trace_header_reserved4; | ||||
| } TX_TRACE_HEADER; | ||||
|  | ||||
|  | ||||
| /* Trace Object Registry. The Trace Object Registry is used to map the object pointer in the trace buffer to | ||||
|    the application's name for the object (defined during object creation in ThreadX).  */ | ||||
|  | ||||
| #ifndef TX_TRACE_OBJECT_REGISTRY_NAME | ||||
| #define TX_TRACE_OBJECT_REGISTRY_NAME                       32 | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the object name types as well as the contents of any additional parameters that might be useful in | ||||
|    trace analysis.  */ | ||||
|  | ||||
| #define TX_TRACE_OBJECT_TYPE_NOT_VALID                      ((UCHAR) 0)     /* Object is not valid                               */ | ||||
| #define TX_TRACE_OBJECT_TYPE_THREAD                         ((UCHAR) 1)     /* P1 = stack start address, P2 = stack size         */ | ||||
| #define TX_TRACE_OBJECT_TYPE_TIMER                          ((UCHAR) 2)     /* P1 = initial ticks, P2 = reschedule ticks         */ | ||||
| #define TX_TRACE_OBJECT_TYPE_QUEUE                          ((UCHAR) 3)     /* P1 = queue size, P2 = message size                */ | ||||
| #define TX_TRACE_OBJECT_TYPE_SEMAPHORE                      ((UCHAR) 4)     /* P1 = initial instances                            */ | ||||
| #define TX_TRACE_OBJECT_TYPE_MUTEX                          ((UCHAR) 5)     /* P1 = priority inheritance flag                    */ | ||||
| #define TX_TRACE_OBJECT_TYPE_EVENT_FLAGS                    ((UCHAR) 6)     /* none                                              */ | ||||
| #define TX_TRACE_OBJECT_TYPE_BLOCK_POOL                     ((UCHAR) 7)     /* P1 = total blocks, P2 = block size                */ | ||||
| #define TX_TRACE_OBJECT_TYPE_BYTE_POOL                      ((UCHAR) 8)     /* P1 = total bytes                                  */ | ||||
|  | ||||
|  | ||||
| typedef struct TX_TRACE_OBJECT_ENTRY_STRUCT | ||||
| { | ||||
|  | ||||
|     UCHAR                                                   tx_trace_object_entry_available;                            /* TX_TRUE -> available                 */ | ||||
|     UCHAR                                                   tx_trace_object_entry_type;                                 /* Types defined above                  */ | ||||
|     UCHAR                                                   tx_trace_object_entry_reserved1;                            /* Should be zero - except for thread   */ | ||||
|     UCHAR                                                   tx_trace_object_entry_reserved2;                            /* Should be zero - except for thread   */ | ||||
|     ULONG                                                   tx_trace_object_entry_thread_pointer;                       /* ThreadX object pointer               */ | ||||
|     ULONG                                                   tx_trace_object_entry_param_1;                              /* Parameter value defined              */ | ||||
|     ULONG                                                   tx_trace_object_entry_param_2;                              /*   according to type above            */ | ||||
|     UCHAR                                                   tx_trace_object_entry_name[TX_TRACE_OBJECT_REGISTRY_NAME];  /* Object name                          */ | ||||
| } TX_TRACE_OBJECT_ENTRY; | ||||
|  | ||||
|  | ||||
| /* Trace Buffer Entry. The Trace Buffer Entry contains information about a particular | ||||
|    event in the system. The high-level format of the Trace Buffer Entry is: | ||||
|  | ||||
|                 Entry                  Size                     Description | ||||
|  | ||||
|             [Thread Pointer]            4           This 4-byte field contains the pointer to the | ||||
|                                                     ThreadX thread running that caused the event. | ||||
|                                                     If this field is NULL, the entry hasn't been used | ||||
|                                                     yet. If this field is 0xFFFFFFFF, the event occurred | ||||
|                                                     from within an ISR. If this entry is 0xF0F0F0F0, the | ||||
|                                                     event occurred during initialization. | ||||
|             [Thread Priority or         4           This 4-byte field contains the current thread pointer for interrupt | ||||
|              Current Thread                         events or the thread preemption-threshold/priority for thread events. | ||||
|              Preemption-Threshold/ | ||||
|              Priority] | ||||
|             [Event ID]                  4           This 4-byte field contains the Event ID of the event. A value of | ||||
|                                                     0xFFFFFFFF indicates the event is invalid. All events are marked | ||||
|                                                     as invalid during initialization. | ||||
|             [Time Stamp]                4           This 4-byte field contains the time stamp of the event. | ||||
|             [Information Field 1]       4           This 4-byte field contains the first 4-bytes of information | ||||
|                                                     specific to the event. | ||||
|             [Information Field 2]       4           This 4-byte field contains the second 4-bytes of information | ||||
|                                                     specific to the event. | ||||
|             [Information Field 3]       4           This 4-byte field contains the third 4-bytes of information | ||||
|                                                     specific to the event. | ||||
|             [Information Field 4]       4           This 4-byte field contains the fourth 4-bytes of information | ||||
|                                                     specific to the event. | ||||
| */ | ||||
|  | ||||
| #define TX_TRACE_INVALID_EVENT                              0xFFFFFFFFUL | ||||
|  | ||||
|  | ||||
| /* Define ThreadX Trace Events, along with a brief description of the additional information fields, | ||||
|    where I1 -> Information Field 1, I2 -> Information Field 2, etc.  */ | ||||
|  | ||||
| /* Event numbers 0 through 4095 are reserved by Azure RTOS. Specific event assignments are: | ||||
|  | ||||
|                                 ThreadX events:     1-199 | ||||
|                                 FileX events:       200-299 | ||||
|                                 NetX events:        300-599 | ||||
|                                 USBX events:        600-999 | ||||
|  | ||||
|    User-defined event numbers start at 4096 and continue through 65535, as defined by the constants | ||||
|    TX_TRACE_USER_EVENT_START and TX_TRACE_USER_EVENT_END, respectively. User events should be based | ||||
|    on these constants in case the user event number assignment is changed in future releases.  */ | ||||
|  | ||||
| /* Define the basic ThreadX thread scheduling events first.  */ | ||||
|  | ||||
| #define TX_TRACE_THREAD_RESUME                              1           /* I1 = thread ptr, I2 = previous_state, I3 = stack ptr, I4 = next thread   */ | ||||
| #define TX_TRACE_THREAD_SUSPEND                             2           /* I1 = thread ptr, I2 = new_state, I3 = stack ptr  I4 = next thread        */ | ||||
| #define TX_TRACE_ISR_ENTER                                  3           /* I1 = stack_ptr, I2 = ISR number, I3 = system state, I4 = preempt disable */ | ||||
| #define TX_TRACE_ISR_EXIT                                   4           /* I1 = stack_ptr, I2 = ISR number, I3 = system state, I4 = preempt disable */ | ||||
| #define TX_TRACE_TIME_SLICE                                 5           /* I1 = next thread ptr, I2 = system state, I3 = preempt disable, I4 = stack*/ | ||||
| #define TX_TRACE_RUNNING                                    6           /* None                                                                     */ | ||||
|  | ||||
|  | ||||
| /* Define the rest of the ThreadX system events.  */ | ||||
|  | ||||
| #define TX_TRACE_BLOCK_ALLOCATE                             10          /* I1 = pool ptr, I2 = memory ptr, I3 = wait option, I4 = remaining blocks  */ | ||||
| #define TX_TRACE_BLOCK_POOL_CREATE                          11          /* I1 = pool ptr, I2 = pool_start, I3 = total blocks, I4 = block size       */ | ||||
| #define TX_TRACE_BLOCK_POOL_DELETE                          12          /* I1 = pool ptr, I2 = stack ptr                                            */ | ||||
| #define TX_TRACE_BLOCK_POOL_INFO_GET                        13          /* I1 = pool ptr                                                            */ | ||||
| #define TX_TRACE_BLOCK_POOL_PERFORMANCE_INFO_GET            14          /* I1 = pool ptr                                                            */ | ||||
| #define TX_TRACE_BLOCK_POOL__PERFORMANCE_SYSTEM_INFO_GET    15          /* None                                                                     */ | ||||
| #define TX_TRACE_BLOCK_POOL_PRIORITIZE                      16          /* I1 = pool ptr, I2 = suspended count, I3 = stack ptr                      */ | ||||
| #define TX_TRACE_BLOCK_RELEASE                              17          /* I1 = pool ptr, I2 = memory ptr, I3 = suspended, I4 = stack ptr           */ | ||||
| #define TX_TRACE_BYTE_ALLOCATE                              20          /* I1 = pool ptr, I2 = memory ptr, I3 = size requested, I4 = wait option    */ | ||||
| #define TX_TRACE_BYTE_POOL_CREATE                           21          /* I1 = pool ptr, I2 = start ptr, I3 = pool size, I4 = stack ptr            */ | ||||
| #define TX_TRACE_BYTE_POOL_DELETE                           22          /* I1 = pool ptr, I2 = stack ptr                                            */ | ||||
| #define TX_TRACE_BYTE_POOL_INFO_GET                         23          /* I1 = pool ptr                                                            */ | ||||
| #define TX_TRACE_BYTE_POOL_PERFORMANCE_INFO_GET             24          /* I1 = pool ptr                                                            */ | ||||
| #define TX_TRACE_BYTE_POOL__PERFORMANCE_SYSTEM_INFO_GET     25          /* None                                                                     */ | ||||
| #define TX_TRACE_BYTE_POOL_PRIORITIZE                       26          /* I1 = pool ptr, I2 = suspended count, I3 = stack ptr                      */ | ||||
| #define TX_TRACE_BYTE_RELEASE                               27          /* I1 = pool ptr, I2 = memory ptr, I3 = suspended, I4 = available bytes     */ | ||||
| #define TX_TRACE_EVENT_FLAGS_CREATE                         30          /* I1 = group ptr, I2 = stack ptr                                           */ | ||||
| #define TX_TRACE_EVENT_FLAGS_DELETE                         31          /* I1 = group ptr, I2 = stack ptr                                           */ | ||||
| #define TX_TRACE_EVENT_FLAGS_GET                            32          /* I1 = group ptr, I2 = requested flags, I3 = current flags, I4 = get option*/ | ||||
| #define TX_TRACE_EVENT_FLAGS_INFO_GET                       33          /* I1 = group ptr                                                           */ | ||||
| #define TX_TRACE_EVENT_FLAGS_PERFORMANCE_INFO_GET           34          /* I1 = group ptr                                                           */ | ||||
| #define TX_TRACE_EVENT_FLAGS__PERFORMANCE_SYSTEM_INFO_GET   35          /* None                                                                     */ | ||||
| #define TX_TRACE_EVENT_FLAGS_SET                            36          /* I1 = group ptr, I2 = flags to set, I3 = set option, I4= suspended count  */ | ||||
| #define TX_TRACE_EVENT_FLAGS_SET_NOTIFY                     37          /* I1 = group ptr                                                           */ | ||||
| #define TX_TRACE_INTERRUPT_CONTROL                          40          /* I1 = new interrupt posture, I2 = stack ptr                               */ | ||||
| #define TX_TRACE_MUTEX_CREATE                               50          /* I1 = mutex ptr, I2 = inheritance, I3 = stack ptr                         */ | ||||
| #define TX_TRACE_MUTEX_DELETE                               51          /* I1 = mutex ptr, I2 = stack ptr                                           */ | ||||
| #define TX_TRACE_MUTEX_GET                                  52          /* I1 = mutex ptr, I2 = wait option, I3 = owning thread, I4 = own count     */ | ||||
| #define TX_TRACE_MUTEX_INFO_GET                             53          /* I1 = mutex ptr                                                           */ | ||||
| #define TX_TRACE_MUTEX_PERFORMANCE_INFO_GET                 54          /* I1 = mutex ptr                                                           */ | ||||
| #define TX_TRACE_MUTEX_PERFORMANCE_SYSTEM_INFO_GET          55          /* None                                                                     */ | ||||
| #define TX_TRACE_MUTEX_PRIORITIZE                           56          /* I1 = mutex ptr, I2 = suspended count, I3 = stack ptr                     */ | ||||
| #define TX_TRACE_MUTEX_PUT                                  57          /* I1 = mutex ptr, I2 = owning thread, I3 = own count, I4 = stack ptr       */ | ||||
| #define TX_TRACE_QUEUE_CREATE                               60          /* I1 = queue ptr, I2 = message size, I3 = queue start, I4 = queue size     */ | ||||
| #define TX_TRACE_QUEUE_DELETE                               61          /* I1 = queue ptr, I2 = stack ptr                                           */ | ||||
| #define TX_TRACE_QUEUE_FLUSH                                62          /* I1 = queue ptr, I2 = stack ptr                                           */ | ||||
| #define TX_TRACE_QUEUE_FRONT_SEND                           63          /* I1 = queue ptr, I2 = source ptr, I3 = wait option, I4 = enqueued         */ | ||||
| #define TX_TRACE_QUEUE_INFO_GET                             64          /* I1 = queue ptr                                                           */ | ||||
| #define TX_TRACE_QUEUE_PERFORMANCE_INFO_GET                 65          /* I1 = queue ptr                                                           */ | ||||
| #define TX_TRACE_QUEUE_PERFORMANCE_SYSTEM_INFO_GET          66          /* None                                                                     */ | ||||
| #define TX_TRACE_QUEUE_PRIORITIZE                           67          /* I1 = queue ptr, I2 = suspended count, I3 = stack ptr                     */ | ||||
| #define TX_TRACE_QUEUE_RECEIVE                              68          /* I1 = queue ptr, I2 = destination ptr, I3 = wait option, I4 = enqueued    */ | ||||
| #define TX_TRACE_QUEUE_SEND                                 69          /* I1 = queue ptr, I2 = source ptr, I3 = wait option, I4 = enqueued         */ | ||||
| #define TX_TRACE_QUEUE_SEND_NOTIFY                          70          /* I1 = queue ptr                                                           */ | ||||
| #define TX_TRACE_SEMAPHORE_CEILING_PUT                      80          /* I1 = semaphore ptr, I2 = current count, I3 = suspended count,I4 =ceiling */ | ||||
| #define TX_TRACE_SEMAPHORE_CREATE                           81          /* I1 = semaphore ptr, I2 = initial count, I3 = stack ptr                   */ | ||||
| #define TX_TRACE_SEMAPHORE_DELETE                           82          /* I1 = semaphore ptr, I2 = stack ptr                                       */ | ||||
| #define TX_TRACE_SEMAPHORE_GET                              83          /* I1 = semaphore ptr, I2 = wait option, I3 = current count, I4 = stack ptr */ | ||||
| #define TX_TRACE_SEMAPHORE_INFO_GET                         84          /* I1 = semaphore ptr                                                       */ | ||||
| #define TX_TRACE_SEMAPHORE_PERFORMANCE_INFO_GET             85          /* I1 = semaphore ptr                                                       */ | ||||
| #define TX_TRACE_SEMAPHORE__PERFORMANCE_SYSTEM_INFO_GET     86          /* None                                                                     */ | ||||
| #define TX_TRACE_SEMAPHORE_PRIORITIZE                       87          /* I1 = semaphore ptr, I2 = suspended count, I2 = stack ptr                 */ | ||||
| #define TX_TRACE_SEMAPHORE_PUT                              88          /* I1 = semaphore ptr, I2 = current count, I3 = suspended count,I4=stack ptr*/ | ||||
| #define TX_TRACE_SEMAPHORE_PUT_NOTIFY                       89          /* I1 = semaphore ptr                                                       */ | ||||
| #define TX_TRACE_THREAD_CREATE                              100         /* I1 = thread ptr, I2 = priority, I3 = stack ptr, I4 = stack_size          */ | ||||
| #define TX_TRACE_THREAD_DELETE                              101         /* I1 = thread ptr, I2 = stack ptr                                          */ | ||||
| #define TX_TRACE_THREAD_ENTRY_EXIT_NOTIFY                   102         /* I1 = thread ptr, I2 = thread state, I3 = stack ptr                       */ | ||||
| #define TX_TRACE_THREAD_IDENTIFY                            103         /* None                                                                     */ | ||||
| #define TX_TRACE_THREAD_INFO_GET                            104         /* I1 = thread ptr, I2 = thread state                                       */ | ||||
| #define TX_TRACE_THREAD_PERFORMANCE_INFO_GET                105         /* I1 = thread ptr, I2 = thread state                                       */ | ||||
| #define TX_TRACE_THREAD_PERFORMANCE_SYSTEM_INFO_GET         106         /* None                                                                     */ | ||||
| #define TX_TRACE_THREAD_PREEMPTION_CHANGE                   107         /* I1 = thread ptr, I2 = new threshold, I3 = old threshold, I4 =thread state*/ | ||||
| #define TX_TRACE_THREAD_PRIORITY_CHANGE                     108         /* I1 = thread ptr, I2 = new priority, I3 = old priority, I4 = thread state */ | ||||
| #define TX_TRACE_THREAD_RELINQUISH                          109         /* I1 = stack ptr, I2 = next thread ptr                                     */ | ||||
| #define TX_TRACE_THREAD_RESET                               110         /* I1 = thread ptr, I2 = thread state                                       */ | ||||
| #define TX_TRACE_THREAD_RESUME_API                          111         /* I1 = thread ptr, I2 = thread state, I3 = stack ptr                       */ | ||||
| #define TX_TRACE_THREAD_SLEEP                               112         /* I1 = sleep value, I2 = thread state, I3 = stack ptr                      */ | ||||
| #define TX_TRACE_THREAD_STACK_ERROR_NOTIFY                  113         /* None                                                                     */ | ||||
| #define TX_TRACE_THREAD_SUSPEND_API                         114         /* I1 = thread ptr, I2 = thread state, I3 = stack ptr                       */ | ||||
| #define TX_TRACE_THREAD_TERMINATE                           115         /* I1 = thread ptr, I2 = thread state, I3 = stack ptr                       */ | ||||
| #define TX_TRACE_THREAD_TIME_SLICE_CHANGE                   116         /* I1 = thread ptr, I2 = new timeslice, I3 = old timeslice                  */ | ||||
| #define TX_TRACE_THREAD_WAIT_ABORT                          117         /* I1 = thread ptr, I2 = thread state, I3 = stack ptr                       */ | ||||
| #define TX_TRACE_TIME_GET                                   120         /* I1 = current time, I2 = stack ptr                                        */ | ||||
| #define TX_TRACE_TIME_SET                                   121         /* I1 = new time                                                            */ | ||||
| #define TX_TRACE_TIMER_ACTIVATE                             122         /* I1 = timer ptr                                                           */ | ||||
| #define TX_TRACE_TIMER_CHANGE                               123         /* I1 = timer ptr, I2 = initial ticks, I3= reschedule ticks                 */ | ||||
| #define TX_TRACE_TIMER_CREATE                               124         /* I1 = timer ptr, I2 = initial ticks, I3= reschedule ticks, I4 = enable    */ | ||||
| #define TX_TRACE_TIMER_DEACTIVATE                           125         /* I1 = timer ptr, I2 = stack ptr                                           */ | ||||
| #define TX_TRACE_TIMER_DELETE                               126         /* I1 = timer ptr                                                           */ | ||||
| #define TX_TRACE_TIMER_INFO_GET                             127         /* I1 = timer ptr, I2 = stack ptr                                           */ | ||||
| #define TX_TRACE_TIMER_PERFORMANCE_INFO_GET                 128         /* I1 = timer ptr                                                           */ | ||||
| #define TX_TRACE_TIMER_PERFORMANCE_SYSTEM_INFO_GET          129         /* None                                                                     */ | ||||
|  | ||||
|  | ||||
| /* Define the an Trace Buffer Entry.  */ | ||||
|  | ||||
| typedef struct TX_TRACE_BUFFER_ENTRY_STRUCT | ||||
| { | ||||
|  | ||||
|     ULONG                                                   tx_trace_buffer_entry_thread_pointer; | ||||
|     ULONG                                                   tx_trace_buffer_entry_thread_priority; | ||||
|     ULONG                                                   tx_trace_buffer_entry_event_id; | ||||
|     ULONG                                                   tx_trace_buffer_entry_time_stamp; | ||||
| #ifdef TX_MISRA_ENABLE | ||||
|     ULONG                                                   tx_trace_buffer_entry_info_1; | ||||
|     ULONG                                                   tx_trace_buffer_entry_info_2; | ||||
|     ULONG                                                   tx_trace_buffer_entry_info_3; | ||||
|     ULONG                                                   tx_trace_buffer_entry_info_4; | ||||
| #else | ||||
|     ULONG                                                   tx_trace_buffer_entry_information_field_1; | ||||
|     ULONG                                                   tx_trace_buffer_entry_information_field_2; | ||||
|     ULONG                                                   tx_trace_buffer_entry_information_field_3; | ||||
|     ULONG                                                   tx_trace_buffer_entry_information_field_4; | ||||
| #endif | ||||
| } TX_TRACE_BUFFER_ENTRY; | ||||
|  | ||||
|  | ||||
| /* Trace management component data declarations follow.  */ | ||||
|  | ||||
| /* Determine if the initialization function of this component is including | ||||
|    this file.  If so, make the data definitions really happen.  Otherwise, | ||||
|    make them extern so other functions in the component can access them.  */ | ||||
|  | ||||
| #ifdef TX_TRACE_INIT | ||||
| #define TRACE_DECLARE | ||||
| #else | ||||
| #define TRACE_DECLARE extern | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Define the pointer to the start of the trace buffer control structure.   */ | ||||
|  | ||||
| TRACE_DECLARE  TX_TRACE_HEADER                  *_tx_trace_header_ptr; | ||||
|  | ||||
|  | ||||
| /* Define the pointer to the start of the trace object registry area in the trace buffer.  */ | ||||
|  | ||||
| TRACE_DECLARE  TX_TRACE_OBJECT_ENTRY            *_tx_trace_registry_start_ptr; | ||||
|  | ||||
|  | ||||
| /* Define the pointer to the end of the trace object registry area in the trace buffer.  */ | ||||
|  | ||||
| TRACE_DECLARE  TX_TRACE_OBJECT_ENTRY            *_tx_trace_registry_end_ptr; | ||||
|  | ||||
|  | ||||
| /* Define the pointer to the starting entry of the actual trace event area of the trace buffer.  */ | ||||
|  | ||||
| TRACE_DECLARE  TX_TRACE_BUFFER_ENTRY             *_tx_trace_buffer_start_ptr; | ||||
|  | ||||
|  | ||||
| /* Define the pointer to the ending entry of the actual trace event area of the trace buffer.  */ | ||||
|  | ||||
| TRACE_DECLARE  TX_TRACE_BUFFER_ENTRY             *_tx_trace_buffer_end_ptr; | ||||
|  | ||||
|  | ||||
| /* Define the pointer to the current entry of the actual trace event area of the trace buffer.  */ | ||||
|  | ||||
| TRACE_DECLARE  TX_TRACE_BUFFER_ENTRY             *_tx_trace_buffer_current_ptr; | ||||
|  | ||||
|  | ||||
| /* Define the trace event enable bits, where each bit represents a type of event that can be enabled | ||||
|    or disabled dynamically by the application.  */ | ||||
|  | ||||
| TRACE_DECLARE  ULONG                            _tx_trace_event_enable_bits; | ||||
|  | ||||
|  | ||||
| /* Define a counter that is used in environments that don't have a timer source. This counter | ||||
|    is incremented on each use giving each event a unique timestamp.  */ | ||||
|  | ||||
| TRACE_DECLARE  ULONG                             _tx_trace_simulated_time; | ||||
|  | ||||
|  | ||||
| /* Define the function pointer used to call the application when the trace buffer wraps. If NULL, | ||||
|    the application has not registered a callback function.  */ | ||||
|  | ||||
| TRACE_DECLARE  VOID                             (*_tx_trace_full_notify_function)(VOID *buffer); | ||||
|  | ||||
|  | ||||
| /* Define the total number of registry entries.  */ | ||||
|  | ||||
| TRACE_DECLARE  ULONG                             _tx_trace_total_registry_entries; | ||||
|  | ||||
|  | ||||
| /* Define a counter that is used to track the number of available registry entries.  */ | ||||
|  | ||||
| TRACE_DECLARE  ULONG                             _tx_trace_available_registry_entries; | ||||
|  | ||||
|  | ||||
| /* Define an index that represents the start of the registry search.  */ | ||||
|  | ||||
| TRACE_DECLARE  ULONG                             _tx_trace_registry_search_start; | ||||
|  | ||||
|  | ||||
| /* Define the event trace macros that are expanded in-line when event tracing is enabled.  */ | ||||
|  | ||||
| #ifdef TX_MISRA_ENABLE | ||||
| #define TX_TRACE_INFO_FIELD_ASSIGNMENT(a,b,c,d)  trace_event_ptr -> tx_trace_buffer_entry_info_1 =  (ULONG) (a); trace_event_ptr -> tx_trace_buffer_entry_info_2 =  (ULONG) (b); trace_event_ptr -> tx_trace_buffer_entry_info_3 =  (ULONG) (c); trace_event_ptr -> tx_trace_buffer_entry_info_4 =  (ULONG) (d); | ||||
| #else | ||||
| #define TX_TRACE_INFO_FIELD_ASSIGNMENT(a,b,c,d)  trace_event_ptr -> tx_trace_buffer_entry_information_field_1 =  (ULONG) (a); trace_event_ptr -> tx_trace_buffer_entry_information_field_2 =  (ULONG) (b); trace_event_ptr -> tx_trace_buffer_entry_information_field_3 =  (ULONG) (c); trace_event_ptr -> tx_trace_buffer_entry_information_field_4 =  (ULONG) (d); | ||||
| #endif | ||||
|  | ||||
|  | ||||
| #define TX_TRACE_INITIALIZE                                     _tx_trace_initialize(); | ||||
| #define TX_TRACE_OBJECT_REGISTER(t,p,n,a,b)                     _tx_trace_object_register((UCHAR) (t), (VOID *) (p), (CHAR *) (n), (ULONG) (a), (ULONG) (b)); | ||||
| #define TX_TRACE_OBJECT_UNREGISTER(o)                           _tx_trace_object_unregister((VOID *) (o)); | ||||
| #ifndef TX_TRACE_IN_LINE_INSERT | ||||
| #define TX_TRACE_IN_LINE_INSERT(i,a,b,c,d,e) \ | ||||
|         { \ | ||||
|         TX_TRACE_BUFFER_ENTRY     *trace_event_ptr; \ | ||||
|         ULONG                      trace_system_state; \ | ||||
|         ULONG                      trace_priority; \ | ||||
|         TX_THREAD                 *trace_thread_ptr; \ | ||||
|             trace_event_ptr =  _tx_trace_buffer_current_ptr; \ | ||||
|             if ((trace_event_ptr) && (_tx_trace_event_enable_bits & ((ULONG) (e)))) \ | ||||
|             { \ | ||||
|                 TX_TRACE_PORT_EXTENSION \ | ||||
|                 trace_system_state =  (ULONG) TX_THREAD_GET_SYSTEM_STATE(); \ | ||||
|                 TX_THREAD_GET_CURRENT(trace_thread_ptr) \ | ||||
|                 \ | ||||
|                 if (trace_system_state == 0) \ | ||||
|                 { \ | ||||
|                     trace_priority =  trace_thread_ptr -> tx_thread_priority; \ | ||||
|                     trace_priority =  trace_priority | 0x80000000UL | (trace_thread_ptr -> tx_thread_preempt_threshold << 16); \ | ||||
|                 } \ | ||||
|                 else if (trace_system_state < 0xF0F0F0F0UL) \ | ||||
|                 { \ | ||||
|                     trace_priority =    (ULONG) trace_thread_ptr; \ | ||||
|                     trace_thread_ptr =  (TX_THREAD *) 0xFFFFFFFFUL; \ | ||||
|                 } \ | ||||
|                 else \ | ||||
|                 { \ | ||||
|                     trace_thread_ptr =  (TX_THREAD *) 0xF0F0F0F0UL; \ | ||||
|                     trace_priority =    0; \ | ||||
|                 } \ | ||||
|                 trace_event_ptr -> tx_trace_buffer_entry_thread_pointer =       (ULONG) trace_thread_ptr; \ | ||||
|                 trace_event_ptr -> tx_trace_buffer_entry_thread_priority =      (ULONG) trace_priority; \ | ||||
|                 trace_event_ptr -> tx_trace_buffer_entry_event_id =             (ULONG) (i); \ | ||||
|                 trace_event_ptr -> tx_trace_buffer_entry_time_stamp =           (ULONG) TX_TRACE_TIME_SOURCE; \ | ||||
|                 TX_TRACE_INFO_FIELD_ASSIGNMENT((a),(b),(c),(d)) \ | ||||
|                 trace_event_ptr++; \ | ||||
|                 if (trace_event_ptr >= _tx_trace_buffer_end_ptr) \ | ||||
|                 { \ | ||||
|                     trace_event_ptr =  _tx_trace_buffer_start_ptr; \ | ||||
|                     _tx_trace_buffer_current_ptr =  trace_event_ptr;  \ | ||||
|                     _tx_trace_header_ptr -> tx_trace_header_buffer_current_pointer =  (ULONG) trace_event_ptr; \ | ||||
|                     if (_tx_trace_full_notify_function) \ | ||||
|                         (_tx_trace_full_notify_function)((VOID *) _tx_trace_header_ptr); \ | ||||
|                 } \ | ||||
|                 else \ | ||||
|                 { \ | ||||
|                     _tx_trace_buffer_current_ptr =  trace_event_ptr;  \ | ||||
|                     _tx_trace_header_ptr -> tx_trace_header_buffer_current_pointer =  (ULONG) trace_event_ptr; \ | ||||
|                 } \ | ||||
|             } \ | ||||
|         } | ||||
| #endif | ||||
| #endif | ||||
|  | ||||
|  | ||||
| #ifdef TX_SOURCE_CODE | ||||
|  | ||||
| /* Define internal function prototypes of the trace component, only if compiling ThreadX source code.  */ | ||||
|  | ||||
| VOID    _tx_trace_initialize(VOID); | ||||
| VOID    _tx_trace_object_register(UCHAR object_type, VOID *object_ptr, CHAR *object_name, ULONG parameter_1, ULONG parameter_2); | ||||
| VOID    _tx_trace_object_unregister(VOID *object_ptr); | ||||
|  | ||||
|  | ||||
| #ifdef TX_ENABLE_EVENT_TRACE | ||||
|  | ||||
| /* Check for MISRA compliance requirements.  */ | ||||
|  | ||||
| #ifdef TX_MISRA_ENABLE | ||||
|  | ||||
| /* Define MISRA-specific routines.  */ | ||||
|  | ||||
| UCHAR                   *_tx_misra_object_to_uchar_pointer_convert(TX_TRACE_OBJECT_ENTRY *pointer); | ||||
| TX_TRACE_OBJECT_ENTRY   *_tx_misra_uchar_to_object_pointer_convert(UCHAR *pointer); | ||||
| TX_TRACE_HEADER         *_tx_misra_uchar_to_header_pointer_convert(UCHAR *pointer); | ||||
| TX_TRACE_BUFFER_ENTRY   *_tx_misra_uchar_to_entry_pointer_convert(UCHAR *pointer); | ||||
| UCHAR                   *_tx_misra_entry_to_uchar_pointer_convert(TX_TRACE_BUFFER_ENTRY *pointer); | ||||
|  | ||||
|  | ||||
| #define TX_OBJECT_TO_UCHAR_POINTER_CONVERT(a)           _tx_misra_object_to_uchar_pointer_convert((a)) | ||||
| #define TX_UCHAR_TO_OBJECT_POINTER_CONVERT(a)           _tx_misra_uchar_to_object_pointer_convert((a)) | ||||
| #define TX_UCHAR_TO_HEADER_POINTER_CONVERT(a)           _tx_misra_uchar_to_header_pointer_convert((a)) | ||||
| #define TX_UCHAR_TO_ENTRY_POINTER_CONVERT(a)            _tx_misra_uchar_to_entry_pointer_convert((a)) | ||||
| #define TX_ENTRY_TO_UCHAR_POINTER_CONVERT(a)            _tx_misra_entry_to_uchar_pointer_convert((a)) | ||||
|  | ||||
| #else | ||||
|  | ||||
| #define TX_OBJECT_TO_UCHAR_POINTER_CONVERT(a)           ((UCHAR *) ((VOID *) (a))) | ||||
| #define TX_UCHAR_TO_OBJECT_POINTER_CONVERT(a)           ((TX_TRACE_OBJECT_ENTRY *) ((VOID *) (a))) | ||||
| #define TX_UCHAR_TO_HEADER_POINTER_CONVERT(a)           ((TX_TRACE_HEADER *) ((VOID *) (a))) | ||||
| #define TX_UCHAR_TO_ENTRY_POINTER_CONVERT(a)            ((TX_TRACE_BUFFER_ENTRY *) ((VOID *) (a))) | ||||
| #define TX_ENTRY_TO_UCHAR_POINTER_CONVERT(a)            ((UCHAR *) ((VOID *) (a))) | ||||
|  | ||||
| #endif | ||||
| #endif | ||||
| #endif | ||||
| #endif | ||||
|  | ||||
		Reference in New Issue
	
	Block a user