merge conflicts trunk
authorchristos <christos@NetBSD.org>
Sun, 30 Apr 2017 23:13:36 +0000
branchtrunk
changeset 250412 1891c82ddd69
parent 250411 63971791f752
child 250413 da85b7c78c71
merge conflicts
sys/external/bsd/acpica/dist/common/dmtbinfo.c
sys/external/bsd/acpica/dist/compiler/aslcompile.c
sys/external/bsd/acpica/dist/compiler/aslcompiler.h
sys/external/bsd/acpica/dist/compiler/aslcompiler.l
sys/external/bsd/acpica/dist/compiler/aslfiles.c
sys/external/bsd/acpica/dist/compiler/asloptions.c
sys/external/bsd/acpica/dist/compiler/aslsupport.l
sys/external/bsd/acpica/dist/compiler/asltree.c
sys/external/bsd/acpica/dist/compiler/aslwalks.c
sys/external/bsd/acpica/dist/debugger/dbmethod.c
sys/external/bsd/acpica/dist/disassembler/dmcstyle.c
sys/external/bsd/acpica/dist/disassembler/dmwalk.c
sys/external/bsd/acpica/dist/dispatcher/dscontrol.c
sys/external/bsd/acpica/dist/dispatcher/dsopcode.c
sys/external/bsd/acpica/dist/dispatcher/dsutils.c
sys/external/bsd/acpica/dist/include/acdisasm.h
sys/external/bsd/acpica/dist/include/acglobal.h
sys/external/bsd/acpica/dist/include/aclocal.h
sys/external/bsd/acpica/dist/include/acmacros.h
sys/external/bsd/acpica/dist/include/acpixf.h
sys/external/bsd/acpica/dist/namespace/nsaccess.c
sys/external/bsd/acpica/dist/namespace/nsrepair2.c
sys/external/bsd/acpica/dist/parser/psopcode.c
sys/external/bsd/acpica/dist/parser/psopinfo.c
sys/external/bsd/acpica/dist/utilities/utcache.c
sys/external/bsd/acpica/dist/utilities/utdebug.c
--- a/sys/external/bsd/acpica/dist/common/dmtbinfo.c	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/common/dmtbinfo.c	Sun Apr 30 23:13:36 2017 +0000
@@ -171,6 +171,7 @@
 #define ACPI_IORT1_OFFSET(f)            (UINT16) ACPI_OFFSET (ACPI_IORT_NAMED_COMPONENT,f)
 #define ACPI_IORT2_OFFSET(f)            (UINT16) ACPI_OFFSET (ACPI_IORT_ROOT_COMPLEX,f)
 #define ACPI_IORT3_OFFSET(f)            (UINT16) ACPI_OFFSET (ACPI_IORT_SMMU,f)
+#define ACPI_IORT3A_OFFSET(f)           (UINT16) ACPI_OFFSET (ACPI_IORT_SMMU_GSI,f)
 #define ACPI_IORT4_OFFSET(f)            (UINT16) ACPI_OFFSET (ACPI_IORT_SMMU_V3,f)
 #define ACPI_IORTA_OFFSET(f)            (UINT16) ACPI_OFFSET (ACPI_IORT_MEMORY_ACCESS,f)
 #define ACPI_IORTH_OFFSET(f)            (UINT16) ACPI_OFFSET (ACPI_IORT_NODE,f)
@@ -259,6 +260,7 @@
 #define ACPI_GTDT0a_FLAG_OFFSET(f,o)    ACPI_FLAG_OFFSET (ACPI_GTDT_TIMER_ENTRY,f,o)
 #define ACPI_GTDT1_FLAG_OFFSET(f,o)     ACPI_FLAG_OFFSET (ACPI_GTDT_WATCHDOG,f,o)
 #define ACPI_IORT3_FLAG_OFFSET(f,o)     ACPI_FLAG_OFFSET (ACPI_IORT_SMMU,f,o)
+#define ACPI_IORT3a_FLAG_OFFSET(f,o)    ACPI_FLAG_OFFSET (ACPI_IORT_SMMU_GSI,f,o)
 #define ACPI_IORT4_FLAG_OFFSET(f,o)     ACPI_FLAG_OFFSET (ACPI_IORT_SMMU_V3,f,o)
 #define ACPI_IORTA_FLAG_OFFSET(f,o)     ACPI_FLAG_OFFSET (ACPI_IORT_MEMORY_ACCESS,f,o)
 #define ACPI_IORTM_FLAG_OFFSET(f,o)     ACPI_FLAG_OFFSET (ACPI_IORT_ID_MAPPING,f,o)
@@ -1549,8 +1551,12 @@
 
 ACPI_DMTABLE_INFO           AcpiDmTableInfoIort3a[] =
 {
-    {ACPI_DMT_UINT64,   0,                                          "SMMU_NSgIrpt Interrupt", 0},
-    {ACPI_DMT_UINT64,   0,                                          "SMMU_NSgCfgIrpt Interrupt", 0},
+    {ACPI_DMT_UINT32,   ACPI_IORT3A_OFFSET (NSgIrpt),                   "NSgIrpt", 0},
+    {ACPI_DMT_UINT32,   ACPI_IORT3A_OFFSET (NSgIrptFlags),              "NSgIrpt Flags (decoded below)", 0},
+    {ACPI_DMT_FLAG0,    ACPI_IORT3a_FLAG_OFFSET (NSgIrptFlags, 0),      "Edge Triggered", 0},
+    {ACPI_DMT_UINT32,   ACPI_IORT3A_OFFSET (NSgCfgIrpt),                "NSgCfgIrpt", 0},
+    {ACPI_DMT_UINT32,   ACPI_IORT3A_OFFSET (NSgCfgIrptFlags),           "NSgCfgIrpt Flags (decoded below)", 0},
+    {ACPI_DMT_FLAG0,    ACPI_IORT3a_FLAG_OFFSET (NSgCfgIrptFlags, 0),   "Edge Triggered", 0},
     ACPI_DMT_TERMINATOR
 };
 
--- a/sys/external/bsd/acpica/dist/compiler/aslcompile.c	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/aslcompile.c	Sun Apr 30 23:13:36 2017 +0000
@@ -285,8 +285,17 @@
     {
         Event = UtBeginEvent ("Resolve all Externals");
         DbgPrint (ASL_DEBUG_OUTPUT, "\nResolve Externals\n\n");
-        TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE,
-            ExAmlExternalWalkBegin, ExAmlExternalWalkEnd, NULL);
+
+        if (Gbl_DoExternalsInPlace)
+        {
+            TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD,
+                ExAmlExternalWalkBegin, NULL, NULL);
+        }
+        else
+        {
+            TrWalkParseTree (Gbl_ParseTreeRoot, ASL_WALK_VISIT_TWICE,
+                ExAmlExternalWalkBegin, ExAmlExternalWalkEnd, NULL);
+        }
         UtEndEvent (Event);
     }
 
@@ -347,6 +356,18 @@
         NULL, &AnalysisWalkInfo);
     UtEndEvent (Event);
 
+    /*
+     * ASL-/ASL+ converter: Gbl_ParseTreeRoot->CommentList contains the
+     * very last comment of a given ASL file because it's the last constructed
+     * node during compilation. We take the very last comment and save it in a
+     * global for it to be used by the disassembler.
+     */
+    if (Gbl_CaptureComments)
+    {
+        AcpiGbl_LastListHead = Gbl_ParseTreeRoot->Asl.CommentList;
+        Gbl_ParseTreeRoot->Asl.CommentList = NULL;
+    }
+
     /* Calculate all AML package lengths */
 
     Event = UtBeginEvent ("Finish AML package length generation");
@@ -800,7 +821,11 @@
 
     /* Final cleanup after compiling one file */
 
-    CmDeleteCaches ();
+    if (!Gbl_DoAslConversion)
+    {
+        CmDeleteCaches ();
+    }
+
 }
 
 
--- a/sys/external/bsd/acpica/dist/compiler/aslcompiler.h	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/aslcompiler.h	Sun Apr 30 23:13:36 2017 +0000
@@ -576,6 +576,12 @@
 CgGenerateAmlOutput (
     void);
 
+void
+CgLocalWriteAmlData (
+    ACPI_PARSE_OBJECT       *Op,
+    void                    *Buffer,
+    UINT32                  Length);
+
 
 /*
  * aslfile
@@ -1360,4 +1366,14 @@
 DtCreateTemplates (
     char                    **argv);
 
+
+/*
+ * ASL/ASL+ converter debug
+ */
+void
+CvDbgPrint (
+    char                    *Fmt,
+    ...);
+
+
 #endif /*  __ASLCOMPILER_H */
--- a/sys/external/bsd/acpica/dist/compiler/aslcompiler.l	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/aslcompiler.l	Sun Apr 30 23:13:36 2017 +0000
@@ -44,6 +44,7 @@
 
 #include "aslcompiler.h"
 #include "aslcompiler.y.h"
+#include "acconvert.h"
 
 #include <stdlib.h>
 #include <string.h>
@@ -66,10 +67,10 @@
 static void
 AslDoLineDirective (void);
 
-static char
+static BOOLEAN
 AslDoComment (void);
 
-static char
+static BOOLEAN
 AslDoCommentType2 (void);
 
 static char
--- a/sys/external/bsd/acpica/dist/compiler/aslfiles.c	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/aslfiles.c	Sun Apr 30 23:13:36 2017 +0000
@@ -511,8 +511,14 @@
     if (!Filename)
     {
         /* Create the output AML filename */
-
-        Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_AML_CODE);
+        if (!Gbl_CaptureComments)
+        {
+            Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_AML_CODE);
+        }
+        else
+        {
+            Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_CONVERT_AML);
+        }
         if (!Filename)
         {
             AslCommonError (ASL_ERROR, ASL_MSG_OUTPUT_FILENAME,
@@ -854,6 +860,28 @@
         AslCompilerFileHeader (ASL_FILE_NAMESPACE_OUTPUT);
     }
 
+    /* Create a debug file for the converter */
+
+    if (AcpiGbl_DebugAslConversion)
+    {
+        Filename = FlGenerateFilename (FilenamePrefix, FILE_SUFFIX_CONVERT_DEBUG);
+        if (!Filename)
+        {
+            AslCommonError (ASL_ERROR, ASL_MSG_LISTING_FILENAME,
+                0, 0, 0, 0, NULL, NULL);
+            return (AE_ERROR);
+        }
+
+        /* Open the converter debug file, text mode */
+
+        FlOpenFile (ASL_FILE_CONV_DEBUG_OUTPUT, Filename, "w+t");
+
+        AslCompilerSignon (ASL_FILE_CONV_DEBUG_OUTPUT);
+        AslCompilerFileHeader (ASL_FILE_CONV_DEBUG_OUTPUT);
+
+        AcpiGbl_ConvDebugFile = Gbl_Files[ASL_FILE_CONV_DEBUG_OUTPUT].Handle;
+    }
+
     return (AE_OK);
 }
 
--- a/sys/external/bsd/acpica/dist/compiler/asloptions.c	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/asloptions.c	Sun Apr 30 23:13:36 2017 +0000
@@ -68,7 +68,7 @@
 
 
 #define ASL_TOKEN_SEPARATORS    " \t\n"
-#define ASL_SUPPORTED_OPTIONS   "@:a:b|c|d^D:e:f^gh^i|I:l^m:no|p:P^r:s|t|T+G^v^w|x:z"
+#define ASL_SUPPORTED_OPTIONS   "@:a:b|c|d^D:e:f^gh^i|I:l^m:no|p:P^q^r:s|t|T+G^v^w|x:z"
 
 #ifdef ACPI_REPRO
 static char ASL_BUILD_DATE[] = "Jan 1, 1970";
@@ -214,6 +214,24 @@
 
         switch (AcpiGbl_Optarg[0])
         {
+
+        case 'c':
+
+            printf ("Debug ASL to ASL+ conversion\n");
+
+            Gbl_DoAslConversion = TRUE;
+            Gbl_FoldConstants = FALSE;
+            Gbl_IntegerOptimizationFlag = FALSE;
+            Gbl_ReferenceOptimizationFlag = FALSE;
+            Gbl_OptimizeTrivialParseNodes = FALSE;
+            Gbl_CaptureComments = TRUE;
+            AcpiGbl_DoDisassemblerOptimizations = FALSE;
+            AcpiGbl_DebugAslConversion = TRUE;
+            AcpiGbl_DmEmitExternalOpcodes = TRUE;
+            Gbl_DoExternalsInPlace = TRUE;
+
+            return (0);
+
         case 'f':
 
             AslCompilerdebug = 1; /* same as yydebug */
@@ -265,6 +283,22 @@
 
         switch (AcpiGbl_Optarg[0])
         {
+
+        case 'a':
+
+            printf ("Convert ASL to ASL+ with comments\n");
+            Gbl_DoAslConversion = TRUE;
+            Gbl_FoldConstants = FALSE;
+            Gbl_IntegerOptimizationFlag = FALSE;
+            Gbl_ReferenceOptimizationFlag = FALSE;
+            Gbl_OptimizeTrivialParseNodes = FALSE;
+            Gbl_CaptureComments = TRUE;
+            AcpiGbl_DoDisassemblerOptimizations = FALSE;
+            AcpiGbl_DmEmitExternalOpcodes = TRUE;
+            Gbl_DoExternalsInPlace = TRUE;
+
+            return (0);
+
         case 'r':
 
             Gbl_NoResourceChecking = TRUE;
@@ -557,6 +591,8 @@
             Gbl_FoldConstants = FALSE;
             Gbl_IntegerOptimizationFlag = FALSE;
             Gbl_ReferenceOptimizationFlag = FALSE;
+            Gbl_OptimizeTrivialParseNodes = FALSE;
+
             break;
 
         case 'c':
@@ -575,15 +611,21 @@
 
         case 'e':
 
-            /* iASL: Disable External opcode generation */
-
-            Gbl_DoExternals = FALSE;
-
             /* Disassembler: Emit embedded external operators */
 
             AcpiGbl_DmEmitExternalOpcodes = TRUE;
             break;
 
+        case 'E':
+
+            /*
+             * iASL: keep External opcodes in place.
+             * No affect if Gbl_DoExternals is false.
+             */
+
+            Gbl_DoExternalsInPlace = TRUE;
+            break;
+
         case 'f':
 
             /* Disable folding on "normal" expressions */
@@ -648,6 +690,17 @@
         Gbl_UseDefaultAmlFilename = FALSE;
         break;
 
+    case 'q':   /* ASL/ASl+ converter: compile only and leave badaml. */
+
+        printf ("Convert ASL to ASL+ with comments\n");
+        Gbl_FoldConstants = FALSE;
+        Gbl_IntegerOptimizationFlag = FALSE;
+        Gbl_ReferenceOptimizationFlag = FALSE;
+        Gbl_OptimizeTrivialParseNodes = FALSE;
+        Gbl_CaptureComments = TRUE;
+        Gbl_DoExternalsInPlace = TRUE;
+        return (0);
+
     case 'r':   /* Override revision found in table header */
 
         Gbl_RevisionOverride = (UINT8) strtoul (AcpiGbl_Optarg, NULL, 0);
--- a/sys/external/bsd/acpica/dist/compiler/aslsupport.l	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/aslsupport.l	Sun Apr 30 23:13:36 2017 +0000
@@ -52,21 +52,12 @@
 #define ASL_HEX_CONSTANT        3
 
 
-/* File node - used for "Include" operator file stack */
-
-typedef struct asl_file_node
+void
+yyerror (char const *s)
 {
-    FILE                    *File;
-    UINT32                  CurrentLineNumber;
-    YY_BUFFER_STATE         State;
-    char                    *Filename;
-    struct asl_file_node    *Next;
 
-} ASL_FILE_NODE;
-
-/* File stack for the "Include" operator (NOT #include operator) */
-
-ASL_FILE_NODE               *Gbl_IncludeFileStack = NULL;
+  AcpiOsPrintf ("YYERROR: %s\n", s);
+}
 
 
 /*******************************************************************************
@@ -289,6 +280,10 @@
 
     Gbl_CurrentLineNumber = 1;
     yyin = InputFile;
+
+    /* converter: reset the comment state to STANDARD_COMMENT */
+
+    Gbl_CommentState.CommentType = STANDARD_COMMENT;
 }
 
 
@@ -392,6 +387,11 @@
 
             AslResetCurrentLineBuffer ();
         }
+
+        if (Gbl_CaptureComments)
+        {
+            CvProcessCommentState (SourceChar);
+        }
     }
 }
 
@@ -459,16 +459,26 @@
  *
  ******************************************************************************/
 
-static char
+static BOOLEAN
 AslDoComment (
     void)
 {
-    int                 c;
-    int                 c1 = 0;
+    int                     c;
+    int                     c1 = 0;
+    char                    *StringBuffer = MsgBuffer;
+    char                    *EndBuffer = MsgBuffer + ASL_MSG_BUFFER_SIZE;
+    ASL_COMMENT_STATE       CurrentState = Gbl_CommentState; /* to reference later on */
 
 
     AslInsertLineBuffer ('/');
     AslInsertLineBuffer ('*');
+    if (Gbl_CaptureComments && CurrentState.CaptureComments)
+    {
+        *StringBuffer = '/';
+        ++StringBuffer;
+        *StringBuffer = '*';
+        ++StringBuffer;
+    }
 
 loop:
 
@@ -477,6 +487,11 @@
     while (((c = input ()) != '*') && (c != EOF))
     {
         AslInsertLineBuffer (c);
+        if (Gbl_CaptureComments && CurrentState.CaptureComments)
+        {
+            *StringBuffer = c;
+            ++StringBuffer;
+        }
         c1 = c;
     }
 
@@ -500,10 +515,15 @@
     /* Comment is closed only if the NEXT character is a slash */
 
     AslInsertLineBuffer (c);
+    if (Gbl_CaptureComments && CurrentState.CaptureComments)
+    {
+        *StringBuffer = c;
+        ++StringBuffer;
+    }
 
     if (((c1 = input ()) != '/') && (c1 != EOF))
     {
-        unput(c1);
+        unput (c1);
         goto loop;
     }
 
@@ -511,8 +531,13 @@
     {
         goto EarlyEOF;
     }
+    if (StringBuffer > EndBuffer)
+    {
+        goto BufferOverflow;
+    }
 
     AslInsertLineBuffer (c1);
+    CvProcessComment (CurrentState, StringBuffer, c1);
     return (TRUE);
 
 
@@ -525,6 +550,18 @@
         Gbl_CurrentLineOffset, Gbl_CurrentColumn,
         Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
     return (FALSE);
+
+
+BufferOverflow:
+
+    /* Comment was too long */
+
+    AslCommonError (ASL_ERROR, ASL_MSG_STRING_LENGTH,
+        Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
+        Gbl_CurrentLineOffset, Gbl_CurrentColumn,
+        Gbl_Files[ASL_FILE_INPUT].Filename, "Max length 4096");
+    return (FALSE);
+
 }
 
 
@@ -536,23 +573,40 @@
  *
  * RETURN:      none
  *
- * DESCRIPTION: Process a new "//" comment.
+ * DESCRIPTION: Process a new "//" comment. Inline comments will be converted
+ *              to "/ *" standard comments.
  *
  ******************************************************************************/
 
-static char
+static BOOLEAN
 AslDoCommentType2 (
     void)
 {
-    int                 c;
+    int                     c;
+    char                    *StringBuffer = MsgBuffer;
+    char                    *EndBuffer = MsgBuffer + ASL_MSG_BUFFER_SIZE;
+    ASL_COMMENT_STATE       CurrentState = Gbl_CommentState;
 
 
     AslInsertLineBuffer ('/');
-    AslInsertLineBuffer ('/');
+    AslInsertLineBuffer ('*');
+
+    if (Gbl_CaptureComments && CurrentState.CaptureComments)
+    {
+        *StringBuffer = '/';
+        ++StringBuffer;
+        *StringBuffer = '*';
+        ++StringBuffer;
+    }
 
     while (((c = input ()) != '\n') && (c != EOF))
     {
         AslInsertLineBuffer (c);
+        if (Gbl_CaptureComments && CurrentState.CaptureComments)
+        {
+            *StringBuffer = c;
+            ++StringBuffer;
+        }
     }
 
     if (c == EOF)
@@ -562,8 +616,26 @@
         c = '\n';
     }
 
+    if (StringBuffer > EndBuffer)
+    {
+        goto BufferOverflow;
+    }
     AslInsertLineBuffer (c);
+
+    CvProcessCommentType2 (CurrentState, StringBuffer);
     return (TRUE);
+
+
+BufferOverflow:
+
+    /* Comment was too long */
+
+    AslCommonError (ASL_ERROR, ASL_MSG_STRING_LENGTH,
+        Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
+        Gbl_CurrentLineOffset, Gbl_CurrentColumn,
+        Gbl_Files[ASL_FILE_INPUT].Filename, "Max length 4096");
+    return (FALSE);
+
 }
 
 
--- a/sys/external/bsd/acpica/dist/compiler/asltree.c	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/asltree.c	Sun Apr 30 23:13:36 2017 +0000
@@ -44,6 +44,7 @@
 #include "aslcompiler.h"
 #include "aslcompiler.y.h"
 #include "acapps.h"
+#include "acconvert.h"
 #include <time.h>
 
 #define _COMPONENT          ACPI_COMPILER
@@ -140,6 +141,7 @@
     UINT32                  ParseOpcode)
 {
     ACPI_PARSE_OBJECT       *Op;
+    ACPI_PARSE_OBJECT       *LatestNode;
 
 
     Op = TrGetNextNode ();
@@ -152,6 +154,82 @@
     Op->Asl.Column            = Gbl_CurrentColumn;
 
     UtSetParseOpName (Op);
+
+    /* The following is for capturing comments */
+
+    if(Gbl_CaptureComments)
+    {
+        LatestNode = Gbl_CommentState.Latest_Parse_Node;
+        Op->Asl.InlineComment     = NULL;
+        Op->Asl.EndNodeComment    = NULL;
+        Op->Asl.CommentList       = NULL;
+        Op->Asl.FileChanged       = FALSE;
+
+        /*
+         * Check to see if the file name has changed before resetting the
+         * latest parse node.
+         */
+        if (LatestNode &&
+            (ParseOpcode != PARSEOP_INCLUDE) &&
+            (ParseOpcode != PARSEOP_INCLUDE_END) &&
+            strcmp (LatestNode->Asl.Filename, Op->Asl.Filename))
+        {
+            CvDbgPrint ("latest node: %s\n", LatestNode->Asl.ParseOpName);
+            Op->Asl.FileChanged = TRUE;
+            if (Gbl_IncludeFileStack)
+            {
+                Op->Asl.ParentFilename = Gbl_IncludeFileStack->Filename;
+            }
+            else
+            {
+                Op->Asl.ParentFilename = NULL;
+            }
+        }
+
+        Gbl_CommentState.Latest_Parse_Node = Op;
+        if (Gbl_CommentState.Latest_Parse_Node->Asl.ParseOpName)
+        {
+            CvDbgPrint ("trallocatenode=Set latest parse node to this node.\n");
+            CvDbgPrint ("           Op->Asl.ParseOpName = %s\n",
+                Gbl_CommentState.Latest_Parse_Node->Asl.ParseOpName);
+            CvDbgPrint ("           Op->Asl.ParseOpcode = 0x%x\n", ParseOpcode);
+
+            if (Op->Asl.FileChanged)
+            {
+                CvDbgPrint("    file has been changed!\n");
+            }
+        }
+
+        /*
+         * if this parse op's syntax uses () and {} (i.e. Package(1){0x00}) then
+         * set a flag in the comment state. This facilitates paring comments for
+         * these types of opcodes.
+         */
+        if ((CvParseOpBlockType(Op) == (BLOCK_PAREN | BLOCK_BRACE)) &&
+            (ParseOpcode != PARSEOP_DEFINITION_BLOCK))
+        {
+            CvDbgPrint ("Parsing paren/Brace node now!\n");
+            Gbl_CommentState.ParsingParenBraceNode = Op;
+        }
+
+        if (Gbl_Comment_List_Head)
+        {
+            CvDbgPrint ("Transferring...\n");
+            Op->Asl.CommentList = Gbl_Comment_List_Head;
+            Gbl_Comment_List_Head = NULL;
+            Gbl_Comment_List_Tail = NULL;
+            CvDbgPrint ("    Transferred current comment list to this node.\n");
+            CvDbgPrint ("    %s\n", Op->Asl.CommentList->Comment);
+        }
+        if (Gbl_Inline_Comment_Buffer)
+        {
+            Op->Asl.InlineComment = Gbl_Inline_Comment_Buffer;
+            Gbl_Inline_Comment_Buffer = NULL;
+            CvDbgPrint ("Transferred current inline comment list to this node.\n");
+        }
+
+    }
+
     return (Op);
 }
 
@@ -294,6 +372,13 @@
         break;
     }
 
+    /* Converter: if this is a method invocation, turn off capture comments. */
+    if (Gbl_CaptureComments &&
+        (ParseOpcode == PARSEOP_METHODCALL))
+    {
+        Gbl_CommentState.CaptureComments = FALSE;
+    }
+
     return (Op);
 }
 
@@ -1060,6 +1145,39 @@
         {
             FirstChild = FALSE;
             Op->Asl.Child = Child;
+
+            /*
+             * For the ASL-/ASL+ converter: if the ParseOp is a connection,
+             * external, offset or accessAs, it means that the comments in the
+             * FirstChild belongs to their parent due to the parsing order in
+             * the .y files. To correct this, take the comments in the
+             * FirstChild place it in the parent. This also means that
+             * legitimate comments for the child gets put to the parent.
+             */
+            if (Gbl_CaptureComments &&
+                ((ParseOpcode == PARSEOP_CONNECTION) ||
+                 (ParseOpcode == PARSEOP_EXTERNAL) ||
+                 (ParseOpcode == PARSEOP_OFFSET) ||
+                 (ParseOpcode == PARSEOP_ACCESSAS)))
+            {
+                Op->Asl.CommentList      = Child->Asl.CommentList;
+                Op->Asl.EndBlkComment    = Child->Asl.EndBlkComment;
+                Op->Asl.InlineComment    = Child->Asl.InlineComment;
+                Op->Asl.FileChanged      = Child->Asl.FileChanged;
+
+                Child->Asl.CommentList   = NULL;
+                Child->Asl.EndBlkComment = NULL;
+                Child->Asl.InlineComment = NULL;
+                Child->Asl.FileChanged   = FALSE;
+
+                /*
+                 * These do not need to be "passed off". They can be copied
+                 * because the code for these opcodes should be printed in the
+                 * same file.
+                 */
+                Op->Asl.Filename         = Child->Asl.Filename;
+                Op->Asl.ParentFilename   = Child->Asl.ParentFilename;
+            }
         }
 
         /* Point all children to parent */
@@ -1073,6 +1191,18 @@
             PrevChild->Asl.Next = Child;
         };
 
+        /* Get the comment from last child in the resource template call */
+
+        if (Gbl_CaptureComments &&
+            (Op->Asl.ParseOpcode == PARSEOP_RESOURCETEMPLATE))
+        {
+            CvDbgPrint ("Transferred current comment list to this node.\n");
+            Op->Asl.CommentList = Child->Asl.CommentList;
+            Child->Asl.CommentList = NULL;
+            Op->Asl.InlineComment = Child->Asl.InlineComment;
+            Child->Asl.InlineComment = NULL;
+        }
+
         /*
          * This child might be a list, point all nodes in the list
          * to the same parent
@@ -1097,9 +1227,9 @@
  * FUNCTION:    TrLinkChildren
  *
  * PARAMETERS:  Op                - An existing parse node
- *              NumChildren         - Number of children to follow
- *              ...                 - A list of child nodes to link to the new
- *                                    node. NumChildren long.
+ *              NumChildren        - Number of children to follow
+ *              ...                - A list of child nodes to link to the new
+ *                                   node. NumChildren long.
  *
  * RETURN:      The updated (linked) node
  *
@@ -1161,6 +1291,25 @@
         break;
     }
 
+    /* The following is for capturing comments */
+
+    if(Gbl_CaptureComments)
+    {
+        /*
+         * If there are "regular comments" detected at this point,
+         * then is an endBlk comment. Categorize it as so and distribute
+         * all regular comments to this parse node.
+         */
+        if (Gbl_Comment_List_Head)
+        {
+            Op->Asl.EndBlkComment = Gbl_Comment_List_Head;
+            CvDbgPrint ("EndBlk Comment for %s: %s",
+                Op->Asl.ParseOpName, Gbl_Comment_List_Head->Comment);
+            Gbl_Comment_List_Head = NULL;
+            Gbl_Comment_List_Tail = NULL;
+        }
+    }
+
     /* Link the new node to it's children */
 
     PrevChild = NULL;
@@ -1224,6 +1373,13 @@
 
     va_end(ap);
     DbgPrint (ASL_PARSE_OUTPUT, "\n\n");
+
+
+    if(Gbl_CaptureComments)
+    {
+        Gbl_CommentState.Latest_Parse_Node = Op;
+        CvDbgPrint ("trlinkchildren=====Set latest parse node to this node.\n");
+    }
     return (Op);
 }
 
@@ -1391,6 +1547,19 @@
         Op1, Op1 ? UtGetOpName(Op1->Asl.ParseOpcode): NULL,
         Op2, Op2 ? UtGetOpName(Op2->Asl.ParseOpcode): NULL);
 
+    /*
+     * Converter: if TrLinkChildNode is called to link a method call,
+     * turn on capture comments as it signifies that we are done parsing
+     * a method call.
+     */
+    if (Gbl_CaptureComments)
+    {
+        if (Op1->Asl.ParseOpcode == PARSEOP_METHODCALL)
+        {
+            Gbl_CommentState.CaptureComments = TRUE;
+        }
+        Gbl_CommentState.Latest_Parse_Node = Op1;
+    }
     if (!Op1 || !Op2)
     {
         return (Op1);
--- a/sys/external/bsd/acpica/dist/compiler/aslwalks.c	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/aslwalks.c	Sun Apr 30 23:13:36 2017 +0000
@@ -317,7 +317,7 @@
 
     case AML_BUFFER_OP:
     case AML_PACKAGE_OP:
-    case AML_VAR_PACKAGE_OP:
+    case AML_VARIABLE_PACKAGE_OP:
 
             /* If length is a constant, we are done */
 
--- a/sys/external/bsd/acpica/dist/debugger/dbmethod.c	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/debugger/dbmethod.c	Sun Apr 30 23:13:36 2017 +0000
@@ -479,6 +479,7 @@
     Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo);
     if (ACPI_FAILURE (Status))
     {
+        ACPI_FREE (Pathname);
         return (Status);
     }
 
--- a/sys/external/bsd/acpica/dist/disassembler/dmcstyle.c	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/disassembler/dmcstyle.c	Sun Apr 30 23:13:36 2017 +0000
@@ -46,6 +46,7 @@
 #include "acparser.h"
 #include "amlcode.h"
 #include "acdebug.h"
+#include "acconvert.h"
 
 
 #define _COMPONENT          ACPI_CA_DEBUGGER
@@ -171,27 +172,27 @@
 
     /* Logical operators, no target */
 
-    case AML_LAND_OP:
+    case AML_LOGICAL_AND_OP:
         OperatorSymbol = " && ";
         break;
 
-    case AML_LEQUAL_OP:
+    case AML_LOGICAL_EQUAL_OP:
         OperatorSymbol = " == ";
         break;
 
-    case AML_LGREATER_OP:
+    case AML_LOGICAL_GREATER_OP:
         OperatorSymbol = " > ";
         break;
 
-    case AML_LLESS_OP:
+    case AML_LOGICAL_LESS_OP:
         OperatorSymbol = " < ";
         break;
 
-    case AML_LOR_OP:
+    case AML_LOGICAL_OR_OP:
         OperatorSymbol = " || ";
         break;
 
-    case AML_LNOT_OP:
+    case AML_LOGICAL_NOT_OP:
         /*
          * Check for the LNOT sub-opcodes. These correspond to
          * LNotEqual, LLessEqual, and LGreaterEqual. There are
@@ -199,15 +200,15 @@
          */
         switch (Argument1->Common.AmlOpcode)
         {
-        case AML_LEQUAL_OP:
+        case AML_LOGICAL_EQUAL_OP:
             OperatorSymbol = " != ";
             break;
 
-        case AML_LGREATER_OP:
+        case AML_LOGICAL_GREATER_OP:
             OperatorSymbol = " <= ";
             break;
 
-        case AML_LLESS_OP:
+        case AML_LOGICAL_LESS_OP:
             OperatorSymbol = " >= ";
             break;
 
@@ -243,7 +244,7 @@
         if ((Argument1->Common.AmlOpcode == AML_STRING_OP)  ||
             (Argument1->Common.AmlOpcode == AML_BUFFER_OP)  ||
             (Argument1->Common.AmlOpcode == AML_PACKAGE_OP) ||
-            (Argument1->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
+            (Argument1->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP))
         {
             Op->Common.DisasmFlags |= ACPI_PARSEOP_CLOSING_PAREN;
             return (FALSE);
@@ -474,11 +475,11 @@
         case AML_BIT_AND_OP:
         case AML_BIT_OR_OP:
         case AML_BIT_XOR_OP:
-        case AML_LAND_OP:
-        case AML_LEQUAL_OP:
-        case AML_LGREATER_OP:
-        case AML_LLESS_OP:
-        case AML_LOR_OP:
+        case AML_LOGICAL_AND_OP:
+        case AML_LOGICAL_EQUAL_OP:
+        case AML_LOGICAL_GREATER_OP:
+        case AML_LOGICAL_LESS_OP:
+        case AML_LOGICAL_OR_OP:
 
             Op->Common.DisasmFlags |= ACPI_PARSEOP_ASSIGNMENT;
             AcpiOsPrintf ("(");
@@ -725,12 +726,14 @@
     if (!AcpiGbl_CstyleDisassembly)
     {
         AcpiOsPrintf (")");
+        ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_END_NODE, NULL, 0);
         return;
     }
 
     if (Op->Common.DisasmFlags & ACPI_PARSEOP_LEGACY_ASL_ONLY)
     {
         AcpiOsPrintf (")");
+        ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_END_NODE, NULL, 0);
         return;
     }
 
@@ -748,16 +751,17 @@
     case AML_BIT_AND_OP:
     case AML_BIT_OR_OP:
     case AML_BIT_XOR_OP:
-    case AML_LAND_OP:
-    case AML_LEQUAL_OP:
-    case AML_LGREATER_OP:
-    case AML_LLESS_OP:
-    case AML_LOR_OP:
+    case AML_LOGICAL_AND_OP:
+    case AML_LOGICAL_EQUAL_OP:
+    case AML_LOGICAL_GREATER_OP:
+    case AML_LOGICAL_LESS_OP:
+    case AML_LOGICAL_OR_OP:
 
         /* Emit paren only if this is not a compound assignment */
 
         if (Op->Common.DisasmFlags & ACPI_PARSEOP_COMPOUND_ASSIGNMENT)
         {
+            ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_END_NODE, NULL, 0);
             return;
         }
 
@@ -777,15 +781,17 @@
         {
             AcpiOsPrintf (")");
         }
+        ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_END_NODE, NULL, 0);
         return;
 
     /* No need for parens for these */
 
     case AML_DECREMENT_OP:
     case AML_INCREMENT_OP:
-    case AML_LNOT_OP:
+    case AML_LOGICAL_NOT_OP:
     case AML_BIT_NOT_OP:
     case AML_STORE_OP:
+        ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_END_NODE, NULL, 0);
         return;
 
     default:
@@ -795,6 +801,9 @@
     }
 
     AcpiOsPrintf (")");
+    ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_END_NODE, NULL, 0);
+
+    return;
 }
 
 
--- a/sys/external/bsd/acpica/dist/disassembler/dmwalk.c	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/disassembler/dmwalk.c	Sun Apr 30 23:13:36 2017 +0000
@@ -46,6 +46,7 @@
 #include "acparser.h"
 #include "amlcode.h"
 #include "acdebug.h"
+#include "acconvert.h"
 
 
 #define _COMPONENT          ACPI_CA_DEBUGGER
@@ -63,6 +64,14 @@
 {
     return;
 }
+
+void
+AcpiDmEmitExternal (
+    ACPI_PARSE_OBJECT       *NameOp,
+    ACPI_PARSE_OBJECT       *TypeOp)
+{
+    return;
+}
 #endif
 
 /* Local prototypes */
@@ -79,10 +88,6 @@
     UINT32                  Level,
     void                    *Context);
 
-static UINT32
-AcpiDmBlockType (
-    ACPI_PARSE_OBJECT       *Op);
-
 
 /*******************************************************************************
  *
@@ -248,7 +253,7 @@
  *
  ******************************************************************************/
 
-static UINT32
+UINT32
 AcpiDmBlockType (
     ACPI_PARSE_OBJECT       *Op)
 {
@@ -270,7 +275,7 @@
     case AML_DEVICE_OP:
     case AML_SCOPE_OP:
     case AML_PROCESSOR_OP:
-    case AML_POWER_RES_OP:
+    case AML_POWER_RESOURCE_OP:
     case AML_THERMAL_ZONE_OP:
     case AML_IF_OP:
     case AML_WHILE_OP:
@@ -292,7 +297,7 @@
         /*lint -fallthrough */
 
     case AML_PACKAGE_OP:
-    case AML_VAR_PACKAGE_OP:
+    case AML_VARIABLE_PACKAGE_OP:
 
         return (BLOCK_PAREN | BLOCK_BRACE);
 
@@ -304,7 +309,7 @@
 
         if (Op->Common.Parent &&
             ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
-             (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)))
+             (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP)))
         {
             /* This is a reference to a method, not an invocation */
 
@@ -357,7 +362,7 @@
     case AML_METHOD_OP:
     case AML_DEVICE_OP:
     case AML_SCOPE_OP:
-    case AML_POWER_RES_OP:
+    case AML_POWER_RESOURCE_OP:
     case AML_PROCESSOR_OP:
     case AML_THERMAL_ZONE_OP:
     case AML_IF_OP:
@@ -370,7 +375,7 @@
 
     case AML_BUFFER_OP:
     case AML_PACKAGE_OP:
-    case AML_VAR_PACKAGE_OP:
+    case AML_VARIABLE_PACKAGE_OP:
 
         return (BLOCK_COMMA_LIST);
 
@@ -414,6 +419,22 @@
     UINT32                  AmlOffset;
 
 
+    /* Determine which file this parse node is contained in. */
+
+    if (Gbl_CaptureComments)
+    {
+        ASL_CV_LABEL_FILENODE (Op);
+
+        if (Level != 0 && ASL_CV_FILE_HAS_SWITCHED (Op))
+        {
+            ASL_CV_SWITCH_FILES (Level, Op);
+        }
+
+        /* If this parse node has regular comments, print them here. */
+
+        ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_STANDARD, NULL, Level);
+    }
+
     OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
 
     /* Listing support to dump the AML code after the ASL statement */
@@ -528,7 +549,11 @@
 
             /* Emit all External() declarations here */
 
-            AcpiDmEmitExternals ();
+            if (!AcpiGbl_DmEmitExternalOpcodes)
+            {
+                AcpiDmEmitExternals ();
+            }
+
             return (AE_OK);
         }
     }
@@ -607,6 +632,12 @@
         Info->Level--;
     }
 
+    if (Op->Common.AmlOpcode == AML_EXTERNAL_OP)
+    {
+        Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+        return (AE_CTRL_DEPTH);
+    }
+
     /* Start the opcode argument list if necessary */
 
     if ((OpInfo->Flags & AML_HAS_ARGS) ||
@@ -617,6 +648,10 @@
         if (AcpiDmBlockType (Op) & BLOCK_PAREN)
         {
             AcpiOsPrintf (" (");
+            if (!(AcpiDmBlockType (Op) & BLOCK_BRACE))
+            {
+                ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, " ", 0);
+            }
         }
 
         /* If this is a named opcode, print the associated name value */
@@ -661,7 +696,7 @@
             case AML_METHOD_OP:
 
                 AcpiDmMethodFlags (Op);
-                AcpiOsPrintf (")");
+                ASL_CV_CLOSE_PAREN (Op, Level);
 
                 /* Emit description comment for Method() with a predefined ACPI name */
 
@@ -674,6 +709,7 @@
 
                 AcpiDmCheckForHardwareId (Op);
                 AcpiOsPrintf (", ");
+                ASL_CV_PRINT_ONE_COMMENT (Op, AML_NAMECOMMENT, NULL, 0);
                 break;
 
             case AML_REGION_OP:
@@ -681,7 +717,7 @@
                 AcpiDmRegionFlags (Op);
                 break;
 
-            case AML_POWER_RES_OP:
+            case AML_POWER_RESOURCE_OP:
 
                 /* Mark the next two Ops as part of the parameter list */
 
@@ -723,7 +759,7 @@
             case AML_DEVICE_OP:
             case AML_THERMAL_ZONE_OP:
 
-                AcpiOsPrintf (")");
+                ASL_CV_CLOSE_PAREN (Op, Level);
                 break;
 
             default:
@@ -817,7 +853,7 @@
                  */
                 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
                 NextOp = NextOp->Common.Next;
-                AcpiOsPrintf (")");
+                ASL_CV_CLOSE_PAREN (Op, Level);
 
                 /* Emit description comment for Name() with a predefined ACPI name */
 
@@ -835,7 +871,7 @@
             return (AE_OK);
 
         case AML_IF_OP:
-        case AML_VAR_PACKAGE_OP:
+        case AML_VARIABLE_PACKAGE_OP:
         case AML_WHILE_OP:
 
             /* The next op is the size or predicate parameter */
@@ -903,6 +939,20 @@
     ACPI_PARSE_OBJECT       *ParentOp;
 
 
+    /* Point the Op's filename pointer to the proper file */
+
+    if (Gbl_CaptureComments)
+    {
+        ASL_CV_LABEL_FILENODE (Op);
+
+        /* Switch the output of these files if necessary */
+
+        if (ASL_CV_FILE_HAS_SWITCHED (Op))
+        {
+            ASL_CV_SWITCH_FILES (Level, Op);
+        }
+    }
+
     if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE ||
         Op->Common.DisasmOpcode == ACPI_DASM_IGNORE_SINGLE)
     {
@@ -915,7 +965,17 @@
     {
         /* Indicates the end of the current descriptor block (table) */
 
-        AcpiOsPrintf ("}\n\n");
+        ASL_CV_CLOSE_BRACE (Op, Level);
+
+        /* Print any comments that are at the end of the file here */
+
+        if (Gbl_CaptureComments && AcpiGbl_LastListHead)
+        {
+            AcpiOsPrintf ("\n");
+            ASL_CV_PRINT_ONE_COMMENT_LIST (AcpiGbl_LastListHead, 0);
+        }
+        AcpiOsPrintf ("\n\n");
+
         return (AE_OK);
     }
 
@@ -976,12 +1036,12 @@
 
         if (Op->Common.DisasmFlags & ACPI_PARSEOP_EMPTY_TERMLIST)
         {
-            AcpiOsPrintf ("}");
+            ASL_CV_CLOSE_BRACE (Op, Level);
         }
         else
         {
             AcpiDmIndent (Level);
-            AcpiOsPrintf ("}");
+            ASL_CV_CLOSE_BRACE (Op, Level);
         }
 
         AcpiDmCommaIfListMember (Op);
@@ -1031,7 +1091,7 @@
             switch (Op->Common.Parent->Common.AmlOpcode)
             {
             case AML_PACKAGE_OP:
-            case AML_VAR_PACKAGE_OP:
+            case AML_VARIABLE_PACKAGE_OP:
 
                 if (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST))
                 {
@@ -1071,7 +1131,7 @@
          */
         if (Op->Common.Next || Op->Common.DisasmOpcode == ACPI_DASM_SWITCH_PREDICATE)
         {
-            AcpiOsPrintf (")");
+            ASL_CV_CLOSE_PAREN (Op, Level);
 
             /*
              * Emit a description comment for a Name() operator that is a
@@ -1098,7 +1158,8 @@
         else
         {
             ParentOp->Common.DisasmFlags |= ACPI_PARSEOP_EMPTY_TERMLIST;
-            AcpiOsPrintf (") {");
+            ASL_CV_CLOSE_PAREN (Op, Level);
+            AcpiOsPrintf ("{");
         }
     }
 
--- a/sys/external/bsd/acpica/dist/dispatcher/dscontrol.c	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/dispatcher/dscontrol.c	Sun Apr 30 23:13:36 2017 +0000
@@ -358,7 +358,7 @@
 
         break;
 
-    case AML_BREAK_POINT_OP:
+    case AML_BREAKPOINT_OP:
 
         AcpiDbSignalBreakPoint (WalkState);
 
--- a/sys/external/bsd/acpica/dist/dispatcher/dsopcode.c	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/dispatcher/dsopcode.c	Sun Apr 30 23:13:36 2017 +0000
@@ -681,7 +681,7 @@
         break;
 
     case AML_PACKAGE_OP:
-    case AML_VAR_PACKAGE_OP:
+    case AML_VARIABLE_PACKAGE_OP:
 
         Status = AcpiDsBuildInternalPackageObj (
             WalkState, Op, Length, &ObjDesc);
@@ -701,7 +701,7 @@
          */
         if ((!Op->Common.Parent) ||
             ((Op->Common.Parent->Common.AmlOpcode != AML_PACKAGE_OP) &&
-             (Op->Common.Parent->Common.AmlOpcode != AML_VAR_PACKAGE_OP) &&
+             (Op->Common.Parent->Common.AmlOpcode != AML_VARIABLE_PACKAGE_OP) &&
              (Op->Common.Parent->Common.AmlOpcode != AML_NAME_OP)))
         {
             WalkState->ResultObj = ObjDesc;
--- a/sys/external/bsd/acpica/dist/dispatcher/dsutils.c	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/dispatcher/dsutils.c	Sun Apr 30 23:13:36 2017 +0000
@@ -297,8 +297,8 @@
         if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP)       ||
             (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP)  ||
             (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP)      ||
-            (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)  ||
             (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP)       ||
+            (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP) ||
             (Op->Common.Parent->Common.AmlOpcode == AML_INT_EVAL_SUBTREE_OP) ||
             (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP))
         {
@@ -589,7 +589,7 @@
              */
             if (Status == AE_NOT_FOUND)
             {
-                if (ParentOp->Common.AmlOpcode == AML_COND_REF_OF_OP)
+                if (ParentOp->Common.AmlOpcode == AML_CONDITIONAL_REF_OF_OP)
                 {
                     /*
                      * For the Conditional Reference op, it's OK if
@@ -870,7 +870,7 @@
     }
 
     if ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
-        (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP) ||
+        (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP) ||
         (Op->Common.Parent->Common.AmlOpcode == AML_REF_OF_OP))
     {
         /* TBD: Should we specify this feature as a bit of OpInfo->Flags of these opcodes? */
--- a/sys/external/bsd/acpica/dist/include/acdisasm.h	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/include/acdisasm.h	Sun Apr 30 23:13:36 2017 +0000
@@ -803,6 +803,11 @@
     void);
 
 void
+AcpiDmEmitExternal (
+    ACPI_PARSE_OBJECT       *NameOp,
+    ACPI_PARSE_OBJECT       *TypeOp);
+
+void
 AcpiDmUnresolvedWarning (
     UINT8                   Type);
 
@@ -1097,4 +1102,13 @@
 AdDisplayStatistics (
     void);
 
+
+/*
+ * dmwalk
+ */
+UINT32
+AcpiDmBlockType (
+    ACPI_PARSE_OBJECT       *Op);
+
+
 #endif  /* __ACDISASM_H__ */
--- a/sys/external/bsd/acpica/dist/include/acglobal.h	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/include/acglobal.h	Sun Apr 30 23:13:36 2017 +0000
@@ -374,6 +374,50 @@
 
 #endif
 
+/*
+ * Meant for the -ca option.
+ */
+ACPI_INIT_GLOBAL (char*,   AcpiGbl_CurrentInlineComment,     NULL);
+ACPI_INIT_GLOBAL (char*,   AcpiGbl_CurrentEndNodeComment,    NULL);
+ACPI_INIT_GLOBAL (char*,   AcpiGbl_CurrentOpenBraceComment,  NULL);
+ACPI_INIT_GLOBAL (char*,   AcpiGbl_CurrentCloseBraceComment, NULL);
+
+ACPI_INIT_GLOBAL (char*,   AcpiGbl_RootFilename, NULL);
+ACPI_INIT_GLOBAL (char*,   AcpiGbl_CurrentFilename, NULL);
+ACPI_INIT_GLOBAL (char*,   AcpiGbl_CurrentParentFilename, NULL);
+ACPI_INIT_GLOBAL (char*,   AcpiGbl_CurrentIncludeFilename, NULL);
+
+ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE,   *AcpiGbl_LastListHead, NULL);
+
+ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE,   *AcpiGbl_DefBlkCommentListHead, NULL);
+ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE,   *AcpiGbl_DefBlkCommentListTail, NULL);
+
+ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE,   *AcpiGbl_RegCommentListHead, NULL);
+ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE,   *AcpiGbl_RegCommentListTail, NULL);
+
+ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE,   *AcpiGbl_IncCommentListHead, NULL);
+ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE,   *AcpiGbl_IncCommentListTail, NULL);
+
+ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE,   *AcpiGbl_EndBlkCommentListHead, NULL);
+ACPI_INIT_GLOBAL (ACPI_COMMENT_NODE,   *AcpiGbl_EndBlkCommentListTail, NULL);
+
+ACPI_INIT_GLOBAL (ACPI_COMMENT_ADDR_NODE,   *AcpiGbl_CommentAddrListHead, NULL);
+
+ACPI_INIT_GLOBAL (ACPI_PARSE_OBJECT,   *AcpiGbl_CurrentScope,     NULL);
+
+ACPI_INIT_GLOBAL (ACPI_FILE_NODE,      *AcpiGbl_FileTreeRoot, NULL);
+
+ACPI_GLOBAL (ACPI_CACHE_T *,            AcpiGbl_RegCommentCache);
+ACPI_GLOBAL (ACPI_CACHE_T *,            AcpiGbl_CommentAddrCache);
+ACPI_GLOBAL (ACPI_CACHE_T *,            AcpiGbl_FileCache);
+
+ACPI_INIT_GLOBAL (BOOLEAN, Gbl_CaptureComments, FALSE);
+
+ACPI_INIT_GLOBAL (BOOLEAN, AcpiGbl_DebugAslConversion, FALSE);
+ACPI_INIT_GLOBAL (ACPI_FILE, AcpiGbl_ConvDebugFile, NULL);
+
+ACPI_GLOBAL (char, AcpiGbl_TableSig[4]);
+
 /*****************************************************************************
  *
  * Application globals
--- a/sys/external/bsd/acpica/dist/include/aclocal.h	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/include/aclocal.h	Sun Apr 30 23:13:36 2017 +0000
@@ -54,7 +54,7 @@
 
 /* Total number of aml opcodes defined */
 
-#define AML_NUM_OPCODES                 0x82
+#define AML_NUM_OPCODES                 0x83
 
 
 /* Forward declarations */
@@ -905,21 +905,55 @@
 #define ACPI_DISASM_ONLY_MEMBERS(a)
 #endif
 
+#if defined(ACPI_ASL_COMPILER)
+#define ACPI_CONVERTER_ONLY_MEMBERS(a)  a;
+#else
+#define ACPI_CONVERTER_ONLY_MEMBERS(a)
+#endif
+
 #define ACPI_PARSE_COMMON \
-    union acpi_parse_object         *Parent;        /* Parent op */\
-    UINT8                           DescriptorType; /* To differentiate various internal objs */\
-    UINT8                           Flags;          /* Type of Op */\
-    UINT16                          AmlOpcode;      /* AML opcode */\
-    UINT8                           *Aml;           /* Address of declaration in AML */\
-    union acpi_parse_object         *Next;          /* Next op */\
-    ACPI_NAMESPACE_NODE             *Node;          /* For use by interpreter */\
-    ACPI_PARSE_VALUE                Value;          /* Value or args associated with the opcode */\
-    UINT8                           ArgListLength;  /* Number of elements in the arg list */\
-    ACPI_DISASM_ONLY_MEMBERS (\
-    UINT16                          DisasmFlags;    /* Used during AML disassembly */\
-    UINT8                           DisasmOpcode;   /* Subtype used for disassembly */\
-    const char                      *OperatorSymbol;/* Used for C-style operator name strings */\
-    char                            AmlOpName[16])  /* Op name (debug only) */
+    union acpi_parse_object         *Parent;            /* Parent op */\
+    UINT8                           DescriptorType;     /* To differentiate various internal objs */\
+    UINT8                           Flags;              /* Type of Op */\
+    UINT16                          AmlOpcode;          /* AML opcode */\
+    UINT8                           *Aml;               /* Address of declaration in AML */\
+    union acpi_parse_object         *Next;              /* Next op */\
+    ACPI_NAMESPACE_NODE             *Node;              /* For use by interpreter */\
+    ACPI_PARSE_VALUE                Value;              /* Value or args associated with the opcode */\
+    UINT8                           ArgListLength;      /* Number of elements in the arg list */\
+     ACPI_DISASM_ONLY_MEMBERS (\
+    UINT16                          DisasmFlags;        /* Used during AML disassembly */\
+    UINT8                           DisasmOpcode;       /* Subtype used for disassembly */\
+    const char                      *OperatorSymbol;    /* Used for C-style operator name strings */\
+    char                            AmlOpName[16])      /* Op name (debug only) */\
+     ACPI_CONVERTER_ONLY_MEMBERS (\
+    char                            *InlineComment;     /* Inline comment */\
+    char                            *EndNodeComment;    /* End of node comment */\
+    char                            *NameComment;       /* Comment associated with the first parameter of the name node */\
+    char                            *CloseBraceComment; /* Comments that come after } on the same as } */\
+    ACPI_COMMENT_NODE               *CommentList;       /* comments that appears before this node */\
+    ACPI_COMMENT_NODE               *EndBlkComment;     /* comments that at the end of a block but before ) or } */\
+    char                            *CvFilename;        /* Filename associated with this node. Used for ASL/ASL+ converter */\
+    char                            *CvParentFilename)  /* Parent filename associated with this node. Used for ASL/ASL+ converter */
+
+
+/* categories of comments */
+
+typedef enum
+{
+    STANDARD_COMMENT = 1,
+    INLINE_COMMENT,
+    ENDNODE_COMMENT,
+    OPENBRACE_COMMENT,
+    CLOSE_BRACE_COMMENT,
+    STD_DEFBLK_COMMENT,
+    END_DEFBLK_COMMENT,
+    FILENAME_COMMENT,
+    PARENTFILENAME_COMMENT,
+    ENDBLK_COMMENT,
+    INCLUDE_COMMENT
+
+} ASL_COMMENT_TYPES;
 
 
 /* Internal opcodes for DisasmOpcode field above */
@@ -936,9 +970,46 @@
 #define ACPI_DASM_LNOT_SUFFIX           0x09        /* End  of a LNotEqual (etc.) pair of opcodes */
 #define ACPI_DASM_HID_STRING            0x0A        /* String is a _HID or _CID */
 #define ACPI_DASM_IGNORE_SINGLE         0x0B        /* Ignore the opcode but not it's children */
-#define ACPI_DASM_SWITCH_PREDICATE      0x0C        /* Object is a predicate for a Switch or Case block */
-#define ACPI_DASM_CASE                  0x0D        /* If/Else is a Case in a Switch/Case block */
-#define ACPI_DASM_DEFAULT               0x0E        /* Else is a Default in a Switch/Case block */
+#define ACPI_DASM_SWITCH                0x0C        /* While is a Switch */
+#define ACPI_DASM_SWITCH_PREDICATE      0x0D        /* Object is a predicate for a Switch or Case block */
+#define ACPI_DASM_CASE                  0x0E        /* If/Else is a Case in a Switch/Case block */
+#define ACPI_DASM_DEFAULT               0x0F        /* Else is a Default in a Switch/Case block */
+
+
+/*
+ * List struct used in the -ca option
+ */
+typedef struct acpi_comment_node
+{
+  char                      *Comment;
+  struct acpi_comment_node  *Next;
+
+} ACPI_COMMENT_NODE;
+
+
+typedef struct acpi_comment_addr_node
+{
+  UINT8                                    *Addr;
+  struct acpi_comment_addr_node            *Next;
+} ACPI_COMMENT_ADDR_NODE;
+
+/*
+ * File node - used for "Include" operator file stack and
+ * depdendency tree for the -ca option
+ */
+typedef struct acpi_file_node
+{
+    void                    *File;
+    char                    *Filename;
+    char                    *FileStart;  /* Points to AML and indicates when the AML for this particular file starts. */
+    char                    *FileEnd;    /* Points to AML and indicates when the AML for this particular file ends. */
+    struct acpi_file_node   *Next;
+    struct acpi_file_node   *Parent;
+    BOOLEAN                 IncludeWritten;
+    ACPI_COMMENT_NODE       *IncludeComment;
+
+} ACPI_FILE_NODE;
+
 
 /*
  * Generic operation (for example:  If, While, Store)
@@ -974,6 +1045,8 @@
     union acpi_parse_object         *Child;
     union acpi_parse_object         *ParentMethod;
     char                            *Filename;
+    BOOLEAN                         FileChanged;
+    char                            *ParentFilename;
     char                            *ExternalName;
     char                            *Namepath;
     char                            NameSeg[4];
@@ -1006,6 +1079,15 @@
 
 } ACPI_PARSE_OBJECT;
 
+typedef struct asl_comment_state
+{
+    UINT8                   CommentType;
+    UINT32                  SpacesBefore;
+    ACPI_PARSE_OBJECT       *Latest_Parse_Node;
+    ACPI_PARSE_OBJECT       *ParsingParenBraceNode;
+    BOOLEAN                 CaptureComments;
+} ASL_COMMENT_STATE;
+
 
 /*
  * Parse state - one state per parser invocation and each control
--- a/sys/external/bsd/acpica/dist/include/acmacros.h	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/include/acmacros.h	Sun Apr 30 23:13:36 2017 +0000
@@ -499,4 +499,39 @@
 #define ACPI_IS_OCTAL_DIGIT(d)              (((char)(d) >= '0') && ((char)(d) <= '7'))
 
 
+/*
+ * Macors used for the ASL-/ASL+ converter utility
+ */
+#ifdef ACPI_ASL_COMPILER
+
+#define ASL_CV_LABEL_FILENODE(a)         CvLabelFileNode(a);
+#define ASL_CV_CAPTURE_COMMENTS_ONLY(a)   CvCaptureCommentsOnly (a);
+#define ASL_CV_CAPTURE_COMMENTS(a)       CvCaptureComments (a);
+#define ASL_CV_TRANSFER_COMMENTS(a)      CvTransferComments (a);
+#define ASL_CV_CLOSE_PAREN(a,b)          CvCloseParenWriteComment(a,b);
+#define ASL_CV_CLOSE_BRACE(a,b)          CvCloseBraceWriteComment(a,b);
+#define ASL_CV_SWITCH_FILES(a,b)         CvSwitchFiles(a,b);
+#define ASL_CV_CLEAR_OP_COMMENTS(a)       CvClearOpComments(a);
+#define ASL_CV_PRINT_ONE_COMMENT(a,b,c,d) CvPrintOneCommentType (a,b,c,d);
+#define ASL_CV_PRINT_ONE_COMMENT_LIST(a,b) CvPrintOneCommentList (a,b);
+#define ASL_CV_FILE_HAS_SWITCHED(a)       CvFileHasSwitched(a)
+#define ASL_CV_INIT_FILETREE(a,b,c)      CvInitFileTree(a,b,c);
+
+#else
+
+#define ASL_CV_LABEL_FILENODE(a)
+#define ASL_CV_CAPTURE_COMMENTS_ONLY(a)
+#define ASL_CV_CAPTURE_COMMENTS(a)
+#define ASL_CV_TRANSFER_COMMENTS(a)
+#define ASL_CV_CLOSE_PAREN(a,b)          AcpiOsPrintf (")");
+#define ASL_CV_CLOSE_BRACE(a,b)          AcpiOsPrintf ("}");
+#define ASL_CV_SWITCH_FILES(a,b)
+#define ASL_CV_CLEAR_OP_COMMENTS(a)
+#define ASL_CV_PRINT_ONE_COMMENT(a,b,c,d)
+#define ASL_CV_PRINT_ONE_COMMENT_LIST(a,b)
+#define ASL_CV_FILE_HAS_SWITCHED(a)       0
+#define ASL_CV_INIT_FILETREE(a,b,c)
+
+#endif
+
 #endif /* ACMACROS_H */
--- a/sys/external/bsd/acpica/dist/include/acpixf.h	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/include/acpixf.h	Sun Apr 30 23:13:36 2017 +0000
@@ -46,7 +46,7 @@
 
 /* Current ACPICA subsystem version in YYYYMMDD format */
 
-#define ACPI_CA_VERSION                 0x20170119
+#define ACPI_CA_VERSION                 0x20170303
 
 #include "acconfig.h"
 #include "actypes.h"
--- a/sys/external/bsd/acpica/dist/namespace/nsaccess.c	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/namespace/nsaccess.c	Sun Apr 30 23:13:36 2017 +0000
@@ -505,7 +505,7 @@
                 "Dual Pathname (2 segments, Flags=%X)\n", Flags));
             break;
 
-        case AML_MULTI_NAME_PREFIX_OP:
+        case AML_MULTI_NAME_PREFIX:
 
             /* More than one NameSeg, search rules do not apply */
 
--- a/sys/external/bsd/acpica/dist/namespace/nsrepair2.c	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/namespace/nsrepair2.c	Sun Apr 30 23:13:36 2017 +0000
@@ -448,16 +448,12 @@
             return (Status);
         }
 
-        /* Take care with reference counts */
-
         if (OriginalElement != *ElementPtr)
         {
-            /* Element was replaced */
+            /* Update reference count of new object */
 
             (*ElementPtr)->Common.ReferenceCount =
                 OriginalRefCount;
-
-            AcpiUtRemoveReference (OriginalElement);
         }
 
         ElementPtr++;
--- a/sys/external/bsd/acpica/dist/parser/psopcode.c	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/parser/psopcode.c	Sun Apr 30 23:13:36 2017 +0000
@@ -72,7 +72,7 @@
     AML_DEVICE_OP
     AML_THERMAL_ZONE_OP
     AML_METHOD_OP
-    AML_POWER_RES_OP
+    AML_POWER_RESOURCE_OP
     AML_PROCESSOR_OP
     AML_FIELD_OP
     AML_INDEX_FIELD_OP
@@ -98,7 +98,7 @@
     AML_DEVICE_OP
     AML_THERMAL_ZONE_OP
     AML_METHOD_OP
-    AML_POWER_RES_OP
+    AML_POWER_RESOURCE_OP
     AML_PROCESSOR_OP
     AML_FIELD_OP
     AML_INDEX_FIELD_OP
@@ -116,7 +116,7 @@
     AML_DEVICE_OP
     AML_THERMAL_ZONE_OP
     AML_METHOD_OP
-    AML_POWER_RES_OP
+    AML_POWER_RESOURCE_OP
     AML_PROCESSOR_OP
     AML_NAME_OP
     AML_ALIAS_OP
@@ -139,7 +139,7 @@
     AML_DEVICE_OP
     AML_THERMAL_ZONE_OP
     AML_METHOD_OP
-    AML_POWER_RES_OP
+    AML_POWER_RESOURCE_OP
     AML_PROCESSOR_OP
     AML_NAME_OP
     AML_ALIAS_OP
@@ -152,7 +152,7 @@
   must be deferred until needed
 
     AML_METHOD_OP
-    AML_VAR_PACKAGE_OP
+    AML_VARIABLE_PACKAGE_OP
     AML_CREATE_FIELD_OP
     AML_CREATE_BIT_FIELD_OP
     AML_CREATE_BYTE_FIELD_OP
@@ -337,7 +337,8 @@
 
 /* ACPI 6.0 opcodes */
 
-/* 81 */ ACPI_OP ("External",           ARGP_EXTERNAL_OP,          ARGI_EXTERNAL_OP,           ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,/* ? */  AML_TYPE_EXEC_3A_0T_0R,   AML_FLAGS_EXEC_3A_0T_0R)
+/* 81 */ ACPI_OP ("External",           ARGP_EXTERNAL_OP,          ARGI_EXTERNAL_OP,           ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,/* ? */  AML_TYPE_EXEC_3A_0T_0R,   AML_FLAGS_EXEC_3A_0T_0R),
+/* 82 */ ACPI_OP ("Comment",            ARGP_COMMENT_OP,           ARGI_COMMENT_OP,            ACPI_TYPE_STRING,            AML_CLASS_ARGUMENT,        AML_TYPE_LITERAL,         AML_CONSTANT)
 
 /*! [End] no source code translation !*/
 };
--- a/sys/external/bsd/acpica/dist/parser/psopinfo.c	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/parser/psopinfo.c	Sun Apr 30 23:13:36 2017 +0000
@@ -242,7 +242,7 @@
 /* 0x90 */    0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x73, 0x74,
 /* 0x98 */    0x75, 0x76, _UNK, _UNK, 0x77, 0x78, 0x79, 0x7A,
 /* 0xA0 */    0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x60, 0x61,
-/* 0xA8 */    0x62, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
+/* 0xA8 */    0x62, 0x82, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
 /* 0xB0 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
 /* 0xB8 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
 /* 0xC0 */    _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK, _UNK,
--- a/sys/external/bsd/acpica/dist/utilities/utcache.c	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/utilities/utcache.c	Sun Apr 30 23:13:36 2017 +0000
@@ -77,7 +77,7 @@
     ACPI_FUNCTION_ENTRY ();
 
 
-    if (!CacheName || !ReturnCache || (ObjectSize < 16))
+    if (!CacheName || !ReturnCache || !ObjectSize)
     {
         return (AE_BAD_PARAMETER);
     }
--- a/sys/external/bsd/acpica/dist/utilities/utdebug.c	Sun Apr 30 20:57:21 2017 +0000
+++ b/sys/external/bsd/acpica/dist/utilities/utdebug.c	Sun Apr 30 23:13:36 2017 +0000
@@ -707,4 +707,5 @@
 
 ACPI_EXPORT_SYMBOL (AcpiTracePoint)
 
+
 #endif