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_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 system event flag performance information.  */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    sets                              Destination for total number of   */
52 /*                                        event flag sets                 */
53 /*    gets                              Destination for total number of   */
54 /*                                        event flag gets                 */
55 /*    suspensions                       Destination for total number of   */
56 /*                                        event flag suspensions          */
57 /*    timeouts                          Destination for total number of   */
58 /*                                        timeouts                        */
59 /*                                                                        */
60 /*  OUTPUT                                                                */
61 /*                                                                        */
62 /*    status                            Completion status                 */
63 /*                                                                        */
64 /*  CALLS                                                                 */
65 /*                                                                        */
66 /*    None                                                                */
67 /*                                                                        */
68 /*  CALLED BY                                                             */
69 /*                                                                        */
70 /*    Application Code                                                    */
71 /*                                                                        */
72 /*  RELEASE HISTORY                                                       */
73 /*                                                                        */
74 /*    DATE              NAME                      DESCRIPTION             */
75 /*                                                                        */
76 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
77 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
78 /*                                            resulting in version 6.1    */
79 /*                                                                        */
80 /**************************************************************************/
_tx_event_flags_performance_system_info_get(ULONG * sets,ULONG * gets,ULONG * suspensions,ULONG * timeouts)81 UINT  _tx_event_flags_performance_system_info_get(ULONG *sets, ULONG *gets, ULONG *suspensions, ULONG *timeouts)
82 {
83 
84 #ifdef TX_EVENT_FLAGS_ENABLE_PERFORMANCE_INFO
85 
86 TX_INTERRUPT_SAVE_AREA
87 
88 
89     /* Disable interrupts.  */
90     TX_DISABLE
91 
92     /* If trace is enabled, insert this event into the trace buffer.  */
93     TX_TRACE_IN_LINE_INSERT(TX_TRACE_EVENT_FLAGS__PERFORMANCE_SYSTEM_INFO_GET, 0, 0, 0, 0, TX_TRACE_EVENT_FLAGS_EVENTS)
94 
95     /* Log this kernel call.  */
96     TX_EL_EVENT_FLAGS__PERFORMANCE_SYSTEM_INFO_GET_INSERT
97 
98     /* Retrieve all the pertinent information and return it in the supplied
99        destinations.  */
100 
101     /* Retrieve the total number of event flag set operations.  */
102     if (sets != TX_NULL)
103     {
104 
105         *sets =  _tx_event_flags_performance_set_count;
106     }
107 
108     /* Retrieve the total number of event flag get operations.  */
109     if (gets != TX_NULL)
110     {
111 
112         *gets =  _tx_event_flags_performance_get_count;
113     }
114 
115     /* Retrieve the total number of event flag thread suspensions.  */
116     if (suspensions != TX_NULL)
117     {
118 
119         *suspensions =  _tx_event_flags_performance_suspension_count;
120     }
121 
122     /* Retrieve the total number of event flag thread timeouts.  */
123     if (timeouts != TX_NULL)
124     {
125 
126         *timeouts =  _tx_event_flags_performance_timeout_count;
127     }
128 
129     /* Restore interrupts.  */
130     TX_RESTORE
131 
132     /* Return completion status.  */
133     return(TX_SUCCESS);
134 
135 #else
136 
137 UINT        status;
138 
139 
140     /* Access input arguments just for the sake of lint, MISRA, etc.  */
141     if (sets != TX_NULL)
142     {
143 
144         /* Not enabled, return error.  */
145         status =  TX_FEATURE_NOT_ENABLED;
146     }
147     else if (gets != TX_NULL)
148     {
149 
150         /* Not enabled, return error.  */
151         status =  TX_FEATURE_NOT_ENABLED;
152     }
153     else if (suspensions != TX_NULL)
154     {
155 
156         /* Not enabled, return error.  */
157         status =  TX_FEATURE_NOT_ENABLED;
158     }
159     else if (timeouts != TX_NULL)
160     {
161 
162         /* Not enabled, return error.  */
163         status =  TX_FEATURE_NOT_ENABLED;
164     }
165     else
166     {
167 
168         /* Not enabled, return error.  */
169         status =  TX_FEATURE_NOT_ENABLED;
170     }
171 
172     /* Return completion status.  */
173     return(status);
174 #endif
175 }
176 
177