summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/Subsystem/Common
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica/Subsystem/Common')
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Common/cmcopy.c766
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Common/cmobject.c287
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Common/cmutils.c280
-rw-r--r--sys/contrib/dev/acpica/Subsystem/Common/cmxface.c12
4 files changed, 787 insertions, 558 deletions
diff --git a/sys/contrib/dev/acpica/Subsystem/Common/cmcopy.c b/sys/contrib/dev/acpica/Subsystem/Common/cmcopy.c
index f27d724..a081e83 100644
--- a/sys/contrib/dev/acpica/Subsystem/Common/cmcopy.c
+++ b/sys/contrib/dev/acpica/Subsystem/Common/cmcopy.c
@@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: cmcopy - Internal to external object translation utilities
- * $Revision: 62 $
+ * $Revision: 66 $
*
*****************************************************************************/
@@ -119,54 +119,43 @@
#include "acpi.h"
#include "acinterp.h"
#include "acnamesp.h"
+#include "amlcode.h"
#define _COMPONENT MISCELLANEOUS
MODULE_NAME ("cmcopy")
-typedef struct Search_st
-{
- ACPI_OPERAND_OBJECT *InternalObj;
- UINT32 Index;
- ACPI_OBJECT *ExternalObj;
-
-} PKG_SEARCH_INFO;
-
-
-/* Used to traverse nested packages */
-PKG_SEARCH_INFO Level[MAX_PACKAGE_DEPTH];
-
-/******************************************************************************
+/*******************************************************************************
*
- * FUNCTION: AcpiCmBuildExternalSimpleObject
+ * FUNCTION: AcpiCmCopyIsimpleToEsimple
*
- * PARAMETERS: *InternalObj - Pointer to the object we are examining
- * *Buffer - Where the object is returned
- * *SpaceUsed - Where the data length is returned
+ * PARAMETERS: *InternalObject - Pointer to the object we are examining
+ * *Buffer - Where the object is returned
+ * *SpaceUsed - Where the data length is returned
*
- * RETURN: Status - the status of the call
+ * RETURN: Status
*
* DESCRIPTION: This function is called to place a simple object in a user
- * buffer.
+ * buffer.
*
* The buffer is assumed to have sufficient space for the object.
*
******************************************************************************/
static ACPI_STATUS
-AcpiCmBuildExternalSimpleObject (
- ACPI_OPERAND_OBJECT *InternalObj,
- ACPI_OBJECT *ExternalObj,
+AcpiCmCopyIsimpleToEsimple (
+ ACPI_OPERAND_OBJECT *InternalObject,
+ ACPI_OBJECT *ExternalObject,
UINT8 *DataSpace,
UINT32 *BufferSpaceUsed)
{
UINT32 Length = 0;
- UINT8 *SourcePtr = NULL;
+ ACPI_STATUS Status = AE_OK;
- FUNCTION_TRACE ("CmBuildExternalSimpleObject");
+ FUNCTION_TRACE ("CmCopyIsimpleToEsimple");
/*
@@ -174,7 +163,7 @@ AcpiCmBuildExternalSimpleObject (
* package element
*/
- if (!InternalObj)
+ if (!InternalObject)
{
*BufferSpaceUsed = 0;
return_ACPI_STATUS (AE_OK);
@@ -182,110 +171,217 @@ AcpiCmBuildExternalSimpleObject (
/* Always clear the external object */
- MEMSET (ExternalObj, 0, sizeof (ACPI_OBJECT));
+ MEMSET (ExternalObject, 0, sizeof (ACPI_OBJECT));
/*
* In general, the external object will be the same type as
* the internal object
*/
- ExternalObj->Type = InternalObj->Common.Type;
+ ExternalObject->Type = InternalObject->Common.Type;
/* However, only a limited number of external types are supported */
- switch (ExternalObj->Type)
+ switch (InternalObject->Common.Type)
{
case ACPI_TYPE_STRING:
- Length = InternalObj->String.Length + 1;
- ExternalObj->String.Length = InternalObj->String.Length;
- ExternalObj->String.Pointer = (NATIVE_CHAR *) DataSpace;
- SourcePtr = (UINT8 *) InternalObj->String.Pointer;
+ Length = InternalObject->String.Length + 1;
+ ExternalObject->String.Length = InternalObject->String.Length;
+ ExternalObject->String.Pointer = (NATIVE_CHAR *) DataSpace;
+ MEMCPY ((void *) DataSpace, (void *) InternalObject->String.Pointer, Length);
break;
case ACPI_TYPE_BUFFER:
- Length = InternalObj->Buffer.Length;
- ExternalObj->Buffer.Length = InternalObj->Buffer.Length;
- ExternalObj->Buffer.Pointer = DataSpace;
- SourcePtr = (UINT8 *) InternalObj->Buffer.Pointer;
+ Length = InternalObject->Buffer.Length;
+ ExternalObject->Buffer.Length = InternalObject->Buffer.Length;
+ ExternalObject->Buffer.Pointer = DataSpace;
+ MEMCPY ((void *) DataSpace, (void *) InternalObject->Buffer.Pointer, Length);
break;
case ACPI_TYPE_INTEGER:
- ExternalObj->Integer.Value= InternalObj->Integer.Value;
+ ExternalObject->Integer.Value= InternalObject->Integer.Value;
break;
case INTERNAL_TYPE_REFERENCE:
/*
- * This is an object reference. We use the object type of "Any"
- * to indicate a reference object containing a handle to an ACPI
- * named object.
+ * This is an object reference. Attempt to dereference it.
*/
- ExternalObj->Type = ACPI_TYPE_ANY;
- ExternalObj->Reference.Handle = InternalObj->Reference.Node;
+ switch (InternalObject->Reference.OpCode)
+ {
+ case AML_ZERO_OP:
+ ExternalObject->Type = ACPI_TYPE_INTEGER;
+ ExternalObject->Integer.Value = 0;
+ break;
+
+ case AML_ONE_OP:
+ ExternalObject->Type = ACPI_TYPE_INTEGER;
+ ExternalObject->Integer.Value = 1;
+ break;
+
+ case AML_ONES_OP:
+ ExternalObject->Type = ACPI_TYPE_INTEGER;
+ ExternalObject->Integer.Value = ACPI_INTEGER_MAX;
+ break;
+
+ case AML_NAMEPATH_OP:
+ /*
+ * This is a named reference, get the string. We already know that
+ * we have room for it, use max length
+ */
+ Length = MAX_STRING_LENGTH;
+ ExternalObject->Type = ACPI_TYPE_STRING;
+ ExternalObject->String.Pointer = (NATIVE_CHAR *) DataSpace;
+ Status = AcpiNsHandleToPathname ((ACPI_HANDLE *) InternalObject->Reference.Node,
+ &Length, (char *) DataSpace);
+ break;
+
+ default:
+ /*
+ * Use the object type of "Any" to indicate a reference
+ * to object containing a handle to an ACPI named object.
+ */
+ ExternalObject->Type = ACPI_TYPE_ANY;
+ ExternalObject->Reference.Handle = InternalObject->Reference.Node;
+ break;
+ }
break;
case ACPI_TYPE_PROCESSOR:
- ExternalObj->Processor.ProcId =
- InternalObj->Processor.ProcId;
-
- ExternalObj->Processor.PblkAddress =
- InternalObj->Processor.Address;
-
- ExternalObj->Processor.PblkLength =
- InternalObj->Processor.Length;
+ ExternalObject->Processor.ProcId = InternalObject->Processor.ProcId;
+ ExternalObject->Processor.PblkAddress = InternalObject->Processor.Address;
+ ExternalObject->Processor.PblkLength = InternalObject->Processor.Length;
break;
+
case ACPI_TYPE_POWER:
- ExternalObj->PowerResource.SystemLevel =
- InternalObj->PowerResource.SystemLevel;
+ ExternalObject->PowerResource.SystemLevel =
+ InternalObject->PowerResource.SystemLevel;
- ExternalObj->PowerResource.ResourceOrder =
- InternalObj->PowerResource.ResourceOrder;
+ ExternalObject->PowerResource.ResourceOrder =
+ InternalObject->PowerResource.ResourceOrder;
break;
+
default:
- return_ACPI_STATUS (AE_CTRL_RETURN_VALUE);
+ /*
+ * There is no corresponding external object type
+ */
+ return_ACPI_STATUS (AE_SUPPORT);
break;
}
- /* Copy data if necessary (strings or buffers) */
- if (Length)
+ *BufferSpaceUsed = (UINT32) ROUND_UP_TO_NATIVE_WORD (Length);
+
+ return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiCmCopyIelementToEelement
+ *
+ * PARAMETERS: ACPI_PKG_CALLBACK
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Copy one package element to another package element
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiCmCopyIelementToEelement (
+ UINT8 ObjectType,
+ ACPI_OPERAND_OBJECT *SourceObject,
+ ACPI_GENERIC_STATE *State,
+ void *Context)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context;
+ UINT32 ObjectSpace;
+ UINT32 ThisIndex;
+ ACPI_OBJECT *TargetObject;
+
+
+
+ ThisIndex = State->Pkg.Index;
+ TargetObject = (ACPI_OBJECT *)
+ &((ACPI_OBJECT *)(State->Pkg.DestObject))->Package.Elements[ThisIndex];
+
+
+ switch (ObjectType)
{
+ case 0:
+
/*
- * Copy the return data to the caller's buffer
+ * This is a simple or null object -- get the size
*/
- MEMCPY ((void *) DataSpace, (void *) SourcePtr, Length);
+
+ Status = AcpiCmCopyIsimpleToEsimple (SourceObject,
+ TargetObject, Info->FreeSpace, &ObjectSpace);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ break;
+
+ case 1:
+
+ /*
+ * Build the package object
+ */
+ TargetObject->Type = ACPI_TYPE_PACKAGE;
+ TargetObject->Package.Count = SourceObject->Package.Count;
+ TargetObject->Package.Elements = (ACPI_OBJECT *) Info->FreeSpace;
+
+ /*
+ * Pass the new package object back to the package walk routine
+ */
+ State->Pkg.ThisTargetObj = TargetObject;
+
+ /*
+ * Save space for the array of objects (Package elements)
+ * update the buffer length counter
+ */
+ ObjectSpace = (UINT32) ROUND_UP_TO_NATIVE_WORD (
+ TargetObject->Package.Count * sizeof (ACPI_OBJECT));
+ break;
+
+ default:
+ return (AE_BAD_PARAMETER);
}
- *BufferSpaceUsed = (UINT32) ROUND_UP_TO_NATIVE_WORD (Length);
+ Info->FreeSpace += ObjectSpace;
+ Info->Length += ObjectSpace;
- return_ACPI_STATUS (AE_OK);
+ return (Status);
}
-/******************************************************************************
+/*******************************************************************************
*
- * FUNCTION: AcpiCmBuildExternalPackageObject
+ * FUNCTION: AcpiCmCopyIpackageToEpackage
*
- * PARAMETERS: *InternalObj - Pointer to the object we are returning
- * *Buffer - Where the object is returned
- * *SpaceUsed - Where the object length is returned
+ * PARAMETERS: *InternalObject - Pointer to the object we are returning
+ * *Buffer - Where the object is returned
+ * *SpaceUsed - Where the object length is returned
*
- * RETURN: Status - the status of the call
+ * RETURN: Status
*
* DESCRIPTION: This function is called to place a package object in a user
* buffer. A package object by definition contains other objects.
@@ -297,52 +393,37 @@ AcpiCmBuildExternalSimpleObject (
******************************************************************************/
static ACPI_STATUS
-AcpiCmBuildExternalPackageObject (
- ACPI_OPERAND_OBJECT *InternalObj,
+AcpiCmCopyIpackageToEpackage (
+ ACPI_OPERAND_OBJECT *InternalObject,
UINT8 *Buffer,
UINT32 *SpaceUsed)
{
- UINT8 *FreeSpace;
- ACPI_OBJECT *ExternalObj;
- UINT32 CurrentDepth = 0;
+ ACPI_OBJECT *ExternalObject;
ACPI_STATUS Status;
- UINT32 Length = 0;
- UINT32 ThisIndex;
- UINT32 ObjectSpace;
- ACPI_OPERAND_OBJECT *ThisInternalObj;
- ACPI_OBJECT *ThisExternalObj;
- PKG_SEARCH_INFO *LevelPtr;
+ ACPI_PKG_INFO Info;
- FUNCTION_TRACE ("CmBuildExternalPackageObject");
+ FUNCTION_TRACE ("CmCopyIpackageToEpackage");
/*
* First package at head of the buffer
*/
- ExternalObj = (ACPI_OBJECT *) Buffer;
+ ExternalObject = (ACPI_OBJECT *) Buffer;
/*
* Free space begins right after the first package
*/
- FreeSpace = Buffer + ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
+ Info.Length = 0;
+ Info.ObjectSpace = 0;
+ Info.NumPackages = 1;
+ Info.FreeSpace = Buffer + ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
- /*
- * Initialize the working variables
- */
- MEMSET ((void *) Level, 0, sizeof (Level));
-
- Level[0].InternalObj = InternalObj;
- Level[0].ExternalObj = ExternalObj;
- Level[0].Index = 0;
- LevelPtr = &Level[0];
- CurrentDepth = 0;
-
- ExternalObj->Type = InternalObj->Common.Type;
- ExternalObj->Package.Count = InternalObj->Package.Count;
- ExternalObj->Package.Elements = (ACPI_OBJECT *) FreeSpace;
+ ExternalObject->Type = InternalObject->Common.Type;
+ ExternalObject->Package.Count = InternalObject->Package.Count;
+ ExternalObject->Package.Elements = (ACPI_OBJECT *) Info.FreeSpace;
/*
@@ -350,144 +431,27 @@ AcpiCmBuildExternalPackageObject (
* and move the free space past it
*/
- FreeSpace += ExternalObj->Package.Count *
- ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
-
-
- while (1)
- {
- ThisIndex = LevelPtr->Index;
- ThisInternalObj =
- (ACPI_OPERAND_OBJECT *)
- LevelPtr->InternalObj->Package.Elements[ThisIndex];
- ThisExternalObj =
- (ACPI_OBJECT *)
- &LevelPtr->ExternalObj->Package.Elements[ThisIndex];
-
+ Info.FreeSpace += ExternalObject->Package.Count *
+ ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
- /*
- * Check for
- * 1) Null object -- OK, this can happen if package
- * element is never initialized
- * 2) Not an internal object - can be Node instead
- * 3) Any internal object other than a package.
- *
- * The more complex package case is handled later
- */
- if ((!ThisInternalObj) ||
- (!VALID_DESCRIPTOR_TYPE (
- ThisInternalObj, ACPI_DESC_TYPE_INTERNAL)) ||
- (!IS_THIS_OBJECT_TYPE (
- ThisInternalObj, ACPI_TYPE_PACKAGE)))
- {
- /*
- * This is a simple or null object -- get the size
- */
+ Status = AcpiCmWalkPackageTree (InternalObject, ExternalObject,
+ AcpiCmCopyIelementToEelement, &Info);
- Status =
- AcpiCmBuildExternalSimpleObject (ThisInternalObj,
- ThisExternalObj,
- FreeSpace,
- &ObjectSpace);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- FreeSpace += ObjectSpace;
- Length += ObjectSpace;
-
- LevelPtr->Index++;
- while (LevelPtr->Index >=
- LevelPtr->InternalObj->Package.Count)
- {
- /*
- * We've handled all of the objects at this
- * level. This means that we have just
- * completed a package. That package may
- * have contained one or more packages
- * itself
- */
- if (CurrentDepth == 0)
- {
- /*
- * We have handled all of the objects
- * in the top level package just add
- * the length of the package objects
- * and get out
- */
- *SpaceUsed = Length;
- return_ACPI_STATUS (AE_OK);
- }
-
- /*
- * go back up a level and move the index
- * past the just completed package object.
- */
- CurrentDepth--;
- LevelPtr = &Level[CurrentDepth];
- LevelPtr->Index++;
- }
- }
+ *SpaceUsed = Info.Length;
+ return_ACPI_STATUS (Status);
- else
- {
- /*
- * This object is a package
- * -- we must go one level deeper
- */
- if (CurrentDepth >= MAX_PACKAGE_DEPTH-1)
- {
- /*
- * Too many nested levels of packages
- * for us to handle
- */
- DEBUG_PRINT (ACPI_ERROR,
- ("CmBuildPackageObject: Pkg nested too deep (max %X)\n",
- MAX_PACKAGE_DEPTH));
- return_ACPI_STATUS (AE_LIMIT);
- }
-
- /*
- * Build the package object
- */
- ThisExternalObj->Type = ACPI_TYPE_PACKAGE;
- ThisExternalObj->Package.Count =
- ThisInternalObj->Package.Count;
- ThisExternalObj->Package.Elements =
- (ACPI_OBJECT *) FreeSpace;
-
- /*
- * Save space for the array of objects (Package elements)
- * update the buffer length counter
- */
- ObjectSpace = (UINT32) ROUND_UP_TO_NATIVE_WORD (
- ThisExternalObj->Package.Count *
- sizeof (ACPI_OBJECT));
-
- FreeSpace += ObjectSpace;
- Length += ObjectSpace;
-
- CurrentDepth++;
- LevelPtr = &Level[CurrentDepth];
- LevelPtr->InternalObj = ThisInternalObj;
- LevelPtr->ExternalObj = ThisExternalObj;
- LevelPtr->Index = 0;
- }
- }
}
-
-/******************************************************************************
+/*******************************************************************************
*
- * FUNCTION: AcpiCmBuildExternalObject
+ * FUNCTION: AcpiCmCopyIobjectToEobject
*
- * PARAMETERS: *InternalObj - The internal object to be converted
- * *BufferPtr - Where the object is returned
+ * PARAMETERS: *InternalObject - The internal object to be converted
+ * *BufferPtr - Where the object is returned
*
- * RETURN: Status - the status of the call
+ * RETURN: Status
*
* DESCRIPTION: This function is called to build an API object to be returned to
* the caller.
@@ -495,26 +459,24 @@ AcpiCmBuildExternalPackageObject (
******************************************************************************/
ACPI_STATUS
-AcpiCmBuildExternalObject (
- ACPI_OPERAND_OBJECT *InternalObj,
+AcpiCmCopyIobjectToEobject (
+ ACPI_OPERAND_OBJECT *InternalObject,
ACPI_BUFFER *RetBuffer)
{
ACPI_STATUS Status;
- FUNCTION_TRACE ("CmBuildExternalObject");
+ FUNCTION_TRACE ("CmCopyIobjectToEobject");
- if (IS_THIS_OBJECT_TYPE (InternalObj, ACPI_TYPE_PACKAGE))
+ if (IS_THIS_OBJECT_TYPE (InternalObject, ACPI_TYPE_PACKAGE))
{
/*
- * Package objects contain other objects (which can be objects)
- * buildpackage does it all
+ * Package object: Copy all subobjects (including
+ * nested packages)
*/
- Status =
- AcpiCmBuildExternalPackageObject (InternalObj,
- RetBuffer->Pointer,
- &RetBuffer->Length);
+ Status = AcpiCmCopyIpackageToEpackage (InternalObject,
+ RetBuffer->Pointer, &RetBuffer->Length);
}
else
@@ -522,13 +484,11 @@ AcpiCmBuildExternalObject (
/*
* Build a simple object (no nested objects)
*/
- Status =
- AcpiCmBuildExternalSimpleObject (InternalObj,
- (ACPI_OBJECT *) RetBuffer->Pointer,
- ((UINT8 *) RetBuffer->Pointer +
- ROUND_UP_TO_NATIVE_WORD (
- sizeof (ACPI_OBJECT))),
- &RetBuffer->Length);
+ Status = AcpiCmCopyIsimpleToEsimple (InternalObject,
+ (ACPI_OBJECT *) RetBuffer->Pointer,
+ ((UINT8 *) RetBuffer->Pointer +
+ ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))),
+ &RetBuffer->Length);
/*
* build simple does not include the object size in the length
* so we add it in here
@@ -540,14 +500,15 @@ AcpiCmBuildExternalObject (
}
-/******************************************************************************
+
+/*******************************************************************************
*
- * FUNCTION: AcpiCmBuildInternalSimpleObject
+ * FUNCTION: AcpiCmCopyEsimpleToIsimple
*
- * PARAMETERS: *ExternalObj - The external object to be converted
- * *InternalObj - Where the internal object is returned
+ * PARAMETERS: *ExternalObject - The external object to be converted
+ * *InternalObject - Where the internal object is returned
*
- * RETURN: Status - the status of the call
+ * RETURN: Status
*
* DESCRIPTION: This function copies an external object to an internal one.
* NOTE: Pointers can be copied, we don't need to copy data.
@@ -557,30 +518,30 @@ AcpiCmBuildExternalObject (
******************************************************************************/
ACPI_STATUS
-AcpiCmBuildInternalSimpleObject (
- ACPI_OBJECT *ExternalObj,
- ACPI_OPERAND_OBJECT *InternalObj)
+AcpiCmCopyEsimpleToIsimple (
+ ACPI_OBJECT *ExternalObject,
+ ACPI_OPERAND_OBJECT *InternalObject)
{
- FUNCTION_TRACE ("CmBuildInternalSimpleObject");
+ FUNCTION_TRACE ("CmCopyEsimpleToIsimple");
- InternalObj->Common.Type = (UINT8) ExternalObj->Type;
+ InternalObject->Common.Type = (UINT8) ExternalObject->Type;
- switch (ExternalObj->Type)
+ switch (ExternalObject->Type)
{
case ACPI_TYPE_STRING:
- InternalObj->String.Length = ExternalObj->String.Length;
- InternalObj->String.Pointer = ExternalObj->String.Pointer;
+ InternalObject->String.Length = ExternalObject->String.Length;
+ InternalObject->String.Pointer = ExternalObject->String.Pointer;
break;
case ACPI_TYPE_BUFFER:
- InternalObj->Buffer.Length = ExternalObj->Buffer.Length;
- InternalObj->Buffer.Pointer = ExternalObj->Buffer.Pointer;
+ InternalObject->Buffer.Length = ExternalObject->Buffer.Length;
+ InternalObject->Buffer.Pointer = ExternalObject->Buffer.Pointer;
break;
@@ -588,7 +549,7 @@ AcpiCmBuildInternalSimpleObject (
/*
* Number is included in the object itself
*/
- InternalObj->Integer.Value = ExternalObj->Integer.Value;
+ InternalObject->Integer.Value = ExternalObject->Integer.Value;
break;
@@ -606,11 +567,11 @@ AcpiCmBuildInternalSimpleObject (
/* Code to convert packages that are parameters to control methods */
-/******************************************************************************
+/*******************************************************************************
*
- * FUNCTION: AcpiCmBuildInternalPackageObject
+ * FUNCTION: AcpiCmCopyEpackageToIpackage
*
- * PARAMETERS: *InternalObj - Pointer to the object we are returning
+ * PARAMETERS: *InternalObject - Pointer to the object we are returning
* *Buffer - Where the object is returned
* *SpaceUsed - Where the length of the object is returned
*
@@ -626,29 +587,27 @@ AcpiCmBuildInternalSimpleObject (
******************************************************************************/
static ACPI_STATUS
-AcpiCmBuildInternalPackageObject (
- ACPI_OPERAND_OBJECT *InternalObj,
+AcpiCmCopyEpackageToIpackage (
+ ACPI_OPERAND_OBJECT *InternalObject,
UINT8 *Buffer,
UINT32 *SpaceUsed)
{
UINT8 *FreeSpace;
- ACPI_OBJECT *ExternalObj;
- UINT32 CurrentDepth = 0;
+ ACPI_OBJECT *ExternalObject;
UINT32 Length = 0;
UINT32 ThisIndex;
UINT32 ObjectSpace = 0;
ACPI_OPERAND_OBJECT *ThisInternalObj;
ACPI_OBJECT *ThisExternalObj;
- PKG_SEARCH_INFO *LevelPtr;
- FUNCTION_TRACE ("CmBuildInternalPackageObject");
+ FUNCTION_TRACE ("CmCopyEpackageToIpackage");
/*
* First package at head of the buffer
*/
- ExternalObj = (ACPI_OBJECT *)Buffer;
+ ExternalObject = (ACPI_OBJECT *)Buffer;
/*
* Free space begins right after the first package
@@ -656,20 +615,9 @@ AcpiCmBuildInternalPackageObject (
FreeSpace = Buffer + sizeof(ACPI_OBJECT);
- /*
- * Initialize the working variables
- */
-
- MEMSET ((void *) Level, 0, sizeof(Level));
-
- Level[0].InternalObj = InternalObj;
- Level[0].ExternalObj = ExternalObj;
- LevelPtr = &Level[0];
- CurrentDepth = 0;
-
- ExternalObj->Type = InternalObj->Common.Type;
- ExternalObj->Package.Count = InternalObj->Package.Count;
- ExternalObj->Package.Elements = (ACPI_OBJECT *)FreeSpace;
+ ExternalObject->Type = InternalObject->Common.Type;
+ ExternalObject->Package.Count = InternalObject->Package.Count;
+ ExternalObject->Package.Elements = (ACPI_OBJECT *)FreeSpace;
/*
@@ -677,108 +625,21 @@ AcpiCmBuildInternalPackageObject (
* and move the free space past it
*/
- FreeSpace += ExternalObj->Package.Count * sizeof(ACPI_OBJECT);
-
-
- while (1)
- {
- ThisIndex = LevelPtr->Index;
-
- ThisInternalObj = (ACPI_OPERAND_OBJECT *)
- &LevelPtr->InternalObj->Package.Elements[ThisIndex];
-
- ThisExternalObj = (ACPI_OBJECT *)
- &LevelPtr->ExternalObj->Package.Elements[ThisIndex];
-
- if (IS_THIS_OBJECT_TYPE (ThisInternalObj, ACPI_TYPE_PACKAGE))
- {
- /*
- * If this object is a package then we go one deeper
- */
- if (CurrentDepth >= MAX_PACKAGE_DEPTH-1)
- {
- /*
- * Too many nested levels of packages for us to handle
- */
- DEBUG_PRINT (ACPI_ERROR,
- ("CmBuildPackageObject: Pkg nested too deep (max %X)\n",
- MAX_PACKAGE_DEPTH));
- return_ACPI_STATUS (AE_LIMIT);
- }
+ FreeSpace += ExternalObject->Package.Count * sizeof(ACPI_OBJECT);
- /*
- * Build the package object
- */
- ThisExternalObj->Type = ACPI_TYPE_PACKAGE;
- ThisExternalObj->Package.Count = ThisInternalObj->Package.Count;
- ThisExternalObj->Package.Elements = (ACPI_OBJECT *) FreeSpace;
- /*
- * Save space for the array of objects (Package elements)
- * update the buffer length counter
- */
- ObjectSpace = ThisExternalObj->Package.Count *
- sizeof (ACPI_OBJECT);
+ /* Call WalkPackage */
- FreeSpace += ObjectSpace;
- Length += ObjectSpace;
-
- CurrentDepth++;
- LevelPtr = &Level[CurrentDepth];
- LevelPtr->InternalObj = ThisInternalObj;
- LevelPtr->ExternalObj = ThisExternalObj;
- LevelPtr->Index = 0;
-
- } /* if object is a package */
-
- else
- {
- FreeSpace += ObjectSpace;
- Length += ObjectSpace;
-
- LevelPtr->Index++;
- while (LevelPtr->Index >=
- LevelPtr->InternalObj->Package.Count)
- {
- /*
- * We've handled all of the objects at
- * this level, This means that we have
- * just completed a package. That package
- * may have contained one or more packages
- * itself
- */
- if (CurrentDepth == 0)
- {
- /*
- * We have handled all of the objects
- * in the top level package just add
- * the length of the package objects
- * and get out
- */
- *SpaceUsed = Length;
- return_ACPI_STATUS (AE_OK);
- }
-
- /*
- * go back up a level and move the index
- * past the just completed package object.
- */
- CurrentDepth--;
- LevelPtr = &Level[CurrentDepth];
- LevelPtr->Index++;
- }
- } /* else object is NOT a package */
- } /* while (1) */
}
#endif /* Future implementation */
-/******************************************************************************
+/*******************************************************************************
*
- * FUNCTION: AcpiCmBuildInternalObject
+ * FUNCTION: AcpiCmCopyEobjectToIobject
*
- * PARAMETERS: *InternalObj - The external object to be converted
+ * PARAMETERS: *InternalObject - The external object to be converted
* *BufferPtr - Where the internal object is returned
*
* RETURN: Status - the status of the call
@@ -788,17 +649,17 @@ AcpiCmBuildInternalPackageObject (
******************************************************************************/
ACPI_STATUS
-AcpiCmBuildInternalObject (
- ACPI_OBJECT *ExternalObj,
- ACPI_OPERAND_OBJECT *InternalObj)
+AcpiCmCopyEobjectToIobject (
+ ACPI_OBJECT *ExternalObject,
+ ACPI_OPERAND_OBJECT *InternalObject)
{
ACPI_STATUS Status;
- FUNCTION_TRACE ("CmBuildInternalObject");
+ FUNCTION_TRACE ("AcpiCmCopyEobjectToIobject");
- if (ExternalObj->Type == ACPI_TYPE_PACKAGE)
+ if (ExternalObject->Type == ACPI_TYPE_PACKAGE)
{
/*
* Package objects contain other objects (which can be objects)
@@ -809,12 +670,12 @@ AcpiCmBuildInternalObject (
* control methods only. This is a very, very rare case.
*/
/*
- Status = AcpiCmBuildInternalPackageObject(InternalObj,
+ Status = AcpiCmCopyEpackageToIpackage(InternalObject,
RetBuffer->Pointer,
&RetBuffer->Length);
*/
DEBUG_PRINT (ACPI_ERROR,
- ("CmBuildInternalObject: Packages as parameters not implemented!\n"));
+ ("AcpiCmCopyEobjectToIobject: Packages as parameters not implemented!\n"));
return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
}
@@ -824,7 +685,7 @@ AcpiCmBuildInternalObject (
/*
* Build a simple object (no nested objects)
*/
- Status = AcpiCmBuildInternalSimpleObject (ExternalObj, InternalObj);
+ Status = AcpiCmCopyEsimpleToIsimple (ExternalObject, InternalObject);
/*
* build simple does not include the object size in the length
* so we add it in here
@@ -834,3 +695,146 @@ AcpiCmBuildInternalObject (
return_ACPI_STATUS (Status);
}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiCmCopyIelementToIelement
+ *
+ * PARAMETERS: ACPI_PKG_CALLBACK
+ *
+ * RETURN: Status - the status of the call
+ *
+ * DESCRIPTION: Copy one package element to another package element
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiCmCopyIelementToIelement (
+ UINT8 ObjectType,
+ ACPI_OPERAND_OBJECT *SourceObject,
+ ACPI_GENERIC_STATE *State,
+ void *Context)
+{
+ ACPI_STATUS Status = AE_OK;
+ UINT32 ThisIndex;
+ ACPI_OPERAND_OBJECT **ThisTargetPtr;
+ ACPI_OPERAND_OBJECT *TargetObject;
+
+
+
+ ThisIndex = State->Pkg.Index;
+ ThisTargetPtr = (ACPI_OPERAND_OBJECT **)
+ &State->Pkg.DestObject->Package.Elements[ThisIndex];
+
+ switch (ObjectType)
+ {
+ case 0:
+
+ /*
+ * This is a simple object, just copy it
+ */
+ TargetObject = AcpiCmCreateInternalObject (SourceObject->Common.Type);
+ if (!TargetObject)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ Status = AcpiAmlStoreObjectToObject (SourceObject, TargetObject,
+ (ACPI_WALK_STATE *) Context);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ *ThisTargetPtr = TargetObject;
+ break;
+
+
+ case 1:
+ /*
+ * This object is a package - go down another nesting level
+ * Create and build the package object
+ */
+ TargetObject = AcpiCmCreateInternalObject (ACPI_TYPE_PACKAGE);
+ if (!TargetObject)
+ {
+ /* TBD: must delete package created up to this point */
+
+ return (AE_NO_MEMORY);
+ }
+
+ TargetObject->Package.Count = SourceObject->Package.Count;
+
+ /*
+ * Pass the new package object back to the package walk routine
+ */
+ State->Pkg.ThisTargetObj = TargetObject;
+
+ /*
+ * Store the object pointer in the parent package object
+ */
+ *ThisTargetPtr = TargetObject;
+ break;
+
+ default:
+ return (AE_BAD_PARAMETER);
+ }
+
+
+ return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiCmCopyIpackageToIpackage
+ *
+ * PARAMETERS: *SourceObj - Pointer to the source package object
+ * *DestObj - Where the internal object is returned
+ *
+ * RETURN: Status - the status of the call
+ *
+ * DESCRIPTION: This function is called to copy an internal package object
+ * into another internal package object.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiCmCopyIpackageToIpackage (
+ ACPI_OPERAND_OBJECT *SourceObj,
+ ACPI_OPERAND_OBJECT *DestObj,
+ ACPI_WALK_STATE *WalkState)
+{
+ ACPI_STATUS Status = AE_OK;
+
+ FUNCTION_TRACE ("CmCopyIpackageToIpackage");
+
+
+
+ DestObj->Common.Type = SourceObj->Common.Type;
+ DestObj->Package.Count = SourceObj->Package.Count;
+
+
+ /*
+ * Create the object array and walk the source package tree
+ */
+
+ DestObj->Package.Elements = AcpiCmCallocate ((SourceObj->Package.Count + 1) *
+ sizeof (void *));
+ DestObj->Package.NextElement = DestObj->Package.Elements;
+
+ if (!DestObj->Package.Elements)
+ {
+ REPORT_ERROR (
+ ("AmlBuildCopyInternalPackageObject: Package allocation failure\n"));
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+
+ Status = AcpiCmWalkPackageTree (SourceObj, DestObj,
+ AcpiCmCopyIelementToIelement, WalkState);
+
+ return_ACPI_STATUS (Status);
+}
+
diff --git a/sys/contrib/dev/acpica/Subsystem/Common/cmobject.c b/sys/contrib/dev/acpica/Subsystem/Common/cmobject.c
index dd8bf22..13869b3 100644
--- a/sys/contrib/dev/acpica/Subsystem/Common/cmobject.c
+++ b/sys/contrib/dev/acpica/Subsystem/Common/cmobject.c
@@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: cmobject - ACPI object create/delete/size/cache routines
- * $Revision: 35 $
+ * $Revision: 36 $
*
*****************************************************************************/
@@ -127,7 +127,7 @@
MODULE_NAME ("cmobject")
-/******************************************************************************
+/*******************************************************************************
*
* FUNCTION: _CmCreateInternalObject
*
@@ -141,11 +141,11 @@
*
* DESCRIPTION: Create and initialize a new internal object.
*
- * NOTE:
- * We always allocate the worst-case object descriptor because these
- * objects are cached, and we want them to be one-size-satisifies-any-request.
- * This in itself may not be the most memory efficient, but the efficiency
- * of the object cache should more than make up for this!
+ * NOTE: We always allocate the worst-case object descriptor because
+ * these objects are cached, and we want them to be
+ * one-size-satisifies-any-request. This in itself may not be
+ * the most memory efficient, but the efficiency of the object
+ * cache should more than make up for this!
*
******************************************************************************/
@@ -187,7 +187,7 @@ _CmCreateInternalObject (
}
-/******************************************************************************
+/*******************************************************************************
*
* FUNCTION: AcpiCmValidInternalObject
*
@@ -195,7 +195,7 @@ _CmCreateInternalObject (
*
* RETURN: Validate a pointer to be an ACPI_OPERAND_OBJECT
*
- *****************************************************************************/
+ ******************************************************************************/
BOOLEAN
AcpiCmValidInternalObject (
@@ -257,7 +257,7 @@ AcpiCmValidInternalObject (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: _CmAllocateObjectDesc
*
@@ -271,7 +271,7 @@ AcpiCmValidInternalObject (
* DESCRIPTION: Allocate a new object descriptor. Gracefully handle
* error conditions.
*
- ****************************************************************************/
+ ******************************************************************************/
void *
_CmAllocateObjectDesc (
@@ -341,7 +341,7 @@ _CmAllocateObjectDesc (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: AcpiCmDeleteObjectDesc
*
@@ -351,7 +351,7 @@ _CmAllocateObjectDesc (
*
* DESCRIPTION: Free an ACPI object descriptor or add it to the object cache
*
- ****************************************************************************/
+ ******************************************************************************/
void
AcpiCmDeleteObjectDesc (
@@ -414,7 +414,7 @@ AcpiCmDeleteObjectDesc (
}
-/******************************************************************************
+/*******************************************************************************
*
* FUNCTION: AcpiCmDeleteObjectCache
*
@@ -461,7 +461,7 @@ AcpiCmDeleteObjectCache (
}
-/*****************************************************************************
+/*******************************************************************************
*
* FUNCTION: AcpiCmInitStaticObject
*
@@ -473,7 +473,7 @@ AcpiCmDeleteObjectCache (
* DESCRIPTION: Initialize a static object. Sets flags to disallow dynamic
* deletion of the object.
*
- ****************************************************************************/
+ ******************************************************************************/
void
AcpiCmInitStaticObject (
@@ -512,14 +512,14 @@ AcpiCmInitStaticObject (
}
-/******************************************************************************
+/*******************************************************************************
*
* FUNCTION: AcpiCmGetSimpleObjectSize
*
- * PARAMETERS: *InternalObj - Pointer to the object we are examining
- * *RetLength - Where the length is returned
+ * PARAMETERS: *InternalObject - Pointer to the object we are examining
+ * *RetLength - Where the length is returned
*
- * RETURN: Status - the status of the call
+ * RETURN: Status
*
* DESCRIPTION: This function is called to determine the space required to
* contain a simple object for return to an API user.
@@ -531,19 +531,19 @@ AcpiCmInitStaticObject (
ACPI_STATUS
AcpiCmGetSimpleObjectSize (
- ACPI_OPERAND_OBJECT *InternalObj,
+ ACPI_OPERAND_OBJECT *InternalObject,
UINT32 *ObjLength)
{
UINT32 Length;
ACPI_STATUS Status = AE_OK;
- FUNCTION_TRACE_PTR ("CmGetSimpleObjectSize", InternalObj);
+ FUNCTION_TRACE_PTR ("CmGetSimpleObjectSize", InternalObject);
/* Handle a null object (Could be a uninitialized package element -- which is legal) */
- if (!InternalObj)
+ if (!InternalObject)
{
*ObjLength = 0;
return_ACPI_STATUS (AE_OK);
@@ -554,7 +554,7 @@ AcpiCmGetSimpleObjectSize (
Length = sizeof (ACPI_OBJECT);
- if (VALID_DESCRIPTOR_TYPE (InternalObj, ACPI_DESC_TYPE_NAMED))
+ if (VALID_DESCRIPTOR_TYPE (InternalObject, ACPI_DESC_TYPE_NAMED))
{
/* Object is a named object (reference), just return the length */
@@ -571,18 +571,18 @@ AcpiCmGetSimpleObjectSize (
* TBD:[Investigate] do strings and buffers require alignment also?
*/
- switch (InternalObj->Common.Type)
+ switch (InternalObject->Common.Type)
{
case ACPI_TYPE_STRING:
- Length += InternalObj->String.Length + 1;
+ Length += InternalObject->String.Length + 1;
break;
case ACPI_TYPE_BUFFER:
- Length += InternalObj->Buffer.Length;
+ Length += InternalObject->Buffer.Length;
break;
@@ -602,11 +602,11 @@ AcpiCmGetSimpleObjectSize (
* The only type that should be here is opcode AML_NAMEPATH_OP -- since
* this means an object reference
*/
- if (InternalObj->Reference.OpCode != AML_NAMEPATH_OP)
+ if (InternalObject->Reference.OpCode != AML_NAMEPATH_OP)
{
DEBUG_PRINT (ACPI_ERROR,
("CmGetSimpleObjectSize: Unsupported Reference opcode=%X in object %p\n",
- InternalObj->Reference.OpCode, InternalObj));
+ InternalObject->Reference.OpCode, InternalObject));
Status = AE_TYPE;
}
break;
@@ -616,7 +616,7 @@ AcpiCmGetSimpleObjectSize (
DEBUG_PRINT (ACPI_ERROR,
("CmGetSimpleObjectSize: Unsupported type=%X in object %p\n",
- InternalObj->Common.Type, InternalObj));
+ InternalObject->Common.Type, InternalObject));
Status = AE_TYPE;
break;
}
@@ -634,161 +634,124 @@ AcpiCmGetSimpleObjectSize (
}
-/******************************************************************************
+/*******************************************************************************
*
- * FUNCTION: AcpiCmGetPackageObjectSize
+ * FUNCTION: AcpiCmCopyPackageToInternal
*
- * PARAMETERS: *InternalObj - Pointer to the object we are examining
- * *RetLength - Where the length is returned
+ * PARAMETERS: ACPI_PKG_CALLBACK
*
* RETURN: Status - the status of the call
*
- * DESCRIPTION: This function is called to determine the space required to contain
- * a package object for return to an API user.
- *
- * This is moderately complex since a package contains other objects
- * including packages.
+ * DESCRIPTION:
*
******************************************************************************/
ACPI_STATUS
-AcpiCmGetPackageObjectSize (
- ACPI_OPERAND_OBJECT *InternalObj,
- UINT32 *ObjLength)
+AcpiCmGetElementLength (
+ UINT8 ObjectType,
+ ACPI_OPERAND_OBJECT *SourceObject,
+ ACPI_GENERIC_STATE *State,
+ void *Context)
{
-
- ACPI_OPERAND_OBJECT *ThisInternalObj;
- ACPI_OPERAND_OBJECT *ParentObj[MAX_PACKAGE_DEPTH];
- ACPI_OPERAND_OBJECT *ThisParent;
- UINT32 ThisIndex;
- UINT32 Index[MAX_PACKAGE_DEPTH];
- UINT32 Length = 0;
+ ACPI_STATUS Status = AE_OK;
+ ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context;
UINT32 ObjectSpace;
- UINT32 CurrentDepth = 0;
- UINT32 PackageCount = 1;
- ACPI_STATUS Status;
- FUNCTION_TRACE_PTR ("CmGetPackageObjectSize", InternalObj);
+ switch (ObjectType)
+ {
+ case 0:
+ /*
+ * Simple object - just get the size (Null object/entry is handled
+ * here also) and sum it into the running package length
+ */
+ Status = AcpiCmGetSimpleObjectSize (SourceObject, &ObjectSpace);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
- /* Init the package stack TBD: replace with linked list */
+ Info->Length += ObjectSpace;
+ break;
- MEMSET(ParentObj, 0, MAX_PACKAGE_DEPTH);
- MEMSET(Index, 0, MAX_PACKAGE_DEPTH);
- ParentObj[0] = InternalObj;
+ case 1:
+ /* Package - nothing much to do here, let the walk handle it */
- while (1)
- {
- ThisParent = ParentObj[CurrentDepth];
- ThisIndex = Index[CurrentDepth];
- ThisInternalObj = ThisParent->Package.Elements[ThisIndex];
+ Info->NumPackages++;
+ State->Pkg.ThisTargetObj = NULL;
+ break;
+ default:
+ return (AE_BAD_PARAMETER);
+ }
- /*
- * Check for 1) An uninitialized package element. It is completely
- * legal to declare a package and leave it uninitialized
- * 2) Any type other than a package. Packages are handled
- * below.
- */
- if ((!ThisInternalObj) ||
- (!IS_THIS_OBJECT_TYPE (ThisInternalObj, ACPI_TYPE_PACKAGE)))
- {
- /*
- * Simple object - just get the size (Null object/entry handled
- * also)
- */
-
- Status =
- AcpiCmGetSimpleObjectSize (ThisInternalObj, &ObjectSpace);
-
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
-
- Length += ObjectSpace;
-
- Index[CurrentDepth]++;
- while (Index[CurrentDepth] >=
- ParentObj[CurrentDepth]->Package.Count)
- {
- /*
- * We've handled all of the objects at
- * this level, This means that we have
- * just completed a package. That package
- * may have contained one or more packages
- * itself.
- */
- if (CurrentDepth == 0)
- {
- /*
- * We have handled all of the objects
- * in the top level package just add the
- * length of the package objects and
- * get out. Round up to the next machine
- * word.
- */
- Length +=
- ROUND_UP_TO_NATIVE_WORD (
- sizeof (ACPI_OBJECT)) *
- PackageCount;
-
- *ObjLength = Length;
-
- return_ACPI_STATUS (AE_OK);
- }
-
- /*
- * Go back up a level and move the index
- * past the just completed package object.
- */
- CurrentDepth--;
- Index[CurrentDepth]++;
- }
- }
+ return (Status);
+}
- else
- {
- /*
- * This object is a package
- * -- go one level deeper
- */
- PackageCount++;
- if (CurrentDepth < MAX_PACKAGE_DEPTH-1)
- {
- CurrentDepth++;
- ParentObj[CurrentDepth] = ThisInternalObj;
- Index[CurrentDepth] = 0;
- }
-
- else
- {
- /*
- * Too many nested levels of packages for us
- * to handle
- */
-
- DEBUG_PRINT (ACPI_ERROR,
- ("CmGetPackageObjectSize: Pkg nested too deep (max %X)\n",
- MAX_PACKAGE_DEPTH));
- return_ACPI_STATUS (AE_LIMIT);
- }
- }
- }
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiCmGetPackageObjectSize
+ *
+ * PARAMETERS: *InternalObject - Pointer to the object we are examining
+ * *RetLength - Where the length is returned
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: This function is called to determine the space required to
+ * contain a package object for return to an API user.
+ *
+ * This is moderately complex since a package contains other
+ * objects including packages.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiCmGetPackageObjectSize (
+ ACPI_OPERAND_OBJECT *InternalObject,
+ UINT32 *ObjLength)
+{
+ ACPI_STATUS Status;
+ ACPI_PKG_INFO Info;
+
+
+ FUNCTION_TRACE_PTR ("CmGetPackageObjectSize", InternalObject);
+
+
+ Info.Length = 0;
+ Info.ObjectSpace = 0;
+ Info.NumPackages = 1;
+
+ Status = AcpiCmWalkPackageTree (InternalObject, NULL,
+ AcpiCmGetElementLength, &Info);
+
+ /*
+ * We have handled all of the objects in all levels of the package.
+ * just add the length of the package objects themselves.
+ * Round up to the next machine word.
+ */
+ Info.Length += ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)) *
+ Info.NumPackages;
+
+ /* Return the total package length */
+
+ *ObjLength = Info.Length;
+ return_ACPI_STATUS (Status);
}
-/******************************************************************************
+
+/*******************************************************************************
*
* FUNCTION: AcpiCmGetObjectSize
*
- * PARAMETERS: *InternalObj - Pointer to the object we are examining
- * *RetLength - Where the length will be returned
+ * PARAMETERS: *InternalObject - Pointer to the object we are examining
+ * *RetLength - Where the length will be returned
*
- * RETURN: Status - the status of the call
+ * RETURN: Status
*
* DESCRIPTION: This function is called to determine the space required to
* contain an object for return to an API user.
@@ -797,23 +760,21 @@ AcpiCmGetPackageObjectSize (
ACPI_STATUS
AcpiCmGetObjectSize(
- ACPI_OPERAND_OBJECT *InternalObj,
+ ACPI_OPERAND_OBJECT *InternalObject,
UINT32 *ObjLength)
{
ACPI_STATUS Status;
- if ((VALID_DESCRIPTOR_TYPE (InternalObj, ACPI_DESC_TYPE_INTERNAL)) &&
- (IS_THIS_OBJECT_TYPE (InternalObj, ACPI_TYPE_PACKAGE)))
+ if ((VALID_DESCRIPTOR_TYPE (InternalObject, ACPI_DESC_TYPE_INTERNAL)) &&
+ (IS_THIS_OBJECT_TYPE (InternalObject, ACPI_TYPE_PACKAGE)))
{
- Status =
- AcpiCmGetPackageObjectSize (InternalObj, ObjLength);
+ Status = AcpiCmGetPackageObjectSize (InternalObject, ObjLength);
}
else
{
- Status =
- AcpiCmGetSimpleObjectSize (InternalObj, ObjLength);
+ Status = AcpiCmGetSimpleObjectSize (InternalObject, ObjLength);
}
return (Status);
diff --git a/sys/contrib/dev/acpica/Subsystem/Common/cmutils.c b/sys/contrib/dev/acpica/Subsystem/Common/cmutils.c
index 2c9c60d..123e4e1 100644
--- a/sys/contrib/dev/acpica/Subsystem/Common/cmutils.c
+++ b/sys/contrib/dev/acpica/Subsystem/Common/cmutils.c
@@ -1,7 +1,7 @@
/*******************************************************************************
*
* Module Name: cmutils - common utility procedures
- * $Revision: 23 $
+ * $Revision: 27 $
*
******************************************************************************/
@@ -476,6 +476,44 @@ AcpiCmCreateUpdateStateAndPush (
/*******************************************************************************
*
+ * FUNCTION: AcpiCmCreatePkgStateAndPush
+ *
+ * PARAMETERS: *Object - Object to be added to the new state
+ * Action - Increment/Decrement
+ * StateList - List the state will be added to
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Create a new state and push it
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiCmCreatePkgStateAndPush (
+ void *InternalObject,
+ void *ExternalObject,
+ UINT16 Index,
+ ACPI_GENERIC_STATE **StateList)
+{
+ ACPI_GENERIC_STATE *State;
+
+
+
+ State = AcpiCmCreatePkgState (InternalObject, ExternalObject, Index);
+ if (!State)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+
+ AcpiCmPushGenericState (StateList, State);
+ return (AE_OK);
+}
+
+
+
+/*******************************************************************************
+ *
* FUNCTION: AcpiCmPushGenericState
*
* PARAMETERS: ListHead - Head of the state stack
@@ -650,6 +688,54 @@ AcpiCmCreateUpdateState (
/*******************************************************************************
*
+ * FUNCTION: AcpiCmCreatePkgState
+ *
+ * PARAMETERS: Object - Initial Object to be installed in the
+ * state
+ * Action - Update action to be performed
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Create an "Update State" - a flavor of the generic state used
+ * to update reference counts and delete complex objects such
+ * as packages.
+ *
+ ******************************************************************************/
+
+ACPI_GENERIC_STATE *
+AcpiCmCreatePkgState (
+ void *InternalObject,
+ void *ExternalObject,
+ UINT16 Index)
+{
+ ACPI_GENERIC_STATE *State;
+
+
+ FUNCTION_TRACE_PTR ("CmCreatePkgState", InternalObject);
+
+
+ /* Create the generic state object */
+
+ State = AcpiCmCreateGenericState ();
+ if (!State)
+ {
+ return (NULL);
+ }
+
+ /* Init fields specific to the update struct */
+
+ State->Pkg.SourceObject = (ACPI_OPERAND_OBJECT *) InternalObject;
+ State->Pkg.DestObject = ExternalObject;
+ State->Pkg.Index = Index;
+ State->Pkg.NumPackages = 1;
+
+ return_PTR (State);
+}
+
+
+
+/*******************************************************************************
+ *
* FUNCTION: AcpiCmCreateControlState
*
* PARAMETERS: None
@@ -793,19 +879,24 @@ ACPI_STATUS
AcpiCmResolvePackageReferences (
ACPI_OPERAND_OBJECT *ObjDesc)
{
- UINT32 Count;
- ACPI_OPERAND_OBJECT *SubObject;
+ UINT32 Count;
+ ACPI_OPERAND_OBJECT *SubObject;
+
FUNCTION_TRACE ("AcpiCmResolvePackageReferences");
+
if (ObjDesc->Common.Type != ACPI_TYPE_PACKAGE)
{
- /* Must be a package */
+ /* The object must be a package */
REPORT_ERROR (("Must resolve Package Refs on a Package\n"));
return_ACPI_STATUS(AE_ERROR);
}
+ /*
+ * TBD: what about nested packages? */
+
for (Count = 0; Count < ObjDesc->Package.Count; Count++)
{
SubObject = ObjDesc->Package.Elements[Count];
@@ -833,6 +924,181 @@ AcpiCmResolvePackageReferences (
return_ACPI_STATUS(AE_OK);
}
+#ifdef ACPI_DEBUG
+
+/******************************************************************************
+ *
+ * FUNCTION: AcpiCmDisplayInitPathname
+ *
+ * PARAMETERS: ObjHandle - Handle whose pathname will be displayed
+ * Path - Additional path string to be appended
+ *
+ * RETURN: ACPI_STATUS
+ *
+ * DESCRIPTION: Display full pathnbame of an object, DEBUG ONLY
+ *
+ *****************************************************************************/
+
+void
+AcpiCmDisplayInitPathname (
+ ACPI_HANDLE ObjHandle,
+ char *Path)
+{
+ ACPI_STATUS Status;
+ UINT32 Length = 128;
+ char Buffer[128];
+
+
+ Status = AcpiNsHandleToPathname (ObjHandle, &Length, Buffer);
+ if (ACPI_SUCCESS (Status))
+ {
+ if (Path)
+ {
+ DEBUG_PRINT (TRACE_INIT, ("%s.%s\n", Buffer, Path))
+ }
+ else
+ {
+ DEBUG_PRINT (TRACE_INIT, ("%s\n", Buffer))
+ }
+ }
+}
+#endif
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiCmWalkPackageTree
+ *
+ * PARAMETERS: ObjDesc - The Package object on which to resolve refs
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Walk through a package
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiCmWalkPackageTree (
+ ACPI_OPERAND_OBJECT *SourceObject,
+ void *TargetObject,
+ ACPI_PKG_CALLBACK WalkCallback,
+ void *Context)
+{
+ ACPI_STATUS Status = AE_OK;
+ ACPI_GENERIC_STATE *StateList = NULL;
+ ACPI_GENERIC_STATE *State;
+ UINT32 ThisIndex;
+ ACPI_OPERAND_OBJECT *ThisSourceObj;
+
+
+ FUNCTION_TRACE ("AcpiCmWalkPackageTree");
+
+
+ State = AcpiCmCreatePkgState (SourceObject, TargetObject, 0);
+ if (!State)
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
+ while (State)
+ {
+ ThisIndex = State->Pkg.Index;
+ ThisSourceObj = (ACPI_OPERAND_OBJECT *)
+ State->Pkg.SourceObject->Package.Elements[ThisIndex];
+
+ /*
+ * Check for
+ * 1) An uninitialized package element. It is completely
+ * legal to declare a package and leave it uninitialized
+ * 2) Not an internal object - can be a namespace node instead
+ * 3) Any type other than a package. Packages are handled in else case below.
+ */
+ if ((!ThisSourceObj) ||
+ (!VALID_DESCRIPTOR_TYPE (
+ ThisSourceObj, ACPI_DESC_TYPE_INTERNAL)) ||
+ (!IS_THIS_OBJECT_TYPE (
+ ThisSourceObj, ACPI_TYPE_PACKAGE)))
+ {
+
+ Status = WalkCallback (0, ThisSourceObj, State, Context);
+ if (ACPI_FAILURE (Status))
+ {
+ /* TBD: must delete package created up to this point */
+
+ return_ACPI_STATUS (Status);
+ }
+
+ State->Pkg.Index++;
+ while (State->Pkg.Index >= State->Pkg.SourceObject->Package.Count)
+ {
+ /*
+ * We've handled all of the objects at this level, This means
+ * that we have just completed a package. That package may
+ * have contained one or more packages itself.
+ *
+ * Delete this state and pop the previous state (package).
+ */
+ AcpiCmDeleteGenericState (State);
+ State = AcpiCmPopGenericState (&StateList);
+
+
+ /* Finished when there are no more states */
+
+ if (!State)
+ {
+ /*
+ * We have handled all of the objects in the top level
+ * package just add the length of the package objects
+ * and exit
+ */
+ return_ACPI_STATUS (AE_OK);
+ }
+
+ /*
+ * Go back up a level and move the index past the just
+ * completed package object.
+ */
+ State->Pkg.Index++;
+ }
+ }
+
+ else
+ {
+ /* This is a sub-object of type package */
+
+ Status = WalkCallback (1, ThisSourceObj, State, Context);
+ if (ACPI_FAILURE (Status))
+ {
+ /* TBD: must delete package created up to this point */
+
+ return_ACPI_STATUS (Status);
+ }
+
+
+ /*
+ * The callback above returned a new target package object.
+ */
+
+ /*
+ * Push the current state and create a new one
+ */
+ AcpiCmPushGenericState (&StateList, State);
+ State = AcpiCmCreatePkgState (ThisSourceObj, State->Pkg.ThisTargetObj, 0);
+ if (!State)
+ {
+ /* TBD: must delete package created up to this point */
+
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+ }
+ }
+
+ /* We should never get here */
+
+ return (AE_AML_INTERNAL);
+
+}
+
+
/*******************************************************************************
*
@@ -845,7 +1111,7 @@ AcpiCmResolvePackageReferences (
*
* RETURN: None
*
- * DESCRIPTION: Print error message from KD table
+ * DESCRIPTION: Print error message
*
******************************************************************************/
@@ -872,7 +1138,7 @@ _ReportError (
*
* RETURN: None
*
- * DESCRIPTION: Print warning message from KD table
+ * DESCRIPTION: Print warning message
*
******************************************************************************/
@@ -898,7 +1164,7 @@ _ReportWarning (
*
* RETURN: None
*
- * DESCRIPTION: Print information message from KD table
+ * DESCRIPTION: Print information message
*
******************************************************************************/
diff --git a/sys/contrib/dev/acpica/Subsystem/Common/cmxface.c b/sys/contrib/dev/acpica/Subsystem/Common/cmxface.c
index 2376295..92312b9 100644
--- a/sys/contrib/dev/acpica/Subsystem/Common/cmxface.c
+++ b/sys/contrib/dev/acpica/Subsystem/Common/cmxface.c
@@ -1,7 +1,7 @@
/******************************************************************************
*
* Module Name: cmxface - External interfaces for "global" ACPI functions
- * $Revision: 62 $
+ * $Revision: 64 $
*
*****************************************************************************/
@@ -272,9 +272,8 @@ AcpiEnableSubsystem (
Status = AcpiEnable ();
if (ACPI_FAILURE (Status))
{
- /* TBD: workaround. Old Lions don't enable properly */
DEBUG_PRINT(ACPI_WARN, ("AcpiEnable failed.\n"));
- /*return_ACPI_STATUS (Status);*/
+ return_ACPI_STATUS (Status);
}
}
@@ -299,15 +298,14 @@ AcpiEnableSubsystem (
/*
* Initialize all device objects in the namespace
- * This runs the _STA, _INI, and _HID methods, and detects
- * the PCI root bus(es)
+ * This runs the _STA and _INI methods.
*/
if (!(Flags & ACPI_NO_DEVICE_INIT))
{
DEBUG_PRINT (TRACE_EXEC, ("[Init] Initializing ACPI Devices\n"));
- Status = AcpiNsInitializeDevices (Flags & ACPI_NO_PCI_INIT);
+ Status = AcpiNsInitializeDevices ();
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
@@ -316,7 +314,7 @@ AcpiEnableSubsystem (
/*
- * Initialize the objects that remain unitialized. This
+ * Initialize the objects that remain uninitialized. This
* runs the executable AML that is part of the declaration of OpRegions
* and Fields.
*/
OpenPOWER on IntegriCloud