utdelete.c revision 199767f8919635c4928607450d9e0abb932109ce
/*******************************************************************************
*
* Module Name: utdelete - object deletion and reference count utilities
*
******************************************************************************/
/*
* Copyright (C) 2000 - 2015, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("utdelete")
/* Local prototypes */
static void
static void
/*******************************************************************************
*
* FUNCTION: AcpiUtDeleteInternalObj
*
* PARAMETERS: Object - Object to be deleted
*
* RETURN: None
*
* DESCRIPTION: Low level object deletion, after reference counts have been
* updated (All reference counts, including sub-objects!)
*
******************************************************************************/
static void
{
void *ObjPointer = NULL;
if (!Object)
{
}
/*
* Must delete or free any pointers within the object that are not
* actual ACPI objects (for example, a raw buffer pointer).
*/
{
case ACPI_TYPE_STRING:
/* Free the actual string buffer */
{
/* But only if it is NOT a pointer into an ACPI table */
}
break;
case ACPI_TYPE_BUFFER:
/* Free the actual buffer */
{
/* But only if it is NOT a pointer into an ACPI table */
}
break;
case ACPI_TYPE_PACKAGE:
/*
* Elements of the package are not handled here, they are deleted
* separately
*/
/* Free the (variable length) element pointer array */
break;
/*
* These objects have a possible list of notify handlers.
* Device object also may have a GPE block.
*/
case ACPI_TYPE_DEVICE:
{
}
/*lint -fallthrough */
case ACPI_TYPE_PROCESSOR:
case ACPI_TYPE_THERMAL:
/* Walk the address handler list for this object */
while (HandlerDesc)
{
}
break;
case ACPI_TYPE_MUTEX:
"***** Mutex %p, OS Mutex %p\n",
if (Object == AcpiGbl_GlobalLockMutex)
{
/* Global Lock has extra semaphore */
}
else
{
}
break;
case ACPI_TYPE_EVENT:
"***** Event %p, OS Semaphore %p\n",
break;
case ACPI_TYPE_METHOD:
"***** Method %p\n", Object));
/* Delete the method mutex if it exists */
{
}
{
}
break;
case ACPI_TYPE_REGION:
"***** Region %p\n", Object));
/*
* Update AddressRange list. However, only permanent regions
* are installed in this list. (Not created within a method)
*/
{
}
if (SecondDesc)
{
/*
* Free the RegionContext if and only if the handler is one of the
* default handlers -- and therefore, we created the context object
* locally, it was not created by an external caller.
*/
if (HandlerDesc)
{
/* Remove the region object from the handler list */
while (NextDesc)
{
{
break;
}
/* Walk the linked list of handlers */
/* Prevent infinite loop if list is corrupted */
{
"Circular region list in address handler object %p",
HandlerDesc));
}
}
{
/* Deactivate region and free region context */
{
}
}
}
/* Now we can free the Extra object */
}
break;
case ACPI_TYPE_BUFFER_FIELD:
"***** Buffer Field %p\n", Object));
if (SecondDesc)
{
}
break;
"***** Bank Field %p\n", Object));
if (SecondDesc)
{
}
break;
default:
break;
}
/* Free any allocated memory (pointer within the object) found above */
if (ObjPointer)
{
ObjPointer));
}
/* Now the object can be safely deleted */
}
/*******************************************************************************
*
* FUNCTION: AcpiUtDeleteInternalObjectList
*
* PARAMETERS: ObjList - Pointer to the list to be deleted
*
* RETURN: None
*
* DESCRIPTION: This function deletes an internal object list, including both
* simple objects and package objects
*
******************************************************************************/
void
{
/* Walk the null-terminated internal list */
{
}
/* Free the combined parameter pointer list and object array */
return;
}
/*******************************************************************************
*
* FUNCTION: AcpiUtUpdateRefCount
*
* PARAMETERS: Object - Object whose ref count is to be updated
* Action - What to do (REF_INCREMENT or REF_DECREMENT)
*
* RETURN: None. Sets new reference count within the object
*
* DESCRIPTION: Modify the reference count for an internal acpi object
*
******************************************************************************/
static void
{
if (!Object)
{
return;
}
/*
* Namespace is not always locked when this function is called.
*/
/* Perform the reference count action (increment, decrement) */
switch (Action)
{
case REF_INCREMENT:
/* The current reference count should never be zero here */
if (!OriginalCount)
{
"Obj %p, Reference Count was zero before increment\n",
Object));
}
"Obj %p Type %.2X Refs %.2X [Incremented]\n",
break;
case REF_DECREMENT:
/* The current reference count must be non-zero */
if (OriginalCount)
{
}
if (!OriginalCount)
{
"Obj %p, Reference Count is already zero, cannot decrement\n",
Object));
}
"Obj %p Type %.2X Refs %.2X [Decremented]\n",
/* Actually delete the object on a reference count of zero */
if (NewCount == 0)
{
}
break;
default:
Action));
return;
}
/*
* Sanity check the reference count, for debug purposes only.
* (A deleted object will have a huge reference count)
*/
if (NewCount > ACPI_MAX_REFERENCE_COUNT)
{
"Large Reference Count (0x%X) in object %p, Type=0x%.2X",
}
}
/*******************************************************************************
*
* FUNCTION: AcpiUtUpdateObjectReference
*
* PARAMETERS: Object - Increment ref count for this object
* and all sub-objects
* Action - Either REF_INCREMENT or REF_DECREMENT
*
* RETURN: Status
*
* DESCRIPTION: Increment the object reference count
*
* Object references are incremented when:
* 1) An object is attached to a Node (namespace object)
* 2) An object is copied (all subobjects must be incremented)
*
* Object references are decremented when:
* 1) An object is detached from an Node
*
******************************************************************************/
{
UINT32 i;
while (Object)
{
/* Make sure that this isn't a namespace handle */
{
"Object %p is NS handle\n", Object));
return (AE_OK);
}
/*
* All sub-objects must have their reference count incremented also.
* Different object types have different subobjects.
*/
{
case ACPI_TYPE_DEVICE:
case ACPI_TYPE_PROCESSOR:
case ACPI_TYPE_POWER:
case ACPI_TYPE_THERMAL:
/*
* Update the notify objects for these types (if present)
* Two lists, system and device notify handlers.
*/
for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++)
{
while (PrevObject)
{
}
}
break;
case ACPI_TYPE_PACKAGE:
/*
* We must update all the sub-objects of the package,
* each of whom may have their own sub-objects.
*/
{
/*
* Null package elements are legal and can be simply
* ignored.
*/
if (!NextObject)
{
continue;
}
{
case ACPI_TYPE_INTEGER:
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
/*
* For these very simple sub-objects, we can just
* update the reference count here and continue.
* Greatly increases performance of this operation.
*/
break;
default:
/*
* For complex sub-objects, push them onto the stack
* for later processing (this eliminates recursion.)
*/
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
break;
}
}
NextObject = NULL;
break;
case ACPI_TYPE_BUFFER_FIELD:
break;
break;
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
break;
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
break;
/*
* The target of an Index (a package, string, or buffer) or a named
* reference must track changes to the ref count of the index or
* target object.
*/
{
}
break;
case ACPI_TYPE_REGION:
default:
break; /* No subobjects for all other types */
}
/*
* Now we can update the count in the main object. This can only
* happen after we update the sub-objects in case this causes the
* main object to be deleted.
*/
/* Move on to the next object to be updated */
if (NextObject)
{
Object = NextObject;
NextObject = NULL;
}
else if (StateList)
{
}
}
return (AE_OK);
"Could not update object reference count"));
/* Free any stacked Update State objects */
while (StateList)
{
}
return (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiUtAddReference
*
* PARAMETERS: Object - Object whose reference count is to be
* incremented
*
* RETURN: None
*
* DESCRIPTION: Add one reference to an ACPI object
*
******************************************************************************/
void
{
/* Ensure that we have a valid object */
if (!AcpiUtValidInternalObject (Object))
{
return;
}
"Obj %p Current Refs=%X [To Be Incremented]\n",
/* Increment the reference count */
return;
}
/*******************************************************************************
*
* FUNCTION: AcpiUtRemoveReference
*
* PARAMETERS: Object - Object whose ref count will be decremented
*
* RETURN: None
*
* DESCRIPTION: Decrement the reference count of an ACPI internal object
*
******************************************************************************/
void
{
/*
* Allow a NULL pointer to be passed in, just ignore it. This saves
* each caller from having to check. Also, ignore NS nodes.
*/
if (!Object ||
{
return;
}
/* Ensure that we have a valid object */
if (!AcpiUtValidInternalObject (Object))
{
return;
}
"Obj %p Current Refs=%X [To Be Decremented]\n",
/*
* Decrement the reference count, and only actually delete the object
* if the reference count becomes 0. (Must also decrement the ref count
* of all subobjects!)
*/
return;
}