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 /**   Byte Memory                                                         */
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_byte_pool.h"
30 #ifdef TX_BYTE_POOL_ENABLE_PERFORMANCE_INFO
31 #include "tx_trace.h"
32 #endif
33 
34 /**************************************************************************/
35 /*                                                                        */
36 /*  FUNCTION                                               RELEASE        */
37 /*                                                                        */
38 /*    _tx_byte_pool_performance_system_info_get           PORTABLE C      */
39 /*                                                           6.1          */
40 /*  AUTHOR                                                                */
41 /*                                                                        */
42 /*    William E. Lamie, Microsoft Corporation                             */
43 /*                                                                        */
44 /*  DESCRIPTION                                                           */
45 /*                                                                        */
46 /*    This function retrieves byte pool performance information.          */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    allocates                         Destination for total number of   */
51 /*                                        allocates                       */
52 /*    releases                          Destination for total number of   */
53 /*                                        releases                        */
54 /*    fragments_searched                Destination for total number of   */
55 /*                                        fragments searched during       */
56 /*                                        allocation                      */
57 /*    merges                            Destination for total number of   */
58 /*                                        adjacent free fragments merged  */
59 /*    splits                            Destination for total number of   */
60 /*                                        fragments split during          */
61 /*                                        allocation                      */
62 /*    suspensions                       Destination for total number of   */
63 /*                                        suspensions                     */
64 /*    timeouts                          Destination for total number of   */
65 /*                                        timeouts                        */
66 /*                                                                        */
67 /*  OUTPUT                                                                */
68 /*                                                                        */
69 /*    status                            Completion status                 */
70 /*                                                                        */
71 /*  CALLS                                                                 */
72 /*                                                                        */
73 /*    None                                                                */
74 /*                                                                        */
75 /*  CALLED BY                                                             */
76 /*                                                                        */
77 /*    Application Code                                                    */
78 /*                                                                        */
79 /*  RELEASE HISTORY                                                       */
80 /*                                                                        */
81 /*    DATE              NAME                      DESCRIPTION             */
82 /*                                                                        */
83 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
84 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
85 /*                                            resulting in version 6.1    */
86 /*                                                                        */
87 /**************************************************************************/
_tx_byte_pool_performance_system_info_get(ULONG * allocates,ULONG * releases,ULONG * fragments_searched,ULONG * merges,ULONG * splits,ULONG * suspensions,ULONG * timeouts)88 UINT  _tx_byte_pool_performance_system_info_get(ULONG *allocates, ULONG *releases,
89                     ULONG *fragments_searched, ULONG *merges, ULONG *splits, ULONG *suspensions, ULONG *timeouts)
90 {
91 
92 #ifdef TX_BYTE_POOL_ENABLE_PERFORMANCE_INFO
93 
94 TX_INTERRUPT_SAVE_AREA
95 
96 
97     /* Disable interrupts.  */
98     TX_DISABLE
99 
100     /* If trace is enabled, insert this event into the trace buffer.  */
101     TX_TRACE_IN_LINE_INSERT(TX_TRACE_BYTE_POOL__PERFORMANCE_SYSTEM_INFO_GET, 0, 0, 0, 0, TX_TRACE_BYTE_POOL_EVENTS)
102 
103     /* Log this kernel call.  */
104     TX_EL_BYTE_POOL_PERFORMANCE_SYSTEM_INFO_GET_INSERT
105 
106     /* Retrieve all the pertinent information and return it in the supplied
107        destinations.  */
108 
109     /* Retrieve the total number of byte pool allocates.  */
110     if (allocates != TX_NULL)
111     {
112 
113         *allocates =  _tx_byte_pool_performance_allocate_count;
114     }
115 
116     /* Retrieve the total number of byte pool releases.  */
117     if (releases != TX_NULL)
118     {
119 
120         *releases =  _tx_byte_pool_performance_release_count;
121     }
122 
123     /* Retrieve the total number of byte pool fragments searched.  */
124     if (fragments_searched != TX_NULL)
125     {
126 
127         *fragments_searched =  _tx_byte_pool_performance_search_count;
128     }
129 
130     /* Retrieve the total number of byte pool fragments merged.  */
131     if (merges != TX_NULL)
132     {
133 
134         *merges =  _tx_byte_pool_performance_merge_count;
135     }
136 
137     /* Retrieve the total number of byte pool fragment splits.  */
138     if (splits != TX_NULL)
139     {
140 
141         *splits =  _tx_byte_pool_performance_split_count;
142     }
143 
144     /* Retrieve the total number of byte pool suspensions.  */
145     if (suspensions != TX_NULL)
146     {
147 
148         *suspensions =  _tx_byte_pool_performance_suspension_count;
149     }
150 
151     /* Retrieve the total number of byte pool timeouts.  */
152     if (timeouts != TX_NULL)
153     {
154 
155         *timeouts =  _tx_byte_pool_performance_timeout_count;
156     }
157 
158     /* Restore interrupts.  */
159     TX_RESTORE
160 
161     /* Return completion status.  */
162     return(TX_SUCCESS);
163 
164 #else
165 
166 UINT        status;
167 
168 
169     /* Access input arguments just for the sake of lint, MISRA, etc.  */
170     if (allocates != TX_NULL)
171     {
172 
173         /* Not enabled, return error.  */
174         status =  TX_FEATURE_NOT_ENABLED;
175     }
176     else if (releases != TX_NULL)
177     {
178 
179         /* Not enabled, return error.  */
180         status =  TX_FEATURE_NOT_ENABLED;
181     }
182     else if (fragments_searched != TX_NULL)
183     {
184 
185         /* Not enabled, return error.  */
186         status =  TX_FEATURE_NOT_ENABLED;
187     }
188     else if (merges != TX_NULL)
189     {
190 
191         /* Not enabled, return error.  */
192         status =  TX_FEATURE_NOT_ENABLED;
193     }
194     else if (splits != TX_NULL)
195     {
196 
197         /* Not enabled, return error.  */
198         status =  TX_FEATURE_NOT_ENABLED;
199     }
200     else if (suspensions != TX_NULL)
201     {
202 
203         /* Not enabled, return error.  */
204         status =  TX_FEATURE_NOT_ENABLED;
205     }
206     else if (timeouts != TX_NULL)
207     {
208 
209         /* Not enabled, return error.  */
210         status =  TX_FEATURE_NOT_ENABLED;
211     }
212     else
213     {
214 
215         /* Not enabled, return error.  */
216         status =  TX_FEATURE_NOT_ENABLED;
217     }
218 
219     /* Return completion status.  */
220     return(status);
221 #endif
222 }
223 
224