1/****************************************************************************** 2 * 3 * Module Name: utalloc - local cache and memory allocation routines |
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. --- 99 unchanged lines hidden (view full) --- 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 121#define _COMPONENT ACPI_UTILITIES 122 ACPI_MODULE_NAME ("utalloc") 123 124 125/****************************************************************************** 126 * 127 * FUNCTION: AcpiUtReleaseToCache --- 35 unchanged lines hidden (view full) --- 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); |
171 ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_CACHED); |
172 173 /* Put the object at the head of the cache list */ 174 |
175 * (ACPI_CAST_INDIRECT_PTR (char, &(((char *) Object)[CacheInfo->LinkOffset]))) = CacheInfo->ListHead; |
176 CacheInfo->ListHead = Object; 177 CacheInfo->CacheDepth++; 178 179 (void) AcpiUtReleaseMutex (ACPI_MTX_CACHES); 180 } 181} 182 183 --- 32 unchanged lines hidden (view full) --- 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; |
224 CacheInfo->ListHead = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) Object)[CacheInfo->LinkOffset]))); |
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 --- 50 unchanged lines hidden (view full) --- 283 ACPI_FUNCTION_ENTRY (); 284 285 286 CacheInfo = &AcpiGbl_MemoryLists[ListId]; 287 while (CacheInfo->ListHead) 288 { 289 /* Delete one cached state object */ 290 |
291 Next = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) CacheInfo->ListHead)[CacheInfo->LinkOffset]))); |
292 ACPI_MEM_FREE (CacheInfo->ListHead); 293 294 CacheInfo->ListHead = Next; 295 CacheInfo->CacheDepth--; 296 } 297} 298 299 --- 163 unchanged lines hidden (view full) --- 463 } 464 465 Allocation = AcpiOsAllocate (Size); 466 if (!Allocation) 467 { 468 /* Report allocation error */ 469 470 _ACPI_REPORT_ERROR (Module, Line, Component, |
471 ("UtAllocate: Could not allocate size %X\n", (UINT32) Size)); |
472 473 return_PTR (NULL); 474 } 475 476 return_PTR (Allocation); 477} 478 479 --- 35 unchanged lines hidden (view full) --- 515 } 516 517 Allocation = AcpiOsAllocate (Size); 518 if (!Allocation) 519 { 520 /* Report allocation error */ 521 522 _ACPI_REPORT_ERROR (Module, Line, Component, |
523 ("UtCallocate: Could not allocate size %X\n", (UINT32) Size)); |
524 return_PTR (NULL); 525 } 526 527 /* Clear the memory block */ 528 529 ACPI_MEMSET (Allocation, 0, Size); 530 return_PTR (Allocation); 531} --- 88 unchanged lines hidden (view full) --- 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, |
628 ("UtCallocate: Could not allocate size %X\n", (UINT32) Size)); |
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); --- 25 unchanged lines hidden (view full) --- 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; |
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 |
684 DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK, 685 (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER))); |
686 687 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalFreed++; 688 AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize -= DebugBlock->Size; 689 |
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 |
698 AcpiOsFree (DebugBlock); 699 700 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation)); 701 702 return_VOID; 703} 704 705 --- 286 unchanged lines hidden (view full) --- 992 ******************************************************************************/ 993 994void 995AcpiUtDumpAllocations ( 996 UINT32 Component, 997 NATIVE_CHAR *Module) 998{ 999 ACPI_DEBUG_MEM_BLOCK *Element; |
1000 ACPI_DESCRIPTOR *Descriptor; |
1001 UINT32 NumOutstanding = 0; 1002 1003 1004 ACPI_FUNCTION_TRACE ("UtDumpAllocations"); 1005 1006 1007 /* 1008 * Walk the allocation list. --- 6 unchanged lines hidden (view full) --- 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 |
1023 Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace); 1024 if (Descriptor->DescriptorId != ACPI_DESC_TYPE_CACHED) |
1025 { 1026 AcpiOsPrintf ("%p Len %04X %9.9s-%d ", |
1027 Descriptor, Element->Size, Element->Module, |
1028 Element->Line); 1029 1030 /* Most of the elements will be internal objects. */ 1031 |
1032 switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor)) |
1033 { |
1034 case ACPI_DESC_TYPE_OPERAND: 1035 AcpiOsPrintf ("ObjType %12.12s R%hd", 1036 AcpiUtGetTypeName (Descriptor->Object.Common.Type), 1037 Descriptor->Object.Common.ReferenceCount); |
1038 break; 1039 1040 case ACPI_DESC_TYPE_PARSER: |
1041 AcpiOsPrintf ("ParseObj AmlOpcode %04hX", 1042 Descriptor->Op.Asl.AmlOpcode); |
1043 break; 1044 1045 case ACPI_DESC_TYPE_NAMED: 1046 AcpiOsPrintf ("Node %4.4s", |
1047 Descriptor->Node.Name.Ascii); |
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"); --- 25 unchanged lines hidden (view full) --- 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; |
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, |
1109 "No outstanding allocations.\n")); |
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 |