summaryrefslogtreecommitdiffstats
path: root/namespace
diff options
context:
space:
mode:
Diffstat (limited to 'namespace')
-rw-r--r--namespace/nseval.c149
-rw-r--r--namespace/nspredef.c458
-rw-r--r--namespace/nsrepair.c291
-rw-r--r--namespace/nsxfeval.c6
4 files changed, 662 insertions, 242 deletions
diff --git a/namespace/nseval.c b/namespace/nseval.c
index 9b31a55..c84a4d5 100644
--- a/namespace/nseval.c
+++ b/namespace/nseval.c
@@ -126,6 +126,13 @@
#define _COMPONENT ACPI_NAMESPACE
ACPI_MODULE_NAME ("nseval")
+/* Local prototypes */
+
+static void
+AcpiNsExecModuleCode (
+ ACPI_OPERAND_OBJECT *MethodObj,
+ ACPI_EVALUATE_INFO *Info);
+
/*******************************************************************************
*
@@ -360,3 +367,145 @@ AcpiNsEvaluate (
return_ACPI_STATUS (Status);
}
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsExecModuleCodeList
+ *
+ * PARAMETERS: None
+ *
+ * RETURN: None. Exceptions during method execution are ignored, since
+ * we cannot abort a table load.
+ *
+ * DESCRIPTION: Execute all elements of the global module-level code list.
+ * Each element is executed as a single control method.
+ *
+ ******************************************************************************/
+
+void
+AcpiNsExecModuleCodeList (
+ void)
+{
+ ACPI_OPERAND_OBJECT *Prev;
+ ACPI_OPERAND_OBJECT *Next;
+ ACPI_EVALUATE_INFO *Info;
+ UINT32 MethodCount = 0;
+
+
+ ACPI_FUNCTION_TRACE (NsExecModuleCodeList);
+
+
+ /* Exit now if the list is empty */
+
+ Next = AcpiGbl_ModuleCodeList;
+ if (!Next)
+ {
+ return_VOID;
+ }
+
+ /* Allocate the evaluation information block */
+
+ Info = ACPI_ALLOCATE (sizeof (ACPI_EVALUATE_INFO));
+ if (!Info)
+ {
+ return_VOID;
+ }
+
+ /* Walk the list, executing each "method" */
+
+ while (Next)
+ {
+ Prev = Next;
+ Next = Next->Method.Mutex;
+
+ /* Clear the link field and execute the method */
+
+ Prev->Method.Mutex = NULL;
+ AcpiNsExecModuleCode (Prev, Info);
+ MethodCount++;
+
+ /* Delete the (temporary) method object */
+
+ AcpiUtRemoveReference (Prev);
+ }
+
+ ACPI_INFO ((AE_INFO,
+ "Executed %u blocks of module-level executable AML code",
+ MethodCount));
+
+ ACPI_FREE (Info);
+ AcpiGbl_ModuleCodeList = NULL;
+ return_VOID;
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsExecModuleCode
+ *
+ * PARAMETERS: MethodObj - Object container for the module-level code
+ * Info - Info block for method evaluation
+ *
+ * RETURN: None. Exceptions during method execution are ignored, since
+ * we cannot abort a table load.
+ *
+ * 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.
+ *
+ ******************************************************************************/
+
+static void
+AcpiNsExecModuleCode (
+ ACPI_OPERAND_OBJECT *MethodObj,
+ ACPI_EVALUATE_INFO *Info)
+{
+ ACPI_OPERAND_OBJECT *RootObj;
+ ACPI_STATUS Status;
+
+
+ ACPI_FUNCTION_TRACE (NsExecModuleCode);
+
+
+ /* Initialize the evaluation information block */
+
+ ACPI_MEMSET (Info, 0, sizeof (ACPI_EVALUATE_INFO));
+ Info->PrefixNode = AcpiGbl_RootNode;
+
+ /*
+ * Get the currently attached root object. Add a reference, because the
+ * ref count will be decreased when the method object is installed to
+ * the root node.
+ */
+ RootObj = AcpiNsGetAttachedObject (AcpiGbl_RootNode);
+ AcpiUtAddReference (RootObj);
+
+ /* Install the method (module-level code) in the root node */
+
+ Status = AcpiNsAttachObject (AcpiGbl_RootNode, MethodObj,
+ ACPI_TYPE_METHOD);
+ if (ACPI_FAILURE (Status))
+ {
+ goto Exit;
+ }
+
+ /* Execute the root node as a control method */
+
+ Status = AcpiNsEvaluate (Info);
+
+ ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Executed module-level code at %p\n",
+ MethodObj->Method.AmlStart));
+
+ /* Detach the temporary method object */
+
+ AcpiNsDetachObject (AcpiGbl_RootNode);
+
+ /* Restore the original root object */
+
+ Status = AcpiNsAttachObject (AcpiGbl_RootNode, RootObj, ACPI_TYPE_DEVICE);
+
+Exit:
+ AcpiUtRemoveReference (RootObj);
+ return_VOID;
+}
+
diff --git a/namespace/nspredef.c b/namespace/nspredef.c
index 0dc7524..77d2369 100644
--- a/namespace/nspredef.c
+++ b/namespace/nspredef.c
@@ -113,7 +113,7 @@
*
*****************************************************************************/
-#define __NSPREDEF_C__
+#define ACPI_CREATE_PREDEFINED_TABLE
#include "acpi.h"
#include "accommon.h"
@@ -155,6 +155,13 @@ AcpiNsCheckPackage (
ACPI_OPERAND_OBJECT **ReturnObjectPtr);
static ACPI_STATUS
+AcpiNsCheckPackageList (
+ ACPI_PREDEFINED_DATA *Data,
+ const ACPI_PREDEFINED_INFO *Package,
+ ACPI_OPERAND_OBJECT **Elements,
+ UINT32 Count);
+
+static ACPI_STATUS
AcpiNsCheckPackageElements (
ACPI_PREDEFINED_DATA *Data,
ACPI_OPERAND_OBJECT **Elements,
@@ -176,13 +183,6 @@ AcpiNsCheckReference (
ACPI_PREDEFINED_DATA *Data,
ACPI_OPERAND_OBJECT *ReturnObject);
-static ACPI_STATUS
-AcpiNsRepairObject (
- ACPI_PREDEFINED_DATA *Data,
- UINT32 ExpectedBtypes,
- UINT32 PackageIndex,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr);
-
static void
AcpiNsGetExpectedTypes (
char *Buffer,
@@ -201,14 +201,6 @@ static const char *AcpiRtypeNames[] =
"/Reference",
};
-/* Object is not a package element */
-
-#define ACPI_NOT_PACKAGE_ELEMENT ACPI_UINT32_MAX
-
-/* Always emit warning message, not dependent on node flags */
-
-#define ACPI_WARN_ALWAYS 0
-
/*******************************************************************************
*
@@ -524,14 +516,11 @@ AcpiNsCheckPackage (
{
ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
const ACPI_PREDEFINED_INFO *Package;
- ACPI_OPERAND_OBJECT *SubPackage;
ACPI_OPERAND_OBJECT **Elements;
- ACPI_OPERAND_OBJECT **SubElements;
- ACPI_STATUS Status;
+ ACPI_STATUS Status = AE_OK;
UINT32 ExpectedCount;
UINT32 Count;
UINT32 i;
- UINT32 j;
ACPI_FUNCTION_NAME (NsCheckPackage);
@@ -593,10 +582,6 @@ AcpiNsCheckPackage (
Status = AcpiNsCheckPackageElements (Data, Elements,
Package->RetInfo.ObjectType1, Package->RetInfo.Count1,
Package->RetInfo.ObjectType2, Package->RetInfo.Count2, 0);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
break;
@@ -665,6 +650,26 @@ AcpiNsCheckPackage (
break;
+ case ACPI_PTYPE2_REV_FIXED:
+
+ /* First element is the (Integer) revision */
+
+ Status = AcpiNsCheckObjectType (Data, Elements,
+ ACPI_RTYPE_INTEGER, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ Elements++;
+ Count--;
+
+ /* Examine the sub-packages */
+
+ Status = AcpiNsCheckPackageList (Data, Package, Elements, Count);
+ break;
+
+
case ACPI_PTYPE2_PKG_COUNT:
/* First element is the (Integer) count of sub-packages to follow */
@@ -689,9 +694,10 @@ AcpiNsCheckPackage (
Count = ExpectedCount;
Elements++;
- /* Now we can walk the sub-packages */
+ /* Examine the sub-packages */
- /*lint -fallthrough */
+ Status = AcpiNsCheckPackageList (Data, Package, Elements, Count);
+ break;
case ACPI_PTYPE2:
@@ -700,146 +706,231 @@ AcpiNsCheckPackage (
case ACPI_PTYPE2_COUNT:
/*
- * These types all return a single package that consists of a variable
- * number of sub-packages
+ * These types all return a single Package that consists of a
+ * variable number of sub-Packages.
+ *
+ * First, ensure that the first element is a sub-Package. If not,
+ * the BIOS may have incorrectly returned the object as a single
+ * package instead of a Package of Packages (a common error if
+ * there is only one entry). We may be able to repair this by
+ * wrapping the returned Package with a new outer Package.
*/
- for (i = 0; i < Count; i++)
+ if ((*Elements)->Common.Type != ACPI_TYPE_PACKAGE)
{
- SubPackage = *Elements;
- SubElements = SubPackage->Package.Elements;
+ /* Create the new outer package and populate it */
- /* Each sub-object must be of type Package */
-
- Status = AcpiNsCheckObjectType (Data, &SubPackage,
- ACPI_RTYPE_PACKAGE, i);
+ Status = AcpiNsRepairPackageList (Data, ReturnObjectPtr);
if (ACPI_FAILURE (Status))
{
return (Status);
}
- /* Examine the different types of sub-packages */
+ /* Update locals to point to the new package (of 1 element) */
- switch (Package->RetInfo.Type)
- {
- case ACPI_PTYPE2:
- case ACPI_PTYPE2_PKG_COUNT:
+ ReturnObject = *ReturnObjectPtr;
+ Elements = ReturnObject->Package.Elements;
+ Count = 1;
+ }
- /* Each subpackage has a fixed number of elements */
+ /* Examine the sub-packages */
- ExpectedCount =
- Package->RetInfo.Count1 + Package->RetInfo.Count2;
- if (SubPackage->Package.Count != ExpectedCount)
- {
- Count = SubPackage->Package.Count;
- goto PackageTooSmall;
- }
+ Status = AcpiNsCheckPackageList (Data, Package, Elements, Count);
+ break;
- Status = AcpiNsCheckPackageElements (Data, SubElements,
- Package->RetInfo.ObjectType1,
- Package->RetInfo.Count1,
- Package->RetInfo.ObjectType2,
- Package->RetInfo.Count2, 0);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- break;
- case ACPI_PTYPE2_FIXED:
+ default:
- /* Each sub-package has a fixed length */
+ /* Should not get here if predefined info table is correct */
- ExpectedCount = Package->RetInfo2.Count;
- if (SubPackage->Package.Count < ExpectedCount)
- {
- Count = SubPackage->Package.Count;
- goto PackageTooSmall;
- }
+ ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+ "Invalid internal return type in table entry: %X",
+ Package->RetInfo.Type));
- /* Check the type of each sub-package element */
+ return (AE_AML_INTERNAL);
+ }
- for (j = 0; j < ExpectedCount; j++)
- {
- Status = AcpiNsCheckObjectType (Data, &SubElements[j],
- Package->RetInfo2.ObjectType[j], j);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- }
- break;
+ return (Status);
- case ACPI_PTYPE2_MIN:
- /* Each sub-package has a variable but minimum length */
+PackageTooSmall:
- ExpectedCount = Package->RetInfo.Count1;
- if (SubPackage->Package.Count < ExpectedCount)
- {
- Count = SubPackage->Package.Count;
- goto PackageTooSmall;
- }
+ /* Error exit for the case with an incorrect package count */
- /* Check the type of each sub-package element */
+ ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+ "Return Package is too small - found %u elements, expected %u",
+ Count, ExpectedCount));
- Status = AcpiNsCheckPackageElements (Data, SubElements,
- Package->RetInfo.ObjectType1,
- SubPackage->Package.Count, 0, 0, 0);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- break;
+ return (AE_AML_OPERAND_VALUE);
+}
- case ACPI_PTYPE2_COUNT:
- /* First element is the (Integer) count of elements to follow */
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsCheckPackageList
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * Package - Pointer to package-specific info for method
+ * Elements - Element list of parent package. All elements
+ * of this list should be of type Package.
+ * Count - Count of subpackages
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Examine a list of subpackages
+ *
+ ******************************************************************************/
- Status = AcpiNsCheckObjectType (Data, SubElements,
- ACPI_RTYPE_INTEGER, 0);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
+static ACPI_STATUS
+AcpiNsCheckPackageList (
+ ACPI_PREDEFINED_DATA *Data,
+ const ACPI_PREDEFINED_INFO *Package,
+ ACPI_OPERAND_OBJECT **Elements,
+ UINT32 Count)
+{
+ ACPI_OPERAND_OBJECT *SubPackage;
+ ACPI_OPERAND_OBJECT **SubElements;
+ ACPI_STATUS Status;
+ UINT32 ExpectedCount;
+ UINT32 i;
+ UINT32 j;
- /* Make sure package is large enough for the Count */
- ExpectedCount = (UINT32) (*SubElements)->Integer.Value;
- if (SubPackage->Package.Count < ExpectedCount)
- {
- Count = SubPackage->Package.Count;
- goto PackageTooSmall;
- }
+ /* Validate each sub-Package in the parent Package */
+
+ for (i = 0; i < Count; i++)
+ {
+ SubPackage = *Elements;
+ SubElements = SubPackage->Package.Elements;
+
+ /* Each sub-object must be of type Package */
+
+ Status = AcpiNsCheckObjectType (Data, &SubPackage,
+ ACPI_RTYPE_PACKAGE, i);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Examine the different types of expected sub-packages */
+
+ switch (Package->RetInfo.Type)
+ {
+ case ACPI_PTYPE2:
+ case ACPI_PTYPE2_PKG_COUNT:
+ case ACPI_PTYPE2_REV_FIXED:
+
+ /* Each subpackage has a fixed number of elements */
+
+ ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;
+ if (SubPackage->Package.Count < ExpectedCount)
+ {
+ goto PackageTooSmall;
+ }
+
+ Status = AcpiNsCheckPackageElements (Data, SubElements,
+ Package->RetInfo.ObjectType1,
+ Package->RetInfo.Count1,
+ Package->RetInfo.ObjectType2,
+ Package->RetInfo.Count2, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ break;
+
- /* Check the type of each sub-package element */
+ case ACPI_PTYPE2_FIXED:
+
+ /* Each sub-package has a fixed length */
+
+ ExpectedCount = Package->RetInfo2.Count;
+ if (SubPackage->Package.Count < ExpectedCount)
+ {
+ goto PackageTooSmall;
+ }
- Status = AcpiNsCheckPackageElements (Data, (SubElements + 1),
- Package->RetInfo.ObjectType1,
- (ExpectedCount - 1), 0, 0, 1);
+ /* Check the type of each sub-package element */
+
+ for (j = 0; j < ExpectedCount; j++)
+ {
+ Status = AcpiNsCheckObjectType (Data, &SubElements[j],
+ Package->RetInfo2.ObjectType[j], j);
if (ACPI_FAILURE (Status))
{
return (Status);
}
- break;
+ }
+ break;
+
- default:
- break;
+ case ACPI_PTYPE2_MIN:
+
+ /* Each sub-package has a variable but minimum length */
+
+ ExpectedCount = Package->RetInfo.Count1;
+ if (SubPackage->Package.Count < ExpectedCount)
+ {
+ goto PackageTooSmall;
}
- Elements++;
- }
- break;
+ /* Check the type of each sub-package element */
+ Status = AcpiNsCheckPackageElements (Data, SubElements,
+ Package->RetInfo.ObjectType1,
+ SubPackage->Package.Count, 0, 0, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ break;
- default:
- /* Should not get here if predefined info table is correct */
+ case ACPI_PTYPE2_COUNT:
- ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
- "Invalid internal return type in table entry: %X",
- Package->RetInfo.Type));
+ /*
+ * First element is the (Integer) count of elements, including
+ * the count field.
+ */
+ Status = AcpiNsCheckObjectType (Data, SubElements,
+ ACPI_RTYPE_INTEGER, 0);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
- return (AE_AML_INTERNAL);
+ /*
+ * Make sure package is large enough for the Count and is
+ * is as large as the minimum size
+ */
+ ExpectedCount = (UINT32) (*SubElements)->Integer.Value;
+ if (SubPackage->Package.Count < ExpectedCount)
+ {
+ goto PackageTooSmall;
+ }
+ if (SubPackage->Package.Count < Package->RetInfo.Count1)
+ {
+ ExpectedCount = Package->RetInfo.Count1;
+ goto PackageTooSmall;
+ }
+
+ /* Check the type of each sub-package element */
+
+ Status = AcpiNsCheckPackageElements (Data, (SubElements + 1),
+ Package->RetInfo.ObjectType1,
+ (ExpectedCount - 1), 0, 0, 1);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ break;
+
+
+ default: /* Should not get here, type was validated by caller */
+
+ return (AE_AML_INTERNAL);
+ }
+
+ Elements++;
}
return (AE_OK);
@@ -847,11 +938,11 @@ AcpiNsCheckPackage (
PackageTooSmall:
- /* Error exit for the case with an incorrect package count */
+ /* The sub-package count was smaller than required */
ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
- "Return Package is too small - found %u, expected %u",
- Count, ExpectedCount));
+ "Return Sub-Package[%u] is too small - found %u elements, expected %u",
+ i, SubPackage->Package.Count, ExpectedCount));
return (AE_AML_OPERAND_VALUE);
}
@@ -1102,117 +1193,6 @@ AcpiNsCheckReference (
/*******************************************************************************
*
- * FUNCTION: AcpiNsRepairObject
- *
- * PARAMETERS: Data - Pointer to validation data structure
- * ExpectedBtypes - Object types expected
- * PackageIndex - Index of object within parent package (if
- * applicable - ACPI_NOT_PACKAGE_ELEMENT
- * otherwise)
- * ReturnObjectPtr - Pointer to the object returned from the
- * evaluation of a method or object
- *
- * RETURN: Status. AE_OK if repair was successful.
- *
- * DESCRIPTION: Attempt to repair/convert a return object of a type that was
- * not expected.
- *
- ******************************************************************************/
-
-static ACPI_STATUS
-AcpiNsRepairObject (
- ACPI_PREDEFINED_DATA *Data,
- UINT32 ExpectedBtypes,
- UINT32 PackageIndex,
- ACPI_OPERAND_OBJECT **ReturnObjectPtr)
-{
- ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
- ACPI_OPERAND_OBJECT *NewObject;
- ACPI_SIZE Length;
-
-
- switch (ReturnObject->Common.Type)
- {
- case ACPI_TYPE_BUFFER:
-
- /* Does the method/object legally return a string? */
-
- if (!(ExpectedBtypes & ACPI_RTYPE_STRING))
- {
- return (AE_AML_OPERAND_TYPE);
- }
-
- /*
- * Have a Buffer, expected a String, convert. Use a ToString
- * conversion, no transform performed on the buffer data. The best
- * example of this is the _BIF method, where the string data from
- * the battery is often (incorrectly) returned as buffer object(s).
- */
- Length = 0;
- while ((Length < ReturnObject->Buffer.Length) &&
- (ReturnObject->Buffer.Pointer[Length]))
- {
- Length++;
- }
-
- /* Allocate a new string object */
-
- NewObject = AcpiUtCreateStringObject (Length);
- if (!NewObject)
- {
- return (AE_NO_MEMORY);
- }
-
- /*
- * Copy the raw buffer data with no transform. String is already NULL
- * terminated at Length+1.
- */
- ACPI_MEMCPY (NewObject->String.Pointer,
- ReturnObject->Buffer.Pointer, Length);
-
- /*
- * If the original object is a package element, we need to:
- * 1. Set the reference count of the new object to match the
- * reference count of the old object.
- * 2. Decrement the reference count of the original object.
- */
- if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT)
- {
- NewObject->Common.ReferenceCount =
- ReturnObject->Common.ReferenceCount;
-
- if (ReturnObject->Common.ReferenceCount > 1)
- {
- ReturnObject->Common.ReferenceCount--;
- }
-
- ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
- "Converted Buffer to expected String at index %u",
- PackageIndex));
- }
- else
- {
- ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
- "Converted Buffer to expected String"));
- }
-
- /* Delete old object, install the new return object */
-
- AcpiUtRemoveReference (ReturnObject);
- *ReturnObjectPtr = NewObject;
- Data->Flags |= ACPI_OBJECT_REPAIRED;
- return (AE_OK);
-
- default:
- break;
- }
-
- return (AE_AML_OPERAND_TYPE);
-}
-
-
-/*******************************************************************************
- *
* FUNCTION: AcpiNsGetExpectedTypes
*
* PARAMETERS: Buffer - Pointer to where the string is returned
diff --git a/namespace/nsrepair.c b/namespace/nsrepair.c
new file mode 100644
index 0000000..ae53426
--- /dev/null
+++ b/namespace/nsrepair.c
@@ -0,0 +1,291 @@
+/******************************************************************************
+ *
+ * Module Name: nsrepair - Repair for objects returned by predefined methods
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
+ * All rights reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+#define __NSREPAIR_C__
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acnamesp.h"
+#include "acpredef.h"
+
+#define _COMPONENT ACPI_NAMESPACE
+ ACPI_MODULE_NAME ("nsrepair")
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsRepairObject
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * ExpectedBtypes - Object types expected
+ * PackageIndex - Index of object within parent package (if
+ * applicable - ACPI_NOT_PACKAGE_ELEMENT
+ * otherwise)
+ * ReturnObjectPtr - Pointer to the object returned from the
+ * evaluation of a method or object
+ *
+ * RETURN: Status. AE_OK if repair was successful.
+ *
+ * DESCRIPTION: Attempt to repair/convert a return object of a type that was
+ * not expected.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsRepairObject (
+ ACPI_PREDEFINED_DATA *Data,
+ UINT32 ExpectedBtypes,
+ UINT32 PackageIndex,
+ ACPI_OPERAND_OBJECT **ReturnObjectPtr)
+{
+ ACPI_OPERAND_OBJECT *ReturnObject = *ReturnObjectPtr;
+ ACPI_OPERAND_OBJECT *NewObject;
+ ACPI_SIZE Length;
+
+
+ switch (ReturnObject->Common.Type)
+ {
+ case ACPI_TYPE_BUFFER:
+
+ /* Does the method/object legally return a string? */
+
+ if (!(ExpectedBtypes & ACPI_RTYPE_STRING))
+ {
+ return (AE_AML_OPERAND_TYPE);
+ }
+
+ /*
+ * Have a Buffer, expected a String, convert. Use a ToString
+ * conversion, no transform performed on the buffer data. The best
+ * example of this is the _BIF method, where the string data from
+ * the battery is often (incorrectly) returned as buffer object(s).
+ */
+ Length = 0;
+ while ((Length < ReturnObject->Buffer.Length) &&
+ (ReturnObject->Buffer.Pointer[Length]))
+ {
+ Length++;
+ }
+
+ /* Allocate a new string object */
+
+ NewObject = AcpiUtCreateStringObject (Length);
+ if (!NewObject)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ /*
+ * Copy the raw buffer data with no transform. String is already NULL
+ * terminated at Length+1.
+ */
+ ACPI_MEMCPY (NewObject->String.Pointer,
+ ReturnObject->Buffer.Pointer, Length);
+
+ /*
+ * If the original object is a package element, we need to:
+ * 1. Set the reference count of the new object to match the
+ * reference count of the old object.
+ * 2. Decrement the reference count of the original object.
+ */
+ if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT)
+ {
+ NewObject->Common.ReferenceCount =
+ ReturnObject->Common.ReferenceCount;
+
+ if (ReturnObject->Common.ReferenceCount > 1)
+ {
+ ReturnObject->Common.ReferenceCount--;
+ }
+
+ ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+ "Converted Buffer to expected String at index %u",
+ PackageIndex));
+ }
+ else
+ {
+ ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+ "Converted Buffer to expected String"));
+ }
+
+ /* Delete old object, install the new return object */
+
+ AcpiUtRemoveReference (ReturnObject);
+ *ReturnObjectPtr = NewObject;
+ Data->Flags |= ACPI_OBJECT_REPAIRED;
+ return (AE_OK);
+
+ default:
+ break;
+ }
+
+ return (AE_AML_OPERAND_TYPE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiNsRepairPackageList
+ *
+ * PARAMETERS: Data - Pointer to validation data structure
+ * ObjDescPtr - Pointer to the object to repair. The new
+ * package object is returned here,
+ * overwriting the old object.
+ *
+ * RETURN: Status, new object in *ObjDescPtr
+ *
+ * DESCRIPTION: Repair a common problem with objects that are defined to return
+ * a variable-length Package of Packages. If the variable-length
+ * is one, some BIOS code mistakenly simply declares a single
+ * Package instead of a Package with one sub-Package. This
+ * function attempts to repair this error by wrapping a Package
+ * object around the original Package, creating the correct
+ * Package with one sub-Package.
+ *
+ * Names that can be repaired in this manner include:
+ * _ALR, _CSD, _HPX, _MLS, _PRT, _PSS, _TRT, TSS
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsRepairPackageList (
+ ACPI_PREDEFINED_DATA *Data,
+ ACPI_OPERAND_OBJECT **ObjDescPtr)
+{
+ ACPI_OPERAND_OBJECT *PkgObjDesc;
+
+
+ /*
+ * Create the new outer package and populate it. The new package will
+ * have a single element, the lone subpackage.
+ */
+ PkgObjDesc = AcpiUtCreatePackageObject (1);
+ if (!PkgObjDesc)
+ {
+ return (AE_NO_MEMORY);
+ }
+
+ PkgObjDesc->Package.Elements[0] = *ObjDescPtr;
+
+ /* Return the new object in the object pointer */
+
+ *ObjDescPtr = PkgObjDesc;
+ Data->Flags |= ACPI_OBJECT_REPAIRED;
+
+ ACPI_WARN_PREDEFINED ((AE_INFO, Data->Pathname, Data->NodeFlags,
+ "Incorrectly formed Package, attempting repair"));
+
+ return (AE_OK);
+}
diff --git a/namespace/nsxfeval.c b/namespace/nsxfeval.c
index c2a5dbb..157ca93 100644
--- a/namespace/nsxfeval.c
+++ b/namespace/nsxfeval.c
@@ -662,7 +662,7 @@ AcpiNsGetDeviceCallback (
ACPI_DEVICE_ID_LIST *Cid;
UINT32 i;
BOOLEAN Found;
- int Match;
+ int NoMatch;
Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
@@ -716,10 +716,10 @@ AcpiNsGetDeviceCallback (
return (AE_CTRL_DEPTH);
}
- Match = ACPI_STRCMP (Hid->String, Info->Hid);
+ NoMatch = ACPI_STRCMP (Hid->String, Info->Hid);
ACPI_FREE (Hid);
- if (!Match)
+ if (NoMatch)
{
/*
* HID does not match, attempt match within the
OpenPOWER on IntegriCloud