[PATCH 1/2] ACPICA: Update to version 20151218 (LP: #1527733)

Colin King colin.king at canonical.com
Fri Dec 18 20:07:40 UTC 2015


From: Colin Ian King <colin.king at canonical.com>

Changes in this release of ACPICA are detailed at the following
link on the ACPICA developer mailing list:

https://lists.acpica.org/pipermail/devel/2015-December/000865.html

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/acpica/fwts_acpica.c                           |   2 +
 src/acpica/source/common/acfileio.c                | 226 +++++++++++--
 src/acpica/source/common/adisasm.c                 |  13 +-
 src/acpica/source/common/getopt.c                  | 348 +++++++++++++++++++++
 src/acpica/source/compiler/Makefile.am             |   1 +
 src/acpica/source/compiler/aslascii.c              |  88 +-----
 src/acpica/source/compiler/aslcompiler.h           |  16 +-
 src/acpica/source/compiler/aslcompiler.y           |  10 +-
 src/acpica/source/compiler/asldefine.h             |   8 +-
 src/acpica/source/compiler/aslfiles.c              |   4 +-
 src/acpica/source/compiler/aslglobal.h             |   2 +-
 src/acpica/source/compiler/asllisting.c            |  30 +-
 src/acpica/source/compiler/aslmain.c               |   3 +-
 src/acpica/source/compiler/aslmap.c                |   2 +-
 src/acpica/source/compiler/aslopcodes.c            |   1 -
 src/acpica/source/compiler/aslrules.y              |  10 +-
 src/acpica/source/compiler/aslstartup.c            |  81 ++---
 src/acpica/source/compiler/aslsupport.l            |   6 +-
 src/acpica/source/compiler/asltree.c               |  22 +-
 src/acpica/source/compiler/aslutils.c              |  44 ++-
 src/acpica/source/compiler/aslwalks.c              |  15 +-
 src/acpica/source/compiler/dttemplate.c            | 293 +++++++++++++----
 src/acpica/source/compiler/dttemplate.h            |  30 --
 src/acpica/source/components/debugger/dbdisply.c   |  28 +-
 src/acpica/source/components/debugger/dbinput.c    |   2 +-
 .../source/components/disassembler/dmopcode.c      | 124 ++++++++
 src/acpica/source/components/disassembler/dmwalk.c |  49 +--
 src/acpica/source/components/dispatcher/dsinit.c   |   2 +-
 src/acpica/source/components/events/evhandler.c    | 169 +++++-----
 src/acpica/source/components/events/evregion.c     | 124 ++++++--
 src/acpica/source/components/events/evrgnini.c     | 101 ++----
 src/acpica/source/components/events/evxfregn.c     |  41 +--
 src/acpica/source/components/executer/excreate.c   |   7 +-
 src/acpica/source/components/executer/exdebug.c    |  76 +++--
 src/acpica/source/components/executer/exdump.c     |   6 +-
 src/acpica/source/components/executer/exmisc.c     |  45 ++-
 src/acpica/source/components/executer/exoparg1.c   |   2 +-
 src/acpica/source/components/namespace/nsconvert.c |  86 ++++-
 src/acpica/source/components/namespace/nseval.c    |  66 +---
 src/acpica/source/components/namespace/nsload.c    |  18 ++
 src/acpica/source/components/namespace/nsrepair.c  |  11 +-
 src/acpica/source/components/parser/psargs.c       |  19 +-
 src/acpica/source/components/parser/psloop.c       |   4 +-
 src/acpica/source/components/parser/psopcode.c     |   2 +-
 src/acpica/source/components/tables/tbutils.c      |   9 +-
 src/acpica/source/components/utilities/utinit.c    |   1 -
 src/acpica/source/components/utilities/utstring.c  |   9 +
 src/acpica/source/components/utilities/utxfinit.c  |  75 +++--
 src/acpica/source/include/acapps.h                 |  14 +-
 src/acpica/source/include/acevents.h               |  18 +-
 src/acpica/source/include/acexcep.h                |   6 +-
 src/acpica/source/include/acglobal.h               |   5 +-
 src/acpica/source/include/aclocal.h                |   3 +
 src/acpica/source/include/acnamesp.h               |   9 +
 src/acpica/source/include/acobject.h               |   7 +-
 src/acpica/source/include/acopcode.h               |  10 +-
 src/acpica/source/include/acparser.h               |   7 +-
 src/acpica/source/include/acpixf.h                 |  11 +-
 src/acpica/source/include/amlcode.h                |   5 +-
 src/acpica/source/tools/acpiexec/aecommon.h        |   4 +
 src/acpica/source/tools/acpiexec/aehandlers.c      |  63 ++--
 src/acpica/source/tools/acpiexec/aeregion.c        |  58 +++-
 src/utilities/kernelscan.c                         |   3 +
 63 files changed, 1827 insertions(+), 727 deletions(-)
 create mode 100644 src/acpica/source/common/getopt.c

diff --git a/src/acpica/fwts_acpica.c b/src/acpica/fwts_acpica.c
index 77a96ca..88f83a6 100644
--- a/src/acpica/fwts_acpica.c
+++ b/src/acpica/fwts_acpica.c
@@ -1099,6 +1099,8 @@ int fwts_acpica_init(fwts_framework *fw)
 		fwts_acpica_RSDP = NULL;
 	}
 
+	AcpiGbl_OverrideDefaultRegionHandlers = TRUE;
+
 	if (ACPI_FAILURE(AcpiInitializeSubsystem())) {
 		fwts_log_error(fw, "Failed to initialise ACPICA subsystem.");
 		goto failed;
diff --git a/src/acpica/source/common/acfileio.c b/src/acpica/source/common/acfileio.c
index 7d6cc23..d260120 100644
--- a/src/acpica/source/common/acfileio.c
+++ b/src/acpica/source/common/acfileio.c
@@ -127,20 +127,20 @@
 /* Local prototypes */
 
 static ACPI_STATUS
-AcpiAcGetOneTableFromFile (
+AcGetOneTableFromFile (
     char                    *Filename,
     FILE                    *File,
     UINT8                   GetOnlyAmlTables,
     ACPI_TABLE_HEADER       **Table);
 
 static ACPI_STATUS
-AcpiAcCheckTextModeCorruption (
+AcCheckTextModeCorruption (
     ACPI_TABLE_HEADER       *Table);
 
 
 /*******************************************************************************
  *
- * FUNCTION:    AcpiAcGetAllTablesFromFile
+ * FUNCTION:    AcGetAllTablesFromFile
  *
  * PARAMETERS:  Filename            - Table filename
  *              GetOnlyAmlTables    - TRUE if the tables must be AML tables
@@ -153,7 +153,7 @@ AcpiAcCheckTextModeCorruption (
  ******************************************************************************/
 
 ACPI_STATUS
-AcpiAcGetAllTablesFromFile (
+AcGetAllTablesFromFile (
     char                    *Filename,
     UINT8                   GetOnlyAmlTables,
     ACPI_NEW_TABLE_DESC     **ReturnListHead)
@@ -187,19 +187,36 @@ AcpiAcGetAllTablesFromFile (
         return (AE_ERROR);
     }
 
-    if (FileSize < 4)
+    fprintf (stderr,
+        "Input file %s, Length 0x%X (%u) bytes\n",
+        Filename, FileSize, FileSize);
+
+    /* We must have at least one ACPI table header */
+
+    if (FileSize < sizeof (ACPI_TABLE_HEADER))
     {
         return (AE_BAD_HEADER);
     }
 
+    /* Check for an non-binary file */
+
+    if (!AcIsFileBinary (File))
+    {
+        fprintf (stderr,
+            "    %s: File does not appear to contain a valid AML table\n",
+            Filename);
+        return (AE_TYPE);
+    }
+
     /* Read all tables within the file */
 
     while (ACPI_SUCCESS (Status))
     {
         /* Get one entire ACPI table */
 
-        Status = AcpiAcGetOneTableFromFile (
+        Status = AcGetOneTableFromFile (
             Filename, File, GetOnlyAmlTables, &Table);
+
         if (Status == AE_CTRL_TERMINATE)
         {
             Status = AE_OK;
@@ -207,13 +224,20 @@ AcpiAcGetAllTablesFromFile (
         }
         else if (Status == AE_TYPE)
         {
-            continue;
+            return (AE_OK);
         }
         else if (ACPI_FAILURE (Status))
         {
             return (Status);
         }
 
+        /* Print table header for iASL/disassembler only */
+
+#ifdef ACPI_ASL_COMPILER
+
+            AcpiTbPrintTableHeader (0, Table);
+#endif
+
         /* Allocate and link a table descriptor */
 
         TableDesc = AcpiOsAllocate (sizeof (ACPI_NEW_TABLE_DESC));
@@ -258,7 +282,7 @@ AcpiAcGetAllTablesFromFile (
 
 /*******************************************************************************
  *
- * FUNCTION:    AcpiAcGetOneTableFromFile
+ * FUNCTION:    AcGetOneTableFromFile
  *
  * PARAMETERS:  Filename            - File where table is located
  *              File                - Open FILE pointer to Filename
@@ -276,7 +300,7 @@ AcpiAcGetAllTablesFromFile (
  ******************************************************************************/
 
 static ACPI_STATUS
-AcpiAcGetOneTableFromFile (
+AcGetOneTableFromFile (
     char                    *Filename,
     FILE                    *File,
     UINT8                   GetOnlyAmlTables,
@@ -286,21 +310,28 @@ AcpiAcGetOneTableFromFile (
     ACPI_TABLE_HEADER       TableHeader;
     ACPI_TABLE_HEADER       *Table;
     INT32                   Count;
-    long                    Position;
+    long                    TableOffset;
 
 
     *ReturnTable = NULL;
 
+    /* Get the table header to examine signature and length */
 
-    /* Get just the table header to get signature and length */
-
-    Position = ftell (File);
+    TableOffset = ftell (File);
     Count = fread (&TableHeader, 1, sizeof (ACPI_TABLE_HEADER), File);
     if (Count != sizeof (ACPI_TABLE_HEADER))
     {
         return (AE_CTRL_TERMINATE);
     }
 
+    /* Validate the table signature/header (limited ASCII chars) */
+
+    Status = AcValidateTableHeader (File, TableOffset);
+    if (ACPI_FAILURE (Status))
+    {
+        return (Status);
+    }
+
     if (GetOnlyAmlTables)
     {
         /* Table must be an AML table (DSDT/SSDT) or FADT */
@@ -309,7 +340,7 @@ AcpiAcGetOneTableFromFile (
             !AcpiUtIsAmlTable (&TableHeader))
         {
             fprintf (stderr,
-                "    %s: [%4.4s] is not an AML table - ignoring\n",
+                "    %s: Table [%4.4s] is not an AML table - ignoring\n",
                 Filename, TableHeader.Signature);
 
             return (AE_TYPE);
@@ -324,9 +355,9 @@ AcpiAcGetOneTableFromFile (
         return (AE_NO_MEMORY);
     }
 
-    /* Now read the entire table */
+    /* Read the entire ACPI table, including header */
 
-    fseek (File, Position, SEEK_SET);
+    fseek (File, TableOffset, SEEK_SET);
 
     Count = fread (Table, 1, TableHeader.Length, File);
     if (Count != (INT32) TableHeader.Length)
@@ -340,18 +371,13 @@ AcpiAcGetOneTableFromFile (
     Status = AcpiTbVerifyChecksum (Table, TableHeader.Length);
     if (ACPI_FAILURE (Status))
     {
-        Status = AcpiAcCheckTextModeCorruption (Table);
+        Status = AcCheckTextModeCorruption (Table);
         if (ACPI_FAILURE (Status))
         {
             goto ErrorExit;
         }
     }
 
-    fprintf (stderr,
-        "Loading ACPI table [%4.4s] from file %12s - Length 0x%06X (%u)\n",
-        TableHeader.Signature, Filename,
-        TableHeader.Length, TableHeader.Length);
-
     *ReturnTable = Table;
     return (AE_OK);
 
@@ -364,7 +390,159 @@ ErrorExit:
 
 /*******************************************************************************
  *
- * FUNCTION:    AcpiAcCheckTextModeCorruption
+ * FUNCTION:    AcIsFileBinary
+ *
+ * PARAMETERS:  File                - Open input file
+ *
+ * RETURN:      TRUE if file appears to be binary
+ *
+ * DESCRIPTION: Scan a file for any non-ASCII bytes.
+ *
+ * Note: Maintains current file position.
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcIsFileBinary (
+    FILE                    *File)
+{
+    UINT8                   Byte;
+    BOOLEAN                 IsBinary = FALSE;
+    long                    FileOffset;
+
+
+    /* Scan entire file for any non-ASCII bytes */
+
+    FileOffset = ftell (File);
+    while (fread (&Byte, 1, 1, File) == 1)
+    {
+        if (!isprint (Byte) && !isspace (Byte))
+        {
+            IsBinary = TRUE;
+            goto Exit;
+        }
+    }
+
+Exit:
+    fseek (File, FileOffset, SEEK_SET);
+    return (IsBinary);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcValidateTableHeader
+ *
+ * PARAMETERS:  File                - Open input file
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Determine if a file seems to contain one or more binary ACPI
+ *              tables, via the
+ *              following checks on what would be the table header:
+ *              1) File must be at least as long as an ACPI_TABLE_HEADER
+ *              2) There must be enough room in the file to hold entire table
+ *              3) Signature, OemId, OemTableId, AslCompilerId must be ASCII
+ *
+ * Note: There can be multiple definition blocks per file, so we cannot
+ * expect/compare the file size to be equal to the table length. 12/2015.
+ *
+ * Note: Maintains current file position.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcValidateTableHeader (
+    FILE                    *File,
+    long                    TableOffset)
+{
+    ACPI_TABLE_HEADER       TableHeader;
+    size_t                  Actual;
+    long                    OriginalOffset;
+    UINT32                  FileSize;
+    UINT32                  i;
+
+
+    ACPI_FUNCTION_TRACE ("AcValidateTableHeader");
+
+
+    /* Read a potential table header */
+
+    OriginalOffset = ftell (File);
+    fseek (File, TableOffset, SEEK_SET);
+
+    Actual = fread (&TableHeader, 1, sizeof (ACPI_TABLE_HEADER), File);
+    fseek (File, OriginalOffset, SEEK_SET);
+
+    if (Actual < sizeof (ACPI_TABLE_HEADER))
+    {
+        return (AE_ERROR);
+    }
+
+    /* Validate the signature (limited ASCII chars) */
+
+    if (!AcpiIsValidSignature (TableHeader.Signature))
+    {
+        fprintf (stderr, "Invalid table signature: 0x%8.8X\n",
+            *ACPI_CAST_PTR (UINT32, TableHeader.Signature));
+        return (AE_BAD_SIGNATURE);
+    }
+
+    /* Validate table length against bytes remaining in the file */
+
+    FileSize = CmGetFileSize (File);
+    if (TableHeader.Length > (UINT32) (FileSize - TableOffset))
+    {
+        fprintf (stderr, "Table [%4.4s] is too long for file - "
+            "needs: 0x%.2X, remaining in file: 0x%.2X\n",
+            TableHeader.Signature, TableHeader.Length,
+            (UINT32) (FileSize - TableOffset));
+        return (AE_BAD_HEADER);
+    }
+
+    /*
+     * These fields must be ASCII: OemId, OemTableId, AslCompilerId.
+     * We allow a NULL terminator in OemId and OemTableId.
+     */
+    for (i = 0; i < ACPI_NAME_SIZE; i++)
+    {
+        if (!ACPI_IS_ASCII ((UINT8) TableHeader.AslCompilerId[i]))
+        {
+            goto BadCharacters;
+        }
+    }
+
+    for (i = 0; (i < ACPI_OEM_ID_SIZE) && (TableHeader.OemId[i]); i++)
+    {
+        if (!ACPI_IS_ASCII ((UINT8) TableHeader.OemId[i]))
+        {
+            goto BadCharacters;
+        }
+    }
+
+    for (i = 0; (i < ACPI_OEM_TABLE_ID_SIZE) && (TableHeader.OemTableId[i]); i++)
+    {
+        if (!ACPI_IS_ASCII ((UINT8) TableHeader.OemTableId[i]))
+        {
+            goto BadCharacters;
+        }
+    }
+
+    return (AE_OK);
+
+
+BadCharacters:
+
+    ACPI_WARNING ((AE_INFO,
+        "Table header for [%4.4s] has invalid ASCII character(s)",
+        TableHeader.Signature));
+    return (AE_OK);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcCheckTextModeCorruption
  *
  * PARAMETERS:  Table           - Table buffer starting with table header
  *
@@ -377,7 +555,7 @@ ErrorExit:
  ******************************************************************************/
 
 static ACPI_STATUS
-AcpiAcCheckTextModeCorruption (
+AcCheckTextModeCorruption (
     ACPI_TABLE_HEADER       *Table)
 {
     UINT32                  i;
diff --git a/src/acpica/source/common/adisasm.c b/src/acpica/source/common/adisasm.c
index 071649a..3b0b2c0 100644
--- a/src/acpica/source/common/adisasm.c
+++ b/src/acpica/source/common/adisasm.c
@@ -264,10 +264,12 @@ AdAmlDisassemble (
     {
         /* Get the list of all AML tables in the file */
 
-        Status = AcpiAcGetAllTablesFromFile (Filename,
+        Status = AcGetAllTablesFromFile (Filename,
             ACPI_GET_ALL_TABLES, &ListHead);
         if (ACPI_FAILURE (Status))
         {
+            AcpiOsPrintf ("Could not get ACPI tables from %s, %s\n",
+                Filename, AcpiFormatException (Status));
             return (Status);
         }
 
@@ -353,13 +355,12 @@ AdAmlDisassemble (
 
 Cleanup:
 
-// check!
-#if 0
-    if (Table && !AcpiGbl_ForceAmlDisassembly && !AcpiUtIsAmlTable (Table))
+    if (Table &&
+        !AcpiGbl_ForceAmlDisassembly &&
+        !AcpiUtIsAmlTable (Table))
     {
         ACPI_FREE (Table);
     }
-#endif
 
     if (File)
     {
@@ -664,7 +665,7 @@ AdDoExternalFileList (
         AcpiOsPrintf ("External object resolution file %16s\n",
             ExternalFilename);
 
-        Status = AcpiAcGetAllTablesFromFile (
+        Status = AcGetAllTablesFromFile (
             ExternalFilename, ACPI_GET_ONLY_AML_TABLES, &ExternalListHead);
         if (ACPI_FAILURE (Status))
         {
diff --git a/src/acpica/source/common/getopt.c b/src/acpica/source/common/getopt.c
new file mode 100644
index 0000000..23c4495
--- /dev/null
+++ b/src/acpica/source/common/getopt.c
@@ -0,0 +1,348 @@
+/******************************************************************************
+ *
+ * Module Name: getopt
+ *
+ *****************************************************************************/
+
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2015, Intel Corp.
+ * All rights reserved.
+ *
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************/
+
+/*
+ * ACPICA getopt() implementation
+ *
+ * Option strings:
+ *    "f"       - Option has no arguments
+ *    "f:"      - Option requires an argument
+ *    "f+"      - Option has an optional argument
+ *    "f^"      - Option has optional single-char sub-options
+ *    "f|"      - Option has required single-char sub-options
+ */
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acapps.h"
+
+#define ACPI_OPTION_ERROR(msg, badchar) \
+    if (AcpiGbl_Opterr) {AcpiLogError ("%s%c\n", msg, badchar);}
+
+
+int                 AcpiGbl_Opterr = 1;
+int                 AcpiGbl_Optind = 1;
+int                 AcpiGbl_SubOptChar = 0;
+char                *AcpiGbl_Optarg;
+
+static int          CurrentCharPtr = 1;
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiGetoptArgument
+ *
+ * PARAMETERS:  argc, argv          - from main
+ *
+ * RETURN:      0 if an argument was found, -1 otherwise. Sets AcpiGbl_Optarg
+ *              to point to the next argument.
+ *
+ * DESCRIPTION: Get the next argument. Used to obtain arguments for the
+ *              two-character options after the original call to AcpiGetopt.
+ *              Note: Either the argument starts at the next character after
+ *              the option, or it is pointed to by the next argv entry.
+ *              (After call to AcpiGetopt, we need to backup to the previous
+ *              argv entry).
+ *
+ ******************************************************************************/
+
+int
+AcpiGetoptArgument (
+    int                     argc,
+    char                    **argv)
+{
+
+    AcpiGbl_Optind--;
+    CurrentCharPtr++;
+
+    if (argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)] != '\0')
+    {
+        AcpiGbl_Optarg = &argv[AcpiGbl_Optind++][(int) (CurrentCharPtr+1)];
+    }
+    else if (++AcpiGbl_Optind >= argc)
+    {
+        ACPI_OPTION_ERROR ("Option requires an argument: -", 'v');
+
+        CurrentCharPtr = 1;
+        return (-1);
+    }
+    else
+    {
+        AcpiGbl_Optarg = argv[AcpiGbl_Optind++];
+    }
+
+    CurrentCharPtr = 1;
+    return (0);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiGetopt
+ *
+ * PARAMETERS:  argc, argv          - from main
+ *              opts                - options info list
+ *
+ * RETURN:      Option character or ACPI_OPT_END
+ *
+ * DESCRIPTION: Get the next option
+ *
+ ******************************************************************************/
+
+int
+AcpiGetopt(
+    int                     argc,
+    char                    **argv,
+    char                    *opts)
+{
+    int                     CurrentChar;
+    char                    *OptsPtr;
+
+
+    if (CurrentCharPtr == 1)
+    {
+        if (AcpiGbl_Optind >= argc ||
+            argv[AcpiGbl_Optind][0] != '-' ||
+            argv[AcpiGbl_Optind][1] == '\0')
+        {
+            return (ACPI_OPT_END);
+        }
+        else if (strcmp (argv[AcpiGbl_Optind], "--") == 0)
+        {
+            AcpiGbl_Optind++;
+            return (ACPI_OPT_END);
+        }
+    }
+
+    /* Get the option */
+
+    CurrentChar = argv[AcpiGbl_Optind][CurrentCharPtr];
+
+    /* Make sure that the option is legal */
+
+    if (CurrentChar == ':' ||
+       (OptsPtr = strchr (opts, CurrentChar)) == NULL)
+    {
+        ACPI_OPTION_ERROR ("Illegal option: -", CurrentChar);
+
+        if (argv[AcpiGbl_Optind][++CurrentCharPtr] == '\0')
+        {
+            AcpiGbl_Optind++;
+            CurrentCharPtr = 1;
+        }
+
+        return ('?');
+    }
+
+    /* Option requires an argument? */
+
+    if (*++OptsPtr == ':')
+    {
+        if (argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)] != '\0')
+        {
+            AcpiGbl_Optarg = &argv[AcpiGbl_Optind++][(int) (CurrentCharPtr+1)];
+        }
+        else if (++AcpiGbl_Optind >= argc)
+        {
+            ACPI_OPTION_ERROR (
+                "Option requires an argument: -", CurrentChar);
+
+            CurrentCharPtr = 1;
+            return ('?');
+        }
+        else
+        {
+            AcpiGbl_Optarg = argv[AcpiGbl_Optind++];
+        }
+
+        CurrentCharPtr = 1;
+    }
+
+    /* Option has an optional argument? */
+
+    else if (*OptsPtr == '+')
+    {
+        if (argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)] != '\0')
+        {
+            AcpiGbl_Optarg = &argv[AcpiGbl_Optind++][(int) (CurrentCharPtr+1)];
+        }
+        else if (++AcpiGbl_Optind >= argc)
+        {
+            AcpiGbl_Optarg = NULL;
+        }
+        else
+        {
+            AcpiGbl_Optarg = argv[AcpiGbl_Optind++];
+        }
+
+        CurrentCharPtr = 1;
+    }
+
+    /* Option has optional single-char arguments? */
+
+    else if (*OptsPtr == '^')
+    {
+        if (argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)] != '\0')
+        {
+            AcpiGbl_Optarg = &argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)];
+        }
+        else
+        {
+            AcpiGbl_Optarg = "^";
+        }
+
+        AcpiGbl_SubOptChar = AcpiGbl_Optarg[0];
+        AcpiGbl_Optind++;
+        CurrentCharPtr = 1;
+    }
+
+    /* Option has a required single-char argument? */
+
+    else if (*OptsPtr == '|')
+    {
+        if (argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)] != '\0')
+        {
+            AcpiGbl_Optarg = &argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)];
+        }
+        else
+        {
+            ACPI_OPTION_ERROR (
+                "Option requires a single-character suboption: -",
+                CurrentChar);
+
+            CurrentCharPtr = 1;
+            return ('?');
+        }
+
+        AcpiGbl_SubOptChar = AcpiGbl_Optarg[0];
+        AcpiGbl_Optind++;
+        CurrentCharPtr = 1;
+    }
+
+    /* Option with no arguments */
+
+    else
+    {
+        if (argv[AcpiGbl_Optind][++CurrentCharPtr] == '\0')
+        {
+            CurrentCharPtr = 1;
+            AcpiGbl_Optind++;
+        }
+
+        AcpiGbl_Optarg = NULL;
+    }
+
+    return (CurrentChar);
+}
diff --git a/src/acpica/source/compiler/Makefile.am b/src/acpica/source/compiler/Makefile.am
index d71068c..26968d2 100644
--- a/src/acpica/source/compiler/Makefile.am
+++ b/src/acpica/source/compiler/Makefile.am
@@ -212,6 +212,7 @@ libfwtsiasl_la_SOURCES = 			\
 	../common/dmtables.c			\
 	../common/dmtbinfo.c 			\
 	../common/dmtbdump.c 			\
+	../common/getopt.c			\
 	../components/debugger/dbfileio.c 	\
 	../components/disassembler/dmbuffer.c 	\
 	../components/disassembler/dmcstyle.c	\
diff --git a/src/acpica/source/compiler/aslascii.c b/src/acpica/source/compiler/aslascii.c
index 0037077..b3cf8aa 100644
--- a/src/acpica/source/compiler/aslascii.c
+++ b/src/acpica/source/compiler/aslascii.c
@@ -114,6 +114,7 @@
  *****************************************************************************/
 
 #include "aslcompiler.h"
+#include <actables.h>
 #include <acapps.h>
 
 #define _COMPONENT          ACPI_COMPILER
@@ -135,90 +136,7 @@ FlConsumeNewComment (
 
 /*******************************************************************************
  *
- * FUNCTION:    FlCheckForAcpiTable
- *
- * PARAMETERS:  Handle              - Open input file
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Determine if a file seems to be a binary ACPI table, via the
- *              following checks on what would be the table header:
- *              0) File must be at least as long as an ACPI_TABLE_HEADER
- *              1) The header length field must match the file size
- *              2) Signature, OemId, OemTableId, AslCompilerId must be ASCII
- *
- ******************************************************************************/
-
-ACPI_STATUS
-FlCheckForAcpiTable (
-    FILE                    *Handle)
-{
-    ACPI_TABLE_HEADER       Table;
-    UINT32                  FileSize;
-    size_t                  Actual;
-    UINT32                  i;
-
-
-    /* Read a potential table header */
-
-    Actual = fread (&Table, 1, sizeof (ACPI_TABLE_HEADER), Handle);
-    fseek (Handle, 0, SEEK_SET);
-
-    if (Actual < sizeof (ACPI_TABLE_HEADER))
-    {
-        return (AE_ERROR);
-    }
-
-    /* Header length field must match the file size */
-
-    FileSize = CmGetFileSize (Handle);
-    if (Table.Length != FileSize)
-    {
-        return (AE_ERROR);
-    }
-
-    /*
-     * These fields must be ASCII:
-     * Signature, OemId, OemTableId, AslCompilerId.
-     * We allow a NULL terminator in OemId and OemTableId.
-     */
-    for (i = 0; i < ACPI_NAME_SIZE; i++)
-    {
-        if (!ACPI_IS_ASCII ((UINT8) Table.Signature[i]))
-        {
-            return (AE_ERROR);
-        }
-
-        if (!ACPI_IS_ASCII ((UINT8) Table.AslCompilerId[i]))
-        {
-            return (AE_ERROR);
-        }
-    }
-
-    for (i = 0; (i < ACPI_OEM_ID_SIZE) && (Table.OemId[i]); i++)
-    {
-        if (!ACPI_IS_ASCII ((UINT8) Table.OemId[i]))
-        {
-            return (AE_ERROR);
-        }
-    }
-
-    for (i = 0; (i < ACPI_OEM_TABLE_ID_SIZE) && (Table.OemTableId[i]); i++)
-    {
-        if (!ACPI_IS_ASCII ((UINT8) Table.OemTableId[i]))
-        {
-            return (AE_ERROR);
-        }
-    }
-
-    printf ("Binary file appears to be a valid ACPI table, disassembling\n");
-    return (AE_OK);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    FlCheckForAscii
+ * FUNCTION:    FlIsFileAsciiSource
  *
  * PARAMETERS:  Filename            - Full input filename
  *              DisplayErrors       - TRUE if error messages desired
@@ -235,7 +153,7 @@ FlCheckForAcpiTable (
  ******************************************************************************/
 
 ACPI_STATUS
-FlCheckForAscii (
+FlIsFileAsciiSource (
     char                    *Filename,
     BOOLEAN                 DisplayErrors)
 {
diff --git a/src/acpica/source/compiler/aslcompiler.h b/src/acpica/source/compiler/aslcompiler.h
index 86a28ad..6c1dcea 100644
--- a/src/acpica/source/compiler/aslcompiler.h
+++ b/src/acpica/source/compiler/aslcompiler.h
@@ -239,11 +239,7 @@ CmDeleteCaches (
  * aslascii - ascii support
  */
 ACPI_STATUS
-FlCheckForAcpiTable (
-    FILE                    *Handle);
-
-ACPI_STATUS
-FlCheckForAscii (
+FlIsFileAsciiSource (
     char                    *Filename,
     BOOLEAN                 DisplayErrors);
 
@@ -813,6 +809,10 @@ TrSetEndLineNumber (
     ACPI_PARSE_OBJECT       *Op);
 
 void
+TrSetCurrentFilename (
+    ACPI_PARSE_OBJECT       *Op);
+
+void
 TrWalkTree (
     void);
 
@@ -995,6 +995,10 @@ DbgPrint (
 #define ASL_PARSE_OUTPUT    1
 #define ASL_TREE_OUTPUT     2
 
+BOOLEAN
+UtQueryForOverwrite (
+    char                    *Pathname);
+
 void
 UtDisplaySupportedTables (
     void);
@@ -1353,6 +1357,6 @@ DtDoCompile(
 
 ACPI_STATUS
 DtCreateTemplates (
-    char                    *Signature);
+    char                    **argv);
 
 #endif /*  __ASLCOMPILER_H */
diff --git a/src/acpica/source/compiler/aslcompiler.y b/src/acpica/source/compiler/aslcompiler.y
index 3a2b191..fd98308 100644
--- a/src/acpica/source/compiler/aslcompiler.y
+++ b/src/acpica/source/compiler/aslcompiler.y
@@ -1362,6 +1362,7 @@ String
 
 CompilerDirective
     : IncludeTerm                   {}
+    | IncludeEndTerm                {}
     | ExternalTerm                  {}
     ;
 
@@ -1968,14 +1969,13 @@ IfTerm
     ;
 
 IncludeTerm
-    : PARSEOP_INCLUDE '('           {$<n>$ = TrCreateLeafNode (PARSEOP_INCLUDE);}
-        String  ')'                 {TrLinkChildren ($<n>3,1,$4);FlOpenIncludeFile ($4);}
-        TermList
-        IncludeEndTerm              {$$ = TrLinkPeerNodes (3,$<n>3,$7,$8);}
+    : PARSEOP_INCLUDE '('
+        String  ')'                 {$$ = TrUpdateNode (PARSEOP_INCLUDE, $3);
+                                        FlOpenIncludeFile ($3);}
     ;
 
 IncludeEndTerm
-    : PARSEOP_INCLUDE_END           {$$ = TrCreateLeafNode (PARSEOP_INCLUDE_END);}
+    : PARSEOP_INCLUDE_END           {$<n>$ = TrCreateLeafNode (PARSEOP_INCLUDE_END); TrSetCurrentFilename ($$);}
     ;
 
 IncTerm
diff --git a/src/acpica/source/compiler/asldefine.h b/src/acpica/source/compiler/asldefine.h
index 87e4d35..f22d9bf 100644
--- a/src/acpica/source/compiler/asldefine.h
+++ b/src/acpica/source/compiler/asldefine.h
@@ -178,10 +178,10 @@
 
 /* Types for input files */
 
-#define ASL_INPUT_TYPE_BINARY       0
-#define ASL_INPUT_TYPE_ACPI_TABLE   1
-#define ASL_INPUT_TYPE_ASCII_ASL    2
-#define ASL_INPUT_TYPE_ASCII_DATA   3
+#define ASL_INPUT_TYPE_BINARY               0
+#define ASL_INPUT_TYPE_BINARY_ACPI_TABLE    1
+#define ASL_INPUT_TYPE_ASCII_ASL            2
+#define ASL_INPUT_TYPE_ASCII_DATA           3
 
 
 /* Misc */
diff --git a/src/acpica/source/compiler/aslfiles.c b/src/acpica/source/compiler/aslfiles.c
index 1c1b1d8..56a6117 100644
--- a/src/acpica/source/compiler/aslfiles.c
+++ b/src/acpica/source/compiler/aslfiles.c
@@ -408,6 +408,7 @@ FlOpenIncludeWithPrefix (
      */
     Gbl_CurrentLineNumber--;
     OriginalLineNumber = Gbl_CurrentLineNumber;
+
     while (DtGetNextLine (IncludeFile, DT_ALLOW_MULTILINE_QUOTES) != ASL_EOF)
     {
         if (Gbl_CurrentLineBuffer[0] == '#')
@@ -416,6 +417,7 @@ FlOpenIncludeWithPrefix (
                 Op, "use #include instead");
         }
     }
+
     Gbl_CurrentLineNumber = OriginalLineNumber;
 
     /* Must seek back to the start of the file */
@@ -642,7 +644,7 @@ FlOpenMiscOutputFiles (
 
     /* All done for disassembler */
 
-    if (Gbl_FileType == ASL_INPUT_TYPE_ACPI_TABLE)
+    if (Gbl_FileType == ASL_INPUT_TYPE_BINARY_ACPI_TABLE)
     {
         return (AE_OK);
     }
diff --git a/src/acpica/source/compiler/aslglobal.h b/src/acpica/source/compiler/aslglobal.h
index 9a9aba4..feb4d45 100644
--- a/src/acpica/source/compiler/aslglobal.h
+++ b/src/acpica/source/compiler/aslglobal.h
@@ -269,6 +269,7 @@ ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_OutputFilenamePrefix,
 ASL_EXTERN ASL_INCLUDE_DIR          ASL_INIT_GLOBAL (*Gbl_IncludeDirList, NULL);
 ASL_EXTERN char                     *Gbl_CurrentInputFilename;
 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_ExternalRefFilename, NULL);
+ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_PreviousIncludeFilename, NULL);
 
 ASL_EXTERN BOOLEAN                  ASL_INIT_GLOBAL (Gbl_HasIncludeFiles, FALSE);
 
@@ -318,7 +319,6 @@ ASL_EXTERN ASL_LISTING_NODE         ASL_INIT_GLOBAL (*Gbl_ListingNode, NULL);
 ASL_EXTERN ACPI_PARSE_OBJECT        *Gbl_FirstLevelInsertionNode;
 ASL_EXTERN UINT8                    ASL_INIT_GLOBAL (Gbl_FileType, 0);
 ASL_EXTERN char                     ASL_INIT_GLOBAL (*Gbl_Signature, NULL);
-ASL_EXTERN char                     *Gbl_TemplateSignature;
 
 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_CurrentHexColumn, 0);
 ASL_EXTERN UINT32                   ASL_INIT_GLOBAL (Gbl_CurrentAmlOffset, 0);
diff --git a/src/acpica/source/compiler/asllisting.c b/src/acpica/source/compiler/asllisting.c
index 6f76133..d30a0bd 100644
--- a/src/acpica/source/compiler/asllisting.c
+++ b/src/acpica/source/compiler/asllisting.c
@@ -349,6 +349,34 @@ LsTreeWriteWalk (
 
     UtPrintFormattedName (Op->Asl.ParseOpcode, Level);
 
+    if (Op->Asl.ParseOpcode == PARSEOP_NAMESEG)
+    {
+        DbgPrint (ASL_TREE_OUTPUT,
+            "%10.4s      ", Op->Asl.Value.Name);
+    }
+    else if ((Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
+        (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
+    {
+        DbgPrint (ASL_TREE_OUTPUT,
+            "%10.32s      ", Op->Asl.Value.String);
+    }
+    else if (Op->Asl.ParseOpcode == PARSEOP_INCLUDE)
+    {
+        DbgPrint (ASL_TREE_OUTPUT,
+            "Open: %s\n", Op->Asl.Value.String);
+        return (AE_OK);
+    }
+    else if (Op->Asl.ParseOpcode == PARSEOP_INCLUDE_END)
+    {
+        DbgPrint (ASL_TREE_OUTPUT,
+            "Close: %s\n", Op->Asl.Filename);
+        return (AE_OK);
+    }
+    else
+    {
+        DbgPrint (ASL_TREE_OUTPUT, "                ");
+    }
+
     DbgPrint (ASL_TREE_OUTPUT, "    (%.4X) Flags %8.8X",
         Op->Asl.ParseOpcode, Op->Asl.CompileFlags);
     TrPrintNodeCompileFlags (Op->Asl.CompileFlags);
@@ -500,7 +528,7 @@ LsWriteNodeToListing (
 
         /* Create a new listing node and push it */
 
-        LsPushNode (Op->Asl.Child->Asl.Value.String);
+        LsPushNode (Op->Asl.Value.String);
         return;
 
 
diff --git a/src/acpica/source/compiler/aslmain.c b/src/acpica/source/compiler/aslmain.c
index 0f90b1f..d1fb045 100644
--- a/src/acpica/source/compiler/aslmain.c
+++ b/src/acpica/source/compiler/aslmain.c
@@ -199,7 +199,8 @@ Usage (
     printf ("\nGeneral:\n");
     ACPI_OPTION ("-@ <file>",       "Specify command file");
     ACPI_OPTION ("-I <dir>",        "Specify additional include directory");
-    ACPI_OPTION ("-T <sig>|ALL|*",  "Create table template file for ACPI <Sig>");
+    ACPI_OPTION ("-T <sig list>|ALL",   "Create ACPI table template/example files");
+    ACPI_OPTION ("-T <count>",      "Emit DSDT and <count> SSDTs to same file");
     ACPI_OPTION ("-p <prefix>",     "Specify path/filename prefix for all output files");
     ACPI_OPTION ("-v",              "Display compiler version");
     ACPI_OPTION ("-vo",             "Enable optimization comments");
diff --git a/src/acpica/source/compiler/aslmap.c b/src/acpica/source/compiler/aslmap.c
index 50b84d1..aa1378f 100644
--- a/src/acpica/source/compiler/aslmap.c
+++ b/src/acpica/source/compiler/aslmap.c
@@ -385,7 +385,7 @@ const ASL_MAPPING_ENTRY     AslKeywordMapping [] =
 /* NOR */                       OP_TABLE_ENTRY (AML_BIT_NOR_OP,             0,                              0,                  ACPI_BTYPE_INTEGER),
 /* NOT */                       OP_TABLE_ENTRY (AML_BIT_NOT_OP,             0,                              0,                  ACPI_BTYPE_INTEGER),
 /* NOTIFY */                    OP_TABLE_ENTRY (AML_NOTIFY_OP,              0,                              0,                  0),
-/* OBJECTTYPE */                OP_TABLE_ENTRY (AML_TYPE_OP,                0,                              0,                  ACPI_BTYPE_INTEGER),
+/* OBJECTTYPE */                OP_TABLE_ENTRY (AML_OBJECT_TYPE_OP,         0,                              0,                  ACPI_BTYPE_INTEGER),
 /* OBJECTTYPE_BFF */            OP_TABLE_ENTRY (AML_BYTE_OP,                ACPI_TYPE_BUFFER_FIELD,         0,                  0),
 /* OBJECTTYPE_BUF */            OP_TABLE_ENTRY (AML_BYTE_OP,                ACPI_TYPE_BUFFER,               0,                  0),
 /* OBJECTTYPE_DDB */            OP_TABLE_ENTRY (AML_BYTE_OP,                ACPI_TYPE_DDB_HANDLE,           0,                  0),
diff --git a/src/acpica/source/compiler/aslopcodes.c b/src/acpica/source/compiler/aslopcodes.c
index 08dc4a4..a028979 100644
--- a/src/acpica/source/compiler/aslopcodes.c
+++ b/src/acpica/source/compiler/aslopcodes.c
@@ -1582,7 +1582,6 @@ OpcGenerateAmlOpcode (
 
     case PARSEOP_INCLUDE:
 
-        Op->Asl.Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
         Gbl_HasIncludeFiles = TRUE;
         break;
 
diff --git a/src/acpica/source/compiler/aslrules.y b/src/acpica/source/compiler/aslrules.y
index 4608f8d..fb6ccc8 100644
--- a/src/acpica/source/compiler/aslrules.y
+++ b/src/acpica/source/compiler/aslrules.y
@@ -499,6 +499,7 @@ String
 
 CompilerDirective
     : IncludeTerm                   {}
+    | IncludeEndTerm                {}
     | ExternalTerm                  {}
     ;
 
@@ -1105,14 +1106,13 @@ IfTerm
     ;
 
 IncludeTerm
-    : PARSEOP_INCLUDE '('           {$<n>$ = TrCreateLeafNode (PARSEOP_INCLUDE);}
-        String  ')'                 {TrLinkChildren ($<n>3,1,$4);FlOpenIncludeFile ($4);}
-        TermList
-        IncludeEndTerm              {$$ = TrLinkPeerNodes (3,$<n>3,$7,$8);}
+    : PARSEOP_INCLUDE '('
+        String  ')'                 {$$ = TrUpdateNode (PARSEOP_INCLUDE, $3);
+                                        FlOpenIncludeFile ($3);}
     ;
 
 IncludeEndTerm
-    : PARSEOP_INCLUDE_END           {$$ = TrCreateLeafNode (PARSEOP_INCLUDE_END);}
+    : PARSEOP_INCLUDE_END           {$<n>$ = TrCreateLeafNode (PARSEOP_INCLUDE_END); TrSetCurrentFilename ($$);}
     ;
 
 IncTerm
diff --git a/src/acpica/source/compiler/aslstartup.c b/src/acpica/source/compiler/aslstartup.c
index 684a3fc..c05b842 100644
--- a/src/acpica/source/compiler/aslstartup.c
+++ b/src/acpica/source/compiler/aslstartup.c
@@ -216,62 +216,63 @@ AslDetectSourceFileType (
     ASL_FILE_INFO           *Info)
 {
     char                    *FileChar;
-    UINT8                   Type;
+    UINT8                   Type = ASL_INPUT_TYPE_ASCII_DATA; /* default */
     ACPI_STATUS             Status;
 
 
-    /* Check for a valid binary ACPI table */
+    /* Check for 100% ASCII source file (comments are ignored) */
 
-    Status = FlCheckForAcpiTable (Info->Handle);
+    Status = FlIsFileAsciiSource (Info->Filename, FALSE);
     if (ACPI_SUCCESS (Status))
     {
-        Type = ASL_INPUT_TYPE_ACPI_TABLE;
-        goto Cleanup;
-    }
+        /*
+         * File contains ASCII source code. Determine if this is an ASL
+         * file or an ACPI data table file.
+         */
+        while (fgets (Gbl_CurrentLineBuffer, Gbl_LineBufferSize, Info->Handle))
+        {
+            /* Uppercase the buffer for caseless compare */
 
-    /* Check for 100% ASCII source file (comments are ignored) */
+            FileChar = Gbl_CurrentLineBuffer;
+            while (*FileChar)
+            {
+                *FileChar = (char) toupper ((int) *FileChar);
+                FileChar++;
+            }
 
-    Status = FlCheckForAscii (Info->Filename, TRUE);
-    if (ACPI_FAILURE (Status))
-    {
-        printf ("Invalid characters in input file - %s\n", Info->Filename);
+            /* Presence of "DefinitionBlock" indicates actual ASL code */
 
-        if (!Gbl_IgnoreErrors)
-        {
-            Type = ASL_INPUT_TYPE_BINARY;
-            goto Cleanup;
+            if (strstr (Gbl_CurrentLineBuffer, "DEFINITIONBLOCK"))
+            {
+                /* Appears to be an ASL file */
+
+                Type = ASL_INPUT_TYPE_ASCII_ASL;
+                goto Cleanup;
+            }
         }
-    }
 
-    /*
-     * File is ASCII. Determine if this is an ASL file or an ACPI data
-     * table file.
-     */
-    while (fgets (Gbl_CurrentLineBuffer, Gbl_LineBufferSize, Info->Handle))
-    {
-        /* Uppercase the buffer for caseless compare */
+        /* Appears to be an ASCII data table source file */
 
-        FileChar = Gbl_CurrentLineBuffer;
-        while (*FileChar)
-        {
-            *FileChar = (char) toupper ((int) *FileChar);
-            FileChar++;
-        }
+        Type = ASL_INPUT_TYPE_ASCII_DATA;
+        goto Cleanup;
+    }
 
-        /* Presence of "DefinitionBlock" indicates actual ASL code */
+    /* We have some sort of binary table, check for valid ACPI table */
 
-        if (strstr (Gbl_CurrentLineBuffer, "DEFINITIONBLOCK"))
-        {
-            /* Appears to be an ASL file */
+    fseek (Info->Handle, 0, SEEK_SET);
 
-            Type = ASL_INPUT_TYPE_ASCII_ASL;
-            goto Cleanup;
-        }
+    Status = AcValidateTableHeader (Info->Handle, 0);
+    if (ACPI_SUCCESS (Status))
+    {
+        fprintf (stderr,
+            "Binary file appears to be a valid ACPI table, disassembling\n");
+
+        Type = ASL_INPUT_TYPE_BINARY_ACPI_TABLE;
+        goto Cleanup;
     }
 
-    /* Not an ASL source file, default to a data table source file */
+    Type = ASL_INPUT_TYPE_BINARY;
 
-    Type = ASL_INPUT_TYPE_ASCII_DATA;
 
 Cleanup:
 
@@ -320,7 +321,7 @@ AslDoDisassembly (
 
     /* Handle additional output files for disassembler */
 
-    Gbl_FileType = ASL_INPUT_TYPE_ACPI_TABLE;
+    Gbl_FileType = ASL_INPUT_TYPE_BINARY_ACPI_TABLE;
     Status = FlOpenMiscOutputFiles (Gbl_OutputFilenamePrefix);
 
     /* This is where the disassembly happens */
@@ -526,7 +527,7 @@ AslDoOneFile (
     /*
      * Binary ACPI table was auto-detected, disassemble it
      */
-    case ASL_INPUT_TYPE_ACPI_TABLE:
+    case ASL_INPUT_TYPE_BINARY_ACPI_TABLE:
 
         /* We have what appears to be an ACPI table, disassemble it */
 
diff --git a/src/acpica/source/compiler/aslsupport.l b/src/acpica/source/compiler/aslsupport.l
index f1a7c59..fdfcdb6 100644
--- a/src/acpica/source/compiler/aslsupport.l
+++ b/src/acpica/source/compiler/aslsupport.l
@@ -268,9 +268,13 @@ AslPopInputFileStack (
     ASL_FILE_NODE           *Fnode;
 
 
+    Gbl_PreviousIncludeFilename = Gbl_Files[ASL_FILE_INPUT].Filename;
     Fnode = Gbl_IncludeFileStack;
     DbgPrint (ASL_PARSE_OUTPUT,
-        "\nPop InputFile Stack, Fnode %p\n\n", Fnode);
+        "\nPop InputFile Stack, Fnode %p\n", Fnode);
+
+    DbgPrint (ASL_PARSE_OUTPUT,
+        "Include: Closing \"%s\"\n\n", Gbl_Files[ASL_FILE_INPUT].Filename);
 
     if (!Fnode)
     {
diff --git a/src/acpica/source/compiler/asltree.c b/src/acpica/source/compiler/asltree.c
index 6948b5d..0690a17 100644
--- a/src/acpica/source/compiler/asltree.c
+++ b/src/acpica/source/compiler/asltree.c
@@ -229,10 +229,30 @@ TrReleaseNode (
 
 /*******************************************************************************
  *
+ * FUNCTION:    TrSetCurrentFilename
+ *
+ * PARAMETERS:  Op                  - An existing parse node
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Save the include file filename. Used for debug output only.
+ *
+ ******************************************************************************/
+
+void
+TrSetCurrentFilename (
+    ACPI_PARSE_OBJECT       *Op)
+{
+    Op->Asl.Filename = Gbl_PreviousIncludeFilename;
+}
+
+
+/*******************************************************************************
+ *
  * FUNCTION:    TrUpdateNode
  *
  * PARAMETERS:  ParseOpcode         - New opcode to be assigned to the node
- *              Op                - An existing parse node
+ *              Op                  - An existing parse node
  *
  * RETURN:      The updated node
  *
diff --git a/src/acpica/source/compiler/aslutils.c b/src/acpica/source/compiler/aslutils.c
index 374fe50..bff011f 100644
--- a/src/acpica/source/compiler/aslutils.c
+++ b/src/acpica/source/compiler/aslutils.c
@@ -118,7 +118,9 @@
 #include "acdisasm.h"
 #include "acnamesp.h"
 #include "amlcode.h"
-#include <acapps.h>
+#include "acapps.h"
+#include <sys/stat.h>
+
 
 #define _COMPONENT          ACPI_COMPILER
         ACPI_MODULE_NAME    ("aslutils")
@@ -137,6 +139,40 @@ UtAttachNameseg (
     char                    *Name);
 
 
+/******************************************************************************
+ *
+ * FUNCTION:    UtQueryForOverwrite
+ *
+ * PARAMETERS:  Pathname            - Output filename
+ *
+ * RETURN:      TRUE if file does not exist or overwrite is authorized
+ *
+ * DESCRIPTION: Query for file overwrite if it already exists.
+ *
+ ******************************************************************************/
+
+BOOLEAN
+UtQueryForOverwrite (
+    char                    *Pathname)
+{
+    struct stat             StatInfo;
+
+
+    if (!stat (Pathname, &StatInfo))
+    {
+        fprintf (stderr, "Target file \"%s\" already exists, overwrite? [y|n] ",
+            Pathname);
+
+        if (getchar () != 'y')
+        {
+            return (FALSE);
+        }
+    }
+
+    return (TRUE);
+}
+
+
 /*******************************************************************************
  *
  * FUNCTION:    UtDisplaySupportedTables
@@ -521,9 +557,11 @@ UtDisplaySummary (
             if (Gbl_Files[ASL_FILE_AML_OUTPUT].Handle)
             {
                 FlPrintFile (FileId,
-                    "%-14s %s - %u bytes, %u named objects, %u executable opcodes\n",
+                    "%-14s %s - %u bytes, %u named objects, "
+                    "%u executable opcodes\n",
                     "AML Output:",
-                    Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, Gbl_TableLength,
+                    Gbl_Files[ASL_FILE_AML_OUTPUT].Filename,
+                    FlGetFileSize (ASL_FILE_AML_OUTPUT),
                     TotalNamedObjects, TotalExecutableOpcodes);
             }
         }
diff --git a/src/acpica/source/compiler/aslwalks.c b/src/acpica/source/compiler/aslwalks.c
index 1675cad..4947c7e 100644
--- a/src/acpica/source/compiler/aslwalks.c
+++ b/src/acpica/source/compiler/aslwalks.c
@@ -931,21 +931,8 @@ AnAnalyzeStoreOperator (
     case PARSEOP_DEREFOF:
     case PARSEOP_REFOF:
     case PARSEOP_INDEX:
-
-        return;
-
     case PARSEOP_METHODCALL:
-        /*
-         * A target is not allowed to be a method call.
-         * It is technically allowed to be a method call, but this only
-         * makes sense in one case: if the method returns a reference object,
-         * which will then allow the Store to complete successfully.
-         * However, this is not supported by the ACPICA interpreter,
-         * and not supported by the MS ASL compiler
-         * at this time. (09/2015)
-         */
-        AslError (ASL_ERROR, ASL_MSG_UNSUPPORTED,
-            TargetOperandOp, "Method invocation cannot be a target");
+
         return;
 
     default:
diff --git a/src/acpica/source/compiler/dttemplate.c b/src/acpica/source/compiler/dttemplate.c
index 6e4c9f9..d1c4a5d 100644
--- a/src/acpica/source/compiler/dttemplate.c
+++ b/src/acpica/source/compiler/dttemplate.c
@@ -129,14 +129,27 @@ AcpiUtIsSpecialTable (
     char                    *Signature);
 
 static ACPI_STATUS
+DtCreateOneTemplateFile (
+    char                    *Signature,
+    UINT32                  TableCount);
+
+static ACPI_STATUS
 DtCreateOneTemplate (
     char                    *Signature,
+    UINT32                  TableCount,
     const ACPI_DMTABLE_DATA *TableData);
 
 static ACPI_STATUS
 DtCreateAllTemplates (
     void);
 
+static int
+DtEmitDefinitionBlock (
+    FILE                    *File,
+    char                    *Filename,
+    char                    *Signature,
+    UINT32                  Instance);
+
 
 /*******************************************************************************
  *
@@ -173,7 +186,7 @@ AcpiUtIsSpecialTable (
  *
  * FUNCTION:    DtCreateTemplates
  *
- * PARAMETERS:  Signature           - ACPI table signature
+ * PARAMETERS:  argv                - Standard command line arguments
  *
  * RETURN:      Status
  *
@@ -183,32 +196,115 @@ AcpiUtIsSpecialTable (
 
 ACPI_STATUS
 DtCreateTemplates (
-    char                    *Signature)
+    char                    **argv)
 {
-    const ACPI_DMTABLE_DATA *TableData;
-    ACPI_STATUS             Status;
+    char                    *Signature;
+    char                    *End;
+    unsigned long           TableCount;
+    ACPI_STATUS             Status = AE_OK;
 
 
     AslInitializeGlobals ();
 
-    /* Default (no signature) is DSDT */
+    Status = AdInitialize ();
+    if (ACPI_FAILURE (Status))
+    {
+        return (Status);
+    }
+
+    /*
+     * Special cases for DSDT, ALL, and '*'
+     */
+
+    /* Default (no signature option) is DSDT */
 
-    if (!Signature)
+    if (AcpiGbl_Optind < 3)
     {
-        Signature = "DSDT";
-        goto GetTemplate;
+        Status = DtCreateOneTemplateFile (ACPI_SIG_DSDT, 0);
+        goto Exit;
     }
 
+    AcpiGbl_Optind--;
+    Signature = argv[AcpiGbl_Optind];
     AcpiUtStrupr (Signature);
-    if (!strcmp (Signature, "ALL") ||
-        !strcmp (Signature, "*"))
+
+    /*
+     * Multiple SSDT support (-T <ssdt count>)
+     */
+    TableCount = strtoul (Signature, &End, 0);
+    if (Signature != End)
+    {
+        /* The count is used for table ID and method name - max is 254(+1) */
+
+        if (TableCount > 254)
+        {
+            fprintf (stderr, "%u SSDTs requested, maximum is 254\n",
+                (unsigned int) TableCount);
+
+            Status = AE_LIMIT;
+            goto Exit;
+        }
+
+        Status = DtCreateOneTemplateFile (ACPI_SIG_DSDT, TableCount);
+        goto Exit;
+    }
+
+    if (!strcmp (Signature, "ALL"))
     {
         /* Create all available/known templates */
 
         Status = DtCreateAllTemplates ();
-        return (Status);
+        goto Exit;
+    }
+
+    /*
+     * Normal case: Create template for each signature
+     */
+    while (argv[AcpiGbl_Optind])
+    {
+        Signature = argv[AcpiGbl_Optind];
+        AcpiUtStrupr (Signature);
+
+        Status = DtCreateOneTemplateFile (Signature, 0);
+        if (ACPI_FAILURE (Status))
+        {
+            goto Exit;
+        }
+
+        AcpiGbl_Optind++;
     }
 
+
+Exit:
+    /* Shutdown ACPICA subsystem */
+
+    (void) AcpiTerminate ();
+    CmDeleteCaches ();
+    return (Status);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    DtCreateOneTemplateFile
+ *
+ * PARAMETERS:  Signature           - ACPI table signature
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Create one template file of the requested signature.
+ *
+ ******************************************************************************/
+
+static ACPI_STATUS
+DtCreateOneTemplateFile (
+    char                    *Signature,
+    UINT32                  TableCount)
+{
+    const ACPI_DMTABLE_DATA *TableData;
+    ACPI_STATUS             Status;
+
+
     /*
      * Validate signature and get the template data:
      *  1) Signature must be 4 characters
@@ -218,8 +314,8 @@ DtCreateTemplates (
     if (strlen (Signature) != ACPI_NAME_SIZE)
     {
         fprintf (stderr,
-            "%s: Invalid ACPI table signature (length must be 4 characters)\n",
-            Signature);
+            "%s: Invalid ACPI table signature "
+            "(length must be 4 characters)\n", Signature);
         return (AE_ERROR);
     }
 
@@ -236,7 +332,8 @@ DtCreateTemplates (
         Signature = "FACP";
     }
 
-GetTemplate:
+    /* TableData will point to the template */
+
     TableData = AcpiDmGetTableData (Signature);
     if (TableData)
     {
@@ -253,18 +350,7 @@ GetTemplate:
         return (AE_ERROR);
     }
 
-    Status = AdInitialize ();
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
-    Status = DtCreateOneTemplate (Signature, TableData);
-
-    /* Shutdown ACPICA subsystem */
-
-    (void) AcpiTerminate ();
-    CmDeleteCaches ();
+    Status = DtCreateOneTemplate (Signature, TableCount, TableData);
     return (Status);
 }
 
@@ -289,12 +375,6 @@ DtCreateAllTemplates (
     ACPI_STATUS             Status;
 
 
-    Status = AdInitialize ();
-    if (ACPI_FAILURE (Status))
-    {
-        return (Status);
-    }
-
     fprintf (stderr, "Creating all supported Template files\n");
 
     /* Walk entire ACPI table data structure */
@@ -306,7 +386,7 @@ DtCreateAllTemplates (
         if (TableData->Template)
         {
             Status = DtCreateOneTemplate (TableData->Signature,
-                TableData);
+                0, TableData);
             if (ACPI_FAILURE (Status))
             {
                 return (Status);
@@ -319,25 +399,31 @@ DtCreateAllTemplates (
      * 1) DSDT/SSDT are AML tables, not data tables
      * 2) FACS and RSDP have non-standard headers
      */
-    Status = DtCreateOneTemplate (ACPI_SIG_DSDT, NULL);
+    Status = DtCreateOneTemplate (ACPI_SIG_DSDT, 0, NULL);
     if (ACPI_FAILURE (Status))
     {
         return (Status);
     }
 
-    Status = DtCreateOneTemplate (ACPI_SIG_SSDT, NULL);
+    Status = DtCreateOneTemplate (ACPI_SIG_SSDT, 0, NULL);
     if (ACPI_FAILURE (Status))
     {
         return (Status);
     }
 
-    Status = DtCreateOneTemplate (ACPI_SIG_FACS, NULL);
+    Status = DtCreateOneTemplate (ACPI_SIG_OSDT, 0, NULL);
     if (ACPI_FAILURE (Status))
     {
         return (Status);
     }
 
-    Status = DtCreateOneTemplate (ACPI_RSDP_NAME, NULL);
+    Status = DtCreateOneTemplate (ACPI_SIG_FACS, 0, NULL);
+    if (ACPI_FAILURE (Status))
+    {
+        return (Status);
+    }
+
+    Status = DtCreateOneTemplate (ACPI_RSDP_NAME, 0, NULL);
     if (ACPI_FAILURE (Status))
     {
         return (Status);
@@ -352,6 +438,7 @@ DtCreateAllTemplates (
  * FUNCTION:    DtCreateOneTemplate
  *
  * PARAMETERS:  Signature           - ACPI signature, NULL terminated.
+ *              TableCount          - Used for SSDTs in same file as DSDT
  *              TableData           - Entry in ACPI table data structure.
  *                                    NULL if a special ACPI table.
  *
@@ -364,12 +451,14 @@ DtCreateAllTemplates (
 static ACPI_STATUS
 DtCreateOneTemplate (
     char                    *Signature,
+    UINT32                  TableCount,
     const ACPI_DMTABLE_DATA  *TableData)
 {
     char                    *DisasmFilename;
     FILE                    *File;
     ACPI_STATUS             Status = AE_OK;
-    ACPI_SIZE               Actual;
+    int                     Actual;
+    UINT32                  i;
 
 
     /* New file will have a .asl suffix */
@@ -382,13 +471,17 @@ DtCreateOneTemplate (
         return (AE_ERROR);
     }
 
-    /* Probably should prompt to overwrite the file */
-
     AcpiUtStrlwr (DisasmFilename);
+    if (!UtQueryForOverwrite (DisasmFilename))
+    {
+        return (AE_ERROR);
+    }
+
     File = fopen (DisasmFilename, "w+");
     if (!File)
     {
-        fprintf (stderr, "Could not open output file %s\n", DisasmFilename);
+        fprintf (stderr, "Could not open output file %s\n",
+            DisasmFilename);
         return (AE_ERROR);
     }
 
@@ -399,8 +492,16 @@ DtCreateOneTemplate (
     AcpiOsPrintf ("/*\n");
     AcpiOsPrintf (ACPI_COMMON_HEADER ("iASL Compiler/Disassembler", " * "));
 
-    AcpiOsPrintf (" * Template for [%4.4s] ACPI Table",
-        Signature);
+    if (TableCount == 0)
+    {
+        AcpiOsPrintf (" * Template for [%4.4s] ACPI Table",
+            Signature);
+    }
+    else
+    {
+        AcpiOsPrintf (" * Template for [%4.4s] and %u [SSDT] ACPI Tables",
+            Signature, TableCount);
+    }
 
     /* Dump the actual ACPI table */
 
@@ -426,45 +527,55 @@ DtCreateOneTemplate (
     }
     else
     {
-        /* Special ACPI tables - DSDT, SSDT, OSDT, FADT, RSDP */
+        /* Special ACPI tables - DSDT, SSDT, OSDT, FACS, RSDP */
 
         AcpiOsPrintf (" (AML byte code table)\n");
-
         AcpiOsPrintf (" */\n");
+
         if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_DSDT))
         {
-            Actual = fwrite (TemplateDsdt, 1, sizeof (TemplateDsdt) -1, File);
-            if (Actual != sizeof (TemplateDsdt) -1)
+            Actual = DtEmitDefinitionBlock (
+                File, DisasmFilename, ACPI_SIG_DSDT, 1);
+            if (Actual < 0)
             {
-                fprintf (stderr,
-                    "Could not write to output file %s\n", DisasmFilename);
                 Status = AE_ERROR;
                 goto Cleanup;
             }
+
+            /* Emit any requested SSDTs into the same file */
+
+            for (i = 1; i <= TableCount; i++)
+            {
+                Actual = DtEmitDefinitionBlock (
+                    File, DisasmFilename, ACPI_SIG_SSDT, i + 1);
+                if (Actual < 0)
+                {
+                    Status = AE_ERROR;
+                    goto Cleanup;
+                }
+            }
         }
         else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_SSDT))
         {
-            Actual = fwrite (TemplateSsdt, 1, sizeof (TemplateSsdt) -1, File);
-            if (Actual != sizeof (TemplateSsdt) -1)
+            Actual = DtEmitDefinitionBlock (
+                File, DisasmFilename, ACPI_SIG_SSDT, 1);
+            if (Actual < 0)
             {
-                fprintf (stderr,
-                    "Could not write to output file %s\n", DisasmFilename);
                 Status = AE_ERROR;
                 goto Cleanup;
             }
         }
         else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_OSDT))
         {
-            Actual = fwrite (TemplateOsdt, 1, sizeof (TemplateOsdt) -1, File);
-            if (Actual != sizeof (TemplateOsdt) -1)
+            Actual = DtEmitDefinitionBlock (
+                File, DisasmFilename, ACPI_SIG_OSDT, 1);
+            if (Actual < 0)
             {
-                fprintf (stderr,
-                    "Could not write to output file %s\n", DisasmFilename);
                 Status = AE_ERROR;
                 goto Cleanup;
             }
         }
-        else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS)) /* FADT */
+        else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_FACS))
         {
             AcpiDmDumpDataTable (ACPI_CAST_PTR (ACPI_TABLE_HEADER,
                 TemplateFacs));
@@ -483,12 +594,72 @@ DtCreateOneTemplate (
         }
     }
 
-    fprintf (stderr,
-        "Created ACPI table template for [%4.4s], written to \"%s\"\n",
-        Signature, DisasmFilename);
+    if (TableCount == 0)
+    {
+        fprintf (stderr,
+            "Created ACPI table template for [%4.4s], "
+            "written to \"%s\"\n",
+            Signature, DisasmFilename);
+    }
+    else
+    {
+        fprintf (stderr,
+            "Created ACPI table templates for [%4.4s] "
+            "and %u [SSDT], written to \"%s\"\n",
+            Signature, TableCount, DisasmFilename);
+    }
 
 Cleanup:
     fclose (File);
     AcpiOsRedirectOutput (stdout);
     return (Status);
 }
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    DtEmitDefinitionBlock
+ *
+ * PARAMETERS:  File                - An open file for the block
+ *              Filename            - Filename for same, for error msg(s)
+ *              Signature           - ACPI signature for the block
+ *              Instance            - Used for multiple SSDTs in the same file
+ *
+ * RETURN:      Status from fprintf
+ *
+ * DESCRIPTION: Emit the raw ASL for a complete Definition Block (DSDT or SSDT)
+ *
+ * Note: The AMLFileName parameter for DefinitionBlock is left as a NULL
+ * string. This allows the compiler to create the output AML filename from
+ * the input filename.
+ *
+ ******************************************************************************/
+
+static int
+DtEmitDefinitionBlock (
+    FILE                    *File,
+    char                    *Filename,
+    char                    *Signature,
+    UINT32                  Instance)
+{
+    int                     Status;
+
+
+    Status = fprintf (File,
+        "DefinitionBlock (\"\", \"%4.4s\", 2, \"Intel\", \"_%4.4s_%.2X\", 0x00000001)\n"
+        "{\n"
+        "    Method (%2.2s%.2X)\n"
+        "    {\n"
+        "    }\n"
+        "}\n\n",
+        Signature, Signature, Instance, Signature, Instance);
+
+    if (Status < 0)
+    {
+        fprintf (stderr,
+            "Could not write %4.4s to output file %s\n",
+            Signature, Filename);
+    }
+
+    return (Status);
+}
diff --git a/src/acpica/source/compiler/dttemplate.h b/src/acpica/source/compiler/dttemplate.h
index 4f158b9..dc73493 100644
--- a/src/acpica/source/compiler/dttemplate.h
+++ b/src/acpica/source/compiler/dttemplate.h
@@ -117,36 +117,6 @@
 #define __DTTEMPLATE_H
 
 
-/* Special templates for the ASL/AML tables: DSDT, SSDT, and OSDT */
-
-const char TemplateDsdt[] =
-    "DefinitionBlock (\"dsdt.aml\", \"DSDT\", 2, \"Intel\", \"Template\", 0x00000001)\n"
-    "{\n"
-    "    Method (MAIN, 0, NotSerialized)\n"
-    "    {\n"
-    "        Return (Zero)\n"
-    "    }\n"
-    "}\n\n";
-
-const char TemplateSsdt[] =
-    "DefinitionBlock (\"ssdt.aml\", \"SSDT\", 2, \"Intel\", \"Template\", 0x00000001)\n"
-    "{\n"
-    "    Method (MAIN, 0, NotSerialized)\n"
-    "    {\n"
-    "        Return (Zero)\n"
-    "    }\n"
-    "}\n\n";
-
-const char TemplateOsdt[] =
-    "DefinitionBlock (\"osdt.aml\", \"OSDT\", 2, \"Intel\", \"Template\", 0x00000001)\n"
-    "{\n"
-    "    Method (MAIN, 0, NotSerialized)\n"
-    "    {\n"
-    "        Return (Zero)\n"
-    "    }\n"
-    "}\n\n";
-
-
 /* Templates for ACPI data tables */
 
 const unsigned char TemplateAsf[] =
diff --git a/src/acpica/source/components/debugger/dbdisply.c b/src/acpica/source/components/debugger/dbdisply.c
index 1fa02a1..a923b6e 100644
--- a/src/acpica/source/components/debugger/dbdisply.c
+++ b/src/acpica/source/components/debugger/dbdisply.c
@@ -120,6 +120,7 @@
 #include "acnamesp.h"
 #include "acparser.h"
 #include "acinterp.h"
+#include "acevents.h"
 #include "acdebug.h"
 
 
@@ -1106,26 +1107,21 @@ AcpiDbDisplayHandlers (
         for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_SpaceIdList); i++)
         {
             SpaceId = AcpiGbl_SpaceIdList[i];
-            HandlerObj = ObjDesc->Device.Handler;
 
             AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
                 AcpiUtGetRegionName ((UINT8) SpaceId), SpaceId);
 
-            while (HandlerObj)
+            HandlerObj = AcpiEvFindRegionHandler (
+                SpaceId, ObjDesc->CommonNotify.Handler);
+            if (HandlerObj)
             {
-                if (AcpiGbl_SpaceIdList[i] ==
-                    HandlerObj->AddressSpace.SpaceId)
-                {
-                    AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,
-                        (HandlerObj->AddressSpace.HandlerFlags &
-                            ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ?
-                            "Default" : "User",
-                        HandlerObj->AddressSpace.Handler);
-
-                    goto FoundHandler;
-                }
+                AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,
+                    (HandlerObj->AddressSpace.HandlerFlags &
+                        ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ?
+                        "Default" : "User",
+                    HandlerObj->AddressSpace.Handler);
 
-                HandlerObj = HandlerObj->AddressSpace.Next;
+                goto FoundHandler;
             }
 
             /* There is no handler for this SpaceId */
@@ -1137,7 +1133,7 @@ AcpiDbDisplayHandlers (
 
         /* Find all handlers for user-defined SpaceIDs */
 
-        HandlerObj = ObjDesc->Device.Handler;
+        HandlerObj = ObjDesc->CommonNotify.Handler;
         while (HandlerObj)
         {
             if (HandlerObj->AddressSpace.SpaceId >= ACPI_USER_REGION_BEGIN)
@@ -1248,7 +1244,7 @@ AcpiDbDisplayNonRootHandlers (
 
     /* Display all handlers associated with this device */
 
-    HandlerObj = ObjDesc->Device.Handler;
+    HandlerObj = ObjDesc->CommonNotify.Handler;
     while (HandlerObj)
     {
         AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,
diff --git a/src/acpica/source/components/debugger/dbinput.c b/src/acpica/source/components/debugger/dbinput.c
index a051e78..0f1421e 100644
--- a/src/acpica/source/components/debugger/dbinput.c
+++ b/src/acpica/source/components/debugger/dbinput.c
@@ -1194,7 +1194,7 @@ AcpiDbCommandDispatch (
         {
             ACPI_NEW_TABLE_DESC     *ListHead = NULL;
 
-            Status = AcpiAcGetAllTablesFromFile (AcpiGbl_DbArgs[1],
+            Status = AcGetAllTablesFromFile (AcpiGbl_DbArgs[1],
                 ACPI_GET_ALL_TABLES, &ListHead);
             if (ACPI_SUCCESS (Status))
             {
diff --git a/src/acpica/source/components/disassembler/dmopcode.c b/src/acpica/source/components/disassembler/dmopcode.c
index 68dda89..272d787 100644
--- a/src/acpica/source/components/disassembler/dmopcode.c
+++ b/src/acpica/source/components/disassembler/dmopcode.c
@@ -132,6 +132,10 @@ static void
 AcpiDmMatchKeyword (
     ACPI_PARSE_OBJECT       *Op);
 
+static void
+AcpiDmConvertToElseIf (
+    ACPI_PARSE_OBJECT       *Op);
+
 
 /*******************************************************************************
  *
@@ -755,6 +759,11 @@ AcpiDmDisassembleOneOp (
         return;
     }
 
+    if (Op->Common.DisasmFlags & ACPI_PARSEOP_ELSEIF)
+    {
+        return; /* ElseIf macro was already emitted */
+    }
+
     switch (Op->Common.DisasmOpcode)
     {
     case ACPI_DASM_MATCHOP:
@@ -1027,6 +1036,11 @@ AcpiDmDisassembleOneOp (
         AcpiDmNamestring (Op->Common.Value.Name);
         break;
 
+    case AML_ELSE_OP:
+
+        AcpiDmConvertToElseIf (Op);
+        break;
+
     default:
 
         /* Just get the opcode name and print it */
@@ -1051,3 +1065,113 @@ AcpiDmDisassembleOneOp (
         break;
     }
 }
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmConvertToElseIf
+ *
+ * PARAMETERS:  OriginalElseOp          - ELSE Object to be examined
+ *
+ * RETURN:      None. Emits either an "Else" or an "ElseIf" ASL operator.
+ *
+ * DESCRIPTION: Detect and convert an If..Else..If sequence to If..ElseIf
+ *
+ * EXAMPLE:
+ *
+ * This If..Else..If nested sequence:
+ *
+ *        If (Arg0 == 1)
+ *        {
+ *            Local0 = 4
+ *        }
+ *        Else
+ *        {
+ *            If (Arg0 == 2)
+ *            {
+ *                Local0 = 5
+ *            }
+ *        }
+ *
+ * Is converted to this simpler If..ElseIf sequence:
+ *
+ *        If (Arg0 == 1)
+ *        {
+ *            Local0 = 4
+ *        }
+ *        ElseIf (Arg0 == 2)
+ *        {
+ *            Local0 = 5
+ *        }
+ *
+ * NOTE: There is no actual ElseIf AML opcode. ElseIf is essentially an ASL
+ * macro that emits an Else opcode followed by an If opcode. This function
+ * reverses these AML sequences back to an ElseIf macro where possible. This
+ * can make the disassembled ASL code simpler and more like the original code.
+ *
+ ******************************************************************************/
+
+static void
+AcpiDmConvertToElseIf (
+    ACPI_PARSE_OBJECT       *OriginalElseOp)
+{
+    ACPI_PARSE_OBJECT       *IfOp;
+    ACPI_PARSE_OBJECT       *ElseOp;
+
+
+    /* Examine the first child of the Else */
+
+    IfOp = OriginalElseOp->Common.Value.Arg;
+    if (!IfOp || (IfOp->Common.AmlOpcode != AML_IF_OP))
+    {
+        /* Not an Else..If sequence, cannot convert to ElseIf */
+
+        AcpiOsPrintf ("%s", "Else");
+        return;
+    }
+
+    /* Emit ElseIf, mark the IF as now an ELSEIF */
+
+    AcpiOsPrintf ("%s", "ElseIf");
+    IfOp->Common.DisasmFlags |= ACPI_PARSEOP_ELSEIF;
+
+    /* The IF parent will now be the same as the original ELSE parent */
+
+    IfOp->Common.Parent = OriginalElseOp->Common.Parent;
+
+    /*
+     * Update the NEXT pointers to restructure the parse tree, essentially
+     * promoting an If..Else block up to the same level as the original
+     * Else.
+     *
+     * Check if the IF has a corresponding ELSE peer
+     */
+    ElseOp = IfOp->Common.Next;
+    if (ElseOp &&
+        (ElseOp->Common.AmlOpcode == AML_ELSE_OP))
+    {
+        /* If an ELSE matches the IF, promote it also */
+
+        ElseOp->Common.Parent = OriginalElseOp->Common.Parent;
+        ElseOp->Common.Next = OriginalElseOp->Common.Next;
+    }
+    else
+    {
+        /* Otherwise, set the IF NEXT to the original ELSE NEXT */
+
+        IfOp->Common.Next = OriginalElseOp->Common.Next;
+    }
+
+    /* Detach the child IF block from the original ELSE */
+
+    OriginalElseOp->Common.Value.Arg = NULL;
+
+    /* Ignore the original ELSE from now on */
+
+    OriginalElseOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+    OriginalElseOp->Common.DisasmOpcode = ACPI_DASM_LNOT_PREFIX;
+
+    /* Insert IF (now ELSEIF) as next peer of the original ELSE */
+
+    OriginalElseOp->Common.Next = IfOp;
+}
diff --git a/src/acpica/source/components/disassembler/dmwalk.c b/src/acpica/source/components/disassembler/dmwalk.c
index ccc1200..bcb5fad 100644
--- a/src/acpica/source/components/disassembler/dmwalk.c
+++ b/src/acpica/source/components/disassembler/dmwalk.c
@@ -560,39 +560,40 @@ AcpiDmDescendingOp (
     }
     else if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
          (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) &&
+         (!(Op->Common.DisasmFlags & ACPI_PARSEOP_ELSEIF)) &&
          (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))
     {
+        /*
+         * This is a first-level element of a term list,
+         * indent a new line
+         */
+        switch (Op->Common.AmlOpcode)
+        {
+        case AML_NOOP_OP:
             /*
-             * This is a first-level element of a term list,
-             * indent a new line
+             * Optionally just ignore this opcode. Some tables use
+             * NoOp opcodes for "padding" out packages that the BIOS
+             * changes dynamically. This can leave hundreds or
+             * thousands of NoOp opcodes that if disassembled,
+             * cannot be compiled because they are syntactically
+             * incorrect.
              */
-            switch (Op->Common.AmlOpcode)
+            if (AcpiGbl_IgnoreNoopOperator)
             {
-            case AML_NOOP_OP:
-                /*
-                 * Optionally just ignore this opcode. Some tables use
-                 * NoOp opcodes for "padding" out packages that the BIOS
-                 * changes dynamically. This can leave hundreds or
-                 * thousands of NoOp opcodes that if disassembled,
-                 * cannot be compiled because they are syntactically
-                 * incorrect.
-                 */
-                if (AcpiGbl_IgnoreNoopOperator)
-                {
-                    Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
-                    return (AE_OK);
-                }
+                Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+                return (AE_OK);
+            }
 
-                /* Fallthrough */
+            /* Fallthrough */
 
-            default:
+        default:
 
-                AcpiDmIndent (Level);
-                break;
-            }
+            AcpiDmIndent (Level);
+            break;
+        }
 
-            Info->LastLevel = Level;
-            Info->Count = 0;
+        Info->LastLevel = Level;
+        Info->Count = 0;
     }
 
     /*
diff --git a/src/acpica/source/components/dispatcher/dsinit.c b/src/acpica/source/components/dispatcher/dsinit.c
index 4d30879..e153717 100644
--- a/src/acpica/source/components/dispatcher/dsinit.c
+++ b/src/acpica/source/components/dispatcher/dsinit.c
@@ -338,7 +338,7 @@ AcpiDsInitializeObjects (
     /* Summary of objects initialized */
 
     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
-        "Table [%4.4s:%8.8s] (id %.2X) - %4u Objects with %3u Devices, "
+        "Table [%4.4s: %-8.8s] (id %.2X) - %4u Objects with %3u Devices, "
         "%3u Regions, %4u Methods (%u/%u/%u Serial/Non/Cvt)\n",
         Table->Signature, Table->OemTableId, OwnerId, Info.ObjectCount,
         Info.DeviceCount,Info.OpRegionCount, Info.MethodCount,
diff --git a/src/acpica/source/components/events/evhandler.c b/src/acpica/source/components/events/evhandler.c
index 4375e7c..f7dff8d 100644
--- a/src/acpica/source/components/events/evhandler.c
+++ b/src/acpica/source/components/events/evhandler.c
@@ -132,6 +132,7 @@ AcpiEvInstallHandler (
     void                    *Context,
     void                    **ReturnValue);
 
+
 /* These are the address spaces that will get default handlers */
 
 UINT8        AcpiGbl_DefaultAddressSpaces[ACPI_NUM_DEFAULT_SPACES] =
@@ -247,7 +248,7 @@ AcpiEvHasDefaultHandler (
     ObjDesc = AcpiNsGetAttachedObject (Node);
     if (ObjDesc)
     {
-        HandlerObj = ObjDesc->Device.Handler;
+        HandlerObj = ObjDesc->CommonNotify.Handler;
 
         /* Walk the linked list of handlers for this object */
 
@@ -348,33 +349,25 @@ AcpiEvInstallHandler (
     {
         /* Check if this Device already has a handler for this address space */
 
-        NextHandlerObj = ObjDesc->Device.Handler;
-        while (NextHandlerObj)
+        NextHandlerObj = AcpiEvFindRegionHandler (
+            HandlerObj->AddressSpace.SpaceId, ObjDesc->CommonNotify.Handler);
+        if (NextHandlerObj)
         {
             /* Found a handler, is it for the same address space? */
 
-            if (NextHandlerObj->AddressSpace.SpaceId ==
-                HandlerObj->AddressSpace.SpaceId)
-            {
-                ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
-                    "Found handler for region [%s] in device %p(%p) "
-                    "handler %p\n",
-                    AcpiUtGetRegionName (HandlerObj->AddressSpace.SpaceId),
-                    ObjDesc, NextHandlerObj, HandlerObj));
-
-                /*
-                 * Since the object we found it on was a device, then it
-                 * means that someone has already installed a handler for
-                 * the branch of the namespace from this device on. Just
-                 * bail out telling the walk routine to not traverse this
-                 * branch. This preserves the scoping rule for handlers.
-                 */
-                return (AE_CTRL_DEPTH);
-            }
-
-            /* Walk the linked list of handlers attached to this device */
-
-            NextHandlerObj = NextHandlerObj->AddressSpace.Next;
+            ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+                "Found handler for region [%s] in device %p(%p) handler %p\n",
+                AcpiUtGetRegionName (HandlerObj->AddressSpace.SpaceId),
+                ObjDesc, NextHandlerObj, HandlerObj));
+
+            /*
+             * Since the object we found it on was a device, then it means
+             * that someone has already installed a handler for the branch
+             * of the namespace from this device on. Just bail out telling
+             * the walk routine to not traverse this branch. This preserves
+             * the scoping rule for handlers.
+             */
+            return (AE_CTRL_DEPTH);
         }
 
         /*
@@ -409,6 +402,46 @@ AcpiEvInstallHandler (
 
 /*******************************************************************************
  *
+ * FUNCTION:    AcpiEvFindRegionHandler
+ *
+ * PARAMETERS:  SpaceId         - The address space ID
+ *              HandlerObj      - Head of the handler object list
+ *
+ * RETURN:      Matching handler object. NULL if space ID not matched
+ *
+ * DESCRIPTION: Search a handler object list for a match on the address
+ *              space ID.
+ *
+ ******************************************************************************/
+
+ACPI_OPERAND_OBJECT *
+AcpiEvFindRegionHandler (
+    ACPI_ADR_SPACE_TYPE     SpaceId,
+    ACPI_OPERAND_OBJECT     *HandlerObj)
+{
+
+    /* Walk the handler list for this device */
+
+    while (HandlerObj)
+    {
+        /* Same SpaceId indicates a handler is installed */
+
+        if (HandlerObj->AddressSpace.SpaceId == SpaceId)
+        {
+            return (HandlerObj);
+        }
+
+        /* Next handler object */
+
+        HandlerObj = HandlerObj->AddressSpace.Next;
+    }
+
+    return (NULL);
+}
+
+
+/*******************************************************************************
+ *
  * FUNCTION:    AcpiEvInstallSpaceHandler
  *
  * PARAMETERS:  Node            - Namespace node for the device
@@ -434,17 +467,16 @@ AcpiEvInstallSpaceHandler (
 {
     ACPI_OPERAND_OBJECT     *ObjDesc;
     ACPI_OPERAND_OBJECT     *HandlerObj;
-    ACPI_STATUS             Status;
+    ACPI_STATUS             Status = AE_OK;
     ACPI_OBJECT_TYPE        Type;
-    UINT8                  Flags = 0;
+    UINT8                   Flags = 0;
 
 
     ACPI_FUNCTION_TRACE (EvInstallSpaceHandler);
 
-
     /*
-     * This registration is valid for only the types below and the root. This
-     * is where the default handlers get placed.
+     * This registration is valid for only the types below and the root.
+     * The root node is where the default handlers get installed.
      */
     if ((Node->Type != ACPI_TYPE_DEVICE)     &&
         (Node->Type != ACPI_TYPE_PROCESSOR)  &&
@@ -517,47 +549,39 @@ AcpiEvInstallSpaceHandler (
     if (ObjDesc)
     {
         /*
-         * The attached device object already exists. Make sure the handler
-         * is not already installed.
+         * The attached device object already exists. Now make sure
+         * the handler is not already installed.
          */
-        HandlerObj = ObjDesc->Device.Handler;
+        HandlerObj = AcpiEvFindRegionHandler (SpaceId,
+            ObjDesc->CommonNotify.Handler);
 
-        /* Walk the handler list for this device */
-
-        while (HandlerObj)
+        if (HandlerObj)
         {
-            /* Same SpaceId indicates a handler already installed */
-
-            if (HandlerObj->AddressSpace.SpaceId == SpaceId)
+            if (HandlerObj->AddressSpace.Handler == Handler)
             {
-                if (HandlerObj->AddressSpace.Handler == Handler)
-                {
-                    /*
-                     * It is (relatively) OK to attempt to install the SAME
-                     * handler twice. This can easily happen with the
-                     * PCI_Config space.
-                     */
-                    Status = AE_SAME_HANDLER;
-                    goto UnlockAndExit;
-                }
-                else
-                {
-                    /* A handler is already installed */
-
-                    Status = AE_ALREADY_EXISTS;
-                }
+                /*
+                 * It is (relatively) OK to attempt to install the SAME
+                 * handler twice. This can easily happen with the
+                 * PCI_Config space.
+                 */
+                Status = AE_SAME_HANDLER;
                 goto UnlockAndExit;
             }
+            else
+            {
+                /* A handler is already installed */
 
-            /* Walk the linked list of handlers */
+                Status = AE_ALREADY_EXISTS;
+            }
 
-            HandlerObj = HandlerObj->AddressSpace.Next;
+            goto UnlockAndExit;
         }
     }
     else
     {
         ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
-            "Creating object on Device %p while installing handler\n", Node));
+            "Creating object on Device %p while installing handler\n",
+            Node));
 
         /* ObjDesc does not exist, create one */
 
@@ -596,7 +620,8 @@ AcpiEvInstallSpaceHandler (
     }
 
     ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
-        "Installing address handler for region %s(%X) on Device %4.4s %p(%p)\n",
+        "Installing address handler for region %s(%X) "
+        "on Device %4.4s %p(%p)\n",
         AcpiUtGetRegionName (SpaceId), SpaceId,
         AcpiUtGetNodeName (Node), Node, ObjDesc));
 
@@ -621,33 +646,31 @@ AcpiEvInstallSpaceHandler (
     HandlerObj->AddressSpace.Node = Node;
     HandlerObj->AddressSpace.Handler = Handler;
     HandlerObj->AddressSpace.Context = Context;
-    HandlerObj->AddressSpace.Setup  = Setup;
+    HandlerObj->AddressSpace.Setup = Setup;
 
     /* Install at head of Device.AddressSpace list */
 
-    HandlerObj->AddressSpace.Next = ObjDesc->Device.Handler;
+    HandlerObj->AddressSpace.Next = ObjDesc->CommonNotify.Handler;
 
     /*
      * The Device object is the first reference on the HandlerObj.
      * Each region that uses the handler adds a reference.
      */
-    ObjDesc->Device.Handler = HandlerObj;
+    ObjDesc->CommonNotify.Handler = HandlerObj;
 
     /*
-     * Walk the namespace finding all of the regions this
-     * handler will manage.
+     * Walk the namespace finding all of the regions this handler will
+     * manage.
      *
-     * Start at the device and search the branch toward
-     * the leaf nodes until either the leaf is encountered or
-     * a device is detected that has an address handler of the
-     * same type.
+     * Start at the device and search the branch toward the leaf nodes
+     * until either the leaf is encountered or a device is detected that
+     * has an address handler of the same type.
      *
-     * In either case, back up and search down the remainder
-     * of the branch
+     * In either case, back up and search down the remainder of the branch
      */
-    Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX,
-        ACPI_NS_WALK_UNLOCK, AcpiEvInstallHandler, NULL,
-        HandlerObj, NULL);
+    Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node,
+        ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
+        AcpiEvInstallHandler, NULL, HandlerObj, NULL);
 
 UnlockAndExit:
     return_ACPI_STATUS (Status);
diff --git a/src/acpica/source/components/events/evregion.c b/src/acpica/source/components/events/evregion.c
index 2b00616..c251b9b 100644
--- a/src/acpica/source/components/events/evregion.c
+++ b/src/acpica/source/components/events/evregion.c
@@ -171,6 +171,7 @@ AcpiEvInitializeOpRegions (
 
     /* Run the _REG methods for OpRegions in each default address space */
 
+    AcpiGbl_RegMethodsEnabled = TRUE;
     for (i = 0; i < ACPI_NUM_DEFAULT_SPACES; i++)
     {
         /*
@@ -181,13 +182,11 @@ AcpiEvInitializeOpRegions (
         if (AcpiEvHasDefaultHandler (AcpiGbl_RootNode,
                AcpiGbl_DefaultAddressSpaces[i]))
         {
-            Status = AcpiEvExecuteRegMethods (AcpiGbl_RootNode,
-                AcpiGbl_DefaultAddressSpaces[i]);
+            AcpiEvExecuteRegMethods (AcpiGbl_RootNode,
+                AcpiGbl_DefaultAddressSpaces[i], ACPI_REG_CONNECT);
         }
     }
 
-    AcpiGbl_RegMethodsExecuted = TRUE;
-
     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
     return_ACPI_STATUS (Status);
 }
@@ -210,6 +209,12 @@ AcpiEvInitializeOpRegions (
  * DESCRIPTION: Dispatch an address space or operation region access to
  *              a previously installed handler.
  *
+ * NOTE: During early initialization, we always install the default region
+ * handlers for Memory, I/O and PCI_Config. This ensures that these operation
+ * region address spaces are always available as per the ACPI specification.
+ * This is especially needed in order to support the execution of
+ * module-level AML code during loading of the ACPI tables.
+ *
  ******************************************************************************/
 
 ACPI_STATUS
@@ -392,7 +397,7 @@ AcpiEvAddressSpaceDispatch (
          * We just returned from a non-default handler, we must re-enter the
          * interpreter
          */
-       AcpiExEnterInterpreter ();
+        AcpiExEnterInterpreter ();
     }
 
     return_ACPI_STATUS (Status);
@@ -414,7 +419,7 @@ AcpiEvAddressSpaceDispatch (
  ******************************************************************************/
 
 void
-AcpiEvDetachRegion(
+AcpiEvDetachRegion (
     ACPI_OPERAND_OBJECT     *RegionObj,
     BOOLEAN                 AcpiNsIsLocked)
 {
@@ -593,6 +598,13 @@ AcpiEvAttachRegion (
     ACPI_FUNCTION_TRACE (EvAttachRegion);
 
 
+    /* Install the region's handler */
+
+    if (RegionObj->Region.Handler)
+    {
+        return_ACPI_STATUS (AE_ALREADY_EXISTS);
+    }
+
     ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
         "Adding Region [%4.4s] %p to address handler %p [%s]\n",
         AcpiUtGetNodeName (RegionObj->Region.Node),
@@ -603,18 +615,62 @@ AcpiEvAttachRegion (
 
     RegionObj->Region.Next = HandlerObj->AddressSpace.RegionList;
     HandlerObj->AddressSpace.RegionList = RegionObj;
+    RegionObj->Region.Handler = HandlerObj;
+    AcpiUtAddReference (HandlerObj);
 
-    /* Install the region's handler */
+    return_ACPI_STATUS (AE_OK);
+}
 
-    if (RegionObj->Region.Handler)
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiEvAssociateRegMethod
+ *
+ * PARAMETERS:  RegionObj           - Region object
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Find and associate _REG method to a region
+ *
+ ******************************************************************************/
+
+void
+AcpiEvAssociateRegMethod (
+    ACPI_OPERAND_OBJECT     *RegionObj)
+{
+    ACPI_NAME               *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG;
+    ACPI_NAMESPACE_NODE     *MethodNode;
+    ACPI_NAMESPACE_NODE     *Node;
+    ACPI_OPERAND_OBJECT     *RegionObj2;
+    ACPI_STATUS             Status;
+
+
+    ACPI_FUNCTION_TRACE (EvAssociateRegMethod);
+
+
+    RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
+    if (!RegionObj2)
     {
-        return_ACPI_STATUS (AE_ALREADY_EXISTS);
+        return_VOID;
     }
 
-    RegionObj->Region.Handler = HandlerObj;
-    AcpiUtAddReference (HandlerObj);
+    Node = RegionObj->Region.Node->Parent;
 
-    return_ACPI_STATUS (AE_OK);
+    /* Find any "_REG" method associated with this region definition */
+
+    Status = AcpiNsSearchOneScope (
+        *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode);
+    if (ACPI_SUCCESS (Status))
+    {
+        /*
+         * The _REG method is optional and there can be only one per region
+         * definition. This will be executed when the handler is attached
+         * or removed
+         */
+        RegionObj2->Extra.Method_REG = MethodNode;
+    }
+
+    return_VOID;
 }
 
 
@@ -651,7 +707,19 @@ AcpiEvExecuteRegMethod (
         return_ACPI_STATUS (AE_NOT_EXIST);
     }
 
-    if (RegionObj2->Extra.Method_REG == NULL)
+    if (RegionObj2->Extra.Method_REG == NULL ||
+        RegionObj->Region.Handler == NULL ||
+        !AcpiGbl_RegMethodsEnabled)
+    {
+        return_ACPI_STATUS (AE_OK);
+    }
+
+    /* _REG(DISCONNECT) should be paired with _REG(CONNECT) */
+
+    if ((Function == ACPI_REG_CONNECT &&
+        RegionObj->Common.Flags & AOPOBJ_REG_CONNECTED) ||
+        (Function == ACPI_REG_DISCONNECT &&
+         !(RegionObj->Common.Flags & AOPOBJ_REG_CONNECTED)))
     {
         return_ACPI_STATUS (AE_OK);
     }
@@ -703,6 +771,20 @@ AcpiEvExecuteRegMethod (
     Status = AcpiNsEvaluate (Info);
     AcpiUtRemoveReference (Args[1]);
 
+    if (ACPI_FAILURE (Status))
+    {
+        goto Cleanup2;
+    }
+
+    if (Function == ACPI_REG_CONNECT)
+    {
+        RegionObj->Common.Flags |= AOPOBJ_REG_CONNECTED;
+    }
+    else
+    {
+        RegionObj->Common.Flags &= ~AOPOBJ_REG_CONNECTED;
+    }
+
 Cleanup2:
     AcpiUtRemoveReference (Args[0]);
 
@@ -718,26 +800,28 @@ Cleanup1:
  *
  * PARAMETERS:  Node            - Namespace node for the device
  *              SpaceId         - The address space ID
+ *              Function        - Passed to _REG: On (1) or Off (0)
  *
- * RETURN:      Status
+ * RETURN:      None
  *
  * DESCRIPTION: Run all _REG methods for the input Space ID;
  *              Note: assumes namespace is locked, or system init time.
  *
  ******************************************************************************/
 
-ACPI_STATUS
+void
 AcpiEvExecuteRegMethods (
     ACPI_NAMESPACE_NODE     *Node,
-    ACPI_ADR_SPACE_TYPE     SpaceId)
+    ACPI_ADR_SPACE_TYPE     SpaceId,
+    UINT32                  Function)
 {
-    ACPI_STATUS             Status;
     ACPI_REG_WALK_INFO      Info;
 
 
     ACPI_FUNCTION_TRACE (EvExecuteRegMethods);
 
     Info.SpaceId = SpaceId;
+    Info.Function = Function;
     Info.RegRunCount = 0;
 
     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_NAMES,
@@ -750,7 +834,7 @@ AcpiEvExecuteRegMethods (
      * regions and _REG methods. (i.e. handlers must be installed for all
      * regions of this Space ID before we can run any _REG methods)
      */
-    Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX,
+    (void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, Node, ACPI_UINT32_MAX,
         ACPI_NS_WALK_UNLOCK, AcpiEvRegRun, NULL, &Info, NULL);
 
     /* Special case for EC: handle "orphan" _REG methods with no region */
@@ -764,7 +848,7 @@ AcpiEvExecuteRegMethods (
         "    Executed %u _REG methods for SpaceId %s\n",
         Info.RegRunCount, AcpiUtGetRegionName (Info.SpaceId)));
 
-    return_ACPI_STATUS (Status);
+    return_VOID;
 }
 
 
@@ -831,7 +915,7 @@ AcpiEvRegRun (
     }
 
     Info->RegRunCount++;
-    Status = AcpiEvExecuteRegMethod (ObjDesc, ACPI_REG_CONNECT);
+    Status = AcpiEvExecuteRegMethod (ObjDesc, Info->Function);
     return (Status);
 }
 
diff --git a/src/acpica/source/components/events/evrgnini.c b/src/acpica/source/components/events/evrgnini.c
index ebc3b59..448e57e 100644
--- a/src/acpica/source/components/events/evrgnini.c
+++ b/src/acpica/source/components/events/evrgnini.c
@@ -639,9 +639,6 @@ AcpiEvInitializeRegion (
     ACPI_ADR_SPACE_TYPE     SpaceId;
     ACPI_NAMESPACE_NODE     *Node;
     ACPI_STATUS             Status;
-    ACPI_NAMESPACE_NODE     *MethodNode;
-    ACPI_NAME               *RegNamePtr = (ACPI_NAME *) METHOD_NAME__REG;
-    ACPI_OPERAND_OBJECT     *RegionObj2;
 
 
     ACPI_FUNCTION_TRACE_U32 (EvInitializeRegion, AcpiNsLocked);
@@ -657,39 +654,15 @@ AcpiEvInitializeRegion (
         return_ACPI_STATUS (AE_OK);
     }
 
-    RegionObj2 = AcpiNsGetSecondaryObject (RegionObj);
-    if (!RegionObj2)
-    {
-        return_ACPI_STATUS (AE_NOT_EXIST);
-    }
+    AcpiEvAssociateRegMethod (RegionObj);
+    RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED;
 
     Node = RegionObj->Region.Node->Parent;
     SpaceId = RegionObj->Region.SpaceId;
 
-    /* Setup defaults */
-
-    RegionObj->Region.Handler = NULL;
-    RegionObj2->Extra.Method_REG = NULL;
-    RegionObj->Common.Flags &= ~(AOPOBJ_SETUP_COMPLETE);
-    RegionObj->Common.Flags |= AOPOBJ_OBJECT_INITIALIZED;
-
-    /* Find any "_REG" method associated with this region definition */
-
-    Status = AcpiNsSearchOneScope (
-        *RegNamePtr, Node, ACPI_TYPE_METHOD, &MethodNode);
-    if (ACPI_SUCCESS (Status))
-    {
-        /*
-         * The _REG method is optional and there can be only one per region
-         * definition. This will be executed when the handler is attached
-         * or removed
-         */
-        RegionObj2->Extra.Method_REG = MethodNode;
-    }
-
     /*
      * The following loop depends upon the root Node having no parent
-     * ie: AcpiGbl_RootNode->ParentEntry being set to NULL
+     * ie: AcpiGbl_RootNode->Parent being set to NULL
      */
     while (Node)
     {
@@ -704,18 +677,10 @@ AcpiEvInitializeRegion (
             switch (Node->Type)
             {
             case ACPI_TYPE_DEVICE:
-
-                HandlerObj = ObjDesc->Device.Handler;
-                break;
-
             case ACPI_TYPE_PROCESSOR:
-
-                HandlerObj = ObjDesc->Processor.Handler;
-                break;
-
             case ACPI_TYPE_THERMAL:
 
-                HandlerObj = ObjDesc->ThermalZone.Handler;
+                HandlerObj = ObjDesc->CommonNotify.Handler;
                 break;
 
             case ACPI_TYPE_METHOD:
@@ -739,51 +704,43 @@ AcpiEvInitializeRegion (
                 break;
             }
 
-            while (HandlerObj)
+            HandlerObj = AcpiEvFindRegionHandler (SpaceId, HandlerObj);
+            if (HandlerObj)
             {
-                /* Is this handler of the correct type? */
-
-                if (HandlerObj->AddressSpace.SpaceId == SpaceId)
-                {
-                    /* Found correct handler */
+                /* Found correct handler */
 
-                    ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
-                        "Found handler %p for region %p in obj %p\n",
-                        HandlerObj, RegionObj, ObjDesc));
+                ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION,
+                    "Found handler %p for region %p in obj %p\n",
+                    HandlerObj, RegionObj, ObjDesc));
 
-                    Status = AcpiEvAttachRegion (HandlerObj, RegionObj,
-                        AcpiNsLocked);
+                Status = AcpiEvAttachRegion (HandlerObj, RegionObj,
+                    AcpiNsLocked);
 
-                    /*
-                     * Tell all users that this region is usable by
-                     * running the _REG method
-                     */
-                    if (AcpiNsLocked)
+                /*
+                 * Tell all users that this region is usable by
+                 * running the _REG method
+                 */
+                if (AcpiNsLocked)
+                {
+                    Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
+                    if (ACPI_FAILURE (Status))
                     {
-                        Status = AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
-                        if (ACPI_FAILURE (Status))
-                        {
-                            return_ACPI_STATUS (Status);
-                        }
+                        return_ACPI_STATUS (Status);
                     }
+                }
 
-                    Status = AcpiEvExecuteRegMethod (RegionObj, ACPI_REG_CONNECT);
+                Status = AcpiEvExecuteRegMethod (RegionObj, ACPI_REG_CONNECT);
 
-                    if (AcpiNsLocked)
+                if (AcpiNsLocked)
+                {
+                    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
+                    if (ACPI_FAILURE (Status))
                     {
-                        Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
-                        if (ACPI_FAILURE (Status))
-                        {
-                            return_ACPI_STATUS (Status);
-                        }
+                        return_ACPI_STATUS (Status);
                     }
-
-                    return_ACPI_STATUS (AE_OK);
                 }
 
-                /* Try next handler in the list */
-
-                HandlerObj = HandlerObj->AddressSpace.Next;
+                return_ACPI_STATUS (AE_OK);
             }
         }
 
diff --git a/src/acpica/source/components/events/evxfregn.c b/src/acpica/source/components/events/evxfregn.c
index 4b70d09..27e4649 100644
--- a/src/acpica/source/components/events/evxfregn.c
+++ b/src/acpica/source/components/events/evxfregn.c
@@ -161,7 +161,6 @@ AcpiInstallAddressSpaceHandler (
 
     ACPI_FUNCTION_TRACE (AcpiInstallAddressSpaceHandler);
 
-
     /* Parameter validation */
 
     if (!Device)
@@ -193,43 +192,9 @@ AcpiInstallAddressSpaceHandler (
         goto UnlockAndExit;
     }
 
-    /*
-     * For the default SpaceIDs, (the IDs for which there are default region handlers
-     * installed) Only execute the _REG methods if the global initialization _REG
-     * methods have already been run (via AcpiInitializeObjects). In other words,
-     * we will defer the execution of the _REG methods for these SpaceIDs until
-     * execution of AcpiInitializeObjects. This is done because we need the handlers
-     * for the default spaces (mem/io/pci/table) to be installed before we can run
-     * any control methods (or _REG methods). There is known BIOS code that depends
-     * on this.
-     *
-     * For all other SpaceIDs, we can safely execute the _REG methods immediately.
-     * This means that for IDs like EmbeddedController, this function should be called
-     * only after AcpiEnableSubsystem has been called.
-     */
-    switch (SpaceId)
-    {
-    case ACPI_ADR_SPACE_SYSTEM_MEMORY:
-    case ACPI_ADR_SPACE_SYSTEM_IO:
-    case ACPI_ADR_SPACE_PCI_CONFIG:
-    case ACPI_ADR_SPACE_DATA_TABLE:
-
-        if (!AcpiGbl_RegMethodsExecuted)
-        {
-            /* We will defer execution of the _REG methods for this space */
-
-            goto UnlockAndExit;
-        }
-        break;
-
-    default:
-
-        break;
-    }
-
     /* Run all _REG methods for this address space */
 
-    Status = AcpiEvExecuteRegMethods (Node, SpaceId);
+    AcpiEvExecuteRegMethods (Node, SpaceId, ACPI_REG_CONNECT);
 
 
 UnlockAndExit:
@@ -308,8 +273,8 @@ AcpiRemoveAddressSpaceHandler (
 
     /* Find the address handler the user requested */
 
-    HandlerObj = ObjDesc->Device.Handler;
-    LastObjPtr = &ObjDesc->Device.Handler;
+    HandlerObj = ObjDesc->CommonNotify.Handler;
+    LastObjPtr = &ObjDesc->CommonNotify.Handler;
     while (HandlerObj)
     {
         /* We have a handler, see if user requested this one */
diff --git a/src/acpica/source/components/executer/excreate.c b/src/acpica/source/components/executer/excreate.c
index fc36956..f3c2004 100644
--- a/src/acpica/source/components/executer/excreate.c
+++ b/src/acpica/source/components/executer/excreate.c
@@ -423,9 +423,10 @@ AcpiExCreateRegion (
      * Remember location in AML stream of address & length
      * operands since they need to be evaluated at run time.
      */
-    RegionObj2 = ObjDesc->Common.NextObject;
+    RegionObj2 = AcpiNsGetSecondaryObject (ObjDesc);
     RegionObj2->Extra.AmlStart = AmlStart;
     RegionObj2->Extra.AmlLength = AmlLength;
+    RegionObj2->Extra.Method_REG = NULL;
     if (WalkState->ScopeInfo)
     {
         RegionObj2->Extra.ScopeNode = WalkState->ScopeInfo->Scope.Node;
@@ -441,6 +442,10 @@ AcpiExCreateRegion (
     ObjDesc->Region.Address = 0;
     ObjDesc->Region.Length = 0;
     ObjDesc->Region.Node = Node;
+    ObjDesc->Region.Handler = NULL;
+    ObjDesc->Common.Flags &=
+        ~(AOPOBJ_SETUP_COMPLETE | AOPOBJ_REG_CONNECTED |
+          AOPOBJ_OBJECT_INITIALIZED);
 
     /* Install the new region object in the parent Node */
 
diff --git a/src/acpica/source/components/executer/exdebug.c b/src/acpica/source/components/executer/exdebug.c
index 67bd8fc..9c2c107 100644
--- a/src/acpica/source/components/executer/exdebug.c
+++ b/src/acpica/source/components/executer/exdebug.c
@@ -168,13 +168,20 @@ AcpiExDoDebugObject (
         return_VOID;
     }
 
-    /*
-     * We will emit the current timer value (in microseconds) with each
-     * debug output. Only need the lower 26 bits. This allows for 67
-     * million microseconds or 67 seconds before rollover.
-     */
-    Timer = ((UINT32) AcpiOsGetTimer () / 10); /* (100 nanoseconds to microseconds) */
-    Timer &= 0x03FFFFFF;
+    /* Null string or newline -- don't emit the line header */
+
+    if (SourceDesc &&
+        (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND) &&
+        (SourceDesc->Common.Type == ACPI_TYPE_STRING))
+    {
+        if ((SourceDesc->String.Length == 0) ||
+                ((SourceDesc->String.Length == 1) &&
+                (*SourceDesc->String.Pointer == '\n')))
+        {
+            AcpiOsPrintf ("\n");
+            return_VOID;
+        }
+    }
 
     /*
      * Print line header as long as we are not in the middle of an
@@ -182,14 +189,31 @@ AcpiExDoDebugObject (
      */
     if (!((Level > 0) && Index == 0))
     {
-        AcpiOsPrintf ("[ACPI Debug %.8u] %*s", Timer, Level, " ");
+        if (AcpiGbl_DisplayDebugTimer)
+        {
+            /*
+             * We will emit the current timer value (in microseconds) with each
+             * debug output. Only need the lower 26 bits. This allows for 67
+             * million microseconds or 67 seconds before rollover.
+             *
+             * Convert 100 nanosecond units to microseconds
+             */
+            Timer = ((UINT32) AcpiOsGetTimer () / 10);
+            Timer &= 0x03FFFFFF;
+
+            AcpiOsPrintf ("[ACPI Debug T=0x%8.8X] %*s", Timer, Level, " ");
+        }
+        else
+        {
+            AcpiOsPrintf ("[ACPI Debug] %*s", Level, " ");
+        }
     }
 
     /* Display the index for package output only */
 
     if (Index > 0)
     {
-       AcpiOsPrintf ("(%.2u) ", Index-1);
+       AcpiOsPrintf ("(%.2u) ", Index - 1);
     }
 
     if (!SourceDesc)
@@ -200,7 +224,13 @@ AcpiExDoDebugObject (
 
     if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND)
     {
-        AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc));
+        /* No object type prefix needed for integers and strings */
+
+        if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) &&
+            (SourceDesc->Common.Type != ACPI_TYPE_STRING))
+        {
+            AcpiOsPrintf ("%s  ", AcpiUtGetObjectTypeName (SourceDesc));
+        }
 
         if (!AcpiUtValidInternalObject (SourceDesc))
         {
@@ -210,7 +240,7 @@ AcpiExDoDebugObject (
     }
     else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
     {
-        AcpiOsPrintf ("%s: %p\n",
+        AcpiOsPrintf ("%s  (Node %p)\n",
             AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
                 SourceDesc);
         return_VOID;
@@ -250,13 +280,12 @@ AcpiExDoDebugObject (
 
     case ACPI_TYPE_STRING:
 
-        AcpiOsPrintf ("[0x%.2X] \"%s\"\n",
-            SourceDesc->String.Length, SourceDesc->String.Pointer);
+        AcpiOsPrintf ("\"%s\"\n", SourceDesc->String.Pointer);
         break;
 
     case ACPI_TYPE_PACKAGE:
 
-        AcpiOsPrintf ("[Contains 0x%.2X Elements]\n",
+        AcpiOsPrintf ("(Contains 0x%.2X Elements):\n",
             SourceDesc->Package.Count);
 
         /* Output the entire contents of the package */
@@ -335,8 +364,10 @@ AcpiExDoDebugObject (
             if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) ==
                 ACPI_DESC_TYPE_NAMED)
             {
-                AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *)
-                    SourceDesc->Reference.Object)->Object,
+                /* Reference object is a namespace node */
+
+                AcpiExDoDebugObject (ACPI_CAST_PTR (ACPI_OPERAND_OBJECT,
+                    SourceDesc->Reference.Object),
                     Level + 4, 0);
             }
             else
@@ -362,8 +393,15 @@ AcpiExDoDebugObject (
                 case ACPI_TYPE_PACKAGE:
 
                     AcpiOsPrintf ("Package[%u] = ", Value);
-                    AcpiExDoDebugObject (*SourceDesc->Reference.Where,
-                        Level+4, 0);
+                    if (!(*SourceDesc->Reference.Where))
+                    {
+                        AcpiOsPrintf ("[Uninitialized Package Element]\n");
+                    }
+                    else
+                    {
+                        AcpiExDoDebugObject (*SourceDesc->Reference.Where,
+                            Level+4, 0);
+                    }
                     break;
 
                 default:
@@ -378,7 +416,7 @@ AcpiExDoDebugObject (
 
     default:
 
-        AcpiOsPrintf ("%p\n", SourceDesc);
+        AcpiOsPrintf ("(Descriptor %p)\n", SourceDesc);
         break;
     }
 
diff --git a/src/acpica/source/components/executer/exdump.c b/src/acpica/source/components/executer/exdump.c
index 73acfd4..2f2836e 100644
--- a/src/acpica/source/components/executer/exdump.c
+++ b/src/acpica/source/components/executer/exdump.c
@@ -594,7 +594,8 @@ AcpiExDumpObject (
             if (Next)
             {
                 AcpiOsPrintf ("(%s %2.2X)",
-                    AcpiUtGetObjectTypeName (Next), Next->Common.Type);
+                    AcpiUtGetObjectTypeName (Next),
+                    Next->AddressSpace.SpaceId);
 
                 while (Next->AddressSpace.Next)
                 {
@@ -606,7 +607,8 @@ AcpiExDumpObject (
 
                     Next = Next->AddressSpace.Next;
                     AcpiOsPrintf ("->%p(%s %2.2X)", Next,
-                        AcpiUtGetObjectTypeName (Next), Next->Common.Type);
+                        AcpiUtGetObjectTypeName (Next),
+                        Next->AddressSpace.SpaceId);
 
                     if ((Next == Start) || (Next == Data))
                     {
diff --git a/src/acpica/source/components/executer/exmisc.c b/src/acpica/source/components/executer/exmisc.c
index c2e04bb..cde2279 100644
--- a/src/acpica/source/components/executer/exmisc.c
+++ b/src/acpica/source/components/executer/exmisc.c
@@ -180,9 +180,9 @@ AcpiExGetObjectReference (
 
         default:
 
-            ACPI_ERROR ((AE_INFO, "Unknown Reference Class 0x%2.2X",
+            ACPI_ERROR ((AE_INFO, "Invalid Reference Class 0x%2.2X",
                 ObjDesc->Reference.Class));
-            return_ACPI_STATUS (AE_AML_INTERNAL);
+            return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
         }
         break;
 
@@ -338,6 +338,7 @@ AcpiExDoConcatenate (
     ACPI_OPERAND_OBJECT     *LocalOperand1 = Operand1;
     ACPI_OPERAND_OBJECT     *ReturnDesc;
     char                    *NewBuf;
+    const char              *TypeString;
     ACPI_STATUS             Status;
 
 
@@ -359,9 +360,42 @@ AcpiExDoConcatenate (
         break;
 
     case ACPI_TYPE_STRING:
+        /*
+         * Per the ACPI spec, Concatenate only supports int/str/buf.
+         * However, we support all objects here as an extension.
+         * This improves the usefulness of the Printf() macro.
+         * 12/2015.
+         */
+        switch (Operand1->Common.Type)
+        {
+        case ACPI_TYPE_INTEGER:
+        case ACPI_TYPE_STRING:
+        case ACPI_TYPE_BUFFER:
 
-        Status = AcpiExConvertToString (
-            Operand1, &LocalOperand1, ACPI_IMPLICIT_CONVERT_HEX);
+            Status = AcpiExConvertToString (
+                Operand1, &LocalOperand1, ACPI_IMPLICIT_CONVERT_HEX);
+            break;
+
+        default:
+            /*
+             * Just emit a string containing the object type.
+             */
+            TypeString = AcpiUtGetTypeName (Operand1->Common.Type);
+
+            LocalOperand1 = AcpiUtCreateStringObject (
+                ((ACPI_SIZE) strlen (TypeString) + 9)); /* 9 For "[Object]" */
+            if (!LocalOperand1)
+            {
+                Status = AE_NO_MEMORY;
+                goto Cleanup;
+            }
+
+            strcpy (LocalOperand1->String.Pointer, "[");
+            strcat (LocalOperand1->String.Pointer, TypeString);
+            strcat (LocalOperand1->String.Pointer, " Object]");
+            Status = AE_OK;
+            break;
+        }
         break;
 
     case ACPI_TYPE_BUFFER:
@@ -440,8 +474,7 @@ AcpiExDoConcatenate (
         /* Concatenate the strings */
 
         strcpy (NewBuf, Operand0->String.Pointer);
-        strcpy (NewBuf + Operand0->String.Length,
-            LocalOperand1->String.Pointer);
+        strcat (NewBuf, LocalOperand1->String.Pointer);
         break;
 
     case ACPI_TYPE_BUFFER:
diff --git a/src/acpica/source/components/executer/exoparg1.c b/src/acpica/source/components/executer/exoparg1.c
index 466c886..965de2d 100644
--- a/src/acpica/source/components/executer/exoparg1.c
+++ b/src/acpica/source/components/executer/exoparg1.c
@@ -796,7 +796,7 @@ AcpiExOpcode_1A_0T_1R (
         Status = AcpiExStore (ReturnDesc, Operand[0], WalkState);
         break;
 
-    case AML_TYPE_OP:               /* ObjectType (SourceObject) */
+    case AML_OBJECT_TYPE_OP:            /* ObjectType (SourceObject) */
         /*
          * Note: The operand is not resolved at this point because we want to
          * get the associated object, not its value. For example, we don't
diff --git a/src/acpica/source/components/namespace/nsconvert.c b/src/acpica/source/components/namespace/nsconvert.c
index ee361ea..af5b255 100644
--- a/src/acpica/source/components/namespace/nsconvert.c
+++ b/src/acpica/source/components/namespace/nsconvert.c
@@ -404,7 +404,8 @@ AcpiNsConvertToBuffer (
  *
  * FUNCTION:    AcpiNsConvertToUnicode
  *
- * PARAMETERS:  OriginalObject      - ASCII String Object to be converted
+ * PARAMETERS:  Scope               - Namespace node for the method/object
+ *              OriginalObject      - ASCII String Object to be converted
  *              ReturnObject        - Where the new converted object is returned
  *
  * RETURN:      Status. AE_OK if conversion was successful.
@@ -415,6 +416,7 @@ AcpiNsConvertToBuffer (
 
 ACPI_STATUS
 AcpiNsConvertToUnicode (
+    ACPI_NAMESPACE_NODE     *Scope,
     ACPI_OPERAND_OBJECT     *OriginalObject,
     ACPI_OPERAND_OBJECT     **ReturnObject)
 {
@@ -476,7 +478,8 @@ AcpiNsConvertToUnicode (
  *
  * FUNCTION:    AcpiNsConvertToResource
  *
- * PARAMETERS:  OriginalObject      - Object to be converted
+ * PARAMETERS:  Scope               - Namespace node for the method/object
+ *              OriginalObject      - Object to be converted
  *              ReturnObject        - Where the new converted object is returned
  *
  * RETURN:      Status. AE_OK if conversion was successful
@@ -488,6 +491,7 @@ AcpiNsConvertToUnicode (
 
 ACPI_STATUS
 AcpiNsConvertToResource (
+    ACPI_NAMESPACE_NODE     *Scope,
     ACPI_OPERAND_OBJECT     *OriginalObject,
     ACPI_OPERAND_OBJECT     **ReturnObject)
 {
@@ -554,3 +558,81 @@ AcpiNsConvertToResource (
     *ReturnObject = NewObject;
     return (AE_OK);
 }
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiNsConvertToReference
+ *
+ * PARAMETERS:  Scope               - Namespace node for the method/object
+ *              OriginalObject      - Object to be converted
+ *              ReturnObject        - Where the new converted object is returned
+ *
+ * RETURN:      Status. AE_OK if conversion was successful
+ *
+ * DESCRIPTION: Attempt to convert a Integer object to a ObjectReference.
+ *              Buffer.
+ *
+ ******************************************************************************/
+
+ACPI_STATUS
+AcpiNsConvertToReference (
+    ACPI_NAMESPACE_NODE     *Scope,
+    ACPI_OPERAND_OBJECT     *OriginalObject,
+    ACPI_OPERAND_OBJECT     **ReturnObject)
+{
+    ACPI_OPERAND_OBJECT     *NewObject = NULL;
+    ACPI_STATUS             Status;
+    ACPI_NAMESPACE_NODE     *Node;
+    ACPI_GENERIC_STATE      ScopeInfo;
+    char                    *Name;
+
+
+    ACPI_FUNCTION_NAME (NsConvertToReference);
+
+
+    /* Convert path into internal presentation */
+
+    Status = AcpiNsInternalizeName (OriginalObject->String.Pointer, &Name);
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
+    /* Find the namespace node */
+
+    ScopeInfo.Scope.Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Scope);
+    Status = AcpiNsLookup (&ScopeInfo, Name,
+        ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
+        ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node);
+    if (ACPI_FAILURE (Status))
+    {
+        /* Check if we are resolving a named reference within a package */
+
+        ACPI_ERROR_NAMESPACE (OriginalObject->String.Pointer, Status);
+        goto ErrorExit;
+    }
+
+    /* Create and init a new internal ACPI object */
+
+    NewObject = AcpiUtCreateInternalObject (ACPI_TYPE_LOCAL_REFERENCE);
+    if (!NewObject)
+    {
+        Status = AE_NO_MEMORY;
+        goto ErrorExit;
+    }
+    NewObject->Reference.Node = Node;
+    NewObject->Reference.Object = Node->Object;
+    NewObject->Reference.Class = ACPI_REFCLASS_NAME;
+
+    /*
+     * Increase reference of the object if needed (the object is likely a
+     * null for device nodes).
+     */
+    AcpiUtAddReference (Node->Object);
+
+ErrorExit:
+    ACPI_FREE (Name);
+    *ReturnObject = NewObject;
+    return (AE_OK);
+}
diff --git a/src/acpica/source/components/namespace/nseval.c b/src/acpica/source/components/namespace/nseval.c
index 9847e93..a62269f 100644
--- a/src/acpica/source/components/namespace/nseval.c
+++ b/src/acpica/source/components/namespace/nseval.c
@@ -491,7 +491,7 @@ AcpiNsExecModuleCodeList (
  *
  * DESCRIPTION: Execute a control method containing a block of module-level
  *              executable AML code. The control method is temporarily
- *              installed to the root node, then evaluated.
+ *              installed to a local copy of the root node, then evaluated.
  *
  ******************************************************************************/
 
@@ -500,10 +500,9 @@ AcpiNsExecModuleCode (
     ACPI_OPERAND_OBJECT     *MethodObj,
     ACPI_EVALUATE_INFO      *Info)
 {
-    ACPI_OPERAND_OBJECT     *ParentObj;
-    ACPI_NAMESPACE_NODE     *ParentNode;
-    ACPI_OBJECT_TYPE        Type;
     ACPI_STATUS             Status;
+    ACPI_NAMESPACE_NODE     *TempNode;
+    ACPI_NAMESPACE_NODE     *ParentNode;
 
 
     ACPI_FUNCTION_TRACE (NsExecModuleCode);
@@ -515,21 +514,18 @@ AcpiNsExecModuleCode (
      */
     ParentNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE,
         MethodObj->Method.NextObject);
-    Type = AcpiNsGetType (ParentNode);
 
-    /*
-     * Get the region handler and save it in the method object. We may need
-     * this if an operation region declaration causes a _REG method to be run.
-     *
-     * We can't do this in AcpiPsLinkModuleCode because
-     * AcpiGbl_RootNode->Object is NULL at PASS1.
-     */
-    if ((Type == ACPI_TYPE_DEVICE) && ParentNode->Object)
+    /* Take a copy of the parent node to act as parent of this method */
+
+    TempNode = ACPI_ALLOCATE (sizeof (ACPI_NAMESPACE_NODE));
+    if (!TempNode)
     {
-        MethodObj->Method.Dispatch.Handler =
-            ParentNode->Object->Device.Handler;
+        return_VOID;
     }
 
+    memcpy (TempNode, ParentNode, sizeof (ACPI_NAMESPACE_NODE));
+    TempNode->Object = NULL; /* Clear the subobject */
+
     /* Must clear NextObject (AcpiNsAttachObject needs the field) */
 
     MethodObj->Method.NextObject = NULL;
@@ -537,26 +533,14 @@ AcpiNsExecModuleCode (
     /* Initialize the evaluation information block */
 
     memset (Info, 0, sizeof (ACPI_EVALUATE_INFO));
-    Info->PrefixNode = ParentNode;
-
-    /*
-     * Get the currently attached parent object. Add a reference, because the
-     * ref count will be decreased when the method object is installed to
-     * the parent node.
-     */
-    ParentObj = AcpiNsGetAttachedObject (ParentNode);
-    if (ParentObj)
-    {
-        AcpiUtAddReference (ParentObj);
-    }
+    Info->PrefixNode = TempNode;
 
     /* Install the method (module-level code) in the parent node */
 
-    Status = AcpiNsAttachObject (ParentNode, MethodObj,
-        ACPI_TYPE_METHOD);
+    Status = AcpiNsAttachObject (TempNode, MethodObj, ACPI_TYPE_METHOD);
     if (ACPI_FAILURE (Status))
     {
-        goto Exit;
+        goto Cleanup;
     }
 
     /* Execute the parent node as a control method */
@@ -574,25 +558,7 @@ AcpiNsExecModuleCode (
         AcpiUtRemoveReference (Info->ReturnObject);
     }
 
-    /* Detach the temporary method object */
-
-    AcpiNsDetachObject (ParentNode);
-
-    /* Restore the original parent object */
-
-    if (ParentObj)
-    {
-        Status = AcpiNsAttachObject (ParentNode, ParentObj, Type);
-    }
-    else
-    {
-        ParentNode->Type = (UINT8) Type;
-    }
-
-Exit:
-    if (ParentObj)
-    {
-        AcpiUtRemoveReference (ParentObj);
-    }
+Cleanup:
+    ACPI_FREE (TempNode);
     return_VOID;
 }
diff --git a/src/acpica/source/components/namespace/nsload.c b/src/acpica/source/components/namespace/nsload.c
index cae1616..738f897 100644
--- a/src/acpica/source/components/namespace/nsload.c
+++ b/src/acpica/source/components/namespace/nsload.c
@@ -239,6 +239,24 @@ Unlock:
     ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
         "**** Completed Table Object Initialization\n"));
 
+    /*
+     * Execute any module-level code that was detected during the table load
+     * phase. Although illegal since ACPI 2.0, there are many machines that
+     * contain this type of code. Each block of detected executable AML code
+     * outside of any control method is wrapped with a temporary control
+     * method object and placed on a global list. The methods on this list
+     * are executed below.
+     *
+     * This case executes the module-level code for each table immediately
+     * after the table has been loaded. This provides compatibility with
+     * other ACPI implementations. Optionally, the execution can be deferred
+     * until later, see AcpiInitializeObjects.
+     */
+    if (!AcpiGbl_GroupModuleLevelCode)
+    {
+        AcpiNsExecModuleCodeList ();
+    }
+
     return_ACPI_STATUS (Status);
 }
 
diff --git a/src/acpica/source/components/namespace/nsrepair.c b/src/acpica/source/components/namespace/nsrepair.c
index 98265bc..556af7c 100644
--- a/src/acpica/source/components/namespace/nsrepair.c
+++ b/src/acpica/source/components/namespace/nsrepair.c
@@ -186,6 +186,11 @@ static const ACPI_SIMPLE_REPAIR_INFO    AcpiObjectRepairInfo[] =
                 ACPI_NOT_PACKAGE_ELEMENT,
                 AcpiNsConvertToResource },
 
+    /* Object reference conversions */
+
+    { "_DEP", ACPI_RTYPE_STRING, ACPI_ALL_PACKAGE_ELEMENTS,
+                AcpiNsConvertToReference },
+
     /* Unicode conversions */
 
     { "_MLS", ACPI_RTYPE_STRING, 1,
@@ -246,7 +251,8 @@ AcpiNsSimpleRepair (
                 ACPI_WARN_ALWAYS, "Missing expected return value"));
         }
 
-        Status = Predefined->ObjectConverter (ReturnObject, &NewObject);
+        Status = Predefined->ObjectConverter (Info->Node, ReturnObject,
+            &NewObject);
         if (ACPI_FAILURE (Status))
         {
             /* A fatal error occurred during a conversion */
@@ -445,7 +451,8 @@ AcpiNsMatchSimpleRepair (
             /* Check if we can actually repair this name/type combination */
 
             if ((ReturnBtype & ThisName->UnexpectedBtypes) &&
-                (PackageIndex == ThisName->PackageIndex))
+                (ThisName->PackageIndex == ACPI_ALL_PACKAGE_ELEMENTS ||
+                 PackageIndex == ThisName->PackageIndex))
             {
                 return (ThisName);
             }
diff --git a/src/acpica/source/components/parser/psargs.c b/src/acpica/source/components/parser/psargs.c
index 4ee5f0a..d6654a1 100644
--- a/src/acpica/source/components/parser/psargs.c
+++ b/src/acpica/source/components/parser/psargs.c
@@ -370,7 +370,7 @@ AcpiPsGetNextNamepath (
         PossibleMethodCall &&
         (Node->Type == ACPI_TYPE_METHOD))
     {
-        if (WalkState->Opcode == AML_UNLOAD_OP)
+        if (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) == ARGP_SUPERNAME)
         {
             /*
              * AcpiPsGetNextNamestring has increased the AML pointer,
@@ -816,7 +816,7 @@ AcpiPsGetNextField (
  *
  * PARAMETERS:  WalkState           - Current state
  *              ParserState         - Current parser state object
- *              ArgType             - The argument type (AML_*_ARG)
+ *              ArgType             - The parser argument type (ARGP_*)
  *              ReturnArg           - Where the next arg is returned
  *
  * RETURN:      Status, and an op object containing the next argument.
@@ -929,6 +929,7 @@ AcpiPsGetNextArg (
     case ARGP_TARGET:
     case ARGP_SUPERNAME:
     case ARGP_SIMPLENAME:
+    case ARGP_NAME_OR_REF:
 
         Subop = AcpiPsPeekOpcode (ParserState);
         if (Subop == 0                  ||
@@ -944,15 +945,16 @@ AcpiPsGetNextArg (
                 return_ACPI_STATUS (AE_NO_MEMORY);
             }
 
-            /* To support SuperName arg of Unload */
+            /* SuperName allows argument to be a method call */
 
-            if (WalkState->Opcode == AML_UNLOAD_OP)
+            if (ArgType == ARGP_SUPERNAME)
             {
-                Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 1);
+                Status = AcpiPsGetNextNamepath (WalkState, ParserState,
+                    Arg, ACPI_POSSIBLE_METHOD_CALL);
 
                 /*
-                 * If the SuperName arg of Unload is a method call,
-                 * we have restored the AML pointer, just free this Arg
+                 * If the SuperName argument is a method call, we have
+                 * already restored the AML pointer, just free this Arg
                  */
                 if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP)
                 {
@@ -962,7 +964,8 @@ AcpiPsGetNextArg (
             }
             else
             {
-                Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 0);
+                Status = AcpiPsGetNextNamepath (WalkState, ParserState,
+                    Arg, ACPI_NOT_METHOD_CALL);
             }
         }
         else
diff --git a/src/acpica/source/components/parser/psloop.c b/src/acpica/source/components/parser/psloop.c
index 2fa4e72..524a6bd 100644
--- a/src/acpica/source/components/parser/psloop.c
+++ b/src/acpica/source/components/parser/psloop.c
@@ -192,8 +192,8 @@ AcpiPsGetArguments (
 
     case AML_INT_NAMEPATH_OP:   /* AML_NAMESTRING_ARG */
 
-        Status = AcpiPsGetNextNamepath (
-            WalkState, &(WalkState->ParserState), Op, 1);
+        Status = AcpiPsGetNextNamepath (WalkState,
+            &(WalkState->ParserState), Op, ACPI_POSSIBLE_METHOD_CALL);
         if (ACPI_FAILURE (Status))
         {
             return_ACPI_STATUS (Status);
diff --git a/src/acpica/source/components/parser/psopcode.c b/src/acpica/source/components/parser/psopcode.c
index 41181c6..4590815 100644
--- a/src/acpica/source/components/parser/psopcode.c
+++ b/src/acpica/source/components/parser/psopcode.c
@@ -317,7 +317,7 @@ const ACPI_OPCODE_INFO    AcpiGbl_AmlOpInfo[AML_NUM_OPCODES] =
 /* 34 */ ACPI_OP ("CreateWordField",    ARGP_CREATE_WORD_FIELD_OP, ARGI_CREATE_WORD_FIELD_OP,  ACPI_TYPE_BUFFER_FIELD,      AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
 /* 35 */ ACPI_OP ("CreateByteField",    ARGP_CREATE_BYTE_FIELD_OP, ARGI_CREATE_BYTE_FIELD_OP,  ACPI_TYPE_BUFFER_FIELD,      AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
 /* 36 */ ACPI_OP ("CreateBitField",     ARGP_CREATE_BIT_FIELD_OP,  ARGI_CREATE_BIT_FIELD_OP,   ACPI_TYPE_BUFFER_FIELD,      AML_CLASS_CREATE,          AML_TYPE_CREATE_FIELD,    AML_HAS_ARGS | AML_NSOBJECT | AML_NSNODE | AML_DEFER | AML_CREATE),
-/* 37 */ ACPI_OP ("ObjectType",         ARGP_TYPE_OP,              ARGI_TYPE_OP,               ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE),
+/* 37 */ ACPI_OP ("ObjectType",         ARGP_OBJECT_TYPE_OP,       ARGI_OBJECT_TYPE_OP,        ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R | AML_NO_OPERAND_RESOLVE),
 /* 38 */ ACPI_OP ("LAnd",               ARGP_LAND_OP,              ARGI_LAND_OP,               ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT),
 /* 39 */ ACPI_OP ("LOr",                ARGP_LOR_OP,               ARGI_LOR_OP,                ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_2A_0T_1R,   AML_FLAGS_EXEC_2A_0T_1R | AML_LOGICAL_NUMERIC | AML_CONSTANT),
 /* 3A */ ACPI_OP ("LNot",               ARGP_LNOT_OP,              ARGI_LNOT_OP,               ACPI_TYPE_ANY,               AML_CLASS_EXECUTE,         AML_TYPE_EXEC_1A_0T_1R,   AML_FLAGS_EXEC_1A_0T_1R | AML_CONSTANT),
diff --git a/src/acpica/source/components/tables/tbutils.c b/src/acpica/source/components/tables/tbutils.c
index bb74c0a..0f25fda 100644
--- a/src/acpica/source/components/tables/tbutils.c
+++ b/src/acpica/source/components/tables/tbutils.c
@@ -491,7 +491,7 @@ NextTable:
  *
  * PARAMETERS:  Signature           - Sig string to be validated
  *
- * RETURN:      TRUE if signature is correct length and has valid characters
+ * RETURN:      TRUE if signature is has 4 valid ACPI characters
  *
  * DESCRIPTION: Validate an ACPI table signature.
  *
@@ -504,13 +504,6 @@ AcpiIsValidSignature (
     UINT32                  i;
 
 
-    /* Validate the signature length */
-
-    if (strlen (Signature) != ACPI_NAME_SIZE)
-    {
-        return (FALSE);
-    }
-
     /* Validate each character in the signature */
 
     for (i = 0; i < ACPI_NAME_SIZE; i++)
diff --git a/src/acpica/source/components/utilities/utinit.c b/src/acpica/source/components/utilities/utinit.c
index ee14368..c29f288 100644
--- a/src/acpica/source/components/utilities/utinit.c
+++ b/src/acpica/source/components/utilities/utinit.c
@@ -298,7 +298,6 @@ AcpiUtInitGlobals (
     AcpiGbl_NextOwnerIdOffset           = 0;
     AcpiGbl_DebuggerConfiguration       = DEBUGGER_THREADING;
     AcpiGbl_OsiMutex                    = NULL;
-    AcpiGbl_RegMethodsExecuted          = FALSE;
     AcpiGbl_MaxLoopIterations           = 0xFFFF;
 
     /* Hardware oriented */
diff --git a/src/acpica/source/components/utilities/utstring.c b/src/acpica/source/components/utilities/utstring.c
index 529b39f..05178cf 100644
--- a/src/acpica/source/components/utilities/utstring.c
+++ b/src/acpica/source/components/utilities/utstring.c
@@ -343,6 +343,15 @@ AcpiUtRepairName (
     ACPI_FUNCTION_NAME (UtRepairName);
 
 
+    /*
+     * Special case for the root node. This can happen if we get an
+     * error during the execution of module-level code.
+     */
+    if (ACPI_COMPARE_NAME (Name, "\\___"))
+    {
+        return;
+    }
+
     ACPI_MOVE_NAME (&OriginalName, Name);
 
     /* Check each character in the name */
diff --git a/src/acpica/source/components/utilities/utxfinit.c b/src/acpica/source/components/utilities/utxfinit.c
index 4703dc1..841aaa4 100644
--- a/src/acpica/source/components/utilities/utxfinit.c
+++ b/src/acpica/source/components/utilities/utxfinit.c
@@ -204,6 +204,25 @@ AcpiInitializeSubsystem (
         return_ACPI_STATUS (Status);
     }
 
+    if (!AcpiGbl_OverrideDefaultRegionHandlers)
+    {
+        /*
+         * Install the default operation region handlers. These are the
+         * handlers that are defined by the ACPI specification to be
+         * "always accessible" -- namely, SystemMemory, SystemIO, and
+         * PCI_Config. This also means that no _REG methods need to be
+         * run for these address spaces. We need to have these handlers
+         * installed before any AML code can be executed, especially any
+         * module-level code (11/2015).
+         */
+        Status = AcpiEvInstallRegionHandlers ();
+        if (ACPI_FAILURE (Status))
+        {
+            ACPI_EXCEPTION ((AE_INFO, Status, "During Region initialization"));
+            return_ACPI_STATUS (Status);
+        }
+    }
+
     return_ACPI_STATUS (AE_OK);
 }
 
@@ -233,6 +252,33 @@ AcpiEnableSubsystem (
     ACPI_FUNCTION_TRACE (AcpiEnableSubsystem);
 
 
+    /*
+     * The early initialization phase is complete. The namespace is loaded,
+     * and we can now support address spaces other than Memory, I/O, and
+     * PCI_Config.
+     */
+    AcpiGbl_EarlyInitialization = FALSE;
+
+    if (AcpiGbl_OverrideDefaultRegionHandlers)
+    {
+        /*
+         * Install the default operation region handlers. These are the
+         * handlers that are defined by the ACPI specification to be
+         * "always accessible" -- namely, SystemMemory, SystemIO, and
+         * PCI_Config. This also means that no _REG methods need to be
+         * run for these address spaces. We need to have these handlers
+         * installed before any AML code can be executed, especially any
+         * module-level code (11/2015).
+         */
+        Status = AcpiEvInstallRegionHandlers ();
+        if (ACPI_FAILURE (Status))
+        {
+            ACPI_EXCEPTION ((AE_INFO, Status, "During Region initialization"));
+            return_ACPI_STATUS (Status);
+        }
+    }
+
+
 #if (!ACPI_REDUCED_HARDWARE)
 
     /* Enable ACPI mode */
@@ -265,26 +311,6 @@ AcpiEnableSubsystem (
         }
     }
 
-#endif /* !ACPI_REDUCED_HARDWARE */
-
-    /*
-     * Install the default OpRegion handlers. These are installed unless
-     * other handlers have already been installed via the
-     * InstallAddressSpaceHandler interface.
-     */
-    if (!(Flags & ACPI_NO_ADDRESS_SPACE_INIT))
-    {
-        ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
-            "[Init] Installing default address space handlers\n"));
-
-        Status = AcpiEvInstallRegionHandlers ();
-        if (ACPI_FAILURE (Status))
-        {
-            return_ACPI_STATUS (Status);
-        }
-    }
-
-#if (!ACPI_REDUCED_HARDWARE)
     /*
      * Initialize ACPI Event handling (Fixed and General Purpose)
      *
@@ -392,8 +418,15 @@ AcpiInitializeObjects (
      * outside of any control method is wrapped with a temporary control
      * method object and placed on a global list. The methods on this list
      * are executed below.
+     *
+     * This case executes the module-level code for all tables only after
+     * all of the tables have been loaded. It is a legacy option and is
+     * not compatible with other ACPI implementations. See AcpiNsLoadTable.
      */
-    AcpiNsExecModuleCodeList ();
+    if (AcpiGbl_GroupModuleLevelCode)
+    {
+        AcpiNsExecModuleCodeList ();
+    }
 
     /*
      * Initialize the objects that remain uninitialized. This runs the
diff --git a/src/acpica/source/include/acapps.h b/src/acpica/source/include/acapps.h
index 4fbebbf..ed206b2 100644
--- a/src/acpica/source/include/acapps.h
+++ b/src/acpica/source/include/acapps.h
@@ -163,7 +163,7 @@
     AcpiOsPrintf (Description);
 
 #define ACPI_OPTION(Name, Description) \
-    AcpiOsPrintf ("  %-18s%s\n", Name, Description);
+    AcpiOsPrintf ("  %-20s%s\n", Name, Description);
 
 
 /* Check for unexpected exceptions */
@@ -187,11 +187,21 @@
 /* acfileio */
 
 ACPI_STATUS
-AcpiAcGetAllTablesFromFile (
+AcGetAllTablesFromFile (
     char                    *Filename,
     UINT8                   GetOnlyAmlTables,
     ACPI_NEW_TABLE_DESC     **ReturnListHead);
 
+BOOLEAN
+AcIsFileBinary (
+    FILE                    *File);
+
+ACPI_STATUS
+AcValidateTableHeader (
+    FILE                    *File,
+    long                    TableOffset);
+
+
 /* Values for GetOnlyAmlTables */
 
 #define ACPI_GET_ONLY_AML_TABLES    TRUE
diff --git a/src/acpica/source/include/acevents.h b/src/acpica/source/include/acevents.h
index 467e14f..e1b1d9b 100644
--- a/src/acpica/source/include/acevents.h
+++ b/src/acpica/source/include/acevents.h
@@ -294,6 +294,11 @@ AcpiEvDeleteGpeHandlers (
 /*
  * evhandler - Address space handling
  */
+ACPI_OPERAND_OBJECT *
+AcpiEvFindRegionHandler (
+    ACPI_ADR_SPACE_TYPE     SpaceId,
+    ACPI_OPERAND_OBJECT     *HandlerObj);
+
 BOOLEAN
 AcpiEvHasDefaultHandler (
     ACPI_NAMESPACE_NODE     *Node,
@@ -336,17 +341,22 @@ AcpiEvAttachRegion (
 
 void
 AcpiEvDetachRegion (
-    ACPI_OPERAND_OBJECT    *RegionObj,
+    ACPI_OPERAND_OBJECT     *RegionObj,
     BOOLEAN                 AcpiNsIsLocked);
 
-ACPI_STATUS
+void
+AcpiEvAssociateRegMethod (
+    ACPI_OPERAND_OBJECT     *RegionObj);
+
+void
 AcpiEvExecuteRegMethods (
     ACPI_NAMESPACE_NODE     *Node,
-    ACPI_ADR_SPACE_TYPE     SpaceId);
+    ACPI_ADR_SPACE_TYPE     SpaceId,
+    UINT32                  Function);
 
 ACPI_STATUS
 AcpiEvExecuteRegMethod (
-    ACPI_OPERAND_OBJECT    *RegionObj,
+    ACPI_OPERAND_OBJECT     *RegionObj,
     UINT32                  Function);
 
 
diff --git a/src/acpica/source/include/acexcep.h b/src/acpica/source/include/acexcep.h
index ca09e6b..6029213 100644
--- a/src/acpica/source/include/acexcep.h
+++ b/src/acpica/source/include/acexcep.h
@@ -200,8 +200,9 @@ typedef struct acpi_exception_info
 #define AE_OWNER_ID_LIMIT               EXCEP_ENV (0x001B)
 #define AE_NOT_CONFIGURED               EXCEP_ENV (0x001C)
 #define AE_ACCESS                       EXCEP_ENV (0x001D)
+#define AE_IO_ERROR                     EXCEP_ENV (0x001E)
 
-#define AE_CODE_ENV_MAX                 0x001D
+#define AE_CODE_ENV_MAX                 0x001E
 
 
 /*
@@ -334,7 +335,8 @@ static const ACPI_EXCEPTION_INFO    AcpiGbl_ExceptionNames_Env[] =
     EXCEP_TXT ("AE_NO_HANDLER",                 "A handler for the operation is not installed"),
     EXCEP_TXT ("AE_OWNER_ID_LIMIT",             "There are no more Owner IDs available for ACPI tables or control methods"),
     EXCEP_TXT ("AE_NOT_CONFIGURED",             "The interface is not part of the current subsystem configuration"),
-    EXCEP_TXT ("AE_ACCESS",                     "Permission denied for the requested operation")
+    EXCEP_TXT ("AE_ACCESS",                     "Permission denied for the requested operation"),
+    EXCEP_TXT ("AE_IO_ERROR",                   "An I/O error occurred")
 };
 
 static const ACPI_EXCEPTION_INFO    AcpiGbl_ExceptionNames_Pgm[] =
diff --git a/src/acpica/source/include/acglobal.h b/src/acpica/source/include/acglobal.h
index 2fb8062..c0286cc 100644
--- a/src/acpica/source/include/acglobal.h
+++ b/src/acpica/source/include/acglobal.h
@@ -158,6 +158,8 @@ ACPI_GLOBAL (UINT8,                     AcpiGbl_IntegerBitWidth);
 ACPI_GLOBAL (UINT8,                     AcpiGbl_IntegerByteWidth);
 ACPI_GLOBAL (UINT8,                     AcpiGbl_IntegerNybbleWidth);
 
+ACPI_INIT_GLOBAL (UINT8,                AcpiGbl_GroupModuleLevelCode, FALSE);
+
 
 /*****************************************************************************
  *
@@ -220,6 +222,7 @@ ACPI_GLOBAL (ACPI_CACHE_T *,            AcpiGbl_OperandCache);
 
 ACPI_INIT_GLOBAL (UINT32,               AcpiGbl_StartupFlags, 0);
 ACPI_INIT_GLOBAL (BOOLEAN,              AcpiGbl_Shutdown, TRUE);
+ACPI_INIT_GLOBAL (BOOLEAN,              AcpiGbl_EarlyInitialization, TRUE);
 
 /* Global handlers */
 
@@ -239,7 +242,7 @@ ACPI_GLOBAL (UINT8,                     AcpiGbl_NextOwnerIdOffset);
 
 /* Initialization sequencing */
 
-ACPI_GLOBAL (BOOLEAN,                   AcpiGbl_RegMethodsExecuted);
+ACPI_INIT_GLOBAL (BOOLEAN,              AcpiGbl_RegMethodsEnabled, FALSE);
 
 /* Misc */
 
diff --git a/src/acpica/source/include/aclocal.h b/src/acpica/source/include/aclocal.h
index 8d1e37b..b6974fc 100644
--- a/src/acpica/source/include/aclocal.h
+++ b/src/acpica/source/include/aclocal.h
@@ -525,6 +525,7 @@ typedef union acpi_predefined_info
 /* Return object auto-repair info */
 
 typedef ACPI_STATUS (*ACPI_OBJECT_CONVERTER) (
+    struct acpi_namespace_node  *Scope,
     union acpi_operand_object   *OriginalObject,
     union acpi_operand_object   **ConvertedObject);
 
@@ -560,6 +561,7 @@ typedef struct acpi_simple_repair_info
 typedef struct acpi_reg_walk_info
 {
     ACPI_ADR_SPACE_TYPE     SpaceId;
+    UINT32                  Function;
     UINT32                  RegRunCount;
 
 } ACPI_REG_WALK_INFO;
@@ -1112,6 +1114,7 @@ typedef struct acpi_parse_state
 #define ACPI_PARSEOP_CLOSING_PAREN      0x10
 #define ACPI_PARSEOP_COMPOUND           0x20
 #define ACPI_PARSEOP_ASSIGNMENT         0x40
+#define ACPI_PARSEOP_ELSEIF             0x80
 
 
 /*****************************************************************************
diff --git a/src/acpica/source/include/acnamesp.h b/src/acpica/source/include/acnamesp.h
index db7f114..fc109f4 100644
--- a/src/acpica/source/include/acnamesp.h
+++ b/src/acpica/source/include/acnamesp.h
@@ -150,6 +150,7 @@
 /* Object is not a package element */
 
 #define ACPI_NOT_PACKAGE_ELEMENT    ACPI_UINT32_MAX
+#define ACPI_ALL_PACKAGE_ELEMENTS   (ACPI_UINT32_MAX-1)
 
 /* Always emit warning message, not dependent on node flags */
 
@@ -296,11 +297,19 @@ AcpiNsConvertToBuffer (
 
 ACPI_STATUS
 AcpiNsConvertToUnicode (
+    ACPI_NAMESPACE_NODE     *Scope,
     ACPI_OPERAND_OBJECT     *OriginalObject,
     ACPI_OPERAND_OBJECT     **ReturnObject);
 
 ACPI_STATUS
 AcpiNsConvertToResource (
+    ACPI_NAMESPACE_NODE     *Scope,
+    ACPI_OPERAND_OBJECT     *OriginalObject,
+    ACPI_OPERAND_OBJECT     **ReturnObject);
+
+ACPI_STATUS
+AcpiNsConvertToReference (
+    ACPI_NAMESPACE_NODE     *Scope,
     ACPI_OPERAND_OBJECT     *OriginalObject,
     ACPI_OPERAND_OBJECT     **ReturnObject);
 
diff --git a/src/acpica/source/include/acobject.h b/src/acpica/source/include/acobject.h
index feaa9d1..0d4a333 100644
--- a/src/acpica/source/include/acobject.h
+++ b/src/acpica/source/include/acobject.h
@@ -166,9 +166,10 @@
 #define AOPOBJ_AML_CONSTANT         0x01    /* Integer is an AML constant */
 #define AOPOBJ_STATIC_POINTER       0x02    /* Data is part of an ACPI table, don't delete */
 #define AOPOBJ_DATA_VALID           0x04    /* Object is initialized and data is valid */
-#define AOPOBJ_OBJECT_INITIALIZED   0x08    /* Region is initialized, _REG was run */
-#define AOPOBJ_SETUP_COMPLETE       0x10    /* Region setup is complete */
-#define AOPOBJ_INVALID              0x20    /* Host OS won't allow a Region address */
+#define AOPOBJ_OBJECT_INITIALIZED   0x08    /* Region is initialized */
+#define AOPOBJ_REG_CONNECTED        0x10    /* _REG was run */
+#define AOPOBJ_SETUP_COMPLETE       0x20    /* Region setup is complete */
+#define AOPOBJ_INVALID              0x40    /* Host OS won't allow a Region address */
 
 
 /******************************************************************************
diff --git a/src/acpica/source/include/acopcode.h b/src/acpica/source/include/acopcode.h
index 50bac80..c6b88c1 100644
--- a/src/acpica/source/include/acopcode.h
+++ b/src/acpica/source/include/acopcode.h
@@ -165,7 +165,7 @@
 #define ARGP_BYTELIST_OP                ARGP_LIST1 (ARGP_NAMESTRING)
 #define ARGP_CONCAT_OP                  ARGP_LIST3 (ARGP_TERMARG,    ARGP_TERMARG,       ARGP_TARGET)
 #define ARGP_CONCAT_RES_OP              ARGP_LIST3 (ARGP_TERMARG,    ARGP_TERMARG,       ARGP_TARGET)
-#define ARGP_COND_REF_OF_OP             ARGP_LIST2 (ARGP_SUPERNAME,  ARGP_SUPERNAME)
+#define ARGP_COND_REF_OF_OP             ARGP_LIST2 (ARGP_NAME_OR_REF,ARGP_TARGET)
 #define ARGP_CONNECTFIELD_OP            ARGP_LIST1 (ARGP_NAMESTRING)
 #define ARGP_CONTINUE_OP                ARG_NONE
 #define ARGP_COPY_OP                    ARGP_LIST2 (ARGP_TERMARG,    ARGP_SIMPLENAME)
@@ -225,13 +225,14 @@
 #define ARGP_NAMEPATH_OP                ARGP_LIST1 (ARGP_NAMESTRING)
 #define ARGP_NOOP_OP                    ARG_NONE
 #define ARGP_NOTIFY_OP                  ARGP_LIST2 (ARGP_SUPERNAME,  ARGP_TERMARG)
+#define ARGP_OBJECT_TYPE_OP             ARGP_LIST1 (ARGP_NAME_OR_REF)
 #define ARGP_ONE_OP                     ARG_NONE
 #define ARGP_ONES_OP                    ARG_NONE
 #define ARGP_PACKAGE_OP                 ARGP_LIST3 (ARGP_PKGLENGTH,  ARGP_BYTEDATA,      ARGP_DATAOBJLIST)
 #define ARGP_POWER_RES_OP               ARGP_LIST5 (ARGP_PKGLENGTH,  ARGP_NAME,          ARGP_BYTEDATA,  ARGP_WORDDATA,  ARGP_OBJLIST)
 #define ARGP_PROCESSOR_OP               ARGP_LIST6 (ARGP_PKGLENGTH,  ARGP_NAME,          ARGP_BYTEDATA,  ARGP_DWORDDATA, ARGP_BYTEDATA,  ARGP_OBJLIST)
 #define ARGP_QWORD_OP                   ARGP_LIST1 (ARGP_QWORDDATA)
-#define ARGP_REF_OF_OP                  ARGP_LIST1 (ARGP_SUPERNAME)
+#define ARGP_REF_OF_OP                  ARGP_LIST1 (ARGP_NAME_OR_REF)
 #define ARGP_REGION_OP                  ARGP_LIST4 (ARGP_NAME,       ARGP_BYTEDATA,      ARGP_TERMARG,   ARGP_TERMARG)
 #define ARGP_RELEASE_OP                 ARGP_LIST1 (ARGP_SUPERNAME)
 #define ARGP_RESERVEDFIELD_OP           ARGP_LIST1 (ARGP_NAMESTRING)
@@ -258,7 +259,6 @@
 #define ARGP_TO_HEX_STR_OP              ARGP_LIST2 (ARGP_TERMARG,    ARGP_TARGET)
 #define ARGP_TO_INTEGER_OP              ARGP_LIST2 (ARGP_TERMARG,    ARGP_TARGET)
 #define ARGP_TO_STRING_OP               ARGP_LIST3 (ARGP_TERMARG,    ARGP_TERMARG,       ARGP_TARGET)
-#define ARGP_TYPE_OP                    ARGP_LIST1 (ARGP_SUPERNAME)
 #define ARGP_UNLOAD_OP                  ARGP_LIST1 (ARGP_SUPERNAME)
 #define ARGP_VAR_PACKAGE_OP             ARGP_LIST3 (ARGP_PKGLENGTH,  ARGP_TERMARG,       ARGP_DATAOBJLIST)
 #define ARGP_WAIT_OP                    ARGP_LIST2 (ARGP_SUPERNAME,  ARGP_TERMARG)
@@ -297,7 +297,7 @@
 #define ARGI_BUFFER_OP                  ARGI_LIST1 (ARGI_INTEGER)
 #define ARGI_BYTE_OP                    ARGI_INVALID_OPCODE
 #define ARGI_BYTELIST_OP                ARGI_INVALID_OPCODE
-#define ARGI_CONCAT_OP                  ARGI_LIST3 (ARGI_COMPUTEDATA,ARGI_COMPUTEDATA,   ARGI_TARGETREF)
+#define ARGI_CONCAT_OP                  ARGI_LIST3 (ARGI_ANYTYPE,    ARGI_ANYTYPE,       ARGI_TARGETREF)
 #define ARGI_CONCAT_RES_OP              ARGI_LIST3 (ARGI_BUFFER,     ARGI_BUFFER,        ARGI_TARGETREF)
 #define ARGI_COND_REF_OF_OP             ARGI_LIST2 (ARGI_OBJECT_REF, ARGI_TARGETREF)
 #define ARGI_CONNECTFIELD_OP            ARGI_INVALID_OPCODE
@@ -359,6 +359,7 @@
 #define ARGI_NAMEPATH_OP                ARGI_INVALID_OPCODE
 #define ARGI_NOOP_OP                    ARG_NONE
 #define ARGI_NOTIFY_OP                  ARGI_LIST2 (ARGI_DEVICE_REF, ARGI_INTEGER)
+#define ARGI_OBJECT_TYPE_OP             ARGI_LIST1 (ARGI_ANYTYPE)
 #define ARGI_ONE_OP                     ARG_NONE
 #define ARGI_ONES_OP                    ARG_NONE
 #define ARGI_PACKAGE_OP                 ARGI_LIST1 (ARGI_INTEGER)
@@ -392,7 +393,6 @@
 #define ARGI_TO_HEX_STR_OP              ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
 #define ARGI_TO_INTEGER_OP              ARGI_LIST2 (ARGI_COMPUTEDATA,ARGI_FIXED_TARGET)
 #define ARGI_TO_STRING_OP               ARGI_LIST3 (ARGI_BUFFER,     ARGI_INTEGER,       ARGI_FIXED_TARGET)
-#define ARGI_TYPE_OP                    ARGI_LIST1 (ARGI_ANYTYPE)
 #define ARGI_UNLOAD_OP                  ARGI_LIST1 (ARGI_DDBHANDLE)
 #define ARGI_VAR_PACKAGE_OP             ARGI_LIST1 (ARGI_INTEGER)
 #define ARGI_WAIT_OP                    ARGI_LIST2 (ARGI_EVENT,      ARGI_INTEGER)
diff --git a/src/acpica/source/include/acparser.h b/src/acpica/source/include/acparser.h
index c525dd3..5876383 100644
--- a/src/acpica/source/include/acparser.h
+++ b/src/acpica/source/include/acparser.h
@@ -178,7 +178,12 @@ AcpiPsGetNextNamepath (
     ACPI_WALK_STATE         *WalkState,
     ACPI_PARSE_STATE        *ParserState,
     ACPI_PARSE_OBJECT       *Arg,
-    BOOLEAN                 MethodCall);
+    BOOLEAN                 PossibleMethodCall);
+
+/* Values for BOOLEAN above */
+
+#define ACPI_NOT_METHOD_CALL            FALSE
+#define ACPI_POSSIBLE_METHOD_CALL       TRUE
 
 ACPI_STATUS
 AcpiPsGetNextArg (
diff --git a/src/acpica/source/include/acpixf.h b/src/acpica/source/include/acpixf.h
index 1bb43ea..096c527 100644
--- a/src/acpica/source/include/acpixf.h
+++ b/src/acpica/source/include/acpixf.h
@@ -118,7 +118,7 @@
 
 /* Current ACPICA subsystem version in YYYYMMDD format */
 
-#define ACPI_CA_VERSION                 0x20151124
+#define ACPI_CA_VERSION                 0x20151218
 
 #include "acconfig.h"
 #include "actypes.h"
@@ -264,6 +264,11 @@ ACPI_INIT_GLOBAL (UINT8,            AcpiGbl_CopyDsdtLocally, FALSE);
 ACPI_INIT_GLOBAL (UINT8,            AcpiGbl_DoNotUseXsdt, FALSE);
 
 /*
+ * Optionally allow default region handlers to be overridden.
+ */
+ACPI_INIT_GLOBAL (UINT8,            AcpiGbl_OverrideDefaultRegionHandlers, 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
@@ -341,6 +346,10 @@ ACPI_INIT_GLOBAL (UINT32,           AcpiDbgLevel, ACPI_NORMAL_DEFAULT);
 #endif
 ACPI_INIT_GLOBAL (UINT32,           AcpiDbgLayer, ACPI_COMPONENT_DEFAULT);
 
+/* Optionally enable timer output with Debug Object output */
+
+ACPI_INIT_GLOBAL (UINT8,            AcpiGbl_DisplayDebugTimer, FALSE);
+
 /*
  * Other miscellaneous globals
  */
diff --git a/src/acpica/source/include/amlcode.h b/src/acpica/source/include/amlcode.h
index 6940b7a..8a0ddcc 100644
--- a/src/acpica/source/include/amlcode.h
+++ b/src/acpica/source/include/amlcode.h
@@ -192,7 +192,7 @@
 #define AML_CREATE_WORD_FIELD_OP    (UINT16) 0x8b
 #define AML_CREATE_BYTE_FIELD_OP    (UINT16) 0x8c
 #define AML_CREATE_BIT_FIELD_OP     (UINT16) 0x8d
-#define AML_TYPE_OP                 (UINT16) 0x8e
+#define AML_OBJECT_TYPE_OP          (UINT16) 0x8e
 #define AML_CREATE_QWORD_FIELD_OP   (UINT16) 0x8f     /* ACPI 2.0 */
 #define AML_LAND_OP                 (UINT16) 0x90
 #define AML_LOR_OP                  (UINT16) 0x91
@@ -313,7 +313,8 @@
 #define ARGP_TERMLIST               0x0F
 #define ARGP_WORDDATA               0x10
 #define ARGP_QWORDDATA              0x11
-#define ARGP_SIMPLENAME             0x12
+#define ARGP_SIMPLENAME             0x12 /* NameString | LocalTerm | ArgTerm */
+#define ARGP_NAME_OR_REF            0x13 /* For ObjectType only */
 
 /*
  * Resolved argument types for the AML Interpreter
diff --git a/src/acpica/source/tools/acpiexec/aecommon.h b/src/acpica/source/tools/acpiexec/aecommon.h
index 1aac52b..5ac8d6c 100644
--- a/src/acpica/source/tools/acpiexec/aecommon.h
+++ b/src/acpica/source/tools/acpiexec/aecommon.h
@@ -185,6 +185,10 @@ ACPI_STATUS
 AeInstallTables (
     void);
 
+ACPI_STATUS
+AeLoadTables (
+    void);
+
 void
 AeDumpNamespace (
     void);
diff --git a/src/acpica/source/tools/acpiexec/aehandlers.c b/src/acpica/source/tools/acpiexec/aehandlers.c
index 9a3f913..f56cc2b 100644
--- a/src/acpica/source/tools/acpiexec/aehandlers.c
+++ b/src/acpica/source/tools/acpiexec/aehandlers.c
@@ -765,7 +765,39 @@ AeInstallLateHandlers (
     void)
 {
     ACPI_STATUS             Status;
+    ACPI_HANDLE             Handle;
+
+
+    Status = AcpiGetHandle (NULL, "\\_TZ.TZ1", &Handle);
+    if (ACPI_SUCCESS (Status))
+    {
+        Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
+            AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
+
+        Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
+            AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
+
+        Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
+            AeNotifyHandler1);
+        Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
+            AeNotifyHandler2);
 
+        Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
+            AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
+
+        Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
+            AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
+    }
+
+    Status = AcpiGetHandle (NULL, "\\_PR.CPU0", &Handle);
+    if (ACPI_SUCCESS (Status))
+    {
+        Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
+            AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
+
+        Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
+            AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
+    }
 
 #if (!ACPI_REDUCED_HARDWARE)
     if (!AcpiGbl_ReducedHardware)
@@ -951,37 +983,6 @@ AeInstallEarlyHandlers (
         printf ("No _SB_ found, %s\n", AcpiFormatException (Status));
     }
 
-    Status = AcpiGetHandle (NULL, "\\_TZ.TZ1", &Handle);
-    if (ACPI_SUCCESS (Status))
-    {
-        Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
-            AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
-
-        Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
-            AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
-
-        Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
-            AeNotifyHandler1);
-        Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
-            AeNotifyHandler2);
-
-        Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
-            AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
-
-        Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
-            AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
-    }
-
-    Status = AcpiGetHandle (NULL, "\\_PR.CPU0", &Handle);
-    if (ACPI_SUCCESS (Status))
-    {
-        Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
-            AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
-
-        Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
-            AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
-    }
-
     /*
      * Install handlers that will override the default handlers for some of
      * the space IDs.
diff --git a/src/acpica/source/tools/acpiexec/aeregion.c b/src/acpica/source/tools/acpiexec/aeregion.c
index 46ddcb8..718e68e 100644
--- a/src/acpica/source/tools/acpiexec/aeregion.c
+++ b/src/acpica/source/tools/acpiexec/aeregion.c
@@ -221,59 +221,87 @@ AeRegionInit (
 }
 
 
+/******************************************************************************
+ *
+ * FUNCTION:    AeOverrideRegionHandlers
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Override the default region handlers for memory, i/o, and
+ *              pci_config. Also install a handler for EC. This is part of
+ *              the "install early handlers" functionality.
+ *
+ *****************************************************************************/
+
 void
-AeInstallRegionHandlers (
+AeOverrideRegionHandlers (
     void)
 {
     UINT32                  i;
     ACPI_STATUS             Status;
 
     /*
-     * Install handlers for some of the "device driver" address spaces
-     * such as SMBus, etc.
+     * Install handlers that will override the default handlers for some of
+     * the space IDs.
      */
-    for (i = 0; i < ACPI_ARRAY_LENGTH (SpaceIdList); i++)
+    for (i = 0; i < ACPI_ARRAY_LENGTH (DefaultSpaceIdList); i++)
     {
         /* Install handler at the root object */
 
         Status = AcpiInstallAddressSpaceHandler (ACPI_ROOT_OBJECT,
-            SpaceIdList[i], AeRegionHandler,
+            DefaultSpaceIdList[i], AeRegionHandler,
             AeRegionInit, &AeMyContext);
+
         if (ACPI_FAILURE (Status))
         {
             ACPI_EXCEPTION ((AE_INFO, Status,
                 "Could not install an OpRegion handler for %s space(%u)",
-                AcpiUtGetRegionName((UINT8) SpaceIdList[i]), SpaceIdList[i]));
-            return;
+                AcpiUtGetRegionName ((UINT8) DefaultSpaceIdList[i]),
+                DefaultSpaceIdList[i]));
         }
     }
 }
 
 
+/******************************************************************************
+ *
+ * FUNCTION:    AeInstallRegionHandlers
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Install handlers for the address spaces other than memory,
+ *              i/o, and pci_config.
+ *
+ *****************************************************************************/
+
 void
-AeOverrideRegionHandlers (
+AeInstallRegionHandlers (
     void)
 {
     UINT32                  i;
     ACPI_STATUS             Status;
 
     /*
-     * Install handlers that will override the default handlers for some of
-     * the space IDs.
+     * Install handlers for some of the "device driver" address spaces
+     * such as SMBus, etc.
      */
-    for (i = 0; i < ACPI_ARRAY_LENGTH (DefaultSpaceIdList); i++)
+    for (i = 0; i < ACPI_ARRAY_LENGTH (SpaceIdList); i++)
     {
         /* Install handler at the root object */
 
         Status = AcpiInstallAddressSpaceHandler (ACPI_ROOT_OBJECT,
-            DefaultSpaceIdList[i], AeRegionHandler,
+            SpaceIdList[i], AeRegionHandler,
             AeRegionInit, &AeMyContext);
+
         if (ACPI_FAILURE (Status))
         {
             ACPI_EXCEPTION ((AE_INFO, Status,
-                "Could not install a default OpRegion handler for %s space(%u)",
-                AcpiUtGetRegionName ((UINT8) DefaultSpaceIdList[i]),
-                DefaultSpaceIdList[i]));
+                "Could not install an OpRegion handler for %s space(%u)",
+                AcpiUtGetRegionName((UINT8) SpaceIdList[i]), SpaceIdList[i]));
             return;
         }
     }
diff --git a/src/utilities/kernelscan.c b/src/utilities/kernelscan.c
index 8674e40..33cf2d3 100644
--- a/src/utilities/kernelscan.c
+++ b/src/utilities/kernelscan.c
@@ -29,6 +29,9 @@
 
 #include "config.h"
 
+#undef DATAROOTDIR
+#define DATAROOTDIR "/usr/share/"
+
 #define PARSER_OK		0
 #define PARSER_COMMENT_FOUND	1
 
-- 
2.6.4




More information about the fwts-devel mailing list