2000-10-28 05:01:06 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2001-08-26 22:28:18 +00:00
|
|
|
* Module Name: utalloc - local cache and memory allocation routines
|
2002-02-23 05:10:40 +00:00
|
|
|
* $Revision: 121 $
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* 1. Copyright Notice
|
|
|
|
*
|
2002-02-23 05:10:40 +00:00
|
|
|
* Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
|
2000-12-21 06:56:46 +00:00
|
|
|
* All rights reserved.
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* 2. License
|
|
|
|
*
|
|
|
|
* 2.1. This is your license from Intel Corp. under its intellectual property
|
|
|
|
* rights. You may have additional license terms from the party that provided
|
|
|
|
* you this software, covering your right to use that party's intellectual
|
|
|
|
* property rights.
|
|
|
|
*
|
|
|
|
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
|
|
|
|
* copy of the source code appearing in this file ("Covered Code") an
|
|
|
|
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
|
|
|
|
* base code distributed originally by Intel ("Original Intel Code") to copy,
|
|
|
|
* make derivatives, distribute, use and display any portion of the Covered
|
|
|
|
* Code in any form, with the right to sublicense such rights; and
|
|
|
|
*
|
|
|
|
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
|
|
|
|
* license (with the right to sublicense), under only those claims of Intel
|
|
|
|
* patents that are infringed by the Original Intel Code, to make, use, sell,
|
|
|
|
* offer to sell, and import the Covered Code and derivative works thereof
|
|
|
|
* solely to the minimum extent necessary to exercise the above copyright
|
|
|
|
* license, and in no event shall the patent license extend to any additions
|
|
|
|
* to or modifications of the Original Intel Code. No other license or right
|
|
|
|
* is granted directly or by implication, estoppel or otherwise;
|
|
|
|
*
|
|
|
|
* The above copyright and patent license is granted only if the following
|
|
|
|
* conditions are met:
|
|
|
|
*
|
|
|
|
* 3. Conditions
|
|
|
|
*
|
|
|
|
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
|
|
|
|
* Redistribution of source code of any substantial portion of the Covered
|
|
|
|
* Code or modification with rights to further distribute source must include
|
|
|
|
* the above Copyright Notice, the above License, this list of Conditions,
|
|
|
|
* and the following Disclaimer and Export Compliance provision. In addition,
|
|
|
|
* Licensee must cause all Covered Code to which Licensee contributes to
|
|
|
|
* contain a file documenting the changes Licensee made to create that Covered
|
|
|
|
* Code and the date of any change. Licensee must include in that file the
|
|
|
|
* documentation of any changes made by any predecessor Licensee. Licensee
|
|
|
|
* must include a prominent statement that the modification is derived,
|
|
|
|
* directly or indirectly, from Original Intel Code.
|
|
|
|
*
|
|
|
|
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
|
|
|
|
* Redistribution of source code of any substantial portion of the Covered
|
|
|
|
* Code or modification without rights to further distribute source must
|
|
|
|
* include the following Disclaimer and Export Compliance provision in the
|
|
|
|
* documentation and/or other materials provided with distribution. In
|
|
|
|
* addition, Licensee may not authorize further sublicense of source of any
|
|
|
|
* portion of the Covered Code, and must include terms to the effect that the
|
|
|
|
* license from Licensee to its licensee is limited to the intellectual
|
|
|
|
* property embodied in the software Licensee provides to its licensee, and
|
|
|
|
* not to intellectual property embodied in modifications its licensee may
|
|
|
|
* make.
|
|
|
|
*
|
|
|
|
* 3.3. Redistribution of Executable. Redistribution in executable form of any
|
|
|
|
* substantial portion of the Covered Code or modification must reproduce the
|
|
|
|
* above Copyright Notice, and the following Disclaimer and Export Compliance
|
|
|
|
* provision in the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* 3.4. Intel retains all right, title, and interest in and to the Original
|
|
|
|
* Intel Code.
|
|
|
|
*
|
|
|
|
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
|
|
|
|
* Intel shall be used in advertising or otherwise to promote the sale, use or
|
|
|
|
* other dealings in products derived from or relating to the Covered Code
|
|
|
|
* without prior written authorization from Intel.
|
|
|
|
*
|
|
|
|
* 4. Disclaimer and Export Compliance
|
|
|
|
*
|
|
|
|
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
|
|
|
|
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
|
|
|
|
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
|
|
|
|
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
|
|
|
|
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
|
|
|
|
* PARTICULAR PURPOSE.
|
|
|
|
*
|
|
|
|
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
|
|
|
|
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
|
|
|
|
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
|
|
|
|
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
|
|
|
|
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
|
|
|
|
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
|
|
|
|
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
|
|
|
|
* LIMITED REMEDY.
|
|
|
|
*
|
|
|
|
* 4.3. Licensee shall not export, either directly or indirectly, any of this
|
|
|
|
* software or system incorporating such software without first obtaining any
|
|
|
|
* required license or other approval from the U. S. Department of Commerce or
|
|
|
|
* any other agency or department of the United States Government. In the
|
|
|
|
* event Licensee exports any such software from the United States or
|
|
|
|
* re-exports any such software from a foreign destination, Licensee shall
|
|
|
|
* ensure that the distribution and export/re-export of the software is in
|
|
|
|
* compliance with all laws, regulations, orders, or other restrictions of the
|
|
|
|
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
|
|
|
|
* any of its subsidiaries will export/re-export any technical data, process,
|
|
|
|
* software, or service, directly or indirectly, to any country for which the
|
|
|
|
* United States government or any agency thereof requires an export license,
|
|
|
|
* other governmental approval, or letter of assurance, without first obtaining
|
|
|
|
* such license, approval or letter.
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
#define __UTALLOC_C__
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
#include "acpi.h"
|
|
|
|
#include "acparser.h"
|
|
|
|
#include "acinterp.h"
|
|
|
|
#include "acnamesp.h"
|
|
|
|
#include "acglobal.h"
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
#define _COMPONENT ACPI_UTILITIES
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_MODULE_NAME ("utalloc")
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiUtReleaseToCache
|
|
|
|
*
|
|
|
|
* PARAMETERS: ListId - Memory list/cache ID
|
|
|
|
* Object - The object to be released
|
|
|
|
*
|
|
|
|
* RETURN: None
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Release an object to the specified cache. If cache is full,
|
|
|
|
* the object is deleted.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
AcpiUtReleaseToCache (
|
|
|
|
UINT32 ListId,
|
|
|
|
void *Object)
|
|
|
|
{
|
|
|
|
ACPI_MEMORY_LIST *CacheInfo;
|
|
|
|
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_FUNCTION_ENTRY ();
|
2001-09-07 01:22:25 +00:00
|
|
|
|
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
/* If walk cache is full, just free this wallkstate object */
|
|
|
|
|
|
|
|
CacheInfo = &AcpiGbl_MemoryLists[ListId];
|
|
|
|
if (CacheInfo->CacheDepth >= CacheInfo->MaxCacheDepth)
|
|
|
|
{
|
|
|
|
ACPI_MEM_FREE (Object);
|
|
|
|
ACPI_MEM_TRACKING (CacheInfo->TotalFreed++);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Otherwise put this object back into the cache */
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
2002-02-23 05:10:40 +00:00
|
|
|
if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES)))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2001-08-26 22:28:18 +00:00
|
|
|
|
|
|
|
/* Mark the object as cached */
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_MEMSET (Object, 0xCA, CacheInfo->ObjectSize);
|
|
|
|
ACPI_SET_DESCRIPTOR_TYPE (Object, ACPI_CACHED_OBJECT);
|
2001-08-26 22:28:18 +00:00
|
|
|
|
|
|
|
/* Put the object at the head of the cache list */
|
|
|
|
|
|
|
|
* (char **) (((char *) Object) + CacheInfo->LinkOffset) = CacheInfo->ListHead;
|
|
|
|
CacheInfo->ListHead = Object;
|
|
|
|
CacheInfo->CacheDepth++;
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
(void) AcpiUtReleaseMutex (ACPI_MTX_CACHES);
|
2001-08-26 22:28:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiUtAcquireFromCache
|
|
|
|
*
|
|
|
|
* PARAMETERS: ListId - Memory list ID
|
|
|
|
*
|
2001-09-07 01:22:25 +00:00
|
|
|
* RETURN: A requested object. NULL if the object could not be
|
2001-08-26 22:28:18 +00:00
|
|
|
* allocated.
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Get an object from the specified cache. If cache is empty,
|
|
|
|
* the object is allocated.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
void *
|
|
|
|
AcpiUtAcquireFromCache (
|
|
|
|
UINT32 ListId)
|
|
|
|
{
|
|
|
|
ACPI_MEMORY_LIST *CacheInfo;
|
|
|
|
void *Object;
|
|
|
|
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_FUNCTION_NAME ("UtAcquireFromCache");
|
2001-09-07 01:22:25 +00:00
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
|
|
|
|
CacheInfo = &AcpiGbl_MemoryLists[ListId];
|
2002-02-23 05:10:40 +00:00
|
|
|
if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_CACHES)))
|
|
|
|
{
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_MEM_TRACKING (CacheInfo->CacheRequests++);
|
|
|
|
|
|
|
|
/* Check the cache first */
|
|
|
|
|
|
|
|
if (CacheInfo->ListHead)
|
|
|
|
{
|
|
|
|
/* There is an object available, use it */
|
|
|
|
|
|
|
|
Object = CacheInfo->ListHead;
|
|
|
|
CacheInfo->ListHead = * (char **) (((char *) Object) + CacheInfo->LinkOffset);
|
|
|
|
|
|
|
|
ACPI_MEM_TRACKING (CacheInfo->CacheHits++);
|
|
|
|
CacheInfo->CacheDepth--;
|
|
|
|
|
2001-09-07 01:22:25 +00:00
|
|
|
#ifdef ACPI_DBG_TRACK_ALLOCATIONS
|
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Object %p from %s\n",
|
|
|
|
Object, AcpiGbl_MemoryLists[ListId].ListName));
|
|
|
|
#endif
|
2001-08-26 22:28:18 +00:00
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
if (ACPI_FAILURE (AcpiUtReleaseMutex (ACPI_MTX_CACHES)))
|
|
|
|
{
|
|
|
|
return (NULL);
|
|
|
|
}
|
2001-08-26 22:28:18 +00:00
|
|
|
|
|
|
|
/* Clear (zero) the previously used Object */
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_MEMSET (Object, 0, CacheInfo->ObjectSize);
|
2001-08-26 22:28:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* The cache is empty, create a new object */
|
|
|
|
|
|
|
|
/* Avoid deadlock with ACPI_MEM_CALLOCATE */
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
if (ACPI_FAILURE (AcpiUtReleaseMutex (ACPI_MTX_CACHES)))
|
|
|
|
{
|
|
|
|
return (NULL);
|
|
|
|
}
|
2001-08-26 22:28:18 +00:00
|
|
|
|
|
|
|
Object = ACPI_MEM_CALLOCATE (CacheInfo->ObjectSize);
|
|
|
|
ACPI_MEM_TRACKING (CacheInfo->TotalAllocated++);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (Object);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiUtDeleteGenericCache
|
|
|
|
*
|
|
|
|
* PARAMETERS: ListId - Memory list ID
|
|
|
|
*
|
|
|
|
* RETURN: None
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Free all objects within the requested cache.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
AcpiUtDeleteGenericCache (
|
|
|
|
UINT32 ListId)
|
|
|
|
{
|
|
|
|
ACPI_MEMORY_LIST *CacheInfo;
|
|
|
|
char *Next;
|
|
|
|
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_FUNCTION_ENTRY ();
|
2001-09-07 01:22:25 +00:00
|
|
|
|
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
CacheInfo = &AcpiGbl_MemoryLists[ListId];
|
|
|
|
while (CacheInfo->ListHead)
|
|
|
|
{
|
|
|
|
/* Delete one cached state object */
|
|
|
|
|
|
|
|
Next = * (char **) (((char *) CacheInfo->ListHead) + CacheInfo->LinkOffset);
|
|
|
|
ACPI_MEM_FREE (CacheInfo->ListHead);
|
|
|
|
|
|
|
|
CacheInfo->ListHead = Next;
|
|
|
|
CacheInfo->CacheDepth--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiUtValidateBuffer
|
|
|
|
*
|
|
|
|
* PARAMETERS: Buffer - Buffer descriptor to be validated
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Perform parameter validation checks on an ACPI_BUFFER
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiUtValidateBuffer (
|
|
|
|
ACPI_BUFFER *Buffer)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Obviously, the structure pointer must be valid */
|
|
|
|
|
|
|
|
if (!Buffer)
|
|
|
|
{
|
|
|
|
return (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Special semantics for the length */
|
|
|
|
|
|
|
|
if ((Buffer->Length == ACPI_NO_BUFFER) ||
|
|
|
|
(Buffer->Length == ACPI_ALLOCATE_BUFFER) ||
|
|
|
|
(Buffer->Length == ACPI_ALLOCATE_LOCAL_BUFFER))
|
|
|
|
{
|
|
|
|
return (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Length is valid, the buffer pointer must be also */
|
|
|
|
|
|
|
|
if (!Buffer->Pointer)
|
|
|
|
{
|
|
|
|
return (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiUtInitializeBuffer
|
|
|
|
*
|
|
|
|
* PARAMETERS: RequiredLength - Length needed
|
|
|
|
* Buffer - Buffer to be validated
|
|
|
|
*
|
|
|
|
* RETURN: Status
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Validate that the buffer is of the required length or
|
|
|
|
* allocate a new buffer.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
ACPI_STATUS
|
|
|
|
AcpiUtInitializeBuffer (
|
|
|
|
ACPI_BUFFER *Buffer,
|
|
|
|
ACPI_SIZE RequiredLength)
|
|
|
|
{
|
|
|
|
ACPI_STATUS Status = AE_OK;
|
|
|
|
|
|
|
|
|
|
|
|
switch (Buffer->Length)
|
|
|
|
{
|
|
|
|
case ACPI_NO_BUFFER:
|
|
|
|
|
|
|
|
/* Set the exception and returned the required length */
|
|
|
|
|
|
|
|
Status = AE_BUFFER_OVERFLOW;
|
|
|
|
break;
|
2001-07-21 03:55:17 +00:00
|
|
|
|
2001-01-31 09:17:50 +00:00
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
case ACPI_ALLOCATE_BUFFER:
|
|
|
|
|
|
|
|
/* Allocate a new buffer */
|
|
|
|
|
|
|
|
Buffer->Pointer = AcpiOsAllocate (RequiredLength);
|
|
|
|
if (!Buffer->Pointer)
|
|
|
|
{
|
|
|
|
return (AE_NO_MEMORY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear the buffer */
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
/* Validate the size of the buffer */
|
|
|
|
|
|
|
|
if (Buffer->Length < RequiredLength)
|
|
|
|
{
|
|
|
|
Status = AE_BUFFER_OVERFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear the buffer */
|
|
|
|
|
|
|
|
ACPI_MEMSET (Buffer->Pointer, 0, RequiredLength);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Buffer->Length = RequiredLength;
|
|
|
|
return (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiUtAllocate
|
|
|
|
*
|
|
|
|
* PARAMETERS: Size - Size of the allocation
|
|
|
|
* Component - Component type of caller
|
|
|
|
* Module - Source file name of caller
|
|
|
|
* Line - Line number of caller
|
|
|
|
*
|
|
|
|
* RETURN: Address of the allocated memory on success, NULL on failure.
|
|
|
|
*
|
|
|
|
* DESCRIPTION: The subsystem's equivalent of malloc.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
void *
|
|
|
|
AcpiUtAllocate (
|
|
|
|
ACPI_SIZE Size,
|
|
|
|
UINT32 Component,
|
|
|
|
NATIVE_CHAR *Module,
|
|
|
|
UINT32 Line)
|
|
|
|
{
|
|
|
|
void *Allocation;
|
|
|
|
|
|
|
|
|
|
|
|
ACPI_FUNCTION_TRACE_U32 ("UtAllocate", Size);
|
|
|
|
|
|
|
|
|
|
|
|
/* Check for an inadvertent size of zero bytes */
|
|
|
|
|
|
|
|
if (!Size)
|
|
|
|
{
|
|
|
|
_ACPI_REPORT_ERROR (Module, Line, Component,
|
|
|
|
("UtAllocate: Attempt to allocate zero bytes\n"));
|
|
|
|
Size = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Allocation = AcpiOsAllocate (Size);
|
|
|
|
if (!Allocation)
|
|
|
|
{
|
|
|
|
/* Report allocation error */
|
|
|
|
|
|
|
|
_ACPI_REPORT_ERROR (Module, Line, Component,
|
|
|
|
("UtAllocate: Could not allocate size %X\n", Size));
|
|
|
|
|
|
|
|
return_PTR (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
return_PTR (Allocation);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiUtCallocate
|
|
|
|
*
|
|
|
|
* PARAMETERS: Size - Size of the allocation
|
|
|
|
* Component - Component type of caller
|
|
|
|
* Module - Source file name of caller
|
|
|
|
* Line - Line number of caller
|
|
|
|
*
|
|
|
|
* RETURN: Address of the allocated memory on success, NULL on failure.
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Subsystem equivalent of calloc.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
void *
|
|
|
|
AcpiUtCallocate (
|
|
|
|
ACPI_SIZE Size,
|
|
|
|
UINT32 Component,
|
|
|
|
NATIVE_CHAR *Module,
|
|
|
|
UINT32 Line)
|
|
|
|
{
|
|
|
|
void *Allocation;
|
|
|
|
|
|
|
|
|
|
|
|
ACPI_FUNCTION_TRACE_U32 ("UtCallocate", Size);
|
|
|
|
|
|
|
|
|
|
|
|
/* Check for an inadvertent size of zero bytes */
|
|
|
|
|
|
|
|
if (!Size)
|
|
|
|
{
|
|
|
|
_ACPI_REPORT_ERROR (Module, Line, Component,
|
|
|
|
("UtCallocate: Attempt to allocate zero bytes\n"));
|
|
|
|
return_PTR (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
Allocation = AcpiOsAllocate (Size);
|
|
|
|
if (!Allocation)
|
|
|
|
{
|
|
|
|
/* Report allocation error */
|
|
|
|
|
|
|
|
_ACPI_REPORT_ERROR (Module, Line, Component,
|
|
|
|
("UtCallocate: Could not allocate size %X\n", Size));
|
|
|
|
return_PTR (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear the memory block */
|
|
|
|
|
|
|
|
ACPI_MEMSET (Allocation, 0, Size);
|
|
|
|
return_PTR (Allocation);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef ACPI_DBG_TRACK_ALLOCATIONS
|
2000-10-28 05:01:06 +00:00
|
|
|
/*
|
2001-08-26 22:28:18 +00:00
|
|
|
* These procedures are used for tracking memory leaks in the subsystem, and
|
|
|
|
* they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set.
|
2001-07-21 03:55:17 +00:00
|
|
|
*
|
|
|
|
* Each memory allocation is tracked via a doubly linked list. Each
|
2000-10-28 05:01:06 +00:00
|
|
|
* element contains the caller's component, module name, function name, and
|
2001-09-07 01:22:25 +00:00
|
|
|
* line number. AcpiUtAllocate and AcpiUtCallocate call
|
2001-10-04 23:12:13 +00:00
|
|
|
* AcpiUtTrackAllocation to add an element to the list; deletion
|
2001-07-21 03:55:17 +00:00
|
|
|
* occurs in the body of AcpiUtFree.
|
2000-10-28 05:01:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiUtAllocateAndTrack
|
|
|
|
*
|
|
|
|
* PARAMETERS: Size - Size of the allocation
|
|
|
|
* Component - Component type of caller
|
|
|
|
* Module - Source file name of caller
|
|
|
|
* Line - Line number of caller
|
|
|
|
*
|
|
|
|
* RETURN: Address of the allocated memory on success, NULL on failure.
|
|
|
|
*
|
|
|
|
* DESCRIPTION: The subsystem's equivalent of malloc.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
void *
|
|
|
|
AcpiUtAllocateAndTrack (
|
|
|
|
ACPI_SIZE Size,
|
|
|
|
UINT32 Component,
|
|
|
|
NATIVE_CHAR *Module,
|
|
|
|
UINT32 Line)
|
|
|
|
{
|
|
|
|
ACPI_DEBUG_MEM_BLOCK *Allocation;
|
|
|
|
ACPI_STATUS Status;
|
|
|
|
|
|
|
|
|
|
|
|
Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_BLOCK), Component,
|
|
|
|
Module, Line);
|
|
|
|
if (!Allocation)
|
|
|
|
{
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = AcpiUtTrackAllocation (ACPI_MEM_LIST_GLOBAL, Allocation, Size,
|
|
|
|
ACPI_MEM_MALLOC, Component, Module, Line);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
AcpiOsFree (Allocation);
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalAllocated++;
|
|
|
|
AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize += (UINT32) Size;
|
|
|
|
|
|
|
|
return ((void *) &Allocation->UserSpace);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiUtCallocateAndTrack
|
|
|
|
*
|
|
|
|
* PARAMETERS: Size - Size of the allocation
|
|
|
|
* Component - Component type of caller
|
|
|
|
* Module - Source file name of caller
|
|
|
|
* Line - Line number of caller
|
|
|
|
*
|
|
|
|
* RETURN: Address of the allocated memory on success, NULL on failure.
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Subsystem equivalent of calloc.
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
void *
|
|
|
|
AcpiUtCallocateAndTrack (
|
|
|
|
ACPI_SIZE Size,
|
|
|
|
UINT32 Component,
|
|
|
|
NATIVE_CHAR *Module,
|
|
|
|
UINT32 Line)
|
|
|
|
{
|
|
|
|
ACPI_DEBUG_MEM_BLOCK *Allocation;
|
|
|
|
ACPI_STATUS Status;
|
|
|
|
|
|
|
|
|
|
|
|
Allocation = AcpiUtCallocate (Size + sizeof (ACPI_DEBUG_MEM_BLOCK), Component,
|
|
|
|
Module, Line);
|
|
|
|
if (!Allocation)
|
|
|
|
{
|
|
|
|
/* Report allocation error */
|
|
|
|
|
|
|
|
_ACPI_REPORT_ERROR (Module, Line, Component,
|
|
|
|
("UtCallocate: Could not allocate size %X\n", Size));
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = AcpiUtTrackAllocation (ACPI_MEM_LIST_GLOBAL, Allocation, Size,
|
|
|
|
ACPI_MEM_CALLOC, Component, Module, Line);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
AcpiOsFree (Allocation);
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].TotalAllocated++;
|
|
|
|
AcpiGbl_MemoryLists[ACPI_MEM_LIST_GLOBAL].CurrentTotalSize += (UINT32) Size;
|
|
|
|
|
|
|
|
return ((void *) &Allocation->UserSpace);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* FUNCTION: AcpiUtFreeAndTrack
|
|
|
|
*
|
|
|
|
* PARAMETERS: Allocation - Address of the memory to deallocate
|
|
|
|
* Component - Component type of caller
|
|
|
|
* Module - Source file name of caller
|
|
|
|
* Line - Line number of caller
|
|
|
|
*
|
|
|
|
* RETURN: None
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Frees the memory at Allocation
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
AcpiUtFreeAndTrack (
|
|
|
|
void *Allocation,
|
|
|
|
UINT32 Component,
|
|
|
|
NATIVE_CHAR *Module,
|
|
|
|
UINT32 Line)
|
|
|
|
{
|
|
|
|
ACPI_DEBUG_MEM_BLOCK *DebugBlock;
|
|
|
|
|
|
|
|
|
|
|
|
ACPI_FUNCTION_TRACE_PTR ("UtFree", Allocation);
|
|
|
|
|
|
|
|
|
|
|
|
if (NULL == Allocation)
|
|
|
|
{
|
|
|
|
_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));
|
|
|
|
|
|
|
|
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);
|
|
|
|
AcpiOsFree (DebugBlock);
|
|
|
|
|
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation));
|
|
|
|
|
|
|
|
return_VOID;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
/*******************************************************************************
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2001-10-04 23:12:13 +00:00
|
|
|
* FUNCTION: AcpiUtFindAllocation
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2002-02-23 05:10:40 +00:00
|
|
|
* PARAMETERS: Allocation - Address of allocated memory
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* RETURN: A list element if found; NULL otherwise.
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Searches for an element in the global allocation tracking list.
|
|
|
|
*
|
2001-05-29 19:52:40 +00:00
|
|
|
******************************************************************************/
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_MEM_BLOCK *
|
2001-10-04 23:12:13 +00:00
|
|
|
AcpiUtFindAllocation (
|
2001-08-26 22:28:18 +00:00
|
|
|
UINT32 ListId,
|
2002-02-23 05:10:40 +00:00
|
|
|
void *Allocation)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_MEM_BLOCK *Element;
|
|
|
|
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_FUNCTION_ENTRY ();
|
2001-09-07 01:22:25 +00:00
|
|
|
|
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
if (ListId > ACPI_MEM_LIST_MAX)
|
|
|
|
{
|
|
|
|
return (NULL);
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
Element = AcpiGbl_MemoryLists[ListId].ListHead;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/* Search for the address. */
|
|
|
|
|
|
|
|
while (Element)
|
|
|
|
{
|
2002-02-23 05:10:40 +00:00
|
|
|
if (Element == Allocation)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
|
|
|
return (Element);
|
|
|
|
}
|
|
|
|
|
|
|
|
Element = Element->Next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
/*******************************************************************************
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2001-10-04 23:12:13 +00:00
|
|
|
* FUNCTION: AcpiUtTrackAllocation
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2002-02-23 05:10:40 +00:00
|
|
|
* PARAMETERS: Allocation - Address of allocated memory
|
2000-10-28 05:01:06 +00:00
|
|
|
* Size - Size of the allocation
|
|
|
|
* AllocType - MEM_MALLOC or MEM_CALLOC
|
|
|
|
* Component - Component type of caller
|
|
|
|
* Module - Source file name of caller
|
|
|
|
* Line - Line number of caller
|
|
|
|
*
|
|
|
|
* RETURN: None.
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Inserts an element into the global allocation tracking list.
|
|
|
|
*
|
2001-05-29 19:52:40 +00:00
|
|
|
******************************************************************************/
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
ACPI_STATUS
|
2001-10-04 23:12:13 +00:00
|
|
|
AcpiUtTrackAllocation (
|
2001-08-26 22:28:18 +00:00
|
|
|
UINT32 ListId,
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_DEBUG_MEM_BLOCK *Allocation,
|
|
|
|
ACPI_SIZE Size,
|
2000-10-28 05:01:06 +00:00
|
|
|
UINT8 AllocType,
|
|
|
|
UINT32 Component,
|
|
|
|
NATIVE_CHAR *Module,
|
|
|
|
UINT32 Line)
|
|
|
|
{
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_MEMORY_LIST *MemList;
|
|
|
|
ACPI_DEBUG_MEM_BLOCK *Element;
|
2000-10-28 05:01:06 +00:00
|
|
|
ACPI_STATUS Status = AE_OK;
|
|
|
|
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_FUNCTION_TRACE_PTR ("UtTrackAllocation", Allocation);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
if (ListId > ACPI_MEM_LIST_MAX)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2001-08-26 22:28:18 +00:00
|
|
|
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
MemList = &AcpiGbl_MemoryLists[ListId];
|
2002-02-23 05:10:40 +00:00
|
|
|
Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Search list for this address to make sure it is not already on the list.
|
|
|
|
* This will catch several kinds of problems.
|
|
|
|
*/
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
Element = AcpiUtFindAllocation (ListId, Allocation);
|
2000-10-28 05:01:06 +00:00
|
|
|
if (Element)
|
|
|
|
{
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_REPORT_ERROR (("UtTrackAllocation: Allocation already present in list! (%p)\n",
|
|
|
|
Allocation));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Element %p Address %p\n", Element, Allocation));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
goto UnlockAndExit;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Fill in the instance data. */
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
Allocation->Size = (UINT32) Size;
|
|
|
|
Allocation->AllocType = AllocType;
|
|
|
|
Allocation->Component = Component;
|
|
|
|
Allocation->Line = Line;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME);
|
2001-08-26 22:28:18 +00:00
|
|
|
|
|
|
|
/* Insert at list head */
|
|
|
|
|
|
|
|
if (MemList->ListHead)
|
|
|
|
{
|
2002-02-23 05:10:40 +00:00
|
|
|
((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation;
|
2001-08-26 22:28:18 +00:00
|
|
|
}
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
Allocation->Next = MemList->ListHead;
|
|
|
|
Allocation->Previous = NULL;
|
2001-09-07 01:22:25 +00:00
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
MemList->ListHead = Allocation;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
UnlockAndExit:
|
2002-02-23 05:10:40 +00:00
|
|
|
Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
|
2000-10-28 05:01:06 +00:00
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
/*******************************************************************************
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2001-10-04 23:12:13 +00:00
|
|
|
* FUNCTION: AcpiUtRemoveAllocation
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2002-02-23 05:10:40 +00:00
|
|
|
* PARAMETERS: Allocation - Address of allocated memory
|
2000-10-28 05:01:06 +00:00
|
|
|
* Component - Component type of caller
|
|
|
|
* Module - Source file name of caller
|
|
|
|
* Line - Line number of caller
|
|
|
|
*
|
|
|
|
* RETURN:
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Deletes an element from the global allocation tracking list.
|
|
|
|
*
|
2001-05-29 19:52:40 +00:00
|
|
|
******************************************************************************/
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_STATUS
|
2001-10-04 23:12:13 +00:00
|
|
|
AcpiUtRemoveAllocation (
|
2001-08-26 22:28:18 +00:00
|
|
|
UINT32 ListId,
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_DEBUG_MEM_BLOCK *Allocation,
|
2000-10-28 05:01:06 +00:00
|
|
|
UINT32 Component,
|
|
|
|
NATIVE_CHAR *Module,
|
|
|
|
UINT32 Line)
|
|
|
|
{
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_MEMORY_LIST *MemList;
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_STATUS Status;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_FUNCTION_TRACE ("UtRemoveAllocation");
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
|
|
|
|
if (ListId > ACPI_MEM_LIST_MAX)
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (AE_BAD_PARAMETER);
|
|
|
|
}
|
|
|
|
|
|
|
|
MemList = &AcpiGbl_MemoryLists[ListId];
|
|
|
|
if (NULL == MemList->ListHead)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2001-08-26 22:28:18 +00:00
|
|
|
/* No allocations! */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
_ACPI_REPORT_ERROR (Module, Line, Component,
|
2001-10-04 23:12:13 +00:00
|
|
|
("UtRemoveAllocation: Empty allocation list, nothing to free!\n"));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
return_ACPI_STATUS (AE_OK);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return_ACPI_STATUS (Status);
|
|
|
|
}
|
2001-09-07 01:22:25 +00:00
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
/* Unlink */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
if (Allocation->Previous)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2002-02-23 05:10:40 +00:00
|
|
|
(Allocation->Previous)->Next = Allocation->Next;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
2001-08-26 22:28:18 +00:00
|
|
|
else
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2002-02-23 05:10:40 +00:00
|
|
|
MemList->ListHead = Allocation->Next;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
if (Allocation->Next)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2002-02-23 05:10:40 +00:00
|
|
|
(Allocation->Next)->Previous = Allocation->Previous;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
/* Mark the segment as deleted */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size %X\n", Allocation->Size));
|
2001-08-26 22:28:18 +00:00
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
|
|
|
|
return_ACPI_STATUS (Status);
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
/*******************************************************************************
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2001-05-29 19:52:40 +00:00
|
|
|
* FUNCTION: AcpiUtDumpAllocationInfo
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* PARAMETERS:
|
|
|
|
*
|
|
|
|
* RETURN: None
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Print some info about the outstanding allocations.
|
|
|
|
*
|
2001-05-29 19:52:40 +00:00
|
|
|
******************************************************************************/
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
void
|
2001-05-29 19:52:40 +00:00
|
|
|
AcpiUtDumpAllocationInfo (
|
2000-10-28 05:01:06 +00:00
|
|
|
void)
|
|
|
|
{
|
2001-08-26 22:28:18 +00:00
|
|
|
/*
|
|
|
|
ACPI_MEMORY_LIST *MemList;
|
|
|
|
*/
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_FUNCTION_TRACE ("UtDumpAllocationInfo");
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
/*
|
|
|
|
ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
|
2000-10-28 05:01:06 +00:00
|
|
|
("%30s: %4d (%3d Kb)\n", "Current allocations",
|
2001-08-26 22:28:18 +00:00
|
|
|
MemList->CurrentCount,
|
|
|
|
ROUND_UP_TO_1K (MemList->CurrentSize)));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
|
2000-10-28 05:01:06 +00:00
|
|
|
("%30s: %4d (%3d Kb)\n", "Max concurrent allocations",
|
2001-08-26 22:28:18 +00:00
|
|
|
MemList->MaxConcurrentCount,
|
|
|
|
ROUND_UP_TO_1K (MemList->MaxConcurrentSize)));
|
|
|
|
|
|
|
|
|
|
|
|
ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
|
|
|
|
("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",
|
|
|
|
RunningObjectCount,
|
|
|
|
ROUND_UP_TO_1K (RunningObjectSize)));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
|
|
|
|
("%30s: %4d (%3d Kb)\n", "Total (all) allocations",
|
|
|
|
RunningAllocCount,
|
|
|
|
ROUND_UP_TO_1K (RunningAllocSize)));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
|
2000-10-28 05:01:06 +00:00
|
|
|
("%30s: %4d (%3d Kb)\n", "Current Nodes",
|
|
|
|
AcpiGbl_CurrentNodeCount,
|
2000-12-01 09:36:25 +00:00
|
|
|
ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize)));
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
|
2000-10-28 05:01:06 +00:00
|
|
|
("%30s: %4d (%3d Kb)\n", "Max Nodes",
|
|
|
|
AcpiGbl_MaxConcurrentNodeCount,
|
2000-12-01 09:36:25 +00:00
|
|
|
ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount * sizeof (ACPI_NAMESPACE_NODE)))));
|
2001-08-26 22:28:18 +00:00
|
|
|
*/
|
2000-10-28 05:01:06 +00:00
|
|
|
return_VOID;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-29 19:52:40 +00:00
|
|
|
/*******************************************************************************
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
2001-10-04 23:12:13 +00:00
|
|
|
* FUNCTION: AcpiUtDumpAllocations
|
2000-10-28 05:01:06 +00:00
|
|
|
*
|
|
|
|
* PARAMETERS: Component - Component(s) to dump info for.
|
|
|
|
* Module - Module to dump info for. NULL means all.
|
|
|
|
*
|
|
|
|
* RETURN: None
|
|
|
|
*
|
|
|
|
* DESCRIPTION: Print a list of all outstanding allocations.
|
|
|
|
*
|
2001-05-29 19:52:40 +00:00
|
|
|
******************************************************************************/
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
void
|
2001-10-04 23:12:13 +00:00
|
|
|
AcpiUtDumpAllocations (
|
2000-10-28 05:01:06 +00:00
|
|
|
UINT32 Component,
|
|
|
|
NATIVE_CHAR *Module)
|
|
|
|
{
|
2001-08-26 22:28:18 +00:00
|
|
|
ACPI_DEBUG_MEM_BLOCK *Element;
|
2001-11-28 04:29:40 +00:00
|
|
|
UINT32 NumOutstanding = 0;
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
ACPI_FUNCTION_TRACE ("UtDumpAllocations");
|
2000-10-28 05:01:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Walk the allocation list.
|
|
|
|
*/
|
2002-02-23 05:10:40 +00:00
|
|
|
if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY)))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
Element = AcpiGbl_MemoryLists[0].ListHead;
|
|
|
|
while (Element)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
|
|
|
if ((Element->Component & Component) &&
|
2002-02-23 05:10:40 +00:00
|
|
|
((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module))))
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2001-11-28 04:29:40 +00:00
|
|
|
/* Ignore allocated objects that are in a cache */
|
|
|
|
|
2001-10-04 23:12:13 +00:00
|
|
|
if (((ACPI_OPERAND_OBJECT *)(&Element->UserSpace))->Common.Type != ACPI_CACHED_OBJECT)
|
2000-10-28 05:01:06 +00:00
|
|
|
{
|
2001-11-28 04:29:40 +00:00
|
|
|
AcpiOsPrintf ("%p Len %04X %9.9s-%d ",
|
2001-10-04 23:12:13 +00:00
|
|
|
&Element->UserSpace, Element->Size, Element->Module,
|
2001-11-28 04:29:40 +00:00
|
|
|
Element->Line);
|
2001-10-04 23:12:13 +00:00
|
|
|
|
|
|
|
/* Most of the elements will be internal objects. */
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
switch (ACPI_GET_DESCRIPTOR_TYPE (&Element->UserSpace))
|
2001-10-04 23:12:13 +00:00
|
|
|
{
|
|
|
|
case ACPI_DESC_TYPE_INTERNAL:
|
2001-11-28 04:29:40 +00:00
|
|
|
AcpiOsPrintf ("ObjType %12.12s R%d",
|
2001-10-31 02:32:29 +00:00
|
|
|
AcpiUtGetTypeName (((ACPI_OPERAND_OBJECT *)(&Element->UserSpace))->Common.Type),
|
2001-11-28 04:29:40 +00:00
|
|
|
((ACPI_OPERAND_OBJECT *)(&Element->UserSpace))->Common.ReferenceCount);
|
2001-10-04 23:12:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_DESC_TYPE_PARSER:
|
2001-11-28 04:29:40 +00:00
|
|
|
AcpiOsPrintf ("ParseObj Opcode %04X",
|
|
|
|
((ACPI_PARSE_OBJECT *)(&Element->UserSpace))->Opcode);
|
2001-10-04 23:12:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_DESC_TYPE_NAMED:
|
2001-11-28 04:29:40 +00:00
|
|
|
AcpiOsPrintf ("Node %4.4s",
|
|
|
|
(char *) &((ACPI_NAMESPACE_NODE *)(&Element->UserSpace))->Name);
|
2001-10-04 23:12:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_DESC_TYPE_STATE:
|
2001-11-28 04:29:40 +00:00
|
|
|
AcpiOsPrintf ("Untyped StateObj");
|
2001-10-04 23:12:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_DESC_TYPE_STATE_UPDATE:
|
2001-11-28 04:29:40 +00:00
|
|
|
AcpiOsPrintf ("UPDATE StateObj");
|
2001-10-04 23:12:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_DESC_TYPE_STATE_PACKAGE:
|
2001-11-28 04:29:40 +00:00
|
|
|
AcpiOsPrintf ("PACKAGE StateObj");
|
2001-10-04 23:12:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_DESC_TYPE_STATE_CONTROL:
|
2001-11-28 04:29:40 +00:00
|
|
|
AcpiOsPrintf ("CONTROL StateObj");
|
2001-10-04 23:12:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_DESC_TYPE_STATE_RPSCOPE:
|
2001-11-28 04:29:40 +00:00
|
|
|
AcpiOsPrintf ("ROOT-PARSE-SCOPE StateObj");
|
2001-10-04 23:12:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_DESC_TYPE_STATE_PSCOPE:
|
2001-11-28 04:29:40 +00:00
|
|
|
AcpiOsPrintf ("PARSE-SCOPE StateObj");
|
2001-10-04 23:12:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_DESC_TYPE_STATE_WSCOPE:
|
2001-11-28 04:29:40 +00:00
|
|
|
AcpiOsPrintf ("WALK-SCOPE StateObj");
|
2001-10-04 23:12:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_DESC_TYPE_STATE_RESULT:
|
2001-11-28 04:29:40 +00:00
|
|
|
AcpiOsPrintf ("RESULT StateObj");
|
2001-10-04 23:12:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_DESC_TYPE_STATE_NOTIFY:
|
2001-11-28 04:29:40 +00:00
|
|
|
AcpiOsPrintf ("NOTIFY StateObj");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_DESC_TYPE_STATE_THREAD:
|
|
|
|
AcpiOsPrintf ("THREAD StateObj");
|
2001-10-04 23:12:13 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
AcpiOsPrintf ( "\n");
|
|
|
|
NumOutstanding++;
|
2000-10-28 05:01:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Element = Element->Next;
|
|
|
|
}
|
|
|
|
|
2002-02-23 05:10:40 +00:00
|
|
|
(void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
/* Print summary */
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-11-28 04:29:40 +00:00
|
|
|
if (!NumOutstanding)
|
|
|
|
{
|
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_OK,
|
|
|
|
"No outstanding allocations.\n"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_OK,
|
|
|
|
"%d(%X) Outstanding allocations\n",
|
|
|
|
NumOutstanding, NumOutstanding));
|
|
|
|
}
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-01-31 09:17:50 +00:00
|
|
|
return_VOID;
|
|
|
|
}
|
2001-07-21 03:55:17 +00:00
|
|
|
|
2000-10-28 05:01:06 +00:00
|
|
|
|
2001-07-21 03:55:17 +00:00
|
|
|
#endif /* #ifdef ACPI_DBG_TRACK_ALLOCATIONS */
|
2000-10-28 05:01:06 +00:00
|
|
|
|