Adjust to new acpica trunk
authorchristos <christos@NetBSD.org>
Fri, 11 Nov 2016 21:11:30 +0000
branchtrunk
changeset 246102 12ee8d0111e5
parent 246101 c12160535f2a
child 246103 93a214f4a31b
Adjust to new acpica
sys/external/bsd/acpica/conf/files.acpica
sys/external/bsd/acpica/dist/common/dmtbdump.c
sys/external/bsd/acpica/dist/common/dmtbinfo.c
sys/external/bsd/acpica/dist/compiler/aslcompiler.h
sys/external/bsd/acpica/dist/compiler/aslutils.c
sys/external/bsd/acpica/dist/compiler/aslxref.c
sys/external/bsd/acpica/dist/compiler/dtfield.c
sys/external/bsd/acpica/dist/compiler/dtparser.y
sys/external/bsd/acpica/dist/compiler/dttable.c
sys/external/bsd/acpica/dist/compiler/dtutils.c
sys/external/bsd/acpica/dist/compiler/prparser.y
sys/external/bsd/acpica/dist/debugger/dbexec.c
sys/external/bsd/acpica/dist/debugger/dbinput.c
sys/external/bsd/acpica/dist/debugger/dbmethod.c
sys/external/bsd/acpica/dist/disassembler/dmbuffer.c
sys/external/bsd/acpica/dist/disassembler/dmcstyle.c
sys/external/bsd/acpica/dist/disassembler/dmresrcl.c
sys/external/bsd/acpica/dist/events/evrgnini.c
sys/external/bsd/acpica/dist/executer/exconfig.c
sys/external/bsd/acpica/dist/include/acapps.h
sys/external/bsd/acpica/dist/include/acdebug.h
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/acnamesp.h
sys/external/bsd/acpica/dist/include/acpiosxf.h
sys/external/bsd/acpica/dist/include/acpixf.h
sys/external/bsd/acpica/dist/include/actables.h
sys/external/bsd/acpica/dist/include/actypes.h
sys/external/bsd/acpica/dist/include/acutils.h
sys/external/bsd/acpica/dist/include/platform/acgcc.h
sys/external/bsd/acpica/dist/include/platform/acnetbsd.h
sys/external/bsd/acpica/dist/include/platform/acwinex.h
sys/external/bsd/acpica/dist/os_specific/service_layers/osefitbl.c
sys/external/bsd/acpica/dist/os_specific/service_layers/osefixf.c
sys/external/bsd/acpica/dist/os_specific/service_layers/oslibcfs.c
sys/external/bsd/acpica/dist/tables/tbdata.c
sys/external/bsd/acpica/dist/tables/tbfadt.c
sys/external/bsd/acpica/dist/tables/tbinstal.c
sys/external/bsd/acpica/dist/tables/tbutils.c
sys/external/bsd/acpica/dist/tables/tbxface.c
sys/external/bsd/acpica/dist/tables/tbxfload.c
sys/external/bsd/acpica/dist/tables/tbxfroot.c
sys/external/bsd/acpica/dist/tools/acpidump/apfiles.c
sys/external/bsd/acpica/dist/utilities/utdebug.c
sys/external/bsd/acpica/dist/utilities/utosi.c
sys/external/bsd/acpica/dist/utilities/utprint.c
sys/external/bsd/acpica/dist/utilities/uttrack.c
--- a/sys/external/bsd/acpica/conf/files.acpica	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/conf/files.acpica	Fri Nov 11 21:11:30 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.acpica,v 1.14 2016/05/04 19:27:57 christos Exp $
+# $NetBSD: files.acpica,v 1.15 2016/11/11 21:11:30 christos Exp $
 
 define		acpica
 makeoptions	acpi	CPPFLAGS+="-I$S/external/bsd/acpica/dist/include"
@@ -204,6 +204,7 @@
 file	utilities/utresrc.c		acpica
 file	utilities/utstate.c		acpica
 file	utilities/utstring.c		acpica
+file	utilities/utstrtoul64.c		acpica
 file	utilities/uttrack.c		acpica
 file	utilities/utuuid.c		acpica
 file	utilities/utxface.c		acpica
--- a/sys/external/bsd/acpica/dist/common/dmtbdump.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/common/dmtbdump.c	Fri Nov 11 21:11:30 2016 +0000
@@ -52,12 +52,31 @@
         ACPI_MODULE_NAME    ("dmtbdump")
 
 
-/* Local prototypes */
-
-static void
-AcpiDmValidateFadtLength (
-    UINT32                  Revision,
-    UINT32                  Length);
+/* Table of revision-dependent FADT sizes */
+
+static const UINT32         FadtRevisionLength [ACPI_FADT_MAX_VERSION + 1] =
+{
+    0,                      /* 0 - illegal */
+    ACPI_FADT_V1_SIZE,      /* 1 - ACPI 1.0 */
+    0,                      /* 2 - illegal */
+    ACPI_FADT_V3_SIZE,      /* 3 - ACPI 2.0 */
+    ACPI_FADT_V4_SIZE,      /* 4 - ACPI 3.0 and ACPI 4.0 */
+    ACPI_FADT_V5_SIZE,      /* 5 - ACPI 5.0 */
+    ACPI_FADT_V6_SIZE       /* 6 - ACPI 6.0 */
+};
+
+/* Table of revision-dependent FADT info tables */
+
+ACPI_DMTABLE_INFO           *FadtRevisionInfo [ACPI_FADT_MAX_VERSION + 1] =
+{
+    NULL,                   /* 0 - illegal */
+    AcpiDmTableInfoFadt1,   /* 1 - ACPI 1.0 */
+    NULL,                   /* 2 - illegal */
+    AcpiDmTableInfoFadt3,   /* 3 - ACPI 2.0 */
+    AcpiDmTableInfoFadt4,   /* 4 - ACPI 3.0 and ACPI 4.0 */
+    AcpiDmTableInfoFadt5,   /* 5 - ACPI 5.0 */
+    AcpiDmTableInfoFadt6    /* 6 - ACPI 6.0 */
+};
 
 
 /*******************************************************************************
@@ -347,6 +366,11 @@
  *
  * DESCRIPTION: Format the contents of a FADT
  *
+ *              Check the FADT revision against the expected table length for
+ *              that revision. Issue a warning if the length is not what was
+ *              expected. This seems to be such a common BIOS bug that the
+ *              FADT revision has been rendered virtually meaningless.
+ *
  * NOTE:        We cannot depend on the FADT version to indicate the actual
  *              contents of the FADT because of BIOS bugs. The table length
  *              is the only reliable indicator.
@@ -358,142 +382,72 @@
     ACPI_TABLE_HEADER       *Table)
 {
     ACPI_STATUS             Status;
-
-
-    /* Always dump the minimum FADT revision 1 fields (ACPI 1.0) */
-
-    Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
-        AcpiDmTableInfoFadt1);
-    if (ACPI_FAILURE (Status))
+    UINT8                   FadtRevision;
+    UINT32                  ExpectedLength;
+    UINT32                  i;
+
+
+    FadtRevision = Table->Revision;
+
+    /* FADT revision/length validation */
+
+    if ((FadtRevision == 0) ||
+        (FadtRevision == 2))
     {
+        AcpiOsPrintf (
+            "// ACPI Warning: Invalid or unsupported FADT revision: %u\n",
+            FadtRevision);
         return;
     }
 
-    /* Check for FADT revision 2 fields (ACPI 1.0B MS extensions) */
-
-    if ((Table->Length > ACPI_FADT_V1_SIZE) &&
-        (Table->Length <= ACPI_FADT_V2_SIZE))
+    if (FadtRevision > ACPI_FADT_MAX_VERSION)
+    {
+        AcpiOsPrintf ("// ACPI Warning: Revision %u is not fully supported, "
+            "disassembling known fields (up to revision %u)\n\n",
+            FadtRevision, ACPI_FADT_MAX_VERSION);
+    }
+    else
     {
-        Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
-            AcpiDmTableInfoFadt2);
-        if (ACPI_FAILURE (Status))
+        ExpectedLength = FadtRevisionLength[FadtRevision];
+        if (Table->Length != ExpectedLength)
         {
-            return;
+            AcpiOsPrintf (
+                "// ACPI Warning: Input FADT revision %X does not match "
+                "expected length: found 0x%X expected 0x%X\n",
+                FadtRevision, Table->Length, ExpectedLength);
         }
     }
 
-    /* Check for FADT revision 3/4 fields and up (ACPI 2.0+ extended data) */
-
-    else if (Table->Length > ACPI_FADT_V2_SIZE)
+    /*
+     * Dump the input table on a per-version basis, but is actually
+     * based upon the length of the table. Table length must
+     * be larger than the required length of the previous version.
+     */
+    for (i = 1; i <= ACPI_FADT_MAX_VERSION; i++)
     {
+        if (!FadtRevisionLength[i]) /* Skip any empty slots */
+        {
+            continue;
+        }
+
+        /* Dump the fields specific to FADT revision[i] */
+
         Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
-            AcpiDmTableInfoFadt3);
+            FadtRevisionInfo[i]);
         if (ACPI_FAILURE (Status))
         {
             return;
         }
 
-        /* Check for FADT revision 5 fields and up (ACPI 5.0+) */
-
-        if (Table->Length > ACPI_FADT_V3_SIZE)
+        if (Table->Length <= FadtRevisionLength[i])
         {
-            Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
-                AcpiDmTableInfoFadt5);
-            if (ACPI_FAILURE (Status))
-            {
-                return;
-            }
-        }
-
-        /* Check for FADT revision 6 fields and up (ACPI 6.0+) */
-
-        if (Table->Length > ACPI_FADT_V3_SIZE)
-        {
-            Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
-                AcpiDmTableInfoFadt6);
-            if (ACPI_FAILURE (Status))
-            {
-                return;
-            }
+            break;  /* End of table */
         }
     }
 
-    /* Validate various fields in the FADT, including length */
+    /* Build a local FADT to test some FADT values */
 
     AcpiTbCreateLocalFadt (Table, Table->Length);
-
-    /* Validate FADT length against the revision */
-
-    AcpiDmValidateFadtLength (Table->Revision, Table->Length);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiDmValidateFadtLength
- *
- * PARAMETERS:  Revision            - FADT revision (Header->Revision)
- *              Length              - FADT length (Header->Length
- *
- * RETURN:      None
- *
- * DESCRIPTION: Check the FADT revision against the expected table length for
- *              that revision. Issue a warning if the length is not what was
- *              expected. This seems to be such a common BIOS bug that the
- *              FADT revision has been rendered virtually meaningless.
- *
- ******************************************************************************/
-
-static void
-AcpiDmValidateFadtLength (
-    UINT32                  Revision,
-    UINT32                  Length)
-{
-    UINT32                  ExpectedLength;
-
-
-    switch (Revision)
-    {
-    case 0:
-
-        AcpiOsPrintf ("// ACPI Warning: Invalid FADT revision: 0\n");
-        return;
-
-    case 1:
-
-        ExpectedLength = ACPI_FADT_V1_SIZE;
-        break;
-
-    case 2:
-
-        ExpectedLength = ACPI_FADT_V2_SIZE;
-        break;
-
-    case 3:
-    case 4:
-
-        ExpectedLength = ACPI_FADT_V3_SIZE;
-        break;
-
-    case 5:
-
-        ExpectedLength = ACPI_FADT_V5_SIZE;
-        break;
-
-    default:
-
-        return;
-    }
-
-    if (Length == ExpectedLength)
-    {
-        return;
-    }
-
-    AcpiOsPrintf (
-        "\n// ACPI Warning: FADT revision %X does not match length: "
-        "found %X expected %X\n",
-        Revision, Length, ExpectedLength);
 }
 
 
--- a/sys/external/bsd/acpica/dist/common/dmtbinfo.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/common/dmtbinfo.c	Fri Nov 11 21:11:30 2016 +0000
@@ -106,6 +106,7 @@
 #define ACPI_NFIT_OFFSET(f)             (UINT16) ACPI_OFFSET (ACPI_TABLE_NFIT,f)
 #define ACPI_PCCT_OFFSET(f)             (UINT16) ACPI_OFFSET (ACPI_TABLE_PCCT,f)
 #define ACPI_PMTT_OFFSET(f)             (UINT16) ACPI_OFFSET (ACPI_TABLE_PMTT,f)
+#define ACPI_RASF_OFFSET(f)             (UINT16) ACPI_OFFSET (ACPI_TABLE_RASF,f)
 #define ACPI_S3PT_OFFSET(f)             (UINT16) ACPI_OFFSET (ACPI_TABLE_S3PT,f)
 #define ACPI_SBST_OFFSET(f)             (UINT16) ACPI_OFFSET (ACPI_TABLE_SBST,f)
 #define ACPI_SLIT_OFFSET(f)             (UINT16) ACPI_OFFSET (ACPI_TABLE_SLIT,f)
@@ -399,7 +400,7 @@
  *
  ******************************************************************************/
 
-/* ACPI 1.0 FADT (Version 1) */
+/* FADT version 1 (ACPI 1.0) */
 
 ACPI_DMTABLE_INFO           AcpiDmTableInfoFadt1[] =
 {
@@ -485,18 +486,7 @@
     ACPI_DMT_TERMINATOR
 };
 
-/* ACPI 1.0 MS Extensions (FADT version 2) */
-
-ACPI_DMTABLE_INFO           AcpiDmTableInfoFadt2[] =
-{
-    {ACPI_DMT_GAS,      ACPI_FADT_OFFSET (ResetRegister),           "Reset Register", 0},
-    {ACPI_DMT_UINT8,    ACPI_FADT_OFFSET (ResetValue),              "Value to cause reset", 0},
-    {ACPI_DMT_UINT16,   ACPI_FADT_OFFSET (ArmBootFlags),            "Reserved", 0},
-    {ACPI_DMT_UINT8,    ACPI_FADT_OFFSET (MinorRevision),           "Reserved", 0},
-    ACPI_DMT_TERMINATOR
-};
-
-/* ACPI 2.0+ Extensions (FADT version 3, 4, and 5) */
+/* FADT version 3 (ACPI 2.0) */
 
 ACPI_DMTABLE_INFO           AcpiDmTableInfoFadt3[] =
 {
@@ -520,16 +510,23 @@
     ACPI_DMT_TERMINATOR
 };
 
-/* ACPI 5.0 Extensions (FADT version 5) */
+/* FADT version 4 (ACPI 3.0 and ACPI 4.0) */
+
+ACPI_DMTABLE_INFO           AcpiDmTableInfoFadt4[] =
+{
+    {ACPI_DMT_GAS,      ACPI_FADT_OFFSET (SleepControl),            "Sleep Control Register", 0},
+    ACPI_DMT_TERMINATOR
+};
+
+/* FADT version 5 (ACPI 5.0) */
 
 ACPI_DMTABLE_INFO           AcpiDmTableInfoFadt5[] =
 {
-    {ACPI_DMT_GAS,      ACPI_FADT_OFFSET (SleepControl),            "Sleep Control Register", 0},
     {ACPI_DMT_GAS,      ACPI_FADT_OFFSET (SleepStatus),             "Sleep Status Register", 0},
     ACPI_DMT_TERMINATOR
 };
 
-/* ACPI 6.0 Extensions (FADT version 6) */
+/* FADT version 6 (ACPI 6.0) */
 
 ACPI_DMTABLE_INFO           AcpiDmTableInfoFadt6[] =
 {
@@ -2440,6 +2437,18 @@
 
 /*******************************************************************************
  *
+ * RASF -  RAS Feature table
+ *
+ ******************************************************************************/
+
+ACPI_DMTABLE_INFO           AcpiDmTableInfoRasf[] =
+{
+    {ACPI_DMT_BUF12,    ACPI_RASF_OFFSET (ChannelId[0]),            "Channel ID", 0},
+    ACPI_DMT_TERMINATOR
+};
+
+/*******************************************************************************
+ *
  * S3PT - S3 Performance Table
  *
  ******************************************************************************/
--- a/sys/external/bsd/acpica/dist/compiler/aslcompiler.h	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/aslcompiler.h	Fri Nov 11 21:11:30 2016 +0000
@@ -62,7 +62,6 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <stdarg.h>
 #include <string.h>
 #include <errno.h>
 #include <ctype.h>
@@ -912,7 +911,7 @@
     void);
 
 /*
- * aslmain - startup
+ * aslhelp - help screens
  */
 void
 Usage (
@@ -922,6 +921,10 @@
 AslFilenameHelp (
     void);
 
+void
+AslDisassemblyHelp (
+    void);
+
 
 /*
  * aslnamesp - namespace output file generation
--- a/sys/external/bsd/acpica/dist/compiler/aslutils.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/aslutils.c	Fri Nov 11 21:11:30 2016 +0000
@@ -909,7 +909,7 @@
  *
  * FUNCTION:    UtDoConstant
  *
- * PARAMETERS:  String              - Hex, Octal, or Decimal string
+ * PARAMETERS:  String              - Hexadecimal or decimal string
  *
  * RETURN:      Converted Integer
  *
@@ -926,9 +926,7 @@
     char                    ErrBuf[64];
 
 
-    Status = AcpiUtStrtoul64 (String, ACPI_ANY_BASE,
-        ACPI_MAX64_BYTE_WIDTH, &Converted);
-
+    Status = AcpiUtStrtoul64 (String, ACPI_STRTOUL_64BIT, &Converted);
     if (ACPI_FAILURE (Status))
     {
         snprintf (ErrBuf, sizeof(ErrBuf), "%s %s\n", "Conversion error:",
@@ -938,64 +936,3 @@
 
     return (Converted);
 }
-
-
-#ifdef _OBSOLETE_FUNCTIONS
-/* Removed 01/2016 */
-
-/*******************************************************************************
- *
- * FUNCTION:    UtConvertByteToHex
- *
- * PARAMETERS:  RawByte             - Binary data
- *              Buffer              - Pointer to where the hex bytes will be
- *                                    stored
- *
- * RETURN:      Ascii hex byte is stored in Buffer.
- *
- * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed
- *              with "0x"
- *
- ******************************************************************************/
-
-void
-UtConvertByteToHex (
-    UINT8                   RawByte,
-    UINT8                   *Buffer)
-{
-
-    Buffer[0] = '0';
-    Buffer[1] = 'x';
-
-    Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4);
-    Buffer[3] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    UtConvertByteToAsmHex
- *
- * PARAMETERS:  RawByte             - Binary data
- *              Buffer              - Pointer to where the hex bytes will be
- *                                    stored
- *
- * RETURN:      Ascii hex byte is stored in Buffer.
- *
- * DESCRIPTION: Perform hex-to-ascii translation. The return data is prefixed
- *              with '0', and a trailing 'h' is added.
- *
- ******************************************************************************/
-
-void
-UtConvertByteToAsmHex (
-    UINT8                   RawByte,
-    UINT8                   *Buffer)
-{
-
-    Buffer[0] = '0';
-    Buffer[1] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 4);
-    Buffer[2] = (UINT8) AcpiUtHexToAsciiChar (RawByte, 0);
-    Buffer[3] = 'h';
-}
-#endif /* OBSOLETE_FUNCTIONS */
--- a/sys/external/bsd/acpica/dist/compiler/aslxref.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/aslxref.c	Fri Nov 11 21:11:30 2016 +0000
@@ -826,16 +826,18 @@
         /*
          * A reference to a method within one of these opcodes is not an
          * invocation of the method, it is simply a reference to the method.
+         *
+         * September 2016: Removed DeRefOf from this list
          */
         if ((Op->Asl.Parent) &&
-           ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_REFOF)      ||
-            (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEREFOF)    ||
+            ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_REFOF)     ||
             (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_PACKAGE)    ||
             (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE)||
             (Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_OBJECTTYPE)))
         {
             return_ACPI_STATUS (AE_OK);
         }
+
         /*
          * There are two types of method invocation:
          * 1) Invocation with arguments -- the parser recognizes this
--- a/sys/external/bsd/acpica/dist/compiler/dtfield.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/dtfield.c	Fri Nov 11 21:11:30 2016 +0000
@@ -370,10 +370,10 @@
  * FUNCTION:    DtNormalizeBuffer
  *
  * PARAMETERS:  Buffer              - Input buffer
- *              Count               - Output the count of hex number in
+ *              Count               - Output the count of hex numbers in
  *                                    the Buffer
  *
- * RETURN:      The normalized buffer, freed by caller
+ * RETURN:      The normalized buffer, must be freed by caller
  *
  * DESCRIPTION: [1A,2B,3C,4D] or 1A, 2B, 3C, 4D will be normalized
  *              to 1A 2B 3C 4D
@@ -457,36 +457,38 @@
     DT_FIELD                *Field,
     UINT32                  ByteLength)
 {
+    char                    *Substring;
     ACPI_STATUS             Status;
-    char                    Hex[3];
-    UINT64                  Value;
+    UINT32                  Count;
     UINT32                  i;
-    UINT32                  Count;
 
 
     /* Allow several different types of value separators */
 
     StringValue = DtNormalizeBuffer (StringValue, &Count);
+    Substring = StringValue;
 
-    Hex[2] = 0;
-    for (i = 0; i < Count; i++)
-    {
-        /* Each element of StringValue is three chars */
+    /* Each element of StringValue is now three chars (2 hex + 1 space) */
 
-        Hex[0] = StringValue[(3 * i)];
-        Hex[1] = StringValue[(3 * i) + 1];
-
-        /* Convert one hex byte */
+    for (i = 0; i < Count; i++, Substring += 3)
+    {
+        /* Check for byte value too long */
 
-        Value = 0;
-        Status = DtStrtoul64 (Hex, &Value);
-        if (ACPI_FAILURE (Status))
+        if (*(&Substring[2]) &&
+           (*(&Substring[2]) != ' '))
         {
-            DtError (ASL_ERROR, ASL_MSG_BUFFER_ELEMENT, Field, MsgBuffer);
+            DtError (ASL_ERROR, ASL_MSG_BUFFER_ELEMENT, Field, Substring);
             goto Exit;
         }
 
-        Buffer[i] = (UINT8) Value;
+        /* Convert two ASCII characters to one hex byte */
+
+        Status = AcpiUtAsciiToHexByte (Substring, &Buffer[i]);
+        if (ACPI_FAILURE (Status))
+        {
+            DtError (ASL_ERROR, ASL_MSG_BUFFER_ELEMENT, Field, Substring);
+            goto Exit;
+        }
     }
 
 Exit:
@@ -499,13 +501,13 @@
  *
  * FUNCTION:    DtCompileFlag
  *
- * PARAMETERS:  Buffer              - Output buffer
- *              Field               - Field to be compiled
- *              Info                - Flag info
+ * PARAMETERS:  Buffer                      - Output buffer
+ *              Field                       - Field to be compiled
+ *              Info                        - Flag info
  *
- * RETURN:
+ * RETURN:      None
  *
- * DESCRIPTION: Compile a flag
+ * DESCRIPTION: Compile a flag field. Handles flags up to 64 bits.
  *
  *****************************************************************************/
 
@@ -521,7 +523,8 @@
     ACPI_STATUS             Status;
 
 
-    Status = DtStrtoul64 (Field->Value, &Value);
+    Status = AcpiUtStrtoul64 (Field->Value,
+        (ACPI_STRTOUL_64BIT | ACPI_STRTOUL_BASE16), &Value);
     if (ACPI_FAILURE (Status))
     {
         DtError (ASL_ERROR, ASL_MSG_INVALID_HEX_INTEGER, Field, NULL);
--- a/sys/external/bsd/acpica/dist/compiler/dtparser.y	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/dtparser.y	Fri Nov 11 21:11:30 2016 +0000
@@ -171,15 +171,15 @@
 
       /* Default base for a non-prefixed integer is 16 */
 
-    | EXPOP_NUMBER                                  { AcpiUtStrtoul64 (DtParsertext, 16, ACPI_MAX64_BYTE_WIDTH, &$$);}
+    | EXPOP_NUMBER                                  { AcpiUtStrtoul64 (DtParsertext, (ACPI_STRTOUL_BASE16 | ACPI_STRTOUL_64BIT), &$$);}
 
       /* Standard hex number (0x1234) */
 
-    | EXPOP_HEX_NUMBER                              { AcpiUtStrtoul64 (DtParsertext, 16, ACPI_MAX64_BYTE_WIDTH, &$$);}
+    | EXPOP_HEX_NUMBER                              { AcpiUtStrtoul64 (DtParsertext, (ACPI_STRTOUL_BASE16 | ACPI_STRTOUL_64BIT), &$$);}
 
       /* TBD: Decimal number with prefix (0d1234) - Not supported by strtoul64 at this time */
 
-    | EXPOP_DECIMAL_NUMBER                          { AcpiUtStrtoul64 (DtParsertext, 10, ACPI_MAX64_BYTE_WIDTH, &$$);}
+    | EXPOP_DECIMAL_NUMBER                          { AcpiUtStrtoul64 (DtParsertext, ACPI_STRTOUL_64BIT, &$$);}
     ;
 %%
 
--- a/sys/external/bsd/acpica/dist/compiler/dttable.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/dttable.c	Fri Nov 11 21:11:30 2016 +0000
@@ -129,9 +129,12 @@
     DT_SUBTABLE             *ParentTable;
     DT_FIELD                **PFieldList = (DT_FIELD **) List;
     ACPI_TABLE_HEADER       *Table;
-    UINT8                   Revision;
+    UINT8                   FadtRevision;
+    UINT32                  i;
 
 
+    /* Minimum table is the FADT version 1 (ACPI 1.0) */
+
     Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt1,
         &Subtable, TRUE);
     if (ACPI_FAILURE (Status))
@@ -143,22 +146,41 @@
     DtInsertSubtable (ParentTable, Subtable);
 
     Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ParentTable->Buffer);
-    Revision = Table->Revision;
+    FadtRevision = Table->Revision;
 
-    if (Revision == 2)
+    /* Revision 0 and 2 are illegal */
+
+    if ((FadtRevision == 0) ||
+        (FadtRevision == 2))
     {
-        Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt2,
-            &Subtable, TRUE);
-        if (ACPI_FAILURE (Status))
+        DtError (ASL_ERROR, 0, NULL,
+            "Invalid value for FADT revision");
+
+        return (AE_BAD_VALUE);
+    }
+
+    /* Revision out of supported range? */
+
+    if (FadtRevision > ACPI_FADT_MAX_VERSION)
+    {
+        DtError (ASL_ERROR, 0, NULL,
+            "Unknown or unsupported value for FADT revision");
+
+        return (AE_BAD_VALUE);
+    }
+
+    /* Compile individual sub-parts of the FADT, per-revision */
+
+    for (i = 3; i <= ACPI_FADT_MAX_VERSION; i++)
+    {
+        if (i > FadtRevision)
         {
-            return (Status);
+            break;
         }
 
-        DtInsertSubtable (ParentTable, Subtable);
-    }
-    else if (Revision >= 2)
-    {
-        Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt3,
+        /* Compile the fields specific to this FADT revision */
+
+        Status = DtCompileTable (PFieldList, FadtRevisionInfo[i],
             &Subtable, TRUE);
         if (ACPI_FAILURE (Status))
         {
@@ -166,30 +188,6 @@
         }
 
         DtInsertSubtable (ParentTable, Subtable);
-
-        if (Revision >= 5)
-        {
-            Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt5,
-                &Subtable, TRUE);
-            if (ACPI_FAILURE (Status))
-            {
-                return (Status);
-            }
-
-            DtInsertSubtable (ParentTable, Subtable);
-        }
-
-        if (Revision >= 6)
-        {
-            Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt6,
-                &Subtable, TRUE);
-            if (ACPI_FAILURE (Status))
-            {
-                return (Status);
-            }
-
-            DtInsertSubtable (ParentTable, Subtable);
-        }
     }
 
     return (AE_OK);
--- a/sys/external/bsd/acpica/dist/compiler/dtutils.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/dtutils.c	Fri Nov 11 21:11:30 2016 +0000
@@ -197,93 +197,6 @@
 
 /******************************************************************************
  *
- * FUNCTION:    DtStrtoul64
- *
- * PARAMETERS:  String              - Null terminated string
- *              ReturnInteger       - Where the converted integer is returned
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Simple conversion of a string hex integer constant to unsigned
- *              value. Assumes no leading "0x" for the constant.
- *
- * Portability note: The reason this function exists is because a 64-bit
- * sscanf is not available in all environments.
- *
- *****************************************************************************/
-
-ACPI_STATUS
-DtStrtoul64 (
-    char                    *String,
-    UINT64                  *ReturnInteger)
-{
-    char                    *ThisChar = String;
-    UINT32                  ThisDigit;
-    UINT64                  ReturnValue = 0;
-    int                     DigitCount = 0;
-
-
-    /* Skip over any white space in the buffer */
-
-    while ((*ThisChar == ' ') || (*ThisChar == '\t'))
-    {
-        ThisChar++;
-    }
-
-    /* Skip leading zeros */
-
-    while ((*ThisChar) == '0')
-    {
-        ThisChar++;
-    }
-
-    /* Convert character-by-character */
-
-    while (*ThisChar)
-    {
-        if (isdigit ((int) *ThisChar))
-        {
-            /* Convert ASCII 0-9 to Decimal value */
-
-            ThisDigit = ((UINT8) *ThisChar) - '0';
-        }
-        else /* Letter */
-        {
-            ThisDigit = (UINT32) toupper ((int) *ThisChar);
-            if (!isxdigit ((int) ThisDigit))
-            {
-                /* Not A-F */
-
-                return (AE_BAD_CHARACTER);
-            }
-
-            /* Convert ASCII Hex char (A-F) to value */
-
-            ThisDigit = (ThisDigit - 'A') + 10;
-        }
-
-        /* Insert the 4-bit hex digit */
-
-        ReturnValue <<= 4;
-        ReturnValue += ThisDigit;
-
-        ThisChar++;
-        DigitCount++;
-        if (DigitCount > 16)
-        {
-            /* Value is too large (> 64 bits/8 bytes/16 hex digits) */
-
-            return (AE_LIMIT);
-        }
-    }
-
-    *ReturnInteger = ReturnValue;
-    return (AE_OK);
-}
-
-
-/******************************************************************************
- *
  * FUNCTION:    DtGetFieldValue
  *
  * PARAMETERS:  Field               - Current field list pointer
@@ -367,6 +280,7 @@
     case ACPI_DMT_RAW_BUFFER:
     case ACPI_DMT_BUF7:
     case ACPI_DMT_BUF10:
+    case ACPI_DMT_BUF12:
     case ACPI_DMT_BUF16:
     case ACPI_DMT_BUF128:
     case ACPI_DMT_PCI_PATH:
@@ -616,6 +530,11 @@
         ByteLength = 10;
         break;
 
+    case ACPI_DMT_BUF12:
+
+        ByteLength = 12;
+        break;
+
     case ACPI_DMT_BUF16:
     case ACPI_DMT_UUID:
 
--- a/sys/external/bsd/acpica/dist/compiler/prparser.y	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/compiler/prparser.y	Fri Nov 11 21:11:30 2016 +0000
@@ -184,11 +184,11 @@
 
       /* Default base for a non-prefixed integer is 10 */
 
-    | EXPOP_NUMBER                                  { AcpiUtStrtoul64 (PrParsertext, 10, ACPI_MAX64_BYTE_WIDTH, &$$);}
+    | EXPOP_NUMBER                                  { AcpiUtStrtoul64 (PrParsertext, ACPI_STRTOUL_64BIT, &$$);}
 
       /* Standard hex number (0x1234) */
 
-    | EXPOP_HEX_NUMBER                              { AcpiUtStrtoul64 (PrParsertext, 16, ACPI_MAX64_BYTE_WIDTH, &$$);}
+    | EXPOP_HEX_NUMBER                              { AcpiUtStrtoul64 (PrParsertext, (ACPI_STRTOUL_BASE16 | ACPI_STRTOUL_64BIT), &$$);}
     ;
 %%
 
--- a/sys/external/bsd/acpica/dist/debugger/dbexec.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/debugger/dbexec.c	Fri Nov 11 21:11:30 2016 +0000
@@ -446,44 +446,51 @@
             ACPI_UINT32_MAX, AcpiDbExecutionWalk, NULL, NULL, NULL);
         return;
     }
-    else
+
+    NameString = ACPI_ALLOCATE (strlen (Name) + 1);
+    if (!NameString)
     {
-        NameString = ACPI_ALLOCATE (strlen (Name) + 1);
-        if (!NameString)
-        {
-            return;
-        }
+        return;
+    }
 
-        memset (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO));
+    memset (&AcpiGbl_DbMethodInfo, 0, sizeof (ACPI_DB_METHOD_INFO));
+    strcpy (NameString, Name);
+    AcpiUtStrupr (NameString);
+
+    /* Subcommand to Execute all predefined names in the namespace */
 
-        strcpy (NameString, Name);
-        AcpiUtStrupr (NameString);
-        AcpiGbl_DbMethodInfo.Name = NameString;
-        AcpiGbl_DbMethodInfo.Args = Args;
-        AcpiGbl_DbMethodInfo.Types = Types;
-        AcpiGbl_DbMethodInfo.Flags = Flags;
+    if (!strncmp (NameString, "PREDEF", 6))
+    {
+        AcpiDbEvaluatePredefinedNames ();
+        ACPI_FREE (NameString);
+        return;
+    }
 
-        ReturnObj.Pointer = NULL;
-        ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
+    AcpiGbl_DbMethodInfo.Name = NameString;
+    AcpiGbl_DbMethodInfo.Args = Args;
+    AcpiGbl_DbMethodInfo.Types = Types;
+    AcpiGbl_DbMethodInfo.Flags = Flags;
 
-        Status = AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo);
-        if (ACPI_FAILURE (Status))
-        {
-            ACPI_FREE (NameString);
-            return;
-        }
+    ReturnObj.Pointer = NULL;
+    ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
 
-        /* Get the NS node, determines existence also */
+    Status = AcpiDbExecuteSetup (&AcpiGbl_DbMethodInfo);
+    if (ACPI_FAILURE (Status))
+    {
+        ACPI_FREE (NameString);
+        return;
+    }
+
+    /* Get the NS node, determines existence also */
 
-        Status = AcpiGetHandle (NULL, AcpiGbl_DbMethodInfo.Pathname,
-            &AcpiGbl_DbMethodInfo.Method);
-        if (ACPI_SUCCESS (Status))
-        {
-            Status = AcpiDbExecuteMethod (&AcpiGbl_DbMethodInfo,
-                &ReturnObj);
-        }
-        ACPI_FREE (NameString);
+    Status = AcpiGetHandle (NULL, AcpiGbl_DbMethodInfo.Pathname,
+        &AcpiGbl_DbMethodInfo.Method);
+    if (ACPI_SUCCESS (Status))
+    {
+        Status = AcpiDbExecuteMethod (&AcpiGbl_DbMethodInfo,
+            &ReturnObj);
     }
+    ACPI_FREE (NameString);
 
     /*
      * Allow any handlers in separate threads to complete.
--- a/sys/external/bsd/acpica/dist/debugger/dbinput.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/debugger/dbinput.c	Fri Nov 11 21:11:30 2016 +0000
@@ -298,6 +298,7 @@
     {1, "     \"Ascii String\"",               "String method argument\n"},
     {1, "     (Hex Byte List)",                "Buffer method argument\n"},
     {1, "     [Package Element List]",         "Package method argument\n"},
+    {5, "  Execute predefined",                "Execute all predefined (public) methods\n"},
     {1, "  Go",                                "Allow method to run to completion\n"},
     {1, "  Information",                       "Display info about the current method\n"},
     {1, "  Into",                              "Step into (not over) a method call\n"},
--- a/sys/external/bsd/acpica/dist/debugger/dbmethod.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/debugger/dbmethod.c	Fri Nov 11 21:11:30 2016 +0000
@@ -53,6 +53,15 @@
 #define _COMPONENT          ACPI_CA_DEBUGGER
         ACPI_MODULE_NAME    ("dbmethod")
 
+/* Local prototypes */
+
+static ACPI_STATUS
+AcpiDbWalkForExecute (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue);
+
 
 /*******************************************************************************
  *
@@ -414,3 +423,139 @@
     AcpiUtReleaseOwnerId (&ObjDesc->Method.OwnerId);
     return (AE_OK);
 }
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbWalkForExecute
+ *
+ * PARAMETERS:  Callback from WalkNamespace
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Batch execution module. Currently only executes predefined
+ *              ACPI names.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+AcpiDbWalkForExecute (
+    ACPI_HANDLE             ObjHandle,
+    UINT32                  NestingLevel,
+    void                    *Context,
+    void                    **ReturnValue)
+{
+    ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
+    ACPI_DB_EXECUTE_WALK    *Info = (ACPI_DB_EXECUTE_WALK *) Context;
+    ACPI_BUFFER             ReturnObj;
+    ACPI_STATUS             Status;
+    char                    *Pathname;
+    UINT32                  i;
+    ACPI_DEVICE_INFO        *ObjInfo;
+    ACPI_OBJECT_LIST        ParamObjects;
+    ACPI_OBJECT             Params[ACPI_METHOD_NUM_ARGS];
+    const ACPI_PREDEFINED_INFO *Predefined;
+
+
+    Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii);
+    if (!Predefined)
+    {
+        return (AE_OK);
+    }
+
+    if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
+    {
+        return (AE_OK);
+    }
+
+    Pathname = AcpiNsGetExternalPathname (Node);
+    if (!Pathname)
+    {
+        return (AE_OK);
+    }
+
+    /* Get the object info for number of method parameters */
+
+    Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo);
+    if (ACPI_FAILURE (Status))
+    {
+        return (Status);
+    }
+
+    ParamObjects.Pointer = NULL;
+    ParamObjects.Count   = 0;
+
+    if (ObjInfo->Type == ACPI_TYPE_METHOD)
+    {
+        /* Setup default parameters */
+
+        for (i = 0; i < ObjInfo->ParamCount; i++)
+        {
+            Params[i].Type           = ACPI_TYPE_INTEGER;
+            Params[i].Integer.Value  = 1;
+        }
+
+        ParamObjects.Pointer     = Params;
+        ParamObjects.Count       = ObjInfo->ParamCount;
+    }
+
+    ACPI_FREE (ObjInfo);
+    ReturnObj.Pointer = NULL;
+    ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
+
+    /* Do the actual method execution */
+
+    AcpiGbl_MethodExecuting = TRUE;
+
+    Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj);
+
+    AcpiOsPrintf ("%-32s returned %s\n", Pathname, AcpiFormatException (Status));
+    AcpiGbl_MethodExecuting = FALSE;
+    ACPI_FREE (Pathname);
+
+    /* Ignore status from method execution */
+
+    Status = AE_OK;
+
+    /* Update count, check if we have executed enough methods */
+
+    Info->Count++;
+    if (Info->Count >= Info->MaxCount)
+    {
+        Status = AE_CTRL_TERMINATE;
+    }
+
+    return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDbEvaluatePredefinedNames
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Namespace batch execution. Execute predefined names in the
+ *              namespace, up to the max count, if specified.
+ *
+ ******************************************************************************/
+
+void
+AcpiDbEvaluatePredefinedNames (
+    void)
+{
+    ACPI_DB_EXECUTE_WALK    Info;
+
+
+    Info.Count = 0;
+    Info.MaxCount = ACPI_UINT32_MAX;
+
+    /* Search all nodes in namespace */
+
+    (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
+                AcpiDbWalkForExecute, NULL, (void *) &Info, NULL);
+
+    AcpiOsPrintf ("Evaluated %u predefined names in the namespace\n", Info.Count);
+}
--- a/sys/external/bsd/acpica/dist/disassembler/dmbuffer.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/disassembler/dmbuffer.c	Fri Nov 11 21:11:30 2016 +0000
@@ -529,7 +529,8 @@
  *
  * PARAMETERS:  Op                  - Buffer Object to be examined
  *
- * RETURN:      TRUE if buffer contains a ASCII string, FALSE otherwise
+ * RETURN:      TRUE if buffer appears to contain data produced via the
+ *              ToPLD macro, FALSE otherwise
  *
  * DESCRIPTION: Determine if a buffer Op contains a _PLD structure
  *
@@ -541,12 +542,60 @@
 {
     ACPI_NAMESPACE_NODE     *Node;
     ACPI_PARSE_OBJECT       *SizeOp;
+    ACPI_PARSE_OBJECT       *ByteListOp;
     ACPI_PARSE_OBJECT       *ParentOp;
+    UINT64                  BufferSize;
+    UINT64                  InitializerSize;
 
 
-    /* Buffer size is the buffer argument */
+    /*
+     * Get the BufferSize argument - Buffer(BufferSize)
+     * If the buffer was generated by the ToPld macro, it must
+     * be a BYTE constant.
+     */
+    SizeOp = Op->Common.Value.Arg;
+    if (SizeOp->Common.AmlOpcode != AML_BYTE_OP)
+    {
+        return (FALSE);
+    }
+
+    /* Check the declared BufferSize, two possibilities */
+
+    BufferSize = SizeOp->Common.Value.Integer;
+    if ((BufferSize != ACPI_PLD_REV1_BUFFER_SIZE) &&
+        (BufferSize != ACPI_PLD_REV2_BUFFER_SIZE))
+    {
+        return (FALSE);
+    }
 
-    SizeOp = Op->Common.Value.Arg;
+    /*
+     * Check the initializer list length. This is the actual
+     * number of bytes in the buffer as counted by the AML parser.
+     * The declared BufferSize can be larger than the actual length.
+     * However, for the ToPLD macro, the BufferSize will be the same
+     * as the initializer list length.
+     */
+    ByteListOp = SizeOp->Common.Next;
+    if (!ByteListOp)
+    {
+        return (FALSE); /* Zero-length buffer case */
+    }
+
+    InitializerSize = ByteListOp->Common.Value.Integer;
+    if ((InitializerSize != ACPI_PLD_REV1_BUFFER_SIZE) &&
+        (InitializerSize != ACPI_PLD_REV2_BUFFER_SIZE))
+    {
+        return (FALSE);
+    }
+
+    /* Final size check */
+
+    if (BufferSize != InitializerSize)
+    {
+        return (FALSE);
+    }
+
+    /* Now examine the buffer parent */
 
     ParentOp = Op->Common.Parent;
     if (!ParentOp)
@@ -571,8 +620,17 @@
         return (FALSE);
     }
 
-    /* Check for proper form: Name(_PLD, Package() {Buffer() {}}) */
-
+    /*
+     * Check for proper form: Name(_PLD, Package() {ToPLD()})
+     *
+     * Note: All other forms such as
+     *      Return (Package() {ToPLD()})
+     *      Local0 = ToPLD()
+     * etc. are not converted back to the ToPLD macro, because
+     * there is really no deterministic way to disassemble the buffer
+     * back to the ToPLD macro, other than trying to find the "_PLD"
+     * name
+     */
     if (ParentOp->Common.AmlOpcode == AML_PACKAGE_OP)
     {
         ParentOp = ParentOp->Common.Parent;
--- a/sys/external/bsd/acpica/dist/disassembler/dmcstyle.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/disassembler/dmcstyle.c	Fri Nov 11 21:11:30 2016 +0000
@@ -98,6 +98,9 @@
     ACPI_PARSE_OBJECT       *Child1;
     ACPI_PARSE_OBJECT       *Child2;
     ACPI_PARSE_OBJECT       *Target;
+    ACPI_PARSE_OBJECT       *GrandChild1;
+    ACPI_PARSE_OBJECT       *GrandChild2;
+    ACPI_PARSE_OBJECT       *GrandTarget = NULL;
 
 
     /* Exit immediately if ASL+ not enabled */
@@ -107,6 +110,14 @@
         return (FALSE);
     }
 
+    /* Check for a non-ASL+ statement, propagate the flag */
+
+    if (Op->Common.Parent->Common.DisasmFlags & ACPI_PARSEOP_LEGACY_ASL_ONLY)
+    {
+        Op->Common.DisasmFlags |= ACPI_PARSEOP_LEGACY_ASL_ONLY;
+        return (FALSE);
+    }
+
     /* Get the first operand */
 
     Child1 = AcpiPsGetArg (Op, 0);
@@ -323,6 +334,7 @@
             if (AcpiDmIsValidTarget (Target))
             {
                 Child1->Common.OperatorSymbol = NULL;
+                Op->Common.DisasmFlags |= ACPI_PARSEOP_LEGACY_ASL_ONLY;
                 return (FALSE);
             }
 
@@ -339,6 +351,13 @@
 
         if (!AcpiDmIsValidTarget (Target))
         {
+            if (Op->Common.Parent->Common.AmlOpcode == AML_STORE_OP)
+            {
+                Op->Common.DisasmFlags = 0;
+                Child1->Common.OperatorSymbol = NULL;
+                return (FALSE);
+            }
+
             /* Not a valid target (placeholder only, from parser) */
             break;
         }
@@ -478,6 +497,69 @@
         /*
          * Target is the 2nd operand.
          * We know the target is valid, it is not optional.
+         *
+         * The following block implements "Ignore conversion if a store
+         * is followed by a math/bit operator that has no target". Used
+         * only for the ASL test suite.
+         */
+        if (!AcpiGbl_DoDisassemblerOptimizations)
+        {
+            switch (Child1->Common.AmlOpcode)
+            {
+            /* This operator has two operands and two targets */
+
+            case AML_DIVIDE_OP:
+
+                GrandChild1 = Child1->Common.Value.Arg;
+                GrandChild2 = GrandChild1->Common.Next;
+                GrandTarget = GrandChild2->Common.Next;
+
+                if (GrandTarget && !AcpiDmIsValidTarget (GrandTarget))
+                {
+                    Op->Common.DisasmFlags |= ACPI_PARSEOP_LEGACY_ASL_ONLY;
+                    return (FALSE);
+                }
+                GrandTarget = GrandTarget->Common.Next;
+                break;
+
+            case AML_ADD_OP:
+            case AML_SUBTRACT_OP:
+            case AML_MULTIPLY_OP:
+            case AML_MOD_OP:
+            case AML_SHIFT_LEFT_OP:
+            case AML_SHIFT_RIGHT_OP:
+            case AML_BIT_AND_OP:
+            case AML_BIT_OR_OP:
+            case AML_BIT_XOR_OP:
+            case AML_INDEX_OP:
+
+                /* These operators have two operands and a target */
+
+                GrandChild1 = Child1->Common.Value.Arg;
+                GrandChild2 = GrandChild1->Common.Next;
+                GrandTarget = GrandChild2->Common.Next;
+                break;
+
+            case AML_BIT_NOT_OP:
+
+                /* This operator has one operand and a target */
+
+                GrandChild1 = Child1->Common.Value.Arg;
+                GrandTarget = GrandChild1->Common.Next;
+                break;
+
+            default:
+                break;
+            }
+
+            if (GrandTarget && !AcpiDmIsValidTarget (GrandTarget))
+            {
+                Op->Common.DisasmFlags |= ACPI_PARSEOP_LEGACY_ASL_ONLY;
+                return (FALSE);
+            }
+        }
+
+        /*
          * In the parse tree, simply swap the target with the
          * source so that the target is processed first.
          */
@@ -563,6 +645,7 @@
 {
     BOOLEAN                 IsCStyleOp = FALSE;
 
+
     /* Always emit paren if ASL+ disassembly disabled */
 
     if (!AcpiGbl_CstyleDisassembly)
@@ -571,6 +654,14 @@
         return;
     }
 
+    /* Check for a non-ASL+ statement */
+
+    if (Op->Common.DisasmFlags & ACPI_PARSEOP_LEGACY_ASL_ONLY)
+    {
+        AcpiOsPrintf (")");
+        return;
+    }
+
     /* Check if we need to add an additional closing paren */
 
     switch (Op->Common.AmlOpcode)
--- a/sys/external/bsd/acpica/dist/disassembler/dmresrcl.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/disassembler/dmresrcl.c	Fri Nov 11 21:11:30 2016 +0000
@@ -443,16 +443,17 @@
         UINT8               SpecificFlags)
 {
 
+    /* _TTP */
+
     AcpiOsPrintf (", %s",
         AcpiGbl_TtpDecode [ACPI_EXTRACT_1BIT_FLAG (SpecificFlags, 4)]);
 
-    /* TRS is only used if TTP is TypeTranslation */
-
-    if (SpecificFlags & 0x10)
-    {
-        AcpiOsPrintf (", %s",
-            AcpiGbl_TrsDecode [ACPI_EXTRACT_1BIT_FLAG (SpecificFlags, 5)]);
-    }
+    /*
+     * TRS is only used if TTP is TypeTranslation. However, the disassembler
+     * always emits exactly what is in the AML.
+     */
+    AcpiOsPrintf (", %s",
+        AcpiGbl_TrsDecode [ACPI_EXTRACT_1BIT_FLAG (SpecificFlags, 5)]);
 }
 
 
--- a/sys/external/bsd/acpica/dist/events/evrgnini.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/events/evrgnini.c	Fri Nov 11 21:11:30 2016 +0000
@@ -618,7 +618,8 @@
                  *
                  * See AcpiNsExecModuleCode
                  */
-                if (ObjDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL)
+                if (!AcpiGbl_ParseTableAsTermList &&
+                    ObjDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL)
                 {
                     HandlerObj = ObjDesc->Method.Dispatch.Handler;
                 }
--- a/sys/external/bsd/acpica/dist/executer/exconfig.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/executer/exconfig.c	Fri Nov 11 21:11:30 2016 +0000
@@ -59,7 +59,6 @@
 static ACPI_STATUS
 AcpiExAddTable (
     UINT32                  TableIndex,
-    ACPI_NAMESPACE_NODE     *ParentNode,
     ACPI_OPERAND_OBJECT     **DdbHandle);
 
 static ACPI_STATUS
@@ -87,12 +86,9 @@
 static ACPI_STATUS
 AcpiExAddTable (
     UINT32                  TableIndex,
-    ACPI_NAMESPACE_NODE     *ParentNode,
     ACPI_OPERAND_OBJECT     **DdbHandle)
 {
     ACPI_OPERAND_OBJECT     *ObjDesc;
-    ACPI_STATUS             Status;
-    ACPI_OWNER_ID           OwnerId;
 
 
     ACPI_FUNCTION_TRACE (ExAddTable);
@@ -110,42 +106,8 @@
 
     ObjDesc->Common.Flags |= AOPOBJ_DATA_VALID;
     ObjDesc->Reference.Class = ACPI_REFCLASS_TABLE;
+    ObjDesc->Reference.Value = TableIndex;
     *DdbHandle = ObjDesc;
-
-    /* Install the new table into the local data structures */
-
-    ObjDesc->Reference.Value = TableIndex;
-
-    /* Add the table to the namespace */
-
-    Status = AcpiNsLoadTable (TableIndex, ParentNode);
-    if (ACPI_FAILURE (Status))
-    {
-        AcpiUtRemoveReference (ObjDesc);
-        *DdbHandle = NULL;
-        return_ACPI_STATUS (Status);
-    }
-
-    /* Execute any module-level code that was found in the table */
-
-    AcpiExExitInterpreter ();
-    if (AcpiGbl_GroupModuleLevelCode)
-    {
-        AcpiNsExecModuleCodeList ();
-    }
-    AcpiExEnterInterpreter ();
-
-    /*
-     * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is
-     * responsible for discovering any new wake GPEs by running _PRW methods
-     * that may have been loaded by this table.
-     */
-    Status = AcpiTbGetOwnerId (TableIndex, &OwnerId);
-    if (ACPI_SUCCESS (Status))
-    {
-        AcpiEvUpdateGpes (OwnerId);
-    }
-
     return_ACPI_STATUS (AE_OK);
 }
 
@@ -174,7 +136,6 @@
     ACPI_NAMESPACE_NODE     *StartNode;
     ACPI_NAMESPACE_NODE     *ParameterNode = NULL;
     ACPI_OPERAND_OBJECT     *DdbHandle;
-    ACPI_TABLE_HEADER       *Table;
     UINT32                  TableIndex;
 
 
@@ -183,10 +144,12 @@
 
     /* Find the ACPI table in the RSDT/XSDT */
 
+    AcpiExExitInterpreter ();
     Status = AcpiTbFindTable (
         Operand[0]->String.Pointer,
         Operand[1]->String.Pointer,
         Operand[2]->String.Pointer, &TableIndex);
+    AcpiExEnterInterpreter ();
     if (ACPI_FAILURE (Status))
     {
         if (Status != AE_NOT_FOUND)
@@ -219,8 +182,9 @@
          * Find the node referenced by the RootPathString. This is the
          * location within the namespace where the table will be loaded.
          */
-        Status = AcpiNsGetNode (StartNode, Operand[3]->String.Pointer,
-            ACPI_NS_SEARCH_PARENT, &ParentNode);
+        Status = AcpiNsGetNodeUnlocked (StartNode,
+            Operand[3]->String.Pointer, ACPI_NS_SEARCH_PARENT,
+            &ParentNode);
         if (ACPI_FAILURE (Status))
         {
             return_ACPI_STATUS (Status);
@@ -243,8 +207,9 @@
 
         /* Find the node referenced by the ParameterPathString */
 
-        Status = AcpiNsGetNode (StartNode, Operand[4]->String.Pointer,
-            ACPI_NS_SEARCH_PARENT, &ParameterNode);
+        Status = AcpiNsGetNodeUnlocked (StartNode,
+            Operand[4]->String.Pointer, ACPI_NS_SEARCH_PARENT,
+            &ParameterNode);
         if (ACPI_FAILURE (Status))
         {
             return_ACPI_STATUS (Status);
@@ -253,7 +218,16 @@
 
     /* Load the table into the namespace */
 
-    Status = AcpiExAddTable (TableIndex, ParentNode, &DdbHandle);
+    ACPI_INFO (("Dynamic OEM Table Load:"));
+    AcpiExExitInterpreter ();
+    Status = AcpiTbLoadTable (TableIndex, ParentNode);
+    AcpiExEnterInterpreter ();
+    if (ACPI_FAILURE (Status))
+    {
+	return_ACPI_STATUS (Status);
+    }
+
+    Status = AcpiExAddTable (TableIndex, &DdbHandle);
     if (ACPI_FAILURE (Status))
     {
         return_ACPI_STATUS (Status);
@@ -276,21 +250,6 @@
         }
     }
 
-    Status = AcpiGetTableByIndex (TableIndex, &Table);
-    if (ACPI_SUCCESS (Status))
-    {
-        ACPI_INFO (("Dynamic OEM Table Load:"));
-        AcpiTbPrintTableHeader (0, Table);
-    }
-
-    /* Invoke table handler if present */
-
-    if (AcpiGbl_TableHandler)
-    {
-        (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table,
-            AcpiGbl_TableHandlerContext);
-    }
-
     *ReturnDesc = DdbHandle;
     return_ACPI_STATUS (Status);
 }
@@ -520,13 +479,10 @@
     /* Install the new table into the local data structures */
 
     ACPI_INFO (("Dynamic OEM Table Load:"));
-    (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
-
-    Status = AcpiTbInstallStandardTable (ACPI_PTR_TO_PHYSADDR (Table),
-        ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, TRUE, TRUE,
-        &TableIndex);
-
-    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
+    AcpiExExitInterpreter ();
+    Status = AcpiTbInstallAndLoadTable (Table, ACPI_PTR_TO_PHYSADDR (Table),
+        ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, TRUE, &TableIndex);
+    AcpiExEnterInterpreter ();
     if (ACPI_FAILURE (Status))
     {
         /* Delete allocated table buffer */
@@ -536,24 +492,13 @@
     }
 
     /*
-     * Note: Now table is "INSTALLED", it must be validated before
-     * loading.
-     */
-    Status = AcpiTbValidateTable (
-        &AcpiGbl_RootTableList.Tables[TableIndex]);
-    if (ACPI_FAILURE (Status))
-    {
-        return_ACPI_STATUS (Status);
-    }
-
-    /*
      * Add the table to the namespace.
      *
      * Note: Load the table objects relative to the root of the namespace.
      * This appears to go against the ACPI specification, but we do it for
      * compatibility with other ACPI implementations.
      */
-    Status = AcpiExAddTable (TableIndex, AcpiGbl_RootNode, &DdbHandle);
+    Status = AcpiExAddTable (TableIndex, &DdbHandle);
     if (ACPI_FAILURE (Status))
     {
         /* On error, TablePtr was deallocated above */
@@ -577,15 +522,6 @@
     /* Remove the reference by added by AcpiExStore above */
 
     AcpiUtRemoveReference (DdbHandle);
-
-    /* Invoke table handler if present */
-
-    if (AcpiGbl_TableHandler)
-    {
-        (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table,
-            AcpiGbl_TableHandlerContext);
-    }
-
     return_ACPI_STATUS (Status);
 }
 
@@ -645,11 +581,18 @@
 
     TableIndex = TableDesc->Reference.Value;
 
+    /*
+     * Release the interpreter lock so that the table lock won't have
+     * strict order requirement against it.
+     */
+    AcpiExExitInterpreter ();
+
     /* Ensure the table is still loaded */
 
     if (!AcpiTbIsTableLoaded (TableIndex))
     {
-        return_ACPI_STATUS (AE_NOT_EXIST);
+        Status = AE_NOT_EXIST;
+        goto LockAndExit;
     }
 
     /* Invoke table handler if present */
@@ -669,16 +612,25 @@
     Status = AcpiTbDeleteNamespaceByOwner (TableIndex);
     if (ACPI_FAILURE (Status))
     {
-        return_ACPI_STATUS (Status);
+        goto LockAndExit;
     }
 
     (void) AcpiTbReleaseOwnerId (TableIndex);
     AcpiTbSetTableLoadedFlag (TableIndex, FALSE);
 
+LockAndExit:
+
+    /* Re-acquire the interpreter lock */
+
+    AcpiExEnterInterpreter ();
+
     /*
      * Invalidate the handle. We do this because the handle may be stored
      * in a named object and may not be actually deleted until much later.
      */
-    DdbHandle->Common.Flags &= ~AOPOBJ_DATA_VALID;
-    return_ACPI_STATUS (AE_OK);
+    if (ACPI_SUCCESS (Status))
+    {
+        DdbHandle->Common.Flags &= ~AOPOBJ_DATA_VALID;
+    }
+    return_ACPI_STATUS (Status);
 }
--- a/sys/external/bsd/acpica/dist/include/acapps.h	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/include/acapps.h	Fri Nov 11 21:11:30 2016 +0000
@@ -44,11 +44,9 @@
 #ifndef _ACAPPS
 #define _ACAPPS
 
-#include <stdio.h>
-
-#ifdef _MSC_VER                 /* disable some level-4 warnings */
-#pragma warning(disable:4100)   /* warning C4100: unreferenced formal parameter */
-#endif
+#ifdef ACPI_USE_STANDARD_HEADERS
+#include <sys/stat.h>
+#endif /* ACPI_USE_STANDARD_HEADERS */
 
 /* Common info for tool signons */
 
@@ -90,13 +88,13 @@
 /* Macros for usage messages */
 
 #define ACPI_USAGE_HEADER(Usage) \
-    AcpiOsPrintf ("Usage: %s\nOptions:\n", Usage);
+    printf ("Usage: %s\nOptions:\n", Usage);
 
 #define ACPI_USAGE_TEXT(Description) \
-    AcpiOsPrintf (Description);
+    printf (Description);
 
 #define ACPI_OPTION(Name, Description) \
-    AcpiOsPrintf ("  %-20s%s\n", Name, Description);
+    printf ("  %-20s%s\n", Name, Description);
 
 
 /* Check for unexpected exceptions */
--- a/sys/external/bsd/acpica/dist/include/acdebug.h	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/include/acdebug.h	Fri Nov 11 21:11:30 2016 +0000
@@ -233,8 +233,8 @@
     ACPI_PARSE_OBJECT       *Op);
 
 void
-AcpiDbBatchExecute (
-    char                    *CountArg);
+AcpiDbEvaluatePredefinedNames (
+    void);
 
 
 /*
--- a/sys/external/bsd/acpica/dist/include/acdisasm.h	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/include/acdisasm.h	Fri Nov 11 21:11:30 2016 +0000
@@ -109,6 +109,7 @@
     ACPI_DMT_UINT64,
     ACPI_DMT_BUF7,
     ACPI_DMT_BUF10,
+    ACPI_DMT_BUF12,
     ACPI_DMT_BUF16,
     ACPI_DMT_BUF128,
     ACPI_DMT_SIG,
@@ -279,8 +280,8 @@
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoErst0[];
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoFacs[];
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoFadt1[];
-extern ACPI_DMTABLE_INFO        AcpiDmTableInfoFadt2[];
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoFadt3[];
+extern ACPI_DMTABLE_INFO        AcpiDmTableInfoFadt4[];
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoFadt5[];
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoFadt6[];
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoFpdt[];
@@ -386,6 +387,7 @@
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoPcct0[];
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoPcct1[];
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoPcct2[];
+extern ACPI_DMTABLE_INFO        AcpiDmTableInfoRasf[];
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoRsdp1[];
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoRsdp2[];
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoS3pt[];
@@ -423,6 +425,9 @@
 
 extern ACPI_DMTABLE_INFO        AcpiDmTableInfoGeneric[][2];
 
+extern ACPI_DMTABLE_INFO        *FadtRevisionInfo [ACPI_FADT_MAX_VERSION + 1];
+
+
 /*
  * dmtable and ahtable
  */
--- a/sys/external/bsd/acpica/dist/include/acglobal.h	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/include/acglobal.h	Fri Nov 11 21:11:30 2016 +0000
@@ -245,10 +245,6 @@
 
 ACPI_GLOBAL (ACPI_THREAD_STATE *,       AcpiGbl_CurrentWalkList);
 
-/* Maximum number of While() loop iterations before forced abort */
-
-ACPI_GLOBAL (UINT16,                    AcpiGbl_MaxLoopIterations);
-
 /* Control method single step flag */
 
 ACPI_GLOBAL (UINT8,                     AcpiGbl_CmSingleStep);
@@ -322,6 +318,7 @@
 ACPI_INIT_GLOBAL (BOOLEAN,              AcpiGbl_ForceAmlDisassembly, FALSE);
 ACPI_INIT_GLOBAL (BOOLEAN,              AcpiGbl_DmOpt_Verbose, TRUE);
 ACPI_INIT_GLOBAL (BOOLEAN,              AcpiGbl_DmEmitExternalOpcodes, FALSE);
+ACPI_INIT_GLOBAL (BOOLEAN,              AcpiGbl_DoDisassemblerOptimizations, TRUE);
 
 ACPI_GLOBAL (BOOLEAN,                   AcpiGbl_DmOpt_Disasm);
 ACPI_GLOBAL (BOOLEAN,                   AcpiGbl_DmOpt_Listing);
@@ -392,6 +389,7 @@
 
 ACPI_INIT_GLOBAL (ACPI_FILE,            AcpiGbl_DebugFile, NULL);
 ACPI_INIT_GLOBAL (ACPI_FILE,            AcpiGbl_OutputFile, NULL);
+ACPI_INIT_GLOBAL (BOOLEAN,              AcpiGbl_DebugTimeout, FALSE);
 
 /* Print buffer */
 
--- a/sys/external/bsd/acpica/dist/include/aclocal.h	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/include/aclocal.h	Fri Nov 11 21:11:30 2016 +0000
@@ -549,11 +549,12 @@
  */
 typedef struct acpi_gpe_event_info
 {
-    union acpi_gpe_dispatch_info    Dispatch;       /* Either Method, Handler, or NotifyList */
-    struct acpi_gpe_register_info   *RegisterInfo;  /* Backpointer to register info */
-    UINT8                           Flags;          /* Misc info about this GPE */
-    UINT8                           GpeNumber;      /* This GPE */
-    UINT8                           RuntimeCount;   /* References to a run GPE */
+    union acpi_gpe_dispatch_info    Dispatch;           /* Either Method, Handler, or NotifyList */
+    struct acpi_gpe_register_info   *RegisterInfo;      /* Backpointer to register info */
+    UINT8                           Flags;              /* Misc info about this GPE */
+    UINT8                           GpeNumber;          /* This GPE */
+    UINT8                           RuntimeCount;       /* References to a run GPE */
+    BOOLEAN                         DisableForDispatch; /* Masked during dispatching */
 
 } ACPI_GPE_EVENT_INFO;
 
@@ -566,6 +567,7 @@
     UINT16                          BaseGpeNumber;  /* Base GPE number for this register */
     UINT8                           EnableForWake;  /* GPEs to keep enabled when sleeping */
     UINT8                           EnableForRun;   /* GPEs to keep enabled when running */
+    UINT8                           MaskForRun;     /* GPEs to keep masked when running */
     UINT8                           EnableMask;     /* Current mask of enabled GPEs */
 
 } ACPI_GPE_REGISTER_INFO;
@@ -914,7 +916,7 @@
     ACPI_PARSE_VALUE                Value;          /* Value or args associated with the opcode */\
     UINT8                           ArgListLength;  /* Number of elements in the arg list */\
     ACPI_DISASM_ONLY_MEMBERS (\
-    UINT8                           DisasmFlags;    /* Used during AML disassembly */\
+    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) */
@@ -1034,14 +1036,15 @@
 
 /* Parse object DisasmFlags */
 
-#define ACPI_PARSEOP_IGNORE                 0x01
-#define ACPI_PARSEOP_PARAMETER_LIST         0x02
-#define ACPI_PARSEOP_EMPTY_TERMLIST         0x04
-#define ACPI_PARSEOP_PREDEFINED_CHECKED     0x08
-#define ACPI_PARSEOP_CLOSING_PAREN          0x10
-#define ACPI_PARSEOP_COMPOUND_ASSIGNMENT    0x20
-#define ACPI_PARSEOP_ASSIGNMENT             0x40
-#define ACPI_PARSEOP_ELSEIF                 0x80
+#define ACPI_PARSEOP_IGNORE                 0x0001
+#define ACPI_PARSEOP_PARAMETER_LIST         0x0002
+#define ACPI_PARSEOP_EMPTY_TERMLIST         0x0004
+#define ACPI_PARSEOP_PREDEFINED_CHECKED     0x0008
+#define ACPI_PARSEOP_CLOSING_PAREN          0x0010
+#define ACPI_PARSEOP_COMPOUND_ASSIGNMENT    0x0020
+#define ACPI_PARSEOP_ASSIGNMENT             0x0040
+#define ACPI_PARSEOP_ELSEIF                 0x0080
+#define ACPI_PARSEOP_LEGACY_ASL_ONLY        0x0100
 
 
 /*****************************************************************************
--- a/sys/external/bsd/acpica/dist/include/acnamesp.h	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/include/acnamesp.h	Fri Nov 11 21:11:30 2016 +0000
@@ -144,6 +144,11 @@
     ACPI_NAMESPACE_NODE     *StartNode);
 
 ACPI_STATUS
+AcpiNsExecuteTable (
+    UINT32                  TableIndex,
+    ACPI_NAMESPACE_NODE     *StartNode);
+
+ACPI_STATUS
 AcpiNsOneCompleteParse (
     UINT32                  PassNumber,
     UINT32                  TableIndex,
@@ -391,6 +396,13 @@
     char                    *SearchFor);
 
 ACPI_STATUS
+AcpiNsGetNodeUnlocked (
+    ACPI_NAMESPACE_NODE     *PrefixNode,
+    const char              *ExternalPathname,
+    UINT32                  Flags,
+    ACPI_NAMESPACE_NODE     **OutNode);
+
+ACPI_STATUS
 AcpiNsGetNode (
     ACPI_NAMESPACE_NODE     *PrefixNode,
     const char              *ExternalPathname,
--- a/sys/external/bsd/acpica/dist/include/acpiosxf.h	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/include/acpiosxf.h	Fri Nov 11 21:11:30 2016 +0000
@@ -492,6 +492,15 @@
     UINT32                  *BytesRead);
 #endif
 
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTracePoint
+void
+AcpiOsTracePoint (
+    ACPI_TRACE_EVENT_TYPE   Type,
+    BOOLEAN                 Begin,
+    UINT8                   *Aml,
+    char                    *Pathname);
+#endif
+
 
 /*
  * Obtain ACPI table(s)
@@ -552,62 +561,4 @@
 #endif
 
 
-/*
- * File I/O and related support
- */
-#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsOpenFile
-ACPI_FILE
-AcpiOsOpenFile (
-    const char              *Path,
-    UINT8                   Modes);
-#endif
-
-#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsCloseFile
-void
-AcpiOsCloseFile (
-    ACPI_FILE               File);
-#endif
-
-#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadFile
-int
-AcpiOsReadFile (
-    ACPI_FILE               File,
-    void                    *Buffer,
-    ACPI_SIZE               Size,
-    ACPI_SIZE               Count);
-#endif
-
-#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWriteFile
-int
-AcpiOsWriteFile (
-    ACPI_FILE               File,
-    void                    *Buffer,
-    ACPI_SIZE               Size,
-    ACPI_SIZE               Count);
-#endif
-
-#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetFileOffset
-long
-AcpiOsGetFileOffset (
-    ACPI_FILE               File);
-#endif
-
-#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsSetFileOffset
-ACPI_STATUS
-AcpiOsSetFileOffset (
-    ACPI_FILE               File,
-    long                    Offset,
-    UINT8                   From);
-#endif
-
-#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTracePoint
-void
-AcpiOsTracePoint (
-    ACPI_TRACE_EVENT_TYPE   Type,
-    BOOLEAN                 Begin,
-    UINT8                   *Aml,
-    char                    *Pathname);
-#endif
-
-
 #endif /* __ACPIOSXF_H__ */
--- a/sys/external/bsd/acpica/dist/include/acpixf.h	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/include/acpixf.h	Fri Nov 11 21:11:30 2016 +0000
@@ -46,7 +46,7 @@
 
 /* Current ACPICA subsystem version in YYYYMMDD format */
 
-#define ACPI_CA_VERSION                 0x20160527
+#define ACPI_CA_VERSION                 0x20160930
 
 #include "acconfig.h"
 #include "actypes.h"
@@ -197,6 +197,13 @@
 ACPI_INIT_GLOBAL (UINT8,            AcpiGbl_GroupModuleLevelCode, FALSE);
 
 /*
+ * Optionally support module level code by parsing the entire table as
+ * a TermList. Default is FALSE, do not execute entire table until some
+ * lock order issues are fixed.
+ */
+ACPI_INIT_GLOBAL (UINT8,            AcpiGbl_ParseTableAsTermList, FALSE);
+
+/*
  * Optionally use 32-bit FADT addresses if and when there is a conflict
  * (address mismatch) between the 32-bit and 64-bit versions of the
  * address. Although ACPICA adheres to the ACPI specification which
@@ -254,6 +261,13 @@
 ACPI_INIT_GLOBAL (BOOLEAN,          AcpiGbl_ReducedHardware, FALSE);
 
 /*
+ * Maximum number of While() loop iterations before forced method abort.
+ * This mechanism is intended to prevent infinite loops during interpreter
+ * execution within a host kernel.
+ */
+ACPI_INIT_GLOBAL (UINT32,           AcpiGbl_MaxLoopIterations, ACPI_MAX_LOOP_COUNT);
+
+/*
  * This mechanism is used to trace a specified AML method. The method is
  * traced each time it is executed.
  */
@@ -420,29 +434,29 @@
  * Initialization
  */
 ACPI_EXTERNAL_RETURN_STATUS (
-ACPI_STATUS
+ACPI_STATUS ACPI_INIT_FUNCTION
 AcpiInitializeTables (
     ACPI_TABLE_DESC         *InitialStorage,
     UINT32                  InitialTableCount,
     BOOLEAN                 AllowResize))
 
 ACPI_EXTERNAL_RETURN_STATUS (
-ACPI_STATUS
+ACPI_STATUS ACPI_INIT_FUNCTION
 AcpiInitializeSubsystem (
     void))
 
 ACPI_EXTERNAL_RETURN_STATUS (
-ACPI_STATUS
+ACPI_STATUS ACPI_INIT_FUNCTION
 AcpiEnableSubsystem (
     UINT32                  Flags))
 
 ACPI_EXTERNAL_RETURN_STATUS (
-ACPI_STATUS
+ACPI_STATUS ACPI_INIT_FUNCTION
 AcpiInitializeObjects (
     UINT32                  Flags))
 
 ACPI_EXTERNAL_RETURN_STATUS (
-ACPI_STATUS
+ACPI_STATUS ACPI_INIT_FUNCTION
 AcpiTerminate (
     void))
 
@@ -520,7 +534,7 @@
  * ACPI table load/unload interfaces
  */
 ACPI_EXTERNAL_RETURN_STATUS (
-ACPI_STATUS
+ACPI_STATUS ACPI_INIT_FUNCTION
 AcpiInstallTable (
     ACPI_PHYSICAL_ADDRESS   Address,
     BOOLEAN                 Physical))
@@ -536,7 +550,7 @@
     ACPI_HANDLE             Object))
 
 ACPI_EXTERNAL_RETURN_STATUS (
-ACPI_STATUS
+ACPI_STATUS ACPI_INIT_FUNCTION
 AcpiLoadTables (
     void))
 
@@ -545,12 +559,12 @@
  * ACPI table manipulation interfaces
  */
 ACPI_EXTERNAL_RETURN_STATUS (
-ACPI_STATUS
+ACPI_STATUS ACPI_INIT_FUNCTION
 AcpiReallocateRootTable (
     void))
 
 ACPI_EXTERNAL_RETURN_STATUS (
-ACPI_STATUS
+ACPI_STATUS ACPI_INIT_FUNCTION
 AcpiFindRootPointer (
     ACPI_PHYSICAL_ADDRESS   *RsdpAddress))
 
@@ -909,6 +923,13 @@
 
 ACPI_HW_DEPENDENT_RETURN_STATUS (
 ACPI_STATUS
+AcpiMaskGpe (
+    ACPI_HANDLE             GpeDevice,
+    UINT32                  GpeNumber,
+    BOOLEAN                 IsMasked))
+
+ACPI_HW_DEPENDENT_RETURN_STATUS (
+ACPI_STATUS
 AcpiMarkGpeForWake (
     ACPI_HANDLE             GpeDevice,
     UINT32                  GpeNumber))
@@ -1232,13 +1253,6 @@
     UINT8                   *Aml,
     char                    *Pathname))
 
-ACPI_APP_DEPENDENT_RETURN_VOID (
-ACPI_PRINTF_LIKE(1)
-void ACPI_INTERNAL_VAR_XFACE
-AcpiLogError (
-    const char              *Format,
-    ...))
-
 ACPI_STATUS
 AcpiInitializeDebugger (
     void);
--- a/sys/external/bsd/acpica/dist/include/actables.h	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/include/actables.h	Fri Nov 11 21:11:30 2016 +0000
@@ -178,6 +178,19 @@
 AcpiTbUninstallTable (
     ACPI_TABLE_DESC        *TableDesc);
 
+ACPI_STATUS
+AcpiTbLoadTable (
+    UINT32                  TableIndex,
+    ACPI_NAMESPACE_NODE     *ParentNode);
+
+ACPI_STATUS
+AcpiTbInstallAndLoadTable (
+    ACPI_TABLE_HEADER       *Table,
+    ACPI_PHYSICAL_ADDRESS   Address,
+    UINT8                   Flags,
+    BOOLEAN                 Override,
+    UINT32                  *TableIndex);
+
 void
 AcpiTbTerminate (
     void);
@@ -237,12 +250,6 @@
     UINT32                  *TableIndex);
 
 ACPI_STATUS
-AcpiTbInstallFixedTable (
-    ACPI_PHYSICAL_ADDRESS   Address,
-    const char              *Signature,
-    UINT32                  *TableIndex);
-
-ACPI_STATUS
 AcpiTbParseRootTable (
     ACPI_PHYSICAL_ADDRESS   RsdpAddress);
 
--- a/sys/external/bsd/acpica/dist/include/actypes.h	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/include/actypes.h	Fri Nov 11 21:11:30 2016 +0000
@@ -746,16 +746,17 @@
  * The encoding of ACPI_EVENT_STATUS is illustrated below.
  * Note that a set bit (1) indicates the property is TRUE
  * (e.g. if bit 0 is set then the event is enabled).
- * +-------------+-+-+-+-+-+
- * |   Bits 31:5 |4|3|2|1|0|
- * +-------------+-+-+-+-+-+
- *          |     | | | | |
- *          |     | | | | +- Enabled?
- *          |     | | | +--- Enabled for wake?
- *          |     | | +----- Status bit set?
- *          |     | +------- Enable bit set?
- *          |     +--------- Has a handler?
- *          +--------------- <Reserved>
+ * +-------------+-+-+-+-+-+-+
+ * |   Bits 31:6 |5|4|3|2|1|0|
+ * +-------------+-+-+-+-+-+-+
+ *          |     | | | | | |
+ *          |     | | | | | +- Enabled?
+ *          |     | | | | +--- Enabled for wake?
+ *          |     | | | +----- Status bit set?
+ *          |     | | +------- Enable bit set?
+ *          |     | +--------- Has a handler?
+ *          |     +----------- Masked?
+ *          +----------------- <Reserved>
  */
 typedef UINT32                          ACPI_EVENT_STATUS;
 
@@ -765,6 +766,7 @@
 #define ACPI_EVENT_FLAG_STATUS_SET      (ACPI_EVENT_STATUS) 0x04
 #define ACPI_EVENT_FLAG_ENABLE_SET      (ACPI_EVENT_STATUS) 0x08
 #define ACPI_EVENT_FLAG_HAS_HANDLER     (ACPI_EVENT_STATUS) 0x10
+#define ACPI_EVENT_FLAG_MASKED          (ACPI_EVENT_STATUS) 0x20
 #define ACPI_EVENT_FLAG_SET             ACPI_EVENT_FLAG_STATUS_SET
 
 /* Actions for AcpiSetGpe, AcpiGpeWakeup, AcpiHwLowSetGpe */
@@ -775,14 +777,15 @@
 
 /*
  * GPE info flags - Per GPE
- * +-------+-+-+---+
- * |  7:5  |4|3|2:0|
- * +-------+-+-+---+
- *     |    | |  |
- *     |    | |  +-- Type of dispatch:to method, handler, notify, or none
- *     |    | +----- Interrupt type: edge or level triggered
- *     |    +------- Is a Wake GPE
- *     +------------ <Reserved>
+ * +---+-+-+-+---+
+ * |7:6|5|4|3|2:0|
+ * +---+-+-+-+---+
+ *   |  | | |  |
+ *   |  | | |  +-- Type of dispatch:to method, handler, notify, or none
+ *   |  | | +----- Interrupt type: edge or level triggered
+ *   |  | +------- Is a Wake GPE
+ *   |  +--------- Is GPE masked by the software GPE masking machanism
+ *   +------------ <Reserved>
  */
 #define ACPI_GPE_DISPATCH_NONE          (UINT8) 0x00
 #define ACPI_GPE_DISPATCH_METHOD        (UINT8) 0x01
@@ -1080,13 +1083,6 @@
 } ACPI_STATISTICS;
 
 
-/* Table Event Types */
-
-#define ACPI_TABLE_EVENT_LOAD           0x0
-#define ACPI_TABLE_EVENT_UNLOAD         0x1
-#define ACPI_NUM_TABLE_EVENTS           2
-
-
 /*
  * Types specific to the OS service interfaces
  */
@@ -1159,9 +1155,14 @@
     void                            *Table,
     void                            *Context);
 
-#define ACPI_TABLE_LOAD             0x0
-#define ACPI_TABLE_UNLOAD           0x1
-#define ACPI_NUM_TABLE_EVENTS       2
+
+/* Table Event Types */
+
+#define ACPI_TABLE_EVENT_LOAD           0x0
+#define ACPI_TABLE_EVENT_UNLOAD         0x1
+#define ACPI_TABLE_EVENT_INSTALL        0x2
+#define ACPI_TABLE_EVENT_UNINSTALL      0x3
+#define ACPI_NUM_TABLE_EVENTS           4
 
 
 /* Address Spaces (For Operation Regions) */
@@ -1388,16 +1389,6 @@
 #define ACPI_OSI_WIN_10                 0x0D
 
 
-/* Definitions of file IO */
-
-#define ACPI_FILE_READING               0x01
-#define ACPI_FILE_WRITING               0x02
-#define ACPI_FILE_BINARY                0x04
-
-#define ACPI_FILE_BEGIN                 0x01
-#define ACPI_FILE_END                   0x02
-
-
 /* Definitions of getopt */
 
 #define ACPI_OPT_END                    -1
--- a/sys/external/bsd/acpica/dist/include/acutils.h	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/include/acutils.h	Fri Nov 11 21:11:30 2016 +0000
@@ -224,14 +224,16 @@
 ACPI_STATUS
 AcpiUtStrtoul64 (
     char                    *String,
-    UINT32                  Base,
-    UINT32                  MaxIntegerByteWidth,
+    UINT32                  Flags,
     UINT64                  *RetInteger);
 
-/* Values for MaxIntegerByteWidth above */
-
-#define ACPI_MAX32_BYTE_WIDTH       4
-#define ACPI_MAX64_BYTE_WIDTH       8
+/*
+ * Values for Flags above
+ * Note: LIMIT values correspond to AcpiGbl_IntegerByteWidth values (4/8)
+ */
+#define ACPI_STRTOUL_32BIT          0x04    /* 4 bytes */
+#define ACPI_STRTOUL_64BIT          0x08    /* 8 bytes */
+#define ACPI_STRTOUL_BASE16         0x10    /* Default: Base10/16 */
 
 
 /*
@@ -286,6 +288,11 @@
     UINT64                  Integer,
     UINT32                  Position);
 
+ACPI_STATUS
+AcpiUtAsciiToHexByte (
+    char                    *TwoAsciiChars,
+    UINT8                   *ReturnByte);
+
 UINT8
 AcpiUtAsciiCharToHex (
     int                     HexChar);
@@ -1068,48 +1075,6 @@
 
 
 /*
- * utprint - printf/vprintf output functions
- */
-const char *
-AcpiUtScanNumber (
-    const char              *String,
-    UINT64                  *NumberPtr);
-
-const char *
-AcpiUtPrintNumber (
-    char                    *String,
-    UINT64                  Number);
-
-int
-AcpiUtVsnprintf (
-    char                    *String,
-    ACPI_SIZE               Size,
-    const char              *Format,
-    va_list                 Args);
-
-int
-AcpiUtSnprintf (
-    char                    *String,
-    ACPI_SIZE               Size,
-    const char              *Format,
-    ...);
-
-#ifdef ACPI_APPLICATION
-int
-AcpiUtFileVprintf (
-    ACPI_FILE               File,
-    const char              *Format,
-    va_list                 Args);
-
-int
-AcpiUtFilePrintf (
-    ACPI_FILE               File,
-    const char              *Format,
-    ...);
-#endif
-
-
-/*
  * utuuid -- UUID support functions
  */
 #if (defined ACPI_ASL_COMPILER || defined ACPI_EXEC_APP || defined ACPI_HELP_APP|| defined ACPI_DISASSEMBLER)
--- a/sys/external/bsd/acpica/dist/include/platform/acgcc.h	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/include/platform/acgcc.h	Fri Nov 11 21:11:30 2016 +0000
@@ -48,7 +48,11 @@
  * Use compiler specific <stdarg.h> is a good practice for even when
  * -nostdinc is specified (i.e., ACPI_USE_STANDARD_HEADERS undefined.
  */
+#ifdef _KERNEL
+#include <sys/stdarg.h>
+#else
 #include <stdarg.h>
+#endif
 
 #define ACPI_INLINE             __inline__
 
--- a/sys/external/bsd/acpica/dist/include/platform/acnetbsd.h	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/include/platform/acnetbsd.h	Fri Nov 11 21:11:30 2016 +0000
@@ -1,7 +1,7 @@
 /******************************************************************************
  *
  * Name: acnetbsd.h - OS specific defines, etc.
- *       $Revision: 1.13 $
+ *       $Revision: 1.14 $
  *
  *****************************************************************************/
 
@@ -45,10 +45,6 @@
 #ifndef __ACNETBSD_H__
 #define __ACNETBSD_H__
 
-/* NetBSD uses GCC */
-
-#include "acgcc.h"
-
 #define ACPI_UINTPTR_T          uintptr_t
 #define ACPI_USE_LOCAL_CACHE
 #define ACPI_CAST_PTHREAD_T(x)  ((ACPI_THREAD_ID) ACPI_TO_INTEGER (x))
--- a/sys/external/bsd/acpica/dist/include/platform/acwinex.h	Fri Nov 11 21:11:03 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/******************************************************************************
- *
- * Name: acwinex.h - Extra OS specific defines, etc.
- *
- *****************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2016, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions, and the following disclaimer,
- *    without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- *    substantially similar to the "NO WARRANTY" disclaimer below
- *    ("Disclaimer") and any redistribution must be conditioned upon
- *    including a substantially similar Disclaimer requirement for further
- *    binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- *    of any contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#ifndef __ACWINEX_H__
-#define __ACWINEX_H__
-
-/* Windows uses VC */
-#ifdef _MSC_VER
-#include "acmsvcex.h"
-#endif
-
-#endif /* __ACWINEX_H__ */
--- a/sys/external/bsd/acpica/dist/os_specific/service_layers/osefitbl.c	Fri Nov 11 21:11:03 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1033 +0,0 @@
-/******************************************************************************
- *
- * Module Name: osefitbl - EFI OSL for obtaining ACPI tables
- *
- *****************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2016, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions, and the following disclaimer,
- *    without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- *    substantially similar to the "NO WARRANTY" disclaimer below
- *    ("Disclaimer") and any redistribution must be conditioned upon
- *    including a substantially similar Disclaimer requirement for further
- *    binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- *    of any contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include "acpidump.h"
-
-
-#define _COMPONENT          ACPI_OS_SERVICES
-        ACPI_MODULE_NAME    ("osefitbl")
-
-
-#ifndef PATH_MAX
-#define PATH_MAX 256
-#endif
-
-
-/* List of information about obtained ACPI tables */
-
-typedef struct osl_table_info
-{
-    struct osl_table_info   *Next;
-    UINT32                  Instance;
-    char                    Signature[ACPI_NAME_SIZE];
-
-} OSL_TABLE_INFO;
-
-/* Local prototypes */
-
-static ACPI_STATUS
-OslTableInitialize (
-    void);
-
-static ACPI_STATUS
-OslAddTableToList (
-    char                    *Signature,
-    UINT32                  Instance);
-
-static ACPI_STATUS
-OslMapTable (
-    ACPI_SIZE               Address,
-    char                    *Signature,
-    ACPI_TABLE_HEADER       **Table);
-
-static void
-OslUnmapTable (
-    ACPI_TABLE_HEADER       *Table);
-
-static ACPI_STATUS
-OslLoadRsdp (
-    void);
-
-static ACPI_STATUS
-OslListTables (
-    void);
-
-static ACPI_STATUS
-OslGetTable (
-    char                    *Signature,
-    UINT32                  Instance,
-    ACPI_TABLE_HEADER       **Table,
-    ACPI_PHYSICAL_ADDRESS   *Address);
-
-
-/* File locations */
-
-#define EFI_SYSTAB          "/sys/firmware/efi/systab"
-
-/* Initialization flags */
-
-UINT8                   Gbl_TableListInitialized = FALSE;
-
-/* Local copies of main ACPI tables */
-
-ACPI_TABLE_RSDP         Gbl_Rsdp;
-ACPI_TABLE_FADT         *Gbl_Fadt = NULL;
-ACPI_TABLE_RSDT         *Gbl_Rsdt = NULL;
-ACPI_TABLE_XSDT         *Gbl_Xsdt = NULL;
-
-/* Table addresses */
-
-ACPI_PHYSICAL_ADDRESS   Gbl_FadtAddress = 0;
-ACPI_PHYSICAL_ADDRESS   Gbl_RsdpAddress = 0;
-
-/* Revision of RSD PTR */
-
-UINT8                   Gbl_Revision = 0;
-
-OSL_TABLE_INFO          *Gbl_TableListHead = NULL;
-UINT32                  Gbl_TableCount = 0;
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiOsGetTableByAddress
- *
- * PARAMETERS:  Address         - Physical address of the ACPI table
- *              Table           - Where a pointer to the table is returned
- *
- * RETURN:      Status; Table buffer is returned if AE_OK.
- *              AE_NOT_FOUND: A valid table was not found at the address
- *
- * DESCRIPTION: Get an ACPI table via a physical memory address.
- *
- *****************************************************************************/
-
-ACPI_STATUS
-AcpiOsGetTableByAddress (
-    ACPI_PHYSICAL_ADDRESS   Address,
-    ACPI_TABLE_HEADER       **Table)
-{
-    UINT32                  TableLength;
-    ACPI_TABLE_HEADER       *MappedTable;
-    ACPI_TABLE_HEADER       *LocalTable = NULL;
-    ACPI_STATUS             Status = AE_OK;
-
-
-    /* Get main ACPI tables from memory on first invocation of this function */
-
-    Status = OslTableInitialize ();
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
-    /* Map the table and validate it */
-
-    Status = OslMapTable (Address, NULL, &MappedTable);
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
-    /* Copy table to local buffer and return it */
-
-    TableLength = ApGetTableLength (MappedTable);
-    if (TableLength == 0)
-    {
-        Status = AE_BAD_HEADER;
-        goto Exit;
-    }
-
-    LocalTable = ACPI_ALLOCATE_ZEROED (TableLength);
-    if (!LocalTable)
-    {
-        Status = AE_NO_MEMORY;
-        goto Exit;
-    }
-
-    memcpy (LocalTable, MappedTable, TableLength);
-
-Exit:
-    OslUnmapTable (MappedTable);
-    *Table = LocalTable;
-    return (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiOsGetTableByName
- *
- * PARAMETERS:  Signature       - ACPI Signature for desired table. Must be
- *                                a null terminated 4-character string.
- *              Instance        - Multiple table support for SSDT/UEFI (0...n)
- *                                Must be 0 for other tables.
- *              Table           - Where a pointer to the table is returned
- *              Address         - Where the table physical address is returned
- *
- * RETURN:      Status; Table buffer and physical address returned if AE_OK.
- *              AE_LIMIT: Instance is beyond valid limit
- *              AE_NOT_FOUND: A table with the signature was not found
- *
- * NOTE:        Assumes the input signature is uppercase.
- *
- *****************************************************************************/
-
-ACPI_STATUS
-AcpiOsGetTableByName (
-    char                    *Signature,
-    UINT32                  Instance,
-    ACPI_TABLE_HEADER       **Table,
-    ACPI_PHYSICAL_ADDRESS   *Address)
-{
-    ACPI_STATUS             Status;
-
-
-    /* Get main ACPI tables from memory on first invocation of this function */
-
-    Status = OslTableInitialize ();
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
-    /* Not a main ACPI table, attempt to extract it from the RSDT/XSDT */
-
-    if (!Gbl_DumpCustomizedTables)
-    {
-        /* Attempt to get the table from the memory */
-
-        Status = OslGetTable (Signature, Instance, Table, Address);
-    }
-    else
-    {
-        /* Attempt to get the table from the static directory */
-
-        Status = AE_SUPPORT;
-    }
-
-    return (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    OslAddTableToList
- *
- * PARAMETERS:  Signature       - Table signature
- *              Instance        - Table instance
- *
- * RETURN:      Status; Successfully added if AE_OK.
- *              AE_NO_MEMORY: Memory allocation error
- *
- * DESCRIPTION: Insert a table structure into OSL table list.
- *
- *****************************************************************************/
-
-static ACPI_STATUS
-OslAddTableToList (
-    char                    *Signature,
-    UINT32                  Instance)
-{
-    OSL_TABLE_INFO          *NewInfo;
-    OSL_TABLE_INFO          *Next;
-    UINT32                  NextInstance = 0;
-    BOOLEAN                 Found = FALSE;
-
-
-    NewInfo = ACPI_ALLOCATE_ZEROED (sizeof (OSL_TABLE_INFO));
-    if (!NewInfo)
-    {
-        return (AE_NO_MEMORY);
-    }
-
-    ACPI_MOVE_NAME (NewInfo->Signature, Signature);
-
-    if (!Gbl_TableListHead)
-    {
-        Gbl_TableListHead = NewInfo;
-    }
-    else
-    {
-        Next = Gbl_TableListHead;
-        while (1)
-        {
-            if (ACPI_COMPARE_NAME (Next->Signature, Signature))
-            {
-                if (Next->Instance == Instance)
-                {
-                    Found = TRUE;
-                }
-                if (Next->Instance >= NextInstance)
-                {
-                    NextInstance = Next->Instance + 1;
-                }
-            }
-
-            if (!Next->Next)
-            {
-                break;
-            }
-            Next = Next->Next;
-        }
-        Next->Next = NewInfo;
-    }
-
-    if (Found)
-    {
-        if (Instance)
-        {
-            AcpiLogError (
-                "%4.4s: Warning unmatched table instance %d, expected %d\n",
-                Signature, Instance, NextInstance);
-        }
-        Instance = NextInstance;
-    }
-
-    NewInfo->Instance = Instance;
-    Gbl_TableCount++;
-
-    return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiOsGetTableByIndex
- *
- * PARAMETERS:  Index           - Which table to get
- *              Table           - Where a pointer to the table is returned
- *              Instance        - Where a pointer to the table instance no. is
- *                                returned
- *              Address         - Where the table physical address is returned
- *
- * RETURN:      Status; Table buffer and physical address returned if AE_OK.
- *              AE_LIMIT: Index is beyond valid limit
- *
- * DESCRIPTION: Get an ACPI table via an index value (0 through n). Returns
- *              AE_LIMIT when an invalid index is reached. Index is not
- *              necessarily an index into the RSDT/XSDT.
- *
- *****************************************************************************/
-
-ACPI_STATUS
-AcpiOsGetTableByIndex (
-    UINT32                  Index,
-    ACPI_TABLE_HEADER       **Table,
-    UINT32                  *Instance,
-    ACPI_PHYSICAL_ADDRESS   *Address)
-{
-    OSL_TABLE_INFO          *Info;
-    ACPI_STATUS             Status;
-    UINT32                  i;
-
-
-    /* Get main ACPI tables from memory on first invocation of this function */
-
-    Status = OslTableInitialize ();
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
-    /* Validate Index */
-
-    if (Index >= Gbl_TableCount)
-    {
-        return (AE_LIMIT);
-    }
-
-    /* Point to the table list entry specified by the Index argument */
-
-    Info = Gbl_TableListHead;
-    for (i = 0; i < Index; i++)
-    {
-        Info = Info->Next;
-    }
-
-    /* Now we can just get the table via the signature */
-
-    Status = AcpiOsGetTableByName (Info->Signature, Info->Instance,
-        Table, Address);
-
-    if (ACPI_SUCCESS (Status))
-    {
-        *Instance = Info->Instance;
-    }
-    return (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    OslLoadRsdp
- *
- * PARAMETERS:  None
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Scan and load RSDP.
- *
- *****************************************************************************/
-
-static ACPI_STATUS
-OslLoadRsdp (
-    void)
-{
-    ACPI_TABLE_HEADER       *MappedTable;
-    UINT8                   *RsdpAddress;
-    ACPI_PHYSICAL_ADDRESS   RsdpBase;
-    ACPI_SIZE               RsdpSize;
-
-
-    /* Get RSDP from memory */
-
-    RsdpSize = sizeof (ACPI_TABLE_RSDP);
-    if (Gbl_RsdpBase)
-    {
-        RsdpBase = Gbl_RsdpBase;
-    }
-    else
-    {
-        RsdpBase = AcpiOsGetRootPointer ();
-    }
-
-    if (!RsdpBase)
-    {
-        RsdpBase = ACPI_HI_RSDP_WINDOW_BASE;
-        RsdpSize = ACPI_HI_RSDP_WINDOW_SIZE;
-    }
-
-    RsdpAddress = AcpiOsMapMemory (RsdpBase, RsdpSize);
-    if (!RsdpAddress)
-    {
-        return (AE_BAD_ADDRESS);
-    }
-
-    /* Search low memory for the RSDP */
-
-    MappedTable = ACPI_CAST_PTR (ACPI_TABLE_HEADER,
-        AcpiTbScanMemoryForRsdp (RsdpAddress, RsdpSize));
-    if (!MappedTable)
-    {
-        AcpiOsUnmapMemory (RsdpAddress, RsdpSize);
-        return (AE_NOT_FOUND);
-    }
-
-    Gbl_RsdpAddress = RsdpBase + (ACPI_CAST8 (MappedTable) - RsdpAddress);
-
-    memcpy (&Gbl_Rsdp, MappedTable, sizeof (ACPI_TABLE_RSDP));
-    AcpiOsUnmapMemory (RsdpAddress, RsdpSize);
-
-    return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    OslCanUseXsdt
- *
- * PARAMETERS:  None
- *
- * RETURN:      TRUE if XSDT is allowed to be used.
- *
- * DESCRIPTION: This function collects logic that can be used to determine if
- *              XSDT should be used instead of RSDT.
- *
- *****************************************************************************/
-
-static BOOLEAN
-OslCanUseXsdt (
-    void)
-{
-    if (Gbl_Revision && !AcpiGbl_DoNotUseXsdt)
-    {
-        return (TRUE);
-    }
-    else
-    {
-        return (FALSE);
-    }
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    OslTableInitialize
- *
- * PARAMETERS:  None
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Initialize ACPI table data. Get and store main ACPI tables to
- *              local variables. Main ACPI tables include RSDT, FADT, RSDT,
- *              and/or XSDT.
- *
- *****************************************************************************/
-
-static ACPI_STATUS
-OslTableInitialize (
-    void)
-{
-    ACPI_STATUS             Status;
-    ACPI_PHYSICAL_ADDRESS   Address;
-
-
-    if (Gbl_TableListInitialized)
-    {
-        return (AE_OK);
-    }
-
-    /* Get RSDP from memory */
-
-    Status = OslLoadRsdp ();
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
-    /* Get XSDT from memory */
-
-    if (Gbl_Rsdp.Revision && !Gbl_DoNotDumpXsdt)
-    {
-        if (Gbl_Xsdt)
-        {
-            ACPI_FREE (Gbl_Xsdt);
-            Gbl_Xsdt = NULL;
-        }
-
-        Gbl_Revision = 2;
-        Status = OslGetTable (ACPI_SIG_XSDT, 0,
-            ACPI_CAST_PTR (ACPI_TABLE_HEADER *, &Gbl_Xsdt), &Address);
-        if (ACPI_FAILURE (Status))
-        {
-            return (Status);
-        }
-    }
-
-    /* Get RSDT from memory */
-
-    if (Gbl_Rsdp.RsdtPhysicalAddress)
-    {
-        if (Gbl_Rsdt)
-        {
-            ACPI_FREE (Gbl_Rsdt);
-            Gbl_Rsdt = NULL;
-        }
-
-        Status = OslGetTable (ACPI_SIG_RSDT, 0,
-            ACPI_CAST_PTR (ACPI_TABLE_HEADER *, &Gbl_Rsdt), &Address);
-        if (ACPI_FAILURE (Status))
-        {
-            return (Status);
-        }
-    }
-
-    /* Get FADT from memory */
-
-    if (Gbl_Fadt)
-    {
-        ACPI_FREE (Gbl_Fadt);
-        Gbl_Fadt = NULL;
-    }
-
-    Status = OslGetTable (ACPI_SIG_FADT, 0,
-        ACPI_CAST_PTR (ACPI_TABLE_HEADER *, &Gbl_Fadt), &Gbl_FadtAddress);
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
-    if (!Gbl_DumpCustomizedTables)
-    {
-        /* Add mandatory tables to global table list first */
-
-        Status = OslAddTableToList (ACPI_RSDP_NAME, 0);
-        if (ACPI_FAILURE (Status))
-        {
-            return (Status);
-        }
-
-        Status = OslAddTableToList (ACPI_SIG_RSDT, 0);
-        if (ACPI_FAILURE (Status))
-        {
-            return (Status);
-        }
-
-        if (Gbl_Revision == 2)
-        {
-            Status = OslAddTableToList (ACPI_SIG_XSDT, 0);
-            if (ACPI_FAILURE (Status))
-            {
-                return (Status);
-            }
-        }
-
-        Status = OslAddTableToList (ACPI_SIG_DSDT, 0);
-        if (ACPI_FAILURE (Status))
-        {
-            return (Status);
-        }
-
-        Status = OslAddTableToList (ACPI_SIG_FACS, 0);
-        if (ACPI_FAILURE (Status))
-        {
-            return (Status);
-        }
-
-        /* Add all tables found in the memory */
-
-        Status = OslListTables ();
-        if (ACPI_FAILURE (Status))
-        {
-            return (Status);
-        }
-    }
-    else
-    {
-        /* Add all tables found in the static directory */
-
-        Status = AE_SUPPORT;
-    }
-
-    Gbl_TableListInitialized = TRUE;
-    return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    OslListTables
- *
- * PARAMETERS:  None
- *
- * RETURN:      Status; Table list is initialized if AE_OK.
- *
- * DESCRIPTION: Add ACPI tables to the table list from memory.
- *
- *****************************************************************************/
-
-static ACPI_STATUS
-OslListTables (
-    void)
-{
-    ACPI_TABLE_HEADER       *MappedTable = NULL;
-    UINT8                   *TableData;
-    UINT8                   NumberOfTables;
-    UINT8                   ItemSize;
-    ACPI_PHYSICAL_ADDRESS   TableAddress = 0;
-    ACPI_STATUS             Status = AE_OK;
-    UINT32                  i;
-
-
-    if (OslCanUseXsdt ())
-    {
-        ItemSize = sizeof (UINT64);
-        TableData = ACPI_CAST8 (Gbl_Xsdt) + sizeof (ACPI_TABLE_HEADER);
-        NumberOfTables =
-            (UINT8) ((Gbl_Xsdt->Header.Length - sizeof (ACPI_TABLE_HEADER))
-            / ItemSize);
-    }
-    else /* Use RSDT if XSDT is not available */
-    {
-        ItemSize = sizeof (UINT32);
-        TableData = ACPI_CAST8 (Gbl_Rsdt) + sizeof (ACPI_TABLE_HEADER);
-        NumberOfTables =
-            (UINT8) ((Gbl_Rsdt->Header.Length - sizeof (ACPI_TABLE_HEADER))
-            / ItemSize);
-    }
-
-    /* Search RSDT/XSDT for the requested table */
-
-    for (i = 0; i < NumberOfTables; ++i, TableData += ItemSize)
-    {
-        if (OslCanUseXsdt ())
-        {
-            TableAddress =
-                (ACPI_PHYSICAL_ADDRESS) (*ACPI_CAST64 (TableData));
-        }
-        else
-        {
-            TableAddress =
-                (ACPI_PHYSICAL_ADDRESS) (*ACPI_CAST32 (TableData));
-        }
-
-        /* Skip NULL entries in RSDT/XSDT */
-
-        if (!TableAddress)
-        {
-            continue;
-        }
-
-        Status = OslMapTable (TableAddress, NULL, &MappedTable);
-        if (ACPI_FAILURE (Status))
-        {
-            return (Status);
-        }
-
-        OslAddTableToList (MappedTable->Signature, 0);
-        OslUnmapTable (MappedTable);
-    }
-
-    return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    OslGetTable
- *
- * PARAMETERS:  Signature       - ACPI Signature for common table. Must be
- *                                a null terminated 4-character string.
- *              Instance        - Multiple table support for SSDT/UEFI (0...n)
- *                                Must be 0 for other tables.
- *              Table           - Where a pointer to the table is returned
- *              Address         - Where the table physical address is returned
- *
- * RETURN:      Status; Table buffer and physical address returned if AE_OK.
- *              AE_LIMIT: Instance is beyond valid limit
- *              AE_NOT_FOUND: A table with the signature was not found
- *
- * DESCRIPTION: Get a BIOS provided ACPI table
- *
- * NOTE:        Assumes the input signature is uppercase.
- *
- *****************************************************************************/
-
-static ACPI_STATUS
-OslGetTable (
-    char                    *Signature,
-    UINT32                  Instance,
-    ACPI_TABLE_HEADER       **Table,
-    ACPI_PHYSICAL_ADDRESS   *Address)
-{
-    ACPI_TABLE_HEADER       *LocalTable = NULL;
-    ACPI_TABLE_HEADER       *MappedTable = NULL;
-    UINT8                   *TableData;
-    UINT8                   NumberOfTables;
-    UINT8                   ItemSize;
-    UINT32                  CurrentInstance = 0;
-    ACPI_PHYSICAL_ADDRESS   TableAddress = 0;
-    UINT32                  TableLength = 0;
-    ACPI_STATUS             Status = AE_OK;
-    UINT32                  i;
-
-
-    /* Handle special tables whose addresses are not in RSDT/XSDT */
-
-    if (ACPI_COMPARE_NAME (Signature, ACPI_RSDP_NAME) ||
-        ACPI_COMPARE_NAME (Signature, ACPI_SIG_RSDT) ||
-        ACPI_COMPARE_NAME (Signature, ACPI_SIG_XSDT) ||
-        ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT) ||
-        ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS))
-    {
-        /*
-         * Get the appropriate address, either 32-bit or 64-bit. Be very
-         * careful about the FADT length and validate table addresses.
-         * Note: The 64-bit addresses have priority.
-         */
-        if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT))
-        {
-            if ((Gbl_Fadt->Header.Length >= MIN_FADT_FOR_XDSDT) &&
-                Gbl_Fadt->XDsdt)
-            {
-                TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_Fadt->XDsdt;
-            }
-            else if ((Gbl_Fadt->Header.Length >= MIN_FADT_FOR_DSDT) &&
-                Gbl_Fadt->Dsdt)
-            {
-                TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_Fadt->Dsdt;
-            }
-        }
-        else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS))
-        {
-            if ((Gbl_Fadt->Header.Length >= MIN_FADT_FOR_XFACS) &&
-                Gbl_Fadt->XFacs)
-            {
-                TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_Fadt->XFacs;
-            }
-            else if ((Gbl_Fadt->Header.Length >= MIN_FADT_FOR_FACS) &&
-                Gbl_Fadt->Facs)
-            {
-                TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_Fadt->Facs;
-            }
-        }
-        else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_XSDT))
-        {
-            if (!Gbl_Revision)
-            {
-                return (AE_BAD_SIGNATURE);
-            }
-            TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_Rsdp.XsdtPhysicalAddress;
-        }
-        else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_RSDT))
-        {
-            TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_Rsdp.RsdtPhysicalAddress;
-        }
-        else
-        {
-            TableAddress = (ACPI_PHYSICAL_ADDRESS) Gbl_RsdpAddress;
-            Signature = ACPI_SIG_RSDP;
-        }
-
-        /* Now we can get the requested special table */
-
-        Status = OslMapTable (TableAddress, Signature, &MappedTable);
-        if (ACPI_FAILURE (Status))
-        {
-            return (Status);
-        }
-
-        TableLength = ApGetTableLength (MappedTable);
-    }
-    else /* Case for a normal ACPI table */
-    {
-        if (OslCanUseXsdt ())
-        {
-            ItemSize = sizeof (UINT64);
-            TableData = ACPI_CAST8 (Gbl_Xsdt) + sizeof (ACPI_TABLE_HEADER);
-            NumberOfTables =
-                (UINT8) ((Gbl_Xsdt->Header.Length - sizeof (ACPI_TABLE_HEADER))
-                / ItemSize);
-        }
-        else /* Use RSDT if XSDT is not available */
-        {
-            ItemSize = sizeof (UINT32);
-            TableData = ACPI_CAST8 (Gbl_Rsdt) + sizeof (ACPI_TABLE_HEADER);
-            NumberOfTables =
-                (UINT8) ((Gbl_Rsdt->Header.Length - sizeof (ACPI_TABLE_HEADER))
-                / ItemSize);
-        }
-
-        /* Search RSDT/XSDT for the requested table */
-
-        for (i = 0; i < NumberOfTables; ++i, TableData += ItemSize)
-        {
-            if (OslCanUseXsdt ())
-            {
-                TableAddress =
-                    (ACPI_PHYSICAL_ADDRESS) (*ACPI_CAST64 (TableData));
-            }
-            else
-            {
-                TableAddress =
-                    (ACPI_PHYSICAL_ADDRESS) (*ACPI_CAST32 (TableData));
-            }
-
-            /* Skip NULL entries in RSDT/XSDT */
-
-            if (!TableAddress)
-            {
-                continue;
-            }
-
-            Status = OslMapTable (TableAddress, NULL, &MappedTable);
-            if (ACPI_FAILURE (Status))
-            {
-                return (Status);
-            }
-            TableLength = MappedTable->Length;
-
-            /* Does this table match the requested signature? */
-
-            if (!ACPI_COMPARE_NAME (MappedTable->Signature, Signature))
-            {
-                OslUnmapTable (MappedTable);
-                MappedTable = NULL;
-                continue;
-            }
-
-            /* Match table instance (for SSDT/UEFI tables) */
-
-            if (CurrentInstance != Instance)
-            {
-                OslUnmapTable (MappedTable);
-                MappedTable = NULL;
-                CurrentInstance++;
-                continue;
-            }
-
-            break;
-        }
-    }
-
-    if (!MappedTable)
-    {
-        return (AE_LIMIT);
-    }
-
-    if (TableLength == 0)
-    {
-        Status = AE_BAD_HEADER;
-        goto Exit;
-    }
-
-    /* Copy table to local buffer and return it */
-
-    LocalTable = ACPI_ALLOCATE_ZEROED (TableLength);
-    if (!LocalTable)
-    {
-        Status = AE_NO_MEMORY;
-        goto Exit;
-    }
-
-    memcpy (LocalTable, MappedTable, TableLength);
-    *Address = TableAddress;
-    *Table = LocalTable;
-
-Exit:
-    OslUnmapTable (MappedTable);
-    return (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    OslMapTable
- *
- * PARAMETERS:  Address             - Address of the table in memory
- *              Signature           - Optional ACPI Signature for desired table.
- *                                    Null terminated 4-character string.
- *              Table               - Where a pointer to the mapped table is
- *                                    returned
- *
- * RETURN:      Status; Mapped table is returned if AE_OK.
- *              AE_NOT_FOUND: A valid table was not found at the address
- *
- * DESCRIPTION: Map entire ACPI table into caller's address space.
- *
- *****************************************************************************/
-
-static ACPI_STATUS
-OslMapTable (
-    ACPI_SIZE               Address,
-    char                    *Signature,
-    ACPI_TABLE_HEADER       **Table)
-{
-    ACPI_TABLE_HEADER       *MappedTable;
-    UINT32                  Length;
-
-
-    if (!Address)
-    {
-        return (AE_BAD_ADDRESS);
-    }
-
-    /*
-     * Map the header so we can get the table length.
-     * Use sizeof (ACPI_TABLE_HEADER) as:
-     * 1. it is bigger than 24 to include RSDP->Length
-     * 2. it is smaller than sizeof (ACPI_TABLE_RSDP)
-     */
-    MappedTable = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER));
-    if (!MappedTable)
-    {
-        AcpiLogError ("Could not map table header at 0x%8.8X%8.8X\n",
-            ACPI_FORMAT_UINT64 (Address));
-        return (AE_BAD_ADDRESS);
-    }
-
-    /* If specified, signature must match */
-
-    if (Signature)
-    {
-        if (ACPI_VALIDATE_RSDP_SIG (Signature))
-        {
-            if (!ACPI_VALIDATE_RSDP_SIG (MappedTable->Signature))
-            {
-                AcpiOsUnmapMemory (MappedTable, sizeof (ACPI_TABLE_HEADER));
-                return (AE_BAD_SIGNATURE);
-            }
-        }
-        else if (!ACPI_COMPARE_NAME (Signature, MappedTable->Signature))
-        {
-            AcpiOsUnmapMemory (MappedTable, sizeof (ACPI_TABLE_HEADER));
-            return (AE_BAD_SIGNATURE);
-        }
-    }
-
-    /* Map the entire table */
-
-    Length = ApGetTableLength (MappedTable);
-    AcpiOsUnmapMemory (MappedTable, sizeof (ACPI_TABLE_HEADER));
-    if (Length == 0)
-    {
-        return (AE_BAD_HEADER);
-    }
-
-    MappedTable = AcpiOsMapMemory (Address, Length);
-    if (!MappedTable)
-    {
-        AcpiLogError ("Could not map table at 0x%8.8X%8.8X length %8.8X\n",
-            ACPI_FORMAT_UINT64 (Address), Length);
-        return (AE_INVALID_TABLE_LENGTH);
-    }
-
-    (void) ApIsValidChecksum (MappedTable);
-
-    *Table = MappedTable;
-    return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    OslUnmapTable
- *
- * PARAMETERS:  Table               - A pointer to the mapped table
- *
- * RETURN:      None
- *
- * DESCRIPTION: Unmap entire ACPI table.
- *
- *****************************************************************************/
-
-static void
-OslUnmapTable (
-    ACPI_TABLE_HEADER       *Table)
-{
-    if (Table)
-    {
-        AcpiOsUnmapMemory (Table, ApGetTableLength (Table));
-    }
-}
--- a/sys/external/bsd/acpica/dist/os_specific/service_layers/osefixf.c	Fri Nov 11 21:11:03 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1091 +0,0 @@
-/******************************************************************************
- *
- * Module Name: osefixf - EFI OSL interfaces
- *
- *****************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2016, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions, and the following disclaimer,
- *    without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- *    substantially similar to the "NO WARRANTY" disclaimer below
- *    ("Disclaimer") and any redistribution must be conditioned upon
- *    including a substantially similar Disclaimer requirement for further
- *    binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- *    of any contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include "acpi.h"
-#include "accommon.h"
-#include "acapps.h"
-
-#define _COMPONENT          ACPI_OS_SERVICES
-        ACPI_MODULE_NAME    ("osefixf")
-
-
-/* Local definitions */
-
-#define ACPI_EFI_PRINT_LENGTH   256
-
-
-/* Local prototypes */
-
-static ACPI_STATUS
-AcpiEfiArgify (
-    char                    *String,
-    int                     *ArgcPtr,
-    char                    ***ArgvPtr);
-
-static BOOLEAN
-AcpiEfiCompareGuid (
-    EFI_GUID                *Guid1,
-    EFI_GUID                *Guid2);
-
-static ACPI_STATUS
-AcpiEfiConvertArgcv (
-    CHAR16                  *LoadOpt,
-    UINT32                  LoadOptSize,
-    int                     *ArgcPtr,
-    char                    ***ArgvPtr,
-    char                    **BufferPtr);
-
-static ACPI_PHYSICAL_ADDRESS
-AcpiEfiGetRsdpViaGuid (
-    EFI_GUID                *Guid);
-
-static CHAR16 *
-AcpiEfiFlushFile (
-    ACPI_FILE               File,
-    CHAR16                  *Begin,
-    CHAR16                  *End,
-    CHAR16                  *Pos,
-    BOOLEAN                 FlushAll);
-
-
-/* Local variables */
-
-static EFI_FILE_HANDLE      AcpiGbl_EfiCurrentVolume = NULL;
-EFI_GUID                    AcpiGbl_LoadedImageProtocol = LOADED_IMAGE_PROTOCOL;
-EFI_GUID                    AcpiGbl_TextInProtocol = SIMPLE_TEXT_INPUT_PROTOCOL;
-EFI_GUID                    AcpiGbl_TextOutProtocol = SIMPLE_TEXT_OUTPUT_PROTOCOL;
-EFI_GUID                    AcpiGbl_FileSystemProtocol = SIMPLE_FILE_SYSTEM_PROTOCOL;
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiEfiGetRsdpViaGuid
- *
- * PARAMETERS:  Guid1               - GUID to compare
- *              Guid2               - GUID to compare
- *
- * RETURN:      TRUE if Guid1 == Guid2
- *
- * DESCRIPTION: Compares two GUIDs
- *
- *****************************************************************************/
-
-static BOOLEAN
-AcpiEfiCompareGuid (
-    EFI_GUID                *Guid1,
-    EFI_GUID                *Guid2)
-{
-    INT32                   *g1;
-    INT32                   *g2;
-    INT32                   r;
-
-
-    g1 = (INT32 *) Guid1;
-    g2 = (INT32 *) Guid2;
-
-    r  = g1[0] - g2[0];
-    r |= g1[1] - g2[1];
-    r |= g1[2] - g2[2];
-    r |= g1[3] - g2[3];
-
-    return (r ? FALSE : TRUE);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiEfiGetRsdpViaGuid
- *
- * PARAMETERS:  None
- *
- * RETURN:      RSDP address if found
- *
- * DESCRIPTION: Find RSDP address via EFI using specified GUID.
- *
- *****************************************************************************/
-
-static ACPI_PHYSICAL_ADDRESS
-AcpiEfiGetRsdpViaGuid (
-    EFI_GUID                *Guid)
-{
-    ACPI_PHYSICAL_ADDRESS   Address = 0;
-    int                     i;
-
-
-    for (i = 0; i < ST->NumberOfTableEntries; i++)
-    {
-        if (AcpiEfiCompareGuid (&ST->ConfigurationTable[i].VendorGuid, Guid))
-        {
-            Address = ACPI_PTR_TO_PHYSADDR (
-                    ST->ConfigurationTable[i].VendorTable);
-            break;
-        }
-    }
-
-    return (Address);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiOsGetRootPointer
- *
- * PARAMETERS:  None
- *
- * RETURN:      RSDP physical address
- *
- * DESCRIPTION: Gets the ACPI root pointer (RSDP)
- *
- *****************************************************************************/
-
-ACPI_PHYSICAL_ADDRESS
-AcpiOsGetRootPointer (
-    void)
-{
-    ACPI_PHYSICAL_ADDRESS   Address;
-    EFI_GUID                Guid10 = ACPI_TABLE_GUID;
-    EFI_GUID                Guid20 = ACPI_20_TABLE_GUID;
-
-
-    Address = AcpiEfiGetRsdpViaGuid (&Guid20);
-    if (!Address)
-    {
-        Address = AcpiEfiGetRsdpViaGuid (&Guid10);
-    }
-
-    return (Address);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiOsMapMemory
- *
- * PARAMETERS:  where               - Physical address of memory to be mapped
- *              length              - How much memory to map
- *
- * RETURN:      Pointer to mapped memory. Null on error.
- *
- * DESCRIPTION: Map physical memory into caller's address space
- *
- *****************************************************************************/
-
-void *
-AcpiOsMapMemory (
-    ACPI_PHYSICAL_ADDRESS   where,
-    ACPI_SIZE               length)
-{
-
-    return (ACPI_TO_POINTER ((ACPI_SIZE) where));
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiOsUnmapMemory
- *
- * PARAMETERS:  where               - Logical address of memory to be unmapped
- *              length              - How much memory to unmap
- *
- * RETURN:      None
- *
- * DESCRIPTION: Delete a previously created mapping. Where and Length must
- *              correspond to a previous mapping exactly.
- *
- *****************************************************************************/
-
-void
-AcpiOsUnmapMemory (
-    void                    *where,
-    ACPI_SIZE               length)
-{
-
-    return;
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    Spinlock interfaces
- *
- * DESCRIPTION: No-op on single threaded BIOS
- *
- *****************************************************************************/
-
-ACPI_STATUS
-AcpiOsCreateLock (
-    ACPI_SPINLOCK           *OutHandle)
-{
-    return (AE_OK);
-}
-
-void
-AcpiOsDeleteLock (
-    ACPI_SPINLOCK           Handle)
-{
-}
-
-ACPI_CPU_FLAGS
-AcpiOsAcquireLock (
-    ACPI_SPINLOCK           Handle)
-{
-    return (0);
-}
-
-void
-AcpiOsReleaseLock (
-    ACPI_SPINLOCK           Handle,
-    ACPI_CPU_FLAGS          Flags)
-{
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiOsAllocate
- *
- * PARAMETERS:  Size                - Amount to allocate, in bytes
- *
- * RETURN:      Pointer to the new allocation. Null on error.
- *
- * DESCRIPTION: Allocate memory. Algorithm is dependent on the OS.
- *
- *****************************************************************************/
-
-void *
-AcpiOsAllocate (
-    ACPI_SIZE               Size)
-{
-    EFI_STATUS              EfiStatus;
-    void                    *Mem;
-
-
-    EfiStatus = uefi_call_wrapper (BS->AllocatePool, 3,
-        EfiLoaderData, Size, &Mem);
-    if (EFI_ERROR (EfiStatus))
-    {
-        AcpiLogError ("EFI_BOOT_SERVICES->AllocatePool(EfiLoaderData) failure.\n");
-        return (NULL);
-    }
-
-    return (Mem);
-}
-
-
-#ifdef USE_NATIVE_ALLOCATE_ZEROED
-/******************************************************************************
- *
- * FUNCTION:    AcpiOsAllocateZeroed
- *
- * PARAMETERS:  Size                - Amount to allocate, in bytes
- *
- * RETURN:      Pointer to the new allocation. Null on error.
- *
- * DESCRIPTION: Allocate and zero memory. Algorithm is dependent on the OS.
- *
- *****************************************************************************/
-
-void *
-AcpiOsAllocateZeroed (
-    ACPI_SIZE               Size)
-{
-    void                    *Mem;
-
-
-    Mem = AcpiOsAllocate (Size);
-    if (Mem)
-    {
-        memset (Mem, 0, Size);
-    }
-
-    return (Mem);
-}
-#endif
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiOsFree
- *
- * PARAMETERS:  Mem                 - Pointer to previously allocated memory
- *
- * RETURN:      None
- *
- * DESCRIPTION: Free memory allocated via AcpiOsAllocate
- *
- *****************************************************************************/
-
-void
-AcpiOsFree (
-    void                    *Mem)
-{
-
-    uefi_call_wrapper (BS->FreePool, 1, Mem);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiOsOpenFile
- *
- * PARAMETERS:  Path                - File path
- *              Modes               - File operation type
- *
- * RETURN:      File descriptor
- *
- * DESCRIPTION: Open a file for reading (ACPI_FILE_READING) or/and writing
- *              (ACPI_FILE_WRITING).
- *
- ******************************************************************************/
-
-ACPI_FILE
-AcpiOsOpenFile (
-    const char              *Path,
-    UINT8                   Modes)
-{
-    EFI_STATUS              EfiStatus = EFI_SUCCESS;
-    UINT64                  OpenModes;
-    EFI_FILE_HANDLE         EfiFile = NULL;
-    CHAR16                  *Path16 = NULL;
-    CHAR16                  *Pos16;
-    const char              *Pos;
-    INTN                    Count, i;
-
-
-    if (!Path)
-    {
-        return (NULL);
-    }
-
-    /* Convert modes */
-
-    OpenModes = EFI_FILE_MODE_READ;
-    if (Modes & ACPI_FILE_WRITING)
-    {
-        OpenModes |= (EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE);
-    }
-
-    /* Allocate path buffer */
-
-    Count = strlen (Path);
-    Path16 = ACPI_ALLOCATE_ZEROED ((Count + 1) * sizeof (CHAR16));
-    if (!Path16)
-    {
-        EfiStatus = EFI_BAD_BUFFER_SIZE;
-        goto ErrorExit;
-    }
-    Pos = Path;
-    Pos16 = Path16;
-    while (*Pos == '/' || *Pos == '\\')
-    {
-        Pos++;
-        Count--;
-    }
-    for (i = 0; i < Count; i++)
-    {
-        if (*Pos == '/')
-        {
-            *Pos16++ = '\\';
-            Pos++;
-        }
-        else
-        {
-            *Pos16++ = *Pos++;
-        }
-    }
-    *Pos16 = '\0';
-
-    EfiStatus = uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Open, 5,
-        AcpiGbl_EfiCurrentVolume, &EfiFile, Path16, OpenModes, 0);
-    if (EFI_ERROR (EfiStatus))
-    {
-        AcpiLogError ("EFI_FILE_HANDLE->Open() failure.\n");
-        goto ErrorExit;
-    }
-
-ErrorExit:
-
-    if (Path16)
-    {
-        ACPI_FREE (Path16);
-    }
-
-    return ((ACPI_FILE) EfiFile);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiOsCloseFile
- *
- * PARAMETERS:  File                - File descriptor
- *
- * RETURN:      None.
- *
- * DESCRIPTION: Close a file.
- *
- ******************************************************************************/
-
-void
-AcpiOsCloseFile (
-    ACPI_FILE               File)
-{
-    EFI_FILE_HANDLE         EfiFile;
-
-
-    if (File == ACPI_FILE_OUT ||
-        File == ACPI_FILE_ERR)
-    {
-        return;
-    }
-    EfiFile = (EFI_FILE_HANDLE) File;
-    (void) uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Close, 1, EfiFile);
-
-    return;
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiOsReadFile
- *
- * PARAMETERS:  File                - File descriptor
- *              Buffer              - Data buffer
- *              Size                - Data block size
- *              Count               - Number of data blocks
- *
- * RETURN:      Size of successfully read buffer
- *
- * DESCRIPTION: Read from a file.
- *
- ******************************************************************************/
-
-int
-AcpiOsReadFile (
-    ACPI_FILE               File,
-    void                    *Buffer,
-    ACPI_SIZE               Size,
-    ACPI_SIZE               Count)
-{
-    int                     Length = -1;
-    EFI_FILE_HANDLE         EfiFile;
-    UINTN                   ReadSize;
-    EFI_STATUS              EfiStatus;
-
-
-    if (File == ACPI_FILE_OUT ||
-        File == ACPI_FILE_ERR)
-    {
-    }
-    else
-    {
-        EfiFile = (EFI_FILE_HANDLE) File;
-        if (!EfiFile)
-        {
-            goto ErrorExit;
-        }
-        ReadSize = Size * Count;
-
-        EfiStatus = uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Read, 3,
-            EfiFile, &ReadSize, Buffer);
-        if (EFI_ERROR (EfiStatus))
-        {
-            AcpiLogError ("EFI_FILE_HANDLE->Read() failure.\n");
-            goto ErrorExit;
-        }
-        Length = ReadSize;
-    }
-
-ErrorExit:
-
-    return (Length);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiEfiFlushFile
- *
- * PARAMETERS:  File                - File descriptor
- *              Begin               - String with boundary
- *              End                 - Boundary of the string
- *              Pos                 - Current position
- *              FlushAll            - Whether checking boundary before flushing
- *
- * RETURN:      Updated position
- *
- * DESCRIPTION: Flush cached buffer to the file.
- *
- ******************************************************************************/
-
-static CHAR16 *
-AcpiEfiFlushFile (
-    ACPI_FILE               File,
-    CHAR16                  *Begin,
-    CHAR16                  *End,
-    CHAR16                  *Pos,
-    BOOLEAN                 FlushAll)
-{
-
-    if (FlushAll || Pos >= (End - 1))
-    {
-        *Pos = 0;
-        uefi_call_wrapper (File->OutputString, 2, File, Begin);
-        Pos = Begin;
-    }
-
-    return (Pos);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiOsWriteFile
- *
- * PARAMETERS:  File                - File descriptor
- *              Buffer              - Data buffer
- *              Size                - Data block size
- *              Count               - Number of data blocks
- *
- * RETURN:      Size of successfully written buffer
- *
- * DESCRIPTION: Write to a file.
- *
- ******************************************************************************/
-
-int
-AcpiOsWriteFile (
-    ACPI_FILE               File,
-    void                    *Buffer,
-    ACPI_SIZE               Size,
-    ACPI_SIZE               Count)
-{
-    int                     Length = -1;
-    CHAR16                  String[ACPI_EFI_PRINT_LENGTH];
-    const char              *Ascii;
-    CHAR16                  *End;
-    CHAR16                  *Pos;
-    int                     i, j;
-    EFI_FILE_HANDLE         EfiFile;
-    UINTN                   WriteSize;
-    EFI_STATUS              EfiStatus;
-
-
-    if (File == ACPI_FILE_OUT ||
-        File == ACPI_FILE_ERR)
-    {
-        Pos = String;
-        End = String + ACPI_EFI_PRINT_LENGTH - 1;
-        Ascii = ACPI_CAST_PTR (const char, Buffer);
-        Length = 0;
-
-        for (j = 0; j < Count; j++)
-        {
-            for (i = 0; i < Size; i++)
-            {
-                if (*Ascii == '\n')
-                {
-                    *Pos++ = '\r';
-                    Pos = AcpiEfiFlushFile (File, String,
-                            End, Pos, FALSE);
-                }
-                *Pos++ = *Ascii++;
-                Length++;
-                Pos = AcpiEfiFlushFile (File, String,
-                        End, Pos, FALSE);
-            }
-        }
-        Pos = AcpiEfiFlushFile (File, String, End, Pos, TRUE);
-    }
-    else
-    {
-        EfiFile = (EFI_FILE_HANDLE) File;
-        if (!EfiFile)
-        {
-            goto ErrorExit;
-        }
-        WriteSize = Size * Count;
-
-        EfiStatus = uefi_call_wrapper (AcpiGbl_EfiCurrentVolume->Write, 3,
-            EfiFile, &WriteSize, Buffer);
-        if (EFI_ERROR (EfiStatus))
-        {
-            AcpiLogError ("EFI_FILE_HANDLE->Write() failure.\n");
-            goto ErrorExit;
-        }
-        Length = WriteSize;
-    }
-
-ErrorExit:
-
-    return (Length);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiOsGetFileOffset
- *
- * PARAMETERS:  File                - File descriptor
- *
- * RETURN:      Size of current position
- *
- * DESCRIPTION: Get current file offset.
- *
- ******************************************************************************/
-
-long
-AcpiOsGetFileOffset (
-    ACPI_FILE               File)
-{
-    long                    Offset = -1;
-
-
-    return (Offset);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiOsSetFileOffset
- *
- * PARAMETERS:  File                - File descriptor
- *              Offset              - File offset
- *              From                - From begin/end of file
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Set current file offset.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiOsSetFileOffset (
-    ACPI_FILE               File,
-    long                    Offset,
-    UINT8                   From)
-{
-
-    return (AE_SUPPORT);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiOsPrintf
- *
- * PARAMETERS:  Format, ...         - Standard printf format
- *
- * RETURN:      None
- *
- * DESCRIPTION: Formatted output.
- *
- *****************************************************************************/
-
-void ACPI_INTERNAL_VAR_XFACE
-AcpiOsPrintf (
-    const char              *Format,
-    ...)
-{
-    va_list                 Args;
-
-
-    va_start (Args, Format);
-    AcpiOsVprintf (Format, Args);
-    va_end (Args);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiOsVprintf
- *
- * PARAMETERS:  Format              - Standard printf format
- *              Args                - Argument list
- *
- * RETURN:      None
- *
- * DESCRIPTION: Formatted output with arguments list pointer.
- *
- *****************************************************************************/
-
-void
-AcpiOsVprintf (
-    const char              *Format,
-    va_list                 Args)
-{
-
-    (void) AcpiUtFileVprintf (ACPI_FILE_OUT, Format, Args);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiOsInitialize
- *
- * PARAMETERS:  None
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Initialize this module.
- *
- *****************************************************************************/
-
-ACPI_STATUS
-AcpiOsInitialize (
-    void)
-{
-
-    return (AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiEfiArgify
- *
- * PARAMETERS:  String              - Pointer to command line argument strings
- *                                    which are seperated with spaces
- *              ArgcPtr             - Return number of the arguments
- *              ArgvPtr             - Return vector of the arguments
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Convert EFI arguments into C arguments.
- *
- *****************************************************************************/
-
-static ACPI_STATUS
-AcpiEfiArgify (
-    char                    *String,
-    int                     *ArgcPtr,
-    char                    ***ArgvPtr)
-{
-    char                    *CopyBuffer;
-    int                     MaxArgc = *ArgcPtr;
-    int                     Argc = 0;
-    char                    **Argv = *ArgvPtr;
-    char                    *Arg;
-    BOOLEAN                 IsSingleQuote = FALSE;
-    BOOLEAN                 IsDoubleQuote = FALSE;
-    BOOLEAN                 IsEscape = FALSE;
-
-
-    if (String == NULL)
-    {
-        return (AE_BAD_PARAMETER);
-    }
-
-    CopyBuffer = String;
-
-    while (*String != '\0')
-    {
-        while (isspace (*String))
-        {
-            *String++ = '\0';
-        }
-        Arg = CopyBuffer;
-        while (*String != '\0')
-        {
-            if (isspace (*String) &&
-                !IsSingleQuote && !IsDoubleQuote && !IsEscape)
-            {
-                *Arg++ = '\0';
-                String++;
-                break;
-            }
-            if (IsEscape)
-            {
-                IsEscape = FALSE;
-                *Arg++ = *String;
-            }
-            else if (*String == '\\')
-            {
-                IsEscape = TRUE;
-            }
-            else if (IsSingleQuote)
-            {
-                if (*String == '\'')
-                {
-                    IsSingleQuote = FALSE;
-                    *Arg++ = '\0';
-                }
-                else
-                {
-                    *Arg++ = *String;
-                }
-            }
-            else if (IsDoubleQuote)
-            {
-                if (*String == '"')
-                {
-                    IsDoubleQuote = FALSE;
-                    *Arg = '\0';
-                }
-                else
-                {
-                    *Arg++ = *String;
-                }
-            }
-            else
-            {
-                if (*String == '\'')
-                {
-                    IsSingleQuote = TRUE;
-                }
-                else if (*String == '"')
-                {
-                    IsDoubleQuote = TRUE;
-                }
-                else
-                {
-                    *Arg++ = *String;
-                }
-            }
-            String++;
-        }
-        if (Argv && Argc < MaxArgc)
-        {
-            Argv[Argc] = CopyBuffer;
-        }
-        Argc++;
-        CopyBuffer = Arg;
-    }
-    if (Argv && Argc < MaxArgc)
-    {
-        Argv[Argc] = NULL;
-    }
-
-    *ArgcPtr = Argc;
-    *ArgvPtr = Argv;
-
-    return ((MaxArgc < Argc) ? AE_NO_MEMORY : AE_OK);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiEfiConvertArgcv
- *
- * PARAMETERS:  LoadOptions         - Pointer to the EFI options buffer, which
- *                                    is NULL terminated
- *              LoadOptionsSize     - Size of the EFI options buffer
- *              ArgcPtr             - Return number of the arguments
- *              ArgvPtr             - Return vector of the arguments
- *              BufferPtr           - Buffer to contain the argument strings
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Convert EFI arguments into C arguments.
- *
- *****************************************************************************/
-
-static ACPI_STATUS
-AcpiEfiConvertArgcv (
-    CHAR16                  *LoadOptions,
-    UINT32                  LoadOptionsSize,
-    int                     *ArgcPtr,
-    char                    ***ArgvPtr,
-    char                    **BufferPtr)
-{
-    ACPI_STATUS             Status = AE_OK;
-    UINT32                  Count = LoadOptionsSize / sizeof (CHAR16);
-    UINT32                  i;
-    CHAR16                  *From;
-    char                    *To;
-    int                     Argc = 0;
-    char                    **Argv = NULL;
-    char                    *Buffer;
-
-
-    /* Prepare a buffer to contain the argument strings */
-
-    Buffer = ACPI_ALLOCATE_ZEROED (Count);
-    if (!Buffer)
-    {
-        Status = AE_NO_MEMORY;
-        goto ErrorExit;
-    }
-
-TryAgain:
-
-    /* Extend the argument vector */
-
-    if (Argv)
-    {
-        ACPI_FREE (Argv);
-        Argv = NULL;
-    }
-    if (Argc > 0)
-    {
-        Argv = ACPI_ALLOCATE_ZEROED (sizeof (char *) * (Argc + 1));
-        if (!Argv)
-        {
-            Status = AE_NO_MEMORY;
-            goto ErrorExit;
-        }
-    }
-
-    /*
-     * Note: As AcpiEfiArgify() will modify the content of the buffer, so
-     *       we need to restore it each time before invoking
-     *       AcpiEfiArgify().
-     */
-    From = LoadOptions;
-    To = ACPI_CAST_PTR (char, Buffer);
-    for (i = 0; i < Count; i++)
-    {
-        *To++ = (char) *From++;
-    }
-
-    /*
-     * The "Buffer" will contain NULL terminated strings after invoking
-     * AcpiEfiArgify(). The number of the strings are saved in Argc and the
-     * pointers of the strings are saved in Argv.
-     */
-    Status = AcpiEfiArgify (Buffer, &Argc, &Argv);
-    if (ACPI_FAILURE (Status))
-    {
-        if (Status == AE_NO_MEMORY)
-        {
-            goto TryAgain;
-        }
-    }
-
-ErrorExit:
-
-    if (ACPI_FAILURE (Status))
-    {
-        ACPI_FREE (Buffer);
-        ACPI_FREE (Argv);
-    }
-    else
-    {
-        *ArgcPtr = Argc;
-        *ArgvPtr = Argv;
-        *BufferPtr = Buffer;
-    }
-    return (Status);
-}
-
-
-/******************************************************************************
- *
- * FUNCTION:    efi_main
- *
- * PARAMETERS:  Image               - EFI image handle
- *              SystemTab           - EFI system table
- *
- * RETURN:      EFI Status
- *
- * DESCRIPTION: Entry point of EFI executable
- *
- *****************************************************************************/
-
-EFI_STATUS
-efi_main (
-    EFI_HANDLE              Image,
-    EFI_SYSTEM_TABLE        *SystemTab)
-{
-    EFI_LOADED_IMAGE        *Info;
-    EFI_STATUS              EfiStatus = EFI_SUCCESS;
-    ACPI_STATUS             Status;
-    int                     argc;
-    char                    **argv = NULL;
-    char                    *OptBuffer = NULL;
-    EFI_FILE_IO_INTERFACE   *Volume = NULL;
-
-
-    /* Initialize global variables */
-
-    ST = SystemTab;
-    BS = SystemTab->BootServices;
-
-    /* Retrieve image information */
-
-    EfiStatus = uefi_call_wrapper (BS->HandleProtocol, 3,
-        Image, &AcpiGbl_LoadedImageProtocol, ACPI_CAST_PTR (VOID, &Info));
-    if (EFI_ERROR (EfiStatus))
-    {
-        AcpiLogError ("EFI_BOOT_SERVICES->HandleProtocol(LoadedImageProtocol) failure.\n");
-        return (EfiStatus);
-    }
-
-    EfiStatus = uefi_call_wrapper (BS->HandleProtocol, 3,
-        Info->DeviceHandle, &AcpiGbl_FileSystemProtocol, (void **) &Volume);
-    if (EFI_ERROR (EfiStatus))
-    {
-        AcpiLogError ("EFI_BOOT_SERVICES->HandleProtocol(FileSystemProtocol) failure.\n");
-        return (EfiStatus);
-    }
-    EfiStatus = uefi_call_wrapper (Volume->OpenVolume, 2,
-        Volume, &AcpiGbl_EfiCurrentVolume);
-    if (EFI_ERROR (EfiStatus))
-    {
-        AcpiLogError ("EFI_FILE_IO_INTERFACE->OpenVolume() failure.\n");
-        return (EfiStatus);
-    }
-
-    Status = AcpiEfiConvertArgcv (Info->LoadOptions,
-        Info->LoadOptionsSize, &argc, &argv, &OptBuffer);
-    if (ACPI_FAILURE (Status))
-    {
-        EfiStatus = EFI_DEVICE_ERROR;
-        goto ErrorAlloc;
-    }
-
-    acpi_main (argc, argv);
-
-ErrorAlloc:
-
-    if (argv)
-    {
-        ACPI_FREE (argv);
-    }
-    if (OptBuffer)
-    {
-        ACPI_FREE (OptBuffer);
-    }
-
-    return (EfiStatus);
-}
--- a/sys/external/bsd/acpica/dist/os_specific/service_layers/oslibcfs.c	Fri Nov 11 21:11:03 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,258 +0,0 @@
-/******************************************************************************
- *
- * Module Name: oslibcfs - C library OSL for file I/O
- *
- *****************************************************************************/
-
-/*
- * Copyright (C) 2000 - 2016, Intel Corp.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions, and the following disclaimer,
- *    without modification.
- * 2. Redistributions in binary form must reproduce at minimum a disclaimer
- *    substantially similar to the "NO WARRANTY" disclaimer below
- *    ("Disclaimer") and any redistribution must be conditioned upon
- *    including a substantially similar Disclaimer requirement for further
- *    binary redistribution.
- * 3. Neither the names of the above-listed copyright holders nor the names
- *    of any contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- * Alternatively, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") version 2 as published by the Free
- * Software Foundation.
- *
- * NO WARRANTY
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGES.
- */
-
-#include "acpi.h"
-#include <stdio.h>
-#include <stdarg.h>
-
-#define _COMPONENT          ACPI_OS_SERVICES
-        ACPI_MODULE_NAME    ("oslibcfs")
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiOsOpenFile
- *
- * PARAMETERS:  Path                - File path
- *              Modes               - File operation type
- *
- * RETURN:      File descriptor.
- *
- * DESCRIPTION: Open a file for reading (ACPI_FILE_READING) or/and writing
- *              (ACPI_FILE_WRITING).
- *
- ******************************************************************************/
-
-ACPI_FILE
-AcpiOsOpenFile (
-    const char              *Path,
-    UINT8                   Modes)
-{
-    ACPI_FILE               File;
-    UINT32                  i = 0;
-    char                    ModesStr[4];
-
-
-    if (Modes & ACPI_FILE_READING)
-    {
-        ModesStr[i++] = 'r';
-    }
-    if (Modes & ACPI_FILE_WRITING)
-    {
-        ModesStr[i++] = 'w';
-    }
-
-    if (Modes & ACPI_FILE_BINARY)
-    {
-        ModesStr[i++] = 'b';
-    }
-
-    ModesStr[i++] = '\0';
-
-    File = fopen (Path, ModesStr);
-    if (!File)
-    {
-        perror ("Could not open file");
-    }
-
-    return (File);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiOsCloseFile
- *
- * PARAMETERS:  File                - An open file descriptor
- *
- * RETURN:      None.
- *
- * DESCRIPTION: Close a file opened via AcpiOsOpenFile.
- *
- ******************************************************************************/
-
-void
-AcpiOsCloseFile (
-    ACPI_FILE               File)
-{
-
-    fclose (File);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiOsReadFile
- *
- * PARAMETERS:  File                - An open file descriptor
- *              Buffer              - Data buffer
- *              Size                - Data block size
- *              Count               - Number of data blocks
- *
- * RETURN:      Number of bytes actually read.
- *
- * DESCRIPTION: Read from a file.
- *
- ******************************************************************************/
-
-int
-AcpiOsReadFile (
-    ACPI_FILE               File,
-    void                    *Buffer,
-    ACPI_SIZE               Size,
-    ACPI_SIZE               Count)
-{
-    int                     Length;
-
-
-    Length = fread (Buffer, Size, Count, File);
-    if (Length < 0)
-    {
-        perror ("Error reading file");
-    }
-
-    return (Length);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiOsWriteFile
- *
- * PARAMETERS:  File                - An open file descriptor
- *              Buffer              - Data buffer
- *              Size                - Data block size
- *              Count               - Number of data blocks
- *
- * RETURN:      Number of bytes actually written.
- *
- * DESCRIPTION: Write to a file.
- *
- ******************************************************************************/
-
-int
-AcpiOsWriteFile (
-    ACPI_FILE               File,
-    void                    *Buffer,
-    ACPI_SIZE               Size,
-    ACPI_SIZE               Count)
-{
-    int                     Length;
-
-
-    Length = fwrite (Buffer, Size, Count, File);
-    if (Length < 0)
-    {
-        perror ("Error writing file");
-    }
-
-    return (Length);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiOsGetFileOffset
- *
- * PARAMETERS:  File                - An open file descriptor
- *
- * RETURN:      Current file pointer position.
- *
- * DESCRIPTION: Get current file offset.
- *
- ******************************************************************************/
-
-long
-AcpiOsGetFileOffset (
-    ACPI_FILE               File)
-{
-    long                    Offset;
-
-
-    Offset = ftell (File);
-    return (Offset);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AcpiOsSetFileOffset
- *
- * PARAMETERS:  File                - An open file descriptor
- *              Offset              - New file offset
- *              From                - From begin/end of file
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Set current file offset.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiOsSetFileOffset (
-    ACPI_FILE               File,
-    long                    Offset,
-    UINT8                   From)
-{
-    int                     Ret = 0;
-
-
-    if (From == ACPI_FILE_BEGIN)
-    {
-        Ret = fseek (File, Offset, SEEK_SET);
-    }
-
-    if (From == ACPI_FILE_END)
-    {
-        Ret = fseek (File, Offset, SEEK_END);
-    }
-
-    if (Ret < 0)
-    {
-        return (AE_ERROR);
-    }
-    else
-    {
-        return (AE_OK);
-    }
-}
--- a/sys/external/bsd/acpica/dist/tables/tbdata.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/tables/tbdata.c	Fri Nov 11 21:11:30 2016 +0000
@@ -45,6 +45,7 @@
 #include "accommon.h"
 #include "acnamesp.h"
 #include "actables.h"
+#include "acevents.h"
 
 #define _COMPONENT          ACPI_TABLES
         ACPI_MODULE_NAME    ("tbdata")
@@ -680,18 +681,13 @@
      * lock may block, and also since the execution of a namespace walk
      * must be allowed to use the interpreter.
      */
-    (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
     Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock);
-
-    AcpiNsDeleteNamespaceByOwner (OwnerId);
     if (ACPI_FAILURE (Status))
     {
         return_ACPI_STATUS (Status);
     }
-
+    AcpiNsDeleteNamespaceByOwner (OwnerId);
     AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock);
-
-    Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
     return_ACPI_STATUS (Status);
 }
 
@@ -867,3 +863,160 @@
 
     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
 }
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiTbLoadTable
+ *
+ * PARAMETERS:  TableIndex              - Table index
+ *              ParentNode              - Where table index is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Load an ACPI table
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbLoadTable (
+    UINT32                  TableIndex,
+    ACPI_NAMESPACE_NODE     *ParentNode)
+{
+    ACPI_TABLE_HEADER       *Table;
+    ACPI_STATUS             Status;
+    ACPI_OWNER_ID           OwnerId;
+
+
+    ACPI_FUNCTION_TRACE (TbLoadTable);
+
+
+    /*
+     * Note: Now table is "INSTALLED", it must be validated before
+     * using.
+     */
+    Status = AcpiGetTableByIndex (TableIndex, &Table);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    Status = AcpiNsLoadTable (TableIndex, ParentNode);
+
+    /* Execute any module-level code that was found in the table */
+
+    if (!AcpiGbl_ParseTableAsTermList && AcpiGbl_GroupModuleLevelCode)
+    {
+        AcpiNsExecModuleCodeList ();
+    }
+
+    /*
+     * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is
+     * responsible for discovering any new wake GPEs by running _PRW methods
+     * that may have been loaded by this table.
+     */
+    Status = AcpiTbGetOwnerId (TableIndex, &OwnerId);
+    if (ACPI_SUCCESS (Status))
+    {
+        AcpiEvUpdateGpes (OwnerId);
+    }
+
+    /* Invoke table handler if present */
+
+    if (AcpiGbl_TableHandler)
+    {
+        (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table,
+            AcpiGbl_TableHandlerContext);
+    }
+
+    return_ACPI_STATUS (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiTbInstallAndLoadTable
+ *
+ * PARAMETERS:  Table                   - Pointer to the table
+ *              Address                 - Physical address of the table
+ *              Flags                   - Allocation flags of the table
+ *              TableIndex              - Where table index is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Install and load an ACPI table
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiTbInstallAndLoadTable (
+    ACPI_TABLE_HEADER       *Table,
+    ACPI_PHYSICAL_ADDRESS   Address,
+    UINT8                   Flags,
+    BOOLEAN                 Override,
+    UINT32                  *TableIndex)
+{
+    ACPI_STATUS             Status;
+    UINT32                  i;
+    ACPI_OWNER_ID           OwnerId;
+
+
+    ACPI_FUNCTION_TRACE (AcpiLoadTable);
+
+
+    (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
+
+    /* Install the table and load it into the namespace */
+
+    Status = AcpiTbInstallStandardTable (Address, Flags, TRUE,
+        Override, &i);
+    if (ACPI_FAILURE (Status))
+    {
+        goto UnlockAndExit;
+    }
+
+    /*
+     * Note: Now table is "INSTALLED", it must be validated before
+     * using.
+     */
+    Status = AcpiTbValidateTable (&AcpiGbl_RootTableList.Tables[i]);
+    if (ACPI_FAILURE (Status))
+    {
+        goto UnlockAndExit;
+    }
+
+    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
+    Status = AcpiNsLoadTable (i, AcpiGbl_RootNode);
+
+    /* Execute any module-level code that was found in the table */
+
+    if (!AcpiGbl_ParseTableAsTermList && AcpiGbl_GroupModuleLevelCode)
+    {
+        AcpiNsExecModuleCodeList ();
+    }
+
+    /*
+     * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is
+     * responsible for discovering any new wake GPEs by running _PRW methods
+     * that may have been loaded by this table.
+     */
+    Status = AcpiTbGetOwnerId (i, &OwnerId);
+    if (ACPI_SUCCESS (Status))
+    {
+        AcpiEvUpdateGpes (OwnerId);
+    }
+
+    /* Invoke table handler if present */
+
+    if (AcpiGbl_TableHandler)
+    {
+        (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table,
+            AcpiGbl_TableHandlerContext);
+    }
+    (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
+
+UnlockAndExit:
+    *TableIndex = i;
+    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
+    return_ACPI_STATUS (Status);
+}
--- a/sys/external/bsd/acpica/dist/tables/tbfadt.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/tables/tbfadt.c	Fri Nov 11 21:11:30 2016 +0000
@@ -375,8 +375,10 @@
 
     /* Obtain the DSDT and FACS tables via their addresses within the FADT */
 
-    AcpiTbInstallFixedTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt,
-        ACPI_SIG_DSDT, &AcpiGbl_DsdtIndex);
+    AcpiTbInstallStandardTable (
+        (ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XDsdt,
+        ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, FALSE, TRUE,
+        &AcpiGbl_DsdtIndex);
 
     /* If Hardware Reduced flag is set, there is no FACS */
 
@@ -384,13 +386,17 @@
     {
         if (AcpiGbl_FADT.Facs)
         {
-            AcpiTbInstallFixedTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.Facs,
-                ACPI_SIG_FACS, &AcpiGbl_FacsIndex);
+            AcpiTbInstallStandardTable (
+                (ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.Facs,
+                ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, FALSE, TRUE,
+                &AcpiGbl_FacsIndex);
         }
         if (AcpiGbl_FADT.XFacs)
         {
-            AcpiTbInstallFixedTable ((ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs,
-                ACPI_SIG_FACS, &AcpiGbl_XFacsIndex);
+            AcpiTbInstallStandardTable (
+                (ACPI_PHYSICAL_ADDRESS) AcpiGbl_FADT.XFacs,
+                ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, FALSE, TRUE,
+                &AcpiGbl_XFacsIndex);
         }
     }
 }
@@ -516,17 +522,19 @@
 
 
     /*
-     * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which
+     * For ACPI 1.0 FADTs (revision 1), ensure that reserved fields which
      * should be zero are indeed zero. This will workaround BIOSs that
      * inadvertently place values in these fields.
      *
      * The ACPI 1.0 reserved fields that will be zeroed are the bytes located
      * at offset 45, 55, 95, and the word located at offset 109, 110.
      *
-     * Note: The FADT revision value is unreliable. Only the length can be
-     * trusted.
+     * Note: The FADT revision value is unreliable because of BIOS errors.
+     * The table length is instead used as the final word on the version.
+     *
+     * Note: FADT revision 3 is the ACPI 2.0 version of the FADT.
      */
-    if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V2_SIZE)
+    if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V3_SIZE)
     {
         AcpiGbl_FADT.PreferredProfile = 0;
         AcpiGbl_FADT.PstateControl = 0;
@@ -591,65 +599,67 @@
          *
          * Address32 zero, Address64 [don't care]   - Use Address64
          *
+         * No override: if AcpiGbl_Use32BitFadtAddresses is FALSE, and:
          * Address32 non-zero, Address64 zero       - Copy/use Address32
          * Address32 non-zero == Address64 non-zero - Use Address64
          * Address32 non-zero != Address64 non-zero - Warning, use Address64
          *
          * Override: if AcpiGbl_Use32BitFadtAddresses is TRUE, and:
+         * Address32 non-zero, Address64 zero       - Copy/use Address32
+         * Address32 non-zero == Address64 non-zero - Copy/use Address32
          * Address32 non-zero != Address64 non-zero - Warning, copy/use Address32
          *
          * Note: SpaceId is always I/O for 32-bit legacy address fields
          */
         if (Address32)
         {
-            if (!Address64->Address)
+            if (Address64->Address)
             {
-                /* 64-bit address is zero, use 32-bit address */
+                if (Address64->Address != (UINT64) Address32)
+                {
+                    /* Address mismatch */
+
+                    ACPI_BIOS_WARNING ((AE_INFO,
+                        "32/64X address mismatch in FADT/%s: "
+                        "0x%8.8X/0x%8.8X%8.8X, using %u-bit address",
+                        Name, Address32,
+                        ACPI_FORMAT_UINT64 (Address64->Address),
+                        AcpiGbl_Use32BitFadtAddresses ? 32 : 64));
+                }
 
+                /*
+                 * For each extended field, check for length mismatch
+                 * between the legacy length field and the corresponding
+                 * 64-bit X length field.
+                 * Note: If the legacy length field is > 0xFF bits, ignore
+                 * this check. (GPE registers can be larger than the
+                 * 64-bit GAS structure can accomodate, 0xFF bits).
+                 */
+                if ((ACPI_MUL_8 (Length) <= ACPI_UINT8_MAX) &&
+                    (Address64->BitWidth != ACPI_MUL_8 (Length)))
+                {
+                    ACPI_BIOS_WARNING ((AE_INFO,
+                        "32/64X length mismatch in FADT/%s: %u/%u",
+                        Name, ACPI_MUL_8 (Length), Address64->BitWidth));
+                }
+            }
+
+            /*
+             * Hardware register access code always uses the 64-bit fields.
+             * So if the 64-bit field is zero or is to be overridden,
+             * initialize it with the 32-bit fields.
+             * Note that when the 32-bit address favor is specified, the
+             * 64-bit fields are always re-initialized so that
+             * AccessSize/BitWidth/BitOffset fields can be correctly
+             * configured to the values to trigger a 32-bit compatible
+             * access mode in the hardware register access code.
+             */
+            if (!Address64->Address || AcpiGbl_Use32BitFadtAddresses)
+            {
                 AcpiTbInitGenericAddress (Address64,
-                    ACPI_ADR_SPACE_SYSTEM_IO,
-                    *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT,
-                        FadtInfoTable[i].Length),
+                    ACPI_ADR_SPACE_SYSTEM_IO, Length,
                     (UINT64) Address32, Name, Flags);
             }
-            else if (Address64->Address != (UINT64) Address32)
-            {
-                /* Address mismatch */
-
-                ACPI_BIOS_WARNING ((AE_INFO,
-                    "32/64X address mismatch in FADT/%s: "
-                    "0x%8.8X/0x%8.8X%8.8X, using %u-bit address",
-                    Name, Address32,
-                    ACPI_FORMAT_UINT64 (Address64->Address),
-                    AcpiGbl_Use32BitFadtAddresses ? 32 : 64));
-
-                if (AcpiGbl_Use32BitFadtAddresses)
-                {
-                    /* 32-bit address override */
-
-                    AcpiTbInitGenericAddress (Address64,
-                        ACPI_ADR_SPACE_SYSTEM_IO,
-                        *ACPI_ADD_PTR (UINT8, &AcpiGbl_FADT,
-                            FadtInfoTable[i].Length),
-                        (UINT64) Address32, Name, Flags);
-                }
-            }
-        }
-
-        /*
-         * For each extended field, check for length mismatch between the
-         * legacy length field and the corresponding 64-bit X length field.
-         * Note: If the legacy length field is > 0xFF bits, ignore this
-         * check. (GPE registers can be larger than the 64-bit GAS structure
-         * can accomodate, 0xFF bits).
-         */
-        if (Address64->Address &&
-           (ACPI_MUL_8 (Length) <= ACPI_UINT8_MAX) &&
-           (Address64->BitWidth != ACPI_MUL_8 (Length)))
-        {
-            ACPI_BIOS_WARNING ((AE_INFO,
-                "32/64X length mismatch in FADT/%s: %u/%u",
-                Name, ACPI_MUL_8 (Length), Address64->BitWidth));
         }
 
         if (FadtInfoTable[i].Flags & ACPI_FADT_REQUIRED)
--- a/sys/external/bsd/acpica/dist/tables/tbinstal.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/tables/tbinstal.c	Fri Nov 11 21:11:30 2016 +0000
@@ -169,74 +169,6 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    AcpiTbInstallFixedTable
- *
- * PARAMETERS:  Address                 - Physical address of DSDT or FACS
- *              Signature               - Table signature, NULL if no need to
- *                                        match
- *              TableIndex              - Where the table index is returned
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Install a fixed ACPI table (DSDT/FACS) into the global data
- *              structure.
- *
- ******************************************************************************/
-
-ACPI_STATUS
-AcpiTbInstallFixedTable (
-    ACPI_PHYSICAL_ADDRESS   Address,
-    const char              *Signature,
-    UINT32                  *TableIndex)
-{
-    ACPI_TABLE_DESC         NewTableDesc;
-    ACPI_STATUS             Status;
-
-
-    ACPI_FUNCTION_TRACE (TbInstallFixedTable);
-
-
-    if (!Address)
-    {
-        ACPI_ERROR ((AE_INFO, "Null physical address for ACPI table [%s]",
-            Signature));
-        return (AE_NO_MEMORY);
-    }
-
-    /* Fill a table descriptor for validation */
-
-    Status = AcpiTbAcquireTempTable (&NewTableDesc, Address,
-        ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL);
-    if (ACPI_FAILURE (Status))
-    {
-        ACPI_ERROR ((AE_INFO, "Could not acquire table length at %8.8X%8.8X",
-            ACPI_FORMAT_UINT64 (Address)));
-        return_ACPI_STATUS (Status);
-    }
-
-    /* Validate and verify a table before installation */
-
-    Status = AcpiTbVerifyTempTable (&NewTableDesc, Signature);
-    if (ACPI_FAILURE (Status))
-    {
-        goto ReleaseAndExit;
-    }
-
-    /* Add the table to the global root table list */
-
-    AcpiTbInstallTableWithOverride (&NewTableDesc, TRUE, TableIndex);
-
-ReleaseAndExit:
-
-    /* Release the temporary table descriptor */
-
-    AcpiTbReleaseTempTable (&NewTableDesc);
-    return_ACPI_STATUS (Status);
-}
-
-
-/*******************************************************************************
- *
  * FUNCTION:    AcpiTbInstallStandardTable
  *
  * PARAMETERS:  Address             - Address of the table (might be a virtual
@@ -248,8 +180,7 @@
  *
  * RETURN:      Status
  *
- * DESCRIPTION: This function is called to install an ACPI table that is
- *              neither DSDT nor FACS (a "standard" table.)
+ * DESCRIPTION: This function is called to verify and install an ACPI table.
  *              When this function is called by "Load" or "LoadTable" opcodes,
  *              or by AcpiLoadTable() API, the "Reload" parameter is set.
  *              After sucessfully returning from this function, table is
@@ -390,6 +321,14 @@
 
     AcpiTbInstallTableWithOverride (&NewTableDesc, Override, TableIndex);
 
+    /* Invoke table handler if present */
+
+    if (AcpiGbl_TableHandler)
+    {
+        (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_INSTALL,
+            NewTableDesc.Pointer, AcpiGbl_TableHandlerContext);
+    }
+
 ReleaseAndExit:
 
     /* Release the temporary table descriptor */
--- a/sys/external/bsd/acpica/dist/tables/tbutils.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/tables/tbutils.c	Fri Nov 11 21:11:30 2016 +0000
@@ -273,7 +273,7 @@
  *
  ******************************************************************************/
 
-ACPI_STATUS
+ACPI_STATUS ACPI_INIT_FUNCTION
 AcpiTbParseRootTable (
     ACPI_PHYSICAL_ADDRESS   RsdpAddress)
 {
--- a/sys/external/bsd/acpica/dist/tables/tbxface.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/tables/tbxface.c	Fri Nov 11 21:11:30 2016 +0000
@@ -103,7 +103,7 @@
  *
  ******************************************************************************/
 
-ACPI_STATUS
+ACPI_STATUS ACPI_INIT_FUNCTION
 AcpiInitializeTables (
     ACPI_TABLE_DESC         *InitialTableArray,
     UINT32                  InitialTableCount,
@@ -179,7 +179,7 @@
  *
  ******************************************************************************/
 
-ACPI_STATUS
+ACPI_STATUS ACPI_INIT_FUNCTION
 AcpiReallocateRootTable (
     void)
 {
--- a/sys/external/bsd/acpica/dist/tables/tbxfload.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/tables/tbxfload.c	Fri Nov 11 21:11:30 2016 +0000
@@ -65,7 +65,7 @@
  *
  ******************************************************************************/
 
-ACPI_STATUS
+ACPI_STATUS ACPI_INIT_FUNCTION
 AcpiLoadTables (
     void)
 {
@@ -111,7 +111,7 @@
             "While loading namespace from ACPI tables"));
     }
 
-    if (!AcpiGbl_GroupModuleLevelCode)
+    if (AcpiGbl_ParseTableAsTermList || !AcpiGbl_GroupModuleLevelCode)
     {
         /*
          * Initialize the objects that remain uninitialized. This
@@ -207,11 +207,11 @@
     memcpy (&AcpiGbl_OriginalDsdtHeader, AcpiGbl_DSDT,
         sizeof (ACPI_TABLE_HEADER));
 
-    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
-
     /* Load and parse tables */
 
+    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
     Status = AcpiNsLoadTable (AcpiGbl_DsdtIndex, AcpiGbl_RootNode);
+    (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
     if (ACPI_FAILURE (Status))
     {
         ACPI_EXCEPTION ((AE_INFO, Status, "[DSDT] table load failed"));
@@ -224,7 +224,6 @@
 
     /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */
 
-    (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
     for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
     {
         Table = &AcpiGbl_RootTableList.Tables[i];
@@ -242,6 +241,7 @@
 
         (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
         Status =  AcpiNsLoadTable (i, AcpiGbl_RootNode);
+        (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
         if (ACPI_FAILURE (Status))
         {
             ACPI_EXCEPTION ((AE_INFO, Status, "(%4.4s:%8.8s) while loading table",
@@ -257,14 +257,12 @@
         {
             TablesLoaded++;
         }
-
-        (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
     }
 
     if (!TablesFailed)
     {
         ACPI_INFO ((
-            "%u ACPI AML tables successfully acquired and loaded\n",
+            "%u ACPI AML tables successfully acquired and loaded",
             TablesLoaded));
     }
     else
@@ -278,6 +276,11 @@
         Status = AE_CTRL_TERMINATE;
     }
 
+#ifdef ACPI_APPLICATION
+    ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "\n"));
+#endif
+
+
 UnlockAndExit:
     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
     return_ACPI_STATUS (Status);
@@ -300,7 +303,7 @@
  *
  ******************************************************************************/
 
-ACPI_STATUS
+ACPI_STATUS ACPI_INIT_FUNCTION
 AcpiInstallTable (
     ACPI_PHYSICAL_ADDRESS   Address,
     BOOLEAN                 Physical)
@@ -366,52 +369,11 @@
         return_ACPI_STATUS (AE_BAD_PARAMETER);
     }
 
-    /* Must acquire the interpreter lock during this operation */
-
-    Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
-    if (ACPI_FAILURE (Status))
-    {
-        return_ACPI_STATUS (Status);
-    }
-
     /* Install the table and load it into the namespace */
 
     ACPI_INFO (("Host-directed Dynamic ACPI Table Load:"));
-    (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
-
-    Status = AcpiTbInstallStandardTable (ACPI_PTR_TO_PHYSADDR (Table),
-        ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL, TRUE, FALSE,
-        &TableIndex);
-
-    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
-    if (ACPI_FAILURE (Status))
-    {
-        goto UnlockAndExit;
-    }
-
-    /*
-     * Note: Now table is "INSTALLED", it must be validated before
-     * using.
-     */
-    Status = AcpiTbValidateTable (
-        &AcpiGbl_RootTableList.Tables[TableIndex]);
-    if (ACPI_FAILURE (Status))
-    {
-        goto UnlockAndExit;
-    }
-
-    Status = AcpiNsLoadTable (TableIndex, AcpiGbl_RootNode);
-
-    /* Invoke table handler if present */
-
-    if (AcpiGbl_TableHandler)
-    {
-        (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table,
-            AcpiGbl_TableHandlerContext);
-    }
-
-UnlockAndExit:
-    (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
+    Status = AcpiTbInstallAndLoadTable (Table, ACPI_PTR_TO_PHYSADDR (Table),
+        ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL, FALSE, &TableIndex);
     return_ACPI_STATUS (Status);
 }
 
@@ -466,9 +428,9 @@
         return_ACPI_STATUS (AE_TYPE);
     }
 
-    /* Must acquire the interpreter lock during this operation */
+    /* Must acquire the table lock during this operation */
 
-    Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
+    Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES);
     if (ACPI_FAILURE (Status))
     {
         return_ACPI_STATUS (Status);
@@ -499,9 +461,11 @@
 
         /* Ensure the table is actually loaded */
 
+        (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
         if (!AcpiTbIsTableLoaded (i))
         {
             Status = AE_NOT_EXIST;
+            (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
             break;
         }
 
@@ -528,10 +492,11 @@
 
         Status = AcpiTbReleaseOwnerId (i);
         AcpiTbSetTableLoadedFlag (i, FALSE);
+        (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
         break;
     }
 
-    (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
+    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
     return_ACPI_STATUS (Status);
 }
 
--- a/sys/external/bsd/acpica/dist/tables/tbxfroot.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/tables/tbxfroot.c	Fri Nov 11 21:11:30 2016 +0000
@@ -156,7 +156,7 @@
  *
  ******************************************************************************/
 
-ACPI_STATUS
+ACPI_STATUS ACPI_INIT_FUNCTION
 AcpiFindRootPointer (
     ACPI_PHYSICAL_ADDRESS   *TableAddress)
 {
@@ -262,7 +262,7 @@
     return_ACPI_STATUS (AE_NOT_FOUND);
 }
 
-ACPI_EXPORT_SYMBOL (AcpiFindRootPointer)
+ACPI_EXPORT_SYMBOL_INIT (AcpiFindRootPointer)
 
 
 /*******************************************************************************
--- a/sys/external/bsd/acpica/dist/tools/acpidump/apfiles.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/tools/acpidump/apfiles.c	Fri Nov 11 21:11:30 2016 +0000
@@ -42,7 +42,6 @@
  */
 
 #include "acpidump.h"
-#include "acapps.h"
 
 
 /* Local prototypes */
@@ -74,7 +73,7 @@
 
     if (!stat (Pathname, &StatInfo))
     {
-        AcpiLogError ("Target path already exists, overwrite? [y|n] ");
+        fprintf (stderr, "Target path already exists, overwrite? [y|n] ");
 
         if (getchar () != 'y')
         {
@@ -116,10 +115,10 @@
 
     /* Point stdout to the file */
 
-    File = AcpiOsOpenFile (Pathname, ACPI_FILE_WRITING);
+    File = fopen (Pathname, "w");
     if (!File)
     {
-        AcpiLogError ("Could not open output file: %s\n", Pathname);
+        fprintf (stderr, "Could not open output file: %s\n", Pathname);
         return (-1);
     }
 
@@ -153,7 +152,7 @@
     char                    Filename[ACPI_NAME_SIZE + 16];
     char                    InstanceStr [16];
     ACPI_FILE               File;
-    size_t                  Actual;
+    ACPI_SIZE               Actual;
     UINT32                  TableLength;
 
 
@@ -182,7 +181,7 @@
 
     if (Instance > 0)
     {
-        AcpiUtSnprintf (InstanceStr, sizeof (InstanceStr), "%u", Instance);
+        snprintf (InstanceStr, sizeof (InstanceStr), "%u", Instance);
         strcat (Filename, InstanceStr);
     }
 
@@ -190,30 +189,29 @@
 
     if (Gbl_VerboseMode)
     {
-        AcpiLogError (
+        fprintf (stderr,
             "Writing [%4.4s] to binary file: %s 0x%X (%u) bytes\n",
             Table->Signature, Filename, Table->Length, Table->Length);
     }
 
     /* Open the file and dump the entire table in binary mode */
 
-    File = AcpiOsOpenFile (Filename,
-        ACPI_FILE_WRITING | ACPI_FILE_BINARY);
+    File = fopen (Filename, "wb");
     if (!File)
     {
-        AcpiLogError ("Could not open output file: %s\n", Filename);
+        fprintf (stderr, "Could not open output file: %s\n", Filename);
         return (-1);
     }
 
-    Actual = AcpiOsWriteFile (File, Table, 1, TableLength);
+    Actual = fwrite (Table, 1, TableLength, File);
     if (Actual != TableLength)
     {
-        AcpiLogError ("Error writing binary output file: %s\n", Filename);
-        AcpiOsCloseFile (File);
+        fprintf (stderr, "Error writing binary output file: %s\n", Filename);
+        fclose (File);
         return (-1);
     }
 
-    AcpiOsCloseFile (File);
+    fclose (File);
     return (0);
 }
 
@@ -239,15 +237,15 @@
     ACPI_TABLE_HEADER       *Buffer = NULL;
     ACPI_FILE               File;
     UINT32                  FileSize;
-    size_t                  Actual;
+    ACPI_SIZE               Actual;
 
 
     /* Must use binary mode */
 
-    File = AcpiOsOpenFile (Pathname, ACPI_FILE_READING | ACPI_FILE_BINARY);
+    File = fopen (Pathname, "rb");
     if (!File)
     {
-        AcpiLogError ("Could not open input file: %s\n", Pathname);
+        fprintf (stderr, "Could not open input file: %s\n", Pathname);
         return (NULL);
     }
 
@@ -256,7 +254,7 @@
     FileSize = CmGetFileSize (File);
     if (FileSize == ACPI_UINT32_MAX)
     {
-        AcpiLogError (
+        fprintf (stderr,
             "Could not get input file size: %s\n", Pathname);
         goto Cleanup;
     }
@@ -266,18 +264,17 @@
     Buffer = ACPI_ALLOCATE_ZEROED (FileSize);
     if (!Buffer)
     {
-        AcpiLogError (
+        fprintf (stderr,
             "Could not allocate file buffer of size: %u\n", FileSize);
         goto Cleanup;
     }
 
     /* Read the entire file */
 
-    Actual = AcpiOsReadFile (File, Buffer, 1, FileSize);
+    Actual = fread (Buffer, 1, FileSize, File);
     if (Actual != FileSize)
     {
-        AcpiLogError (
-            "Could not read input file: %s\n", Pathname);
+        fprintf (stderr, "Could not read input file: %s\n", Pathname);
         ACPI_FREE (Buffer);
         Buffer = NULL;
         goto Cleanup;
@@ -286,6 +283,6 @@
     *OutFileSize = FileSize;
 
 Cleanup:
-    AcpiOsCloseFile (File);
+    fclose (File);
     return (Buffer);
 }
--- a/sys/external/bsd/acpica/dist/utilities/utdebug.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/utilities/utdebug.c	Fri Nov 11 21:11:30 2016 +0000
@@ -708,33 +708,3 @@
 ACPI_EXPORT_SYMBOL (AcpiTracePoint)
 
 #endif
-
-
-#ifdef ACPI_APPLICATION
-/*******************************************************************************
- *
- * FUNCTION:    AcpiLogError
- *
- * PARAMETERS:  Format              - Printf format field
- *              ...                 - Optional printf arguments
- *
- * RETURN:      None
- *
- * DESCRIPTION: Print error message to the console, used by applications.
- *
- ******************************************************************************/
-
-void  ACPI_INTERNAL_VAR_XFACE
-AcpiLogError (
-    const char              *Format,
-    ...)
-{
-    va_list                 Args;
-
-    va_start (Args, Format);
-    (void) AcpiUtFileVprintf (ACPI_FILE_ERR, Format, Args);
-    va_end (Args);
-}
-
-ACPI_EXPORT_SYMBOL (AcpiLogError)
-#endif
--- a/sys/external/bsd/acpica/dist/utilities/utosi.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/utilities/utosi.c	Fri Nov 11 21:11:30 2016 +0000
@@ -442,11 +442,22 @@
  * PARAMETERS:  WalkState           - Current walk state
  *
  * RETURN:      Status
+ *              Integer: TRUE (0) if input string is matched
+ *                       FALSE (-1) if string is not matched
  *
  * DESCRIPTION: Implementation of the _OSI predefined control method. When
  *              an invocation of _OSI is encountered in the system AML,
  *              control is transferred to this function.
  *
+ * (August 2016)
+ * Note:  _OSI is now defined to return "Ones" to indicate a match, for
+ * compatibility with other ACPI implementations. On a 32-bit DSDT, Ones
+ * is 0xFFFFFFFF. On a 64-bit DSDT, Ones is 0xFFFFFFFFFFFFFFFF
+ * (ACPI_UINT64_MAX).
+ *
+ * This function always returns ACPI_UINT64_MAX for TRUE, and later code
+ * will truncate this to 32 bits if necessary.
+ *
  ******************************************************************************/
 
 ACPI_STATUS
@@ -458,7 +469,7 @@
     ACPI_INTERFACE_INFO     *InterfaceInfo;
     ACPI_INTERFACE_HANDLER  InterfaceHandler;
     ACPI_STATUS             Status;
-    UINT32                  ReturnValue;
+    UINT64                  ReturnValue;
 
 
     ACPI_FUNCTION_TRACE (UtOsiImplementation);
@@ -507,7 +518,7 @@
             AcpiGbl_OsiData = InterfaceInfo->Value;
         }
 
-        ReturnValue = ACPI_UINT32_MAX;
+        ReturnValue = ACPI_UINT64_MAX;
     }
 
     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
@@ -520,8 +531,11 @@
     InterfaceHandler = AcpiGbl_InterfaceHandler;
     if (InterfaceHandler)
     {
-        ReturnValue = InterfaceHandler (
-            StringDesc->String.Pointer, ReturnValue);
+        if (InterfaceHandler (
+            StringDesc->String.Pointer, (UINT32) ReturnValue))
+        {
+            ReturnValue = ACPI_UINT64_MAX;
+        }
     }
 
     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
--- a/sys/external/bsd/acpica/dist/utilities/utprint.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/utilities/utprint.c	Fri Nov 11 21:11:30 2016 +0000
@@ -40,7 +40,6 @@
  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGES.
  */
-
 #include "acpi.h"
 #include "accommon.h"
 
@@ -413,7 +412,9 @@
     return (String);
 }
 
-
+#undef sprintf
+#undef snprintf
+#undef vsnprintf
 /*******************************************************************************
  *
  * FUNCTION:    vsnprintf
--- a/sys/external/bsd/acpica/dist/utilities/uttrack.c	Fri Nov 11 21:11:03 2016 +0000
+++ b/sys/external/bsd/acpica/dist/utilities/uttrack.c	Fri Nov 11 21:11:30 2016 +0000
@@ -107,15 +107,13 @@
     ACPI_MEMORY_LIST        *Cache;
 
 
-    Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST));
+    Cache = AcpiOsAllocateZeroed (sizeof (ACPI_MEMORY_LIST));
     if (!Cache)
     {
         return (AE_NO_MEMORY);
     }
 
-    memset (Cache, 0, sizeof (ACPI_MEMORY_LIST));
-
-    Cache->ListName = __UNCONST(ListName);
+    Cache->ListName = ListName;
     Cache->ObjectSize = ObjectSize;
 
     *ReturnCache = Cache;