Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/acpica/dist merge acpica 20180427



details:   https://anonhg.NetBSD.org/src/rev/0f2a7d41bdf0
branches:  trunk
changeset: 322506:0f2a7d41bdf0
user:      christos <christos%NetBSD.org@localhost>
date:      Sat May 05 00:12:15 2018 +0000

description:
merge acpica 20180427

diffstat:

 sys/external/bsd/acpica/dist/compiler/aslcompiler.h |    9 +
 sys/external/bsd/acpica/dist/compiler/aslload.c     |   72 ++++++-
 sys/external/bsd/acpica/dist/compiler/aslutils.c    |   91 ++++++++
 sys/external/bsd/acpica/dist/compiler/aslxref.c     |  220 +------------------
 sys/external/bsd/acpica/dist/debugger/dbnames.c     |   13 +-
 sys/external/bsd/acpica/dist/debugger/dbtest.c      |   67 +++++-
 sys/external/bsd/acpica/dist/include/acapps.h       |    4 +
 sys/external/bsd/acpica/dist/include/acpixf.h       |    2 +-
 sys/external/bsd/acpica/dist/resources/rsdump.c     |    2 +-
 sys/external/bsd/acpica/dist/tables/tbinstal.c      |    2 +-
 sys/external/bsd/acpica/dist/utilities/utprint.c    |    1 +
 11 files changed, 272 insertions(+), 211 deletions(-)

diffs (truncated from 739 to 300 lines):

diff -r dea85bc9650b -r 0f2a7d41bdf0 sys/external/bsd/acpica/dist/compiler/aslcompiler.h
--- a/sys/external/bsd/acpica/dist/compiler/aslcompiler.h       Fri May 04 23:44:07 2018 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/aslcompiler.h       Sat May 05 00:12:15 2018 +0000
@@ -1079,6 +1079,15 @@
     ACPI_PARSE_OBJECT       *Op,
     UINT32                  Level);
 
+void *
+UtGetParentMethod (
+    ACPI_NAMESPACE_NODE     *Node);
+
+BOOLEAN
+UtNodeIsDescendantOf (
+    ACPI_NAMESPACE_NODE     *Node1,
+    ACPI_NAMESPACE_NODE     *Node2);
+
 void
 UtDisplaySupportedTables (
     void);
diff -r dea85bc9650b -r 0f2a7d41bdf0 sys/external/bsd/acpica/dist/compiler/aslload.c
--- a/sys/external/bsd/acpica/dist/compiler/aslload.c   Fri May 04 23:44:07 2018 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/aslload.c   Sat May 05 00:12:15 2018 +0000
@@ -45,8 +45,9 @@
 #include "amlcode.h"
 #include "acdispat.h"
 #include "acnamesp.h"
+#include "acparser.h"
+#include "aslcompiler.y.h"
 
-#include "aslcompiler.y.h"
 
 #define _COMPONENT          ACPI_COMPILER
         ACPI_MODULE_NAME    ("aslload")
@@ -362,9 +363,13 @@
     UINT32                  i;
     BOOLEAN                 ForceNewScope = FALSE;
     ACPI_OWNER_ID           OwnerId = 0;
+    const ACPI_OPCODE_INFO  *OpInfo;
+    ACPI_PARSE_OBJECT       *ParentOp;
 
 
     ACPI_FUNCTION_NAME (LdNamespace1Begin);
+
+
     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Op %p [%s]\n",
         Op, Op->Asl.ParseOpName));
 
@@ -440,6 +445,69 @@
         return (AE_OK);
     }
 
+    /* Check for a possible illegal forward reference */
+
+    if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
+        (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
+    {
+        /*
+         * Op->Asl.Namepath will be NULL for these opcodes.
+         * These opcodes are guaranteed to have a parent.
+         * Examine the parent opcode.
+         */
+        Status = AE_OK;
+        ParentOp = Op->Asl.Parent;
+        OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Asl.AmlOpcode);
+
+        /*
+         * Exclude all operators that actually declare a new name:
+         *      Name (ABCD, 1) -> Ignore (AML_CLASS_NAMED_OBJECT)
+         * We only want references to named objects:
+         *      Store (2, WXYZ) -> Attempt to resolve the name
+         */
+        if (OpInfo->Class == AML_CLASS_NAMED_OBJECT)
+        {
+            return (AE_OK);
+        }
+
+        /*
+         * Check if the referenced object exists at this point during
+         * the load:
+         * 1) If it exists, then this cannot be a forward reference.
+         * 2) If it does not exist, it could be a forward reference or
+         * it truly does not exist (and no external declaration).
+         */
+        Status = AcpiNsLookup (WalkState->ScopeInfo,
+            Op->Asl.Value.Name, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+            ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
+            WalkState, &Node);
+        if (Status == AE_NOT_FOUND)
+        {
+            /*
+             * This is either a foward reference or the object truly
+             * does not exist. The two cases can only be differentiated
+             * during the cross-reference stage later. Mark the Op/Name
+             * as not-found for now to indicate the need for further
+             * processing.
+             *
+             * Special case: Allow forward references from elements of
+             * Package objects. This provides compatibility with other
+             * ACPI implementations. To correctly implement this, the
+             * ACPICA table load defers package resolution until the entire
+             * namespace has been loaded.
+             */
+            if ((ParentOp->Asl.ParseOpcode != PARSEOP_PACKAGE) &&
+                (ParentOp->Asl.ParseOpcode != PARSEOP_VAR_PACKAGE))
+            {
+                Op->Asl.CompileFlags |= OP_NOT_FOUND_DURING_LOAD;
+            }
+
+            return (AE_OK);
+        }
+
+        return (Status);
+    }
+
     Path = Op->Asl.Namepath;
     if (!Path)
     {
@@ -476,7 +544,6 @@
         }
         break;
 
-
     case PARSEOP_EXTERNAL:
         /*
          * "External" simply enters a name and type into the namespace.
@@ -658,7 +725,6 @@
         Status = AE_OK;
         goto FinishNode;
 
-
     default:
 
         ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
diff -r dea85bc9650b -r 0f2a7d41bdf0 sys/external/bsd/acpica/dist/compiler/aslutils.c
--- a/sys/external/bsd/acpica/dist/compiler/aslutils.c  Fri May 04 23:44:07 2018 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/aslutils.c  Sat May 05 00:12:15 2018 +0000
@@ -130,6 +130,97 @@
 
 /*******************************************************************************
  *
+ * FUNCTION:    UtNodeIsDescendantOf
+ *
+ * PARAMETERS:  Node1                   - Child node
+ *              Node2                   - Possible parent node
+ *
+ * RETURN:      Boolean
+ *
+ * DESCRIPTION: Returns TRUE if Node1 is a descendant of Node2. Otherwise,
+ *              return FALSE. Note, we assume a NULL Node2 element to be the
+ *              topmost (root) scope. All nodes are descendants of the root.
+ *              Note: Nodes at the same level (siblings) are not considered
+ *              descendants.
+ *
+ ******************************************************************************/
+
+BOOLEAN
+UtNodeIsDescendantOf (
+    ACPI_NAMESPACE_NODE     *Node1,
+    ACPI_NAMESPACE_NODE     *Node2)
+{
+
+    if (Node1 == Node2)
+    {
+        return (FALSE);
+    }
+
+    if (!Node2)
+    {
+        return (TRUE); /* All nodes descend from the root */
+    }
+
+    /* Walk upward until the root is reached or parent is found */
+
+    while (Node1)
+    {
+        if (Node1 == Node2)
+        {
+            return (TRUE);
+        }
+
+        Node1 = Node1->Parent;
+    }
+
+    return (FALSE);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    UtGetParentMethod
+ *
+ * PARAMETERS:  Node                    - Namespace node for any object
+ *
+ * RETURN:      Namespace node for the parent method
+ *              NULL - object is not within a method
+ *
+ * DESCRIPTION: Find the parent (owning) method node for a namespace object
+ *
+ ******************************************************************************/
+
+void *
+UtGetParentMethod (
+    ACPI_NAMESPACE_NODE     *Node)
+{
+    ACPI_NAMESPACE_NODE     *ParentNode;
+
+
+    if (!Node)
+    {
+        return (NULL);
+    }
+
+    /* Walk upward until a method is found, or the root is reached */
+
+    ParentNode = Node->Parent;
+    while (ParentNode)
+    {
+        if (ParentNode->Type == ACPI_TYPE_METHOD)
+        {
+            return (ParentNode);
+        }
+
+        ParentNode = ParentNode->Parent;
+    }
+
+    return (NULL); /* Object is not within a control method */
+}
+
+
+/*******************************************************************************
+ *
  * FUNCTION:    UtDisplaySupportedTables
  *
  * PARAMETERS:  None
diff -r dea85bc9650b -r 0f2a7d41bdf0 sys/external/bsd/acpica/dist/compiler/aslxref.c
--- a/sys/external/bsd/acpica/dist/compiler/aslxref.c   Fri May 04 23:44:07 2018 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/aslxref.c   Sat May 05 00:12:15 2018 +0000
@@ -89,22 +89,6 @@
     UINT32                  FieldBitLength,
     UINT32                  AccessBitWidth);
 
-#ifdef __UNDER_DEVELOPMENT
-static ACPI_PARSE_OBJECT *
-XfGetParentMethod (
-    ACPI_PARSE_OBJECT       *Op);
-
-static void
-XfCheckIllegalReference (
-    ACPI_PARSE_OBJECT       *Op,
-    ACPI_NAMESPACE_NODE     *Node);
-
-static BOOLEAN
-XfIsObjectParental (
-    ACPI_PARSE_OBJECT       *MethodOp1,
-    ACPI_PARSE_OBJECT       *MethodOp2);
-#endif
-
 
 /*******************************************************************************
  *
@@ -594,7 +578,7 @@
     Gbl_NsLookupCount++;
 
     Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
-        ACPI_IMODE_EXECUTE, Flags, WalkState, &(Node));
+        ACPI_IMODE_EXECUTE, Flags, WalkState, &Node);
     if (ACPI_FAILURE (Status))
     {
         if (Status == AE_NOT_FOUND)
@@ -652,6 +636,26 @@
         return_ACPI_STATUS (Status);
     }
 
+    /* Object was found above, check for an illegal forward reference */
+
+    if (Op->Asl.CompileFlags & OP_NOT_FOUND_DURING_LOAD)
+    {
+        /*
+         * During the load phase, this Op was flagged as a possible
+         * illegal forward reference
+         *
+         * Note: Allow "forward references" from within a method to an
+         * object that is not within any method (module-level code)
+         */
+        if (!WalkState->ScopeInfo || (UtGetParentMethod (Node) &&
+            !UtNodeIsDescendantOf (WalkState->ScopeInfo->Scope.Node,
+                UtGetParentMethod (Node))))
+        {
+            AslError (ASL_ERROR, ASL_MSG_ILLEGAL_FORWARD_REF, Op,
+                Op->Asl.ExternalName);
+        }
+    }
+
     /* Check for a reference vs. name declaration */
 
     if (!(OpInfo->Flags & AML_NAMED) &&
@@ -660,13 +664,6 @@
         /* This node has been referenced, mark it for reference check */
 
         Node->Flags |= ANOBJ_IS_REFERENCED;



Home | Main Index | Thread Index | Old Index