diff options
Diffstat (limited to 'source/components/namespace')
-rw-r--r-- | source/components/namespace/nsconvert.c | 86 | ||||
-rw-r--r-- | source/components/namespace/nseval.c | 66 | ||||
-rw-r--r-- | source/components/namespace/nsload.c | 18 | ||||
-rw-r--r-- | source/components/namespace/nsrepair.c | 11 |
4 files changed, 127 insertions, 54 deletions
diff --git a/source/components/namespace/nsconvert.c b/source/components/namespace/nsconvert.c index 84eeec1fa48a..5d3eb033e713 100644 --- a/source/components/namespace/nsconvert.c +++ b/source/components/namespace/nsconvert.c @@ -332,7 +332,8 @@ AcpiNsConvertToBuffer ( * * FUNCTION: AcpiNsConvertToUnicode * - * PARAMETERS: OriginalObject - ASCII String Object to be converted + * PARAMETERS: Scope - Namespace node for the method/object + * OriginalObject - ASCII String Object to be converted * ReturnObject - Where the new converted object is returned * * RETURN: Status. AE_OK if conversion was successful. @@ -343,6 +344,7 @@ AcpiNsConvertToBuffer ( ACPI_STATUS AcpiNsConvertToUnicode ( + ACPI_NAMESPACE_NODE *Scope, ACPI_OPERAND_OBJECT *OriginalObject, ACPI_OPERAND_OBJECT **ReturnObject) { @@ -404,7 +406,8 @@ AcpiNsConvertToUnicode ( * * FUNCTION: AcpiNsConvertToResource * - * PARAMETERS: OriginalObject - Object to be converted + * PARAMETERS: Scope - Namespace node for the method/object + * OriginalObject - Object to be converted * ReturnObject - Where the new converted object is returned * * RETURN: Status. AE_OK if conversion was successful @@ -416,6 +419,7 @@ AcpiNsConvertToUnicode ( ACPI_STATUS AcpiNsConvertToResource ( + ACPI_NAMESPACE_NODE *Scope, ACPI_OPERAND_OBJECT *OriginalObject, ACPI_OPERAND_OBJECT **ReturnObject) { @@ -482,3 +486,81 @@ AcpiNsConvertToResource ( *ReturnObject = NewObject; return (AE_OK); } + + +/******************************************************************************* + * + * FUNCTION: AcpiNsConvertToReference + * + * PARAMETERS: Scope - Namespace node for the method/object + * OriginalObject - Object to be converted + * ReturnObject - Where the new converted object is returned + * + * RETURN: Status. AE_OK if conversion was successful + * + * DESCRIPTION: Attempt to convert a Integer object to a ObjectReference. + * Buffer. + * + ******************************************************************************/ + +ACPI_STATUS +AcpiNsConvertToReference ( + ACPI_NAMESPACE_NODE *Scope, + ACPI_OPERAND_OBJECT *OriginalObject, + ACPI_OPERAND_OBJECT **ReturnObject) +{ + ACPI_OPERAND_OBJECT *NewObject = NULL; + ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *Node; + ACPI_GENERIC_STATE ScopeInfo; + char *Name; + + + ACPI_FUNCTION_NAME (NsConvertToReference); + + + /* Convert path into internal presentation */ + + Status = AcpiNsInternalizeName (OriginalObject->String.Pointer, &Name); + if (ACPI_FAILURE (Status)) + { + return_ACPI_STATUS (Status); + } + + /* Find the namespace node */ + + ScopeInfo.Scope.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Scope); + Status = AcpiNsLookup (&ScopeInfo, Name, + ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE, + ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node); + if (ACPI_FAILURE (Status)) + { + /* Check if we are resolving a named reference within a package */ + + ACPI_ERROR_NAMESPACE (OriginalObject->String.Pointer, Status); + goto ErrorExit; + } + + /* Create and init a new internal ACPI object */ + + NewObject = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE); + if (!NewObject) + { + Status = AE_NO_MEMORY; + goto ErrorExit; + } + NewObject->Reference.Node = Node; + NewObject->Reference.Object = Node->Object; + NewObject->Reference.Class = ACPI_REFCLASS_NAME; + + /* + * Increase reference of the object if needed (the object is likely a + * null for device nodes). + */ + AcpiUtAddReference (Node->Object); + +ErrorExit: + ACPI_FREE (Name); + *ReturnObject = NewObject; + return (AE_OK); +} diff --git a/source/components/namespace/nseval.c b/source/components/namespace/nseval.c index 0509c80e7a0c..a4819947dae4 100644 --- a/source/components/namespace/nseval.c +++ b/source/components/namespace/nseval.c @@ -418,7 +418,7 @@ AcpiNsExecModuleCodeList ( * * DESCRIPTION: Execute a control method containing a block of module-level * executable AML code. The control method is temporarily - * installed to the root node, then evaluated. + * installed to a local copy of the root node, then evaluated. * ******************************************************************************/ @@ -427,10 +427,9 @@ AcpiNsExecModuleCode ( ACPI_OPERAND_OBJECT *MethodObj, ACPI_EVALUATE_INFO *Info) { - ACPI_OPERAND_OBJECT *ParentObj; - ACPI_NAMESPACE_NODE *ParentNode; - ACPI_OBJECT_TYPE Type; ACPI_STATUS Status; + ACPI_NAMESPACE_NODE *TempNode; + ACPI_NAMESPACE_NODE *ParentNode; ACPI_FUNCTION_TRACE (NsExecModuleCode); @@ -442,21 +441,18 @@ AcpiNsExecModuleCode ( */ ParentNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, MethodObj->Method.NextObject); - Type = AcpiNsGetType (ParentNode); - /* - * Get the region handler and save it in the method object. We may need - * this if an operation region declaration causes a _REG method to be run. - * - * We can't do this in AcpiPsLinkModuleCode because - * AcpiGbl_RootNode->Object is NULL at PASS1. - */ - if ((Type == ACPI_TYPE_DEVICE) && ParentNode->Object) + /* Take a copy of the parent node to act as parent of this method */ + + TempNode = ACPI_ALLOCATE (sizeof (ACPI_NAMESPACE_NODE)); + if (!TempNode) { - MethodObj->Method.Dispatch.Handler = - ParentNode->Object->Device.Handler; + return_VOID; } + memcpy (TempNode, ParentNode, sizeof (ACPI_NAMESPACE_NODE)); + TempNode->Object = NULL; /* Clear the subobject */ + /* Must clear NextObject (AcpiNsAttachObject needs the field) */ MethodObj->Method.NextObject = NULL; @@ -464,26 +460,14 @@ AcpiNsExecModuleCode ( /* Initialize the evaluation information block */ memset (Info, 0, sizeof (ACPI_EVALUATE_INFO)); - Info->PrefixNode = ParentNode; - - /* - * Get the currently attached parent object. Add a reference, because the - * ref count will be decreased when the method object is installed to - * the parent node. - */ - ParentObj = AcpiNsGetAttachedObject (ParentNode); - if (ParentObj) - { - AcpiUtAddReference (ParentObj); - } + Info->PrefixNode = TempNode; /* Install the method (module-level code) in the parent node */ - Status = AcpiNsAttachObject (ParentNode, MethodObj, - ACPI_TYPE_METHOD); + Status = AcpiNsAttachObject (TempNode, MethodObj, ACPI_TYPE_METHOD); if (ACPI_FAILURE (Status)) { - goto Exit; + goto Cleanup; } /* Execute the parent node as a control method */ @@ -501,25 +485,7 @@ AcpiNsExecModuleCode ( AcpiUtRemoveReference (Info->ReturnObject); } - /* Detach the temporary method object */ - - AcpiNsDetachObject (ParentNode); - - /* Restore the original parent object */ - - if (ParentObj) - { - Status = AcpiNsAttachObject (ParentNode, ParentObj, Type); - } - else - { - ParentNode->Type = (UINT8) Type; - } - -Exit: - if (ParentObj) - { - AcpiUtRemoveReference (ParentObj); - } +Cleanup: + ACPI_FREE (TempNode); return_VOID; } diff --git a/source/components/namespace/nsload.c b/source/components/namespace/nsload.c index b1b6afa70615..edd79327ff93 100644 --- a/source/components/namespace/nsload.c +++ b/source/components/namespace/nsload.c @@ -167,6 +167,24 @@ Unlock: ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "**** Completed Table Object Initialization\n")); + /* + * Execute any module-level code that was detected during the table load + * phase. Although illegal since ACPI 2.0, there are many machines that + * contain this type of code. Each block of detected executable AML code + * outside of any control method is wrapped with a temporary control + * method object and placed on a global list. The methods on this list + * are executed below. + * + * This case executes the module-level code for each table immediately + * after the table has been loaded. This provides compatibility with + * other ACPI implementations. Optionally, the execution can be deferred + * until later, see AcpiInitializeObjects. + */ + if (!AcpiGbl_GroupModuleLevelCode) + { + AcpiNsExecModuleCodeList (); + } + return_ACPI_STATUS (Status); } diff --git a/source/components/namespace/nsrepair.c b/source/components/namespace/nsrepair.c index d98e11022eef..bb4b8a2fd720 100644 --- a/source/components/namespace/nsrepair.c +++ b/source/components/namespace/nsrepair.c @@ -114,6 +114,11 @@ static const ACPI_SIMPLE_REPAIR_INFO AcpiObjectRepairInfo[] = ACPI_NOT_PACKAGE_ELEMENT, AcpiNsConvertToResource }, + /* Object reference conversions */ + + { "_DEP", ACPI_RTYPE_STRING, ACPI_ALL_PACKAGE_ELEMENTS, + AcpiNsConvertToReference }, + /* Unicode conversions */ { "_MLS", ACPI_RTYPE_STRING, 1, @@ -174,7 +179,8 @@ AcpiNsSimpleRepair ( ACPI_WARN_ALWAYS, "Missing expected return value")); } - Status = Predefined->ObjectConverter (ReturnObject, &NewObject); + Status = Predefined->ObjectConverter (Info->Node, ReturnObject, + &NewObject); if (ACPI_FAILURE (Status)) { /* A fatal error occurred during a conversion */ @@ -373,7 +379,8 @@ AcpiNsMatchSimpleRepair ( /* Check if we can actually repair this name/type combination */ if ((ReturnBtype & ThisName->UnexpectedBtypes) && - (PackageIndex == ThisName->PackageIndex)) + (ThisName->PackageIndex == ACPI_ALL_PACKAGE_ELEMENTS || + PackageIndex == ThisName->PackageIndex)) { return (ThisName); } |