Update of debug levels and defines

date	2002.11.27.17.47.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 18:58:33 +00:00
parent 726e94e95a
commit 31313c03b4
2 changed files with 123 additions and 83 deletions

View File

@ -2,7 +2,7 @@
*
* Module Name: tbxface - Public interfaces to the ACPI subsystem
* ACPI table oriented interfaces
* $Revision: 1.59 $
* $Revision: 1.60 $
*
*****************************************************************************/
@ -192,7 +192,7 @@ AcpiLoadTables (void)
goto ErrorExit;
}
ACPI_DEBUG_PRINT ((ACPI_DB_OK, "ACPI Tables successfully acquired\n"));
ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
/* Load the namespace from the tables */

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: utalloc - local cache and memory allocation routines
* $Revision: 1.116 $
* $Revision: 1.128 $
*
*****************************************************************************/
@ -117,13 +117,9 @@
#define __UTALLOC_C__
#include "acpi.h"
#include "acparser.h"
#include "acinterp.h"
#include "acnamesp.h"
#include "acglobal.h"
#define _COMPONENT ACPI_UTILITIES
MODULE_NAME ("utalloc")
ACPI_MODULE_NAME ("utalloc")
/******************************************************************************
@ -148,7 +144,7 @@ AcpiUtReleaseToCache (
ACPI_MEMORY_LIST *CacheInfo;
FUNCTION_ENTRY ();
ACPI_FUNCTION_ENTRY ();
/* If walk cache is full, just free this wallkstate object */
@ -164,20 +160,23 @@ AcpiUtReleaseToCache (
else
{
AcpiUtAcquireMutex (ACPI_MTX_CACHES);
if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES)))
{
return;
}
/* Mark the object as cached */
MEMSET (Object, 0xCA, CacheInfo->ObjectSize);
ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_CACHED_OBJECT);
ACPI_MEMSET (Object, 0xCA, CacheInfo->ObjectSize);
ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_DESC_TYPE_CACHED);
/* Put the object at the head of the cache list */
* (char **) (((char *) Object) + CacheInfo->LinkOffset) = CacheInfo->ListHead;
* (ACPI_CAST_INDIRECT_PTR (char, &(((char *) Object)[CacheInfo->LinkOffset]))) = CacheInfo->ListHead;
CacheInfo->ListHead = Object;
CacheInfo->CacheDepth++;
AcpiUtReleaseMutex (ACPI_MTX_CACHES);
(void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
}
}
@ -204,11 +203,15 @@ AcpiUtAcquireFromCache (
void *Object;
PROC_NAME ("UtAcquireFromCache");
ACPI_FUNCTION_NAME ("UtAcquireFromCache");
CacheInfo = &AcpiGbl_MemoryLists[ListId];
AcpiUtAcquireMutex (ACPI_MTX_CACHES);
if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES)))
{
return (NULL);
}
ACPI_MEM_TRACKING (CacheInfo->CacheRequests++);
/* Check the cache first */
@ -218,7 +221,7 @@ AcpiUtAcquireFromCache (
/* There is an object available, use it */
Object = CacheInfo->ListHead;
CacheInfo->ListHead = * (char **) (((char *) Object) + CacheInfo->LinkOffset);
CacheInfo->ListHead = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) Object)[CacheInfo->LinkOffset])));
ACPI_MEM_TRACKING (CacheInfo->CacheHits++);
CacheInfo->CacheDepth--;
@ -228,11 +231,14 @@ AcpiUtAcquireFromCache (
Object, AcpiGbl_MemoryLists[ListId].ListName));
#endif
AcpiUtReleaseMutex (ACPI_MTX_CACHES);
if (ACPI_FAILURE (AcpiUtReleaseMutex (ACPI_MTX_CACHES)))
{
return (NULL);
}
/* Clear (zero) the previously used Object */
MEMSET (Object, 0, CacheInfo->ObjectSize);
ACPI_MEMSET (Object, 0, CacheInfo->ObjectSize);
}
else
@ -241,7 +247,10 @@ AcpiUtAcquireFromCache (
/* Avoid deadlock with ACPI_MEM_CALLOCATE */
AcpiUtReleaseMutex (ACPI_MTX_CACHES);
if (ACPI_FAILURE (AcpiUtReleaseMutex (ACPI_MTX_CACHES)))
{
return (NULL);
}
Object = ACPI_MEM_CALLOCATE (CacheInfo->ObjectSize);
ACPI_MEM_TRACKING (CacheInfo->TotalAllocated++);
@ -271,7 +280,7 @@ AcpiUtDeleteGenericCache (
char *Next;
FUNCTION_ENTRY ();
ACPI_FUNCTION_ENTRY ();
CacheInfo = &AcpiGbl_MemoryLists[ListId];
@ -279,7 +288,7 @@ AcpiUtDeleteGenericCache (
{
/* Delete one cached state object */
Next = * (char **) (((char *) CacheInfo->ListHead) + CacheInfo->LinkOffset);
Next = *(ACPI_CAST_INDIRECT_PTR (char, &(((char *) CacheInfo->ListHead)[CacheInfo->LinkOffset])));
ACPI_MEM_FREE (CacheInfo->ListHead);
CacheInfo->ListHead = Next;
@ -288,7 +297,6 @@ AcpiUtDeleteGenericCache (
}
/*******************************************************************************
*
* FUNCTION: AcpiUtValidateBuffer
@ -366,7 +374,6 @@ AcpiUtInitializeBuffer (
case ACPI_ALLOCATE_BUFFER:
case ACPI_ALLOCATE_LOCAL_BUFFER:
/* Allocate a new buffer */
@ -378,7 +385,23 @@ AcpiUtInitializeBuffer (
/* Clear the buffer */
MEMSET (Buffer->Pointer, 0, RequiredLength);
ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
break;
case ACPI_ALLOCATE_LOCAL_BUFFER:
/* Allocate a new buffer with local interface to allow tracking */
Buffer->Pointer = ACPI_MEM_ALLOCATE (RequiredLength);
if (!Buffer->Pointer)
{
return (AE_NO_MEMORY);
}
/* Clear the buffer */
ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
break;
@ -393,7 +416,7 @@ AcpiUtInitializeBuffer (
/* Clear the buffer */
MEMSET (Buffer->Pointer, 0, RequiredLength);
ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
break;
}
@ -427,14 +450,14 @@ AcpiUtAllocate (
void *Allocation;
FUNCTION_TRACE_U32 ("UtAllocate", Size);
ACPI_FUNCTION_TRACE_U32 ("UtAllocate", Size);
/* Check for an inadvertent size of zero bytes */
if (!Size)
{
_REPORT_ERROR (Module, Line, Component,
_ACPI_REPORT_ERROR (Module, Line, Component,
("UtAllocate: Attempt to allocate zero bytes\n"));
Size = 1;
}
@ -444,8 +467,8 @@ AcpiUtAllocate (
{
/* Report allocation error */
_REPORT_ERROR (Module, Line, Component,
("UtAllocate: Could not allocate size %X\n", Size));
_ACPI_REPORT_ERROR (Module, Line, Component,
("UtAllocate: Could not allocate size %X\n", (UINT32) Size));
return_PTR (NULL);
}
@ -479,14 +502,14 @@ AcpiUtCallocate (
void *Allocation;
FUNCTION_TRACE_U32 ("UtCallocate", Size);
ACPI_FUNCTION_TRACE_U32 ("UtCallocate", Size);
/* Check for an inadvertent size of zero bytes */
if (!Size)
{
_REPORT_ERROR (Module, Line, Component,
_ACPI_REPORT_ERROR (Module, Line, Component,
("UtCallocate: Attempt to allocate zero bytes\n"));
return_PTR (NULL);
}
@ -496,20 +519,18 @@ AcpiUtCallocate (
{
/* Report allocation error */
_REPORT_ERROR (Module, Line, Component,
("UtCallocate: Could not allocate size %X\n", Size));
_ACPI_REPORT_ERROR (Module, Line, Component,
("UtCallocate: Could not allocate size %X\n", (UINT32) Size));
return_PTR (NULL);
}
/* Clear the memory block */
MEMSET (Allocation, 0, Size);
ACPI_MEMSET (Allocation, 0, Size);
return_PTR (Allocation);
}
#ifdef ACPI_DBG_TRACK_ALLOCATIONS
/*
* These procedures are used for tracking memory leaks in the subsystem, and
@ -523,7 +544,6 @@ AcpiUtCallocate (
*/
/*******************************************************************************
*
* FUNCTION: AcpiUtAllocateAndTrack
@ -550,7 +570,6 @@ AcpiUtAllocateAndTrack (
ACPI_STATUS Status;
Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_BLOCK), Component,
Module, Line);
if (!Allocation)
@ -559,7 +578,7 @@ AcpiUtAllocateAndTrack (
}
Status = AcpiUtTrackAllocation (ACPI_MEM_LIST_GLOBAL, Allocation, Size,
MEM_MALLOC, Component, Module, Line);
ACPI_MEM_MALLOC, Component, Module, Line);
if (ACPI_FAILURE (Status))
{
AcpiOsFree (Allocation);
@ -573,7 +592,6 @@ AcpiUtAllocateAndTrack (
}
/*******************************************************************************
*
* FUNCTION: AcpiUtCallocateAndTrack
@ -600,20 +618,19 @@ AcpiUtCallocateAndTrack (
ACPI_STATUS Status;
Allocation = AcpiUtCallocate (Size + sizeof (ACPI_DEBUG_MEM_BLOCK), Component,
Module, Line);
if (!Allocation)
{
/* Report allocation error */
_REPORT_ERROR (Module, Line, Component,
("UtCallocate: Could not allocate size %X\n", Size));
_ACPI_REPORT_ERROR (Module, Line, Component,
("UtCallocate: Could not allocate size %X\n", (UINT32) Size));
return (NULL);
}
Status = AcpiUtTrackAllocation (ACPI_MEM_LIST_GLOBAL, Allocation, Size,
MEM_CALLOC, Component, Module, Line);
ACPI_MEM_CALLOC, Component, Module, Line);
if (ACPI_FAILURE (Status))
{
AcpiOsFree (Allocation);
@ -650,27 +667,34 @@ AcpiUtFreeAndTrack (
UINT32 Line)
{
ACPI_DEBUG_MEM_BLOCK *DebugBlock;
ACPI_STATUS Status;
FUNCTION_TRACE_PTR ("UtFree", Allocation);
ACPI_FUNCTION_TRACE_PTR ("UtFree", Allocation);
if (NULL == Allocation)
{
_REPORT_ERROR (Module, Line, Component,
_ACPI_REPORT_ERROR (Module, Line, Component,
("AcpiUtFree: Attempt to delete a NULL address\n"));
return_VOID;
}
DebugBlock = (ACPI_DEBUG_MEM_BLOCK *)
(((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER));
DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK,
(((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER)));
AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalFreed++;
AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize -= DebugBlock->Size;
AcpiUtRemoveAllocation (ACPI_MEM_LIST_GLOBAL, DebugBlock,
Component, Module, Line);
Status = AcpiUtRemoveAllocation (ACPI_MEM_LIST_GLOBAL, DebugBlock,
Component, Module, Line);
if (ACPI_FAILURE (Status))
{
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not free memory, %s\n",
AcpiFormatException (Status)));
}
AcpiOsFree (DebugBlock);
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation));
@ -679,7 +703,6 @@ AcpiUtFreeAndTrack (
}
/*******************************************************************************
*
* FUNCTION: AcpiUtFindAllocation
@ -700,7 +723,7 @@ AcpiUtFindAllocation (
ACPI_DEBUG_MEM_BLOCK *Element;
FUNCTION_ENTRY ();
ACPI_FUNCTION_ENTRY ();
if (ListId > ACPI_MEM_LIST_MAX)
@ -758,7 +781,7 @@ AcpiUtTrackAllocation (
ACPI_STATUS Status = AE_OK;
FUNCTION_TRACE_PTR ("UtTrackAllocation", Allocation);
ACPI_FUNCTION_TRACE_PTR ("UtTrackAllocation", Allocation);
if (ListId > ACPI_MEM_LIST_MAX)
@ -767,7 +790,11 @@ AcpiUtTrackAllocation (
}
MemList = &AcpiGbl_MemoryLists[ListId];
AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
/*
* Search list for this address to make sure it is not already on the list.
@ -777,7 +804,7 @@ AcpiUtTrackAllocation (
Element = AcpiUtFindAllocation (ListId, Allocation);
if (Element)
{
REPORT_ERROR (("UtTrackAllocation: Allocation already present in list! (%p)\n",
ACPI_REPORT_ERROR (("UtTrackAllocation: Allocation already present in list! (%p)\n",
Allocation));
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", Element, Allocation));
@ -792,7 +819,7 @@ AcpiUtTrackAllocation (
Allocation->Component = Component;
Allocation->Line = Line;
STRNCPY (Allocation->Module, Module, MAX_MODULE_NAME);
ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME);
/* Insert at list head */
@ -808,7 +835,7 @@ AcpiUtTrackAllocation (
UnlockAndExit:
AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
return_ACPI_STATUS (Status);
}
@ -837,9 +864,10 @@ AcpiUtRemoveAllocation (
UINT32 Line)
{
ACPI_MEMORY_LIST *MemList;
ACPI_STATUS Status;
FUNCTION_TRACE ("UtRemoveAllocation");
ACPI_FUNCTION_TRACE ("UtRemoveAllocation");
if (ListId > ACPI_MEM_LIST_MAX)
@ -852,13 +880,17 @@ AcpiUtRemoveAllocation (
{
/* No allocations! */
_REPORT_ERROR (Module, Line, Component,
_ACPI_REPORT_ERROR (Module, Line, Component,
("UtRemoveAllocation: Empty allocation list, nothing to free!\n"));
return_ACPI_STATUS (AE_OK);
}
AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
/* Unlink */
@ -878,12 +910,12 @@ AcpiUtRemoveAllocation (
/* Mark the segment as deleted */
MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size);
ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size);
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size %X\n", Allocation->Size));
AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
return_ACPI_STATUS (AE_OK);
Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
return_ACPI_STATUS (Status);
}
@ -907,7 +939,7 @@ AcpiUtDumpAllocationInfo (
ACPI_MEMORY_LIST *MemList;
*/
FUNCTION_TRACE ("UtDumpAllocationInfo");
ACPI_FUNCTION_TRACE ("UtDumpAllocationInfo");
/*
ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
@ -965,49 +997,54 @@ AcpiUtDumpAllocations (
NATIVE_CHAR *Module)
{
ACPI_DEBUG_MEM_BLOCK *Element;
ACPI_DESCRIPTOR *Descriptor;
UINT32 NumOutstanding = 0;
FUNCTION_TRACE ("UtDumpAllocations");
ACPI_FUNCTION_TRACE ("UtDumpAllocations");
/*
* Walk the allocation list.
*/
AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY)))
{
return;
}
Element = AcpiGbl_MemoryLists[0].ListHead;
while (Element)
{
if ((Element->Component & Component) &&
((Module == NULL) || (0 == STRCMP (Module, Element->Module))))
((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module))))
{
/* Ignore allocated objects that are in a cache */
if (((ACPI_OPERAND_OBJECT *)(&Element->UserSpace))->Common.Type != ACPI_CACHED_OBJECT)
Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace);
if (Descriptor->DescriptorId != ACPI_DESC_TYPE_CACHED)
{
AcpiOsPrintf ("%p Len %04X %9.9s-%d ",
&Element->UserSpace, Element->Size, Element->Module,
Descriptor, Element->Size, Element->Module,
Element->Line);
/* Most of the elements will be internal objects. */
switch (ACPI_GET_DESCRIPTOR_TYPE (&Element->UserSpace))
switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor))
{
case ACPI_DESC_TYPE_INTERNAL:
AcpiOsPrintf ("ObjType %12.12s R%d",
AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *)(&Element->UserSpace))->Common.Type),
((ACPI_OPERAND_OBJECT *)(&Element->UserSpace))->Common.ReferenceCount);
case ACPI_DESC_TYPE_OPERAND:
AcpiOsPrintf ("ObjType %12.12s R%hd",
AcpiUtGetTypeName (Descriptor->Object.Common.Type),
Descriptor->Object.Common.ReferenceCount);
break;
case ACPI_DESC_TYPE_PARSER:
AcpiOsPrintf ("ParseObj Opcode %04X",
((ACPI_PARSE_OBJECT *)(&Element->UserSpace))->Opcode);
AcpiOsPrintf ("ParseObj AmlOpcode %04hX",
Descriptor->Op.Asl.AmlOpcode);
break;
case ACPI_DESC_TYPE_NAMED:
AcpiOsPrintf ("Node %4.4s",
(char *) &((ACPI_NAMESPACE_NODE *)(&Element->UserSpace))->Name);
Descriptor->Node.Name.Ascii);
break;
case ACPI_DESC_TYPE_STATE:
@ -1049,6 +1086,10 @@ AcpiUtDumpAllocations (
case ACPI_DESC_TYPE_STATE_THREAD:
AcpiOsPrintf ("THREAD StateObj");
break;
default:
/* All types should appear above */
break;
}
AcpiOsPrintf ( "\n");
@ -1058,18 +1099,18 @@ AcpiUtDumpAllocations (
Element = Element->Next;
}
AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
(void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
/* Print summary */
if (!NumOutstanding)
{
ACPI_DEBUG_PRINT ((ACPI_DB_OK,
"No outstanding allocations.\n"));
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"No outstanding allocations.\n"));
}
else
{
ACPI_DEBUG_PRINT ((ACPI_DB_OK,
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
"%d(%X) Outstanding allocations\n",
NumOutstanding, NumOutstanding));
}
@ -1078,6 +1119,5 @@ AcpiUtDumpAllocations (
}
#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */