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