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 /** Event Flags */
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_event_flags.h"
30 #ifdef TX_EVENT_FLAGS_ENABLE_PERFORMANCE_INFO
31 #include "tx_trace.h"
32 #endif
33
34
35 /**************************************************************************/
36 /* */
37 /* FUNCTION RELEASE */
38 /* */
39 /* _tx_event_flags_performance_info_get PORTABLE C */
40 /* 6.1 */
41 /* AUTHOR */
42 /* */
43 /* William E. Lamie, Microsoft Corporation */
44 /* */
45 /* DESCRIPTION */
46 /* */
47 /* This function retrieves performance information from the specified */
48 /* event flag group. */
49 /* */
50 /* INPUT */
51 /* */
52 /* group_ptr Pointer to event flag group */
53 /* sets Destination for the number of */
54 /* event flag sets on this group */
55 /* gets Destination for the number of */
56 /* event flag gets on this group */
57 /* suspensions Destination for the number of */
58 /* event flag suspensions on this */
59 /* group */
60 /* timeouts Destination for number of timeouts*/
61 /* on this event flag group */
62 /* */
63 /* OUTPUT */
64 /* */
65 /* status Completion status */
66 /* */
67 /* CALLS */
68 /* */
69 /* None */
70 /* */
71 /* CALLED BY */
72 /* */
73 /* Application Code */
74 /* */
75 /* RELEASE HISTORY */
76 /* */
77 /* DATE NAME DESCRIPTION */
78 /* */
79 /* 05-19-2020 William E. Lamie Initial Version 6.0 */
80 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
81 /* resulting in version 6.1 */
82 /* */
83 /**************************************************************************/
_tx_event_flags_performance_info_get(TX_EVENT_FLAGS_GROUP * group_ptr,ULONG * sets,ULONG * gets,ULONG * suspensions,ULONG * timeouts)84 UINT _tx_event_flags_performance_info_get(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG *sets, ULONG *gets,
85 ULONG *suspensions, ULONG *timeouts)
86 {
87
88 #ifdef TX_EVENT_FLAGS_ENABLE_PERFORMANCE_INFO
89
90 TX_INTERRUPT_SAVE_AREA
91 UINT status;
92
93
94 /* Determine if this is a legal request. */
95 if (group_ptr == TX_NULL)
96 {
97
98 /* Event flags group pointer is illegal, return error. */
99 status = TX_PTR_ERROR;
100 }
101
102 /* Determine if the event group ID is invalid. */
103 else if (group_ptr -> tx_event_flags_group_id != TX_EVENT_FLAGS_ID)
104 {
105
106 /* Event flags group pointer is illegal, return error. */
107 status = TX_PTR_ERROR;
108 }
109 else
110 {
111
112 /* Disable interrupts. */
113 TX_DISABLE
114
115 /* If trace is enabled, insert this event into the trace buffer. */
116 TX_TRACE_IN_LINE_INSERT(TX_TRACE_EVENT_FLAGS_PERFORMANCE_INFO_GET, group_ptr, 0, 0, 0, TX_TRACE_EVENT_FLAGS_EVENTS)
117
118 /* Log this kernel call. */
119 TX_EL_EVENT_FLAGS_PERFORMANCE_INFO_GET_INSERT
120
121 /* Retrieve all the pertinent information and return it in the supplied
122 destinations. */
123
124 /* Retrieve the number of set operations on this event flag group. */
125 if (sets != TX_NULL)
126 {
127
128 *sets = group_ptr -> tx_event_flags_group_performance_set_count;
129 }
130
131 /* Retrieve the number of get operations on this event flag group. */
132 if (gets != TX_NULL)
133 {
134
135 *gets = group_ptr -> tx_event_flags_group__performance_get_count;
136 }
137
138 /* Retrieve the number of thread suspensions on this event flag group. */
139 if (suspensions != TX_NULL)
140 {
141
142 *suspensions = group_ptr -> tx_event_flags_group___performance_suspension_count;
143 }
144
145 /* Retrieve the number of thread timeouts on this event flag group. */
146 if (timeouts != TX_NULL)
147 {
148
149 *timeouts = group_ptr -> tx_event_flags_group____performance_timeout_count;
150 }
151
152 /* Restore interrupts. */
153 TX_RESTORE
154
155 /* Return successful completion. */
156 status = TX_SUCCESS;
157 }
158 #else
159 UINT status;
160
161
162 /* Access input arguments just for the sake of lint, MISRA, etc. */
163 if (group_ptr != TX_NULL)
164 {
165
166 /* Not enabled, return error. */
167 status = TX_FEATURE_NOT_ENABLED;
168 }
169 else if (sets != TX_NULL)
170 {
171
172 /* Not enabled, return error. */
173 status = TX_FEATURE_NOT_ENABLED;
174 }
175 else if (gets != TX_NULL)
176 {
177
178 /* Not enabled, return error. */
179 status = TX_FEATURE_NOT_ENABLED;
180 }
181 else if (suspensions != TX_NULL)
182 {
183
184 /* Not enabled, return error. */
185 status = TX_FEATURE_NOT_ENABLED;
186 }
187 else if (timeouts != TX_NULL)
188 {
189
190 /* Not enabled, return error. */
191 status = TX_FEATURE_NOT_ENABLED;
192 }
193 else
194 {
195
196 /* Not enabled, return error. */
197 status = TX_FEATURE_NOT_ENABLED;
198 }
199 #endif
200
201 /* Return completion status. */
202 return(status);
203 }
204
205