Deleted Added
full compact
utalloc.c (91116) utalloc.c (99679)
1/******************************************************************************
2 *
3 * Module Name: utalloc - local cache and memory allocation routines
1/******************************************************************************
2 *
3 * Module Name: utalloc - local cache and memory allocation routines
4 * $Revision: 121 $
4 * $Revision: 127 $
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
90 *
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
99 *
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117#define __UTALLOC_C__
118
119#include "acpi.h"
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
28 *
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
37 *
38 * The above copyright and patent license is granted only if the following
39 * conditions are met:
40 *
41 * 3. Conditions
42 *
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
54 *
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
65 * make.
66 *
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
71 * distribution.
72 *
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
75 *
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
80 *
81 * 4. Disclaimer and Export Compliance
82 *
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89 * PARTICULAR PURPOSE.
90 *
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98 * LIMITED REMEDY.
99 *
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117#define __UTALLOC_C__
118
119#include "acpi.h"
120#include "acparser.h"
121#include "acinterp.h"
122#include "acnamesp.h"
123#include "acglobal.h"
124
125#define _COMPONENT ACPI_UTILITIES
126 ACPI_MODULE_NAME ("utalloc")
127
128
129/******************************************************************************
130 *
131 * FUNCTION: AcpiUtReleaseToCache
132 *
133 * PARAMETERS: ListId - Memory list/cache ID
134 * Object - The object to be released
135 *
136 * RETURN: None
137 *
138 * DESCRIPTION: Release an object to the specified cache. If cache is full,
139 * the object is deleted.
140 *
141 ******************************************************************************/
142
143void
144AcpiUtReleaseToCache (
145 UINT32 ListId,
146 void *Object)
147{
148 ACPI_MEMORY_LIST *CacheInfo;
149
150
151 ACPI_FUNCTION_ENTRY ();
152
153
154 /* If walk cache is full, just free this wallkstate object */
155
156 CacheInfo = &AcpiGbl_MemoryLists[ListId];
157 if (CacheInfo->CacheDepth >= CacheInfo->MaxCacheDepth)
158 {
159 ACPI_MEM_FREE (Object);
160 ACPI_MEM_TRACKING (CacheInfo->TotalFreed++);
161 }
162
163 /* Otherwise put this object back into the cache */
164
165 else
166 {
167 if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES)))
168 {
169 return;
170 }
171
172 /* Mark the object as cached */
173
174 ACPI_MEMSET (Object, 0xCA, CacheInfo->ObjectSize);
120
121#define _COMPONENT ACPI_UTILITIES
122 ACPI_MODULE_NAME ("utalloc")
123
124
125/******************************************************************************
126 *
127 * FUNCTION: AcpiUtReleaseToCache
128 *
129 * PARAMETERS: ListId - Memory list/cache ID
130 * Object - The object to be released
131 *
132 * RETURN: None
133 *
134 * DESCRIPTION: Release an object to the specified cache. If cache is full,
135 * the object is deleted.
136 *
137 ******************************************************************************/
138
139void
140AcpiUtReleaseToCache (
141 UINT32 ListId,
142 void *Object)
143{
144 ACPI_MEMORY_LIST *CacheInfo;
145
146
147 ACPI_FUNCTION_ENTRY ();
148
149
150 /* If walk cache is full, just free this wallkstate object */
151
152 CacheInfo = &AcpiGbl_MemoryLists[ListId];
153 if (CacheInfo->CacheDepth >= CacheInfo->MaxCacheDepth)
154 {
155 ACPI_MEM_FREE (Object);
156 ACPI_MEM_TRACKING (CacheInfo->TotalFreed++);
157 }
158
159 /* Otherwise put this object back into the cache */
160
161 else
162 {
163 if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES)))
164 {
165 return;
166 }
167
168 /* Mark the object as cached */
169
170 ACPI_MEMSET (Object, 0xCA, CacheInfo->ObjectSize);
175 ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_CACHED_OBJECT);
171 ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_CACHED);
176
177 /* Put the object at the head of the cache list */
178
172
173 /* Put the object at the head of the cache list */
174
179 * (char **) (((char *) Object) + CacheInfo->LinkOffset) = CacheInfo->ListHead;
175 * (ACPI_CAST_INDIRECT_PTR (char, &(((char *) Object)[CacheInfo->LinkOffset]))) = CacheInfo->ListHead;
180 CacheInfo->ListHead = Object;
181 CacheInfo->CacheDepth++;
182
183 (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
184 }
185}
186
187
188/******************************************************************************
189 *
190 * FUNCTION: AcpiUtAcquireFromCache
191 *
192 * PARAMETERS: ListId - Memory list ID
193 *
194 * RETURN: A requested object. NULL if the object could not be
195 * allocated.
196 *
197 * DESCRIPTION: Get an object from the specified cache. If cache is empty,
198 * the object is allocated.
199 *
200 ******************************************************************************/
201
202void *
203AcpiUtAcquireFromCache (
204 UINT32 ListId)
205{
206 ACPI_MEMORY_LIST *CacheInfo;
207 void *Object;
208
209
210 ACPI_FUNCTION_NAME ("UtAcquireFromCache");
211
212
213 CacheInfo = &AcpiGbl_MemoryLists[ListId];
214 if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES)))
215 {
216 return (NULL);
217 }
218
219 ACPI_MEM_TRACKING (CacheInfo->CacheRequests++);
220
221 /* Check the cache first */
222
223 if (CacheInfo->ListHead)
224 {
225 /* There is an object available, use it */
226
227 Object = CacheInfo->ListHead;
176 CacheInfo->ListHead = Object;
177 CacheInfo->CacheDepth++;
178
179 (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
180 }
181}
182
183
184/******************************************************************************
185 *
186 * FUNCTION: AcpiUtAcquireFromCache
187 *
188 * PARAMETERS: ListId - Memory list ID
189 *
190 * RETURN: A requested object. NULL if the object could not be
191 * allocated.
192 *
193 * DESCRIPTION: Get an object from the specified cache. If cache is empty,
194 * the object is allocated.
195 *
196 ******************************************************************************/
197
198void *
199AcpiUtAcquireFromCache (
200 UINT32 ListId)
201{
202 ACPI_MEMORY_LIST *CacheInfo;
203 void *Object;
204
205
206 ACPI_FUNCTION_NAME ("UtAcquireFromCache");
207
208
209 CacheInfo = &AcpiGbl_MemoryLists[ListId];
210 if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES)))
211 {
212 return (NULL);
213 }
214
215 ACPI_MEM_TRACKING (CacheInfo->CacheRequests++);
216
217 /* Check the cache first */
218
219 if (CacheInfo->ListHead)
220 {
221 /* There is an object available, use it */
222
223 Object = CacheInfo->ListHead;
228 CacheInfo->ListHead = * (char **) (((char *) Object) + CacheInfo->LinkOffset);
224 CacheInfo->ListHead = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) Object)[CacheInfo->LinkOffset])));
229
230 ACPI_MEM_TRACKING (CacheInfo->CacheHits++);
231 CacheInfo->CacheDepth--;
232
233#ifdef ACPI_DBG_TRACK_ALLOCATIONS
234 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p from %s\n",
235 Object, AcpiGbl_MemoryLists[ListId].ListName));
236#endif
237
238 if (ACPI_FAILURE (AcpiUtReleaseMutex (ACPI_MTX_CACHES)))
239 {
240 return (NULL);
241 }
242
243 /* Clear (zero) the previously used Object */
244
245 ACPI_MEMSET (Object, 0, CacheInfo->ObjectSize);
246 }
247
248 else
249 {
250 /* The cache is empty, create a new object */
251
252 /* Avoid deadlock with ACPI_MEM_CALLOCATE */
253
254 if (ACPI_FAILURE (AcpiUtReleaseMutex (ACPI_MTX_CACHES)))
255 {
256 return (NULL);
257 }
258
259 Object = ACPI_MEM_CALLOCATE (CacheInfo->ObjectSize);
260 ACPI_MEM_TRACKING (CacheInfo->TotalAllocated++);
261 }
262
263 return (Object);
264}
265
266
267/******************************************************************************
268 *
269 * FUNCTION: AcpiUtDeleteGenericCache
270 *
271 * PARAMETERS: ListId - Memory list ID
272 *
273 * RETURN: None
274 *
275 * DESCRIPTION: Free all objects within the requested cache.
276 *
277 ******************************************************************************/
278
279void
280AcpiUtDeleteGenericCache (
281 UINT32 ListId)
282{
283 ACPI_MEMORY_LIST *CacheInfo;
284 char *Next;
285
286
287 ACPI_FUNCTION_ENTRY ();
288
289
290 CacheInfo = &AcpiGbl_MemoryLists[ListId];
291 while (CacheInfo->ListHead)
292 {
293 /* Delete one cached state object */
294
225
226 ACPI_MEM_TRACKING (CacheInfo->CacheHits++);
227 CacheInfo->CacheDepth--;
228
229#ifdef ACPI_DBG_TRACK_ALLOCATIONS
230 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p from %s\n",
231 Object, AcpiGbl_MemoryLists[ListId].ListName));
232#endif
233
234 if (ACPI_FAILURE (AcpiUtReleaseMutex (ACPI_MTX_CACHES)))
235 {
236 return (NULL);
237 }
238
239 /* Clear (zero) the previously used Object */
240
241 ACPI_MEMSET (Object, 0, CacheInfo->ObjectSize);
242 }
243
244 else
245 {
246 /* The cache is empty, create a new object */
247
248 /* Avoid deadlock with ACPI_MEM_CALLOCATE */
249
250 if (ACPI_FAILURE (AcpiUtReleaseMutex (ACPI_MTX_CACHES)))
251 {
252 return (NULL);
253 }
254
255 Object = ACPI_MEM_CALLOCATE (CacheInfo->ObjectSize);
256 ACPI_MEM_TRACKING (CacheInfo->TotalAllocated++);
257 }
258
259 return (Object);
260}
261
262
263/******************************************************************************
264 *
265 * FUNCTION: AcpiUtDeleteGenericCache
266 *
267 * PARAMETERS: ListId - Memory list ID
268 *
269 * RETURN: None
270 *
271 * DESCRIPTION: Free all objects within the requested cache.
272 *
273 ******************************************************************************/
274
275void
276AcpiUtDeleteGenericCache (
277 UINT32 ListId)
278{
279 ACPI_MEMORY_LIST *CacheInfo;
280 char *Next;
281
282
283 ACPI_FUNCTION_ENTRY ();
284
285
286 CacheInfo = &AcpiGbl_MemoryLists[ListId];
287 while (CacheInfo->ListHead)
288 {
289 /* Delete one cached state object */
290
295 Next = * (char **) (((char *) CacheInfo->ListHead) + CacheInfo->LinkOffset);
291 Next = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) CacheInfo->ListHead)[CacheInfo->LinkOffset])));
296 ACPI_MEM_FREE (CacheInfo->ListHead);
297
298 CacheInfo->ListHead = Next;
299 CacheInfo->CacheDepth--;
300 }
301}
302
303
304/*******************************************************************************
305 *
306 * FUNCTION: AcpiUtValidateBuffer
307 *
308 * PARAMETERS: Buffer - Buffer descriptor to be validated
309 *
310 * RETURN: Status
311 *
312 * DESCRIPTION: Perform parameter validation checks on an ACPI_BUFFER
313 *
314 ******************************************************************************/
315
316ACPI_STATUS
317AcpiUtValidateBuffer (
318 ACPI_BUFFER *Buffer)
319{
320
321 /* Obviously, the structure pointer must be valid */
322
323 if (!Buffer)
324 {
325 return (AE_BAD_PARAMETER);
326 }
327
328 /* Special semantics for the length */
329
330 if ((Buffer->Length == ACPI_NO_BUFFER) ||
331 (Buffer->Length == ACPI_ALLOCATE_BUFFER) ||
332 (Buffer->Length == ACPI_ALLOCATE_LOCAL_BUFFER))
333 {
334 return (AE_OK);
335 }
336
337 /* Length is valid, the buffer pointer must be also */
338
339 if (!Buffer->Pointer)
340 {
341 return (AE_BAD_PARAMETER);
342 }
343
344 return (AE_OK);
345}
346
347
348/*******************************************************************************
349 *
350 * FUNCTION: AcpiUtInitializeBuffer
351 *
352 * PARAMETERS: RequiredLength - Length needed
353 * Buffer - Buffer to be validated
354 *
355 * RETURN: Status
356 *
357 * DESCRIPTION: Validate that the buffer is of the required length or
358 * allocate a new buffer.
359 *
360 ******************************************************************************/
361
362ACPI_STATUS
363AcpiUtInitializeBuffer (
364 ACPI_BUFFER *Buffer,
365 ACPI_SIZE RequiredLength)
366{
367 ACPI_STATUS Status = AE_OK;
368
369
370 switch (Buffer->Length)
371 {
372 case ACPI_NO_BUFFER:
373
374 /* Set the exception and returned the required length */
375
376 Status = AE_BUFFER_OVERFLOW;
377 break;
378
379
380 case ACPI_ALLOCATE_BUFFER:
381
382 /* Allocate a new buffer */
383
384 Buffer->Pointer = AcpiOsAllocate (RequiredLength);
385 if (!Buffer->Pointer)
386 {
387 return (AE_NO_MEMORY);
388 }
389
390 /* Clear the buffer */
391
392 ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
393 break;
394
395
396 case ACPI_ALLOCATE_LOCAL_BUFFER:
397
398 /* Allocate a new buffer with local interface to allow tracking */
399
400 Buffer->Pointer = ACPI_MEM_ALLOCATE (RequiredLength);
401 if (!Buffer->Pointer)
402 {
403 return (AE_NO_MEMORY);
404 }
405
406 /* Clear the buffer */
407
408 ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
409 break;
410
411
412 default:
413
414 /* Validate the size of the buffer */
415
416 if (Buffer->Length < RequiredLength)
417 {
418 Status = AE_BUFFER_OVERFLOW;
419 }
420
421 /* Clear the buffer */
422
423 ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
424 break;
425 }
426
427 Buffer->Length = RequiredLength;
428 return (Status);
429}
430
431
432/*******************************************************************************
433 *
434 * FUNCTION: AcpiUtAllocate
435 *
436 * PARAMETERS: Size - Size of the allocation
437 * Component - Component type of caller
438 * Module - Source file name of caller
439 * Line - Line number of caller
440 *
441 * RETURN: Address of the allocated memory on success, NULL on failure.
442 *
443 * DESCRIPTION: The subsystem's equivalent of malloc.
444 *
445 ******************************************************************************/
446
447void *
448AcpiUtAllocate (
449 ACPI_SIZE Size,
450 UINT32 Component,
451 NATIVE_CHAR *Module,
452 UINT32 Line)
453{
454 void *Allocation;
455
456
457 ACPI_FUNCTION_TRACE_U32 ("UtAllocate", Size);
458
459
460 /* Check for an inadvertent size of zero bytes */
461
462 if (!Size)
463 {
464 _ACPI_REPORT_ERROR (Module, Line, Component,
465 ("UtAllocate: Attempt to allocate zero bytes\n"));
466 Size = 1;
467 }
468
469 Allocation = AcpiOsAllocate (Size);
470 if (!Allocation)
471 {
472 /* Report allocation error */
473
474 _ACPI_REPORT_ERROR (Module, Line, Component,
292 ACPI_MEM_FREE (CacheInfo->ListHead);
293
294 CacheInfo->ListHead = Next;
295 CacheInfo->CacheDepth--;
296 }
297}
298
299
300/*******************************************************************************
301 *
302 * FUNCTION: AcpiUtValidateBuffer
303 *
304 * PARAMETERS: Buffer - Buffer descriptor to be validated
305 *
306 * RETURN: Status
307 *
308 * DESCRIPTION: Perform parameter validation checks on an ACPI_BUFFER
309 *
310 ******************************************************************************/
311
312ACPI_STATUS
313AcpiUtValidateBuffer (
314 ACPI_BUFFER *Buffer)
315{
316
317 /* Obviously, the structure pointer must be valid */
318
319 if (!Buffer)
320 {
321 return (AE_BAD_PARAMETER);
322 }
323
324 /* Special semantics for the length */
325
326 if ((Buffer->Length == ACPI_NO_BUFFER) ||
327 (Buffer->Length == ACPI_ALLOCATE_BUFFER) ||
328 (Buffer->Length == ACPI_ALLOCATE_LOCAL_BUFFER))
329 {
330 return (AE_OK);
331 }
332
333 /* Length is valid, the buffer pointer must be also */
334
335 if (!Buffer->Pointer)
336 {
337 return (AE_BAD_PARAMETER);
338 }
339
340 return (AE_OK);
341}
342
343
344/*******************************************************************************
345 *
346 * FUNCTION: AcpiUtInitializeBuffer
347 *
348 * PARAMETERS: RequiredLength - Length needed
349 * Buffer - Buffer to be validated
350 *
351 * RETURN: Status
352 *
353 * DESCRIPTION: Validate that the buffer is of the required length or
354 * allocate a new buffer.
355 *
356 ******************************************************************************/
357
358ACPI_STATUS
359AcpiUtInitializeBuffer (
360 ACPI_BUFFER *Buffer,
361 ACPI_SIZE RequiredLength)
362{
363 ACPI_STATUS Status = AE_OK;
364
365
366 switch (Buffer->Length)
367 {
368 case ACPI_NO_BUFFER:
369
370 /* Set the exception and returned the required length */
371
372 Status = AE_BUFFER_OVERFLOW;
373 break;
374
375
376 case ACPI_ALLOCATE_BUFFER:
377
378 /* Allocate a new buffer */
379
380 Buffer->Pointer = AcpiOsAllocate (RequiredLength);
381 if (!Buffer->Pointer)
382 {
383 return (AE_NO_MEMORY);
384 }
385
386 /* Clear the buffer */
387
388 ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
389 break;
390
391
392 case ACPI_ALLOCATE_LOCAL_BUFFER:
393
394 /* Allocate a new buffer with local interface to allow tracking */
395
396 Buffer->Pointer = ACPI_MEM_ALLOCATE (RequiredLength);
397 if (!Buffer->Pointer)
398 {
399 return (AE_NO_MEMORY);
400 }
401
402 /* Clear the buffer */
403
404 ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
405 break;
406
407
408 default:
409
410 /* Validate the size of the buffer */
411
412 if (Buffer->Length < RequiredLength)
413 {
414 Status = AE_BUFFER_OVERFLOW;
415 }
416
417 /* Clear the buffer */
418
419 ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
420 break;
421 }
422
423 Buffer->Length = RequiredLength;
424 return (Status);
425}
426
427
428/*******************************************************************************
429 *
430 * FUNCTION: AcpiUtAllocate
431 *
432 * PARAMETERS: Size - Size of the allocation
433 * Component - Component type of caller
434 * Module - Source file name of caller
435 * Line - Line number of caller
436 *
437 * RETURN: Address of the allocated memory on success, NULL on failure.
438 *
439 * DESCRIPTION: The subsystem's equivalent of malloc.
440 *
441 ******************************************************************************/
442
443void *
444AcpiUtAllocate (
445 ACPI_SIZE Size,
446 UINT32 Component,
447 NATIVE_CHAR *Module,
448 UINT32 Line)
449{
450 void *Allocation;
451
452
453 ACPI_FUNCTION_TRACE_U32 ("UtAllocate", Size);
454
455
456 /* Check for an inadvertent size of zero bytes */
457
458 if (!Size)
459 {
460 _ACPI_REPORT_ERROR (Module, Line, Component,
461 ("UtAllocate: Attempt to allocate zero bytes\n"));
462 Size = 1;
463 }
464
465 Allocation = AcpiOsAllocate (Size);
466 if (!Allocation)
467 {
468 /* Report allocation error */
469
470 _ACPI_REPORT_ERROR (Module, Line, Component,
475 ("UtAllocate: Could not allocate size %X\n", Size));
471 ("UtAllocate: Could not allocate size %X\n", (UINT32) Size));
476
477 return_PTR (NULL);
478 }
479
480 return_PTR (Allocation);
481}
482
483
484/*******************************************************************************
485 *
486 * FUNCTION: AcpiUtCallocate
487 *
488 * PARAMETERS: Size - Size of the allocation
489 * Component - Component type of caller
490 * Module - Source file name of caller
491 * Line - Line number of caller
492 *
493 * RETURN: Address of the allocated memory on success, NULL on failure.
494 *
495 * DESCRIPTION: Subsystem equivalent of calloc.
496 *
497 ******************************************************************************/
498
499void *
500AcpiUtCallocate (
501 ACPI_SIZE Size,
502 UINT32 Component,
503 NATIVE_CHAR *Module,
504 UINT32 Line)
505{
506 void *Allocation;
507
508
509 ACPI_FUNCTION_TRACE_U32 ("UtCallocate", Size);
510
511
512 /* Check for an inadvertent size of zero bytes */
513
514 if (!Size)
515 {
516 _ACPI_REPORT_ERROR (Module, Line, Component,
517 ("UtCallocate: Attempt to allocate zero bytes\n"));
518 return_PTR (NULL);
519 }
520
521 Allocation = AcpiOsAllocate (Size);
522 if (!Allocation)
523 {
524 /* Report allocation error */
525
526 _ACPI_REPORT_ERROR (Module, Line, Component,
472
473 return_PTR (NULL);
474 }
475
476 return_PTR (Allocation);
477}
478
479
480/*******************************************************************************
481 *
482 * FUNCTION: AcpiUtCallocate
483 *
484 * PARAMETERS: Size - Size of the allocation
485 * Component - Component type of caller
486 * Module - Source file name of caller
487 * Line - Line number of caller
488 *
489 * RETURN: Address of the allocated memory on success, NULL on failure.
490 *
491 * DESCRIPTION: Subsystem equivalent of calloc.
492 *
493 ******************************************************************************/
494
495void *
496AcpiUtCallocate (
497 ACPI_SIZE Size,
498 UINT32 Component,
499 NATIVE_CHAR *Module,
500 UINT32 Line)
501{
502 void *Allocation;
503
504
505 ACPI_FUNCTION_TRACE_U32 ("UtCallocate", Size);
506
507
508 /* Check for an inadvertent size of zero bytes */
509
510 if (!Size)
511 {
512 _ACPI_REPORT_ERROR (Module, Line, Component,
513 ("UtCallocate: Attempt to allocate zero bytes\n"));
514 return_PTR (NULL);
515 }
516
517 Allocation = AcpiOsAllocate (Size);
518 if (!Allocation)
519 {
520 /* Report allocation error */
521
522 _ACPI_REPORT_ERROR (Module, Line, Component,
527 ("UtCallocate: Could not allocate size %X\n", Size));
523 ("UtCallocate: Could not allocate size %X\n", (UINT32) Size));
528 return_PTR (NULL);
529 }
530
531 /* Clear the memory block */
532
533 ACPI_MEMSET (Allocation, 0, Size);
534 return_PTR (Allocation);
535}
536
537
538#ifdef ACPI_DBG_TRACK_ALLOCATIONS
539/*
540 * These procedures are used for tracking memory leaks in the subsystem, and
541 * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set.
542 *
543 * Each memory allocation is tracked via a doubly linked list. Each
544 * element contains the caller's component, module name, function name, and
545 * line number. AcpiUtAllocate and AcpiUtCallocate call
546 * AcpiUtTrackAllocation to add an element to the list; deletion
547 * occurs in the body of AcpiUtFree.
548 */
549
550
551/*******************************************************************************
552 *
553 * FUNCTION: AcpiUtAllocateAndTrack
554 *
555 * PARAMETERS: Size - Size of the allocation
556 * Component - Component type of caller
557 * Module - Source file name of caller
558 * Line - Line number of caller
559 *
560 * RETURN: Address of the allocated memory on success, NULL on failure.
561 *
562 * DESCRIPTION: The subsystem's equivalent of malloc.
563 *
564 ******************************************************************************/
565
566void *
567AcpiUtAllocateAndTrack (
568 ACPI_SIZE Size,
569 UINT32 Component,
570 NATIVE_CHAR *Module,
571 UINT32 Line)
572{
573 ACPI_DEBUG_MEM_BLOCK *Allocation;
574 ACPI_STATUS Status;
575
576
577 Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_BLOCK), Component,
578 Module, Line);
579 if (!Allocation)
580 {
581 return (NULL);
582 }
583
584 Status = AcpiUtTrackAllocation (ACPI_MEM_LIST_GLOBAL, Allocation, Size,
585 ACPI_MEM_MALLOC, Component, Module, Line);
586 if (ACPI_FAILURE (Status))
587 {
588 AcpiOsFree (Allocation);
589 return (NULL);
590 }
591
592 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalAllocated++;
593 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize += (UINT32) Size;
594
595 return ((void *) &Allocation->UserSpace);
596}
597
598
599/*******************************************************************************
600 *
601 * FUNCTION: AcpiUtCallocateAndTrack
602 *
603 * PARAMETERS: Size - Size of the allocation
604 * Component - Component type of caller
605 * Module - Source file name of caller
606 * Line - Line number of caller
607 *
608 * RETURN: Address of the allocated memory on success, NULL on failure.
609 *
610 * DESCRIPTION: Subsystem equivalent of calloc.
611 *
612 ******************************************************************************/
613
614void *
615AcpiUtCallocateAndTrack (
616 ACPI_SIZE Size,
617 UINT32 Component,
618 NATIVE_CHAR *Module,
619 UINT32 Line)
620{
621 ACPI_DEBUG_MEM_BLOCK *Allocation;
622 ACPI_STATUS Status;
623
624
625 Allocation = AcpiUtCallocate (Size + sizeof (ACPI_DEBUG_MEM_BLOCK), Component,
626 Module, Line);
627 if (!Allocation)
628 {
629 /* Report allocation error */
630
631 _ACPI_REPORT_ERROR (Module, Line, Component,
524 return_PTR (NULL);
525 }
526
527 /* Clear the memory block */
528
529 ACPI_MEMSET (Allocation, 0, Size);
530 return_PTR (Allocation);
531}
532
533
534#ifdef ACPI_DBG_TRACK_ALLOCATIONS
535/*
536 * These procedures are used for tracking memory leaks in the subsystem, and
537 * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set.
538 *
539 * Each memory allocation is tracked via a doubly linked list. Each
540 * element contains the caller's component, module name, function name, and
541 * line number. AcpiUtAllocate and AcpiUtCallocate call
542 * AcpiUtTrackAllocation to add an element to the list; deletion
543 * occurs in the body of AcpiUtFree.
544 */
545
546
547/*******************************************************************************
548 *
549 * FUNCTION: AcpiUtAllocateAndTrack
550 *
551 * PARAMETERS: Size - Size of the allocation
552 * Component - Component type of caller
553 * Module - Source file name of caller
554 * Line - Line number of caller
555 *
556 * RETURN: Address of the allocated memory on success, NULL on failure.
557 *
558 * DESCRIPTION: The subsystem's equivalent of malloc.
559 *
560 ******************************************************************************/
561
562void *
563AcpiUtAllocateAndTrack (
564 ACPI_SIZE Size,
565 UINT32 Component,
566 NATIVE_CHAR *Module,
567 UINT32 Line)
568{
569 ACPI_DEBUG_MEM_BLOCK *Allocation;
570 ACPI_STATUS Status;
571
572
573 Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_BLOCK), Component,
574 Module, Line);
575 if (!Allocation)
576 {
577 return (NULL);
578 }
579
580 Status = AcpiUtTrackAllocation (ACPI_MEM_LIST_GLOBAL, Allocation, Size,
581 ACPI_MEM_MALLOC, Component, Module, Line);
582 if (ACPI_FAILURE (Status))
583 {
584 AcpiOsFree (Allocation);
585 return (NULL);
586 }
587
588 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalAllocated++;
589 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize += (UINT32) Size;
590
591 return ((void *) &Allocation->UserSpace);
592}
593
594
595/*******************************************************************************
596 *
597 * FUNCTION: AcpiUtCallocateAndTrack
598 *
599 * PARAMETERS: Size - Size of the allocation
600 * Component - Component type of caller
601 * Module - Source file name of caller
602 * Line - Line number of caller
603 *
604 * RETURN: Address of the allocated memory on success, NULL on failure.
605 *
606 * DESCRIPTION: Subsystem equivalent of calloc.
607 *
608 ******************************************************************************/
609
610void *
611AcpiUtCallocateAndTrack (
612 ACPI_SIZE Size,
613 UINT32 Component,
614 NATIVE_CHAR *Module,
615 UINT32 Line)
616{
617 ACPI_DEBUG_MEM_BLOCK *Allocation;
618 ACPI_STATUS Status;
619
620
621 Allocation = AcpiUtCallocate (Size + sizeof (ACPI_DEBUG_MEM_BLOCK), Component,
622 Module, Line);
623 if (!Allocation)
624 {
625 /* Report allocation error */
626
627 _ACPI_REPORT_ERROR (Module, Line, Component,
632 ("UtCallocate: Could not allocate size %X\n", Size));
628 ("UtCallocate: Could not allocate size %X\n", (UINT32) Size));
633 return (NULL);
634 }
635
636 Status = AcpiUtTrackAllocation (ACPI_MEM_LIST_GLOBAL, Allocation, Size,
637 ACPI_MEM_CALLOC, Component, Module, Line);
638 if (ACPI_FAILURE (Status))
639 {
640 AcpiOsFree (Allocation);
641 return (NULL);
642 }
643
644 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalAllocated++;
645 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize += (UINT32) Size;
646
647 return ((void *) &Allocation->UserSpace);
648}
649
650
651/*******************************************************************************
652 *
653 * FUNCTION: AcpiUtFreeAndTrack
654 *
655 * PARAMETERS: Allocation - Address of the memory to deallocate
656 * Component - Component type of caller
657 * Module - Source file name of caller
658 * Line - Line number of caller
659 *
660 * RETURN: None
661 *
662 * DESCRIPTION: Frees the memory at Allocation
663 *
664 ******************************************************************************/
665
666void
667AcpiUtFreeAndTrack (
668 void *Allocation,
669 UINT32 Component,
670 NATIVE_CHAR *Module,
671 UINT32 Line)
672{
673 ACPI_DEBUG_MEM_BLOCK *DebugBlock;
629 return (NULL);
630 }
631
632 Status = AcpiUtTrackAllocation (ACPI_MEM_LIST_GLOBAL, Allocation, Size,
633 ACPI_MEM_CALLOC, Component, Module, Line);
634 if (ACPI_FAILURE (Status))
635 {
636 AcpiOsFree (Allocation);
637 return (NULL);
638 }
639
640 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalAllocated++;
641 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize += (UINT32) Size;
642
643 return ((void *) &Allocation->UserSpace);
644}
645
646
647/*******************************************************************************
648 *
649 * FUNCTION: AcpiUtFreeAndTrack
650 *
651 * PARAMETERS: Allocation - Address of the memory to deallocate
652 * Component - Component type of caller
653 * Module - Source file name of caller
654 * Line - Line number of caller
655 *
656 * RETURN: None
657 *
658 * DESCRIPTION: Frees the memory at Allocation
659 *
660 ******************************************************************************/
661
662void
663AcpiUtFreeAndTrack (
664 void *Allocation,
665 UINT32 Component,
666 NATIVE_CHAR *Module,
667 UINT32 Line)
668{
669 ACPI_DEBUG_MEM_BLOCK *DebugBlock;
670 ACPI_STATUS Status;
674
675
676 ACPI_FUNCTION_TRACE_PTR ("UtFree", Allocation);
677
678
679 if (NULL == Allocation)
680 {
681 _ACPI_REPORT_ERROR (Module, Line, Component,
682 ("AcpiUtFree: Attempt to delete a NULL address\n"));
683
684 return_VOID;
685 }
686
671
672
673 ACPI_FUNCTION_TRACE_PTR ("UtFree", Allocation);
674
675
676 if (NULL == Allocation)
677 {
678 _ACPI_REPORT_ERROR (Module, Line, Component,
679 ("AcpiUtFree: Attempt to delete a NULL address\n"));
680
681 return_VOID;
682 }
683
687 DebugBlock = (ACPI_DEBUG_MEM_BLOCK *)
688 (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER));
684 DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK,
685 (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER)));
689
690 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalFreed++;
691 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize -= DebugBlock->Size;
692
686
687 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalFreed++;
688 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize -= DebugBlock->Size;
689
693 AcpiUtRemoveAllocation (ACPI_MEM_LIST_GLOBAL, DebugBlock,
694 Component, Module, Line);
690 Status = AcpiUtRemoveAllocation (ACPI_MEM_LIST_GLOBAL, DebugBlock,
691 Component, Module, Line);
692 if (ACPI_FAILURE (Status))
693 {
694 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not free memory, %s\n",
695 AcpiFormatException (Status)));
696 }
697
695 AcpiOsFree (DebugBlock);
696
697 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation));
698
699 return_VOID;
700}
701
702
703/*******************************************************************************
704 *
705 * FUNCTION: AcpiUtFindAllocation
706 *
707 * PARAMETERS: Allocation - Address of allocated memory
708 *
709 * RETURN: A list element if found; NULL otherwise.
710 *
711 * DESCRIPTION: Searches for an element in the global allocation tracking list.
712 *
713 ******************************************************************************/
714
715ACPI_DEBUG_MEM_BLOCK *
716AcpiUtFindAllocation (
717 UINT32 ListId,
718 void *Allocation)
719{
720 ACPI_DEBUG_MEM_BLOCK *Element;
721
722
723 ACPI_FUNCTION_ENTRY ();
724
725
726 if (ListId > ACPI_MEM_LIST_MAX)
727 {
728 return (NULL);
729 }
730
731 Element = AcpiGbl_MemoryLists[ListId].ListHead;
732
733 /* Search for the address. */
734
735 while (Element)
736 {
737 if (Element == Allocation)
738 {
739 return (Element);
740 }
741
742 Element = Element->Next;
743 }
744
745 return (NULL);
746}
747
748
749/*******************************************************************************
750 *
751 * FUNCTION: AcpiUtTrackAllocation
752 *
753 * PARAMETERS: Allocation - Address of allocated memory
754 * Size - Size of the allocation
755 * AllocType - MEM_MALLOC or MEM_CALLOC
756 * Component - Component type of caller
757 * Module - Source file name of caller
758 * Line - Line number of caller
759 *
760 * RETURN: None.
761 *
762 * DESCRIPTION: Inserts an element into the global allocation tracking list.
763 *
764 ******************************************************************************/
765
766ACPI_STATUS
767AcpiUtTrackAllocation (
768 UINT32 ListId,
769 ACPI_DEBUG_MEM_BLOCK *Allocation,
770 ACPI_SIZE Size,
771 UINT8 AllocType,
772 UINT32 Component,
773 NATIVE_CHAR *Module,
774 UINT32 Line)
775{
776 ACPI_MEMORY_LIST *MemList;
777 ACPI_DEBUG_MEM_BLOCK *Element;
778 ACPI_STATUS Status = AE_OK;
779
780
781 ACPI_FUNCTION_TRACE_PTR ("UtTrackAllocation", Allocation);
782
783
784 if (ListId > ACPI_MEM_LIST_MAX)
785 {
786 return_ACPI_STATUS (AE_BAD_PARAMETER);
787 }
788
789 MemList = &AcpiGbl_MemoryLists[ListId];
790 Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
791 if (ACPI_FAILURE (Status))
792 {
793 return_ACPI_STATUS (Status);
794 }
795
796 /*
797 * Search list for this address to make sure it is not already on the list.
798 * This will catch several kinds of problems.
799 */
800
801 Element = AcpiUtFindAllocation (ListId, Allocation);
802 if (Element)
803 {
804 ACPI_REPORT_ERROR (("UtTrackAllocation: Allocation already present in list! (%p)\n",
805 Allocation));
806
807 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", Element, Allocation));
808
809 goto UnlockAndExit;
810 }
811
812 /* Fill in the instance data. */
813
814 Allocation->Size = (UINT32) Size;
815 Allocation->AllocType = AllocType;
816 Allocation->Component = Component;
817 Allocation->Line = Line;
818
819 ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME);
820
821 /* Insert at list head */
822
823 if (MemList->ListHead)
824 {
825 ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation;
826 }
827
828 Allocation->Next = MemList->ListHead;
829 Allocation->Previous = NULL;
830
831 MemList->ListHead = Allocation;
832
833
834UnlockAndExit:
835 Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
836 return_ACPI_STATUS (Status);
837}
838
839
840/*******************************************************************************
841 *
842 * FUNCTION: AcpiUtRemoveAllocation
843 *
844 * PARAMETERS: Allocation - Address of allocated memory
845 * Component - Component type of caller
846 * Module - Source file name of caller
847 * Line - Line number of caller
848 *
849 * RETURN:
850 *
851 * DESCRIPTION: Deletes an element from the global allocation tracking list.
852 *
853 ******************************************************************************/
854
855ACPI_STATUS
856AcpiUtRemoveAllocation (
857 UINT32 ListId,
858 ACPI_DEBUG_MEM_BLOCK *Allocation,
859 UINT32 Component,
860 NATIVE_CHAR *Module,
861 UINT32 Line)
862{
863 ACPI_MEMORY_LIST *MemList;
864 ACPI_STATUS Status;
865
866
867 ACPI_FUNCTION_TRACE ("UtRemoveAllocation");
868
869
870 if (ListId > ACPI_MEM_LIST_MAX)
871 {
872 return_ACPI_STATUS (AE_BAD_PARAMETER);
873 }
874
875 MemList = &AcpiGbl_MemoryLists[ListId];
876 if (NULL == MemList->ListHead)
877 {
878 /* No allocations! */
879
880 _ACPI_REPORT_ERROR (Module, Line, Component,
881 ("UtRemoveAllocation: Empty allocation list, nothing to free!\n"));
882
883 return_ACPI_STATUS (AE_OK);
884 }
885
886 Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
887 if (ACPI_FAILURE (Status))
888 {
889 return_ACPI_STATUS (Status);
890 }
891
892 /* Unlink */
893
894 if (Allocation->Previous)
895 {
896 (Allocation->Previous)->Next = Allocation->Next;
897 }
898 else
899 {
900 MemList->ListHead = Allocation->Next;
901 }
902
903 if (Allocation->Next)
904 {
905 (Allocation->Next)->Previous = Allocation->Previous;
906 }
907
908 /* Mark the segment as deleted */
909
910 ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size);
911
912 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size %X\n", Allocation->Size));
913
914 Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
915 return_ACPI_STATUS (Status);
916}
917
918
919/*******************************************************************************
920 *
921 * FUNCTION: AcpiUtDumpAllocationInfo
922 *
923 * PARAMETERS:
924 *
925 * RETURN: None
926 *
927 * DESCRIPTION: Print some info about the outstanding allocations.
928 *
929 ******************************************************************************/
930
931void
932AcpiUtDumpAllocationInfo (
933 void)
934{
935/*
936 ACPI_MEMORY_LIST *MemList;
937*/
938
939 ACPI_FUNCTION_TRACE ("UtDumpAllocationInfo");
940
941/*
942 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
943 ("%30s: %4d (%3d Kb)\n", "Current allocations",
944 MemList->CurrentCount,
945 ROUND_UP_TO_1K (MemList->CurrentSize)));
946
947 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
948 ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations",
949 MemList->MaxConcurrentCount,
950 ROUND_UP_TO_1K (MemList->MaxConcurrentSize)));
951
952
953 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
954 ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",
955 RunningObjectCount,
956 ROUND_UP_TO_1K (RunningObjectSize)));
957
958 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
959 ("%30s: %4d (%3d Kb)\n", "Total (all) allocations",
960 RunningAllocCount,
961 ROUND_UP_TO_1K (RunningAllocSize)));
962
963
964 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
965 ("%30s: %4d (%3d Kb)\n", "Current Nodes",
966 AcpiGbl_CurrentNodeCount,
967 ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize)));
968
969 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
970 ("%30s: %4d (%3d Kb)\n", "Max Nodes",
971 AcpiGbl_MaxConcurrentNodeCount,
972 ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount * sizeof (ACPI_NAMESPACE_NODE)))));
973*/
974 return_VOID;
975}
976
977
978/*******************************************************************************
979 *
980 * FUNCTION: AcpiUtDumpAllocations
981 *
982 * PARAMETERS: Component - Component(s) to dump info for.
983 * Module - Module to dump info for. NULL means all.
984 *
985 * RETURN: None
986 *
987 * DESCRIPTION: Print a list of all outstanding allocations.
988 *
989 ******************************************************************************/
990
991void
992AcpiUtDumpAllocations (
993 UINT32 Component,
994 NATIVE_CHAR *Module)
995{
996 ACPI_DEBUG_MEM_BLOCK *Element;
698 AcpiOsFree (DebugBlock);
699
700 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation));
701
702 return_VOID;
703}
704
705
706/*******************************************************************************
707 *
708 * FUNCTION: AcpiUtFindAllocation
709 *
710 * PARAMETERS: Allocation - Address of allocated memory
711 *
712 * RETURN: A list element if found; NULL otherwise.
713 *
714 * DESCRIPTION: Searches for an element in the global allocation tracking list.
715 *
716 ******************************************************************************/
717
718ACPI_DEBUG_MEM_BLOCK *
719AcpiUtFindAllocation (
720 UINT32 ListId,
721 void *Allocation)
722{
723 ACPI_DEBUG_MEM_BLOCK *Element;
724
725
726 ACPI_FUNCTION_ENTRY ();
727
728
729 if (ListId > ACPI_MEM_LIST_MAX)
730 {
731 return (NULL);
732 }
733
734 Element = AcpiGbl_MemoryLists[ListId].ListHead;
735
736 /* Search for the address. */
737
738 while (Element)
739 {
740 if (Element == Allocation)
741 {
742 return (Element);
743 }
744
745 Element = Element->Next;
746 }
747
748 return (NULL);
749}
750
751
752/*******************************************************************************
753 *
754 * FUNCTION: AcpiUtTrackAllocation
755 *
756 * PARAMETERS: Allocation - Address of allocated memory
757 * Size - Size of the allocation
758 * AllocType - MEM_MALLOC or MEM_CALLOC
759 * Component - Component type of caller
760 * Module - Source file name of caller
761 * Line - Line number of caller
762 *
763 * RETURN: None.
764 *
765 * DESCRIPTION: Inserts an element into the global allocation tracking list.
766 *
767 ******************************************************************************/
768
769ACPI_STATUS
770AcpiUtTrackAllocation (
771 UINT32 ListId,
772 ACPI_DEBUG_MEM_BLOCK *Allocation,
773 ACPI_SIZE Size,
774 UINT8 AllocType,
775 UINT32 Component,
776 NATIVE_CHAR *Module,
777 UINT32 Line)
778{
779 ACPI_MEMORY_LIST *MemList;
780 ACPI_DEBUG_MEM_BLOCK *Element;
781 ACPI_STATUS Status = AE_OK;
782
783
784 ACPI_FUNCTION_TRACE_PTR ("UtTrackAllocation", Allocation);
785
786
787 if (ListId > ACPI_MEM_LIST_MAX)
788 {
789 return_ACPI_STATUS (AE_BAD_PARAMETER);
790 }
791
792 MemList = &AcpiGbl_MemoryLists[ListId];
793 Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
794 if (ACPI_FAILURE (Status))
795 {
796 return_ACPI_STATUS (Status);
797 }
798
799 /*
800 * Search list for this address to make sure it is not already on the list.
801 * This will catch several kinds of problems.
802 */
803
804 Element = AcpiUtFindAllocation (ListId, Allocation);
805 if (Element)
806 {
807 ACPI_REPORT_ERROR (("UtTrackAllocation: Allocation already present in list! (%p)\n",
808 Allocation));
809
810 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", Element, Allocation));
811
812 goto UnlockAndExit;
813 }
814
815 /* Fill in the instance data. */
816
817 Allocation->Size = (UINT32) Size;
818 Allocation->AllocType = AllocType;
819 Allocation->Component = Component;
820 Allocation->Line = Line;
821
822 ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME);
823
824 /* Insert at list head */
825
826 if (MemList->ListHead)
827 {
828 ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation;
829 }
830
831 Allocation->Next = MemList->ListHead;
832 Allocation->Previous = NULL;
833
834 MemList->ListHead = Allocation;
835
836
837UnlockAndExit:
838 Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
839 return_ACPI_STATUS (Status);
840}
841
842
843/*******************************************************************************
844 *
845 * FUNCTION: AcpiUtRemoveAllocation
846 *
847 * PARAMETERS: Allocation - Address of allocated memory
848 * Component - Component type of caller
849 * Module - Source file name of caller
850 * Line - Line number of caller
851 *
852 * RETURN:
853 *
854 * DESCRIPTION: Deletes an element from the global allocation tracking list.
855 *
856 ******************************************************************************/
857
858ACPI_STATUS
859AcpiUtRemoveAllocation (
860 UINT32 ListId,
861 ACPI_DEBUG_MEM_BLOCK *Allocation,
862 UINT32 Component,
863 NATIVE_CHAR *Module,
864 UINT32 Line)
865{
866 ACPI_MEMORY_LIST *MemList;
867 ACPI_STATUS Status;
868
869
870 ACPI_FUNCTION_TRACE ("UtRemoveAllocation");
871
872
873 if (ListId > ACPI_MEM_LIST_MAX)
874 {
875 return_ACPI_STATUS (AE_BAD_PARAMETER);
876 }
877
878 MemList = &AcpiGbl_MemoryLists[ListId];
879 if (NULL == MemList->ListHead)
880 {
881 /* No allocations! */
882
883 _ACPI_REPORT_ERROR (Module, Line, Component,
884 ("UtRemoveAllocation: Empty allocation list, nothing to free!\n"));
885
886 return_ACPI_STATUS (AE_OK);
887 }
888
889 Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
890 if (ACPI_FAILURE (Status))
891 {
892 return_ACPI_STATUS (Status);
893 }
894
895 /* Unlink */
896
897 if (Allocation->Previous)
898 {
899 (Allocation->Previous)->Next = Allocation->Next;
900 }
901 else
902 {
903 MemList->ListHead = Allocation->Next;
904 }
905
906 if (Allocation->Next)
907 {
908 (Allocation->Next)->Previous = Allocation->Previous;
909 }
910
911 /* Mark the segment as deleted */
912
913 ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size);
914
915 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size %X\n", Allocation->Size));
916
917 Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
918 return_ACPI_STATUS (Status);
919}
920
921
922/*******************************************************************************
923 *
924 * FUNCTION: AcpiUtDumpAllocationInfo
925 *
926 * PARAMETERS:
927 *
928 * RETURN: None
929 *
930 * DESCRIPTION: Print some info about the outstanding allocations.
931 *
932 ******************************************************************************/
933
934void
935AcpiUtDumpAllocationInfo (
936 void)
937{
938/*
939 ACPI_MEMORY_LIST *MemList;
940*/
941
942 ACPI_FUNCTION_TRACE ("UtDumpAllocationInfo");
943
944/*
945 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
946 ("%30s: %4d (%3d Kb)\n", "Current allocations",
947 MemList->CurrentCount,
948 ROUND_UP_TO_1K (MemList->CurrentSize)));
949
950 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
951 ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations",
952 MemList->MaxConcurrentCount,
953 ROUND_UP_TO_1K (MemList->MaxConcurrentSize)));
954
955
956 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
957 ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",
958 RunningObjectCount,
959 ROUND_UP_TO_1K (RunningObjectSize)));
960
961 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
962 ("%30s: %4d (%3d Kb)\n", "Total (all) allocations",
963 RunningAllocCount,
964 ROUND_UP_TO_1K (RunningAllocSize)));
965
966
967 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
968 ("%30s: %4d (%3d Kb)\n", "Current Nodes",
969 AcpiGbl_CurrentNodeCount,
970 ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize)));
971
972 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
973 ("%30s: %4d (%3d Kb)\n", "Max Nodes",
974 AcpiGbl_MaxConcurrentNodeCount,
975 ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount * sizeof (ACPI_NAMESPACE_NODE)))));
976*/
977 return_VOID;
978}
979
980
981/*******************************************************************************
982 *
983 * FUNCTION: AcpiUtDumpAllocations
984 *
985 * PARAMETERS: Component - Component(s) to dump info for.
986 * Module - Module to dump info for. NULL means all.
987 *
988 * RETURN: None
989 *
990 * DESCRIPTION: Print a list of all outstanding allocations.
991 *
992 ******************************************************************************/
993
994void
995AcpiUtDumpAllocations (
996 UINT32 Component,
997 NATIVE_CHAR *Module)
998{
999 ACPI_DEBUG_MEM_BLOCK *Element;
1000 ACPI_DESCRIPTOR *Descriptor;
997 UINT32 NumOutstanding = 0;
998
999
1000 ACPI_FUNCTION_TRACE ("UtDumpAllocations");
1001
1002
1003 /*
1004 * Walk the allocation list.
1005 */
1006 if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY)))
1007 {
1008 return;
1009 }
1010
1011 Element = AcpiGbl_MemoryLists[0].ListHead;
1012 while (Element)
1013 {
1014 if ((Element->Component & Component) &&
1015 ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module))))
1016 {
1017 /* Ignore allocated objects that are in a cache */
1018
1001 UINT32 NumOutstanding = 0;
1002
1003
1004 ACPI_FUNCTION_TRACE ("UtDumpAllocations");
1005
1006
1007 /*
1008 * Walk the allocation list.
1009 */
1010 if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY)))
1011 {
1012 return;
1013 }
1014
1015 Element = AcpiGbl_MemoryLists[0].ListHead;
1016 while (Element)
1017 {
1018 if ((Element->Component & Component) &&
1019 ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module))))
1020 {
1021 /* Ignore allocated objects that are in a cache */
1022
1019 if (((ACPI_OPERAND_OBJECT *)(&Element->UserSpace))->Common.Type != ACPI_CACHED_OBJECT)
1023 Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace);
1024 if (Descriptor->DescriptorId != ACPI_DESC_TYPE_CACHED)
1020 {
1021 AcpiOsPrintf ("%p Len %04X %9.9s-%d ",
1025 {
1026 AcpiOsPrintf ("%p Len %04X %9.9s-%d ",
1022 &Element->UserSpace, Element->Size, Element->Module,
1027 Descriptor, Element->Size, Element->Module,
1023 Element->Line);
1024
1025 /* Most of the elements will be internal objects. */
1026
1028 Element->Line);
1029
1030 /* Most of the elements will be internal objects. */
1031
1027 switch (ACPI_GET_DESCRIPTOR_TYPE (&Element->UserSpace))
1032 switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor))
1028 {
1033 {
1029 case ACPI_DESC_TYPE_INTERNAL:
1030 AcpiOsPrintf ("ObjType %12.12s R%d",
1031 AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *)(&Element->UserSpace))->Common.Type),
1032 ((ACPI_OPERAND_OBJECT *)(&Element->UserSpace))->Common.ReferenceCount);
1034 case ACPI_DESC_TYPE_OPERAND:
1035 AcpiOsPrintf ("ObjType %12.12s R%hd",
1036 AcpiUtGetTypeName (Descriptor->Object.Common.Type),
1037 Descriptor->Object.Common.ReferenceCount);
1033 break;
1034
1035 case ACPI_DESC_TYPE_PARSER:
1038 break;
1039
1040 case ACPI_DESC_TYPE_PARSER:
1036 AcpiOsPrintf ("ParseObj Opcode %04X",
1037 ((ACPI_PARSE_OBJECT *)(&Element->UserSpace))->Opcode);
1041 AcpiOsPrintf ("ParseObj AmlOpcode %04hX",
1042 Descriptor->Op.Asl.AmlOpcode);
1038 break;
1039
1040 case ACPI_DESC_TYPE_NAMED:
1041 AcpiOsPrintf ("Node %4.4s",
1043 break;
1044
1045 case ACPI_DESC_TYPE_NAMED:
1046 AcpiOsPrintf ("Node %4.4s",
1042 (char *) &((ACPI_NAMESPACE_NODE *)(&Element->UserSpace))->Name);
1047 Descriptor->Node.Name.Ascii);
1043 break;
1044
1045 case ACPI_DESC_TYPE_STATE:
1046 AcpiOsPrintf ("Untyped StateObj");
1047 break;
1048
1049 case ACPI_DESC_TYPE_STATE_UPDATE:
1050 AcpiOsPrintf ("UPDATE StateObj");
1051 break;
1052
1053 case ACPI_DESC_TYPE_STATE_PACKAGE:
1054 AcpiOsPrintf ("PACKAGE StateObj");
1055 break;
1056
1057 case ACPI_DESC_TYPE_STATE_CONTROL:
1058 AcpiOsPrintf ("CONTROL StateObj");
1059 break;
1060
1061 case ACPI_DESC_TYPE_STATE_RPSCOPE:
1062 AcpiOsPrintf ("ROOT-PARSE-SCOPE StateObj");
1063 break;
1064
1065 case ACPI_DESC_TYPE_STATE_PSCOPE:
1066 AcpiOsPrintf ("PARSE-SCOPE StateObj");
1067 break;
1068
1069 case ACPI_DESC_TYPE_STATE_WSCOPE:
1070 AcpiOsPrintf ("WALK-SCOPE StateObj");
1071 break;
1072
1073 case ACPI_DESC_TYPE_STATE_RESULT:
1074 AcpiOsPrintf ("RESULT StateObj");
1075 break;
1076
1077 case ACPI_DESC_TYPE_STATE_NOTIFY:
1078 AcpiOsPrintf ("NOTIFY StateObj");
1079 break;
1080
1081 case ACPI_DESC_TYPE_STATE_THREAD:
1082 AcpiOsPrintf ("THREAD StateObj");
1083 break;
1048 break;
1049
1050 case ACPI_DESC_TYPE_STATE:
1051 AcpiOsPrintf ("Untyped StateObj");
1052 break;
1053
1054 case ACPI_DESC_TYPE_STATE_UPDATE:
1055 AcpiOsPrintf ("UPDATE StateObj");
1056 break;
1057
1058 case ACPI_DESC_TYPE_STATE_PACKAGE:
1059 AcpiOsPrintf ("PACKAGE StateObj");
1060 break;
1061
1062 case ACPI_DESC_TYPE_STATE_CONTROL:
1063 AcpiOsPrintf ("CONTROL StateObj");
1064 break;
1065
1066 case ACPI_DESC_TYPE_STATE_RPSCOPE:
1067 AcpiOsPrintf ("ROOT-PARSE-SCOPE StateObj");
1068 break;
1069
1070 case ACPI_DESC_TYPE_STATE_PSCOPE:
1071 AcpiOsPrintf ("PARSE-SCOPE StateObj");
1072 break;
1073
1074 case ACPI_DESC_TYPE_STATE_WSCOPE:
1075 AcpiOsPrintf ("WALK-SCOPE StateObj");
1076 break;
1077
1078 case ACPI_DESC_TYPE_STATE_RESULT:
1079 AcpiOsPrintf ("RESULT StateObj");
1080 break;
1081
1082 case ACPI_DESC_TYPE_STATE_NOTIFY:
1083 AcpiOsPrintf ("NOTIFY StateObj");
1084 break;
1085
1086 case ACPI_DESC_TYPE_STATE_THREAD:
1087 AcpiOsPrintf ("THREAD StateObj");
1088 break;
1089
1090 default:
1091 /* All types should appear above */
1092 break;
1084 }
1085
1086 AcpiOsPrintf ( "\n");
1087 NumOutstanding++;
1088 }
1089 }
1090 Element = Element->Next;
1091 }
1092
1093 (void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
1094
1095 /* Print summary */
1096
1097 if (!NumOutstanding)
1098 {
1099 ACPI_DEBUG_PRINT ((ACPI_DB_OK,
1093 }
1094
1095 AcpiOsPrintf ( "\n");
1096 NumOutstanding++;
1097 }
1098 }
1099 Element = Element->Next;
1100 }
1101
1102 (void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
1103
1104 /* Print summary */
1105
1106 if (!NumOutstanding)
1107 {
1108 ACPI_DEBUG_PRINT ((ACPI_DB_OK,
1100 "No outstanding allocations.\n"));
1109 "No outstanding allocations.\n"));
1101 }
1102 else
1103 {
1104 ACPI_DEBUG_PRINT ((ACPI_DB_OK,
1105 "%d(%X) Outstanding allocations\n",
1106 NumOutstanding, NumOutstanding));
1107 }
1108
1109 return_VOID;
1110}
1111
1112
1113#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */
1114
1110 }
1111 else
1112 {
1113 ACPI_DEBUG_PRINT ((ACPI_DB_OK,
1114 "%d(%X) Outstanding allocations\n",
1115 NumOutstanding, NumOutstanding));
1116 }
1117
1118 return_VOID;
1119}
1120
1121
1122#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */
1123