diff options
author | iwasaki <iwasaki@FreeBSD.org> | 2002-06-30 17:50:46 +0000 |
---|---|---|
committer | iwasaki <iwasaki@FreeBSD.org> | 2002-06-30 17:50:46 +0000 |
commit | 6b92cff93be2b7ae83deb340b753b02444cdcacd (patch) | |
tree | a30a26908f5dc9678327cc04b639b945340f97c7 /sys/contrib/dev/acpica/dsobject.c | |
parent | 918310234a7ff346da92f4f10b72dac878b415f2 (diff) | |
download | FreeBSD-src-6b92cff93be2b7ae83deb340b753b02444cdcacd.zip FreeBSD-src-6b92cff93be2b7ae83deb340b753b02444cdcacd.tar.gz |
Vendor import of the Intel ACPI CA 200200404 drop.
Diffstat (limited to 'sys/contrib/dev/acpica/dsobject.c')
-rw-r--r-- | sys/contrib/dev/acpica/dsobject.c | 363 |
1 files changed, 199 insertions, 164 deletions
diff --git a/sys/contrib/dev/acpica/dsobject.c b/sys/contrib/dev/acpica/dsobject.c index d56125f..d367c91 100644 --- a/sys/contrib/dev/acpica/dsobject.c +++ b/sys/contrib/dev/acpica/dsobject.c @@ -1,7 +1,7 @@ /****************************************************************************** * * Module Name: dsobject - Dispatcher object management routines - * $Revision: 90 $ + * $Revision: 91 $ * *****************************************************************************/ @@ -139,11 +139,11 @@ * RETURN: Status * * DESCRIPTION: Callback from AcpiWalkNamespace. Invoked for every object - * within the namespace. + * within the namespace. * * Currently, the only objects that require initialization are: * 1) Methods - * 2) Op Regions + * 2) Operation Regions * ******************************************************************************/ @@ -176,7 +176,6 @@ AcpiDsInitOneObject ( return (AE_OK); } - /* And even then, we are only interested in a few object types */ Type = AcpiNsGetType (ObjHandle); @@ -249,12 +248,13 @@ AcpiDsInitOneObject ( * * FUNCTION: AcpiDsInitializeObjects * - * PARAMETERS: None + * PARAMETERS: TableDesc - Descriptor for parent ACPI table + * StartNode - Root of subtree to be initialized. * * RETURN: Status * - * DESCRIPTION: Walk the entire namespace and perform any necessary - * initialization on the objects found therein + * DESCRIPTION: Walk the namespace starting at "StartNode" and perform any + * necessary initialization on the objects found therein * ******************************************************************************/ @@ -280,7 +280,6 @@ AcpiDsInitializeObjects ( Info.ObjectCount = 0; Info.TableDesc = TableDesc; - /* Walk entire namespace from the supplied root */ Status = AcpiWalkNamespace (ACPI_TYPE_ANY, StartNode, ACPI_UINT32_MAX, @@ -306,9 +305,10 @@ AcpiDsInitializeObjects ( * * FUNCTION: AcpiDsInitObjectFromOp * - * PARAMETERS: Op - Parser op used to init the internal object + * PARAMETERS: WalkState - Current walk state + * Op - Parser op used to init the internal object * Opcode - AML opcode associated with the object - * ObjDesc - Namespace object to be initialized + * RetObjDesc - Namespace object to be initialized * * RETURN: Status * @@ -325,10 +325,6 @@ AcpiDsInitObjectFromOp ( UINT16 Opcode, ACPI_OPERAND_OBJECT **RetObjDesc) { - ACPI_STATUS Status; - ACPI_PARSE_OBJECT *Arg; - ACPI_PARSE2_OBJECT *ByteList; - ACPI_OPERAND_OBJECT *ArgDesc; const ACPI_OPCODE_INFO *OpInfo; ACPI_OPERAND_OBJECT *ObjDesc; @@ -345,108 +341,40 @@ AcpiDsInitObjectFromOp ( return (AE_TYPE); } - - /* Get and prepare the first argument */ + /* Perform per-object initialization */ switch (ObjDesc->Common.Type) { case ACPI_TYPE_BUFFER: - ObjDesc->Buffer.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; - - /* First arg is a number */ - - AcpiDsCreateOperand (WalkState, Op->Value.Arg, 0); - ArgDesc = WalkState->Operands [WalkState->NumOperands - 1]; - AcpiDsObjStackPop (1, WalkState); - - /* Resolve the object (could be an arg or local) */ - - Status = AcpiExResolveToValue (&ArgDesc, WalkState); - if (ACPI_FAILURE (Status)) - { - AcpiUtRemoveReference (ArgDesc); - return (Status); - } - - /* We are expecting a number */ - - if (ArgDesc->Common.Type != ACPI_TYPE_INTEGER) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Expecting number, got obj: %p type %X\n", - ArgDesc, ArgDesc->Common.Type)); - AcpiUtRemoveReference (ArgDesc); - return (AE_TYPE); - } - - /* Get the value, delete the internal object */ - - ObjDesc->Buffer.Length = (UINT32) ArgDesc->Integer.Value; - AcpiUtRemoveReference (ArgDesc); - - /* Allocate the buffer */ - - if (ObjDesc->Buffer.Length == 0) - { - ObjDesc->Buffer.Pointer = NULL; - ACPI_REPORT_WARNING (("Buffer created with zero length in AML\n")); - break; - } - - else - { - ObjDesc->Buffer.Pointer = ACPI_MEM_CALLOCATE ( - ObjDesc->Buffer.Length); - - if (!ObjDesc->Buffer.Pointer) - { - return (AE_NO_MEMORY); - } - } - /* - * Second arg is the buffer data (optional) ByteList can be either - * individual bytes or a string initializer. + * Defer evaluation of Buffer TermArg operand */ - Arg = Op->Value.Arg; /* skip first arg */ - - ByteList = (ACPI_PARSE2_OBJECT *) Arg->Next; - if (ByteList) - { - if (ByteList->Opcode != AML_INT_BYTELIST_OP) - { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Expecting bytelist, got: %p\n", - ByteList)); - return (AE_TYPE); - } - - ACPI_MEMCPY (ObjDesc->Buffer.Pointer, ByteList->Data, - ObjDesc->Buffer.Length); - } - + ObjDesc->Buffer.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; + ObjDesc->Buffer.AmlStart = ((ACPI_PARSE2_OBJECT *) Op)->Data; + ObjDesc->Buffer.AmlLength = ((ACPI_PARSE2_OBJECT *) Op)->Length; break; case ACPI_TYPE_PACKAGE: /* - * When called, an internal package object has already been built and - * is pointed to by ObjDesc. AcpiDsBuildInternalObject builds another - * internal package object, so remove reference to the original so - * that it is deleted. Error checking is done within the remove - * reference function. + * Defer evaluation of Package TermArg operand */ - AcpiUtRemoveReference (ObjDesc); - Status = AcpiDsBuildInternalObject (WalkState, Op, RetObjDesc); + ObjDesc->Package.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0]; + ObjDesc->Package.AmlStart = ((ACPI_PARSE2_OBJECT *) Op)->Data; + ObjDesc->Package.AmlLength = ((ACPI_PARSE2_OBJECT *) Op)->Length; break; - case ACPI_TYPE_INTEGER: + + case ACPI_TYPE_INTEGER: + ObjDesc->Integer.Value = Op->Value.Integer; break; case ACPI_TYPE_STRING: + ObjDesc->String.Pointer = Op->Value.String; ObjDesc->String.Length = ACPI_STRLEN (Op->Value.String); @@ -496,7 +424,6 @@ AcpiDsInitObjectFromOp ( ObjDesc->Reference.Opcode = Opcode; break; } - break; @@ -514,9 +441,10 @@ AcpiDsInitObjectFromOp ( /***************************************************************************** * - * FUNCTION: AcpiDsBuildInternalSimpleObj + * FUNCTION: AcpiDsBuildInternalObject * - * PARAMETERS: Op - Parser object to be translated + * PARAMETERS: WalkState - Current walk state + * Op - Parser object to be translated * ObjDescPtr - Where the ACPI internal object is returned * * RETURN: Status @@ -526,8 +454,8 @@ AcpiDsInitObjectFromOp ( * ****************************************************************************/ -static ACPI_STATUS -AcpiDsBuildInternalSimpleObj ( +ACPI_STATUS +AcpiDsBuildInternalObject ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, ACPI_OPERAND_OBJECT **ObjDescPtr) @@ -537,7 +465,7 @@ AcpiDsBuildInternalSimpleObj ( char *Name; - ACPI_FUNCTION_TRACE ("DsBuildInternalSimpleObj"); + ACPI_FUNCTION_TRACE ("DsBuildInternalObject"); if (Op->Opcode == AML_INT_NAMEPATH_OP) @@ -567,7 +495,6 @@ AcpiDsBuildInternalSimpleObj ( Name, Op->AmlOffset)); ACPI_MEM_FREE (Name); } - else { ACPI_REPORT_WARNING (("Reference %s at AML %X not found\n", @@ -576,7 +503,6 @@ AcpiDsBuildInternalSimpleObj ( *ObjDescPtr = NULL; } - else { return_ACPI_STATUS (Status); @@ -601,14 +527,13 @@ AcpiDsBuildInternalSimpleObj ( } *ObjDescPtr = ObjDesc; - return_ACPI_STATUS (AE_OK); } /***************************************************************************** * - * FUNCTION: AcpiDsBuildInternalPackageObj + * FUNCTION: AcpiDsBuildInternalBufferObj * * PARAMETERS: Op - Parser object to be translated * ObjDescPtr - Where the ACPI internal object is returned @@ -621,121 +546,231 @@ AcpiDsBuildInternalSimpleObj ( ****************************************************************************/ ACPI_STATUS -AcpiDsBuildInternalPackageObj ( +AcpiDsBuildInternalBufferObj ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, + UINT32 BufferLength, ACPI_OPERAND_OBJECT **ObjDescPtr) { ACPI_PARSE_OBJECT *Arg; ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_STATUS Status = AE_OK; + ACPI_PARSE2_OBJECT *ByteList; + UINT32 ByteListLength = 0; - ACPI_FUNCTION_TRACE ("DsBuildInternalPackageObj"); + ACPI_FUNCTION_TRACE ("DsBuildInternalBufferObj"); - ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE); - *ObjDescPtr = ObjDesc; - if (!ObjDesc) - { - return_ACPI_STATUS (AE_NO_MEMORY); - } - - if (Op->Opcode == AML_VAR_PACKAGE_OP) + ObjDesc = *ObjDescPtr; + if (ObjDesc) { /* - * Variable length package parameters are evaluated JIT + * We are evaluating a Named buffer object "Name (xxxx, Buffer)". + * The buffer object already exists (from the NS node) */ - return_ACPI_STATUS (AE_OK); } + else + { + /* Create a new buffer object */ - /* The first argument must be the package length */ - - Arg = Op->Value.Arg; - ObjDesc->Package.Count = Arg->Value.Integer32; + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER); + *ObjDescPtr = ObjDesc; + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + } /* - * Allocate the array of pointers (ptrs to the - * individual objects) Add an extra pointer slot so - * that the list is always null terminated. + * Second arg is the buffer data (optional) ByteList can be either + * individual bytes or a string initializer. In either case, a + * ByteList appears in the AML. */ - ObjDesc->Package.Elements = ACPI_MEM_CALLOCATE ( - (ObjDesc->Package.Count + 1) * sizeof (void *)); + Arg = Op->Value.Arg; /* skip first arg */ - if (!ObjDesc->Package.Elements) + ByteList = (ACPI_PARSE2_OBJECT *) Arg->Next; + if (ByteList) { - AcpiUtDeleteObjectDesc (ObjDesc); - return_ACPI_STATUS (AE_NO_MEMORY); - } + if (ByteList->Opcode != AML_INT_BYTELIST_OP) + { + ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, + "Expecting bytelist, got AML opcode %X in op %p\n", + ByteList->Opcode, ByteList)); - ObjDesc->Package.NextElement = ObjDesc->Package.Elements; + AcpiUtRemoveReference (ObjDesc); + return (AE_TYPE); + } + + ByteListLength = ByteList->Value.Integer32; + } /* - * Now init the elements of the package + * The buffer length (number of bytes) will be the larger of: + * 1) The specified buffer length and + * 2) The length of the initializer byte list */ - Arg = Arg->Next; - while (Arg) + ObjDesc->Buffer.Length = BufferLength; + if (ByteListLength > BufferLength) { - if (Arg->Opcode == AML_PACKAGE_OP) - { - Status = AcpiDsBuildInternalPackageObj (WalkState, Arg, - ObjDesc->Package.NextElement); - } + ObjDesc->Buffer.Length = ByteListLength; + } - else - { - Status = AcpiDsBuildInternalSimpleObj (WalkState, Arg, - ObjDesc->Package.NextElement); - } + /* Allocate the buffer */ - ObjDesc->Package.NextElement++; - Arg = Arg->Next; + if (ObjDesc->Buffer.Length == 0) + { + ObjDesc->Buffer.Pointer = NULL; + ACPI_REPORT_WARNING (("Buffer created with zero length in AML\n")); + return_ACPI_STATUS (AE_OK); } - ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID; - return_ACPI_STATUS (Status); + ObjDesc->Buffer.Pointer = ACPI_MEM_CALLOCATE ( + ObjDesc->Buffer.Length); + if (!ObjDesc->Buffer.Pointer) + { + AcpiUtDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* Initialize buffer from the ByteList (if present) */ + + if (ByteList) + { + ACPI_MEMCPY (ObjDesc->Buffer.Pointer, ByteList->Data, + ByteListLength); + } + + ObjDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; + Op->Node = (ACPI_NAMESPACE_NODE *) ObjDesc; + return_ACPI_STATUS (AE_OK); } /***************************************************************************** * - * FUNCTION: AcpiDsBuildInternalObject + * FUNCTION: AcpiDsBuildInternalPackageObj * * PARAMETERS: Op - Parser object to be translated * ObjDescPtr - Where the ACPI internal object is returned * * RETURN: Status * - * DESCRIPTION: Translate a parser Op object to the equivalent namespace - * object + * DESCRIPTION: Translate a parser Op package object to the equivalent + * namespace object * ****************************************************************************/ ACPI_STATUS -AcpiDsBuildInternalObject ( +AcpiDsBuildInternalPackageObj ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, + UINT32 PackageLength, ACPI_OPERAND_OBJECT **ObjDescPtr) { - ACPI_STATUS Status; + ACPI_PARSE_OBJECT *Arg; + ACPI_PARSE_OBJECT *Parent; + ACPI_OPERAND_OBJECT *ObjDesc = NULL; + UINT32 PackageListLength; + ACPI_STATUS Status = AE_OK; + UINT32 i; - switch (Op->Opcode) + ACPI_FUNCTION_TRACE ("DsBuildInternalPackageObj"); + + + /* Find the parent of a possibly nested package */ + + + Parent = Op->Parent; + while ((Parent->Opcode == AML_PACKAGE_OP) || + (Parent->Opcode == AML_VAR_PACKAGE_OP)) { - case AML_PACKAGE_OP: - case AML_VAR_PACKAGE_OP: + Parent = Parent->Parent; + } - Status = AcpiDsBuildInternalPackageObj (WalkState, Op, ObjDescPtr); - break; + ObjDesc = *ObjDescPtr; + if (ObjDesc) + { + /* + * We are evaluating a Named package object "Name (xxxx, Package)". + * Get the existing package object from the NS node + */ + } + else + { + ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE); + *ObjDescPtr = ObjDesc; + if (!ObjDesc) + { + return_ACPI_STATUS (AE_NO_MEMORY); + } + ObjDesc->Package.Node = Parent->Node; + } - default: + ObjDesc->Package.Count = PackageLength; - Status = AcpiDsBuildInternalSimpleObj (WalkState, Op, ObjDescPtr); - break; + /* Count the number of items in the package list */ + + PackageListLength = 0; + Arg = Op->Value.Arg; + Arg = Arg->Next; + while (Arg) + { + PackageListLength++; + Arg = Arg->Next; + } + + /* + * The package length (number of elements) will be the greater + * of the specified length and the length of the initializer list + */ + if (PackageListLength > PackageLength) + { + ObjDesc->Package.Count = PackageListLength; } - return (Status); + /* + * Allocate the pointer array (array of pointers to the + * individual objects). Add an extra pointer slot so + * that the list is always null terminated. + */ + ObjDesc->Package.Elements = ACPI_MEM_CALLOCATE ( + (ObjDesc->Package.Count + 1) * sizeof (void *)); + + if (!ObjDesc->Package.Elements) + { + AcpiUtDeleteObjectDesc (ObjDesc); + return_ACPI_STATUS (AE_NO_MEMORY); + } + + /* + * Now init the elements of the package + */ + i = 0; + Arg = Op->Value.Arg; + Arg = Arg->Next; + while (Arg) + { + if (Arg->Opcode == AML_INT_RETURN_VALUE_OP) + { + /* Object (package or buffer) is already built */ + + ObjDesc->Package.Elements[i] = (ACPI_OPERAND_OBJECT *) Arg->Node; + } + else + { + Status = AcpiDsBuildInternalObject (WalkState, Arg, + &ObjDesc->Package.Elements[i]); + } + + i++; + Arg = Arg->Next; + } + + ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID; + Op->Node = (ACPI_NAMESPACE_NODE *) ObjDesc; + return_ACPI_STATUS (Status); } @@ -794,7 +829,7 @@ AcpiDsCreateNode ( Node->Type = ObjDesc->Common.Type; - /* Init obj */ + /* Attach obj to node */ Status = AcpiNsAttachObject (Node, ObjDesc, Node->Type); |