BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / bus_managers / acpi / acpica / components / utilities / uttrack.c
blobdf04aa3a572e8d4b5ef78b8d9b2ef23e73cd4776
1 /******************************************************************************
3 * Module Name: uttrack - Memory allocation tracking routines (debug only)
5 *****************************************************************************/
7 /******************************************************************************
9 * 1. Copyright Notice
11 * Some or all of this work - Copyright (c) 1999 - 2014, Intel Corp.
12 * All rights reserved.
14 * 2. License
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
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
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
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
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
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
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
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
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
40 * 3. Conditions
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
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
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
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
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
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
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
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
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
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
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
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
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
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
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
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
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
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
103 * event Licensee exports any such software from the United States or
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
106 * compliance with all laws, regulations, orders, or other restrictions of the
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,
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,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************/
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.
120 * Each memory allocation is tracked via a doubly linked list. Each
121 * element contains the caller's component, module name, function name, and
122 * line number. AcpiUtAllocate and AcpiUtAllocateZeroed call
123 * AcpiUtTrackAllocation to add an element to the list; deletion
124 * occurs in the body of AcpiUtFree.
127 #define __UTTRACK_C__
129 #include "acpi.h"
130 #include "accommon.h"
132 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
134 #define _COMPONENT ACPI_UTILITIES
135 ACPI_MODULE_NAME ("uttrack")
138 /* Local prototypes */
140 static ACPI_DEBUG_MEM_BLOCK *
141 AcpiUtFindAllocation (
142 ACPI_DEBUG_MEM_BLOCK *Allocation);
144 static ACPI_STATUS
145 AcpiUtTrackAllocation (
146 ACPI_DEBUG_MEM_BLOCK *Address,
147 ACPI_SIZE Size,
148 UINT8 AllocType,
149 UINT32 Component,
150 const char *Module,
151 UINT32 Line);
153 static ACPI_STATUS
154 AcpiUtRemoveAllocation (
155 ACPI_DEBUG_MEM_BLOCK *Address,
156 UINT32 Component,
157 const char *Module,
158 UINT32 Line);
161 /*******************************************************************************
163 * FUNCTION: AcpiUtCreateList
165 * PARAMETERS: CacheName - Ascii name for the cache
166 * ObjectSize - Size of each cached object
167 * ReturnCache - Where the new cache object is returned
169 * RETURN: Status
171 * DESCRIPTION: Create a local memory list for tracking purposed
173 ******************************************************************************/
175 ACPI_STATUS
176 AcpiUtCreateList (
177 char *ListName,
178 UINT16 ObjectSize,
179 ACPI_MEMORY_LIST **ReturnCache)
181 ACPI_MEMORY_LIST *Cache;
184 Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST));
185 if (!Cache)
187 return (AE_NO_MEMORY);
190 ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST));
192 Cache->ListName = ListName;
193 Cache->ObjectSize = ObjectSize;
195 *ReturnCache = Cache;
196 return (AE_OK);
200 /*******************************************************************************
202 * FUNCTION: AcpiUtAllocateAndTrack
204 * PARAMETERS: Size - Size of the allocation
205 * Component - Component type of caller
206 * Module - Source file name of caller
207 * Line - Line number of caller
209 * RETURN: Address of the allocated memory on success, NULL on failure.
211 * DESCRIPTION: The subsystem's equivalent of malloc.
213 ******************************************************************************/
215 void *
216 AcpiUtAllocateAndTrack (
217 ACPI_SIZE Size,
218 UINT32 Component,
219 const char *Module,
220 UINT32 Line)
222 ACPI_DEBUG_MEM_BLOCK *Allocation;
223 ACPI_STATUS Status;
226 /* Check for an inadvertent size of zero bytes */
228 if (!Size)
230 ACPI_WARNING ((Module, Line,
231 "Attempt to allocate zero bytes, allocating 1 byte"));
232 Size = 1;
235 Allocation = AcpiOsAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER));
236 if (!Allocation)
238 /* Report allocation error */
240 ACPI_WARNING ((Module, Line,
241 "Could not allocate size %u", (UINT32) Size));
243 return (NULL);
246 Status = AcpiUtTrackAllocation (Allocation, Size,
247 ACPI_MEM_MALLOC, Component, Module, Line);
248 if (ACPI_FAILURE (Status))
250 AcpiOsFree (Allocation);
251 return (NULL);
254 AcpiGbl_GlobalList->TotalAllocated++;
255 AcpiGbl_GlobalList->TotalSize += (UINT32) Size;
256 AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size;
257 if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied)
259 AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize;
262 return ((void *) &Allocation->UserSpace);
266 /*******************************************************************************
268 * FUNCTION: AcpiUtAllocateZeroedAndTrack
270 * PARAMETERS: Size - Size of the allocation
271 * Component - Component type of caller
272 * Module - Source file name of caller
273 * Line - Line number of caller
275 * RETURN: Address of the allocated memory on success, NULL on failure.
277 * DESCRIPTION: Subsystem equivalent of calloc.
279 ******************************************************************************/
281 void *
282 AcpiUtAllocateZeroedAndTrack (
283 ACPI_SIZE Size,
284 UINT32 Component,
285 const char *Module,
286 UINT32 Line)
288 ACPI_DEBUG_MEM_BLOCK *Allocation;
289 ACPI_STATUS Status;
292 /* Check for an inadvertent size of zero bytes */
294 if (!Size)
296 ACPI_WARNING ((Module, Line,
297 "Attempt to allocate zero bytes, allocating 1 byte"));
298 Size = 1;
301 Allocation = AcpiOsAllocateZeroed (Size + sizeof (ACPI_DEBUG_MEM_HEADER));
302 if (!Allocation)
304 /* Report allocation error */
306 ACPI_ERROR ((Module, Line,
307 "Could not allocate size %u", (UINT32) Size));
308 return (NULL);
311 Status = AcpiUtTrackAllocation (Allocation, Size,
312 ACPI_MEM_CALLOC, Component, Module, Line);
313 if (ACPI_FAILURE (Status))
315 AcpiOsFree (Allocation);
316 return (NULL);
319 AcpiGbl_GlobalList->TotalAllocated++;
320 AcpiGbl_GlobalList->TotalSize += (UINT32) Size;
321 AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size;
322 if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied)
324 AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize;
327 return ((void *) &Allocation->UserSpace);
331 /*******************************************************************************
333 * FUNCTION: AcpiUtFreeAndTrack
335 * PARAMETERS: Allocation - Address of the memory to deallocate
336 * Component - Component type of caller
337 * Module - Source file name of caller
338 * Line - Line number of caller
340 * RETURN: None
342 * DESCRIPTION: Frees the memory at Allocation
344 ******************************************************************************/
346 void
347 AcpiUtFreeAndTrack (
348 void *Allocation,
349 UINT32 Component,
350 const char *Module,
351 UINT32 Line)
353 ACPI_DEBUG_MEM_BLOCK *DebugBlock;
354 ACPI_STATUS Status;
357 ACPI_FUNCTION_TRACE_PTR (UtFree, Allocation);
360 if (NULL == Allocation)
362 ACPI_ERROR ((Module, Line,
363 "Attempt to delete a NULL address"));
365 return_VOID;
368 DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK,
369 (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER)));
371 AcpiGbl_GlobalList->TotalFreed++;
372 AcpiGbl_GlobalList->CurrentTotalSize -= DebugBlock->Size;
374 Status = AcpiUtRemoveAllocation (DebugBlock,
375 Component, Module, Line);
376 if (ACPI_FAILURE (Status))
378 ACPI_EXCEPTION ((AE_INFO, Status, "Could not free memory"));
381 AcpiOsFree (DebugBlock);
382 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed (block %p)\n",
383 Allocation, DebugBlock));
384 return_VOID;
388 /*******************************************************************************
390 * FUNCTION: AcpiUtFindAllocation
392 * PARAMETERS: Allocation - Address of allocated memory
394 * RETURN: Three cases:
395 * 1) List is empty, NULL is returned.
396 * 2) Element was found. Returns Allocation parameter.
397 * 3) Element was not found. Returns position where it should be
398 * inserted into the list.
400 * DESCRIPTION: Searches for an element in the global allocation tracking list.
401 * If the element is not found, returns the location within the
402 * list where the element should be inserted.
404 * Note: The list is ordered by larger-to-smaller addresses.
406 * This global list is used to detect memory leaks in ACPICA as
407 * well as other issues such as an attempt to release the same
408 * internal object more than once. Although expensive as far
409 * as cpu time, this list is much more helpful for finding these
410 * types of issues than using memory leak detectors outside of
411 * the ACPICA code.
413 ******************************************************************************/
415 static ACPI_DEBUG_MEM_BLOCK *
416 AcpiUtFindAllocation (
417 ACPI_DEBUG_MEM_BLOCK *Allocation)
419 ACPI_DEBUG_MEM_BLOCK *Element;
422 Element = AcpiGbl_GlobalList->ListHead;
423 if (!Element)
425 return (NULL);
429 * Search for the address.
431 * Note: List is ordered by larger-to-smaller addresses, on the
432 * assumption that a new allocation usually has a larger address
433 * than previous allocations.
435 while (Element > Allocation)
437 /* Check for end-of-list */
439 if (!Element->Next)
441 return (Element);
444 Element = Element->Next;
447 if (Element == Allocation)
449 return (Element);
452 return (Element->Previous);
456 /*******************************************************************************
458 * FUNCTION: AcpiUtTrackAllocation
460 * PARAMETERS: Allocation - Address of allocated memory
461 * Size - Size of the allocation
462 * AllocType - MEM_MALLOC or MEM_CALLOC
463 * Component - Component type of caller
464 * Module - Source file name of caller
465 * Line - Line number of caller
467 * RETURN: Status
469 * DESCRIPTION: Inserts an element into the global allocation tracking list.
471 ******************************************************************************/
473 static ACPI_STATUS
474 AcpiUtTrackAllocation (
475 ACPI_DEBUG_MEM_BLOCK *Allocation,
476 ACPI_SIZE Size,
477 UINT8 AllocType,
478 UINT32 Component,
479 const char *Module,
480 UINT32 Line)
482 ACPI_MEMORY_LIST *MemList;
483 ACPI_DEBUG_MEM_BLOCK *Element;
484 ACPI_STATUS Status = AE_OK;
487 ACPI_FUNCTION_TRACE_PTR (UtTrackAllocation, Allocation);
490 if (AcpiGbl_DisableMemTracking)
492 return_ACPI_STATUS (AE_OK);
495 MemList = AcpiGbl_GlobalList;
496 Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
497 if (ACPI_FAILURE (Status))
499 return_ACPI_STATUS (Status);
503 * Search the global list for this address to make sure it is not
504 * already present. This will catch several kinds of problems.
506 Element = AcpiUtFindAllocation (Allocation);
507 if (Element == Allocation)
509 ACPI_ERROR ((AE_INFO,
510 "UtTrackAllocation: Allocation (%p) already present in global list!",
511 Allocation));
512 goto UnlockAndExit;
515 /* Fill in the instance data */
517 Allocation->Size = (UINT32) Size;
518 Allocation->AllocType = AllocType;
519 Allocation->Component = Component;
520 Allocation->Line = Line;
522 ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME);
523 Allocation->Module[ACPI_MAX_MODULE_NAME-1] = 0;
525 if (!Element)
527 /* Insert at list head */
529 if (MemList->ListHead)
531 ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation;
534 Allocation->Next = MemList->ListHead;
535 Allocation->Previous = NULL;
537 MemList->ListHead = Allocation;
539 else
541 /* Insert after element */
543 Allocation->Next = Element->Next;
544 Allocation->Previous = Element;
546 if (Element->Next)
548 (Element->Next)->Previous = Allocation;
551 Element->Next = Allocation;
555 UnlockAndExit:
556 Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
557 return_ACPI_STATUS (Status);
561 /*******************************************************************************
563 * FUNCTION: AcpiUtRemoveAllocation
565 * PARAMETERS: Allocation - Address of allocated memory
566 * Component - Component type of caller
567 * Module - Source file name of caller
568 * Line - Line number of caller
570 * RETURN: Status
572 * DESCRIPTION: Deletes an element from the global allocation tracking list.
574 ******************************************************************************/
576 static ACPI_STATUS
577 AcpiUtRemoveAllocation (
578 ACPI_DEBUG_MEM_BLOCK *Allocation,
579 UINT32 Component,
580 const char *Module,
581 UINT32 Line)
583 ACPI_MEMORY_LIST *MemList;
584 ACPI_STATUS Status;
587 ACPI_FUNCTION_NAME (UtRemoveAllocation);
590 if (AcpiGbl_DisableMemTracking)
592 return (AE_OK);
595 MemList = AcpiGbl_GlobalList;
596 if (NULL == MemList->ListHead)
598 /* No allocations! */
600 ACPI_ERROR ((Module, Line,
601 "Empty allocation list, nothing to free!"));
603 return (AE_OK);
606 Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
607 if (ACPI_FAILURE (Status))
609 return (Status);
612 /* Unlink */
614 if (Allocation->Previous)
616 (Allocation->Previous)->Next = Allocation->Next;
618 else
620 MemList->ListHead = Allocation->Next;
623 if (Allocation->Next)
625 (Allocation->Next)->Previous = Allocation->Previous;
628 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing %p, size 0%X\n",
629 &Allocation->UserSpace, Allocation->Size));
631 /* Mark the segment as deleted */
633 ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size);
635 Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
636 return (Status);
640 /*******************************************************************************
642 * FUNCTION: AcpiUtDumpAllocationInfo
644 * PARAMETERS: None
646 * RETURN: None
648 * DESCRIPTION: Print some info about the outstanding allocations.
650 ******************************************************************************/
652 void
653 AcpiUtDumpAllocationInfo (
654 void)
657 ACPI_MEMORY_LIST *MemList;
660 ACPI_FUNCTION_TRACE (UtDumpAllocationInfo);
663 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
664 ("%30s: %4d (%3d Kb)\n", "Current allocations",
665 MemList->CurrentCount,
666 ROUND_UP_TO_1K (MemList->CurrentSize)));
668 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
669 ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations",
670 MemList->MaxConcurrentCount,
671 ROUND_UP_TO_1K (MemList->MaxConcurrentSize)));
674 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
675 ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",
676 RunningObjectCount,
677 ROUND_UP_TO_1K (RunningObjectSize)));
679 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
680 ("%30s: %4d (%3d Kb)\n", "Total (all) allocations",
681 RunningAllocCount,
682 ROUND_UP_TO_1K (RunningAllocSize)));
685 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
686 ("%30s: %4d (%3d Kb)\n", "Current Nodes",
687 AcpiGbl_CurrentNodeCount,
688 ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize)));
690 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
691 ("%30s: %4d (%3d Kb)\n", "Max Nodes",
692 AcpiGbl_MaxConcurrentNodeCount,
693 ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount *
694 sizeof (ACPI_NAMESPACE_NODE)))));
696 return_VOID;
700 /*******************************************************************************
702 * FUNCTION: AcpiUtDumpAllocations
704 * PARAMETERS: Component - Component(s) to dump info for.
705 * Module - Module to dump info for. NULL means all.
707 * RETURN: None
709 * DESCRIPTION: Print a list of all outstanding allocations.
711 ******************************************************************************/
713 void
714 AcpiUtDumpAllocations (
715 UINT32 Component,
716 const char *Module)
718 ACPI_DEBUG_MEM_BLOCK *Element;
719 ACPI_DESCRIPTOR *Descriptor;
720 UINT32 NumOutstanding = 0;
721 UINT8 DescriptorType;
724 ACPI_FUNCTION_TRACE (UtDumpAllocations);
727 if (AcpiGbl_DisableMemTracking)
729 return_VOID;
733 * Walk the allocation list.
735 if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY)))
737 return_VOID;
740 Element = AcpiGbl_GlobalList->ListHead;
741 while (Element)
743 if ((Element->Component & Component) &&
744 ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module))))
746 Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace);
748 if (Element->Size < sizeof (ACPI_COMMON_DESCRIPTOR))
750 AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u "
751 "[Not a Descriptor - too small]\n",
752 Descriptor, Element->Size, Element->Module,
753 Element->Line);
755 else
757 /* Ignore allocated objects that are in a cache */
759 if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) != ACPI_DESC_TYPE_CACHED)
761 AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u [%s] ",
762 Descriptor, Element->Size, Element->Module,
763 Element->Line, AcpiUtGetDescriptorName (Descriptor));
765 /* Validate the descriptor type using Type field and length */
767 DescriptorType = 0; /* Not a valid descriptor type */
769 switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor))
771 case ACPI_DESC_TYPE_OPERAND:
773 if (Element->Size == sizeof (ACPI_OPERAND_OBJECT))
775 DescriptorType = ACPI_DESC_TYPE_OPERAND;
777 break;
779 case ACPI_DESC_TYPE_PARSER:
781 if (Element->Size == sizeof (ACPI_PARSE_OBJECT))
783 DescriptorType = ACPI_DESC_TYPE_PARSER;
785 break;
787 case ACPI_DESC_TYPE_NAMED:
789 if (Element->Size == sizeof (ACPI_NAMESPACE_NODE))
791 DescriptorType = ACPI_DESC_TYPE_NAMED;
793 break;
795 default:
797 break;
800 /* Display additional info for the major descriptor types */
802 switch (DescriptorType)
804 case ACPI_DESC_TYPE_OPERAND:
806 AcpiOsPrintf ("%12.12s RefCount 0x%04X\n",
807 AcpiUtGetTypeName (Descriptor->Object.Common.Type),
808 Descriptor->Object.Common.ReferenceCount);
809 break;
811 case ACPI_DESC_TYPE_PARSER:
813 AcpiOsPrintf ("AmlOpcode 0x%04hX\n",
814 Descriptor->Op.Asl.AmlOpcode);
815 break;
817 case ACPI_DESC_TYPE_NAMED:
819 AcpiOsPrintf ("%4.4s\n",
820 AcpiUtGetNodeName (&Descriptor->Node));
821 break;
823 default:
825 AcpiOsPrintf ( "\n");
826 break;
831 NumOutstanding++;
834 Element = Element->Next;
837 (void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
839 /* Print summary */
841 if (!NumOutstanding)
843 ACPI_INFO ((AE_INFO, "No outstanding allocations"));
845 else
847 ACPI_ERROR ((AE_INFO, "%u(0x%X) Outstanding allocations",
848 NumOutstanding, NumOutstanding));
851 return_VOID;
854 #endif /* ACPI_DBG_TRACK_ALLOCATIONS */