Rev 1498 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1498 | Rev 2216 | ||
---|---|---|---|
1 | /****************************************************************************** |
1 | /****************************************************************************** |
2 | * |
2 | * |
3 | * Module Name: uttrack - Memory allocation tracking routines (debug only) |
3 | * Module Name: uttrack - Memory allocation tracking routines (debug only) |
4 | * |
4 | * |
5 | *****************************************************************************/ |
5 | *****************************************************************************/ |
6 | 6 | ||
7 | /****************************************************************************** |
7 | /****************************************************************************** |
8 | * |
8 | * |
9 | * 1. Copyright Notice |
9 | * 1. Copyright Notice |
10 | * |
10 | * |
11 | * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. |
11 | * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. |
12 | * All rights reserved. |
12 | * All rights reserved. |
13 | * |
13 | * |
14 | * 2. License |
14 | * 2. License |
15 | * |
15 | * |
16 | * 2.1. This is your license from Intel Corp. under its intellectual property |
16 | * 2.1. This is your license from Intel Corp. under its intellectual property |
17 | * rights. You may have additional license terms from the party that provided |
17 | * rights. You may have additional license terms from the party that provided |
18 | * you this software, covering your right to use that party's intellectual |
18 | * you this software, covering your right to use that party's intellectual |
19 | * property rights. |
19 | * property rights. |
20 | * |
20 | * |
21 | * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
21 | * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a |
22 | * copy of the source code appearing in this file ("Covered Code") an |
22 | * copy of the source code appearing in this file ("Covered Code") an |
23 | * irrevocable, perpetual, worldwide license under Intel's copyrights in the |
23 | * irrevocable, perpetual, worldwide license under Intel's copyrights in the |
24 | * base code distributed originally by Intel ("Original Intel Code") to copy, |
24 | * base code distributed originally by Intel ("Original Intel Code") to copy, |
25 | * make derivatives, distribute, use and display any portion of the Covered |
25 | * make derivatives, distribute, use and display any portion of the Covered |
26 | * Code in any form, with the right to sublicense such rights; and |
26 | * Code in any form, with the right to sublicense such rights; and |
27 | * |
27 | * |
28 | * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
28 | * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent |
29 | * license (with the right to sublicense), under only those claims of Intel |
29 | * license (with the right to sublicense), under only those claims of Intel |
30 | * patents that are infringed by the Original Intel Code, to make, use, sell, |
30 | * patents that are infringed by the Original Intel Code, to make, use, sell, |
31 | * offer to sell, and import the Covered Code and derivative works thereof |
31 | * offer to sell, and import the Covered Code and derivative works thereof |
32 | * solely to the minimum extent necessary to exercise the above copyright |
32 | * solely to the minimum extent necessary to exercise the above copyright |
33 | * license, and in no event shall the patent license extend to any additions |
33 | * license, and in no event shall the patent license extend to any additions |
34 | * to or modifications of the Original Intel Code. No other license or right |
34 | * to or modifications of the Original Intel Code. No other license or right |
35 | * is granted directly or by implication, estoppel or otherwise; |
35 | * is granted directly or by implication, estoppel or otherwise; |
36 | * |
36 | * |
37 | * The above copyright and patent license is granted only if the following |
37 | * The above copyright and patent license is granted only if the following |
38 | * conditions are met: |
38 | * conditions are met: |
39 | * |
39 | * |
40 | * 3. Conditions |
40 | * 3. Conditions |
41 | * |
41 | * |
42 | * 3.1. Redistribution of Source with Rights to Further Distribute Source. |
42 | * 3.1. Redistribution of Source with Rights to Further Distribute Source. |
43 | * Redistribution of source code of any substantial portion of the Covered |
43 | * Redistribution of source code of any substantial portion of the Covered |
44 | * Code or modification with rights to further distribute source must include |
44 | * Code or modification with rights to further distribute source must include |
45 | * the above Copyright Notice, the above License, this list of Conditions, |
45 | * the above Copyright Notice, the above License, this list of Conditions, |
46 | * and the following Disclaimer and Export Compliance provision. In addition, |
46 | * and the following Disclaimer and Export Compliance provision. In addition, |
47 | * Licensee must cause all Covered Code to which Licensee contributes to |
47 | * Licensee must cause all Covered Code to which Licensee contributes to |
48 | * contain a file documenting the changes Licensee made to create that Covered |
48 | * contain a file documenting the changes Licensee made to create that Covered |
49 | * Code and the date of any change. Licensee must include in that file the |
49 | * Code and the date of any change. Licensee must include in that file the |
50 | * documentation of any changes made by any predecessor Licensee. Licensee |
50 | * documentation of any changes made by any predecessor Licensee. Licensee |
51 | * must include a prominent statement that the modification is derived, |
51 | * must include a prominent statement that the modification is derived, |
52 | * directly or indirectly, from Original Intel Code. |
52 | * directly or indirectly, from Original Intel Code. |
53 | * |
53 | * |
54 | * 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
54 | * 3.2. Redistribution of Source with no Rights to Further Distribute Source. |
55 | * Redistribution of source code of any substantial portion of the Covered |
55 | * Redistribution of source code of any substantial portion of the Covered |
56 | * Code or modification without rights to further distribute source must |
56 | * Code or modification without rights to further distribute source must |
57 | * include the following Disclaimer and Export Compliance provision in the |
57 | * include the following Disclaimer and Export Compliance provision in the |
58 | * documentation and/or other materials provided with distribution. In |
58 | * documentation and/or other materials provided with distribution. In |
59 | * addition, Licensee may not authorize further sublicense of source of any |
59 | * addition, Licensee may not authorize further sublicense of source of any |
60 | * portion of the Covered Code, and must include terms to the effect that the |
60 | * portion of the Covered Code, and must include terms to the effect that the |
61 | * license from Licensee to its licensee is limited to the intellectual |
61 | * license from Licensee to its licensee is limited to the intellectual |
62 | * property embodied in the software Licensee provides to its licensee, and |
62 | * property embodied in the software Licensee provides to its licensee, and |
63 | * not to intellectual property embodied in modifications its licensee may |
63 | * not to intellectual property embodied in modifications its licensee may |
64 | * make. |
64 | * make. |
65 | * |
65 | * |
66 | * 3.3. Redistribution of Executable. Redistribution in executable form of any |
66 | * 3.3. Redistribution of Executable. Redistribution in executable form of any |
67 | * substantial portion of the Covered Code or modification must reproduce the |
67 | * substantial portion of the Covered Code or modification must reproduce the |
68 | * above Copyright Notice, and the following Disclaimer and Export Compliance |
68 | * above Copyright Notice, and the following Disclaimer and Export Compliance |
69 | * provision in the documentation and/or other materials provided with the |
69 | * provision in the documentation and/or other materials provided with the |
70 | * distribution. |
70 | * distribution. |
71 | * |
71 | * |
72 | * 3.4. Intel retains all right, title, and interest in and to the Original |
72 | * 3.4. Intel retains all right, title, and interest in and to the Original |
73 | * Intel Code. |
73 | * Intel Code. |
74 | * |
74 | * |
75 | * 3.5. Neither the name Intel nor any other trademark owned or controlled by |
75 | * 3.5. Neither the name Intel nor any other trademark owned or controlled by |
76 | * Intel shall be used in advertising or otherwise to promote the sale, use or |
76 | * Intel shall be used in advertising or otherwise to promote the sale, use or |
77 | * other dealings in products derived from or relating to the Covered Code |
77 | * other dealings in products derived from or relating to the Covered Code |
78 | * without prior written authorization from Intel. |
78 | * without prior written authorization from Intel. |
79 | * |
79 | * |
80 | * 4. Disclaimer and Export Compliance |
80 | * 4. Disclaimer and Export Compliance |
81 | * |
81 | * |
82 | * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
82 | * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED |
83 | * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
83 | * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE |
84 | * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
84 | * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, |
85 | * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
85 | * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY |
86 | * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
86 | * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY |
87 | * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
87 | * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A |
88 | * PARTICULAR PURPOSE. |
88 | * PARTICULAR PURPOSE. |
89 | * |
89 | * |
90 | * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
90 | * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES |
91 | * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
91 | * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR |
92 | * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
92 | * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, |
93 | * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
93 | * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY |
94 | * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
94 | * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL |
95 | * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
95 | * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS |
96 | * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
96 | * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY |
97 | * LIMITED REMEDY. |
97 | * LIMITED REMEDY. |
98 | * |
98 | * |
99 | * 4.3. Licensee shall not export, either directly or indirectly, any of this |
99 | * 4.3. Licensee shall not export, either directly or indirectly, any of this |
100 | * software or system incorporating such software without first obtaining any |
100 | * software or system incorporating such software without first obtaining any |
101 | * required license or other approval from the U. S. Department of Commerce or |
101 | * required license or other approval from the U. S. Department of Commerce or |
102 | * any other agency or department of the United States Government. In the |
102 | * any other agency or department of the United States Government. In the |
103 | * event Licensee exports any such software from the United States or |
103 | * event Licensee exports any such software from the United States or |
104 | * re-exports any such software from a foreign destination, Licensee shall |
104 | * re-exports any such software from a foreign destination, Licensee shall |
105 | * ensure that the distribution and export/re-export of the software is in |
105 | * ensure that the distribution and export/re-export of the software is in |
106 | * compliance with all laws, regulations, orders, or other restrictions of the |
106 | * compliance with all laws, regulations, orders, or other restrictions of the |
107 | * U.S. Export Administration Regulations. Licensee agrees that neither it nor |
107 | * U.S. Export Administration Regulations. Licensee agrees that neither it nor |
108 | * any of its subsidiaries will export/re-export any technical data, process, |
108 | * any of its subsidiaries will export/re-export any technical data, process, |
109 | * software, or service, directly or indirectly, to any country for which the |
109 | * software, or service, directly or indirectly, to any country for which the |
110 | * United States government or any agency thereof requires an export license, |
110 | * United States government or any agency thereof requires an export license, |
111 | * other governmental approval, or letter of assurance, without first obtaining |
111 | * other governmental approval, or letter of assurance, without first obtaining |
112 | * such license, approval or letter. |
112 | * such license, approval or letter. |
113 | * |
113 | * |
114 | *****************************************************************************/ |
114 | *****************************************************************************/ |
115 | 115 | ||
116 | /* |
116 | /* |
117 | * These procedures are used for tracking memory leaks in the subsystem, and |
117 | * These procedures are used for tracking memory leaks in the subsystem, and |
118 | * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set. |
118 | * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set. |
119 | * |
119 | * |
120 | * Each memory allocation is tracked via a doubly linked list. Each |
120 | * Each memory allocation is tracked via a doubly linked list. Each |
121 | * element contains the caller's component, module name, function name, and |
121 | * element contains the caller's component, module name, function name, and |
122 | * line number. AcpiUtAllocate and AcpiUtAllocateZeroed call |
122 | * line number. AcpiUtAllocate and AcpiUtAllocateZeroed call |
123 | * AcpiUtTrackAllocation to add an element to the list; deletion |
123 | * AcpiUtTrackAllocation to add an element to the list; deletion |
124 | * occurs in the body of AcpiUtFree. |
124 | * occurs in the body of AcpiUtFree. |
125 | */ |
125 | */ |
126 | 126 | ||
127 | #define __UTTRACK_C__ |
127 | #define __UTTRACK_C__ |
128 | 128 | ||
129 | #include "acpi.h" |
129 | #include "acpi.h" |
130 | #include "accommon.h" |
130 | #include "accommon.h" |
131 | 131 | ||
132 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS |
132 | #ifdef ACPI_DBG_TRACK_ALLOCATIONS |
133 | 133 | ||
134 | #define _COMPONENT ACPI_UTILITIES |
134 | #define _COMPONENT ACPI_UTILITIES |
135 | ACPI_MODULE_NAME ("uttrack") |
135 | ACPI_MODULE_NAME ("uttrack") |
136 | 136 | ||
137 | /* Local prototypes */ |
137 | /* Local prototypes */ |
138 | 138 | ||
139 | static ACPI_DEBUG_MEM_BLOCK * |
139 | static ACPI_DEBUG_MEM_BLOCK * |
140 | AcpiUtFindAllocation ( |
140 | AcpiUtFindAllocation ( |
141 | void *Allocation); |
141 | void *Allocation); |
142 | 142 | ||
143 | static ACPI_STATUS |
143 | static ACPI_STATUS |
144 | AcpiUtTrackAllocation ( |
144 | AcpiUtTrackAllocation ( |
145 | ACPI_DEBUG_MEM_BLOCK *Address, |
145 | ACPI_DEBUG_MEM_BLOCK *Address, |
146 | ACPI_SIZE Size, |
146 | ACPI_SIZE Size, |
147 | UINT8 AllocType, |
147 | UINT8 AllocType, |
148 | UINT32 Component, |
148 | UINT32 Component, |
149 | const char *Module, |
149 | const char *Module, |
150 | UINT32 Line); |
150 | UINT32 Line); |
151 | 151 | ||
152 | static ACPI_STATUS |
152 | static ACPI_STATUS |
153 | AcpiUtRemoveAllocation ( |
153 | AcpiUtRemoveAllocation ( |
154 | ACPI_DEBUG_MEM_BLOCK *Address, |
154 | ACPI_DEBUG_MEM_BLOCK *Address, |
155 | UINT32 Component, |
155 | UINT32 Component, |
156 | const char *Module, |
156 | const char *Module, |
157 | UINT32 Line); |
157 | UINT32 Line); |
158 | 158 | ||
159 | 159 | ||
160 | /******************************************************************************* |
160 | /******************************************************************************* |
161 | * |
161 | * |
162 | * FUNCTION: AcpiUtCreateList |
162 | * FUNCTION: AcpiUtCreateList |
163 | * |
163 | * |
164 | * PARAMETERS: CacheName - Ascii name for the cache |
164 | * PARAMETERS: CacheName - Ascii name for the cache |
165 | * ObjectSize - Size of each cached object |
165 | * ObjectSize - Size of each cached object |
166 | * ReturnCache - Where the new cache object is returned |
166 | * ReturnCache - Where the new cache object is returned |
167 | * |
167 | * |
168 | * RETURN: Status |
168 | * RETURN: Status |
169 | * |
169 | * |
170 | * DESCRIPTION: Create a local memory list for tracking purposed |
170 | * DESCRIPTION: Create a local memory list for tracking purposed |
171 | * |
171 | * |
172 | ******************************************************************************/ |
172 | ******************************************************************************/ |
173 | 173 | ||
174 | ACPI_STATUS |
174 | ACPI_STATUS |
175 | AcpiUtCreateList ( |
175 | AcpiUtCreateList ( |
176 | char *ListName, |
176 | char *ListName, |
177 | UINT16 ObjectSize, |
177 | UINT16 ObjectSize, |
178 | ACPI_MEMORY_LIST **ReturnCache) |
178 | ACPI_MEMORY_LIST **ReturnCache) |
179 | { |
179 | { |
180 | ACPI_MEMORY_LIST *Cache; |
180 | ACPI_MEMORY_LIST *Cache; |
181 | 181 | ||
182 | 182 | ||
183 | Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST)); |
183 | Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST)); |
184 | if (!Cache) |
184 | if (!Cache) |
185 | { |
185 | { |
186 | return (AE_NO_MEMORY); |
186 | return (AE_NO_MEMORY); |
187 | } |
187 | } |
188 | 188 | ||
189 | ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST)); |
189 | ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST)); |
190 | 190 | ||
191 | Cache->ListName = ListName; |
191 | Cache->ListName = ListName; |
192 | Cache->ObjectSize = ObjectSize; |
192 | Cache->ObjectSize = ObjectSize; |
193 | 193 | ||
194 | *ReturnCache = Cache; |
194 | *ReturnCache = Cache; |
195 | return (AE_OK); |
195 | return (AE_OK); |
196 | } |
196 | } |
197 | 197 | ||
198 | 198 | ||
199 | /******************************************************************************* |
199 | /******************************************************************************* |
200 | * |
200 | * |
201 | * FUNCTION: AcpiUtAllocateAndTrack |
201 | * FUNCTION: AcpiUtAllocateAndTrack |
202 | * |
202 | * |
203 | * PARAMETERS: Size - Size of the allocation |
203 | * PARAMETERS: Size - Size of the allocation |
204 | * Component - Component type of caller |
204 | * Component - Component type of caller |
205 | * Module - Source file name of caller |
205 | * Module - Source file name of caller |
206 | * Line - Line number of caller |
206 | * Line - Line number of caller |
207 | * |
207 | * |
208 | * RETURN: Address of the allocated memory on success, NULL on failure. |
208 | * RETURN: Address of the allocated memory on success, NULL on failure. |
209 | * |
209 | * |
210 | * DESCRIPTION: The subsystem's equivalent of malloc. |
210 | * DESCRIPTION: The subsystem's equivalent of malloc. |
211 | * |
211 | * |
212 | ******************************************************************************/ |
212 | ******************************************************************************/ |
213 | 213 | ||
214 | void * |
214 | void * |
215 | AcpiUtAllocateAndTrack ( |
215 | AcpiUtAllocateAndTrack ( |
216 | ACPI_SIZE Size, |
216 | ACPI_SIZE Size, |
217 | UINT32 Component, |
217 | UINT32 Component, |
218 | const char *Module, |
218 | const char *Module, |
219 | UINT32 Line) |
219 | UINT32 Line) |
220 | { |
220 | { |
221 | ACPI_DEBUG_MEM_BLOCK *Allocation; |
221 | ACPI_DEBUG_MEM_BLOCK *Allocation; |
222 | ACPI_STATUS Status; |
222 | ACPI_STATUS Status; |
223 | 223 | ||
224 | 224 | ||
225 | Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER), |
225 | Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER), |
226 | Component, Module, Line); |
226 | Component, Module, Line); |
227 | if (!Allocation) |
227 | if (!Allocation) |
228 | { |
228 | { |
229 | return (NULL); |
229 | return (NULL); |
230 | } |
230 | } |
231 | 231 | ||
232 | Status = AcpiUtTrackAllocation (Allocation, Size, |
232 | Status = AcpiUtTrackAllocation (Allocation, Size, |
233 | ACPI_MEM_MALLOC, Component, Module, Line); |
233 | ACPI_MEM_MALLOC, Component, Module, Line); |
234 | if (ACPI_FAILURE (Status)) |
234 | if (ACPI_FAILURE (Status)) |
235 | { |
235 | { |
236 | AcpiOsFree (Allocation); |
236 | AcpiOsFree (Allocation); |
237 | return (NULL); |
237 | return (NULL); |
238 | } |
238 | } |
239 | 239 | ||
240 | AcpiGbl_GlobalList->TotalAllocated++; |
240 | AcpiGbl_GlobalList->TotalAllocated++; |
241 | AcpiGbl_GlobalList->TotalSize += (UINT32) Size; |
241 | AcpiGbl_GlobalList->TotalSize += (UINT32) Size; |
242 | AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size; |
242 | AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size; |
243 | if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied) |
243 | if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied) |
244 | { |
244 | { |
245 | AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize; |
245 | AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize; |
246 | } |
246 | } |
247 | 247 | ||
248 | return ((void *) &Allocation->UserSpace); |
248 | return ((void *) &Allocation->UserSpace); |
249 | } |
249 | } |
250 | 250 | ||
251 | 251 | ||
252 | /******************************************************************************* |
252 | /******************************************************************************* |
253 | * |
253 | * |
254 | * FUNCTION: AcpiUtAllocateZeroedAndTrack |
254 | * FUNCTION: AcpiUtAllocateZeroedAndTrack |
255 | * |
255 | * |
256 | * PARAMETERS: Size - Size of the allocation |
256 | * PARAMETERS: Size - Size of the allocation |
257 | * Component - Component type of caller |
257 | * Component - Component type of caller |
258 | * Module - Source file name of caller |
258 | * Module - Source file name of caller |
259 | * Line - Line number of caller |
259 | * Line - Line number of caller |
260 | * |
260 | * |
261 | * RETURN: Address of the allocated memory on success, NULL on failure. |
261 | * RETURN: Address of the allocated memory on success, NULL on failure. |
262 | * |
262 | * |
263 | * DESCRIPTION: Subsystem equivalent of calloc. |
263 | * DESCRIPTION: Subsystem equivalent of calloc. |
264 | * |
264 | * |
265 | ******************************************************************************/ |
265 | ******************************************************************************/ |
266 | 266 | ||
267 | void * |
267 | void * |
268 | AcpiUtAllocateZeroedAndTrack ( |
268 | AcpiUtAllocateZeroedAndTrack ( |
269 | ACPI_SIZE Size, |
269 | ACPI_SIZE Size, |
270 | UINT32 Component, |
270 | UINT32 Component, |
271 | const char *Module, |
271 | const char *Module, |
272 | UINT32 Line) |
272 | UINT32 Line) |
273 | { |
273 | { |
274 | ACPI_DEBUG_MEM_BLOCK *Allocation; |
274 | ACPI_DEBUG_MEM_BLOCK *Allocation; |
275 | ACPI_STATUS Status; |
275 | ACPI_STATUS Status; |
276 | 276 | ||
277 | 277 | ||
278 | Allocation = AcpiUtAllocateZeroed (Size + sizeof (ACPI_DEBUG_MEM_HEADER), |
278 | Allocation = AcpiUtAllocateZeroed (Size + sizeof (ACPI_DEBUG_MEM_HEADER), |
279 | Component, Module, Line); |
279 | Component, Module, Line); |
280 | if (!Allocation) |
280 | if (!Allocation) |
281 | { |
281 | { |
282 | /* Report allocation error */ |
282 | /* Report allocation error */ |
283 | 283 | ||
284 | ACPI_ERROR ((Module, Line, |
284 | ACPI_ERROR ((Module, Line, |
285 | "Could not allocate size %u", (UINT32) Size)); |
285 | "Could not allocate size %u", (UINT32) Size)); |
286 | return (NULL); |
286 | return (NULL); |
287 | } |
287 | } |
288 | 288 | ||
289 | Status = AcpiUtTrackAllocation (Allocation, Size, |
289 | Status = AcpiUtTrackAllocation (Allocation, Size, |
290 | ACPI_MEM_CALLOC, Component, Module, Line); |
290 | ACPI_MEM_CALLOC, Component, Module, Line); |
291 | if (ACPI_FAILURE (Status)) |
291 | if (ACPI_FAILURE (Status)) |
292 | { |
292 | { |
293 | AcpiOsFree (Allocation); |
293 | AcpiOsFree (Allocation); |
294 | return (NULL); |
294 | return (NULL); |
295 | } |
295 | } |
296 | 296 | ||
297 | AcpiGbl_GlobalList->TotalAllocated++; |
297 | AcpiGbl_GlobalList->TotalAllocated++; |
298 | AcpiGbl_GlobalList->TotalSize += (UINT32) Size; |
298 | AcpiGbl_GlobalList->TotalSize += (UINT32) Size; |
299 | AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size; |
299 | AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size; |
300 | if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied) |
300 | if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied) |
301 | { |
301 | { |
302 | AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize; |
302 | AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize; |
303 | } |
303 | } |
304 | 304 | ||
305 | return ((void *) &Allocation->UserSpace); |
305 | return ((void *) &Allocation->UserSpace); |
306 | } |
306 | } |
307 | 307 | ||
308 | 308 | ||
309 | /******************************************************************************* |
309 | /******************************************************************************* |
310 | * |
310 | * |
311 | * FUNCTION: AcpiUtFreeAndTrack |
311 | * FUNCTION: AcpiUtFreeAndTrack |
312 | * |
312 | * |
313 | * PARAMETERS: Allocation - Address of the memory to deallocate |
313 | * PARAMETERS: Allocation - Address of the memory to deallocate |
314 | * Component - Component type of caller |
314 | * Component - Component type of caller |
315 | * Module - Source file name of caller |
315 | * Module - Source file name of caller |
316 | * Line - Line number of caller |
316 | * Line - Line number of caller |
317 | * |
317 | * |
318 | * RETURN: None |
318 | * RETURN: None |
319 | * |
319 | * |
320 | * DESCRIPTION: Frees the memory at Allocation |
320 | * DESCRIPTION: Frees the memory at Allocation |
321 | * |
321 | * |
322 | ******************************************************************************/ |
322 | ******************************************************************************/ |
323 | 323 | ||
324 | void |
324 | void |
325 | AcpiUtFreeAndTrack ( |
325 | AcpiUtFreeAndTrack ( |
326 | void *Allocation, |
326 | void *Allocation, |
327 | UINT32 Component, |
327 | UINT32 Component, |
328 | const char *Module, |
328 | const char *Module, |
329 | UINT32 Line) |
329 | UINT32 Line) |
330 | { |
330 | { |
331 | ACPI_DEBUG_MEM_BLOCK *DebugBlock; |
331 | ACPI_DEBUG_MEM_BLOCK *DebugBlock; |
332 | ACPI_STATUS Status; |
332 | ACPI_STATUS Status; |
333 | 333 | ||
334 | 334 | ||
335 | ACPI_FUNCTION_TRACE_PTR (UtFree, Allocation); |
335 | ACPI_FUNCTION_TRACE_PTR (UtFree, Allocation); |
336 | 336 | ||
337 | 337 | ||
338 | if (NULL == Allocation) |
338 | if (NULL == Allocation) |
339 | { |
339 | { |
340 | ACPI_ERROR ((Module, Line, |
340 | ACPI_ERROR ((Module, Line, |
341 | "Attempt to delete a NULL address")); |
341 | "Attempt to delete a NULL address")); |
342 | 342 | ||
343 | return_VOID; |
343 | return_VOID; |
344 | } |
344 | } |
345 | 345 | ||
346 | DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK, |
346 | DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK, |
347 | (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER))); |
347 | (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER))); |
348 | 348 | ||
349 | AcpiGbl_GlobalList->TotalFreed++; |
349 | AcpiGbl_GlobalList->TotalFreed++; |
350 | AcpiGbl_GlobalList->CurrentTotalSize -= DebugBlock->Size; |
350 | AcpiGbl_GlobalList->CurrentTotalSize -= DebugBlock->Size; |
351 | 351 | ||
352 | Status = AcpiUtRemoveAllocation (DebugBlock, |
352 | Status = AcpiUtRemoveAllocation (DebugBlock, |
353 | Component, Module, Line); |
353 | Component, Module, Line); |
354 | if (ACPI_FAILURE (Status)) |
354 | if (ACPI_FAILURE (Status)) |
355 | { |
355 | { |
356 | ACPI_EXCEPTION ((AE_INFO, Status, "Could not free memory")); |
356 | ACPI_EXCEPTION ((AE_INFO, Status, "Could not free memory")); |
357 | } |
357 | } |
358 | 358 | ||
359 | AcpiOsFree (DebugBlock); |
359 | AcpiOsFree (DebugBlock); |
360 | ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation)); |
360 | ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation)); |
361 | return_VOID; |
361 | return_VOID; |
362 | } |
362 | } |
363 | 363 | ||
364 | 364 | ||
365 | /******************************************************************************* |
365 | /******************************************************************************* |
366 | * |
366 | * |
367 | * FUNCTION: AcpiUtFindAllocation |
367 | * FUNCTION: AcpiUtFindAllocation |
368 | * |
368 | * |
369 | * PARAMETERS: Allocation - Address of allocated memory |
369 | * PARAMETERS: Allocation - Address of allocated memory |
370 | * |
370 | * |
371 | * RETURN: A list element if found; NULL otherwise. |
371 | * RETURN: A list element if found; NULL otherwise. |
372 | * |
372 | * |
373 | * DESCRIPTION: Searches for an element in the global allocation tracking list. |
373 | * DESCRIPTION: Searches for an element in the global allocation tracking list. |
374 | * |
374 | * |
375 | ******************************************************************************/ |
375 | ******************************************************************************/ |
376 | 376 | ||
377 | static ACPI_DEBUG_MEM_BLOCK * |
377 | static ACPI_DEBUG_MEM_BLOCK * |
378 | AcpiUtFindAllocation ( |
378 | AcpiUtFindAllocation ( |
379 | void *Allocation) |
379 | void *Allocation) |
380 | { |
380 | { |
381 | ACPI_DEBUG_MEM_BLOCK *Element; |
381 | ACPI_DEBUG_MEM_BLOCK *Element; |
382 | 382 | ||
383 | 383 | ||
384 | ACPI_FUNCTION_ENTRY (); |
384 | ACPI_FUNCTION_ENTRY (); |
385 | 385 | ||
386 | 386 | ||
387 | Element = AcpiGbl_GlobalList->ListHead; |
387 | Element = AcpiGbl_GlobalList->ListHead; |
388 | 388 | ||
389 | /* Search for the address. */ |
389 | /* Search for the address. */ |
390 | 390 | ||
391 | while (Element) |
391 | while (Element) |
392 | { |
392 | { |
393 | if (Element == Allocation) |
393 | if (Element == Allocation) |
394 | { |
394 | { |
395 | return (Element); |
395 | return (Element); |
396 | } |
396 | } |
397 | 397 | ||
398 | Element = Element->Next; |
398 | Element = Element->Next; |
399 | } |
399 | } |
400 | 400 | ||
401 | return (NULL); |
401 | return (NULL); |
402 | } |
402 | } |
403 | 403 | ||
404 | 404 | ||
405 | /******************************************************************************* |
405 | /******************************************************************************* |
406 | * |
406 | * |
407 | * FUNCTION: AcpiUtTrackAllocation |
407 | * FUNCTION: AcpiUtTrackAllocation |
408 | * |
408 | * |
409 | * PARAMETERS: Allocation - Address of allocated memory |
409 | * PARAMETERS: Allocation - Address of allocated memory |
410 | * Size - Size of the allocation |
410 | * Size - Size of the allocation |
411 | * AllocType - MEM_MALLOC or MEM_CALLOC |
411 | * AllocType - MEM_MALLOC or MEM_CALLOC |
412 | * Component - Component type of caller |
412 | * Component - Component type of caller |
413 | * Module - Source file name of caller |
413 | * Module - Source file name of caller |
414 | * Line - Line number of caller |
414 | * Line - Line number of caller |
415 | * |
415 | * |
416 | * RETURN: None. |
416 | * RETURN: None. |
417 | * |
417 | * |
418 | * DESCRIPTION: Inserts an element into the global allocation tracking list. |
418 | * DESCRIPTION: Inserts an element into the global allocation tracking list. |
419 | * |
419 | * |
420 | ******************************************************************************/ |
420 | ******************************************************************************/ |
421 | 421 | ||
422 | static ACPI_STATUS |
422 | static ACPI_STATUS |
423 | AcpiUtTrackAllocation ( |
423 | AcpiUtTrackAllocation ( |
424 | ACPI_DEBUG_MEM_BLOCK *Allocation, |
424 | ACPI_DEBUG_MEM_BLOCK *Allocation, |
425 | ACPI_SIZE Size, |
425 | ACPI_SIZE Size, |
426 | UINT8 AllocType, |
426 | UINT8 AllocType, |
427 | UINT32 Component, |
427 | UINT32 Component, |
428 | const char *Module, |
428 | const char *Module, |
429 | UINT32 Line) |
429 | UINT32 Line) |
430 | { |
430 | { |
431 | ACPI_MEMORY_LIST *MemList; |
431 | ACPI_MEMORY_LIST *MemList; |
432 | ACPI_DEBUG_MEM_BLOCK *Element; |
432 | ACPI_DEBUG_MEM_BLOCK *Element; |
433 | ACPI_STATUS Status = AE_OK; |
433 | ACPI_STATUS Status = AE_OK; |
434 | 434 | ||
435 | 435 | ||
436 | ACPI_FUNCTION_TRACE_PTR (UtTrackAllocation, Allocation); |
436 | ACPI_FUNCTION_TRACE_PTR (UtTrackAllocation, Allocation); |
437 | 437 | ||
438 | 438 | ||
439 | if (AcpiGbl_DisableMemTracking) |
439 | if (AcpiGbl_DisableMemTracking) |
440 | { |
440 | { |
441 | return_ACPI_STATUS (AE_OK); |
441 | return_ACPI_STATUS (AE_OK); |
442 | } |
442 | } |
443 | 443 | ||
444 | MemList = AcpiGbl_GlobalList; |
444 | MemList = AcpiGbl_GlobalList; |
445 | Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY); |
445 | Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY); |
446 | if (ACPI_FAILURE (Status)) |
446 | if (ACPI_FAILURE (Status)) |
447 | { |
447 | { |
448 | return_ACPI_STATUS (Status); |
448 | return_ACPI_STATUS (Status); |
449 | } |
449 | } |
450 | 450 | ||
451 | /* |
451 | /* |
452 | * Search list for this address to make sure it is not already on the list. |
452 | * Search list for this address to make sure it is not already on the list. |
453 | * This will catch several kinds of problems. |
453 | * This will catch several kinds of problems. |
454 | */ |
454 | */ |
455 | Element = AcpiUtFindAllocation (Allocation); |
455 | Element = AcpiUtFindAllocation (Allocation); |
456 | if (Element) |
456 | if (Element) |
457 | { |
457 | { |
458 | ACPI_ERROR ((AE_INFO, |
458 | ACPI_ERROR ((AE_INFO, |
459 | "UtTrackAllocation: Allocation already present in list! (%p)", |
459 | "UtTrackAllocation: Allocation already present in list! (%p)", |
460 | Allocation)); |
460 | Allocation)); |
461 | 461 | ||
462 | ACPI_ERROR ((AE_INFO, "Element %p Address %p", |
462 | ACPI_ERROR ((AE_INFO, "Element %p Address %p", |
463 | Element, Allocation)); |
463 | Element, Allocation)); |
464 | 464 | ||
465 | goto UnlockAndExit; |
465 | goto UnlockAndExit; |
466 | } |
466 | } |
467 | 467 | ||
468 | /* Fill in the instance data. */ |
468 | /* Fill in the instance data. */ |
469 | 469 | ||
470 | Allocation->Size = (UINT32) Size; |
470 | Allocation->Size = (UINT32) Size; |
471 | Allocation->AllocType = AllocType; |
471 | Allocation->AllocType = AllocType; |
472 | Allocation->Component = Component; |
472 | Allocation->Component = Component; |
473 | Allocation->Line = Line; |
473 | Allocation->Line = Line; |
474 | 474 | ||
475 | ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME); |
475 | ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME); |
476 | Allocation->Module[ACPI_MAX_MODULE_NAME-1] = 0; |
476 | Allocation->Module[ACPI_MAX_MODULE_NAME-1] = 0; |
477 | 477 | ||
478 | /* Insert at list head */ |
478 | /* Insert at list head */ |
479 | 479 | ||
480 | if (MemList->ListHead) |
480 | if (MemList->ListHead) |
481 | { |
481 | { |
482 | ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation; |
482 | ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation; |
483 | } |
483 | } |
484 | 484 | ||
485 | Allocation->Next = MemList->ListHead; |
485 | Allocation->Next = MemList->ListHead; |
486 | Allocation->Previous = NULL; |
486 | Allocation->Previous = NULL; |
487 | 487 | ||
488 | MemList->ListHead = Allocation; |
488 | MemList->ListHead = Allocation; |
489 | 489 | ||
490 | 490 | ||
491 | UnlockAndExit: |
491 | UnlockAndExit: |
492 | Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY); |
492 | Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY); |
493 | return_ACPI_STATUS (Status); |
493 | return_ACPI_STATUS (Status); |
494 | } |
494 | } |
495 | 495 | ||
496 | 496 | ||
497 | /******************************************************************************* |
497 | /******************************************************************************* |
498 | * |
498 | * |
499 | * FUNCTION: AcpiUtRemoveAllocation |
499 | * FUNCTION: AcpiUtRemoveAllocation |
500 | * |
500 | * |
501 | * PARAMETERS: Allocation - Address of allocated memory |
501 | * PARAMETERS: Allocation - Address of allocated memory |
502 | * Component - Component type of caller |
502 | * Component - Component type of caller |
503 | * Module - Source file name of caller |
503 | * Module - Source file name of caller |
504 | * Line - Line number of caller |
504 | * Line - Line number of caller |
505 | * |
505 | * |
506 | * RETURN: |
506 | * RETURN: |
507 | * |
507 | * |
508 | * DESCRIPTION: Deletes an element from the global allocation tracking list. |
508 | * DESCRIPTION: Deletes an element from the global allocation tracking list. |
509 | * |
509 | * |
510 | ******************************************************************************/ |
510 | ******************************************************************************/ |
511 | 511 | ||
512 | static ACPI_STATUS |
512 | static ACPI_STATUS |
513 | AcpiUtRemoveAllocation ( |
513 | AcpiUtRemoveAllocation ( |
514 | ACPI_DEBUG_MEM_BLOCK *Allocation, |
514 | ACPI_DEBUG_MEM_BLOCK *Allocation, |
515 | UINT32 Component, |
515 | UINT32 Component, |
516 | const char *Module, |
516 | const char *Module, |
517 | UINT32 Line) |
517 | UINT32 Line) |
518 | { |
518 | { |
519 | ACPI_MEMORY_LIST *MemList; |
519 | ACPI_MEMORY_LIST *MemList; |
520 | ACPI_STATUS Status; |
520 | ACPI_STATUS Status; |
521 | 521 | ||
522 | 522 | ||
523 | ACPI_FUNCTION_TRACE (UtRemoveAllocation); |
523 | ACPI_FUNCTION_TRACE (UtRemoveAllocation); |
524 | 524 | ||
525 | 525 | ||
526 | if (AcpiGbl_DisableMemTracking) |
526 | if (AcpiGbl_DisableMemTracking) |
527 | { |
527 | { |
528 | return_ACPI_STATUS (AE_OK); |
528 | return_ACPI_STATUS (AE_OK); |
529 | } |
529 | } |
530 | 530 | ||
531 | MemList = AcpiGbl_GlobalList; |
531 | MemList = AcpiGbl_GlobalList; |
532 | if (NULL == MemList->ListHead) |
532 | if (NULL == MemList->ListHead) |
533 | { |
533 | { |
534 | /* No allocations! */ |
534 | /* No allocations! */ |
535 | 535 | ||
536 | ACPI_ERROR ((Module, Line, |
536 | ACPI_ERROR ((Module, Line, |
537 | "Empty allocation list, nothing to free!")); |
537 | "Empty allocation list, nothing to free!")); |
538 | 538 | ||
539 | return_ACPI_STATUS (AE_OK); |
539 | return_ACPI_STATUS (AE_OK); |
540 | } |
540 | } |
541 | 541 | ||
542 | Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY); |
542 | Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY); |
543 | if (ACPI_FAILURE (Status)) |
543 | if (ACPI_FAILURE (Status)) |
544 | { |
544 | { |
545 | return_ACPI_STATUS (Status); |
545 | return_ACPI_STATUS (Status); |
546 | } |
546 | } |
547 | 547 | ||
548 | /* Unlink */ |
548 | /* Unlink */ |
549 | 549 | ||
550 | if (Allocation->Previous) |
550 | if (Allocation->Previous) |
551 | { |
551 | { |
552 | (Allocation->Previous)->Next = Allocation->Next; |
552 | (Allocation->Previous)->Next = Allocation->Next; |
553 | } |
553 | } |
554 | else |
554 | else |
555 | { |
555 | { |
556 | MemList->ListHead = Allocation->Next; |
556 | MemList->ListHead = Allocation->Next; |
557 | } |
557 | } |
558 | 558 | ||
559 | if (Allocation->Next) |
559 | if (Allocation->Next) |
560 | { |
560 | { |
561 | (Allocation->Next)->Previous = Allocation->Previous; |
561 | (Allocation->Next)->Previous = Allocation->Previous; |
562 | } |
562 | } |
563 | 563 | ||
564 | /* Mark the segment as deleted */ |
564 | /* Mark the segment as deleted */ |
565 | 565 | ||
566 | ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size); |
566 | ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size); |
567 | 567 | ||
568 | ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", |
568 | ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", |
569 | Allocation->Size)); |
569 | Allocation->Size)); |
570 | 570 | ||
571 | Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY); |
571 | Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY); |
572 | return_ACPI_STATUS (Status); |
572 | return_ACPI_STATUS (Status); |
573 | } |
573 | } |
574 | 574 | ||
575 | 575 | ||
576 | /******************************************************************************* |
576 | /******************************************************************************* |
577 | * |
577 | * |
578 | * FUNCTION: AcpiUtDumpAllocationInfo |
578 | * FUNCTION: AcpiUtDumpAllocationInfo |
579 | * |
579 | * |
580 | * PARAMETERS: |
580 | * PARAMETERS: |
581 | * |
581 | * |
582 | * RETURN: None |
582 | * RETURN: None |
583 | * |
583 | * |
584 | * DESCRIPTION: Print some info about the outstanding allocations. |
584 | * DESCRIPTION: Print some info about the outstanding allocations. |
585 | * |
585 | * |
586 | ******************************************************************************/ |
586 | ******************************************************************************/ |
587 | 587 | ||
588 | void |
588 | void |
589 | AcpiUtDumpAllocationInfo ( |
589 | AcpiUtDumpAllocationInfo ( |
590 | void) |
590 | void) |
591 | { |
591 | { |
592 | /* |
592 | /* |
593 | ACPI_MEMORY_LIST *MemList; |
593 | ACPI_MEMORY_LIST *MemList; |
594 | */ |
594 | */ |
595 | 595 | ||
596 | ACPI_FUNCTION_TRACE (UtDumpAllocationInfo); |
596 | ACPI_FUNCTION_TRACE (UtDumpAllocationInfo); |
597 | 597 | ||
598 | /* |
598 | /* |
599 | ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, |
599 | ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, |
600 | ("%30s: %4d (%3d Kb)\n", "Current allocations", |
600 | ("%30s: %4d (%3d Kb)\n", "Current allocations", |
601 | MemList->CurrentCount, |
601 | MemList->CurrentCount, |
602 | ROUND_UP_TO_1K (MemList->CurrentSize))); |
602 | ROUND_UP_TO_1K (MemList->CurrentSize))); |
603 | 603 | ||
604 | ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, |
604 | ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, |
605 | ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations", |
605 | ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations", |
606 | MemList->MaxConcurrentCount, |
606 | MemList->MaxConcurrentCount, |
607 | ROUND_UP_TO_1K (MemList->MaxConcurrentSize))); |
607 | ROUND_UP_TO_1K (MemList->MaxConcurrentSize))); |
608 | 608 | ||
609 | 609 | ||
610 | ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, |
610 | ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, |
611 | ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects", |
611 | ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects", |
612 | RunningObjectCount, |
612 | RunningObjectCount, |
613 | ROUND_UP_TO_1K (RunningObjectSize))); |
613 | ROUND_UP_TO_1K (RunningObjectSize))); |
614 | 614 | ||
615 | ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, |
615 | ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, |
616 | ("%30s: %4d (%3d Kb)\n", "Total (all) allocations", |
616 | ("%30s: %4d (%3d Kb)\n", "Total (all) allocations", |
617 | RunningAllocCount, |
617 | RunningAllocCount, |
618 | ROUND_UP_TO_1K (RunningAllocSize))); |
618 | ROUND_UP_TO_1K (RunningAllocSize))); |
619 | 619 | ||
620 | 620 | ||
621 | ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, |
621 | ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, |
622 | ("%30s: %4d (%3d Kb)\n", "Current Nodes", |
622 | ("%30s: %4d (%3d Kb)\n", "Current Nodes", |
623 | AcpiGbl_CurrentNodeCount, |
623 | AcpiGbl_CurrentNodeCount, |
624 | ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize))); |
624 | ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize))); |
625 | 625 | ||
626 | ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, |
626 | ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, |
627 | ("%30s: %4d (%3d Kb)\n", "Max Nodes", |
627 | ("%30s: %4d (%3d Kb)\n", "Max Nodes", |
628 | AcpiGbl_MaxConcurrentNodeCount, |
628 | AcpiGbl_MaxConcurrentNodeCount, |
629 | ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount * |
629 | ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount * |
630 | sizeof (ACPI_NAMESPACE_NODE))))); |
630 | sizeof (ACPI_NAMESPACE_NODE))))); |
631 | */ |
631 | */ |
632 | return_VOID; |
632 | return_VOID; |
633 | } |
633 | } |
634 | 634 | ||
635 | 635 | ||
636 | /******************************************************************************* |
636 | /******************************************************************************* |
637 | * |
637 | * |
638 | * FUNCTION: AcpiUtDumpAllocations |
638 | * FUNCTION: AcpiUtDumpAllocations |
639 | * |
639 | * |
640 | * PARAMETERS: Component - Component(s) to dump info for. |
640 | * PARAMETERS: Component - Component(s) to dump info for. |
641 | * Module - Module to dump info for. NULL means all. |
641 | * Module - Module to dump info for. NULL means all. |
642 | * |
642 | * |
643 | * RETURN: None |
643 | * RETURN: None |
644 | * |
644 | * |
645 | * DESCRIPTION: Print a list of all outstanding allocations. |
645 | * DESCRIPTION: Print a list of all outstanding allocations. |
646 | * |
646 | * |
647 | ******************************************************************************/ |
647 | ******************************************************************************/ |
648 | 648 | ||
649 | void |
649 | void |
650 | AcpiUtDumpAllocations ( |
650 | AcpiUtDumpAllocations ( |
651 | UINT32 Component, |
651 | UINT32 Component, |
652 | const char *Module) |
652 | const char *Module) |
653 | { |
653 | { |
654 | ACPI_DEBUG_MEM_BLOCK *Element; |
654 | ACPI_DEBUG_MEM_BLOCK *Element; |
655 | ACPI_DESCRIPTOR *Descriptor; |
655 | ACPI_DESCRIPTOR *Descriptor; |
656 | UINT32 NumOutstanding = 0; |
656 | UINT32 NumOutstanding = 0; |
657 | UINT8 DescriptorType; |
657 | UINT8 DescriptorType; |
658 | 658 | ||
659 | 659 | ||
660 | ACPI_FUNCTION_TRACE (UtDumpAllocations); |
660 | ACPI_FUNCTION_TRACE (UtDumpAllocations); |
661 | 661 | ||
662 | 662 | ||
663 | if (AcpiGbl_DisableMemTracking) |
663 | if (AcpiGbl_DisableMemTracking) |
664 | { |
664 | { |
665 | return; |
665 | return; |
666 | } |
666 | } |
667 | 667 | ||
668 | /* |
668 | /* |
669 | * Walk the allocation list. |
669 | * Walk the allocation list. |
670 | */ |
670 | */ |
671 | if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY))) |
671 | if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY))) |
672 | { |
672 | { |
673 | return; |
673 | return; |
674 | } |
674 | } |
675 | 675 | ||
676 | Element = AcpiGbl_GlobalList->ListHead; |
676 | Element = AcpiGbl_GlobalList->ListHead; |
677 | while (Element) |
677 | while (Element) |
678 | { |
678 | { |
679 | if ((Element->Component & Component) && |
679 | if ((Element->Component & Component) && |
680 | ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module)))) |
680 | ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module)))) |
681 | { |
681 | { |
682 | Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace); |
682 | Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace); |
683 | 683 | ||
684 | if (Element->Size < sizeof (ACPI_COMMON_DESCRIPTOR)) |
684 | if (Element->Size < sizeof (ACPI_COMMON_DESCRIPTOR)) |
685 | { |
685 | { |
686 | AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u " |
686 | AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u " |
687 | "[Not a Descriptor - too small]\n", |
687 | "[Not a Descriptor - too small]\n", |
688 | Descriptor, Element->Size, Element->Module, |
688 | Descriptor, Element->Size, Element->Module, |
689 | Element->Line); |
689 | Element->Line); |
690 | } |
690 | } |
691 | else |
691 | else |
692 | { |
692 | { |
693 | /* Ignore allocated objects that are in a cache */ |
693 | /* Ignore allocated objects that are in a cache */ |
694 | 694 | ||
695 | if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) != ACPI_DESC_TYPE_CACHED) |
695 | if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) != ACPI_DESC_TYPE_CACHED) |
696 | { |
696 | { |
697 | AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u [%s] ", |
697 | AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u [%s] ", |
698 | Descriptor, Element->Size, Element->Module, |
698 | Descriptor, Element->Size, Element->Module, |
699 | Element->Line, AcpiUtGetDescriptorName (Descriptor)); |
699 | Element->Line, AcpiUtGetDescriptorName (Descriptor)); |
700 | 700 | ||
701 | /* Validate the descriptor type using Type field and length */ |
701 | /* Validate the descriptor type using Type field and length */ |
702 | 702 | ||
703 | DescriptorType = 0; /* Not a valid descriptor type */ |
703 | DescriptorType = 0; /* Not a valid descriptor type */ |
704 | 704 | ||
705 | switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor)) |
705 | switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor)) |
706 | { |
706 | { |
707 | case ACPI_DESC_TYPE_OPERAND: |
707 | case ACPI_DESC_TYPE_OPERAND: |
708 | if (Element->Size == sizeof (ACPI_DESC_TYPE_OPERAND)) |
708 | if (Element->Size == sizeof (ACPI_DESC_TYPE_OPERAND)) |
709 | { |
709 | { |
710 | DescriptorType = ACPI_DESC_TYPE_OPERAND; |
710 | DescriptorType = ACPI_DESC_TYPE_OPERAND; |
711 | } |
711 | } |
712 | break; |
712 | break; |
713 | 713 | ||
714 | case ACPI_DESC_TYPE_PARSER: |
714 | case ACPI_DESC_TYPE_PARSER: |
715 | if (Element->Size == sizeof (ACPI_DESC_TYPE_PARSER)) |
715 | if (Element->Size == sizeof (ACPI_DESC_TYPE_PARSER)) |
716 | { |
716 | { |
717 | DescriptorType = ACPI_DESC_TYPE_PARSER; |
717 | DescriptorType = ACPI_DESC_TYPE_PARSER; |
718 | } |
718 | } |
719 | break; |
719 | break; |
720 | 720 | ||
721 | case ACPI_DESC_TYPE_NAMED: |
721 | case ACPI_DESC_TYPE_NAMED: |
722 | if (Element->Size == sizeof (ACPI_DESC_TYPE_NAMED)) |
722 | if (Element->Size == sizeof (ACPI_DESC_TYPE_NAMED)) |
723 | { |
723 | { |
724 | DescriptorType = ACPI_DESC_TYPE_NAMED; |
724 | DescriptorType = ACPI_DESC_TYPE_NAMED; |
725 | } |
725 | } |
726 | break; |
726 | break; |
727 | 727 | ||
728 | default: |
728 | default: |
729 | break; |
729 | break; |
730 | } |
730 | } |
731 | 731 | ||
732 | /* Display additional info for the major descriptor types */ |
732 | /* Display additional info for the major descriptor types */ |
733 | 733 | ||
734 | switch (DescriptorType) |
734 | switch (DescriptorType) |
735 | { |
735 | { |
736 | case ACPI_DESC_TYPE_OPERAND: |
736 | case ACPI_DESC_TYPE_OPERAND: |
737 | AcpiOsPrintf ("%12.12s RefCount 0x%04X\n", |
737 | AcpiOsPrintf ("%12.12s RefCount 0x%04X\n", |
738 | AcpiUtGetTypeName (Descriptor->Object.Common.Type), |
738 | AcpiUtGetTypeName (Descriptor->Object.Common.Type), |
739 | Descriptor->Object.Common.ReferenceCount); |
739 | Descriptor->Object.Common.ReferenceCount); |
740 | break; |
740 | break; |
741 | 741 | ||
742 | case ACPI_DESC_TYPE_PARSER: |
742 | case ACPI_DESC_TYPE_PARSER: |
743 | AcpiOsPrintf ("AmlOpcode 0x%04hX\n", |
743 | AcpiOsPrintf ("AmlOpcode 0x%04hX\n", |
744 | Descriptor->Op.Asl.AmlOpcode); |
744 | Descriptor->Op.Asl.AmlOpcode); |
745 | break; |
745 | break; |
746 | 746 | ||
747 | case ACPI_DESC_TYPE_NAMED: |
747 | case ACPI_DESC_TYPE_NAMED: |
748 | AcpiOsPrintf ("%4.4s\n", |
748 | AcpiOsPrintf ("%4.4s\n", |
749 | AcpiUtGetNodeName (&Descriptor->Node)); |
749 | AcpiUtGetNodeName (&Descriptor->Node)); |
750 | break; |
750 | break; |
751 | 751 | ||
752 | default: |
752 | default: |
753 | AcpiOsPrintf ( "\n"); |
753 | AcpiOsPrintf ( "\n"); |
754 | break; |
754 | break; |
755 | } |
755 | } |
756 | } |
756 | } |
757 | } |
757 | } |
758 | 758 | ||
759 | NumOutstanding++; |
759 | NumOutstanding++; |
760 | } |
760 | } |
761 | 761 | ||
762 | Element = Element->Next; |
762 | Element = Element->Next; |
763 | } |
763 | } |
764 | 764 | ||
765 | (void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY); |
765 | (void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY); |
766 | 766 | ||
767 | /* Print summary */ |
767 | /* Print summary */ |
768 | 768 | ||
769 | if (!NumOutstanding) |
769 | if (!NumOutstanding) |
770 | { |
770 | { |
771 | ACPI_INFO ((AE_INFO, "No outstanding allocations")); |
771 | ACPI_INFO ((AE_INFO, "No outstanding allocations")); |
772 | } |
772 | } |
773 | else |
773 | else |
774 | { |
774 | { |
775 | ACPI_ERROR ((AE_INFO, "%u(0x%X) Outstanding allocations", |
775 | ACPI_ERROR ((AE_INFO, "%u(0x%X) Outstanding allocations", |
776 | NumOutstanding, NumOutstanding)); |
776 | NumOutstanding, NumOutstanding)); |
777 | } |
777 | } |
778 | 778 | ||
779 | return_VOID; |
779 | return_VOID; |
780 | } |
780 | } |
781 | 781 | ||
782 | #endif /* ACPI_DBG_TRACK_ALLOCATIONS */> |
782 | #endif /* ACPI_DBG_TRACK_ALLOCATIONS */> |