diff options
author | jkim <jkim@FreeBSD.org> | 2007-03-22 17:24:05 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2007-03-22 17:24:05 +0000 |
commit | e031ab5da47b5f6c28c3cc5d576128b2d8d202e6 (patch) | |
tree | 69d0fa3b3760b0abcc0335ff748e39701a8bf064 /sys/contrib/dev/acpica/dsobject.c | |
parent | dbc8115981195155aec9304dd8f0ee570bd3d32c (diff) | |
download | FreeBSD-src-e031ab5da47b5f6c28c3cc5d576128b2d8d202e6.zip FreeBSD-src-e031ab5da47b5f6c28c3cc5d576128b2d8d202e6.tar.gz |
Vendor import of Intel ACPI-CA 20070320
Diffstat (limited to 'sys/contrib/dev/acpica/dsobject.c')
-rw-r--r-- | sys/contrib/dev/acpica/dsobject.c | 203 |
1 files changed, 121 insertions, 82 deletions
diff --git a/sys/contrib/dev/acpica/dsobject.c b/sys/contrib/dev/acpica/dsobject.c index e0e4917..a058299 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: 1.124 $ + * $Revision: 1.135 $ * *****************************************************************************/ @@ -9,7 +9,7 @@ * * 1. Copyright Notice * - * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp. + * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. * All rights reserved. * * 2. License @@ -126,6 +126,8 @@ #define _COMPONENT ACPI_DISPATCHER ACPI_MODULE_NAME ("dsobject") +/* Local prototypes */ + static ACPI_STATUS AcpiDsBuildInternalObject ( ACPI_WALK_STATE *WalkState, @@ -159,35 +161,59 @@ AcpiDsBuildInternalObject ( ACPI_STATUS Status; - ACPI_FUNCTION_TRACE ("DsBuildInternalObject"); + ACPI_FUNCTION_TRACE (DsBuildInternalObject); *ObjDescPtr = NULL; if (Op->Common.AmlOpcode == AML_INT_NAMEPATH_OP) { /* - * This is an named object reference. If this name was + * This is a named object reference. If this name was * previously looked up in the namespace, it was stored in this op. * Otherwise, go ahead and look it up now */ if (!Op->Common.Node) { Status = AcpiNsLookup (WalkState->ScopeInfo, - Op->Common.Value.String, - ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, - ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, - NULL, - (ACPI_NAMESPACE_NODE **) &(Op->Common.Node)); - + Op->Common.Value.String, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, + ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, &(Op->Common.Node))); if (ACPI_FAILURE (Status)) { - ACPI_REPORT_NSERROR (Op->Common.Value.String, Status); + /* Check if we are resolving a named reference within a package */ + + if ((Status == AE_NOT_FOUND) && (AcpiGbl_EnableInterpreterSlack) && + + ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))) + { + /* + * We didn't find the target and we are populating elements + * of a package - ignore if slack enabled. Some ASL code + * contains dangling invalid references in packages and + * expects that no exception will be issued. Leave the + * element as a null element. It cannot be used, but it + * can be overwritten by subsequent ASL code - this is + * typically the case. + */ + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Ignoring unresolved reference in package [%4.4s]\n", + WalkState->ScopeInfo->Scope.Node->Name.Ascii)); + + return_ACPI_STATUS (AE_OK); + } + else + { + ACPI_ERROR_NAMESPACE (Op->Common.Value.String, Status); + } + return_ACPI_STATUS (Status); } } } - /* Create and init the internal ACPI object */ + /* Create and init a new internal ACPI object */ ObjDesc = AcpiUtCreateInternalObject ( (AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode))->ObjectType); @@ -238,18 +264,16 @@ AcpiDsBuildInternalBufferObj ( UINT32 ByteListLength = 0; - ACPI_FUNCTION_TRACE ("DsBuildInternalBufferObj"); + ACPI_FUNCTION_TRACE (DsBuildInternalBufferObj); + /* + * If we are evaluating a Named buffer object "Name (xxxx, Buffer)". + * The buffer object already exists (from the NS node), otherwise it must + * be created. + */ ObjDesc = *ObjDescPtr; - if (ObjDesc) - { - /* - * We are evaluating a Named buffer object "Name (xxxx, Buffer)". - * The buffer object already exists (from the NS node) - */ - } - else + if (!ObjDesc) { /* Create a new buffer object */ @@ -273,8 +297,8 @@ AcpiDsBuildInternalBufferObj ( { if (ByteList->Common.AmlOpcode != AML_INT_BYTELIST_OP) { - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Expecting bytelist, got AML opcode %X in op %p\n", + ACPI_ERROR ((AE_INFO, + "Expecting bytelist, got AML opcode %X in op %p", ByteList->Common.AmlOpcode, ByteList)); AcpiUtRemoveReference (ObjDesc); @@ -305,7 +329,7 @@ AcpiDsBuildInternalBufferObj ( } else { - ObjDesc->Buffer.Pointer = ACPI_MEM_CALLOCATE ( + ObjDesc->Buffer.Pointer = ACPI_ALLOCATE_ZEROED ( ObjDesc->Buffer.Length); if (!ObjDesc->Buffer.Pointer) { @@ -323,7 +347,7 @@ AcpiDsBuildInternalBufferObj ( } ObjDesc->Buffer.Flags |= AOPOBJ_DATA_VALID; - Op->Common.Node = (ACPI_NAMESPACE_NODE *) ObjDesc; + Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc); return_ACPI_STATUS (AE_OK); } @@ -334,7 +358,8 @@ AcpiDsBuildInternalBufferObj ( * * PARAMETERS: WalkState - Current walk state * Op - Parser object to be translated - * PackageLength - Number of elements in the package + * ElementCount - Number of elements in the package - this is + * the NumElements argument to Package() * ObjDescPtr - Where the ACPI internal object is returned * * RETURN: Status @@ -342,44 +367,54 @@ AcpiDsBuildInternalBufferObj ( * DESCRIPTION: Translate a parser Op package object to the equivalent * namespace object * + * NOTE: The number of elements in the package will be always be the NumElements + * count, regardless of the number of elements in the package list. If + * NumElements is smaller, only that many package list elements are used. + * if NumElements is larger, the Package object is padded out with + * objects of type Uninitialized (as per ACPI spec.) + * + * Even though the ASL compilers do not allow NumElements to be smaller + * than the Package list length (for the fixed length package opcode), some + * BIOS code modifies the AML on the fly to adjust the NumElements, and + * this code compensates for that. This also provides compatibility with + * other AML interpreters. + * ******************************************************************************/ ACPI_STATUS AcpiDsBuildInternalPackageObj ( ACPI_WALK_STATE *WalkState, ACPI_PARSE_OBJECT *Op, - UINT32 PackageLength, + UINT32 ElementCount, ACPI_OPERAND_OBJECT **ObjDescPtr) { ACPI_PARSE_OBJECT *Arg; ACPI_PARSE_OBJECT *Parent; ACPI_OPERAND_OBJECT *ObjDesc = NULL; - UINT32 PackageListLength; ACPI_STATUS Status = AE_OK; - UINT32 i; + ACPI_NATIVE_UINT i; + UINT16 Index; + UINT16 ReferenceCount; - ACPI_FUNCTION_TRACE ("DsBuildInternalPackageObj"); + ACPI_FUNCTION_TRACE (DsBuildInternalPackageObj); /* Find the parent of a possibly nested package */ Parent = Op->Common.Parent; - while ((Parent->Common.AmlOpcode == AML_PACKAGE_OP) || + while ((Parent->Common.AmlOpcode == AML_PACKAGE_OP) || (Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)) { Parent = Parent->Common.Parent; } + /* + * If we are evaluating a Named package object "Name (xxxx, Package)", + * the package object already exists, otherwise it must be created. + */ ObjDesc = *ObjDescPtr; - if (ObjDesc) - { - /* - * We are evaluating a Named package object "Name (xxxx, Package)". - * Get the existing package object from the NS node - */ - } - else + if (!ObjDesc) { ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE); *ObjDescPtr = ObjDesc; @@ -391,35 +426,13 @@ AcpiDsBuildInternalPackageObj ( ObjDesc->Package.Node = Parent->Common.Node; } - ObjDesc->Package.Count = PackageLength; - - /* Count the number of items in the package list */ - - PackageListLength = 0; - Arg = Op->Common.Value.Arg; - Arg = Arg->Common.Next; - while (Arg) - { - PackageListLength++; - Arg = Arg->Common.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; - } - /* - * Allocate the pointer array (array of pointers to the - * individual objects). Add an extra pointer slot so - * that the list is always null terminated. + * Allocate the element array (array of pointers to the individual + * objects) based on the NumElements parameter. Add an extra pointer slot + * so that the list is always null terminated. */ - ObjDesc->Package.Elements = ACPI_MEM_CALLOCATE ( - ((ACPI_SIZE) ObjDesc->Package.Count + 1) * sizeof (void *)); + ObjDesc->Package.Elements = ACPI_ALLOCATE_ZEROED ( + ((ACPI_SIZE) ElementCount + 1) * sizeof (void *)); if (!ObjDesc->Package.Elements) { @@ -427,17 +440,21 @@ AcpiDsBuildInternalPackageObj ( return_ACPI_STATUS (AE_NO_MEMORY); } + ObjDesc->Package.Count = ElementCount; + /* - * Now init the elements of the package + * Initialize the elements of the package, up to the NumElements count. + * Package is automatically padded with uninitialized (NULL) elements + * if NumElements is greater than the package list length. Likewise, + * Package is truncated if NumElements is less than the list length. */ - i = 0; Arg = Op->Common.Value.Arg; Arg = Arg->Common.Next; - while (Arg) + for (i = 0; Arg && (i < ElementCount); i++) { if (Arg->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP) { - /* Object (package or buffer) is already built */ + /* This package element is already built, just get it */ ObjDesc->Package.Elements[i] = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Arg->Common.Node); @@ -448,12 +465,34 @@ AcpiDsBuildInternalPackageObj ( &ObjDesc->Package.Elements[i]); } - i++; + if (*ObjDescPtr) + { + /* Existing package, get existing reference count */ + + ReferenceCount = (*ObjDescPtr)->Common.ReferenceCount; + if (ReferenceCount > 1) + { + /* Make new element ref count match original ref count */ + + for (Index = 0; Index < (ReferenceCount - 1); Index++) + { + AcpiUtAddReference ((ObjDesc->Package.Elements[i])); + } + } + } + Arg = Arg->Common.Next; } + if (!Arg) + { + ACPI_DEBUG_PRINT ((ACPI_DB_INFO, + "Package List length larger than NumElements count (%X), truncated\n", + ElementCount)); + } + ObjDesc->Package.Flags |= AOPOBJ_DATA_VALID; - Op->Common.Node = (ACPI_NAMESPACE_NODE *) ObjDesc; + Op->Common.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjDesc); return_ACPI_STATUS (Status); } @@ -482,7 +521,7 @@ AcpiDsCreateNode ( ACPI_OPERAND_OBJECT *ObjDesc; - ACPI_FUNCTION_TRACE_PTR ("DsCreateNode", Op); + ACPI_FUNCTION_TRACE_PTR (DsCreateNode, Op); /* @@ -557,7 +596,7 @@ AcpiDsInitObjectFromOp ( ACPI_STATUS Status = AE_OK; - ACPI_FUNCTION_TRACE ("DsInitObjectFromOp"); + ACPI_FUNCTION_TRACE (DsInitObjectFromOp); ObjDesc = *RetObjDesc; @@ -578,8 +617,8 @@ AcpiDsInitObjectFromOp ( /* * Defer evaluation of Buffer TermArg operand */ - ObjDesc->Buffer.Node = (ACPI_NAMESPACE_NODE *) - WalkState->Operands[0]; + ObjDesc->Buffer.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, + WalkState->Operands[0]); ObjDesc->Buffer.AmlStart = Op->Named.Data; ObjDesc->Buffer.AmlLength = Op->Named.Length; break; @@ -590,8 +629,8 @@ AcpiDsInitObjectFromOp ( /* * Defer evaluation of Package TermArg operand */ - ObjDesc->Package.Node = (ACPI_NAMESPACE_NODE *) - WalkState->Operands[0]; + ObjDesc->Package.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, + WalkState->Operands[0]); ObjDesc->Package.AmlStart = Op->Named.Data; ObjDesc->Package.AmlLength = Op->Named.Length; break; @@ -642,8 +681,8 @@ AcpiDsInitObjectFromOp ( default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, - "Unknown constant opcode %X\n", Opcode)); + ACPI_ERROR ((AE_INFO, + "Unknown constant opcode %X", Opcode)); Status = AE_AML_OPERAND_TYPE; break; } @@ -660,7 +699,7 @@ AcpiDsInitObjectFromOp ( default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Integer type %X\n", + ACPI_ERROR ((AE_INFO, "Unknown Integer type %X", OpInfo->Type)); Status = AE_AML_OPERAND_TYPE; break; @@ -737,7 +776,7 @@ AcpiDsInitObjectFromOp ( default: - ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unimplemented data type: %X\n", + ACPI_ERROR ((AE_INFO, "Unimplemented data type: %X", ACPI_GET_OBJECT_TYPE (ObjDesc))); Status = AE_AML_OPERAND_TYPE; |