Deleted Added
sdiff udiff text old ( 91116 ) new ( 99679 )
full compact
1/******************************************************************************
2 *
3 * Module Name: utalloc - local cache and memory allocation routines
4 * $Revision: 121 $
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#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

--- 35 unchanged lines hidden (view full) ---

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);
175 ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_CACHED_OBJECT);
176
177 /* Put the object at the head of the cache list */
178
179 * (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

--- 32 unchanged lines hidden (view full) ---

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;
228 CacheInfo->ListHead = * (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

--- 50 unchanged lines hidden (view full) ---

287 ACPI_FUNCTION_ENTRY ();
288
289
290 CacheInfo = &AcpiGbl_MemoryLists[ListId];
291 while (CacheInfo->ListHead)
292 {
293 /* Delete one cached state object */
294
295 Next = * (char **) (((char *) CacheInfo->ListHead) + CacheInfo->LinkOffset);
296 ACPI_MEM_FREE (CacheInfo->ListHead);
297
298 CacheInfo->ListHead = Next;
299 CacheInfo->CacheDepth--;
300 }
301}
302
303

--- 163 unchanged lines hidden (view full) ---

467 }
468
469 Allocation = AcpiOsAllocate (Size);
470 if (!Allocation)
471 {
472 /* Report allocation error */
473
474 _ACPI_REPORT_ERROR (Module, Line, Component,
475 ("UtAllocate: Could not allocate size %X\n", Size));
476
477 return_PTR (NULL);
478 }
479
480 return_PTR (Allocation);
481}
482
483

--- 35 unchanged lines hidden (view full) ---

519 }
520
521 Allocation = AcpiOsAllocate (Size);
522 if (!Allocation)
523 {
524 /* Report allocation error */
525
526 _ACPI_REPORT_ERROR (Module, Line, Component,
527 ("UtCallocate: Could not allocate size %X\n", Size));
528 return_PTR (NULL);
529 }
530
531 /* Clear the memory block */
532
533 ACPI_MEMSET (Allocation, 0, Size);
534 return_PTR (Allocation);
535}

--- 88 unchanged lines hidden (view full) ---

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,
632 ("UtCallocate: Could not allocate size %X\n", 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);

--- 25 unchanged lines hidden (view full) ---

666void
667AcpiUtFreeAndTrack (
668 void *Allocation,
669 UINT32 Component,
670 NATIVE_CHAR *Module,
671 UINT32 Line)
672{
673 ACPI_DEBUG_MEM_BLOCK *DebugBlock;
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
687 DebugBlock = (ACPI_DEBUG_MEM_BLOCK *)
688 (((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
693 AcpiUtRemoveAllocation (ACPI_MEM_LIST_GLOBAL, DebugBlock,
694 Component, Module, Line);
695 AcpiOsFree (DebugBlock);
696
697 ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation));
698
699 return_VOID;
700}
701
702

--- 286 unchanged lines hidden (view full) ---

989 ******************************************************************************/
990
991void
992AcpiUtDumpAllocations (
993 UINT32 Component,
994 NATIVE_CHAR *Module)
995{
996 ACPI_DEBUG_MEM_BLOCK *Element;
997 UINT32 NumOutstanding = 0;
998
999
1000 ACPI_FUNCTION_TRACE ("UtDumpAllocations");
1001
1002
1003 /*
1004 * Walk the allocation list.

--- 6 unchanged lines hidden (view full) ---

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
1019 if (((ACPI_OPERAND_OBJECT *)(&Element->UserSpace))->Common.Type != ACPI_CACHED_OBJECT)
1020 {
1021 AcpiOsPrintf ("%p Len %04X %9.9s-%d ",
1022 &Element->UserSpace, Element->Size, Element->Module,
1023 Element->Line);
1024
1025 /* Most of the elements will be internal objects. */
1026
1027 switch (ACPI_GET_DESCRIPTOR_TYPE (&Element->UserSpace))
1028 {
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);
1033 break;
1034
1035 case ACPI_DESC_TYPE_PARSER:
1036 AcpiOsPrintf ("ParseObj Opcode %04X",
1037 ((ACPI_PARSE_OBJECT *)(&Element->UserSpace))->Opcode);
1038 break;
1039
1040 case ACPI_DESC_TYPE_NAMED:
1041 AcpiOsPrintf ("Node %4.4s",
1042 (char *) &((ACPI_NAMESPACE_NODE *)(&Element->UserSpace))->Name);
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");

--- 25 unchanged lines hidden (view full) ---

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;
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,
1100 "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