1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** ThreadX Component                                                     */
17 /**                                                                       */
18 /**   Trace                                                               */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define TX_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "tx_api.h"
29 #include "tx_trace.h"
30 #ifdef TX_ENABLE_EVENT_TRACE
31 
32 
33 /* Define the pointer to the start of the trace buffer control structure.   */
34 
35 TX_TRACE_HEADER                   *_tx_trace_header_ptr;
36 
37 
38 /* Define the pointer to the start of the trace object registry area in the trace buffer.  */
39 
40 TX_TRACE_OBJECT_ENTRY             *_tx_trace_registry_start_ptr;
41 
42 
43 /* Define the pointer to the end of the trace object registry area in the trace buffer.  */
44 
45 TX_TRACE_OBJECT_ENTRY             *_tx_trace_registry_end_ptr;
46 
47 
48 /* Define the pointer to the starting entry of the actual trace event area of the trace buffer.  */
49 
50 TX_TRACE_BUFFER_ENTRY             *_tx_trace_buffer_start_ptr;
51 
52 
53 /* Define the pointer to the ending entry of the actual trace event area of the trace buffer.  */
54 
55 TX_TRACE_BUFFER_ENTRY             *_tx_trace_buffer_end_ptr;
56 
57 
58 /* Define the pointer to the current entry of the actual trace event area of the trace buffer.  */
59 
60 TX_TRACE_BUFFER_ENTRY             *_tx_trace_buffer_current_ptr;
61 
62 
63 /* Define the trace event enable bits, where each bit represents a type of event that can be enabled
64    or disabled dynamically by the application.  */
65 
66 ULONG                            _tx_trace_event_enable_bits;
67 
68 
69 /* Define a counter that is used in environments that don't have a timer source. This counter
70    is incremented on each use giving each event a unique timestamp.  */
71 
72 ULONG                             _tx_trace_simulated_time;
73 
74 
75 /* Define the function pointer used to call the application when the trace buffer wraps. If NULL,
76    the application has not registered a callback function.  */
77 
78 VOID                             (*_tx_trace_full_notify_function)(VOID *buffer);
79 
80 
81 /* Define the total number of registry entries.  */
82 
83 ULONG                             _tx_trace_total_registry_entries;
84 
85 
86 /* Define a counter that is used to track the number of available registry entries.  */
87 
88 ULONG                             _tx_trace_available_registry_entries;
89 
90 
91 /* Define an index that represents the start of the registry search.  */
92 
93 ULONG                             _tx_trace_registry_search_start;
94 
95 #endif
96 
97 
98 /**************************************************************************/
99 /*                                                                        */
100 /*  FUNCTION                                               RELEASE        */
101 /*                                                                        */
102 /*    _tx_trace_initialize                                PORTABLE C      */
103 /*                                                           6.1          */
104 /*  AUTHOR                                                                */
105 /*                                                                        */
106 /*    William E. Lamie, Microsoft Corporation                             */
107 /*                                                                        */
108 /*  DESCRIPTION                                                           */
109 /*                                                                        */
110 /*    This function initializes the various control data structures for   */
111 /*    the trace component.                                                */
112 /*                                                                        */
113 /*  INPUT                                                                 */
114 /*                                                                        */
115 /*    None                                                                */
116 /*                                                                        */
117 /*  OUTPUT                                                                */
118 /*                                                                        */
119 /*    None                                                                */
120 /*                                                                        */
121 /*  CALLS                                                                 */
122 /*                                                                        */
123 /*    None                                                                */
124 /*                                                                        */
125 /*  CALLED BY                                                             */
126 /*                                                                        */
127 /*    _tx_initialize_high_level         High level initialization         */
128 /*                                                                        */
129 /*  RELEASE HISTORY                                                       */
130 /*                                                                        */
131 /*    DATE              NAME                      DESCRIPTION             */
132 /*                                                                        */
133 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
134 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
135 /*                                            resulting in version 6.1    */
136 /*                                                                        */
137 /**************************************************************************/
_tx_trace_initialize(VOID)138 VOID  _tx_trace_initialize(VOID)
139 {
140 
141 #ifdef TX_ENABLE_EVENT_TRACE
142 #ifndef TX_DISABLE_REDUNDANT_CLEARING
143 
144     /* Initialize all the pointers to the trace buffer to NULL.  */
145     _tx_trace_header_ptr =          TX_NULL;
146     _tx_trace_registry_start_ptr =  TX_NULL;
147     _tx_trace_registry_end_ptr =    TX_NULL;
148     _tx_trace_buffer_start_ptr =    TX_NULL;
149     _tx_trace_buffer_end_ptr =      TX_NULL;
150     _tx_trace_buffer_current_ptr =  TX_NULL;
151 #endif
152 #endif
153 }
154 
155