summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/nsxfobj.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica/nsxfobj.c')
-rw-r--r--sys/contrib/dev/acpica/nsxfobj.c224
1 files changed, 119 insertions, 105 deletions
diff --git a/sys/contrib/dev/acpica/nsxfobj.c b/sys/contrib/dev/acpica/nsxfobj.c
index fc0ee50..ea1941e 100644
--- a/sys/contrib/dev/acpica/nsxfobj.c
+++ b/sys/contrib/dev/acpica/nsxfobj.c
@@ -2,7 +2,7 @@
*
* Module Name: nsxfobj - Public interfaces to the ACPI subsystem
* ACPI Object oriented interfaces
- * $Revision: 98 $
+ * $Revision: 108 $
*
******************************************************************************/
@@ -10,7 +10,7 @@
*
* 1. Copyright Notice
*
- * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
+ * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
* All rights reserved.
*
* 2. License
@@ -125,7 +125,7 @@
#define _COMPONENT ACPI_NAMESPACE
- MODULE_NAME ("nsxfobj")
+ ACPI_MODULE_NAME ("nsxfobj")
/*******************************************************************************
@@ -158,12 +158,11 @@ AcpiEvaluateObject (
ACPI_STATUS Status;
ACPI_OPERAND_OBJECT **InternalParams = NULL;
ACPI_OPERAND_OBJECT *InternalReturnObj = NULL;
- UINT32 BufferSpaceNeeded;
- UINT32 UserBufferLength;
+ ACPI_SIZE BufferSpaceNeeded;
UINT32 i;
- FUNCTION_TRACE ("AcpiEvaluateObject");
+ ACPI_FUNCTION_TRACE ("AcpiEvaluateObject");
/*
@@ -177,13 +176,13 @@ AcpiEvaluateObject (
* Allocate a new parameter block for the internal objects
* Add 1 to count to allow for null terminated internal list
*/
- InternalParams = ACPI_MEM_CALLOCATE ((ExternalParams->Count + 1) * sizeof (void *));
+ InternalParams = ACPI_MEM_CALLOCATE ((ExternalParams->Count + 1) *
+ sizeof (void *));
if (!InternalParams)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
-
/*
* Convert each external object in the list to an
* internal object
@@ -192,7 +191,6 @@ AcpiEvaluateObject (
{
Status = AcpiUtCopyEobjectToIobject (&ExternalParams->Pointer[i],
&InternalParams[i]);
-
if (ACPI_FAILURE (Status))
{
AcpiUtDeleteInternalObjectList (InternalParams);
@@ -202,7 +200,6 @@ AcpiEvaluateObject (
InternalParams[ExternalParams->Count] = NULL;
}
-
/*
* Three major cases:
* 1) Fully qualified pathname
@@ -215,9 +212,9 @@ AcpiEvaluateObject (
/*
* The path is fully qualified, just evaluate by name
*/
- Status = AcpiNsEvaluateByName (Pathname, InternalParams, &InternalReturnObj);
+ Status = AcpiNsEvaluateByName (Pathname, InternalParams,
+ &InternalReturnObj);
}
-
else if (!Handle)
{
/*
@@ -227,17 +224,17 @@ AcpiEvaluateObject (
*/
if (!Pathname)
{
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Both Handle and Pathname are NULL\n"));
+ ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
+ "Both Handle and Pathname are NULL\n"));
}
-
else
{
- ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "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;
}
-
else
{
/*
@@ -251,16 +248,16 @@ AcpiEvaluateObject (
* The null pathname case means the handle is for
* the actual object to be evaluated
*/
- Status = AcpiNsEvaluateByHandle (Handle, InternalParams, &InternalReturnObj);
+ Status = AcpiNsEvaluateByHandle (Handle, InternalParams,
+ &InternalReturnObj);
}
-
else
{
/*
* Both a Handle and a relative Pathname
*/
Status = AcpiNsEvaluateRelative (Handle, Pathname, InternalParams,
- &InternalReturnObj);
+ &InternalReturnObj);
}
}
@@ -269,29 +266,27 @@ AcpiEvaluateObject (
* If we are expecting a return value, and all went well above,
* copy the return value to an external object.
*/
-
if (ReturnBuffer)
{
- UserBufferLength = ReturnBuffer->Length;
- ReturnBuffer->Length = 0;
-
- if (InternalReturnObj)
+ if (!InternalReturnObj)
{
- if (VALID_DESCRIPTOR_TYPE (InternalReturnObj, ACPI_DESC_TYPE_NAMED))
+ ReturnBuffer->Length = 0;
+ }
+ else
+ {
+ if (ACPI_GET_DESCRIPTOR_TYPE (InternalReturnObj) == ACPI_DESC_TYPE_NAMED)
{
/*
- * If we got an Node as a return object,
- * this means the object we are evaluating
- * has nothing interesting to return (such
- * as a mutex, etc.) We return an error
- * because these types are essentially
- * unsupported by this interface. We
- * don't check up front because this makes
- * it easier to add support for various
- * types at a later date if necessary.
+ * If we received a NS Node as a return object, this means that
+ * the object we are evaluating has nothing interesting to
+ * return (such as a mutex, etc.) We return an error because
+ * these types are essentially unsupported by this interface.
+ * We don't check up front because this makes it easier to add
+ * support for various types at a later date if necessary.
*/
Status = AE_TYPE;
- InternalReturnObj = NULL; /* No need to delete an Node */
+ InternalReturnObj = NULL; /* No need to delete a NS Node */
+ ReturnBuffer->Length = 0;
}
if (ACPI_SUCCESS (Status))
@@ -304,25 +299,18 @@ AcpiEvaluateObject (
&BufferSpaceNeeded);
if (ACPI_SUCCESS (Status))
{
- /*
- * Check if there is enough room in the
- * caller's buffer
- */
- if (UserBufferLength < BufferSpaceNeeded)
+ /* Validate/Allocate/Clear caller buffer */
+
+ Status = AcpiUtInitializeBuffer (ReturnBuffer, BufferSpaceNeeded);
+ if (ACPI_FAILURE (Status))
{
/*
- * Caller's buffer is too small, can't
- * give him partial results fail the call
- * but return the buffer size needed
+ * Caller's buffer is too small or a new one can't be allocated
*/
ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
- "Needed buffer size %X, received %X\n",
- BufferSpaceNeeded, UserBufferLength));
-
- ReturnBuffer->Length = BufferSpaceNeeded;
- Status = AE_BUFFER_OVERFLOW;
+ "Needed buffer size %X, %s\n",
+ BufferSpaceNeeded, AcpiFormatException (Status)));
}
-
else
{
/*
@@ -330,14 +318,12 @@ AcpiEvaluateObject (
*/
Status = AcpiUtCopyIobjectToEobject (InternalReturnObj,
ReturnBuffer);
- ReturnBuffer->Length = BufferSpaceNeeded;
}
}
}
}
}
-
/* Delete the return and parameter objects */
if (InternalReturnObj)
@@ -388,7 +374,7 @@ AcpiGetNextObject (
ACPI_HANDLE Child,
ACPI_HANDLE *RetHandle)
{
- ACPI_STATUS Status = AE_OK;
+ ACPI_STATUS Status;
ACPI_NAMESPACE_NODE *Node;
ACPI_NAMESPACE_NODE *ParentNode = NULL;
ACPI_NAMESPACE_NODE *ChildNode = NULL;
@@ -401,7 +387,11 @@ AcpiGetNextObject (
return (AE_BAD_PARAMETER);
}
- AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
/* If null handle, use the parent */
@@ -416,11 +406,9 @@ AcpiGetNextObject (
goto UnlockAndExit;
}
}
-
- /* Non-null handle, ignore the parent */
-
else
{
+ /* Non-null handle, ignore the parent */
/* Convert and validate the handle */
ChildNode = AcpiNsMapHandleToNode (Child);
@@ -431,11 +419,9 @@ AcpiGetNextObject (
}
}
-
/* Internal function does the real work */
- Node = AcpiNsGetNextNode ((ACPI_OBJECT_TYPE8) Type,
- ParentNode, ChildNode);
+ Node = AcpiNsGetNextNode (Type, ParentNode, ChildNode);
if (!Node)
{
Status = AE_NOT_FOUND;
@@ -450,7 +436,7 @@ AcpiGetNextObject (
UnlockAndExit:
- AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return (Status);
}
@@ -474,6 +460,7 @@ AcpiGetType (
ACPI_OBJECT_TYPE *RetType)
{
ACPI_NAMESPACE_NODE *Node;
+ ACPI_STATUS Status;
/* Parameter Validation */
@@ -493,22 +480,26 @@ AcpiGetType (
return (AE_OK);
}
- AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
/* Convert and validate the handle */
Node = AcpiNsMapHandleToNode (Handle);
if (!Node)
{
- AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return (AE_BAD_PARAMETER);
}
*RetType = Node->Type;
- AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- return (AE_OK);
+ Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ return (Status);
}
@@ -532,7 +523,7 @@ AcpiGetParent (
ACPI_HANDLE *RetHandle)
{
ACPI_NAMESPACE_NODE *Node;
- ACPI_STATUS Status = AE_OK;
+ ACPI_STATUS Status;
if (!RetHandle)
@@ -547,8 +538,11 @@ AcpiGetParent (
return (AE_NULL_ENTRY);
}
-
- AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
/* Convert and validate the handle */
@@ -559,15 +553,14 @@ AcpiGetParent (
goto UnlockAndExit;
}
-
/* Get the parent entry */
*RetHandle =
- AcpiNsConvertEntryToHandle (AcpiNsGetParentObject (Node));
+ AcpiNsConvertEntryToHandle (AcpiNsGetParentNode (Node));
/* Return exeption if parent is null */
- if (!AcpiNsGetParentObject (Node))
+ if (!AcpiNsGetParentNode (Node))
{
Status = AE_NULL_ENTRY;
}
@@ -575,7 +568,7 @@ AcpiGetParent (
UnlockAndExit:
- AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return (Status);
}
@@ -622,7 +615,7 @@ AcpiWalkNamespace (
ACPI_STATUS Status;
- FUNCTION_TRACE ("AcpiWalkNamespace");
+ ACPI_FUNCTION_TRACE ("AcpiWalkNamespace");
/* Parameter validation */
@@ -640,13 +633,16 @@ 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);
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
- AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ Status = AcpiNsWalkNamespace (Type, StartObject, MaxDepth, ACPI_NS_WALK_UNLOCK,
+ UserFunction, Context, ReturnValue);
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return_ACPI_STATUS (Status);
}
@@ -682,9 +678,18 @@ AcpiNsGetDeviceCallback (
Info = Context;
- AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
Node = AcpiNsMapHandleToNode (ObjHandle);
- AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
if (!Node)
{
@@ -716,20 +721,18 @@ AcpiNsGetDeviceCallback (
{
return (AE_OK);
}
-
else if (ACPI_FAILURE (Status))
{
return (AE_CTRL_DEPTH);
}
- if (STRNCMP (Hid.Buffer, Info->Hid, sizeof (Hid.Buffer)) != 0)
+ if (ACPI_STRNCMP (Hid.Buffer, Info->Hid, sizeof (Hid.Buffer)) != 0)
{
Status = AcpiUtExecute_CID (Node, &Cid);
if (Status == AE_NOT_FOUND)
{
return (AE_OK);
}
-
else if (ACPI_FAILURE (Status))
{
return (AE_CTRL_DEPTH);
@@ -737,7 +740,7 @@ AcpiNsGetDeviceCallback (
/* TBD: Handle CID packages */
- if (STRNCMP (Cid.Buffer, Info->Hid, sizeof (Cid.Buffer)) != 0)
+ if (ACPI_STRNCMP (Cid.Buffer, Info->Hid, sizeof (Cid.Buffer)) != 0)
{
return (AE_OK);
}
@@ -785,7 +788,7 @@ AcpiGetDevices (
ACPI_GET_DEVICES_INFO Info;
- FUNCTION_TRACE ("AcpiGetDevices");
+ ACPI_FUNCTION_TRACE ("AcpiGetDevices");
/* Parameter validation */
@@ -809,15 +812,19 @@ AcpiGetDevices (
* to the user function - since this function
* must be allowed to make Acpi calls itself.
*/
- AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return_ACPI_STATUS (Status);
+ }
+
Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE,
ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
- NS_WALK_UNLOCK,
+ ACPI_NS_WALK_UNLOCK,
AcpiNsGetDeviceCallback, &Info,
ReturnValue);
- AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
-
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return_ACPI_STATUS (Status);
}
@@ -826,11 +833,11 @@ AcpiGetDevices (
*
* FUNCTION: AcpiAttachData
*
- * PARAMETERS:
+ * PARAMETERS:
*
* RETURN: Status
*
- * DESCRIPTION:
+ * DESCRIPTION:
*
******************************************************************************/
@@ -853,8 +860,11 @@ AcpiAttachData (
return (AE_BAD_PARAMETER);
}
-
- AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
/* Convert and validate the handle */
@@ -868,8 +878,7 @@ AcpiAttachData (
Status = AcpiNsAttachData (Node, Handler, Data);
UnlockAndExit:
-
- AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return (Status);
}
@@ -878,11 +887,11 @@ UnlockAndExit:
*
* FUNCTION: AcpiDetachData
*
- * PARAMETERS:
+ * PARAMETERS:
*
* RETURN: Status
*
- * DESCRIPTION:
+ * DESCRIPTION:
*
******************************************************************************/
@@ -903,7 +912,11 @@ AcpiDetachData (
return (AE_BAD_PARAMETER);
}
- AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
/* Convert and validate the handle */
@@ -917,8 +930,7 @@ AcpiDetachData (
Status = AcpiNsDetachData (Node, Handler);
UnlockAndExit:
-
- AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return (Status);
}
@@ -927,11 +939,11 @@ UnlockAndExit:
*
* FUNCTION: AcpiGetData
*
- * PARAMETERS:
+ * PARAMETERS:
*
* RETURN: Status
*
- * DESCRIPTION:
+ * DESCRIPTION:
*
******************************************************************************/
@@ -954,7 +966,11 @@ AcpiGetData (
return (AE_BAD_PARAMETER);
}
- AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
/* Convert and validate the handle */
@@ -968,10 +984,8 @@ AcpiGetData (
Status = AcpiNsGetAttachedData (Node, Handler, Data);
UnlockAndExit:
-
- AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+ (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
return (Status);
}
-
OpenPOWER on IntegriCloud