1 /******************************************************************************
3 * Module Name: utalloc - local cache and memory allocation routines
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
13 * All rights reserved.
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
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
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;
38 * The above copyright and patent license is granted only if the following
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.
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
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
73 * 3.4. Intel retains all right, title, and interest in and to the Original
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.
81 * 4. Disclaimer and Export Compliance
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
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
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.
115 *****************************************************************************/
117 #define __UTALLOC_C__
121 #define _COMPONENT ACPI_UTILITIES
122 ACPI_MODULE_NAME ("utalloc")
125 /******************************************************************************
127 * FUNCTION: AcpiUtReleaseToCache
129 * PARAMETERS: ListId - Memory list/cache ID
130 * Object - The object to be released
134 * DESCRIPTION: Release an object to the specified cache. If cache is full,
135 * the object is deleted.
137 ******************************************************************************/
140 AcpiUtReleaseToCache (
144 ACPI_MEMORY_LIST *CacheInfo;
147 ACPI_FUNCTION_ENTRY ();
150 /* If walk cache is full, just free this wallkstate object */
152 CacheInfo = &AcpiGbl_MemoryLists[ListId];
153 if (CacheInfo->CacheDepth >= CacheInfo->MaxCacheDepth)
155 ACPI_MEM_FREE (Object);
156 ACPI_MEM_TRACKING (CacheInfo->TotalFreed++);
159 /* Otherwise put this object back into the cache */
163 if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES)))
168 /* Mark the object as cached */
170 ACPI_MEMSET (Object, 0xCA, CacheInfo->ObjectSize);
171 ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_CACHED);
173 /* Put the object at the head of the cache list */
175 * (ACPI_CAST_INDIRECT_PTR (char, &(((char *) Object)[CacheInfo->LinkOffset]))) = CacheInfo->ListHead;
176 CacheInfo->ListHead = Object;
177 CacheInfo->CacheDepth++;
179 (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
184 /******************************************************************************
186 * FUNCTION: AcpiUtAcquireFromCache
188 * PARAMETERS: ListId - Memory list ID
190 * RETURN: A requested object. NULL if the object could not be
193 * DESCRIPTION: Get an object from the specified cache. If cache is empty,
194 * the object is allocated.
196 ******************************************************************************/
199 AcpiUtAcquireFromCache (
202 ACPI_MEMORY_LIST *CacheInfo;
206 ACPI_FUNCTION_NAME ("UtAcquireFromCache");
209 CacheInfo = &AcpiGbl_MemoryLists[ListId];
210 if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES)))
215 ACPI_MEM_TRACKING (CacheInfo->CacheRequests++);
217 /* Check the cache first */
219 if (CacheInfo->ListHead)
221 /* There is an object available, use it */
223 Object = CacheInfo->ListHead;
224 CacheInfo->ListHead = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) Object)[CacheInfo->LinkOffset])));
226 ACPI_MEM_TRACKING (CacheInfo->CacheHits++);
227 CacheInfo->CacheDepth--;
229 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
230 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p from %s\n",
231 Object, AcpiGbl_MemoryLists[ListId].ListName));
234 if (ACPI_FAILURE (AcpiUtReleaseMutex (ACPI_MTX_CACHES)))
239 /* Clear (zero) the previously used Object */
241 ACPI_MEMSET (Object, 0, CacheInfo->ObjectSize);
246 /* The cache is empty, create a new object */
248 /* Avoid deadlock with ACPI_MEM_CALLOCATE */
250 if (ACPI_FAILURE (AcpiUtReleaseMutex (ACPI_MTX_CACHES)))
255 Object = ACPI_MEM_CALLOCATE (CacheInfo->ObjectSize);
256 ACPI_MEM_TRACKING (CacheInfo->TotalAllocated++);
263 /******************************************************************************
265 * FUNCTION: AcpiUtDeleteGenericCache
267 * PARAMETERS: ListId - Memory list ID
271 * DESCRIPTION: Free all objects within the requested cache.
273 ******************************************************************************/
276 AcpiUtDeleteGenericCache (
279 ACPI_MEMORY_LIST *CacheInfo;
283 ACPI_FUNCTION_ENTRY ();
286 CacheInfo = &AcpiGbl_MemoryLists[ListId];
287 while (CacheInfo->ListHead)
289 /* Delete one cached state object */
291 Next = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) CacheInfo->ListHead)[CacheInfo->LinkOffset])));
292 ACPI_MEM_FREE (CacheInfo->ListHead);
294 CacheInfo->ListHead = Next;
295 CacheInfo->CacheDepth--;
300 /*******************************************************************************
302 * FUNCTION: AcpiUtValidateBuffer
304 * PARAMETERS: Buffer - Buffer descriptor to be validated
308 * DESCRIPTION: Perform parameter validation checks on an ACPI_BUFFER
310 ******************************************************************************/
313 AcpiUtValidateBuffer (
317 /* Obviously, the structure pointer must be valid */
321 return (AE_BAD_PARAMETER);
324 /* Special semantics for the length */
326 if ((Buffer->Length == ACPI_NO_BUFFER) ||
327 (Buffer->Length == ACPI_ALLOCATE_BUFFER) ||
328 (Buffer->Length == ACPI_ALLOCATE_LOCAL_BUFFER))
333 /* Length is valid, the buffer pointer must be also */
335 if (!Buffer->Pointer)
337 return (AE_BAD_PARAMETER);
344 /*******************************************************************************
346 * FUNCTION: AcpiUtInitializeBuffer
348 * PARAMETERS: RequiredLength - Length needed
349 * Buffer - Buffer to be validated
353 * DESCRIPTION: Validate that the buffer is of the required length or
354 * allocate a new buffer.
356 ******************************************************************************/
359 AcpiUtInitializeBuffer (
361 ACPI_SIZE RequiredLength)
363 ACPI_STATUS Status = AE_OK;
366 switch (Buffer->Length)
370 /* Set the exception and returned the required length */
372 Status = AE_BUFFER_OVERFLOW;
376 case ACPI_ALLOCATE_BUFFER:
378 /* Allocate a new buffer */
380 Buffer->Pointer = AcpiOsAllocate (RequiredLength);
381 if (!Buffer->Pointer)
383 return (AE_NO_MEMORY);
386 /* Clear the buffer */
388 ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
392 case ACPI_ALLOCATE_LOCAL_BUFFER:
394 /* Allocate a new buffer with local interface to allow tracking */
396 Buffer->Pointer = ACPI_MEM_ALLOCATE (RequiredLength);
397 if (!Buffer->Pointer)
399 return (AE_NO_MEMORY);
402 /* Clear the buffer */
404 ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
410 /* Validate the size of the buffer */
412 if (Buffer->Length < RequiredLength)
414 Status = AE_BUFFER_OVERFLOW;
419 Buffer->Length = RequiredLength;
424 /*******************************************************************************
426 * FUNCTION: AcpiUtAllocate
428 * PARAMETERS: Size - Size of the allocation
429 * Component - Component type of caller
430 * Module - Source file name of caller
431 * Line - Line number of caller
433 * RETURN: Address of the allocated memory on success, NULL on failure.
435 * DESCRIPTION: The subsystem's equivalent of malloc.
437 ******************************************************************************/
449 ACPI_FUNCTION_TRACE_U32 ("UtAllocate", Size);
452 /* Check for an inadvertent size of zero bytes */
456 _ACPI_REPORT_ERROR (Module, Line, Component,
457 ("UtAllocate: Attempt to allocate zero bytes\n"));
461 Allocation = AcpiOsAllocate (Size);
464 /* Report allocation error */
466 _ACPI_REPORT_ERROR (Module, Line, Component,
467 ("UtAllocate: Could not allocate size %X\n", (UINT32) Size));
472 return_PTR (Allocation);
476 /*******************************************************************************
478 * FUNCTION: AcpiUtCallocate
480 * PARAMETERS: Size - Size of the allocation
481 * Component - Component type of caller
482 * Module - Source file name of caller
483 * Line - Line number of caller
485 * RETURN: Address of the allocated memory on success, NULL on failure.
487 * DESCRIPTION: Subsystem equivalent of calloc.
489 ******************************************************************************/
501 ACPI_FUNCTION_TRACE_U32 ("UtCallocate", Size);
504 /* Check for an inadvertent size of zero bytes */
508 _ACPI_REPORT_ERROR (Module, Line, Component,
509 ("UtCallocate: Attempt to allocate zero bytes\n"));
513 Allocation = AcpiOsAllocate (Size);
516 /* Report allocation error */
518 _ACPI_REPORT_ERROR (Module, Line, Component,
519 ("UtCallocate: Could not allocate size %X\n", (UINT32) Size));
523 /* Clear the memory block */
525 ACPI_MEMSET (Allocation, 0, Size);
526 return_PTR (Allocation);
530 #ifdef ACPI_DBG_TRACK_ALLOCATIONS
532 * These procedures are used for tracking memory leaks in the subsystem, and
533 * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set.
535 * Each memory allocation is tracked via a doubly linked list. Each
536 * element contains the caller's component, module name, function name, and
537 * line number. AcpiUtAllocate and AcpiUtCallocate call
538 * AcpiUtTrackAllocation to add an element to the list; deletion
539 * occurs in the body of AcpiUtFree.
543 /*******************************************************************************
545 * FUNCTION: AcpiUtAllocateAndTrack
547 * PARAMETERS: Size - Size of the allocation
548 * Component - Component type of caller
549 * Module - Source file name of caller
550 * Line - Line number of caller
552 * RETURN: Address of the allocated memory on success, NULL on failure.
554 * DESCRIPTION: The subsystem's equivalent of malloc.
556 ******************************************************************************/
559 AcpiUtAllocateAndTrack (
565 ACPI_DEBUG_MEM_BLOCK *Allocation;
569 Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_BLOCK), Component,
576 Status = AcpiUtTrackAllocation (ACPI_MEM_LIST_GLOBAL, Allocation, Size,
577 ACPI_MEM_MALLOC, Component, Module, Line);
578 if (ACPI_FAILURE (Status))
580 AcpiOsFree (Allocation);
584 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalAllocated++;
585 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize += (UINT32) Size;
587 return ((void *) &Allocation->UserSpace);
591 /*******************************************************************************
593 * FUNCTION: AcpiUtCallocateAndTrack
595 * PARAMETERS: Size - Size of the allocation
596 * Component - Component type of caller
597 * Module - Source file name of caller
598 * Line - Line number of caller
600 * RETURN: Address of the allocated memory on success, NULL on failure.
602 * DESCRIPTION: Subsystem equivalent of calloc.
604 ******************************************************************************/
607 AcpiUtCallocateAndTrack (
613 ACPI_DEBUG_MEM_BLOCK *Allocation;
617 Allocation = AcpiUtCallocate (Size + sizeof (ACPI_DEBUG_MEM_BLOCK), Component,
621 /* Report allocation error */
623 _ACPI_REPORT_ERROR (Module, Line, Component,
624 ("UtCallocate: Could not allocate size %X\n", (UINT32) Size));
628 Status = AcpiUtTrackAllocation (ACPI_MEM_LIST_GLOBAL, Allocation, Size,
629 ACPI_MEM_CALLOC, Component, Module, Line);
630 if (ACPI_FAILURE (Status))
632 AcpiOsFree (Allocation);
636 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalAllocated++;
637 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize += (UINT32) Size;
639 return ((void *) &Allocation->UserSpace);
643 /*******************************************************************************
645 * FUNCTION: AcpiUtFreeAndTrack
647 * PARAMETERS: Allocation - Address of the memory to deallocate
648 * Component - Component type of caller
649 * Module - Source file name of caller
650 * Line - Line number of caller
654 * DESCRIPTION: Frees the memory at Allocation
656 ******************************************************************************/
665 ACPI_DEBUG_MEM_BLOCK *DebugBlock;
669 ACPI_FUNCTION_TRACE_PTR ("UtFree", Allocation);
672 if (NULL == Allocation)
674 _ACPI_REPORT_ERROR (Module, Line, Component,
675 ("AcpiUtFree: Attempt to delete a NULL address\n"));
680 DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK,
681 (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER)));
683 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalFreed++;
684 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize -= DebugBlock->Size;
686 Status = AcpiUtRemoveAllocation (ACPI_MEM_LIST_GLOBAL, DebugBlock,
687 Component, Module, Line);
688 if (ACPI_FAILURE (Status))
690 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not free memory, %s\n",
691 AcpiFormatException (Status)));
694 AcpiOsFree (DebugBlock);
696 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation));
702 /*******************************************************************************
704 * FUNCTION: AcpiUtFindAllocation
706 * PARAMETERS: Allocation - Address of allocated memory
708 * RETURN: A list element if found; NULL otherwise.
710 * DESCRIPTION: Searches for an element in the global allocation tracking list.
712 ******************************************************************************/
714 ACPI_DEBUG_MEM_BLOCK *
715 AcpiUtFindAllocation (
719 ACPI_DEBUG_MEM_BLOCK *Element;
722 ACPI_FUNCTION_ENTRY ();
725 if (ListId > ACPI_MEM_LIST_MAX)
730 Element = AcpiGbl_MemoryLists[ListId].ListHead;
732 /* Search for the address. */
736 if (Element == Allocation)
741 Element = Element->Next;
748 /*******************************************************************************
750 * FUNCTION: AcpiUtTrackAllocation
752 * PARAMETERS: Allocation - Address of allocated memory
753 * Size - Size of the allocation
754 * AllocType - MEM_MALLOC or MEM_CALLOC
755 * Component - Component type of caller
756 * Module - Source file name of caller
757 * Line - Line number of caller
761 * DESCRIPTION: Inserts an element into the global allocation tracking list.
763 ******************************************************************************/
766 AcpiUtTrackAllocation (
768 ACPI_DEBUG_MEM_BLOCK *Allocation,
775 ACPI_MEMORY_LIST *MemList;
776 ACPI_DEBUG_MEM_BLOCK *Element;
777 ACPI_STATUS Status = AE_OK;
780 ACPI_FUNCTION_TRACE_PTR ("UtTrackAllocation", Allocation);
783 if (ListId > ACPI_MEM_LIST_MAX)
785 return_ACPI_STATUS (AE_BAD_PARAMETER);
788 MemList = &AcpiGbl_MemoryLists[ListId];
789 Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
790 if (ACPI_FAILURE (Status))
792 return_ACPI_STATUS (Status);
796 * Search list for this address to make sure it is not already on the list.
797 * This will catch several kinds of problems.
800 Element = AcpiUtFindAllocation (ListId, Allocation);
803 ACPI_REPORT_ERROR (("UtTrackAllocation: Allocation already present in list! (%p)\n",
806 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", Element, Allocation));
811 /* Fill in the instance data. */
813 Allocation->Size = (UINT32) Size;
814 Allocation->AllocType = AllocType;
815 Allocation->Component = Component;
816 Allocation->Line = Line;
818 ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME);
820 /* Insert at list head */
822 if (MemList->ListHead)
824 ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation;
827 Allocation->Next = MemList->ListHead;
828 Allocation->Previous = NULL;
830 MemList->ListHead = Allocation;
834 Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
835 return_ACPI_STATUS (Status);
839 /*******************************************************************************
841 * FUNCTION: AcpiUtRemoveAllocation
843 * PARAMETERS: Allocation - Address of allocated memory
844 * Component - Component type of caller
845 * Module - Source file name of caller
846 * Line - Line number of caller
850 * DESCRIPTION: Deletes an element from the global allocation tracking list.
852 ******************************************************************************/
855 AcpiUtRemoveAllocation (
857 ACPI_DEBUG_MEM_BLOCK *Allocation,
862 ACPI_MEMORY_LIST *MemList;
866 ACPI_FUNCTION_TRACE ("UtRemoveAllocation");
869 if (ListId > ACPI_MEM_LIST_MAX)
871 return_ACPI_STATUS (AE_BAD_PARAMETER);
874 MemList = &AcpiGbl_MemoryLists[ListId];
875 if (NULL == MemList->ListHead)
877 /* No allocations! */
879 _ACPI_REPORT_ERROR (Module, Line, Component,
880 ("UtRemoveAllocation: Empty allocation list, nothing to free!\n"));
882 return_ACPI_STATUS (AE_OK);
885 Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
886 if (ACPI_FAILURE (Status))
888 return_ACPI_STATUS (Status);
893 if (Allocation->Previous)
895 (Allocation->Previous)->Next = Allocation->Next;
899 MemList->ListHead = Allocation->Next;
902 if (Allocation->Next)
904 (Allocation->Next)->Previous = Allocation->Previous;
907 /* Mark the segment as deleted */
909 ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size);
911 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", Allocation->Size));
913 Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
914 return_ACPI_STATUS (Status);
918 /*******************************************************************************
920 * FUNCTION: AcpiUtDumpAllocationInfo
926 * DESCRIPTION: Print some info about the outstanding allocations.
928 ******************************************************************************/
931 AcpiUtDumpAllocationInfo (
935 ACPI_MEMORY_LIST *MemList;
938 ACPI_FUNCTION_TRACE ("UtDumpAllocationInfo");
941 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
942 ("%30s: %4d (%3d Kb)\n", "Current allocations",
943 MemList->CurrentCount,
944 ROUND_UP_TO_1K (MemList->CurrentSize)));
946 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
947 ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations",
948 MemList->MaxConcurrentCount,
949 ROUND_UP_TO_1K (MemList->MaxConcurrentSize)));
952 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
953 ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",
955 ROUND_UP_TO_1K (RunningObjectSize)));
957 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
958 ("%30s: %4d (%3d Kb)\n", "Total (all) allocations",
960 ROUND_UP_TO_1K (RunningAllocSize)));
963 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
964 ("%30s: %4d (%3d Kb)\n", "Current Nodes",
965 AcpiGbl_CurrentNodeCount,
966 ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize)));
968 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
969 ("%30s: %4d (%3d Kb)\n", "Max Nodes",
970 AcpiGbl_MaxConcurrentNodeCount,
971 ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount * sizeof (ACPI_NAMESPACE_NODE)))));
977 /*******************************************************************************
979 * FUNCTION: AcpiUtDumpAllocations
981 * PARAMETERS: Component - Component(s) to dump info for.
982 * Module - Module to dump info for. NULL means all.
986 * DESCRIPTION: Print a list of all outstanding allocations.
988 ******************************************************************************/
991 AcpiUtDumpAllocations (
995 ACPI_DEBUG_MEM_BLOCK *Element;
996 ACPI_DESCRIPTOR *Descriptor;
997 UINT32 NumOutstanding = 0;
1000 ACPI_FUNCTION_TRACE ("UtDumpAllocations");
1004 * Walk the allocation list.
1006 if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY)))
1011 Element = AcpiGbl_MemoryLists[0].ListHead;
1014 if ((Element->Component & Component) &&
1015 ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module))))
1017 /* Ignore allocated objects that are in a cache */
1019 Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace);
1020 if (Descriptor->DescriptorId != ACPI_DESC_TYPE_CACHED)
1022 AcpiOsPrintf ("%p Len %04X %9.9s-%d [%s] ",
1023 Descriptor, Element->Size, Element->Module,
1024 Element->Line, AcpiUtGetDescriptorName (Descriptor));
1026 /* Most of the elements will be Operand objects. */
1028 switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor))
1030 case ACPI_DESC_TYPE_OPERAND:
1031 AcpiOsPrintf ("%12.12s R%hd",
1032 AcpiUtGetTypeName (Descriptor->Object.Common.Type),
1033 Descriptor->Object.Common.ReferenceCount);
1036 case ACPI_DESC_TYPE_PARSER:
1037 AcpiOsPrintf ("AmlOpcode %04hX",
1038 Descriptor->Op.Asl.AmlOpcode);
1041 case ACPI_DESC_TYPE_NAMED:
1042 AcpiOsPrintf ("%4.4s",
1043 AcpiUtGetNodeName (&Descriptor->Node));
1050 AcpiOsPrintf ( "\n");
1054 Element = Element->Next;
1057 (void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
1061 if (!NumOutstanding)
1063 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
1064 "No outstanding allocations.\n"));
1068 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
1069 "%d(%X) Outstanding allocations\n",
1070 NumOutstanding, NumOutstanding));
1077 #endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */