Major rework of the reference count mechanism for internal objects.

date	2001.10.08.18.03.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 18:36:05 +00:00
parent 961ab40281
commit e5267506ce
3 changed files with 170 additions and 220 deletions

View File

@ -2,7 +2,7 @@
*
* Module Name: nsutils - Utilities for accessing ACPI namespace, accessing
* parents and siblings and Scope manipulation
* $Revision: 1.87 $
* $Revision: 1.90 $
*
*****************************************************************************/
@ -230,12 +230,12 @@ AcpiNsLocal (
*
* FUNCTION: AcpiNsGetInternalNameLength
*
* PARAMETERS: Info - Info struct initialized with the
* PARAMETERS: Info - Info struct initialized with the
* external name pointer.
*
* RETURN: Status
*
* DESCRIPTION: Calculate the length of the internal (AML) namestring
* DESCRIPTION: Calculate the length of the internal (AML) namestring
* corresponding to the external (ASL) namestring.
*
******************************************************************************/
@ -248,11 +248,14 @@ AcpiNsGetInternalNameLength (
UINT32 i;
FUNCTION_ENTRY ();
NextExternalChar = Info->ExternalName;
Info->NumCarats = 0;
Info->NumSegments = 0;
Info->FullyQualified = FALSE;
/*
* For the internal name, the required length is 4 bytes
* per segment, plus 1 each for RootPrefix, MultiNamePrefixOp,
@ -273,7 +276,6 @@ AcpiNsGetInternalNameLength (
/*
* Handle Carat prefixes
*/
while (*NextExternalChar == '^')
{
Info->NumCarats++;
@ -299,7 +301,7 @@ AcpiNsGetInternalNameLength (
}
}
Info->Length = (ACPI_NAME_SIZE * Info->NumSegments) +
Info->Length = (ACPI_NAME_SIZE * Info->NumSegments) +
4 + Info->NumCarats;
Info->NextExternalChar = NextExternalChar;
@ -316,7 +318,7 @@ AcpiNsGetInternalNameLength (
*
* RETURN: Status
*
* DESCRIPTION: Construct the internal (AML) namestring
* DESCRIPTION: Construct the internal (AML) namestring
* corresponding to the external (ASL) namestring.
*
******************************************************************************/
@ -334,7 +336,7 @@ AcpiNsBuildInternalName (
FUNCTION_TRACE ("NsBuildInternalName");
/* Setup the correct prefixes, counts, and pointers */
if (Info->FullyQualified)
@ -695,6 +697,9 @@ AcpiNsConvertHandleToEntry (
ACPI_HANDLE Handle)
{
FUNCTION_ENTRY ();
/*
* Simple implementation for now;
* TBD: [Future] Real integer handles allow for more verification
@ -1042,6 +1047,9 @@ AcpiNsGetParentObject (
{
FUNCTION_ENTRY ();
if (!Node)
{
return (NULL);
@ -1066,21 +1074,21 @@ AcpiNsGetParentObject (
/*******************************************************************************
*
* FUNCTION: AcpiNsGetNextValidObject
* FUNCTION: AcpiNsGetNextValidNode
*
* PARAMETERS: Node - Current table entry
*
* RETURN: Next valid object in the table. NULL if no more valid
* objects
* RETURN: Next valid Node in the linked node list. NULL if no more valid
* nodess
*
* DESCRIPTION: Find the next valid object within a name table.
* DESCRIPTION: Find the next valid node within a name table.
* Useful for implementing NULL-end-of-list loops.
*
******************************************************************************/
ACPI_NAMESPACE_NODE *
AcpiNsGetNextValidObject (
AcpiNsGetNextValidNode (
ACPI_NAMESPACE_NODE *Node)
{

View File

@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: nswalk - Functions for walking the APCI namespace
* Module Name: nswalk - Functions for walking the ACPI namespace
* $Revision: 1.25 $
*
*****************************************************************************/
@ -9,8 +9,8 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
* reserved.
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
* All rights reserved.
*
* 2. License
*
@ -122,113 +122,107 @@
#include "acnamesp.h"
#define _COMPONENT NAMESPACE
MODULE_NAME ("nswalk");
#define _COMPONENT ACPI_NAMESPACE
MODULE_NAME ("nswalk")
/****************************************************************************
/*******************************************************************************
*
* FUNCTION: AcpiGetNextObject
* FUNCTION: AcpiNsGetNextNode
*
* PARAMETERS: Type - Type of object to be searched for
* Parent - Parent object whose children we are getting
* LastChild - Previous child that was found.
* The NEXT child will be returned
* RetHandle - Where handle to the next object is placed
* PARAMETERS: Type - Type of node to be searched for
* ParentNode - Parent node whose children we are
* getting
* ChildNode - Previous child that was found.
* The NEXT child will be returned
*
* RETURN: Status
* RETURN: ACPI_NAMESPACE_NODE - Pointer to the NEXT child or NULL if
* none is found.
*
* DESCRIPTION: Return the next peer object within the namespace. If Handle is
* valid, Scope is ignored. Otherwise, the first object within
* Scope is returned.
* DESCRIPTION: Return the next peer node within the namespace. If Handle
* is valid, Scope is ignored. Otherwise, the first node
* within Scope is returned.
*
******************************************************************************/
ACPI_NAMED_OBJECT*
AcpiNsGetNextObject (
OBJECT_TYPE_INTERNAL Type,
ACPI_NAMED_OBJECT *Parent,
ACPI_NAMED_OBJECT *Child)
ACPI_NAMESPACE_NODE *
AcpiNsGetNextNode (
ACPI_OBJECT_TYPE8 Type,
ACPI_NAMESPACE_NODE *ParentNode,
ACPI_NAMESPACE_NODE *ChildNode)
{
ACPI_NAMED_OBJECT *ThisEntry = NULL;
ACPI_NAMESPACE_NODE *NextNode = NULL;
if (!Child)
FUNCTION_ENTRY ();
if (!ChildNode)
{
/* It's really the parent's _scope_ that we want */
if (Parent->ChildTable)
if (ParentNode->Child)
{
ThisEntry = Parent->ChildTable->Entries;
NextNode = ParentNode->Child;
}
}
else
{
/* Start search at the NEXT object */
/* Start search at the NEXT node */
ThisEntry = AcpiNsGetNextValidEntry (Child);
NextNode = AcpiNsGetNextValidNode (ChildNode);
}
/* If any type is OK, we are done */
if (Type == ACPI_TYPE_ANY)
{
/* Make sure this is valid entry first */
/* NextNode is NULL if we are at the end-of-list */
if ((!ThisEntry) ||
(!ThisEntry->Name))
{
return (NULL);
}
return (ThisEntry);
return (NextNode);
}
/* Must search for the node -- but within this scope only */
/* Must search for the object -- but within this scope only */
while (ThisEntry)
while (NextNode)
{
/* If type matches, we are done */
if (ThisEntry->Type == Type)
if (NextNode->Type == Type)
{
return (ThisEntry);
return (NextNode);
}
/* Otherwise, move on to the next object */
/* Otherwise, move on to the next node */
ThisEntry = AcpiNsGetNextValidEntry (ThisEntry);
NextNode = AcpiNsGetNextValidNode (NextNode);
}
/* Not found */
return (NULL);
}
/******************************************************************************
/*******************************************************************************
*
* FUNCTION: AcpiNsWalkNamespace
*
* PARAMETERS: Type - ACPI_OBJECT_TYPE to search for
* StartObject - Handle in namespace where search begins
* StartNode - Handle in namespace where search begins
* MaxDepth - Depth to which search is to reach
* UnlockBeforeCallback- Whether to unlock the NS before invoking
* the callback routine
* UserFunction - Called when an object of "Type" is found
* Context - Passed to user function
*
* RETURNS Return value from the UserFunction if terminated early.
* Otherwise, returns NULL.
* ReturnValue - from the UserFunction if terminated early.
* Otherwise, returns NULL.
* RETURNS: Status
*
* DESCRIPTION: Performs a modified depth-first walk of the namespace tree,
* starting (and ending) at the object specified by StartHandle.
* The UserFunction is called whenever an object that matches
* starting (and ending) at the node specified by StartHandle.
* The UserFunction is called whenever a node that matches
* the type parameter is found. If the user function returns
* a non-zero value, the search is terminated immediately and this
* value is returned to the caller.
@ -243,102 +237,99 @@ AcpiNsGetNextObject (
ACPI_STATUS
AcpiNsWalkNamespace (
OBJECT_TYPE_INTERNAL Type,
ACPI_HANDLE StartObject,
ACPI_OBJECT_TYPE8 Type,
ACPI_HANDLE StartNode,
UINT32 MaxDepth,
BOOLEAN UnlockBeforeCallback,
WALK_CALLBACK UserFunction,
ACPI_WALK_CALLBACK UserFunction,
void *Context,
void **ReturnValue)
{
ACPI_STATUS Status;
ACPI_NAMED_OBJECT *ChildEntry;
ACPI_NAMED_OBJECT *ParentEntry;
OBJECT_TYPE_INTERNAL ChildType;
ACPI_NAMESPACE_NODE *ChildNode;
ACPI_NAMESPACE_NODE *ParentNode;
ACPI_OBJECT_TYPE8 ChildType;
UINT32 Level;
FUNCTION_TRACE ("NsWalkNamespace");
/* Special case for the namespace root object */
if (StartObject == ACPI_ROOT_OBJECT)
/* Special case for the namespace Root Node */
if (StartNode == ACPI_ROOT_OBJECT)
{
StartObject = AcpiGbl_RootObject;
StartNode = AcpiGbl_RootNode;
}
/* Null child means "get first object" */
/* Null child means "get first node" */
ParentEntry = StartObject;
ChildEntry = 0;
ChildType = ACPI_TYPE_ANY;
Level = 1;
ParentNode = StartNode;
ChildNode = 0;
ChildType = ACPI_TYPE_ANY;
Level = 1;
/*
* Traverse the tree of objects until we bubble back up to where we
* Traverse the tree of nodes until we bubble back up to where we
* started. When Level is zero, the loop is done because we have
* bubbled up to (and passed) the original parent handle (StartEntry)
*/
while (Level > 0)
{
/*
* Get the next typed object in this scope. Null returned
* if not found
*/
/* Get the next node in this scope. Null if not found */
Status = AE_OK;
ChildEntry = AcpiNsGetNextObject (ACPI_TYPE_ANY,
ParentEntry,
ChildEntry);
if (ChildEntry)
ChildNode = AcpiNsGetNextNode (ACPI_TYPE_ANY, ParentNode, ChildNode);
if (ChildNode)
{
/*
* Found an object, Get the type if we are not
* Found node, Get the type if we are not
* searching for ANY
*/
if (Type != ACPI_TYPE_ANY)
{
ChildType = ChildEntry->Type;
ChildType = ChildNode->Type;
}
if (ChildType == Type)
{
/*
* Found a matching object, invoke the user
* Found a matching node, invoke the user
* callback function
*/
if (UnlockBeforeCallback)
{
AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE);
AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
}
Status = UserFunction (ChildEntry, Level,
Status = UserFunction (ChildNode, Level,
Context, ReturnValue);
if (UnlockBeforeCallback)
{
AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE);
AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
}
switch (Status)
{
case AE_OK:
case AE_CTRL_DEPTH:
/* Just keep going */
break;
case AE_CTRL_TERMINATE:
/* Exit now, with OK status */
return_ACPI_STATUS (AE_OK);
break;
default:
/* All others are valid exceptions */
return_ACPI_STATUS (Status);
break;
}
@ -352,19 +343,17 @@ AcpiNsWalkNamespace (
* or if the user function has specified that the
* maximum depth has been reached.
*/
if ((Level < MaxDepth) && (Status != AE_CTRL_DEPTH))
{
if (AcpiNsGetNextObject (ACPI_TYPE_ANY,
ChildEntry, 0))
if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, 0))
{
/*
* There is at least one child of this
* object, visit the object
* node, visit the onde
*/
Level++;
ParentEntry = ChildEntry;
ChildEntry = 0;
ParentNode = ChildNode;
ChildNode = 0;
}
}
}
@ -372,17 +361,18 @@ AcpiNsWalkNamespace (
else
{
/*
* No more children in this object (AcpiNsGetNextObject
* No more children of this node (AcpiNsGetNextNode
* failed), go back upwards in the namespace tree to
* the object's parent.
* the node's parent.
*/
Level--;
ChildEntry = ParentEntry;
ParentEntry = AcpiNsGetParentEntry (ParentEntry);
ChildNode = ParentNode;
ParentNode = AcpiNsGetParentObject (ParentNode);
}
}
/* Complete walk, not terminated by user function */
return_ACPI_STATUS (AE_OK);
}

View File

@ -2,7 +2,7 @@
*
* Module Name: nsxfobj - Public interfaces to the ACPI subsystem
* ACPI Object oriented interfaces
* $Revision: 1.72 $
* $Revision: 1.94 $
*
******************************************************************************/
@ -10,8 +10,8 @@
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999, Intel Corp. All rights
* reserved.
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
* All rights reserved.
*
* 2. License
*
@ -124,7 +124,7 @@
#include "acdispat.h"
#define _COMPONENT NAMESPACE
#define _COMPONENT ACPI_NAMESPACE
MODULE_NAME ("nsxfobj")
@ -134,12 +134,10 @@
*
* PARAMETERS: Handle - Object handle (optional)
* *Pathname - Object pathname (optional)
* **Params - List of parameters to pass to
* method, terminated by NULL.
* Params itself may be NULL
* if no parameters are being
* passed.
* *ReturnObject - Where to put method's return value (if
* **ExternalParams - List of parameters to pass to method,
* terminated by NULL. May be NULL
* if no parameters are being passed.
* *ReturnBuffer - Where to put method's return value (if
* any). If NULL, no value is returned.
*
* RETURN: Status
@ -154,19 +152,15 @@ ACPI_STATUS
AcpiEvaluateObject (
ACPI_HANDLE Handle,
ACPI_STRING Pathname,
ACPI_OBJECT_LIST *ParamObjects,
ACPI_OBJECT_LIST *ExternalParams,
ACPI_BUFFER *ReturnBuffer)
{
ACPI_STATUS Status;
ACPI_OPERAND_OBJECT **ParamPtr = NULL;
ACPI_OPERAND_OBJECT *ReturnObj = NULL;
ACPI_OPERAND_OBJECT *ObjectPtr = NULL;
ACPI_OPERAND_OBJECT **InternalParams = NULL;
ACPI_OPERAND_OBJECT *InternalReturnObj = NULL;
UINT32 BufferSpaceNeeded;
UINT32 UserBufferLength;
UINT32 Count;
UINT32 i;
UINT32 ParamLength;
UINT32 ObjectLength;
FUNCTION_TRACE ("AcpiEvaluateObject");
@ -177,56 +171,35 @@ AcpiEvaluateObject (
* (which must be a control method), the external objects
* must be converted to internal objects
*/
if (ParamObjects && ParamObjects->Count)
if (ExternalParams && ExternalParams->Count)
{
/*
* Allocate a new parameter block for the internal objects
* Add 1 to count to allow for null terminated internal list
*/
Count = ParamObjects->Count;
ParamLength = (Count + 1) * sizeof (void *);
ObjectLength = Count * sizeof (ACPI_OPERAND_OBJECT);
ParamPtr = AcpiCmCallocate (ParamLength + /* Parameter List part */
ObjectLength); /* Actual objects */
if (!ParamPtr)
InternalParams = ACPI_MEM_CALLOCATE ((ExternalParams->Count + 1) * sizeof (void *));
if (!InternalParams)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
ObjectPtr = (ACPI_OPERAND_OBJECT *) ((UINT8 *) ParamPtr +
ParamLength);
/*
* Init the param array of pointers and NULL terminate
* the list
*/
for (i = 0; i < Count; i++)
{
ParamPtr[i] = &ObjectPtr[i];
AcpiCmInitStaticObject (&ObjectPtr[i]);
}
ParamPtr[Count] = NULL;
/*
* Convert each external object in the list to an
* internal object
*/
for (i = 0; i < Count; i++)
for (i = 0; i < ExternalParams->Count; i++)
{
Status =
AcpiCmBuildInternalObject (&ParamObjects->Pointer[i],
ParamPtr[i]);
Status = AcpiUtCopyEobjectToIobject (&ExternalParams->Pointer[i],
&InternalParams[i]);
if (ACPI_FAILURE (Status))
{
AcpiCmDeleteInternalObjectList (ParamPtr);
AcpiUtDeleteInternalObjectList (InternalParams);
return_ACPI_STATUS (Status);
}
}
InternalParams[ExternalParams->Count] = NULL;
}
@ -236,14 +209,13 @@ AcpiEvaluateObject (
* 2) No handle, not fully qualified pathname (error)
* 3) Valid handle
*/
if ((Pathname) &&
(AcpiNsValidRootPrefix (Pathname[0])))
{
/*
* The path is fully qualified, just evaluate by name
*/
Status = AcpiNsEvaluateByName (Pathname, ParamPtr, &ReturnObj);
Status = AcpiNsEvaluateByName (Pathname, InternalParams, &InternalReturnObj);
}
else if (!Handle)
@ -253,17 +225,14 @@ AcpiEvaluateObject (
* is specified. Since we've already handled fully
* qualified names above, this is an error
*/
if (!Pathname)
{
DEBUG_PRINT (ACPI_ERROR,
("AcpiEvaluateObject: Both Handle and Pathname are NULL\n"));
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Both Handle and Pathname are NULL\n"));
}
else
{
DEBUG_PRINT (ACPI_ERROR,
("AcpiEvaluateObject: Handle is NULL and Pathname is relative\n"));
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Handle is NULL and Pathname is relative\n"));
}
Status = AE_BAD_PARAMETER;
@ -276,14 +245,13 @@ AcpiEvaluateObject (
* pathname it is relative. The handle will be validated
* in the lower procedures
*/
if (!Pathname)
{
/*
* The null pathname case means the handle is for
* the actual object to be evaluated
*/
Status = AcpiNsEvaluateByHandle (Handle, ParamPtr, &ReturnObj);
Status = AcpiNsEvaluateByHandle (Handle, InternalParams, &InternalReturnObj);
}
else
@ -291,8 +259,8 @@ AcpiEvaluateObject (
/*
* Both a Handle and a relative Pathname
*/
Status = AcpiNsEvaluateRelative (Handle, Pathname, ParamPtr,
&ReturnObj);
Status = AcpiNsEvaluateRelative (Handle, Pathname, InternalParams,
&InternalReturnObj);
}
}
@ -307,9 +275,9 @@ AcpiEvaluateObject (
UserBufferLength = ReturnBuffer->Length;
ReturnBuffer->Length = 0;
if (ReturnObj)
if (InternalReturnObj)
{
if (VALID_DESCRIPTOR_TYPE (ReturnObj, ACPI_DESC_TYPE_NAMED))
if (VALID_DESCRIPTOR_TYPE (InternalReturnObj, ACPI_DESC_TYPE_NAMED))
{
/*
* If we got an Node as a return object,
@ -323,7 +291,7 @@ AcpiEvaluateObject (
* types at a later date if necessary.
*/
Status = AE_TYPE;
ReturnObj = NULL; /* No need to delete an Node */
InternalReturnObj = NULL; /* No need to delete an Node */
}
if (ACPI_SUCCESS (Status))
@ -332,7 +300,7 @@ AcpiEvaluateObject (
* Find out how large a buffer is needed
* to contain the returned object
*/
Status = AcpiCmGetObjectSize (ReturnObj,
Status = AcpiUtGetObjectSize (InternalReturnObj,
&BufferSpaceNeeded);
if (ACPI_SUCCESS (Status))
{
@ -340,7 +308,6 @@ AcpiEvaluateObject (
* Check if there is enough room in the
* caller's buffer
*/
if (UserBufferLength < BufferSpaceNeeded)
{
/*
@ -348,9 +315,8 @@ AcpiEvaluateObject (
* give him partial results fail the call
* but return the buffer size needed
*/
DEBUG_PRINT (ACPI_ERROR,
("AcpiEvaluateObject: Needed buffer size %d, received %d\n",
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
"Needed buffer size %X, received %X\n",
BufferSpaceNeeded, UserBufferLength));
ReturnBuffer->Length = BufferSpaceNeeded;
@ -362,7 +328,7 @@ AcpiEvaluateObject (
/*
* We have enough space for the object, build it
*/
Status = AcpiCmBuildExternalObject (ReturnObj,
Status = AcpiUtCopyIobjectToEobject (InternalReturnObj,
ReturnBuffer);
ReturnBuffer->Length = BufferSpaceNeeded;
}
@ -374,24 +340,23 @@ AcpiEvaluateObject (
/* Delete the return and parameter objects */
if (ReturnObj)
if (InternalReturnObj)
{
/*
* Delete the internal return object. (Or at least
* decrement the reference count by one)
*/
AcpiCmRemoveReference (ReturnObj);
AcpiUtRemoveReference (InternalReturnObj);
}
/*
* Free the input parameter list (if we created one),
*/
if (ParamPtr)
if (InternalParams)
{
/* Free the allocated parameter block */
AcpiCmDeleteInternalObjectList (ParamPtr);
AcpiUtDeleteInternalObjectList (InternalParams);
}
return_ACPI_STATUS (Status);
@ -436,7 +401,7 @@ AcpiGetNextObject (
return (AE_BAD_PARAMETER);
}
AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE);
AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
/* If null handle, use the parent */
@ -469,7 +434,7 @@ AcpiGetNextObject (
/* Internal function does the real work */
Node = AcpiNsGetNextObject ((OBJECT_TYPE_INTERNAL) Type,
Node = AcpiNsGetNextNode ((ACPI_OBJECT_TYPE8) Type,
ParentNode, ChildNode);
if (!Node)
{
@ -485,7 +450,7 @@ AcpiGetNextObject (
UnlockAndExit:
AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE);
AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return (Status);
}
@ -528,21 +493,21 @@ AcpiGetType (
return (AE_OK);
}
AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE);
AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
/* Convert and validate the handle */
Node = AcpiNsConvertHandleToEntry (Handle);
if (!Node)
{
AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE);
AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return (AE_BAD_PARAMETER);
}
*RetType = Node->Type;
AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE);
AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return (AE_OK);
}
@ -570,9 +535,6 @@ AcpiGetParent (
ACPI_STATUS Status = AE_OK;
/* No trace macro, too verbose */
if (!RetHandle)
{
return (AE_BAD_PARAMETER);
@ -586,7 +548,7 @@ AcpiGetParent (
}
AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE);
AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
/* Convert and validate the handle */
@ -613,7 +575,7 @@ AcpiGetParent (
UnlockAndExit:
AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE);
AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return (Status);
}
@ -653,7 +615,7 @@ AcpiWalkNamespace (
ACPI_OBJECT_TYPE Type,
ACPI_HANDLE StartObject,
UINT32 MaxDepth,
WALK_CALLBACK UserFunction,
ACPI_WALK_CALLBACK UserFunction,
void *Context,
void **ReturnValue)
{
@ -678,15 +640,12 @@ AcpiWalkNamespace (
* to the user function - since this function
* must be allowed to make Acpi calls itself.
*/
AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
Status = AcpiNsWalkNamespace ((ACPI_OBJECT_TYPE8) Type, StartObject,
MaxDepth, NS_WALK_UNLOCK, UserFunction, Context,
ReturnValue);
AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE);
Status = AcpiNsWalkNamespace ((OBJECT_TYPE_INTERNAL) Type,
StartObject, MaxDepth,
NS_WALK_UNLOCK,
UserFunction, Context,
ReturnValue);
AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE);
AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return_ACPI_STATUS (Status);
}
@ -706,7 +665,7 @@ AcpiWalkNamespace (
*
******************************************************************************/
ACPI_STATUS
static ACPI_STATUS
AcpiNsGetDeviceCallback (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
@ -716,37 +675,33 @@ AcpiNsGetDeviceCallback (
ACPI_STATUS Status;
ACPI_NAMESPACE_NODE *Node;
UINT32 Flags;
DEVICE_ID DeviceId;
ACPI_DEVICE_ID DeviceId;
ACPI_GET_DEVICES_INFO *Info;
Info = Context;
AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE);
AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
Node = AcpiNsConvertHandleToEntry (ObjHandle);
AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
if (!Node)
{
AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE);
return (AE_BAD_PARAMETER);
}
AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE);
/*
* Run _STA to determine if device is present
*/
Status = AcpiCmExecute_STA (Node, &Flags);
Status = AcpiUtExecute_STA (Node, &Flags);
if (ACPI_FAILURE (Status))
{
return (Status);
return (AE_CTRL_DEPTH);
}
if (!(Flags & 0x01))
{
/* don't return at the device or children of the device if not there */
return (AE_CTRL_DEPTH);
}
@ -755,8 +710,7 @@ AcpiNsGetDeviceCallback (
*/
if (Info->Hid != NULL)
{
Status = AcpiCmExecute_HID (Node, &DeviceId);
Status = AcpiUtExecute_HID (Node, &DeviceId);
if (Status == AE_NOT_FOUND)
{
return (AE_OK);
@ -764,7 +718,7 @@ AcpiNsGetDeviceCallback (
else if (ACPI_FAILURE (Status))
{
return (Status);
return (AE_CTRL_DEPTH);
}
if (STRNCMP (DeviceId.Buffer, Info->Hid, sizeof (DeviceId.Buffer)) != 0)
@ -774,7 +728,6 @@ AcpiNsGetDeviceCallback (
}
Info->UserFunction (ObjHandle, NestingLevel, Info->Context, ReturnValue);
return (AE_OK);
}
@ -807,7 +760,7 @@ AcpiNsGetDeviceCallback (
ACPI_STATUS
AcpiGetDevices (
NATIVE_CHAR *HID,
WALK_CALLBACK UserFunction,
ACPI_WALK_CALLBACK UserFunction,
void *Context,
void **ReturnValue)
{
@ -839,15 +792,14 @@ AcpiGetDevices (
* to the user function - since this function
* must be allowed to make Acpi calls itself.
*/
AcpiCmAcquireMutex (ACPI_MTX_NAMESPACE);
AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE,
ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
NS_WALK_UNLOCK,
AcpiNsGetDeviceCallback, &Info,
ReturnValue);
AcpiCmReleaseMutex (ACPI_MTX_NAMESPACE);
AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return_ACPI_STATUS (Status);
}
}