[ACPICA] Update to version 20180531. CORE-15222
[reactos.git] / drivers / bus / acpi / acpica / parser / psobject.c
index f595b28..6dc3242 100644 (file)
@@ -46,6 +46,7 @@
 #include "acparser.h"
 #include "amlcode.h"
 #include "acconvert.h"
+#include "acnamesp.h"
 
 #define _COMPONENT          ACPI_PARSER
         ACPI_MODULE_NAME    ("psobject")
@@ -74,7 +75,7 @@ static ACPI_STATUS
 AcpiPsGetAmlOpcode (
     ACPI_WALK_STATE         *WalkState)
 {
-    UINT32                  AmlOffset;
+    ACPI_ERROR_ONLY (UINT32 AmlOffset);
 
 
     ACPI_FUNCTION_TRACE_PTR (PsGetAmlOpcode, WalkState);
@@ -109,8 +110,8 @@ AcpiPsGetAmlOpcode (
 
         if (WalkState->PassNumber == 2)
         {
-            AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->Aml,
-                WalkState->ParserState.AmlStart);
+            ACPI_ERROR_ONLY(AmlOffset = (UINT32) ACPI_PTR_DIFF (WalkState->Aml,
+                WalkState->ParserState.AmlStart));
 
             ACPI_ERROR ((AE_INFO,
                 "Unknown opcode 0x%.2X at table offset 0x%.4X, ignoring",
@@ -614,6 +615,20 @@ AcpiPsCompleteOp (
         {
             if (*Op)
             {
+                /*
+                 * These Opcodes need to be removed from the namespace because they
+                 * get created even if these opcodes cannot be created due to
+                 * errors.
+                 */
+                if (((*Op)->Common.AmlOpcode == AML_REGION_OP) ||
+                    ((*Op)->Common.AmlOpcode == AML_DATA_REGION_OP))
+                {
+                    AcpiNsDeleteChildren ((*Op)->Common.Node);
+                    AcpiNsRemoveNode ((*Op)->Common.Node);
+                    (*Op)->Common.Node = NULL;
+                    AcpiPsDeleteParseTree (*Op);
+                }
+
                 Status2 = AcpiPsCompleteThisOp (WalkState, *Op);
                 if (ACPI_FAILURE (Status2))
                 {
@@ -639,6 +654,20 @@ AcpiPsCompleteOp (
 #endif
         WalkState->PrevOp = NULL;
         WalkState->PrevArgTypes = WalkState->ArgTypes;
+
+        if (WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL)
+        {
+            /*
+             * There was something that went wrong while executing code at the
+             * module-level. We need to skip parsing whatever caused the
+             * error and keep going. One runtime error during the table load
+             * should not cause the entire table to not be loaded. This is
+             * because there could be correct AML beyond the parts that caused
+             * the runtime error.
+             */
+            ACPI_ERROR ((AE_INFO, "Ignore error and continue table load"));
+            return_ACPI_STATUS (AE_OK);
+        }
         return_ACPI_STATUS (Status);
     }