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 /** Timer */
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_timer.h"
30 #ifdef TX_TIMER_ENABLE_PERFORMANCE_INFO
31 #include "tx_trace.h"
32 #endif
33
34
35 /**************************************************************************/
36 /* */
37 /* FUNCTION RELEASE */
38 /* */
39 /* _tx_timer_performance_system_info_get PORTABLE C */
40 /* 6.1 */
41 /* AUTHOR */
42 /* */
43 /* William E. Lamie, Microsoft Corporation */
44 /* */
45 /* DESCRIPTION */
46 /* */
47 /* This function retrieves timer performance information. */
48 /* */
49 /* INPUT */
50 /* */
51 /* activates Destination for total number of */
52 /* activations */
53 /* reactivates Destination for total number of */
54 /* reactivations */
55 /* deactivates Destination for total number of */
56 /* deactivations */
57 /* expirations Destination for total number of */
58 /* expirations */
59 /* expiration_adjusts Destination for total number of */
60 /* expiration adjustments */
61 /* */
62 /* OUTPUT */
63 /* */
64 /* status Completion status */
65 /* */
66 /* CALLS */
67 /* */
68 /* None */
69 /* */
70 /* CALLED BY */
71 /* */
72 /* Application Code */
73 /* */
74 /* RELEASE HISTORY */
75 /* */
76 /* DATE NAME DESCRIPTION */
77 /* */
78 /* 05-19-2020 William E. Lamie Initial Version 6.0 */
79 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
80 /* resulting in version 6.1 */
81 /* */
82 /**************************************************************************/
_tx_timer_performance_system_info_get(ULONG * activates,ULONG * reactivates,ULONG * deactivates,ULONG * expirations,ULONG * expiration_adjusts)83 UINT _tx_timer_performance_system_info_get(ULONG *activates, ULONG *reactivates,
84 ULONG *deactivates, ULONG *expirations, ULONG *expiration_adjusts)
85 {
86
87 #ifdef TX_TIMER_ENABLE_PERFORMANCE_INFO
88
89 TX_INTERRUPT_SAVE_AREA
90
91
92 /* Disable interrupts. */
93 TX_DISABLE
94
95 /* If trace is enabled, insert this event into the trace buffer. */
96 TX_TRACE_IN_LINE_INSERT(TX_TRACE_TIMER_PERFORMANCE_SYSTEM_INFO_GET, 0, 0, 0, 0, TX_TRACE_TIMER_EVENTS)
97
98 /* Log this kernel call. */
99 TX_EL_TIMER_PERFORMANCE_SYSTEM_INFO_GET_INSERT
100
101 /* Retrieve the total number of timer activations. */
102 if (activates != TX_NULL)
103 {
104
105 *activates = _tx_timer_performance_activate_count;
106 }
107
108 /* Retrieve the total number of timer reactivations. */
109 if (reactivates != TX_NULL)
110 {
111
112 *reactivates = _tx_timer_performance_reactivate_count;
113 }
114
115 /* Retrieve the total number of timer deactivations. */
116 if (deactivates != TX_NULL)
117 {
118
119 *deactivates = _tx_timer_performance_deactivate_count;
120 }
121
122 /* Retrieve the total number of timer expirations. */
123 if (expirations != TX_NULL)
124 {
125
126 *expirations = _tx_timer_performance_expiration_count;
127 }
128
129 /* Retrieve the total number of timer expiration adjustments. */
130 if (expiration_adjusts != TX_NULL)
131 {
132
133 *expiration_adjusts = _tx_timer_performance__expiration_adjust_count;
134 }
135
136 /* Restore interrupts. */
137 TX_RESTORE
138
139 /* Return completion status. */
140 return(TX_SUCCESS);
141
142 #else
143
144 UINT status;
145
146
147 /* Access input arguments just for the sake of lint, MISRA, etc. */
148 if (activates != TX_NULL)
149 {
150
151 /* Not enabled, return error. */
152 status = TX_FEATURE_NOT_ENABLED;
153 }
154 else if (reactivates != TX_NULL)
155 {
156
157 /* Not enabled, return error. */
158 status = TX_FEATURE_NOT_ENABLED;
159 }
160 else if (deactivates != TX_NULL)
161 {
162
163 /* Not enabled, return error. */
164 status = TX_FEATURE_NOT_ENABLED;
165 }
166 else if (expirations != TX_NULL)
167 {
168
169 /* Not enabled, return error. */
170 status = TX_FEATURE_NOT_ENABLED;
171 }
172 else if (expiration_adjusts != TX_NULL)
173 {
174
175 /* Not enabled, return error. */
176 status = TX_FEATURE_NOT_ENABLED;
177 }
178 else
179 {
180
181 /* Not enabled, return error. */
182 status = TX_FEATURE_NOT_ENABLED;
183 }
184
185 /* Return completion status. */
186 return(status);
187 #endif
188 }
189
190