1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11
12 /**************************************************************************/
13 /**************************************************************************/
14 /** */
15 /** ThreadX Component */
16 /** */
17 /** Timer */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22 #define TX_SOURCE_CODE
23
24
25 /* Include necessary system files. */
26
27 #include "tx_api.h"
28 #include "tx_timer.h"
29 #ifdef TX_TIMER_ENABLE_PERFORMANCE_INFO
30 #include "tx_trace.h"
31 #endif
32
33
34 /**************************************************************************/
35 /* */
36 /* FUNCTION RELEASE */
37 /* */
38 /* _tx_timer_performance_info_get PORTABLE C */
39 /* 6.1 */
40 /* AUTHOR */
41 /* */
42 /* William E. Lamie, Microsoft Corporation */
43 /* */
44 /* DESCRIPTION */
45 /* */
46 /* This function retrieves performance information from the specified */
47 /* timer. */
48 /* */
49 /* INPUT */
50 /* */
51 /* timer_ptr Pointer to timer control block */
52 /* activates Destination for the number of */
53 /* activations of this timer */
54 /* reactivates Destination for the number of */
55 /* reactivations of this timer */
56 /* deactivates Destination for the number of */
57 /* deactivations of this timer */
58 /* expirations Destination for the number of */
59 /* expirations of this timer */
60 /* expiration_adjusts Destination for the number of */
61 /* expiration adjustments of this */
62 /* timer */
63 /* */
64 /* OUTPUT */
65 /* */
66 /* status Completion status */
67 /* */
68 /* CALLS */
69 /* */
70 /* None */
71 /* */
72 /* CALLED BY */
73 /* */
74 /* Application Code */
75 /* */
76 /* RELEASE HISTORY */
77 /* */
78 /* DATE NAME DESCRIPTION */
79 /* */
80 /* 05-19-2020 William E. Lamie Initial Version 6.0 */
81 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
82 /* resulting in version 6.1 */
83 /* */
84 /**************************************************************************/
_tx_timer_performance_info_get(TX_TIMER * timer_ptr,ULONG * activates,ULONG * reactivates,ULONG * deactivates,ULONG * expirations,ULONG * expiration_adjusts)85 UINT _tx_timer_performance_info_get(TX_TIMER *timer_ptr, ULONG *activates, ULONG *reactivates,
86 ULONG *deactivates, ULONG *expirations, ULONG *expiration_adjusts)
87 {
88
89 #ifdef TX_TIMER_ENABLE_PERFORMANCE_INFO
90
91 TX_INTERRUPT_SAVE_AREA
92 UINT status;
93
94
95 /* Determine if this is a legal request. */
96 if (timer_ptr == TX_NULL)
97 {
98
99 /* Timer pointer is illegal, return error. */
100 status = TX_PTR_ERROR;
101 }
102
103 /* Determine if the timer ID is invalid. */
104 else if (timer_ptr -> tx_timer_id != TX_TIMER_ID)
105 {
106
107 /* Timer pointer is illegal, return error. */
108 status = TX_PTR_ERROR;
109 }
110 else
111 {
112
113 /* Disable interrupts. */
114 TX_DISABLE
115
116 /* If trace is enabled, insert this event into the trace buffer. */
117 TX_TRACE_IN_LINE_INSERT(TX_TRACE_TIMER_PERFORMANCE_INFO_GET, timer_ptr, 0, 0, 0, TX_TRACE_TIMER_EVENTS)
118
119 /* Log this kernel call. */
120 TX_EL_TIMER_PERFORMANCE_INFO_GET_INSERT
121
122 /* Retrieve the number of activations of this timer. */
123 if (activates != TX_NULL)
124 {
125
126 *activates = timer_ptr -> tx_timer_performance_activate_count;
127 }
128
129 /* Retrieve the number of reactivations of this timer. */
130 if (reactivates != TX_NULL)
131 {
132
133 *reactivates = timer_ptr -> tx_timer_performance_reactivate_count;
134 }
135
136 /* Retrieve the number of deactivations of this timer. */
137 if (deactivates != TX_NULL)
138 {
139
140 *deactivates = timer_ptr -> tx_timer_performance_deactivate_count;
141 }
142
143 /* Retrieve the number of expirations of this timer. */
144 if (expirations != TX_NULL)
145 {
146
147 *expirations = timer_ptr -> tx_timer_performance_expiration_count;
148 }
149
150 /* Retrieve the number of expiration adjustments of this timer. */
151 if (expiration_adjusts != TX_NULL)
152 {
153
154 *expiration_adjusts = timer_ptr -> tx_timer_performance__expiration_adjust_count;
155 }
156
157 /* Restore interrupts. */
158 TX_RESTORE
159
160 /* Return successful completion. */
161 status = TX_SUCCESS;
162 }
163 #else
164 UINT status;
165
166
167 /* Access input arguments just for the sake of lint, MISRA, etc. */
168 if (timer_ptr != TX_NULL)
169 {
170
171 /* Not enabled, return error. */
172 status = TX_FEATURE_NOT_ENABLED;
173 }
174 else if (activates != TX_NULL)
175 {
176
177 /* Not enabled, return error. */
178 status = TX_FEATURE_NOT_ENABLED;
179 }
180 else if (reactivates != TX_NULL)
181 {
182
183 /* Not enabled, return error. */
184 status = TX_FEATURE_NOT_ENABLED;
185 }
186 else if (deactivates != TX_NULL)
187 {
188
189 /* Not enabled, return error. */
190 status = TX_FEATURE_NOT_ENABLED;
191 }
192 else if (expirations != TX_NULL)
193 {
194
195 /* Not enabled, return error. */
196 status = TX_FEATURE_NOT_ENABLED;
197 }
198 else if (expiration_adjusts != TX_NULL)
199 {
200
201 /* Not enabled, return error. */
202 status = TX_FEATURE_NOT_ENABLED;
203 }
204 else
205 {
206
207 /* Not enabled, return error. */
208 status = TX_FEATURE_NOT_ENABLED;
209 }
210 #endif
211
212 /* Return completion status. */
213 return(status);
214 }
215
216