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 /** Event Flags */
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_event_flags.h"
29 #ifdef TX_EVENT_FLAGS_ENABLE_PERFORMANCE_INFO
30 #include "tx_trace.h"
31 #endif
32
33
34 /**************************************************************************/
35 /* */
36 /* FUNCTION RELEASE */
37 /* */
38 /* _tx_event_flags_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 /* event flag group. */
48 /* */
49 /* INPUT */
50 /* */
51 /* group_ptr Pointer to event flag group */
52 /* sets Destination for the number of */
53 /* event flag sets on this group */
54 /* gets Destination for the number of */
55 /* event flag gets on this group */
56 /* suspensions Destination for the number of */
57 /* event flag suspensions on this */
58 /* group */
59 /* timeouts Destination for number of timeouts*/
60 /* on this event flag group */
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_event_flags_performance_info_get(TX_EVENT_FLAGS_GROUP * group_ptr,ULONG * sets,ULONG * gets,ULONG * suspensions,ULONG * timeouts)83 UINT _tx_event_flags_performance_info_get(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG *sets, ULONG *gets,
84 ULONG *suspensions, ULONG *timeouts)
85 {
86
87 #ifdef TX_EVENT_FLAGS_ENABLE_PERFORMANCE_INFO
88
89 TX_INTERRUPT_SAVE_AREA
90 UINT status;
91
92
93 /* Determine if this is a legal request. */
94 if (group_ptr == TX_NULL)
95 {
96
97 /* Event flags group pointer is illegal, return error. */
98 status = TX_PTR_ERROR;
99 }
100
101 /* Determine if the event group ID is invalid. */
102 else if (group_ptr -> tx_event_flags_group_id != TX_EVENT_FLAGS_ID)
103 {
104
105 /* Event flags group pointer is illegal, return error. */
106 status = TX_PTR_ERROR;
107 }
108 else
109 {
110
111 /* Disable interrupts. */
112 TX_DISABLE
113
114 /* If trace is enabled, insert this event into the trace buffer. */
115 TX_TRACE_IN_LINE_INSERT(TX_TRACE_EVENT_FLAGS_PERFORMANCE_INFO_GET, group_ptr, 0, 0, 0, TX_TRACE_EVENT_FLAGS_EVENTS)
116
117 /* Log this kernel call. */
118 TX_EL_EVENT_FLAGS_PERFORMANCE_INFO_GET_INSERT
119
120 /* Retrieve all the pertinent information and return it in the supplied
121 destinations. */
122
123 /* Retrieve the number of set operations on this event flag group. */
124 if (sets != TX_NULL)
125 {
126
127 *sets = group_ptr -> tx_event_flags_group_performance_set_count;
128 }
129
130 /* Retrieve the number of get operations on this event flag group. */
131 if (gets != TX_NULL)
132 {
133
134 *gets = group_ptr -> tx_event_flags_group__performance_get_count;
135 }
136
137 /* Retrieve the number of thread suspensions on this event flag group. */
138 if (suspensions != TX_NULL)
139 {
140
141 *suspensions = group_ptr -> tx_event_flags_group___performance_suspension_count;
142 }
143
144 /* Retrieve the number of thread timeouts on this event flag group. */
145 if (timeouts != TX_NULL)
146 {
147
148 *timeouts = group_ptr -> tx_event_flags_group____performance_timeout_count;
149 }
150
151 /* Restore interrupts. */
152 TX_RESTORE
153
154 /* Return successful completion. */
155 status = TX_SUCCESS;
156 }
157 #else
158 UINT status;
159
160
161 /* Access input arguments just for the sake of lint, MISRA, etc. */
162 if (group_ptr != TX_NULL)
163 {
164
165 /* Not enabled, return error. */
166 status = TX_FEATURE_NOT_ENABLED;
167 }
168 else if (sets != TX_NULL)
169 {
170
171 /* Not enabled, return error. */
172 status = TX_FEATURE_NOT_ENABLED;
173 }
174 else if (gets != TX_NULL)
175 {
176
177 /* Not enabled, return error. */
178 status = TX_FEATURE_NOT_ENABLED;
179 }
180 else if (suspensions != TX_NULL)
181 {
182
183 /* Not enabled, return error. */
184 status = TX_FEATURE_NOT_ENABLED;
185 }
186 else if (timeouts != TX_NULL)
187 {
188
189 /* Not enabled, return error. */
190 status = TX_FEATURE_NOT_ENABLED;
191 }
192 else
193 {
194
195 /* Not enabled, return error. */
196 status = TX_FEATURE_NOT_ENABLED;
197 }
198 #endif
199
200 /* Return completion status. */
201 return(status);
202 }
203
204