From 7e18c49e0c58129623651d87d1a9efdfb0b02a0c Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Thu, 29 Dec 2016 12:33:42 +0100
Subject: [PATCH] WIP ACPICA 20161222

---
 sys/contrib/dev/acpica/changes.txt                 |  89 +++
 .../dev/acpica/generate/unix/acpiexec/Makefile     |   1 +
 .../dev/acpica/generate/unix/acpihelp/Makefile     |   2 +
 sys/contrib/dev/acpica/source/common/acfileio.c    |   2 +-
 sys/contrib/dev/acpica/source/common/ahtable.c     |   6 +-
 sys/contrib/dev/acpica/source/common/ahuuids.c     |   4 +-
 sys/contrib/dev/acpica/source/compiler/aslutils.c  |   2 +-
 .../acpica/source/components/debugger/dbinput.c    | 111 +---
 .../acpica/source/components/debugger/dbxface.c    |  70 +-
 .../source/components/disassembler/dmopcode.c      | 465 ++++++++++++-
 .../acpica/source/components/disassembler/dmwalk.c |  31 +-
 .../acpica/source/components/executer/exconfig.c   |   2 +-
 .../acpica/source/components/executer/exfldio.c    |  15 +-
 .../acpica/source/components/hardware/hwesleep.c   |  27 +-
 .../dev/acpica/source/components/hardware/hwregs.c | 230 ++++++-
 .../acpica/source/components/hardware/hwsleep.c    |  10 +
 .../dev/acpica/source/components/parser/psargs.c   |  81 ++-
 .../dev/acpica/source/components/parser/psloop.c   |   3 +
 .../dev/acpica/source/components/parser/psobject.c |   8 +-
 .../dev/acpica/source/components/parser/pstree.c   |  10 +-
 .../acpica/source/components/utilities/utclib.c    | 142 ++++
 .../acpica/source/components/utilities/utdecode.c  |   4 +-
 .../acpica/source/components/utilities/utdelete.c  |   5 +-
 .../acpica/source/components/utilities/utmutex.c   |  19 -
 .../acpica/source/components/utilities/utresrc.c   |  17 +-
 sys/contrib/dev/acpica/source/include/acclib.h     |  38 ++
 sys/contrib/dev/acpica/source/include/acdebug.h    |   3 +-
 sys/contrib/dev/acpica/source/include/acdisasm.h   |   6 +-
 sys/contrib/dev/acpica/source/include/acexcep.h    |   8 +-
 sys/contrib/dev/acpica/source/include/acglobal.h   |   5 -
 sys/contrib/dev/acpica/source/include/aclocal.h    |   7 +-
 sys/contrib/dev/acpica/source/include/acmacros.h   |  85 ++-
 sys/contrib/dev/acpica/source/include/acopcode.h   |   8 +-
 sys/contrib/dev/acpica/source/include/acpiosxf.h   |  34 +-
 sys/contrib/dev/acpica/source/include/acpixf.h     |  15 +-
 .../dev/acpica/source/include/platform/acefi.h     |   4 +-
 .../dev/acpica/source/include/platform/acefiex.h   |  52 +-
 .../dev/acpica/source/include/platform/acenv.h     |   5 +-
 .../dev/acpica/source/include/platform/aclinux.h   |   5 +-
 .../dev/acpica/source/include/platform/aclinuxex.h |  14 +
 .../source/os_specific/service_layers/osgendbg.c   | 366 +++++++++++
 .../source/os_specific/service_layers/osunixxf.c   |  27 +
 .../source/os_specific/service_layers/oswinxf.c    |  27 +
 .../dev/acpica/source/tools/acpiexec/aemain.c      |  65 +-
 .../dev/acpica/source/tools/acpihelp/acpihelp.h    |  74 ++-
 .../dev/acpica/source/tools/acpihelp/ahaml.c       | 349 ++++++++++
 .../dev/acpica/source/tools/acpihelp/ahamlops.c    |   2 +-
 .../dev/acpica/source/tools/acpihelp/ahasl.c       | 319 +++++++++
 .../dev/acpica/source/tools/acpihelp/ahaslkey.c    |   4 +-
 .../dev/acpica/source/tools/acpihelp/ahaslops.c    |   2 +-
 .../dev/acpica/source/tools/acpihelp/ahdecode.c    | 732 ++-------------------
 .../dev/acpica/source/tools/acpihelp/ahgrammar.c   |   2 +-
 .../dev/acpica/source/tools/acpihelp/ahmain.c      |   2 +
 .../dev/acpica/source/tools/efihello/efihello.c    | 124 ++++
 sys/contrib/dev/acpica/tests/misc/grammar.asl      | 149 ++---
 sys/dev/acpica/Osd/OsdDebug.c                      |  54 +-
 sys/dev/acpica/Osd/OsdHardware.c                   |   9 +
 usr.sbin/acpi/acpiexec/Makefile                    |   1 +
 usr.sbin/acpi/acpihelp/Makefile                    |   2 +
 59 files changed, 2837 insertions(+), 1118 deletions(-)
 create mode 100644 sys/contrib/dev/acpica/source/os_specific/service_layers/osgendbg.c
 create mode 100644 sys/contrib/dev/acpica/source/tools/acpihelp/ahaml.c
 create mode 100644 sys/contrib/dev/acpica/source/tools/acpihelp/ahasl.c
 create mode 100644 sys/contrib/dev/acpica/source/tools/efihello/efihello.c

diff --git a/sys/contrib/dev/acpica/changes.txt b/sys/contrib/dev/acpica/changes.txt
index 52bc749dfe..ee16343813 100644
--- a/sys/contrib/dev/acpica/changes.txt
+++ b/sys/contrib/dev/acpica/changes.txt
@@ -1,4 +1,93 @@
 ----------------------------------------
+22 December 2016. Summary of changes for version 20161222:
+
+
+1) ACPICA kernel-resident subsystem:
+
+AML Debugger: Implemented a new mechanism to simplify and enhance 
+debugger integration into all environments, including kernel debuggers 
+and user-space utilities, as well as remote debug services. This 
+mechanism essentially consists of new OSL interfaces to support debugger 
+initialization/termination, as well as wait/notify interfaces to perform 
+the debugger handshake with the host. Lv Zheng.
+
+    New OSL interfaces:
+        AcpiOsInitializeDebugger (void)
+        AcpiOsTerminateDebugger (void)
+        AcpiOsWaitCommandReady (void)
+        AcpiOsNotifyCommandComplete (void)
+
+    New OS services layer:
+        osgendbg.c -- Example implementation, and used for AcpiExec
+
+Update for Generic Address Space (GAS) support: Although the AccessWidth 
+and/or BitOffset fields of the GAS are not often used, this change now 
+fully supports these fields. This affects the internal support for FADT 
+registers, registers in other ACPI data tables, and the AcpiRead and 
+AcpiWrite public interfaces. Lv Zheng.
+
+Sleep support: In order to simplify integration of ACPI sleep for the 
+various host operating systems, a new OSL interface has been introduced. 
+AcpiOsEnterSleep allows the host to perform any required operations 
+before the final write to the sleep control register(s) is performed by 
+ACPICA. Lv Zheng.
+
+    New OSL interface:
+        AcpiOsEnterSleep(SleepState, RegisterAValue, RegisterBValue)
+
+    Called from these internal interfaces:
+        AcpiHwLegacySleep
+        AcpiHwExtendedSleep
+
+EFI support: Added a very small EFI/ACPICA example application. Provides 
+a simple demo for EFI integration, as well as assisting with resolution 
+of issues related to customer ACPICA/EFI integration. Lv Zheng. See:
+
+    source/tools/efihello/efihello.c
+
+Local C library: Implemented several new functions to enhance ACPICA 
+portability, for environments where these clib functions are not 
+available (such as EFI). Lv Zheng:
+    putchar
+    getchar
+    strpbrk
+    strtok
+    memmove
+
+Fixed a regression where occasionally a valid resource descriptor was 
+incorrectly detected as invalid at runtime, and a 
+AE_AML_NO_RESOURCE_END_TAG was returned.
+
+Fixed a problem with the recently implemented support that enables 
+control method invocations as Target operands to many ASL operators. 
+Warnings of this form: "Needed type [Reference], found [Processor]" were 
+seen at runtime for some method invocations.
+
+Example Code and Data Size: These are the sizes for the OS-independent 
+acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The 
+debug version of the code includes the debug output trace mechanism and 
+has a much larger code and data size.
+
+  Current Release:
+    Non-Debug Version: 141.5K Code, 58.5K Data, 200.0K Total
+    Debug Version:     201.7K Code, 82.7K Data, 284.4K Total
+  Previous Release:
+    Non-Debug Version: 140.5K Code, 58.5K Data, 198.9K Total
+    Debug Version:     201.3K Code, 82.7K Data, 284.0K Total
+
+
+2) iASL Compiler/Disassembler and Tools:
+
+Disassembler: Enhanced output by adding the capability to detect and 
+disassemble ASL Switch/Case statements back to the original ASL source 
+code instead of if/else blocks. David Box.
+
+AcpiHelp: Split a large file into separate files based upon 
+functionality/purpose. New files are:
+    ahaml.c
+    ahasl.c
+
+----------------------------------------
 17 November 2016. Summary of changes for version 20161117:
 
 
diff --git a/sys/contrib/dev/acpica/generate/unix/acpiexec/Makefile b/sys/contrib/dev/acpica/generate/unix/acpiexec/Makefile
index 62850ac274..3191850adf 100644
--- a/sys/contrib/dev/acpica/generate/unix/acpiexec/Makefile
+++ b/sys/contrib/dev/acpica/generate/unix/acpiexec/Makefile
@@ -163,6 +163,7 @@ OBJECTS = \
 	$(OBJDIR)/nsxfeval.o\
 	$(OBJDIR)/nsxfname.o\
 	$(OBJDIR)/nsxfobj.o\
+	$(OBJDIR)/osgendbg.o\
 	$(OBJDIR)/osunixxf.o\
 	$(OBJDIR)/psargs.o\
 	$(OBJDIR)/psloop.o\
diff --git a/sys/contrib/dev/acpica/generate/unix/acpihelp/Makefile b/sys/contrib/dev/acpica/generate/unix/acpihelp/Makefile
index b0896755c2..7f04770d35 100644
--- a/sys/contrib/dev/acpica/generate/unix/acpihelp/Makefile
+++ b/sys/contrib/dev/acpica/generate/unix/acpihelp/Makefile
@@ -28,7 +28,9 @@ HEADERS = \
     $(wildcard $(ACPIHELP)/*.h)
 
 OBJECTS = \
+	$(OBJDIR)/ahaml.o\
 	$(OBJDIR)/ahamlops.o\
+	$(OBJDIR)/ahasl.o\
 	$(OBJDIR)/ahaslkey.o\
 	$(OBJDIR)/ahaslops.o\
 	$(OBJDIR)/ahdecode.o\
diff --git a/sys/contrib/dev/acpica/source/common/acfileio.c b/sys/contrib/dev/acpica/source/common/acfileio.c
index ffa23a64e2..d13d1e7edc 100644
--- a/sys/contrib/dev/acpica/source/common/acfileio.c
+++ b/sys/contrib/dev/acpica/source/common/acfileio.c
@@ -403,7 +403,7 @@ AcValidateTableHeader (
     UINT32                  i;
 
 
-    ACPI_FUNCTION_TRACE ("AcValidateTableHeader");
+    ACPI_FUNCTION_TRACE (AcValidateTableHeader);
 
 
     /* Read a potential table header */
diff --git a/sys/contrib/dev/acpica/source/common/ahtable.c b/sys/contrib/dev/acpica/source/common/ahtable.c
index 67d1be06cc..43f2feecab 100644
--- a/sys/contrib/dev/acpica/source/common/ahtable.c
+++ b/sys/contrib/dev/acpica/source/common/ahtable.c
@@ -51,7 +51,7 @@ const AH_TABLE *
 AcpiAhGetTableInfo (
     char                    *Signature);
 
-extern const AH_TABLE      AcpiSupportedTables[];
+extern const AH_TABLE      Gbl_AcpiSupportedTables[];
 
 
 /*******************************************************************************
@@ -73,7 +73,7 @@ AcpiAhGetTableInfo (
     const AH_TABLE      *Info;
 
 
-    for (Info = AcpiSupportedTables; Info->Signature; Info++)
+    for (Info = Gbl_AcpiSupportedTables; Info->Signature; Info++)
     {
         if (ACPI_COMPARE_NAME (Signature, Info->Signature))
         {
@@ -89,7 +89,7 @@ AcpiAhGetTableInfo (
  * Note: Any tables added here should be duplicated within AcpiDmTableData
  * in the file common/dmtable.c
  */
-const AH_TABLE      AcpiSupportedTables[] =
+const AH_TABLE      Gbl_AcpiSupportedTables[] =
 {
     {ACPI_SIG_ASF,  "Alert Standard Format table"},
     {ACPI_SIG_BERT, "Boot Error Record Table"},
diff --git a/sys/contrib/dev/acpica/source/common/ahuuids.c b/sys/contrib/dev/acpica/source/common/ahuuids.c
index ec75624d46..5708a3c239 100644
--- a/sys/contrib/dev/acpica/source/common/ahuuids.c
+++ b/sys/contrib/dev/acpica/source/common/ahuuids.c
@@ -52,7 +52,7 @@
 /*
  * Table of "known" (ACPI-related) UUIDs
  */
-const AH_UUID  AcpiUuids[] =
+const AH_UUID  Gbl_AcpiUuids[] =
 {
     {"[Controllers]",               NULL},
     {"GPIO Controller",             UUID_GPIO_CONTROLLER},
@@ -112,7 +112,7 @@ AcpiAhMatchUuid (
 
     /* Walk the table of known ACPI-related UUIDs */
 
-    for (Info = AcpiUuids; Info->Description; Info++)
+    for (Info = Gbl_AcpiUuids; Info->Description; Info++)
     {
         /* Null string means desciption is a UUID class */
 
diff --git a/sys/contrib/dev/acpica/source/compiler/aslutils.c b/sys/contrib/dev/acpica/source/compiler/aslutils.c
index 990e72f023..1599a2e5d9 100644
--- a/sys/contrib/dev/acpica/source/compiler/aslutils.c
+++ b/sys/contrib/dev/acpica/source/compiler/aslutils.c
@@ -155,7 +155,7 @@ UtDisplaySupportedTables (
     /* All ACPI tables with the common table header */
 
     printf ("\n  Supported ACPI tables:\n");
-    for (TableData = AcpiSupportedTables, i = 1;
+    for (TableData = Gbl_AcpiSupportedTables, i = 1;
          TableData->Signature; TableData++, i++)
     {
         printf ("%8u) %s    %s\n", i,
diff --git a/sys/contrib/dev/acpica/source/components/debugger/dbinput.c b/sys/contrib/dev/acpica/source/components/debugger/dbinput.c
index 69789849c7..65cacdc296 100644
--- a/sys/contrib/dev/acpica/source/components/debugger/dbinput.c
+++ b/sys/contrib/dev/acpica/source/components/debugger/dbinput.c
@@ -66,10 +66,6 @@ AcpiDbMatchCommand (
     char                    *UserCommand);
 
 static void
-AcpiDbSingleThread (
-    void);
-
-static void
 AcpiDbDisplayCommandInfo (
     const char              *Command,
     BOOLEAN                 DisplayAll);
@@ -1233,61 +1229,17 @@ void ACPI_SYSTEM_XFACE
 AcpiDbExecuteThread (
     void                    *Context)
 {
-    ACPI_STATUS             Status = AE_OK;
-    ACPI_STATUS             MStatus;
-
-
-    while (Status != AE_CTRL_TERMINATE && !AcpiGbl_DbTerminateLoop)
-    {
-        AcpiGbl_MethodExecuting = FALSE;
-        AcpiGbl_StepToNextCall = FALSE;
 
-        MStatus = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady,
-            ACPI_WAIT_FOREVER);
-        if (ACPI_FAILURE (MStatus))
-        {
-            return;
-        }
-
-        Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
-
-        AcpiOsReleaseMutex (AcpiGbl_DbCommandComplete);
-    }
+    (void) AcpiDbUserCommands ();
     AcpiGbl_DbThreadsTerminated = TRUE;
 }
 
 
 /*******************************************************************************
  *
- * FUNCTION:    AcpiDbSingleThread
- *
- * PARAMETERS:  None
- *
- * RETURN:      None
- *
- * DESCRIPTION: Debugger execute thread. Waits for a command line, then
- *              simply dispatches it.
- *
- ******************************************************************************/
-
-static void
-AcpiDbSingleThread (
-    void)
-{
-
-    AcpiGbl_MethodExecuting = FALSE;
-    AcpiGbl_StepToNextCall = FALSE;
-
-    (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
-}
-
-
-/*******************************************************************************
- *
  * FUNCTION:    AcpiDbUserCommands
  *
- * PARAMETERS:  Prompt              - User prompt (depends on mode)
- *              Op                  - Current executing parse op
+ * PARAMETERS:  None
  *
  * RETURN:      None
  *
@@ -1298,8 +1250,7 @@ AcpiDbSingleThread (
 
 ACPI_STATUS
 AcpiDbUserCommands (
-    char                    Prompt,
-    ACPI_PARSE_OBJECT       *Op)
+    void)
 {
     ACPI_STATUS             Status = AE_OK;
 
@@ -1310,56 +1261,34 @@ AcpiDbUserCommands (
 
     while (!AcpiGbl_DbTerminateLoop)
     {
-        /* Force output to console until a command is entered */
-
-        AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
-
-        /* Different prompt if method is executing */
+        /* Wait the readiness of the command */
 
-        if (!AcpiGbl_MethodExecuting)
-        {
-            AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
-        }
-        else
+        Status = AcpiOsWaitCommandReady ();
+        if (ACPI_FAILURE (Status))
         {
-            AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
+            break;
         }
 
-        /* Get the user input line */
+        /* Just call to the command line interpreter */
 
-        Status = AcpiOsGetLine (AcpiGbl_DbLineBuf,
-            ACPI_DB_LINE_BUFFER_SIZE, NULL);
-        if (ACPI_FAILURE (Status))
-        {
-            ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line"));
-            return (Status);
-        }
+        AcpiGbl_MethodExecuting = FALSE;
+        AcpiGbl_StepToNextCall = FALSE;
 
-        /* Check for single or multithreaded debug */
+        (void) AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, NULL, NULL);
 
-        if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
-        {
-            /*
-             * Signal the debug thread that we have a command to execute,
-             * and wait for the command to complete.
-             */
-            AcpiOsReleaseMutex (AcpiGbl_DbCommandReady);
-
-            Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete,
-                ACPI_WAIT_FOREVER);
-            if (ACPI_FAILURE (Status))
-            {
-                return (Status);
-            }
-        }
-        else
-        {
-            /* Just call to the command line interpreter */
+        /* Notify the completion of the command */
 
-            AcpiDbSingleThread ();
+        Status = AcpiOsNotifyCommandComplete ();
+        if (ACPI_FAILURE (Status))
+        {
+            break;
         }
     }
 
+    if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE)
+    {
+        ACPI_EXCEPTION ((AE_INFO, Status, "While parsing command line"));
+    }
     return (Status);
 }
 
diff --git a/sys/contrib/dev/acpica/source/components/debugger/dbxface.c b/sys/contrib/dev/acpica/source/components/debugger/dbxface.c
index 9000695f46..90a9d8a4e9 100644
--- a/sys/contrib/dev/acpica/source/components/debugger/dbxface.c
+++ b/sys/contrib/dev/acpica/source/components/debugger/dbxface.c
@@ -96,50 +96,23 @@ AcpiDbStartCommand (
 
     AcpiGbl_MethodExecuting = TRUE;
     Status = AE_CTRL_TRUE;
+
     while (Status == AE_CTRL_TRUE)
     {
-        if (AcpiGbl_DebuggerConfiguration == DEBUGGER_MULTI_THREADED)
-        {
-            /* Handshake with the front-end that gets user command lines */
+        /* Notify the completion of the command */
 
-            AcpiOsReleaseMutex (AcpiGbl_DbCommandComplete);
-
-            Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady,
-                ACPI_WAIT_FOREVER);
-            if (ACPI_FAILURE (Status))
-            {
-                return (Status);
-            }
-        }
-        else
+        Status = AcpiOsNotifyCommandComplete ();
+        if (ACPI_FAILURE (Status))
         {
-            /* Single threaded, we must get a command line ourselves */
-
-            /* Force output to console until a command is entered */
-
-            AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
-
-            /* Different prompt if method is executing */
-
-            if (!AcpiGbl_MethodExecuting)
-            {
-                AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
-            }
-            else
-            {
-                AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
-            }
+            goto ErrorExit;
+        }
 
-            /* Get the user input line */
+        /* Wait the readiness of the command */
 
-            Status = AcpiOsGetLine (AcpiGbl_DbLineBuf,
-                ACPI_DB_LINE_BUFFER_SIZE, NULL);
-            if (ACPI_FAILURE (Status))
-            {
-                ACPI_EXCEPTION ((AE_INFO, Status,
-                    "While parsing command line"));
-                return (Status);
-            }
+        Status = AcpiOsWaitCommandReady ();
+        if (ACPI_FAILURE (Status))
+        {
+            goto ErrorExit;
         }
 
         Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, WalkState, Op);
@@ -147,6 +120,12 @@ AcpiDbStartCommand (
 
     /* AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); */
 
+ErrorExit:
+    if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE)
+    {
+        ACPI_EXCEPTION ((AE_INFO, Status,
+            "While parsing/handling command line"));
+    }
     return (Status);
 }
 
@@ -494,16 +473,7 @@ AcpiInitializeDebugger (
     {
         /* These were created with one unit, grab it */
 
-        Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete,
-            ACPI_WAIT_FOREVER);
-        if (ACPI_FAILURE (Status))
-        {
-            AcpiOsPrintf ("Could not get debugger mutex\n");
-            return_ACPI_STATUS (Status);
-        }
-
-        Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady,
-            ACPI_WAIT_FOREVER);
+        Status = AcpiOsInitializeDebugger ();
         if (ACPI_FAILURE (Status))
         {
             AcpiOsPrintf ("Could not get debugger mutex\n");
@@ -557,14 +527,14 @@ AcpiTerminateDebugger (
 
     if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
     {
-        AcpiOsReleaseMutex (AcpiGbl_DbCommandReady);
-
         /* Wait the AML Debugger threads */
 
         while (!AcpiGbl_DbThreadsTerminated)
         {
             AcpiOsSleep (100);
         }
+
+        AcpiOsTerminateDebugger ();
     }
 
     if (AcpiGbl_DbBuffer)
diff --git a/sys/contrib/dev/acpica/source/components/disassembler/dmopcode.c b/sys/contrib/dev/acpica/source/components/disassembler/dmopcode.c
index 57e86f7bd3..ac29f4cf8f 100644
--- a/sys/contrib/dev/acpica/source/components/disassembler/dmopcode.c
+++ b/sys/contrib/dev/acpica/source/components/disassembler/dmopcode.c
@@ -69,6 +69,13 @@ static void
 AcpiDmPromoteSubtree (
     ACPI_PARSE_OBJECT       *StartOp);
 
+static BOOLEAN
+AcpiDmIsSwitchBlock (
+    ACPI_PARSE_OBJECT       *Op);
+
+static BOOLEAN
+AcpiDmIsCaseBlock (
+    ACPI_PARSE_OBJECT       *Op);
 
 /*******************************************************************************
  *
@@ -969,6 +976,28 @@ AcpiDmDisassembleOneOp (
         AcpiDmNamestring (Op->Common.Value.Name);
         break;
 
+    case AML_WHILE_OP:
+
+        if (AcpiDmIsSwitchBlock(Op))
+        {
+            AcpiOsPrintf ("%s", "Switch");
+            break;
+        }
+
+        AcpiOsPrintf ("%s", OpInfo->Name);
+        break;
+
+    case AML_IF_OP:
+
+        if (Op->Common.DisasmOpcode == ACPI_DASM_CASE)
+        {
+            AcpiOsPrintf ("%s", "Case");
+            break;
+        }
+
+        AcpiOsPrintf ("%s", OpInfo->Name);
+        break;
+
     case AML_ELSE_OP:
 
         AcpiDmConvertToElseIf (Op);
@@ -1079,6 +1108,12 @@ AcpiDmConvertToElseIf (
     {
         /* Not a proper Else..If sequence, cannot convert to ElseIf */
 
+        if (OriginalElseOp->Common.DisasmOpcode == ACPI_DASM_DEFAULT)
+        {
+            AcpiOsPrintf ("%s", "Default");
+            return;
+        }
+
         AcpiOsPrintf ("%s", "Else");
         return;
     }
@@ -1088,13 +1123,42 @@ AcpiDmConvertToElseIf (
     ElseOp = IfOp->Common.Next;
     if (ElseOp && ElseOp->Common.Next)
     {
+        if (OriginalElseOp->Common.DisasmOpcode == ACPI_DASM_DEFAULT)
+        {
+            AcpiOsPrintf ("%s", "Default");
+            return;
+        }
+
         AcpiOsPrintf ("%s", "Else");
         return;
     }
 
-    /* Emit ElseIf, mark the IF as now an ELSEIF */
+    if (OriginalElseOp->Common.DisasmOpcode == ACPI_DASM_DEFAULT)
+    {
+        /*
+         * There is an ElseIf but in this case the Else is actually
+         * a Default block for a Switch/Case statement. No conversion.
+         */
+        AcpiOsPrintf ("%s", "Default");
+        return;
+    }
+
+    if (OriginalElseOp->Common.DisasmOpcode == ACPI_DASM_CASE)
+    {
+        /*
+         * This ElseIf is actually a Case block for a Switch/Case
+         * statement. Print Case but do not return so that we can
+         * promote the subtree and keep the indentation level.
+         */
+        AcpiOsPrintf ("%s", "Case");
+    }
+    else
+    {
+       /* Emit ElseIf, mark the IF as now an ELSEIF */
+
+        AcpiOsPrintf ("%s", "ElseIf");
+    }
 
-    AcpiOsPrintf ("%s", "ElseIf");
     IfOp->Common.DisasmFlags |= ACPI_PARSEOP_ELSEIF;
 
     /* The IF parent will now be the same as the original ELSE parent */
@@ -1186,4 +1250,401 @@ AcpiDmPromoteSubtree (
     }
 }
 
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmIsTempName
+ *
+ * PARAMETERS:  Op              - Object to be examined
+ *
+ * RETURN:      TRUE if object is a temporary (_T_x) name
+ *
+ * DESCRIPTION: Determine if an object is a temporary name and ignore it.
+ *              Temporary names are only used for Switch statements. This
+ *              function depends on this restriced usage.
+ *
+ ******************************************************************************/
+
+BOOLEAN
+AcpiDmIsTempName (
+    ACPI_PARSE_OBJECT       *Op)
+{
+    char                    *Temp;
+
+    if (Op->Common.AmlOpcode != AML_NAME_OP)
+    {
+        return (FALSE);
+    }
+
+    Temp = (char *)(Op->Common.Aml);
+    ++Temp;
+
+    if (strncmp(Temp, "_T_", 3))
+    {
+        return (FALSE);
+    }
+
+    /* Ignore Op */
+
+    Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+
+    return (TRUE);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmIsSwitchBlock
+ *
+ * PARAMETERS:  Op              - While Object
+ *
+ * RETURN:      TRUE if While block can be converted to a Switch/Case block
+ *
+ * DESCRIPTION: Determines if While block is a Switch/Case statement. Modifies
+ *              parse tree to allow for Switch/Case disassembly during walk.
+ *
+ * EXAMPLE: Example of parse tree to be converted
+ *
+ *    While
+ *        One
+ *        Store
+ *            ByteConst
+ *             -NamePath-
+ *        If
+ *            LEqual
+ *                -NamePath-
+ *                Zero
+ *            Return
+ *                One
+ *        Else
+ *            Return
+ *                WordConst
+ *        Break
+ *
+ ******************************************************************************/
+
+static BOOLEAN
+AcpiDmIsSwitchBlock (
+    ACPI_PARSE_OBJECT       *Op)
+{
+    ACPI_PARSE_OBJECT       *OneOp;
+    ACPI_PARSE_OBJECT       *StoreOp;
+    ACPI_PARSE_OBJECT       *NamePathOp;
+    ACPI_PARSE_OBJECT       *PredicateOp;
+    ACPI_PARSE_OBJECT       *CurrentOp;
+    ACPI_PARSE_OBJECT       *TempOp;
+
+    /* Check for One Op Predicate */
+
+    OneOp = AcpiPsGetArg (Op, 0);
+    if (!OneOp || (OneOp->Common.AmlOpcode != AML_ONE_OP))
+    {
+        return (FALSE);
+    }
+
+    /* Check for Store Op */
+
+    StoreOp = OneOp->Common.Next;
+    if (!StoreOp || (StoreOp->Common.AmlOpcode != AML_STORE_OP))
+    {
+        return (FALSE);
+    }
+
+    /* Check for Name Op with _T_ string */
+
+    NamePathOp = AcpiPsGetArg (StoreOp, 1);
+    if (!NamePathOp || (NamePathOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP))
+    {
+        return (FALSE);
+    }
+
+    if (strncmp((char *)(NamePathOp->Common.Aml), "_T_", 3))
+    {
+        return (FALSE);
+    }
+
+    /* This is a Switch/Case control block */
+
+    /* Ignore the One Op Predicate */
+
+    OneOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+
+    /* Ignore the Store Op, but not the children */
+
+    StoreOp->Common.DisasmOpcode = ACPI_DASM_IGNORE_SINGLE;
+
+    /*
+     * First arg of Store Op is the Switch condition.
+     * Mark it as a Switch predicate and as a parameter list for paren
+     * closing and correct indentation.
+     */
+    PredicateOp = AcpiPsGetArg (StoreOp, 0);
+    PredicateOp->Common.DisasmOpcode = ACPI_DASM_SWITCH_PREDICATE;
+    PredicateOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
+
+    /* Ignore the Name Op */
+
+    NamePathOp->Common.DisasmFlags = ACPI_PARSEOP_IGNORE;
+
+    /* Remaining opcodes are the Case statements (If/ElseIf's) */
+
+    CurrentOp = StoreOp->Common.Next;
+    while (AcpiDmIsCaseBlock (CurrentOp))
+    {
+        /* Block is a Case structure */
+
+        if (CurrentOp->Common.AmlOpcode == AML_ELSE_OP)
+        {
+            /* ElseIf */
+
+            CurrentOp->Common.DisasmOpcode = ACPI_DASM_CASE;
+            CurrentOp = AcpiPsGetArg (CurrentOp, 0);
+        }
+
+        /* If */
+
+        CurrentOp->Common.DisasmOpcode = ACPI_DASM_CASE;
+
+        /*
+         * Mark the parse tree for Case disassembly. There are two
+         * types of Case statements. The first type of statement begins with
+         * an LEqual. The second starts with an LNot and uses a Match statement
+         * on a Package of constants.
+         */
+        TempOp = AcpiPsGetArg (CurrentOp, 0);
+        switch (TempOp->Common.AmlOpcode)
+        {
+            case (AML_LEQUAL_OP):
+
+                /* Ignore just the LEqual Op */
+
+                TempOp->Common.DisasmOpcode = ACPI_DASM_IGNORE_SINGLE;
+
+                /* Ignore the NamePath Op */
+
+                TempOp = AcpiPsGetArg (TempOp, 0);
+                TempOp->Common.DisasmFlags = ACPI_PARSEOP_IGNORE;
+
+                /*
+                 * Second arg of LEqual will be the Case predicate.
+                 * Mark it as a predicate and also as a parameter list for paren
+                 * closing and correct indentation.
+                 */
+                PredicateOp = TempOp->Common.Next;
+                PredicateOp->Common.DisasmOpcode = ACPI_DASM_SWITCH_PREDICATE;
+                PredicateOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
+
+                break;
+
+            case (AML_LNOT_OP):
+
+                /*
+                 * The Package will be the predicate of the Case statement.
+                 * It's under:
+                 *            LNOT
+                 *                LEQUAL
+                 *                    MATCH
+                 *                        PACKAGE
+                 */
+
+                /* Get the LEqual Op from LNot */
+
+                TempOp = AcpiPsGetArg (TempOp, 0);
+
+                /* Get the Match Op from LEqual */
+
+                TempOp = AcpiPsGetArg (TempOp, 0);
+
+                /* Get the Package Op from Match */
+
+                PredicateOp = AcpiPsGetArg (TempOp, 0);
+
+                /* Mark as parameter list for paren closing */
+
+                PredicateOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
+
+                /*
+                 * The Package list would be too deeply indented if we
+                 * chose to simply ignore the all the parent opcodes, so
+                 * we rearrange the parse tree instead.
+                 */
+
+                /*
+                 * Save the second arg of the If/Else Op which is the
+                 * block code of code for this Case statement.
+                 */
+                TempOp = AcpiPsGetArg (CurrentOp, 1);
+
+                /*
+                 * Move the Package Op to the child (predicate) of the
+                 * Case statement.
+                 */
+                CurrentOp->Common.Value.Arg = PredicateOp;
+                PredicateOp->Common.Parent = CurrentOp;
+
+                /* Add the block code */
+
+                PredicateOp->Common.Next = TempOp;
+
+                break;
+
+            default:
+
+                /* Should never get here */
+
+                break;
+        }
+
+        /* Advance to next Case block */
+
+        CurrentOp = CurrentOp->Common.Next;
+    }
+
+    /* If CurrentOp is now an Else, then this is a Default block */
+
+    if (CurrentOp && CurrentOp->Common.AmlOpcode == AML_ELSE_OP)
+    {
+        CurrentOp->Common.DisasmOpcode = ACPI_DASM_DEFAULT;
+    }
+
+    /*
+     * From the first If advance to the Break op. It's possible to
+     * have an Else (Default) op here when there is only one Case
+     * statement, so check for it.
+     */
+    CurrentOp = StoreOp->Common.Next->Common.Next;
+    if (CurrentOp->Common.AmlOpcode == AML_ELSE_OP)
+    {
+        CurrentOp = CurrentOp->Common.Next;
+    }
+
+    /* Ignore the Break Op */
+
+    CurrentOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+
+    return (TRUE);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AcpiDmIsCaseBlock
+ *
+ * PARAMETERS:  Op              - Object to test
+ *
+ * RETURN:      TRUE if Object is beginning of a Case block.
+ *
+ * DESCRIPTION: Determines if an Object is the beginning of a Case block for a
+ *              Switch/Case statement. Parse tree must be one of the following
+ *              forms:
+ *
+ *              Else (Optional)
+ *                  If
+ *                      LEqual
+ *                          -NamePath- _T_x
+ *
+ *              Else (Optional)
+ *                  If
+ *                      LNot
+ *                          LEqual
+ *                              Match
+ *                                  Package
+ *                                      ByteConst
+ *                                      -NamePath- _T_x
+ *
+ ******************************************************************************/
+
+static BOOLEAN
+AcpiDmIsCaseBlock (
+    ACPI_PARSE_OBJECT       *Op)
+{
+    ACPI_PARSE_OBJECT       *CurrentOp;
+
+    if (!Op)
+    {
+        return (FALSE);
+    }
+
+    /* Look for an If or ElseIf */
+
+    CurrentOp = Op;
+    if (CurrentOp->Common.AmlOpcode == AML_ELSE_OP)
+    {
+        CurrentOp = AcpiPsGetArg (CurrentOp, 0);
+        if (!CurrentOp)
+        {
+            return (FALSE);
+        }
+    }
+
+    if (!CurrentOp || CurrentOp->Common.AmlOpcode != AML_IF_OP)
+    {
+        return (FALSE);
+    }
+
+    /* Child must be LEqual or LNot */
+
+    CurrentOp = AcpiPsGetArg (CurrentOp, 0);
+    if (!CurrentOp)
+    {
+        return (FALSE);
+    }
+
+    switch (CurrentOp->Common.AmlOpcode)
+    {
+        case (AML_LEQUAL_OP):
+
+            /* Next child must be NamePath with string _T_ */
+
+            CurrentOp = AcpiPsGetArg (CurrentOp, 0);
+            if (!CurrentOp || !CurrentOp->Common.Value.Name ||
+                strncmp(CurrentOp->Common.Value.Name, "_T_", 3))
+            {
+                return (FALSE);
+            }
+
+            break;
+
+        case (AML_LNOT_OP):
+
+            /* Child of LNot must be LEqual op */
+
+            CurrentOp = AcpiPsGetArg (CurrentOp, 0);
+            if (!CurrentOp || (CurrentOp->Common.AmlOpcode != AML_LEQUAL_OP))
+            {
+                return (FALSE);
+            }
+
+            /* Child of LNot must be Match op */
+
+            CurrentOp = AcpiPsGetArg (CurrentOp, 0);
+            if (!CurrentOp || (CurrentOp->Common.AmlOpcode != AML_MATCH_OP))
+            {
+                return (FALSE);
+            }
+
+            /* First child of Match must be Package op */
+
+            CurrentOp = AcpiPsGetArg (CurrentOp, 0);
+            if (!CurrentOp || (CurrentOp->Common.AmlOpcode != AML_PACKAGE_OP))
+            {
+                return (FALSE);
+            }
+
+            /* Third child of Match must be NamePath with string _T_ */
+
+            CurrentOp = AcpiPsGetArg (CurrentOp->Common.Parent, 2);
+            if (!CurrentOp || !CurrentOp->Common.Value.Name ||
+                strncmp(CurrentOp->Common.Value.Name, "_T_", 3))
+            {
+                return (FALSE);
+            }
+
+            break;
+
+        default:
+
+            return (FALSE);
+    }
+
+    return (TRUE);
+}
+
 #endif  /* ACPI_DISASSEMBLER */
diff --git a/sys/contrib/dev/acpica/source/components/disassembler/dmwalk.c b/sys/contrib/dev/acpica/source/components/disassembler/dmwalk.c
index 621121141c..6decf66450 100644
--- a/sys/contrib/dev/acpica/source/components/disassembler/dmwalk.c
+++ b/sys/contrib/dev/acpica/source/components/disassembler/dmwalk.c
@@ -457,6 +457,20 @@ AcpiDmDescendingOp (
         return (AE_CTRL_DEPTH);
     }
 
+    if (AcpiDmIsTempName(Op))
+    {
+        /* Ignore compiler generated temporary names */
+
+        return (AE_CTRL_DEPTH);
+    }
+
+    if (Op->Common.DisasmOpcode == ACPI_DASM_IGNORE_SINGLE)
+    {
+        /* Ignore this op, but not it's children */
+
+        return (AE_OK);
+    }
+
     if (Op->Common.AmlOpcode == AML_IF_OP)
     {
         NextOp = AcpiPsGetDepthNext (NULL, Op);
@@ -891,7 +905,8 @@ AcpiDmAscendingOp (
     ACPI_PARSE_OBJECT       *ParentOp;
 
 
-    if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE)
+    if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE ||
+        Op->Common.DisasmOpcode == ACPI_DASM_IGNORE_SINGLE)
     {
         /* Ignore this op -- it was handled elsewhere */
 
@@ -1051,9 +1066,12 @@ AcpiDmAscendingOp (
 
         /*
          * Just completed a parameter node for something like "Buffer (param)".
-         * Close the paren and open up the term list block with a brace
+         * Close the paren and open up the term list block with a brace.
+         *
+         * Switch predicates don't have a Next node but require a closing paren
+         * and opening brace.
          */
-        if (Op->Common.Next)
+        if (Op->Common.Next || Op->Common.DisasmOpcode == ACPI_DASM_SWITCH_PREDICATE)
         {
             AcpiOsPrintf (")");
 
@@ -1068,6 +1086,13 @@ AcpiDmAscendingOp (
                 AcpiDmPredefinedDescription (ParentOp);
             }
 
+            /* Correct the indentation level for Switch and Case predicates */
+
+            if (Op->Common.DisasmOpcode == ACPI_DASM_SWITCH_PREDICATE)
+            {
+                --Level;
+            }
+
             AcpiOsPrintf ("\n");
             AcpiDmIndent (Level - 1);
             AcpiOsPrintf ("{\n");
diff --git a/sys/contrib/dev/acpica/source/components/executer/exconfig.c b/sys/contrib/dev/acpica/source/components/executer/exconfig.c
index f49b0a9fa9..c61b148922 100644
--- a/sys/contrib/dev/acpica/source/components/executer/exconfig.c
+++ b/sys/contrib/dev/acpica/source/components/executer/exconfig.c
@@ -224,7 +224,7 @@ AcpiExLoadTableOp (
     AcpiExEnterInterpreter ();
     if (ACPI_FAILURE (Status))
     {
-	return_ACPI_STATUS (Status);
+        return_ACPI_STATUS (Status);
     }
 
     Status = AcpiExAddTable (TableIndex, &DdbHandle);
diff --git a/sys/contrib/dev/acpica/source/components/executer/exfldio.c b/sys/contrib/dev/acpica/source/components/executer/exfldio.c
index fd46a0c023..a865a86ae1 100644
--- a/sys/contrib/dev/acpica/source/components/executer/exfldio.c
+++ b/sys/contrib/dev/acpica/source/components/executer/exfldio.c
@@ -946,20 +946,9 @@ AcpiExInsertIntoField (
 
     AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth);
 
-    /*
-     * Create the bitmasks used for bit insertion.
-     * Note: This if/else is used to bypass compiler differences with the
-     * shift operator
-     */
-    if (AccessBitWidth == ACPI_INTEGER_BIT_SIZE)
-    {
-        WidthMask = ACPI_UINT64_MAX;
-    }
-    else
-    {
-        WidthMask = ACPI_MASK_BITS_ABOVE (AccessBitWidth);
-    }
+    /* Create the bitmasks used for bit insertion */
 
+    WidthMask = ACPI_MASK_BITS_ABOVE_64 (AccessBitWidth);
     Mask = WidthMask &
         ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset);
 
diff --git a/sys/contrib/dev/acpica/source/components/hardware/hwesleep.c b/sys/contrib/dev/acpica/source/components/hardware/hwesleep.c
index de914df853..52b6964e69 100644
--- a/sys/contrib/dev/acpica/source/components/hardware/hwesleep.c
+++ b/sys/contrib/dev/acpica/source/components/hardware/hwesleep.c
@@ -113,7 +113,7 @@ AcpiHwExtendedSleep (
     UINT8                   SleepState)
 {
     ACPI_STATUS             Status;
-    UINT8                   SleepTypeValue;
+    UINT8                   SleepControl;
     UINT64                  SleepStatus;
 
 
@@ -139,10 +139,6 @@ AcpiHwExtendedSleep (
 
     AcpiGbl_SystemAwakeAndRunning = FALSE;
 
-    /* Flush caches, as per ACPI specification */
-
-    ACPI_FLUSH_CPU_CACHE ();
-
     /*
      * Set the SLP_TYP and SLP_EN bits.
      *
@@ -152,11 +148,24 @@ AcpiHwExtendedSleep (
     ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
         "Entering sleep state [S%u]\n", SleepState));
 
-    SleepTypeValue = ((AcpiGbl_SleepTypeA << ACPI_X_SLEEP_TYPE_POSITION) &
-        ACPI_X_SLEEP_TYPE_MASK);
+    SleepControl = ((AcpiGbl_SleepTypeA << ACPI_X_SLEEP_TYPE_POSITION) &
+        ACPI_X_SLEEP_TYPE_MASK) | ACPI_X_SLEEP_ENABLE;
+
+    /* Flush caches, as per ACPI specification */
+
+    ACPI_FLUSH_CPU_CACHE ();
+
+    Status = AcpiOsEnterSleep (SleepState, SleepControl, 0);
+    if (Status == AE_CTRL_TERMINATE)
+    {
+        return_ACPI_STATUS (AE_OK);
+    }
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
 
-    Status = AcpiWrite ((UINT64) (SleepTypeValue | ACPI_X_SLEEP_ENABLE),
-        &AcpiGbl_FADT.SleepControl);
+    Status = AcpiWrite ((UINT64) SleepControl, &AcpiGbl_FADT.SleepControl);
     if (ACPI_FAILURE (Status))
     {
         return_ACPI_STATUS (Status);
diff --git a/sys/contrib/dev/acpica/source/components/hardware/hwregs.c b/sys/contrib/dev/acpica/source/components/hardware/hwregs.c
index bc85c96b55..744186b87c 100644
--- a/sys/contrib/dev/acpica/source/components/hardware/hwregs.c
+++ b/sys/contrib/dev/acpica/source/components/hardware/hwregs.c
@@ -54,6 +54,12 @@
 
 /* Local Prototypes */
 
+static UINT8
+AcpiHwGetAccessBitWidth (
+    UINT64                  Address,
+    ACPI_GENERIC_ADDRESS    *Reg,
+    UINT8                   MaxBitWidth);
+
 static ACPI_STATUS
 AcpiHwReadMultiple (
     UINT32                  *Value,
@@ -71,6 +77,90 @@ AcpiHwWriteMultiple (
 
 /******************************************************************************
  *
+ * FUNCTION:    AcpiHwGetAccessBitWidth
+ *
+ * PARAMETERS:  Address             - GAS register address
+ *              Reg                 - GAS register structure
+ *              MaxBitWidth         - Max BitWidth supported (32 or 64)
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Obtain optimal access bit width
+ *
+ ******************************************************************************/
+
+static UINT8
+AcpiHwGetAccessBitWidth (
+    UINT64                  Address,
+    ACPI_GENERIC_ADDRESS    *Reg,
+    UINT8                   MaxBitWidth)
+{
+    UINT8                   AccessBitWidth;
+
+
+    /*
+     * GAS format "register", used by FADT:
+     *  1. Detected if BitOffset is 0 and BitWidth is 8/16/32/64;
+     *  2. AccessSize field is ignored and BitWidth field is used for
+     *     determining the boundary of the IO accesses.
+     * GAS format "region", used by APEI registers:
+     *  1. Detected if BitOffset is not 0 or BitWidth is not 8/16/32/64;
+     *  2. AccessSize field is used for determining the boundary of the
+     *     IO accesses;
+     *  3. BitOffset/BitWidth fields are used to describe the "region".
+     *
+     * Note: This algorithm assumes that the "Address" fields should always
+     *       contain aligned values.
+     */
+    if (!Reg->BitOffset && Reg->BitWidth &&
+        ACPI_IS_POWER_OF_TWO (Reg->BitWidth) &&
+        ACPI_IS_ALIGNED (Reg->BitWidth, 8))
+    {
+        AccessBitWidth = Reg->BitWidth;
+    }
+    else if (Reg->AccessWidth)
+    {
+        AccessBitWidth = (1 << (Reg->AccessWidth + 2));
+    }
+    else
+    {
+        AccessBitWidth = ACPI_ROUND_UP_POWER_OF_TWO_8 (
+            Reg->BitOffset + Reg->BitWidth);
+        if (AccessBitWidth <= 8)
+        {
+            AccessBitWidth = 8;
+        }
+        else
+        {
+            while (!ACPI_IS_ALIGNED (Address, AccessBitWidth >> 3))
+            {
+                AccessBitWidth >>= 1;
+            }
+        }
+    }
+
+    /* Maximum IO port access bit width is 32 */
+
+    if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_IO)
+    {
+        MaxBitWidth = 32;
+    }
+
+    /*
+     * Return access width according to the requested maximum access bit width,
+     * as the caller should know the format of the register and may enforce
+     * a 32-bit accesses.
+     */
+    if (AccessBitWidth < MaxBitWidth)
+    {
+        return (AccessBitWidth);
+    }
+    return (MaxBitWidth);
+}
+
+
+/******************************************************************************
+ *
  * FUNCTION:    AcpiHwValidateRegister
  *
  * PARAMETERS:  Reg                 - GAS register structure
@@ -91,6 +181,9 @@ AcpiHwValidateRegister (
     UINT8                   MaxBitWidth,
     UINT64                  *Address)
 {
+    UINT8                   BitWidth;
+    UINT8                   AccessWidth;
+
 
     /* Must have a valid pointer to a GAS structure */
 
@@ -120,24 +213,25 @@ AcpiHwValidateRegister (
         return (AE_SUPPORT);
     }
 
-    /* Validate the BitWidth */
+    /* Validate the AccessWidth */
 
-    if ((Reg->BitWidth != 8) &&
-        (Reg->BitWidth != 16) &&
-        (Reg->BitWidth != 32) &&
-        (Reg->BitWidth != MaxBitWidth))
+    if (Reg->AccessWidth > 4)
     {
         ACPI_ERROR ((AE_INFO,
-            "Unsupported register bit width: 0x%X", Reg->BitWidth));
+            "Unsupported register access width: 0x%X", Reg->AccessWidth));
         return (AE_SUPPORT);
     }
 
-    /* Validate the BitOffset. Just a warning for now. */
+    /* Validate the BitWidth, convert AccessWidth into number of bits */
 
-    if (Reg->BitOffset != 0)
+    AccessWidth = AcpiHwGetAccessBitWidth (*Address, Reg, MaxBitWidth);
+    BitWidth = ACPI_ROUND_UP (Reg->BitOffset + Reg->BitWidth, AccessWidth);
+    if (MaxBitWidth < BitWidth)
     {
         ACPI_WARNING ((AE_INFO,
-            "Unsupported register bit offset: 0x%X", Reg->BitOffset));
+            "Requested bit width 0x%X is smaller than register bit width 0x%X",
+            MaxBitWidth, BitWidth));
+        return (AE_SUPPORT);
     }
 
     return (AE_OK);
@@ -158,10 +252,7 @@ AcpiHwValidateRegister (
  *              64-bit values is not needed.
  *
  * LIMITATIONS: <These limitations also apply to AcpiHwWrite>
- *      BitWidth must be exactly 8, 16, or 32.
  *      SpaceID must be SystemMemory or SystemIO.
- *      BitOffset and AccessWidth are currently ignored, as there has
- *          not been a need to implement these.
  *
  ******************************************************************************/
 
@@ -171,7 +262,12 @@ AcpiHwRead (
     ACPI_GENERIC_ADDRESS    *Reg)
 {
     UINT64                  Address;
+    UINT8                   AccessWidth;
+    UINT32                  BitWidth;
+    UINT8                   BitOffset;
     UINT64                  Value64;
+    UINT32                  Value32;
+    UINT8                   Index;
     ACPI_STATUS             Status;
 
 
@@ -186,30 +282,58 @@ AcpiHwRead (
         return (Status);
     }
 
-    /* Initialize entire 32-bit return value to zero */
-
+    /*
+     * Initialize entire 32-bit return value to zero, convert AccessWidth
+     * into number of bits based
+     */
     *Value = 0;
+    AccessWidth = AcpiHwGetAccessBitWidth (Address, Reg, 32);
+    BitWidth = Reg->BitOffset + Reg->BitWidth;
+    BitOffset = Reg->BitOffset;
 
     /*
      * Two address spaces supported: Memory or IO. PCI_Config is
      * not supported here because the GAS structure is insufficient
      */
-    if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
+    Index = 0;
+    while (BitWidth)
     {
-        Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS)
-            Address, &Value64, Reg->BitWidth);
+        if (BitOffset >= AccessWidth)
+        {
+            Value32 = 0;
+            BitOffset -= AccessWidth;
+        }
+        else
+        {
+            if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
+            {
+                Status = AcpiOsReadMemory ((ACPI_PHYSICAL_ADDRESS)
+                    Address + Index * ACPI_DIV_8 (AccessWidth),
+                    &Value64, AccessWidth);
+                Value32 = (UINT32) Value64;
+            }
+            else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
+            {
+                Status = AcpiHwReadPort ((ACPI_IO_ADDRESS)
+                    Address + Index * ACPI_DIV_8 (AccessWidth),
+                    &Value32, AccessWidth);
+            }
+        }
 
-        *Value = (UINT32) Value64;
-    }
-    else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
-    {
-        Status = AcpiHwReadPort ((ACPI_IO_ADDRESS)
-            Address, Value, Reg->BitWidth);
+        /*
+         * Use offset style bit writes because "Index * AccessWidth" is
+         * ensured to be less than 32-bits by AcpiHwValidateRegister().
+         */
+        ACPI_SET_BITS (Value, Index * AccessWidth,
+            ACPI_MASK_BITS_ABOVE_32 (AccessWidth), Value32);
+
+        BitWidth -= BitWidth > AccessWidth ? AccessWidth : BitWidth;
+        Index++;
     }
 
     ACPI_DEBUG_PRINT ((ACPI_DB_IO,
         "Read:  %8.8X width %2d from %8.8X%8.8X (%s)\n",
-        *Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address),
+        *Value, AccessWidth, ACPI_FORMAT_UINT64 (Address),
         AcpiUtGetRegionName (Reg->SpaceId)));
 
     return (Status);
@@ -237,6 +361,12 @@ AcpiHwWrite (
     ACPI_GENERIC_ADDRESS    *Reg)
 {
     UINT64                  Address;
+    UINT8                   AccessWidth;
+    UINT32                  BitWidth;
+    UINT8                   BitOffset;
+    UINT64                  Value64;
+    UINT32                  Value32;
+    UINT8                   Index;
     ACPI_STATUS             Status;
 
 
@@ -251,24 +381,58 @@ AcpiHwWrite (
         return (Status);
     }
 
+    /* Convert AccessWidth into number of bits based */
+
+    AccessWidth = AcpiHwGetAccessBitWidth (Address, Reg, 32);
+    BitWidth = Reg->BitOffset + Reg->BitWidth;
+    BitOffset = Reg->BitOffset;
+
     /*
      * Two address spaces supported: Memory or IO. PCI_Config is
      * not supported here because the GAS structure is insufficient
      */
-    if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
+    Index = 0;
+    while (BitWidth)
     {
-        Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS)
-            Address, (UINT64) Value, Reg->BitWidth);
-    }
-    else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
-    {
-        Status = AcpiHwWritePort ((ACPI_IO_ADDRESS)
-            Address, Value, Reg->BitWidth);
+        /*
+         * Use offset style bit reads because "Index * AccessWidth" is
+         * ensured to be less than 32-bits by AcpiHwValidateRegister().
+         */
+        Value32 = ACPI_GET_BITS (&Value, Index * AccessWidth,
+            ACPI_MASK_BITS_ABOVE_32 (AccessWidth));
+
+        if (BitOffset >= AccessWidth)
+        {
+            BitOffset -= AccessWidth;
+        }
+        else
+        {
+            if (Reg->SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY)
+            {
+                Value64 = (UINT64) Value32;
+                Status = AcpiOsWriteMemory ((ACPI_PHYSICAL_ADDRESS)
+                    Address + Index * ACPI_DIV_8 (AccessWidth),
+                    Value64, AccessWidth);
+            }
+            else /* ACPI_ADR_SPACE_SYSTEM_IO, validated earlier */
+            {
+                Status = AcpiHwWritePort ((ACPI_IO_ADDRESS)
+                    Address + Index * ACPI_DIV_8 (AccessWidth),
+                    Value32, AccessWidth);
+            }
+        }
+
+        /*
+         * Index * AccessWidth is ensured to be less than 32-bits by
+         * AcpiHwValidateRegister().
+         */
+        BitWidth -= BitWidth > AccessWidth ? AccessWidth : BitWidth;
+        Index++;
     }
 
     ACPI_DEBUG_PRINT ((ACPI_DB_IO,
         "Wrote: %8.8X width %2d   to %8.8X%8.8X (%s)\n",
-        Value, Reg->BitWidth, ACPI_FORMAT_UINT64 (Address),
+        Value, AccessWidth, ACPI_FORMAT_UINT64 (Address),
         AcpiUtGetRegionName (Reg->SpaceId)));
 
     return (Status);
diff --git a/sys/contrib/dev/acpica/source/components/hardware/hwsleep.c b/sys/contrib/dev/acpica/source/components/hardware/hwsleep.c
index 13cf255137..2431d9a8d4 100644
--- a/sys/contrib/dev/acpica/source/components/hardware/hwsleep.c
+++ b/sys/contrib/dev/acpica/source/components/hardware/hwsleep.c
@@ -159,6 +159,16 @@ AcpiHwLegacySleep (
 
     ACPI_FLUSH_CPU_CACHE ();
 
+    Status = AcpiOsEnterSleep (SleepState, Pm1aControl, Pm1bControl);
+    if (Status == AE_CTRL_TERMINATE)
+    {
+        return_ACPI_STATUS (AE_OK);
+    }
+    if (ACPI_FAILURE (Status))
+    {
+        return_ACPI_STATUS (Status);
+    }
+
     /* Write #2: Write both SLP_TYP + SLP_EN */
 
     Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl);
diff --git a/sys/contrib/dev/acpica/source/components/parser/psargs.c b/sys/contrib/dev/acpica/source/components/parser/psargs.c
index a4745c3adc..67d8aef26e 100644
--- a/sys/contrib/dev/acpica/source/components/parser/psargs.c
+++ b/sys/contrib/dev/acpica/source/components/parser/psargs.c
@@ -298,23 +298,26 @@ AcpiPsGetNextNamepath (
         PossibleMethodCall &&
         (Node->Type == ACPI_TYPE_METHOD))
     {
-        if (WalkState->Opcode == AML_UNLOAD_OP)
+        if ((GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) == ARGP_SUPERNAME) ||
+            (GET_CURRENT_ARG_TYPE (WalkState->ArgTypes) == ARGP_TARGET))
         {
             /*
-             * AcpiPsGetNextNamestring has increased the AML pointer,
-             * so we need to restore the saved AML pointer for method call.
+             * AcpiPsGetNextNamestring has increased the AML pointer past
+             * the method invocation namestring, so we need to restore the
+             * saved AML pointer back to the original method invocation
+             * namestring.
              */
             WalkState->ParserState.Aml = Start;
             WalkState->ArgCount = 1;
             AcpiPsInitOp (Arg, AML_INT_METHODCALL_OP);
-            return_ACPI_STATUS (AE_OK);
         }
 
         /* This name is actually a control method invocation */
 
         MethodDesc = AcpiNsGetAttachedObject (Node);
         ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
-            "Control Method - %p Desc %p Path=%p\n", Node, MethodDesc, Path));
+            "Control Method invocation %4.4s - %p Desc %p Path=%p\n",
+            Node->Name.Ascii, Node, MethodDesc, Path));
 
         NameOp = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, Start);
         if (!NameOp)
@@ -771,6 +774,10 @@ AcpiPsGetNextArg (
     ACPI_FUNCTION_TRACE_PTR (PsGetNextArg, ParserState);
 
 
+    ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+        "Expected argument type ARGP: %s (%2.2X)\n",
+        AcpiUtGetArgumentTypeName (ArgType), ArgType));
+
     switch (ArgType)
     {
     case ARGP_BYTEDATA:
@@ -854,11 +861,13 @@ AcpiPsGetNextArg (
         }
         break;
 
-    case ARGP_TARGET:
-    case ARGP_SUPERNAME:
     case ARGP_SIMPLENAME:
     case ARGP_NAME_OR_REF:
 
+        ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+            "**** SimpleName/NameOrRef: %s (%2.2X)\n",
+            AcpiUtGetArgumentTypeName (ArgType), ArgType));
+
         Subop = AcpiPsPeekOpcode (ParserState);
         if (Subop == 0                  ||
             AcpiPsIsLeadingChar (Subop) ||
@@ -873,27 +882,46 @@ AcpiPsGetNextArg (
                 return_ACPI_STATUS (AE_NO_MEMORY);
             }
 
-            /* To support SuperName arg of Unload */
+            Status = AcpiPsGetNextNamepath (WalkState, ParserState,
+                Arg, ACPI_NOT_METHOD_CALL);
+        }
+        else
+        {
+            /* Single complex argument, nothing returned */
+
+            WalkState->ArgCount = 1;
+        }
+        break;
+
+    case ARGP_TARGET:
+    case ARGP_SUPERNAME:
+
+        ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+            "**** Target/Supername: %s (%2.2X)\n",
+            AcpiUtGetArgumentTypeName (ArgType), ArgType));
 
-            if (WalkState->Opcode == AML_UNLOAD_OP)
+        Subop = AcpiPsPeekOpcode (ParserState);
+        if (Subop == 0                  ||
+            AcpiPsIsLeadingChar (Subop) ||
+            ACPI_IS_ROOT_PREFIX (Subop) ||
+            ACPI_IS_PARENT_PREFIX (Subop))
+        {
+            /* NULL target (zero). Convert to a NULL namepath */
+
+            Arg = AcpiPsAllocOp (AML_INT_NAMEPATH_OP, ParserState->Aml);
+            if (!Arg)
             {
-                Status = AcpiPsGetNextNamepath (WalkState, ParserState,
-                    Arg, ACPI_POSSIBLE_METHOD_CALL);
-
-                /*
-                 * 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)
-                {
-                    AcpiPsFreeOp (Arg);
-                    Arg = NULL;
-                }
+                return_ACPI_STATUS (AE_NO_MEMORY);
             }
-            else
+
+            Status = AcpiPsGetNextNamepath (WalkState, ParserState,
+                Arg, ACPI_POSSIBLE_METHOD_CALL);
+
+            if (Arg->Common.AmlOpcode == AML_INT_METHODCALL_OP)
             {
-                Status = AcpiPsGetNextNamepath (WalkState, ParserState,
-                    Arg, ACPI_NOT_METHOD_CALL);
+                AcpiPsFreeOp (Arg);
+                Arg = NULL;
+                WalkState->ArgCount = 1;
             }
         }
         else
@@ -907,6 +935,11 @@ AcpiPsGetNextArg (
     case ARGP_DATAOBJ:
     case ARGP_TERMARG:
 
+
+    ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+        "**** TermArg/DataObj: %s (%2.2X)\n",
+        AcpiUtGetArgumentTypeName (ArgType), ArgType));
+
         /* Single complex argument, nothing returned */
 
         WalkState->ArgCount = 1;
diff --git a/sys/contrib/dev/acpica/source/components/parser/psloop.c b/sys/contrib/dev/acpica/source/components/parser/psloop.c
index e0839fd7d8..5056cd1de7 100644
--- a/sys/contrib/dev/acpica/source/components/parser/psloop.c
+++ b/sys/contrib/dev/acpica/source/components/parser/psloop.c
@@ -104,6 +104,9 @@ AcpiPsGetArguments (
     ACPI_FUNCTION_TRACE_PTR (PsGetArguments, WalkState);
 
 
+    ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
+        "Get arguments for opcode [%s]\n", Op->Common.AmlOpName));
+
     switch (Op->Common.AmlOpcode)
     {
     case AML_BYTE_OP:       /* AML_BYTEDATA_ARG */
diff --git a/sys/contrib/dev/acpica/source/components/parser/psobject.c b/sys/contrib/dev/acpica/source/components/parser/psobject.c
index 7edc39e2b7..d027f6d989 100644
--- a/sys/contrib/dev/acpica/source/components/parser/psobject.c
+++ b/sys/contrib/dev/acpica/source/components/parser/psobject.c
@@ -373,7 +373,13 @@ AcpiPsCreateOp (
                 Op->Common.Flags |= ACPI_PARSEOP_TARGET;
             }
         }
-        else if (ParentScope->Common.AmlOpcode == AML_INCREMENT_OP)
+
+        /*
+         * Special case for both Increment() and Decrement(), where
+         * the lone argument is both a source and a target.
+         */
+        else if ((ParentScope->Common.AmlOpcode == AML_INCREMENT_OP) ||
+                (ParentScope->Common.AmlOpcode == AML_DECREMENT_OP))
         {
             Op->Common.Flags |= ACPI_PARSEOP_TARGET;
         }
diff --git a/sys/contrib/dev/acpica/source/components/parser/pstree.c b/sys/contrib/dev/acpica/source/components/parser/pstree.c
index 729856982b..a38eb435a2 100644
--- a/sys/contrib/dev/acpica/source/components/parser/pstree.c
+++ b/sys/contrib/dev/acpica/source/components/parser/pstree.c
@@ -142,12 +142,12 @@ AcpiPsAppendArg (
     const ACPI_OPCODE_INFO  *OpInfo;
 
 
-    ACPI_FUNCTION_ENTRY ();
+    ACPI_FUNCTION_TRACE (PsAppendArg);
 
 
     if (!Op)
     {
-        return;
+        return_VOID;
     }
 
     /* Get the info structure for this opcode */
@@ -159,7 +159,7 @@ AcpiPsAppendArg (
 
         ACPI_ERROR ((AE_INFO, "Invalid AML Opcode: 0x%2.2X",
             Op->Common.AmlOpcode));
-        return;
+        return_VOID;
     }
 
     /* Check if this opcode requires argument sub-objects */
@@ -168,7 +168,7 @@ AcpiPsAppendArg (
     {
         /* Has no linked argument objects */
 
-        return;
+        return_VOID;
     }
 
     /* Append the argument to the linked argument list */
@@ -200,6 +200,8 @@ AcpiPsAppendArg (
 
         Op->Common.ArgListLength++;
     }
+
+    return_VOID;
 }
 
 
diff --git a/sys/contrib/dev/acpica/source/components/utilities/utclib.c b/sys/contrib/dev/acpica/source/components/utilities/utclib.c
index 8c188d00a4..9b4c9c6f73 100644
--- a/sys/contrib/dev/acpica/source/components/utilities/utclib.c
+++ b/sys/contrib/dev/acpica/source/components/utilities/utclib.c
@@ -129,6 +129,61 @@ memcmp (
 
 /*******************************************************************************
  *
+ * FUNCTION:    memmove
+ *
+ * PARAMETERS:  Dest        - Target of the copy
+ *              Src         - Source buffer to copy
+ *              Count       - Number of bytes to copy
+ *
+ * RETURN:      Dest
+ *
+ * DESCRIPTION: Copy arbitrary bytes of memory with respect to the overlapping
+ *
+ ******************************************************************************/
+
+void *
+memmove (
+    void                    *Dest,
+    const void              *Src,
+    ACPI_SIZE               Count)
+{
+    char                    *New = (char *) Dest;
+    char                    *Old = (char *) Src;
+
+
+    if (Old > New)
+    {
+        /* Copy from the beginning */
+
+        while (Count)
+        {
+            *New = *Old;
+            New++;
+            Old++;
+            Count--;
+        }
+    }
+    else if (Old < New)
+    {
+        /* Copy from the end */
+
+        New = New + Count - 1;
+        Old = Old + Count - 1;
+        while (Count)
+        {
+            *New = *Old;
+            New--;
+            Old--;
+            Count--;
+        }
+    }
+
+    return (Dest);
+}
+
+
+/*******************************************************************************
+ *
  * FUNCTION:    memcpy
  *
  * PARAMETERS:  Dest        - Target of the copy
@@ -231,6 +286,93 @@ strlen (
 
 /*******************************************************************************
  *
+ * FUNCTION:    strpbrk
+ *
+ * PARAMETERS:  String              - Null terminated string
+ *              Delimiters          - Delimiters to match
+ *
+ * RETURN:      The first occurance in the string of any of the bytes in the
+ *              delimiters
+ *
+ * DESCRIPTION: Search a string for any of a set of the delimiters
+ *
+ ******************************************************************************/
+
+char *
+strpbrk (
+    const char              *String,
+    const char              *Delimiters)
+{
+    const char              *Delimiter;
+
+
+    for ( ; *String != '\0'; ++String)
+    {
+        for (Delimiter = Delimiters; *Delimiter != '\0'; Delimiter++)
+        {
+            if (*String == *Delimiter)
+            {
+                return (ACPI_CAST_PTR (char, String));
+            }
+        }
+    }
+
+    return (NULL);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    strtok
+ *
+ * PARAMETERS:  String              - Null terminated string
+ *              Delimiters          - Delimiters to match
+ *
+ * RETURN:      Pointer to the next token
+ *
+ * DESCRIPTION: Split string into tokens
+ *
+ ******************************************************************************/
+
+char*
+strtok (
+    char                    *String,
+    const char              *Delimiters)
+{
+    char                    *Begin = String;
+    static char             *SavedPtr;
+
+
+    if (Begin == NULL)
+    {
+        if (SavedPtr == NULL)
+        {
+            return (NULL);
+        }
+        Begin = SavedPtr;
+    }
+
+    SavedPtr = strpbrk (Begin, Delimiters);
+    while (SavedPtr == Begin)
+    {
+        *Begin++ = '\0';
+        SavedPtr = strpbrk (Begin, Delimiters);
+    }
+
+    if (SavedPtr)
+    {
+        *SavedPtr++ = '\0';
+        return (Begin);
+    }
+    else
+    {
+        return (NULL);
+    }
+}
+
+
+/*******************************************************************************
+ *
  * FUNCTION:    strcpy
  *
  * PARAMETERS:  DstString       - Target of the copy
diff --git a/sys/contrib/dev/acpica/source/components/utilities/utdecode.c b/sys/contrib/dev/acpica/source/components/utilities/utdecode.c
index 45adf14c6d..1a79286ccf 100644
--- a/sys/contrib/dev/acpica/source/components/utilities/utdecode.c
+++ b/sys/contrib/dev/acpica/source/components/utilities/utdecode.c
@@ -269,7 +269,7 @@ AcpiUtGetObjectTypeName (
     if (!ObjDesc)
     {
         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n"));
-        return_PTR ("[NULL Object Descriptor]");
+        return_STR ("[NULL Object Descriptor]");
     }
 
     /* These descriptor types share a common area */
@@ -282,7 +282,7 @@ AcpiUtGetObjectTypeName (
             ACPI_GET_DESCRIPTOR_TYPE (ObjDesc),
             AcpiUtGetDescriptorName (ObjDesc), ObjDesc));
 
-        return_PTR ("Invalid object");
+        return_STR ("Invalid object");
     }
 
     return_STR (AcpiUtGetTypeName (ObjDesc->Common.Type));
diff --git a/sys/contrib/dev/acpica/source/components/utilities/utdelete.c b/sys/contrib/dev/acpica/source/components/utilities/utdelete.c
index 95a98f5681..d36eedfe69 100644
--- a/sys/contrib/dev/acpica/source/components/utilities/utdelete.c
+++ b/sys/contrib/dev/acpica/source/components/utilities/utdelete.c
@@ -449,8 +449,9 @@ AcpiUtUpdateRefCount (
         }
 
         ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
-            "Obj %p Type %.2X Refs %.2X [Incremented]\n",
-            Object, Object->Common.Type, NewCount));
+            "Obj %p Type %.2X [%s] Refs %.2X [Incremented]\n",
+            Object, Object->Common.Type,
+            AcpiUtGetObjectTypeName (Object), NewCount));
         break;
 
     case REF_DECREMENT:
diff --git a/sys/contrib/dev/acpica/source/components/utilities/utmutex.c b/sys/contrib/dev/acpica/source/components/utilities/utmutex.c
index 83b1cee0d7..563ef600cc 100644
--- a/sys/contrib/dev/acpica/source/components/utilities/utmutex.c
+++ b/sys/contrib/dev/acpica/source/components/utilities/utmutex.c
@@ -129,19 +129,6 @@ AcpiUtMutexInitialize (
         return_ACPI_STATUS (Status);
     }
 
-#ifdef ACPI_DEBUGGER
-
-    /* Debugger Support */
-
-    Status = AcpiOsCreateMutex (&AcpiGbl_DbCommandReady);
-    if (ACPI_FAILURE (Status))
-    {
-        return_ACPI_STATUS (Status);
-    }
-
-    Status = AcpiOsCreateMutex (&AcpiGbl_DbCommandComplete);
-#endif
-
     return_ACPI_STATUS (Status);
 }
 
@@ -187,12 +174,6 @@ AcpiUtMutexTerminate (
     /* Delete the reader/writer lock */
 
     AcpiUtDeleteRwLock (&AcpiGbl_NamespaceRwLock);
-
-#ifdef ACPI_DEBUGGER
-    AcpiOsDeleteMutex (AcpiGbl_DbCommandReady);
-    AcpiOsDeleteMutex (AcpiGbl_DbCommandComplete);
-#endif
-
     return_VOID;
 }
 
diff --git a/sys/contrib/dev/acpica/source/components/utilities/utresrc.c b/sys/contrib/dev/acpica/source/components/utilities/utresrc.c
index 2de32b501c..747da34f04 100644
--- a/sys/contrib/dev/acpica/source/components/utilities/utresrc.c
+++ b/sys/contrib/dev/acpica/source/components/utilities/utresrc.c
@@ -468,8 +468,10 @@ AcpiUtWalkAmlResources (
     ACPI_FUNCTION_TRACE (UtWalkAmlResources);
 
 
-    /* The absolute minimum resource template is one EndTag descriptor */
-
+    /*
+     * The absolute minimum resource template is one EndTag descriptor.
+     * However, we will treat a lone EndTag as just a simple buffer.
+     */
     if (AmlLength < sizeof (AML_RESOURCE_END_TAG))
     {
         return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
@@ -503,8 +505,8 @@ AcpiUtWalkAmlResources (
 
         if (UserFunction)
         {
-            Status = UserFunction (
-                Aml, Length, Offset, ResourceIndex, Context);
+            Status = UserFunction (Aml, Length, Offset,
+                ResourceIndex, Context);
             if (ACPI_FAILURE (Status))
             {
                 return_ACPI_STATUS (Status);
@@ -531,6 +533,13 @@ AcpiUtWalkAmlResources (
                 *Context = Aml;
             }
 
+            /* Check if buffer is defined to be longer than the resource length */
+
+            if (AmlLength > (Offset + Length))
+            {
+                return_ACPI_STATUS (AE_AML_NO_RESOURCE_END_TAG);
+            }
+
             /* Normal exit */
 
             return_ACPI_STATUS (AE_OK);
diff --git a/sys/contrib/dev/acpica/source/include/acclib.h b/sys/contrib/dev/acpica/source/include/acclib.h
index 0b104b6126..ab1c3d7676 100644
--- a/sys/contrib/dev/acpica/source/include/acclib.h
+++ b/sys/contrib/dev/acpica/source/include/acclib.h
@@ -104,6 +104,16 @@ strchr (
     int                     ch);
 
 char *
+strpbrk (
+    const char              *String,
+    const char              *Delimiters);
+
+char *
+strtok (
+    char                    *String,
+    const char              *Delimiters);
+
+char *
 strcpy (
     char                    *DstString,
     const char              *SrcString);
@@ -165,6 +175,12 @@ memcpy (
     ACPI_SIZE               Count);
 
 void *
+memmove (
+    void                    *Dest,
+    const void              *Src,
+    ACPI_SIZE               Count);
+
+void *
 memset (
     void                    *Dest,
     int                     Value,
@@ -226,6 +242,13 @@ sprintf (
  */
 extern int errno;
 
+#ifndef EOF
+#define EOF                 (-1)
+#endif
+
+#define putchar(c)          fputc(stdout, c)
+#define getchar(c)          fgetc(stdin)
+
 int
 vprintf (
     const char              *Format,
@@ -280,6 +303,21 @@ fseek (
 long
 ftell (
     FILE                    *File);
+
+int
+fgetc (
+    FILE                    *File);
+
+int
+fputc (
+    FILE                    *File,
+    char                    c);
+
+char *
+fgets (
+    char                    *s,
+    ACPI_SIZE               Size,
+    FILE                    *File);
 #endif
 
 #endif /* _ACCLIB_H */
diff --git a/sys/contrib/dev/acpica/source/include/acdebug.h b/sys/contrib/dev/acpica/source/include/acdebug.h
index 6dfa8a22ce..56e01269fd 100644
--- a/sys/contrib/dev/acpica/source/include/acdebug.h
+++ b/sys/contrib/dev/acpica/source/include/acdebug.h
@@ -421,8 +421,7 @@ AcpiDbExecuteThread (
 
 ACPI_STATUS
 AcpiDbUserCommands (
-    char                    Prompt,
-    ACPI_PARSE_OBJECT       *Op);
+    void);
 
 char *
 AcpiDbGetNextToken (
diff --git a/sys/contrib/dev/acpica/source/include/acdisasm.h b/sys/contrib/dev/acpica/source/include/acdisasm.h
index 719ff859bc..bbf727962c 100644
--- a/sys/contrib/dev/acpica/source/include/acdisasm.h
+++ b/sys/contrib/dev/acpica/source/include/acdisasm.h
@@ -429,7 +429,7 @@ extern ACPI_DMTABLE_INFO        AcpiDmTableInfoGeneric[][2];
  * dmtable and ahtable
  */
 extern const ACPI_DMTABLE_DATA  AcpiDmTableData[];
-extern const AH_TABLE           AcpiSupportedTables[];
+extern const AH_TABLE           Gbl_AcpiSupportedTables[];
 
 UINT8
 AcpiDmGenerateChecksum (
@@ -651,6 +651,10 @@ AcpiDmDisassembleOneOp (
     ACPI_OP_WALK_INFO       *Info,
     ACPI_PARSE_OBJECT       *Op);
 
+BOOLEAN
+AcpiDmIsTempName (
+    ACPI_PARSE_OBJECT       *Op);
+
 UINT32
 AcpiDmListType (
     ACPI_PARSE_OBJECT       *Op);
diff --git a/sys/contrib/dev/acpica/source/include/acexcep.h b/sys/contrib/dev/acpica/source/include/acexcep.h
index 0f9a6aa569..2fe81dccce 100644
--- a/sys/contrib/dev/acpica/source/include/acexcep.h
+++ b/sys/contrib/dev/acpica/source/include/acexcep.h
@@ -217,11 +217,10 @@ typedef struct acpi_exception_info
 #define AE_CTRL_TRANSFER                EXCEP_CTL (0x0008)
 #define AE_CTRL_BREAK                   EXCEP_CTL (0x0009)
 #define AE_CTRL_CONTINUE                EXCEP_CTL (0x000A)
-#define AE_CTRL_SKIP                    EXCEP_CTL (0x000B)
-#define AE_CTRL_PARSE_CONTINUE          EXCEP_CTL (0x000C)
-#define AE_CTRL_PARSE_PENDING           EXCEP_CTL (0x000D)
+#define AE_CTRL_PARSE_CONTINUE          EXCEP_CTL (0x000B)
+#define AE_CTRL_PARSE_PENDING           EXCEP_CTL (0x000C)
 
-#define AE_CODE_CTRL_MAX                0x000D
+#define AE_CODE_CTRL_MAX                0x000C
 
 
 /* Exception strings for AcpiFormatException */
@@ -344,7 +343,6 @@ static const ACPI_EXCEPTION_INFO    AcpiGbl_ExceptionNames_Ctrl[] =
     EXCEP_TXT ("AE_CTRL_TRANSFER",              "Transfer control to called method"),
     EXCEP_TXT ("AE_CTRL_BREAK",                 "A Break has been executed"),
     EXCEP_TXT ("AE_CTRL_CONTINUE",              "A Continue has been executed"),
-    EXCEP_TXT ("AE_CTRL_SKIP",                  "Not currently used"),
     EXCEP_TXT ("AE_CTRL_PARSE_CONTINUE",        "Used to skip over bad opcodes"),
     EXCEP_TXT ("AE_CTRL_PARSE_PENDING",         "Used to implement AML While loops")
 };
diff --git a/sys/contrib/dev/acpica/source/include/acglobal.h b/sys/contrib/dev/acpica/source/include/acglobal.h
index 1d5c17e637..60a2ffddfb 100644
--- a/sys/contrib/dev/acpica/source/include/acglobal.h
+++ b/sys/contrib/dev/acpica/source/include/acglobal.h
@@ -331,7 +331,6 @@ ACPI_GLOBAL (ACPI_EXTERNAL_FILE *,      AcpiGbl_ExternalFileList);
 #ifdef ACPI_DEBUGGER
 
 ACPI_INIT_GLOBAL (BOOLEAN,              AcpiGbl_AbortMethod, FALSE);
-ACPI_INIT_GLOBAL (BOOLEAN,              AcpiGbl_MethodExecuting, FALSE);
 ACPI_INIT_GLOBAL (ACPI_THREAD_ID,       AcpiGbl_DbThreadId, ACPI_INVALID_THREAD_ID);
 
 ACPI_GLOBAL (BOOLEAN,                   AcpiGbl_DbOpt_NoIniMethods);
@@ -350,7 +349,6 @@ ACPI_GLOBAL (ACPI_OBJECT_TYPE,          AcpiGbl_DbArgTypes[ACPI_DEBUGGER_MAX_ARG
 
 /* These buffers should all be the same size */
 
-ACPI_GLOBAL (char,                      AcpiGbl_DbLineBuf[ACPI_DB_LINE_BUFFER_SIZE]);
 ACPI_GLOBAL (char,                      AcpiGbl_DbParsedBuf[ACPI_DB_LINE_BUFFER_SIZE]);
 ACPI_GLOBAL (char,                      AcpiGbl_DbScopeBuf[ACPI_DB_LINE_BUFFER_SIZE]);
 ACPI_GLOBAL (char,                      AcpiGbl_DbDebugFilename[ACPI_DB_LINE_BUFFER_SIZE]);
@@ -365,9 +363,6 @@ ACPI_GLOBAL (UINT16,                    AcpiGbl_NodeTypeCountMisc);
 ACPI_GLOBAL (UINT32,                    AcpiGbl_NumNodes);
 ACPI_GLOBAL (UINT32,                    AcpiGbl_NumObjects);
 
-ACPI_GLOBAL (ACPI_MUTEX,                AcpiGbl_DbCommandReady);
-ACPI_GLOBAL (ACPI_MUTEX,                AcpiGbl_DbCommandComplete);
-
 #endif /* ACPI_DEBUGGER */
 
 #if defined (ACPI_DISASSEMBLER) || defined (ACPI_ASL_COMPILER)
diff --git a/sys/contrib/dev/acpica/source/include/aclocal.h b/sys/contrib/dev/acpica/source/include/aclocal.h
index f41160953b..734cae17a3 100644
--- a/sys/contrib/dev/acpica/source/include/aclocal.h
+++ b/sys/contrib/dev/acpica/source/include/aclocal.h
@@ -923,7 +923,7 @@ typedef union acpi_parse_value
     char                            AmlOpName[16])  /* Op name (debug only) */
 
 
-/* Flags for DisasmFlags field  above */
+/* Internal opcodes for DisasmOpcode field above */
 
 #define ACPI_DASM_BUFFER                0x00        /* Buffer is a simple data buffer */
 #define ACPI_DASM_RESOURCE              0x01        /* Buffer is a Resource Descriptor */
@@ -936,7 +936,10 @@ typedef union acpi_parse_value
 #define ACPI_DASM_LNOT_PREFIX           0x08        /* Start of a LNotEqual (etc.) pair of opcodes */
 #define ACPI_DASM_LNOT_SUFFIX           0x09        /* End  of a LNotEqual (etc.) pair of opcodes */
 #define ACPI_DASM_HID_STRING            0x0A        /* String is a _HID or _CID */
-#define ACPI_DASM_IGNORE                0x0B        /* Not used at this time */
+#define ACPI_DASM_IGNORE_SINGLE         0x0B        /* Ignore the opcode but not it's children */
+#define ACPI_DASM_SWITCH_PREDICATE      0x0C        /* Object is a predicate for a Switch or Case block */
+#define ACPI_DASM_CASE                  0x0D        /* If/Else is a Case in a Switch/Case block */
+#define ACPI_DASM_DEFAULT               0x0E        /* Else is a Default in a Switch/Case block */
 
 /*
  * Generic operation (for example:  If, While, Store)
diff --git a/sys/contrib/dev/acpica/source/include/acmacros.h b/sys/contrib/dev/acpica/source/include/acmacros.h
index 21256cbba7..5a5e79318a 100644
--- a/sys/contrib/dev/acpica/source/include/acmacros.h
+++ b/sys/contrib/dev/acpica/source/include/acmacros.h
@@ -47,7 +47,7 @@
 
 /*
  * Extract data using a pointer. Any more than a byte and we
- * get into potential aligment issues -- see the STORE macros below.
+ * get into potential alignment issues -- see the STORE macros below.
  * Use with care.
  */
 #define ACPI_CAST8(ptr)                 ACPI_CAST_PTR (UINT8, (ptr))
@@ -64,7 +64,7 @@
 #define ACPI_SET64(ptr, val)            (*ACPI_CAST64 (ptr) = (UINT64) (val))
 
 /*
- * printf() format helper. This macros is a workaround for the difficulties
+ * printf() format helper. This macro is a workaround for the difficulties
  * with emitting 64-bit integers and 64-bit pointers with the same code
  * for both 32-bit and 64-bit hosts.
  */
@@ -264,14 +264,93 @@
 
 #define ACPI_IS_MISALIGNED(value)           (((ACPI_SIZE) value) & (sizeof(ACPI_SIZE)-1))
 
+/* Generic bit manipulation */
+
+#ifndef ACPI_USE_NATIVE_BIT_FINDER
+
+#define __ACPI_FIND_LAST_BIT_2(a, r)        ((((UINT8)  (a)) & 0x02) ? (r)+1 : (r))
+#define __ACPI_FIND_LAST_BIT_4(a, r)        ((((UINT8)  (a)) & 0x0C) ? \
+                                             __ACPI_FIND_LAST_BIT_2  ((a)>>2,  (r)+2) : \
+                                             __ACPI_FIND_LAST_BIT_2  ((a), (r)))
+#define __ACPI_FIND_LAST_BIT_8(a, r)        ((((UINT8)  (a)) & 0xF0) ? \
+                                             __ACPI_FIND_LAST_BIT_4  ((a)>>4,  (r)+4) : \
+                                             __ACPI_FIND_LAST_BIT_4  ((a), (r)))
+#define __ACPI_FIND_LAST_BIT_16(a, r)       ((((UINT16) (a)) & 0xFF00) ? \
+                                             __ACPI_FIND_LAST_BIT_8  ((a)>>8,  (r)+8) : \
+                                             __ACPI_FIND_LAST_BIT_8  ((a), (r)))
+#define __ACPI_FIND_LAST_BIT_32(a, r)       ((((UINT32) (a)) & 0xFFFF0000) ? \
+                                             __ACPI_FIND_LAST_BIT_16 ((a)>>16, (r)+16) : \
+                                             __ACPI_FIND_LAST_BIT_16 ((a), (r)))
+#define __ACPI_FIND_LAST_BIT_64(a, r)       ((((UINT64) (a)) & 0xFFFFFFFF00000000) ? \
+                                             __ACPI_FIND_LAST_BIT_32 ((a)>>32, (r)+32) : \
+                                             __ACPI_FIND_LAST_BIT_32 ((a), (r)))
+
+#define ACPI_FIND_LAST_BIT_8(a)             ((a) ? __ACPI_FIND_LAST_BIT_8 (a, 1) : 0)
+#define ACPI_FIND_LAST_BIT_16(a)            ((a) ? __ACPI_FIND_LAST_BIT_16 (a, 1) : 0)
+#define ACPI_FIND_LAST_BIT_32(a)            ((a) ? __ACPI_FIND_LAST_BIT_32 (a, 1) : 0)
+#define ACPI_FIND_LAST_BIT_64(a)            ((a) ? __ACPI_FIND_LAST_BIT_64 (a, 1) : 0)
+
+#define __ACPI_FIND_FIRST_BIT_2(a, r)       ((((UINT8) (a)) & 0x01) ? (r) : (r)+1)
+#define __ACPI_FIND_FIRST_BIT_4(a, r)       ((((UINT8) (a)) & 0x03) ? \
+                                             __ACPI_FIND_FIRST_BIT_2  ((a), (r)) : \
+                                             __ACPI_FIND_FIRST_BIT_2  ((a)>>2, (r)+2))
+#define __ACPI_FIND_FIRST_BIT_8(a, r)       ((((UINT8) (a)) & 0x0F) ? \
+                                             __ACPI_FIND_FIRST_BIT_4  ((a), (r)) : \
+                                             __ACPI_FIND_FIRST_BIT_4  ((a)>>4, (r)+4))
+#define __ACPI_FIND_FIRST_BIT_16(a, r)      ((((UINT16) (a)) & 0x00FF) ? \
+                                             __ACPI_FIND_FIRST_BIT_8  ((a), (r)) : \
+                                             __ACPI_FIND_FIRST_BIT_8  ((a)>>8, (r)+8))
+#define __ACPI_FIND_FIRST_BIT_32(a, r)      ((((UINT32) (a)) & 0x0000FFFF) ? \
+                                             __ACPI_FIND_FIRST_BIT_16 ((a), (r)) : \
+                                             __ACPI_FIND_FIRST_BIT_16 ((a)>>16, (r)+16))
+#define __ACPI_FIND_FIRST_BIT_64(a, r)      ((((UINT64) (a)) & 0x00000000FFFFFFFF) ? \
+                                             __ACPI_FIND_FIRST_BIT_32 ((a), (r)) : \
+                                             __ACPI_FIND_FIRST_BIT_32 ((a)>>32, (r)+32))
+
+#define ACPI_FIND_FIRST_BIT_8(a)            ((a) ? __ACPI_FIND_FIRST_BIT_8 (a, 1) : 0)
+#define ACPI_FIND_FIRST_BIT_16(a)           ((a) ? __ACPI_FIND_FIRST_BIT_16 (a, 1) : 0)
+#define ACPI_FIND_FIRST_BIT_32(a)           ((a) ? __ACPI_FIND_FIRST_BIT_32 (a, 1) : 0)
+#define ACPI_FIND_FIRST_BIT_64(a)           ((a) ? __ACPI_FIND_FIRST_BIT_64 (a, 1) : 0)
+
+#endif /* ACPI_USE_NATIVE_BIT_FINDER */
+
+/* Generic (power-of-two) rounding */
+
+#define ACPI_ROUND_UP_POWER_OF_TWO_8(a)     ((UINT8) \
+                                            (((UINT16) 1) <<  ACPI_FIND_LAST_BIT_8  ((a)  - 1)))
+#define ACPI_ROUND_DOWN_POWER_OF_TWO_8(a)   ((UINT8) \
+                                            (((UINT16) 1) << (ACPI_FIND_LAST_BIT_8  ((a)) - 1)))
+#define ACPI_ROUND_UP_POWER_OF_TWO_16(a)    ((UINT16) \
+                                            (((UINT32) 1) <<  ACPI_FIND_LAST_BIT_16 ((a)  - 1)))
+#define ACPI_ROUND_DOWN_POWER_OF_TWO_16(a)  ((UINT16) \
+                                            (((UINT32) 1) << (ACPI_FIND_LAST_BIT_16 ((a)) - 1)))
+#define ACPI_ROUND_UP_POWER_OF_TWO_32(a)    ((UINT32) \
+                                            (((UINT64) 1) <<  ACPI_FIND_LAST_BIT_32 ((a)  - 1)))
+#define ACPI_ROUND_DOWN_POWER_OF_TWO_32(a)  ((UINT32) \
+                                            (((UINT64) 1) << (ACPI_FIND_LAST_BIT_32 ((a)) - 1)))
+#define ACPI_IS_ALIGNED(a, s)               (((a) & ((s) - 1)) == 0)
+#define ACPI_IS_POWER_OF_TWO(a)             ACPI_IS_ALIGNED(a, a)
+
 /*
  * Bitmask creation
  * Bit positions start at zero.
  * MASK_BITS_ABOVE creates a mask starting AT the position and above
  * MASK_BITS_BELOW creates a mask starting one bit BELOW the position
+ * MASK_BITS_ABOVE/BELOW accepts a bit offset to create a mask
+ * MASK_BITS_ABOVE/BELOW_32/64 accepts a bit width to create a mask
+ * Note: The ACPI_INTEGER_BIT_SIZE check is used to bypass compiler
+ * differences with the shift operator
  */
 #define ACPI_MASK_BITS_ABOVE(position)      (~((ACPI_UINT64_MAX) << ((UINT32) (position))))
 #define ACPI_MASK_BITS_BELOW(position)      ((ACPI_UINT64_MAX) << ((UINT32) (position)))
+#define ACPI_MASK_BITS_ABOVE_32(width)      ((UINT32) ACPI_MASK_BITS_ABOVE(width))
+#define ACPI_MASK_BITS_BELOW_32(width)      ((UINT32) ACPI_MASK_BITS_BELOW(width))
+#define ACPI_MASK_BITS_ABOVE_64(width)      ((width) == ACPI_INTEGER_BIT_SIZE ? \
+                                                ACPI_UINT64_MAX : \
+                                                ACPI_MASK_BITS_ABOVE(width))
+#define ACPI_MASK_BITS_BELOW_64(width)      ((width) == ACPI_INTEGER_BIT_SIZE ? \
+                                                (UINT64) 0 : \
+                                                ACPI_MASK_BITS_BELOW(width))
 
 /* Bitfields within ACPI registers */
 
@@ -376,7 +455,7 @@
  */
 #ifndef ACPI_NO_ERROR_MESSAGES
 /*
- * Error reporting. Callers module and line number are inserted by AE_INFO,
+ * Error reporting. The callers module and line number are inserted by AE_INFO,
  * the plist contains a set of parens to allow variable-length lists.
  * These macros are used for both the debug and non-debug versions of the code.
  */
diff --git a/sys/contrib/dev/acpica/source/include/acopcode.h b/sys/contrib/dev/acpica/source/include/acopcode.h
index 5b499d7c46..e5c35255ca 100644
--- a/sys/contrib/dev/acpica/source/include/acopcode.h
+++ b/sys/contrib/dev/acpica/source/include/acopcode.h
@@ -93,7 +93,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_NAME_OR_REF,ARGP_TARGET)
+#define ARGP_COND_REF_OF_OP             ARGP_LIST2 (ARGP_SIMPLENAME, 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)
@@ -106,7 +106,7 @@
 #define ARGP_DATA_REGION_OP             ARGP_LIST4 (ARGP_NAME,       ARGP_TERMARG,       ARGP_TERMARG,   ARGP_TERMARG)
 #define ARGP_DEBUG_OP                   ARG_NONE
 #define ARGP_DECREMENT_OP               ARGP_LIST1 (ARGP_SUPERNAME)
-#define ARGP_DEREF_OF_OP                ARGP_LIST1 (ARGP_TERMARG)
+#define ARGP_DEREF_OF_OP                ARGP_LIST1 (ARGP_SUPERNAME)
 #define ARGP_DEVICE_OP                  ARGP_LIST3 (ARGP_PKGLENGTH,  ARGP_NAME,          ARGP_OBJLIST)
 #define ARGP_DIVIDE_OP                  ARGP_LIST4 (ARGP_TERMARG,    ARGP_TERMARG,       ARGP_TARGET,    ARGP_TARGET)
 #define ARGP_DWORD_OP                   ARGP_LIST1 (ARGP_DWORDDATA)
@@ -153,14 +153,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_OBJECT_TYPE_OP             ARGP_LIST1 (ARGP_SIMPLENAME)
 #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_NAME_OR_REF)
+#define ARGP_REF_OF_OP                  ARGP_LIST1 (ARGP_SIMPLENAME)
 #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)
diff --git a/sys/contrib/dev/acpica/source/include/acpiosxf.h b/sys/contrib/dev/acpica/source/include/acpiosxf.h
index 788e06644d..9c5775f023 100644
--- a/sys/contrib/dev/acpica/source/include/acpiosxf.h
+++ b/sys/contrib/dev/acpica/source/include/acpiosxf.h
@@ -456,6 +456,14 @@ AcpiOsSignal (
     void                    *Info);
 #endif
 
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsEnterSleep
+ACPI_STATUS
+AcpiOsEnterSleep (
+    UINT8                   SleepState,
+    UINT32                  RegaValue,
+    UINT32                  RegbValue);
+#endif
+
 
 /*
  * Debug print routines
@@ -482,7 +490,7 @@ AcpiOsRedirectOutput (
 
 
 /*
- * Debug input
+ * Debug IO
  */
 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsGetLine
 ACPI_STATUS
@@ -492,6 +500,30 @@ AcpiOsGetLine (
     UINT32                  *BytesRead);
 #endif
 
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsInitializeDebugger
+ACPI_STATUS
+AcpiOsInitializeDebugger (
+    void);
+#endif
+
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTerminateDebugger
+void
+AcpiOsTerminateDebugger (
+    void);
+#endif
+
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWaitCommandReady
+ACPI_STATUS
+AcpiOsWaitCommandReady (
+    void);
+#endif
+
+#ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsNotifyCommandComplete
+ACPI_STATUS
+AcpiOsNotifyCommandComplete (
+    void);
+#endif
+
 #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTracePoint
 void
 AcpiOsTracePoint (
diff --git a/sys/contrib/dev/acpica/source/include/acpixf.h b/sys/contrib/dev/acpica/source/include/acpixf.h
index f5f86d4fb2..ce47020541 100644
--- a/sys/contrib/dev/acpica/source/include/acpixf.h
+++ b/sys/contrib/dev/acpica/source/include/acpixf.h
@@ -46,7 +46,7 @@
 
 /* Current ACPICA subsystem version in YYYYMMDD format */
 
-#define ACPI_CA_VERSION                 0x20161117
+#define ACPI_CA_VERSION                 0x20161222
 
 #include "acconfig.h"
 #include "actypes.h"
@@ -293,6 +293,15 @@ ACPI_INIT_GLOBAL (UINT32,           AcpiDbgLayer, ACPI_COMPONENT_DEFAULT);
 ACPI_INIT_GLOBAL (UINT8,            AcpiGbl_DisplayDebugTimer, FALSE);
 
 /*
+ * Debugger command handshake globals. Host OSes need to access these
+ * variables to implement their own command handshake mechanism.
+ */
+#ifdef ACPI_DEBUGGER
+ACPI_INIT_GLOBAL (BOOLEAN,          AcpiGbl_MethodExecuting, FALSE);
+ACPI_GLOBAL (char,                  AcpiGbl_DbLineBuf[ACPI_DB_LINE_BUFFER_SIZE]);
+#endif
+
+/*
  * Other miscellaneous globals
  */
 ACPI_GLOBAL (ACPI_TABLE_FADT,       AcpiGbl_FADT);
@@ -1267,6 +1276,10 @@ AcpiTerminateDebugger (
     void);
 
 void
+AcpiRunDebugger (
+    char                    *BatchBuffer);
+
+void
 AcpiSetDebuggerThreadId (
     ACPI_THREAD_ID          ThreadId);
 
diff --git a/sys/contrib/dev/acpica/source/include/platform/acefi.h b/sys/contrib/dev/acpica/source/include/platform/acefi.h
index af3df6cd81..69f1e55c9a 100644
--- a/sys/contrib/dev/acpica/source/include/platform/acefi.h
+++ b/sys/contrib/dev/acpica/source/include/platform/acefi.h
@@ -251,8 +251,10 @@ struct _ACPI_EFI_PCI_IO;
 extern struct _ACPI_EFI_SYSTEM_TABLE        *ST;
 extern struct _ACPI_EFI_BOOT_SERVICES       *BS;
 
-#define FILE                struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE
+typedef union acpi_efi_file ACPI_EFI_FILE;
+#define FILE                ACPI_EFI_FILE
 
+extern FILE                 *stdin;
 extern FILE                 *stdout;
 extern FILE                 *stderr;
 
diff --git a/sys/contrib/dev/acpica/source/include/platform/acefiex.h b/sys/contrib/dev/acpica/source/include/platform/acefiex.h
index 4ae0c66280..c16c1afbbb 100644
--- a/sys/contrib/dev/acpica/source/include/platform/acefiex.h
+++ b/sys/contrib/dev/acpica/source/include/platform/acefiex.h
@@ -95,6 +95,20 @@ typedef struct {
     UINT8   Data4[8];
 } ACPI_EFI_GUID;
 
+typedef struct {
+    UINT16 Year;       /* 1998 - 20XX */
+    UINT8  Month;      /* 1 - 12 */
+    UINT8  Day;        /* 1 - 31 */
+    UINT8  Hour;       /* 0 - 23 */
+    UINT8  Minute;     /* 0 - 59 */
+    UINT8  Second;     /* 0 - 59 */
+    UINT8  Pad1;
+    UINT32 Nanosecond; /* 0 - 999,999,999 */
+    INT16  TimeZone;   /* -1440 to 1440 or 2047 */
+    UINT8  Daylight;
+    UINT8  Pad2;
+} ACPI_EFI_TIME;
+
 typedef struct _ACPI_EFI_DEVICE_PATH {
         UINT8                           Type;
         UINT8                           SubType;
@@ -375,6 +389,22 @@ ACPI_EFI_STATUS
     struct _ACPI_EFI_FILE_HANDLE                *File,
     UINT64                                      *Position);
 
+#define ACPI_EFI_FILE_INFO_ID \
+    { 0x9576e92, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} }
+
+typedef struct {
+    UINT64 Size;
+    UINT64 FileSize;
+    UINT64 PhysicalSize;
+    ACPI_EFI_TIME CreateTime;
+    ACPI_EFI_TIME LastAccessTime;
+    ACPI_EFI_TIME ModificationTime;
+    UINT64 Attribute;
+    CHAR16 FileName[1];
+} ACPI_EFI_FILE_INFO;
+
+#define SIZE_OF_ACPI_EFI_FILE_INFO  ACPI_OFFSET(ACPI_EFI_FILE_INFO, FileName)
+
 typedef
 ACPI_EFI_STATUS
 (ACPI_EFI_API *ACPI_EFI_FILE_GET_INFO) (
@@ -457,6 +487,15 @@ ACPI_EFI_STATUS
     ACPI_EFI_HANDLE                 ImageHandle);
 
 
+typedef
+ACPI_EFI_STATUS
+(ACPI_EFI_API *ACPI_EFI_SET_WATCHDOG_TIMER) (
+    UINTN                           Timeout,
+    UINT64                          WatchdogCode,
+    UINTN                           DataSize,
+    CHAR16                          *WatchdogData);
+
+
 #define EFI_IMAGE_INFORMATION_REVISION      0x1000
 typedef struct {
     UINT32                          Revision;
@@ -744,13 +783,12 @@ typedef struct _ACPI_EFI_BOOT_SERVICES {
     ACPI_EFI_EXIT_BOOT_SERVICES         ExitBootServices;
     ACPI_EFI_GET_NEXT_MONOTONIC_COUNT   GetNextMonotonicCount;
     ACPI_EFI_STALL                      Stall;
-    ACPI_EFI_SET_WATCHDOG_TIMER         SetWatchdogTimer;
 #else
     ACPI_EFI_UNKNOWN_INTERFACE          ExitBootServices;
     ACPI_EFI_UNKNOWN_INTERFACE          GetNextMonotonicCount;
     ACPI_EFI_UNKNOWN_INTERFACE          Stall;
-    ACPI_EFI_UNKNOWN_INTERFACE          SetWatchdogTimer;
 #endif
+    ACPI_EFI_SET_WATCHDOG_TIMER         SetWatchdogTimer;
 
 #if 0
     ACPI_EFI_CONNECT_CONTROLLER         ConnectController;
@@ -896,6 +934,15 @@ typedef struct _ACPI_EFI_PCI_IO {
     VOID                                *RomImage;
 } ACPI_EFI_PCI_IO;
 
+/* FILE abstraction */
+
+union acpi_efi_file {
+    struct _ACPI_EFI_FILE_HANDLE File;
+    struct _ACPI_SIMPLE_TEXT_OUTPUT_INTERFACE ConOut;
+    struct _ACPI_SIMPLE_INPUT_INTERFACE ConIn;
+};
+
+
 /* GNU EFI definitions */
 
 #if defined(_GNU_EFI)
@@ -929,5 +976,6 @@ extern ACPI_EFI_GUID AcpiGbl_LoadedImageProtocol;
 extern ACPI_EFI_GUID AcpiGbl_TextInProtocol;
 extern ACPI_EFI_GUID AcpiGbl_TextOutProtocol;
 extern ACPI_EFI_GUID AcpiGbl_FileSystemProtocol;
+extern ACPI_EFI_GUID AcpiGbl_GenericFileInfo;
 
 #endif /* __ACEFIEX_H__ */
diff --git a/sys/contrib/dev/acpica/source/include/platform/acenv.h b/sys/contrib/dev/acpica/source/include/platform/acenv.h
index 97187f8b0c..3fcc93b91b 100644
--- a/sys/contrib/dev/acpica/source/include/platform/acenv.h
+++ b/sys/contrib/dev/acpica/source/include/platform/acenv.h
@@ -76,7 +76,8 @@
     (defined ACPI_NAMES_APP)    || \
     (defined ACPI_SRC_APP)      || \
     (defined ACPI_XTRACT_APP)   || \
-    (defined ACPI_EXAMPLE_APP)
+    (defined ACPI_EXAMPLE_APP)  || \
+    (defined ACPI_EFI_HELLO)
 #define ACPI_APPLICATION
 #define ACPI_SINGLE_THREADED
 #define USE_NATIVE_ALLOCATE_ZEROED
@@ -361,7 +362,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
-#ifdef ACPI_APPLICATION
+#if defined (ACPI_APPLICATION) || defined(ACPI_LIBRARY)
 #include <stdio.h>
 #include <fcntl.h>
 #include <errno.h>
diff --git a/sys/contrib/dev/acpica/source/include/platform/aclinux.h b/sys/contrib/dev/acpica/source/include/platform/aclinux.h
index 048f76a598..c19a8e45f8 100644
--- a/sys/contrib/dev/acpica/source/include/platform/aclinux.h
+++ b/sys/contrib/dev/acpica/source/include/platform/aclinux.h
@@ -153,6 +153,8 @@
  */
 #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsReadable
 #define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsWritable
+#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsInitializeDebugger
+#define ACPI_USE_ALTERNATE_PROTOTYPE_AcpiOsTerminateDebugger
 
 /*
  * OSL interfaces used by utilities
@@ -193,7 +195,8 @@
 #define ACPI_CAST_PTHREAD_T(Pthread) ((ACPI_THREAD_ID) (Pthread))
 
 #if defined(__ia64__)    || defined(__x86_64__) ||\
-    defined(__aarch64__) || defined(__PPC64__)
+    defined(__aarch64__) || defined(__PPC64__) ||\
+    defined(__s390x__)
 #define ACPI_MACHINE_WIDTH          64
 #define COMPILER_DEPENDENT_INT64    long
 #define COMPILER_DEPENDENT_UINT64   unsigned long
diff --git a/sys/contrib/dev/acpica/source/include/platform/aclinuxex.h b/sys/contrib/dev/acpica/source/include/platform/aclinuxex.h
index f1f9c9a21a..2e2cc6aa87 100644
--- a/sys/contrib/dev/acpica/source/include/platform/aclinuxex.h
+++ b/sys/contrib/dev/acpica/source/include/platform/aclinuxex.h
@@ -144,6 +144,20 @@ AcpiOsReadable (
     return TRUE;
 }
 
+static inline ACPI_STATUS
+AcpiOsInitializeDebugger (
+    void)
+{
+    return AE_OK;
+}
+
+static inline void
+AcpiOsTerminateDebugger (
+    void)
+{
+    return;
+}
+
 
 /*
  * OSL interfaces added by Linux
diff --git a/sys/contrib/dev/acpica/source/os_specific/service_layers/osgendbg.c b/sys/contrib/dev/acpica/source/os_specific/service_layers/osgendbg.c
new file mode 100644
index 0000000000..1b7079e1c8
--- /dev/null
+++ b/sys/contrib/dev/acpica/source/os_specific/service_layers/osgendbg.c
@@ -0,0 +1,366 @@
+/******************************************************************************
+ *
+ * Module Name: osgendbg - Generic debugger command singalling
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2016, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acdebug.h"
+
+
+#define _COMPONENT          ACPI_CA_DEBUGGER
+        ACPI_MODULE_NAME    ("osgendbg")
+
+
+/* Local prototypes */
+
+static void
+AcpiDbRunRemoteDebugger (
+    char                    *BatchBuffer);
+
+
+static ACPI_MUTEX           AcpiGbl_DbCommandReady;
+static ACPI_MUTEX           AcpiGbl_DbCommandComplete;
+static BOOLEAN              AcpiGbl_DbCommandSignalsInitialized = FALSE;
+
+/******************************************************************************
+ *
+ * FUNCTION:    AcpiDbRunRemoteDebugger
+ *
+ * PARAMETERS:  BatchBuffer         - Buffer containing commands running in
+ *                                    the batch mode
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Run multi-threading debugger remotely
+ *
+ *****************************************************************************/
+
+static void
+AcpiDbRunRemoteDebugger (
+    char                    *BatchBuffer)
+{
+    ACPI_STATUS             Status;
+    char                    *Ptr = BatchBuffer;
+    char                    *Cmd = Ptr;
+
+
+    while (!AcpiGbl_DbTerminateLoop)
+    {
+        if (BatchBuffer)
+        {
+            if (*Ptr)
+            {
+                while (*Ptr)
+                {
+                    if (*Ptr == ',')
+                    {
+                        /* Convert commas to spaces */
+                        *Ptr = ' ';
+                    }
+                    else if (*Ptr == ';')
+                    {
+                        *Ptr = '\0';
+                        continue;
+                    }
+
+                    Ptr++;
+                }
+
+                strncpy (AcpiGbl_DbLineBuf, Cmd, ACPI_DB_LINE_BUFFER_SIZE);
+                Ptr++;
+                Cmd = Ptr;
+            }
+            else
+            {
+                return;
+            }
+        }
+        else
+        {
+            /* Force output to console until a command is entered */
+
+            AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
+
+            /* Different prompt if method is executing */
+
+            if (!AcpiGbl_MethodExecuting)
+            {
+                AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
+            }
+            else
+            {
+                AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
+            }
+
+            /* Get the user input line */
+
+            Status = AcpiOsGetLine (AcpiGbl_DbLineBuf,
+                ACPI_DB_LINE_BUFFER_SIZE, NULL);
+            if (ACPI_FAILURE (Status))
+            {
+                return;
+            }
+        }
+
+        /*
+         * Signal the debug thread that we have a command to execute,
+         * and wait for the command to complete.
+         */
+        AcpiOsReleaseMutex (AcpiGbl_DbCommandReady);
+
+        Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete,
+            ACPI_WAIT_FOREVER);
+        if (ACPI_FAILURE (Status))
+        {
+            return;
+        }
+    }
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    AcpiOsWaitCommandReady
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Negotiate with the debugger foreground thread (the user
+ *              thread) to wait the readiness of a command.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsWaitCommandReady (
+    void)
+{
+    ACPI_STATUS             Status = AE_OK;
+
+
+    if (AcpiGbl_DebuggerConfiguration == DEBUGGER_MULTI_THREADED)
+    {
+        Status = AE_TIME;
+
+        while (Status == AE_TIME)
+        {
+            if (AcpiGbl_DbTerminateLoop)
+            {
+                Status = AE_CTRL_TERMINATE;
+            }
+            else
+            {
+                Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady, 1000);
+            }
+        }
+    }
+    else
+    {
+        /* Force output to console until a command is entered */
+
+        AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
+
+        /* Different prompt if method is executing */
+
+        if (!AcpiGbl_MethodExecuting)
+        {
+            AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
+        }
+        else
+        {
+            AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
+        }
+
+        /* Get the user input line */
+
+        Status = AcpiOsGetLine (AcpiGbl_DbLineBuf,
+            ACPI_DB_LINE_BUFFER_SIZE, NULL);
+    }
+
+    if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE)
+    {
+        ACPI_EXCEPTION ((AE_INFO, Status,
+            "While parsing/handling command line"));
+    }
+    return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    AcpiOsNotifyCommandComplete
+ *
+ * PARAMETERS:  void
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Negotiate with the debugger foreground thread (the user
+ *              thread) to notify the completion of a command.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsNotifyCommandComplete (
+    void)
+{
+
+    if (AcpiGbl_DebuggerConfiguration == DEBUGGER_MULTI_THREADED)
+    {
+        AcpiOsReleaseMutex (AcpiGbl_DbCommandComplete);
+    }
+    return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    AcpiOsInitializeDebugger
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Initialize OSPM specific part of the debugger
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsInitializeDebugger (
+    void)
+{
+    ACPI_STATUS             Status;
+
+
+    /* Create command signals */
+
+    Status = AcpiOsCreateMutex (&AcpiGbl_DbCommandReady);
+    if (ACPI_FAILURE (Status))
+    {
+        return (Status);
+    }
+    Status = AcpiOsCreateMutex (&AcpiGbl_DbCommandComplete);
+    if (ACPI_FAILURE (Status))
+    {
+        goto ErrorReady;
+    }
+
+    /* Initialize the states of the command signals */
+
+    Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete,
+        ACPI_WAIT_FOREVER);
+    if (ACPI_FAILURE (Status))
+    {
+        goto ErrorComplete;
+    }
+    Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady,
+        ACPI_WAIT_FOREVER);
+    if (ACPI_FAILURE (Status))
+    {
+        goto ErrorComplete;
+    }
+
+    AcpiGbl_DbCommandSignalsInitialized = TRUE;
+    return (Status);
+
+ErrorComplete:
+    AcpiOsDeleteMutex (AcpiGbl_DbCommandComplete);
+ErrorReady:
+    AcpiOsDeleteMutex (AcpiGbl_DbCommandReady);
+    return (Status);
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    AcpiOsTerminateDebugger
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Terminate signals used by the multi-threading debugger
+ *
+ *****************************************************************************/
+
+void
+AcpiOsTerminateDebugger (
+    void)
+{
+
+    if (AcpiGbl_DbCommandSignalsInitialized)
+    {
+        AcpiOsDeleteMutex (AcpiGbl_DbCommandReady);
+        AcpiOsDeleteMutex (AcpiGbl_DbCommandComplete);
+    }
+}
+
+
+/******************************************************************************
+ *
+ * FUNCTION:    AcpiRunDebugger
+ *
+ * PARAMETERS:  BatchBuffer         - Buffer containing commands running in
+ *                                    the batch mode
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Run a local/remote debugger
+ *
+ *****************************************************************************/
+
+void
+AcpiRunDebugger (
+    char                    *BatchBuffer)
+{
+    /* Check for single or multithreaded debug */
+
+    if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
+    {
+        AcpiDbRunRemoteDebugger (BatchBuffer);
+    }
+    else
+    {
+        AcpiDbUserCommands ();
+    }
+}
+
+ACPI_EXPORT_SYMBOL (AcpiRunDebugger)
diff --git a/sys/contrib/dev/acpica/source/os_specific/service_layers/osunixxf.c b/sys/contrib/dev/acpica/source/os_specific/service_layers/osunixxf.c
index 3837b8e99d..47e358bc82 100644
--- a/sys/contrib/dev/acpica/source/os_specific/service_layers/osunixxf.c
+++ b/sys/contrib/dev/acpica/source/os_specific/service_layers/osunixxf.c
@@ -361,6 +361,33 @@ AcpiOsPhysicalTableOverride (
 
 /******************************************************************************
  *
+ * FUNCTION:    AcpiOsEnterSleep
+ *
+ * PARAMETERS:  SleepState          - Which sleep state to enter
+ *              RegaValue           - Register A value
+ *              RegbValue           - Register B value
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: A hook before writing sleep registers to enter the sleep
+ *              state. Return AE_CTRL_SKIP to skip further sleep register
+ *              writes.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsEnterSleep (
+    UINT8                   SleepState,
+    UINT32                  RegaValue,
+    UINT32                  RegbValue)
+{
+
+    return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
  * FUNCTION:    AcpiOsRedirectOutput
  *
  * PARAMETERS:  Destination         - An open file handle/pointer
diff --git a/sys/contrib/dev/acpica/source/os_specific/service_layers/oswinxf.c b/sys/contrib/dev/acpica/source/os_specific/service_layers/oswinxf.c
index b4fc999c7b..cc6a79a70f 100644
--- a/sys/contrib/dev/acpica/source/os_specific/service_layers/oswinxf.c
+++ b/sys/contrib/dev/acpica/source/os_specific/service_layers/oswinxf.c
@@ -289,6 +289,33 @@ AcpiOsPhysicalTableOverride (
 
 /******************************************************************************
  *
+ * FUNCTION:    AcpiOsEnterSleep
+ *
+ * PARAMETERS:  SleepState          - Which sleep state to enter
+ *              RegaValue           - Register A value
+ *              RegbValue           - Register B value
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: A hook before writing sleep registers to enter the sleep
+ *              state. Return AE_CTRL_SKIP to skip further sleep register
+ *              writes.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+AcpiOsEnterSleep (
+    UINT8                   SleepState,
+    UINT32                  RegaValue,
+    UINT32                  RegbValue)
+{
+
+    return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
  * FUNCTION:    AcpiOsGetTimer
  *
  * PARAMETERS:  None
diff --git a/sys/contrib/dev/acpica/source/tools/acpiexec/aemain.c b/sys/contrib/dev/acpica/source/tools/acpiexec/aemain.c
index 826d60df13..1f236f2244 100644
--- a/sys/contrib/dev/acpica/source/tools/acpiexec/aemain.c
+++ b/sys/contrib/dev/acpica/source/tools/acpiexec/aemain.c
@@ -66,10 +66,6 @@ AeDoOptions (
     int                     argc,
     char                    **argv);
 
-static void
-AcpiDbRunBatchMode (
-    void);
-
 
 #define AE_BUFFER_SIZE              1024
 #define ASL_MAX_FILES               256
@@ -663,12 +659,12 @@ EnterDebugger:
     default:
     case AE_MODE_COMMAND_LOOP:
 
-        AcpiDbUserCommands (ACPI_DEBUGGER_COMMAND_PROMPT, NULL);
+        AcpiRunDebugger (NULL);
         break;
 
     case AE_MODE_BATCH_MULTIPLE:
 
-        AcpiDbRunBatchMode ();
+        AcpiRunDebugger (BatchBuffer);
         break;
 
     case AE_MODE_BATCH_SINGLE:
@@ -679,12 +675,7 @@ EnterDebugger:
 
     /* Shut down the debugger and ACPICA */
 
-#if 0
-
-    /* Temporarily removed */
     AcpiTerminateDebugger ();
-    (void) AcpiTerminate ();
-#endif
 
 NormalExit:
     ExitCode = 0;
@@ -693,55 +684,3 @@ ErrorExit:
     (void) AcpiOsTerminate ();
     return (ExitCode);
 }
-
-
-/******************************************************************************
- *
- * FUNCTION:    AcpiDbRunBatchMode
- *
- * PARAMETERS:  BatchCommandLine    - A semicolon separated list of commands
- *                                    to be executed.
- *                                    Use only commas to separate elements of
- *                                    particular command.
- * RETURN:      None
- *
- * DESCRIPTION: For each command of list separated by ';' prepare the command
- *              buffer and pass it to AcpiDbCommandDispatch.
- *
- *****************************************************************************/
-
-static void
-AcpiDbRunBatchMode (
-    void)
-{
-    char                    *Ptr = BatchBuffer;
-    char                    *Cmd = Ptr;
-    UINT8                   Run = 0;
-
-
-    AcpiGbl_MethodExecuting = FALSE;
-    AcpiGbl_StepToNextCall = FALSE;
-
-    while (*Ptr)
-    {
-        if (*Ptr == ',')
-        {
-            /* Convert commas to spaces */
-            *Ptr = ' ';
-        }
-        else if (*Ptr == ';')
-        {
-            *Ptr = '\0';
-            Run = 1;
-        }
-
-        Ptr++;
-
-        if (Run || (*Ptr == '\0'))
-        {
-            (void) AcpiDbCommandDispatch (Cmd, NULL, NULL);
-            Run = 0;
-            Cmd = Ptr;
-        }
-    }
-}
diff --git a/sys/contrib/dev/acpica/source/tools/acpihelp/acpihelp.h b/sys/contrib/dev/acpica/source/tools/acpihelp/acpihelp.h
index 2005567476..eb0c38d39b 100644
--- a/sys/contrib/dev/acpica/source/tools/acpihelp/acpihelp.h
+++ b/sys/contrib/dev/acpica/source/tools/acpihelp/acpihelp.h
@@ -56,6 +56,50 @@
 #endif
 
 
+/*
+ * Global variables. Defined in ahmain.c only, externed in all other files
+ */
+#undef ACPI_GLOBAL
+#undef ACPI_INIT_GLOBAL
+
+#ifdef DEFINE_AHELP_GLOBALS
+#define ACPI_GLOBAL(type,name) \
+    extern type name; \
+    type name
+
+#define ACPI_INIT_GLOBAL(type,name,value) \
+    type name=value
+
+#else
+#ifndef ACPI_GLOBAL
+#define ACPI_GLOBAL(type,name) \
+    extern type name
+#endif
+
+#ifndef ACPI_INIT_GLOBAL
+#define ACPI_INIT_GLOBAL(type,name,value) \
+    extern type name
+#endif
+#endif
+
+
+#define AH_BUFFER_LENGTH                128
+#define AH_LINE_BUFFER_LENGTH           512
+#define AH_MAX_ASL_LINE_LENGTH          70
+#define AH_MAX_AML_LINE_LENGTH          100
+
+ACPI_GLOBAL (char,                      Gbl_Buffer[AH_BUFFER_LENGTH]);
+ACPI_GLOBAL (char,                      Gbl_LineBuffer[AH_LINE_BUFFER_LENGTH]);
+
+
+#define AH_DISPLAY_EXCEPTION(Status, Name) \
+    printf ("%.4X: %s\n", Status, Name)
+
+#define AH_DISPLAY_EXCEPTION_TEXT(Status, Exception) \
+    printf ("%.4X: %-28s (%s)\n", Status,\
+    Exception->Name, Exception->Description)
+
+
 typedef enum
 {
     AH_DECODE_DEFAULT           = 0,
@@ -75,10 +119,6 @@ typedef enum
 
 } AH_OPTION_TYPES;
 
-#define     AH_MAX_ASL_LINE_LENGTH      70
-#define     AH_MAX_AML_LINE_LENGTH      100
-
-
 typedef struct ah_aml_opcode
 {
     UINT16          OpcodeRangeStart;
@@ -122,14 +162,17 @@ typedef struct ah_directive_info
 
 } AH_DIRECTIVE_INFO;
 
-extern const AH_AML_OPCODE          AmlOpcodeInfo[];
-extern const AH_AML_TYPE            AmlTypesInfo[];
-extern const AH_ASL_OPERATOR        AslOperatorInfo[];
-extern const AH_ASL_KEYWORD         AslKeywordInfo[];
-extern const AH_UUID                AcpiUuids[];
-extern const AH_DIRECTIVE_INFO      PreprocessorDirectives[];
-extern const AH_TABLE               AcpiSupportedTables[];
-extern BOOLEAN                      AhDisplayAll;
+
+/* Externals for various data tables */
+
+extern const AH_AML_OPCODE          Gbl_AmlOpcodeInfo[];
+extern const AH_AML_TYPE            Gbl_AmlTypesInfo[];
+extern const AH_ASL_OPERATOR        Gbl_AslOperatorInfo[];
+extern const AH_ASL_KEYWORD         Gbl_AslKeywordInfo[];
+extern const AH_UUID                Gbl_AcpiUuids[];
+extern const AH_DIRECTIVE_INFO      Gbl_PreprocessorDirectives[];
+extern const AH_TABLE               Gbl_AcpiSupportedTables[];
+
 
 void
 AhFindAmlOpcode (
@@ -183,4 +226,11 @@ void
 AhDisplayDirectives (
     void);
 
+void
+AhPrintOneField (
+    UINT32                  Indent,
+    UINT32                  CurrentPosition,
+    UINT32                  MaxPosition,
+    const char              *Field);
+
 #endif /* __ACPIHELP_H */
diff --git a/sys/contrib/dev/acpica/source/tools/acpihelp/ahaml.c b/sys/contrib/dev/acpica/source/tools/acpihelp/ahaml.c
new file mode 100644
index 0000000000..dcd4258151
--- /dev/null
+++ b/sys/contrib/dev/acpica/source/tools/acpihelp/ahaml.c
@@ -0,0 +1,349 @@
+/******************************************************************************
+ *
+ * Module Name: ahaml - AML opcode decoding for acpihelp utility
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2016, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include "acpihelp.h"
+
+
+/* Local prototypes */
+
+static void
+AhDisplayAmlOpcode (
+    const AH_AML_OPCODE     *Op);
+
+static void
+AhDisplayAmlType (
+    const AH_AML_TYPE       *Op);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AhFindAmlOpcode (entry point for AML opcode name search)
+ *
+ * PARAMETERS:  Name                - Name or prefix for an AML opcode.
+ *                                    NULL means "find all"
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Find all AML opcodes that match the input Name or name
+ *              prefix.
+ *
+ ******************************************************************************/
+
+void
+AhFindAmlOpcode (
+    char                    *Name)
+{
+    const AH_AML_OPCODE     *Op;
+    BOOLEAN                 Found = FALSE;
+
+
+    AcpiUtStrupr (Name);
+
+    /* Find/display all opcode names that match the input name prefix */
+
+    for (Op = Gbl_AmlOpcodeInfo; Op->OpcodeString; Op++)
+    {
+        if (!Op->OpcodeName) /* Unused opcodes */
+        {
+            continue;
+        }
+
+        if (!Name || (Name[0] == '*'))
+        {
+            AhDisplayAmlOpcode (Op);
+            Found = TRUE;
+            continue;
+        }
+
+        /* Upper case the opcode name before substring compare */
+
+        strcpy (Gbl_Buffer, Op->OpcodeName);
+        AcpiUtStrupr (Gbl_Buffer);
+
+        if (strstr (Gbl_Buffer, Name) == Gbl_Buffer)
+        {
+            AhDisplayAmlOpcode (Op);
+            Found = TRUE;
+        }
+    }
+
+    if (!Found)
+    {
+        printf ("%s, no matching AML operators\n", Name);
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AhDecodeAmlOpcode (entry point for AML opcode search)
+ *
+ * PARAMETERS:  OpcodeString        - String version of AML opcode
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Display information about the input AML opcode
+ *
+ ******************************************************************************/
+
+void
+AhDecodeAmlOpcode (
+    char                    *OpcodeString)
+{
+    const AH_AML_OPCODE     *Op;
+    UINT32                  Opcode;
+    UINT8                   Prefix;
+
+
+    if (!OpcodeString)
+    {
+        AhFindAmlOpcode (NULL);
+        return;
+    }
+
+    Opcode = strtoul (OpcodeString, NULL, 16);
+    if (Opcode > ACPI_UINT16_MAX)
+    {
+        printf ("Invalid opcode (more than 16 bits)\n");
+        return;
+    }
+
+    /* Only valid opcode extension is 0x5B */
+
+    Prefix = (Opcode & 0x0000FF00) >> 8;
+    if (Prefix && (Prefix != 0x5B))
+    {
+        printf ("Invalid opcode (invalid extension prefix 0x%X)\n",
+            Prefix);
+        return;
+    }
+
+    /* Find/Display the opcode. May fall within an opcode range */
+
+    for (Op = Gbl_AmlOpcodeInfo; Op->OpcodeString; Op++)
+    {
+        if ((Opcode >= Op->OpcodeRangeStart) &&
+            (Opcode <= Op->OpcodeRangeEnd))
+        {
+            AhDisplayAmlOpcode (Op);
+        }
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AhDisplayAmlOpcode
+ *
+ * PARAMETERS:  Op                  - An opcode info struct
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Display the contents of an AML opcode information struct
+ *
+ ******************************************************************************/
+
+static void
+AhDisplayAmlOpcode (
+    const AH_AML_OPCODE     *Op)
+{
+
+    if (!Op->OpcodeName)
+    {
+        printf ("%18s: Opcode=%-9s\n", "Reserved opcode", Op->OpcodeString);
+        return;
+    }
+
+    /* Opcode name and value(s) */
+
+    printf ("%18s: Opcode=%-9s Type (%s)",
+        Op->OpcodeName, Op->OpcodeString, Op->Type);
+
+    /* Optional fixed/static arguments */
+
+    if (Op->FixedArguments)
+    {
+        printf (" FixedArgs (");
+        AhPrintOneField (37, 36 + 7 + strlen (Op->Type) + 12,
+            AH_MAX_AML_LINE_LENGTH, Op->FixedArguments);
+        printf (")");
+    }
+
+    /* Optional variable-length argument list */
+
+    if (Op->VariableArguments)
+    {
+        if (Op->FixedArguments)
+        {
+            printf ("\n%*s", 36, " ");
+        }
+        printf (" VariableArgs (");
+        AhPrintOneField (37, 15, AH_MAX_AML_LINE_LENGTH, Op->VariableArguments);
+        printf (")");
+    }
+    printf ("\n");
+
+    /* Grammar specification */
+
+    if (Op->Grammar)
+    {
+        AhPrintOneField (37, 0, AH_MAX_AML_LINE_LENGTH, Op->Grammar);
+        printf ("\n");
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AhFindAmlTypes (entry point for AML grammar keyword search)
+ *
+ * PARAMETERS:  Name                - Name or prefix for an AML grammar element.
+ *                                    NULL means "find all"
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Find all AML grammar keywords that match the input Name or name
+ *              prefix.
+ *
+ ******************************************************************************/
+
+void
+AhFindAmlTypes (
+    char                    *Name)
+{
+    const AH_AML_TYPE       *Keyword;
+    BOOLEAN                 Found = FALSE;
+
+
+    AcpiUtStrupr (Name);
+
+    for (Keyword = Gbl_AmlTypesInfo; Keyword->Name; Keyword++)
+    {
+        if (!Name)
+        {
+            printf ("    %s\n", Keyword->Name);
+            Found = TRUE;
+            continue;
+        }
+
+        if (*Name == '*')
+        {
+            AhDisplayAmlType (Keyword);
+            Found = TRUE;
+            continue;
+        }
+
+        /* Upper case the operator name before substring compare */
+
+        strcpy (Gbl_Buffer, Keyword->Name);
+        AcpiUtStrupr (Gbl_Buffer);
+
+        if (strstr (Gbl_Buffer, Name) == Gbl_Buffer)
+        {
+            AhDisplayAmlType (Keyword);
+            Found = TRUE;
+        }
+    }
+
+    if (!Found)
+    {
+        printf ("%s, no matching AML grammar type\n", Name);
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AhDisplayAmlType
+ *
+ * PARAMETERS:  Op                  - Pointer to AML grammar info
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Format and display info for an AML grammar element.
+ *
+ ******************************************************************************/
+
+static void
+AhDisplayAmlType (
+    const AH_AML_TYPE       *Op)
+{
+    char                    *Description;
+
+
+    Description = Op->Description;
+    printf ("%4s", " ");    /* Primary indent */
+
+    /* Emit the entire description string */
+
+    while (*Description)
+    {
+        /* Description can be multiple lines, must indent each */
+
+        while (*Description != '\n')
+        {
+            printf ("%c", *Description);
+            Description++;
+        }
+
+        printf ("\n");
+        Description++;
+
+        /* Do indent */
+
+        if (*Description)
+        {
+            printf ("%8s", " ");    /* Secondary indent */
+
+            /* Index extra for a comment */
+
+            if ((Description[0] == '/') &&
+                (Description[1] == '/'))
+            {
+                printf ("%4s", " ");
+            }
+        }
+    }
+
+    printf ("\n");
+}
diff --git a/sys/contrib/dev/acpica/source/tools/acpihelp/ahamlops.c b/sys/contrib/dev/acpica/source/tools/acpihelp/ahamlops.c
index 57a0963c1f..b2d7c8f017 100644
--- a/sys/contrib/dev/acpica/source/tools/acpihelp/ahamlops.c
+++ b/sys/contrib/dev/acpica/source/tools/acpihelp/ahamlops.c
@@ -48,7 +48,7 @@
  * AML opcodes with related syntax and grammar information.
  * This table was extracted from the ACPI specification.
  */
-const AH_AML_OPCODE         AmlOpcodeInfo[] =
+const AH_AML_OPCODE         Gbl_AmlOpcodeInfo[] =
 {
     {0x00,   0x00,   "0x00",            "ZeroOp",               "DataObject",   NULL,                                           NULL,
                                                                 NULL},
diff --git a/sys/contrib/dev/acpica/source/tools/acpihelp/ahasl.c b/sys/contrib/dev/acpica/source/tools/acpihelp/ahasl.c
new file mode 100644
index 0000000000..c9fd3a672e
--- /dev/null
+++ b/sys/contrib/dev/acpica/source/tools/acpihelp/ahasl.c
@@ -0,0 +1,319 @@
+/******************************************************************************
+ *
+ * Module Name: ahasl - ASL operator decoding for acpihelp utility
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2016, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include "acpihelp.h"
+
+
+/* Local prototypes */
+
+static void
+AhDisplayAslOperator (
+    const AH_ASL_OPERATOR   *Op);
+
+static void
+AhDisplayOperatorKeywords (
+    const AH_ASL_OPERATOR   *Op);
+
+static void
+AhDisplayAslKeyword (
+    const AH_ASL_KEYWORD    *Op);
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AhFindAslKeywords (entry point for ASL keyword search)
+ *
+ * PARAMETERS:  Name                - Name or prefix for an ASL keyword.
+ *                                    NULL means "find all"
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Find all ASL keywords that match the input Name or name
+ *              prefix.
+ *
+ ******************************************************************************/
+
+void
+AhFindAslKeywords (
+    char                    *Name)
+{
+    const AH_ASL_KEYWORD    *Keyword;
+    BOOLEAN                 Found = FALSE;
+
+
+    AcpiUtStrupr (Name);
+
+    for (Keyword = Gbl_AslKeywordInfo; Keyword->Name; Keyword++)
+    {
+        if (!Name || (Name[0] == '*'))
+        {
+            AhDisplayAslKeyword (Keyword);
+            Found = TRUE;
+            continue;
+        }
+
+        /* Upper case the operator name before substring compare */
+
+        strcpy (Gbl_Buffer, Keyword->Name);
+        AcpiUtStrupr (Gbl_Buffer);
+
+        if (strstr (Gbl_Buffer, Name) == Gbl_Buffer)
+        {
+            AhDisplayAslKeyword (Keyword);
+            Found = TRUE;
+        }
+    }
+
+    if (!Found)
+    {
+        printf ("%s, no matching ASL keywords\n", Name);
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AhDisplayAslKeyword
+ *
+ * PARAMETERS:  Op                  - Pointer to ASL keyword with syntax info
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Format and display syntax info for an ASL keyword. Splits
+ *              long lines appropriately for reading.
+ *
+ ******************************************************************************/
+
+static void
+AhDisplayAslKeyword (
+    const AH_ASL_KEYWORD    *Op)
+{
+
+    /* ASL keyword name and description */
+
+    printf ("%22s: %s\n", Op->Name, Op->Description);
+    if (!Op->KeywordList)
+    {
+        return;
+    }
+
+    /* List of actual keywords */
+
+    AhPrintOneField (24, 0, AH_MAX_ASL_LINE_LENGTH, Op->KeywordList);
+    printf ("\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AhFindAslAndAmlOperators
+ *
+ * PARAMETERS:  Name                - Name or prefix for an ASL operator.
+ *                                    NULL means "find all"
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Find all ASL operators that match the input Name or name
+ *              prefix. Also displays the AML information if only one entry
+ *              matches.
+ *
+ ******************************************************************************/
+
+void
+AhFindAslAndAmlOperators (
+    char                    *Name)
+{
+    UINT32                  MatchCount;
+
+
+    MatchCount = AhFindAslOperators (Name);
+    if (MatchCount == 1)
+    {
+        AhFindAmlOpcode (Name);
+    }
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AhFindAslOperators (entry point for ASL operator search)
+ *
+ * PARAMETERS:  Name                - Name or prefix for an ASL operator.
+ *                                    NULL means "find all"
+ *
+ * RETURN:      Number of operators that matched the name prefix.
+ *
+ * DESCRIPTION: Find all ASL operators that match the input Name or name
+ *              prefix.
+ *
+ ******************************************************************************/
+
+UINT32
+AhFindAslOperators (
+    char                    *Name)
+{
+    const AH_ASL_OPERATOR   *Operator;
+    BOOLEAN                 MatchCount = 0;
+
+
+    AcpiUtStrupr (Name);
+
+    /* Find/display all names that match the input name prefix */
+
+    for (Operator = Gbl_AslOperatorInfo; Operator->Name; Operator++)
+    {
+        if (!Name || (Name[0] == '*'))
+        {
+            AhDisplayAslOperator (Operator);
+            MatchCount++;
+            continue;
+        }
+
+        /* Upper case the operator name before substring compare */
+
+        strcpy (Gbl_Buffer, Operator->Name);
+        AcpiUtStrupr (Gbl_Buffer);
+
+        if (strstr (Gbl_Buffer, Name) == Gbl_Buffer)
+        {
+            AhDisplayAslOperator (Operator);
+            MatchCount++;
+        }
+    }
+
+    if (!MatchCount)
+    {
+        printf ("%s, no matching ASL operators\n", Name);
+    }
+
+    return (MatchCount);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AhDisplayAslOperator
+ *
+ * PARAMETERS:  Op                  - Pointer to ASL operator with syntax info
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Format and display syntax info for an ASL operator. Splits
+ *              long lines appropriately for reading.
+ *
+ ******************************************************************************/
+
+static void
+AhDisplayAslOperator (
+    const AH_ASL_OPERATOR   *Op)
+{
+
+    /* ASL operator name and description */
+
+    printf ("%16s: %s\n", Op->Name, Op->Description);
+    if (!Op->Syntax)
+    {
+        return;
+    }
+
+    /* Syntax for the operator */
+
+    AhPrintOneField (18, 0, AH_MAX_ASL_LINE_LENGTH, Op->Syntax);
+    printf ("\n");
+
+    AhDisplayOperatorKeywords (Op);
+    printf ("\n");
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    AhDisplayOperatorKeywords
+ *
+ * PARAMETERS:  Op                  - Pointer to ASL keyword with syntax info
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Display any/all keywords that are associated with the ASL
+ *              operator.
+ *
+ ******************************************************************************/
+
+static void
+AhDisplayOperatorKeywords (
+    const AH_ASL_OPERATOR   *Op)
+{
+    char                    *Token;
+    char                    *Separators = "(){}, ";
+    BOOLEAN                 FirstKeyword = TRUE;
+
+
+    if (!Op || !Op->Syntax)
+    {
+        return;
+    }
+
+    /*
+     * Find all parameters that have the word "keyword" within, and then
+     * display the info about that keyword
+     */
+    strcpy (Gbl_LineBuffer, Op->Syntax);
+    Token = strtok (Gbl_LineBuffer, Separators);
+    while (Token)
+    {
+        if (strstr (Token, "Keyword"))
+        {
+            if (FirstKeyword)
+            {
+                printf ("\n");
+                FirstKeyword = FALSE;
+            }
+
+            /* Found a keyword, display keyword information */
+
+            AhFindAslKeywords (Token);
+        }
+
+        Token = strtok (NULL, Separators);
+    }
+}
diff --git a/sys/contrib/dev/acpica/source/tools/acpihelp/ahaslkey.c b/sys/contrib/dev/acpica/source/tools/acpihelp/ahaslkey.c
index 62791801f0..37d3ee9c52 100644
--- a/sys/contrib/dev/acpica/source/tools/acpihelp/ahaslkey.c
+++ b/sys/contrib/dev/acpica/source/tools/acpihelp/ahaslkey.c
@@ -48,7 +48,7 @@
  * ASL Keyword types and associated actual keywords.
  * This table was extracted from the ACPI specification.
  */
-const AH_ASL_KEYWORD        AslKeywordInfo[] =
+const AH_ASL_KEYWORD        Gbl_AslKeywordInfo[] =
 {
     {"AccessAttribKeyword", "Serial Bus Attributes (with legacy SMBus aliases)",
         ":= AttribQuick (SMBusQuick) | AttribSendReceive (SMBusSendReceive) | "
@@ -151,7 +151,7 @@ const AH_ASL_KEYWORD        AslKeywordInfo[] =
 
 /* Preprocessor directives */
 
-const AH_DIRECTIVE_INFO      PreprocessorDirectives[] =
+const AH_DIRECTIVE_INFO      Gbl_PreprocessorDirectives[] =
 {
     {"#include \"Filename\"",               "Standard include of an ASCII ASL source code file"},
     {"#include <Filename>",                 "Alternate syntax for #include, alternate search path"},
diff --git a/sys/contrib/dev/acpica/source/tools/acpihelp/ahaslops.c b/sys/contrib/dev/acpica/source/tools/acpihelp/ahaslops.c
index 39abc31b44..7437fccd63 100644
--- a/sys/contrib/dev/acpica/source/tools/acpihelp/ahaslops.c
+++ b/sys/contrib/dev/acpica/source/tools/acpihelp/ahaslops.c
@@ -48,7 +48,7 @@
  * Note: All tokens require a space separator.
  * Long lines are automatically split during output.
  */
-const AH_ASL_OPERATOR       AslOperatorInfo[] =
+const AH_ASL_OPERATOR       Gbl_AslOperatorInfo[] =
 {
     {"AccessAs",                "(AccessType, AccessAttribKeyword | "
                                 "ExtendedAttribKeyword (AccessLength))",
diff --git a/sys/contrib/dev/acpica/source/tools/acpihelp/ahdecode.c b/sys/contrib/dev/acpica/source/tools/acpihelp/ahdecode.c
index 5f422904a5..c1ac74c3c0 100644
--- a/sys/contrib/dev/acpica/source/tools/acpihelp/ahdecode.c
+++ b/sys/contrib/dev/acpica/source/tools/acpihelp/ahdecode.c
@@ -1,6 +1,6 @@
 /******************************************************************************
  *
- * Module Name: ahdecode - Operator/Opcode decoding for acpihelp utility
+ * Module Name: ahdecode - Miscellaneous decoding for acpihelp utility
  *
  *****************************************************************************/
 
@@ -48,19 +48,6 @@
 #include "acpredef.h"
 
 
-#define AH_DISPLAY_EXCEPTION(Status, Name) \
-    printf ("%.4X: %s\n", Status, Name)
-
-#define AH_DISPLAY_EXCEPTION_TEXT(Status, Exception) \
-    printf ("%.4X: %-28s (%s)\n", Status, Exception->Name, Exception->Description)
-
-#define BUFFER_LENGTH           128
-#define LINE_BUFFER_LENGTH      512
-
-static char         Gbl_Buffer[BUFFER_LENGTH];
-static char         Gbl_LineBuffer[LINE_BUFFER_LENGTH];
-
-
 /* Local prototypes */
 
 static BOOLEAN
@@ -76,32 +63,77 @@ static void
 AhDisplayResourceName (
     const ACPI_PREDEFINED_INFO  *ThisName);
 
-static void
-AhDisplayAmlOpcode (
-    const AH_AML_OPCODE     *Op);
-
-static void
-AhDisplayAmlType (
-    const AH_AML_TYPE       *Op);
-
-static void
-AhDisplayAslOperator (
-    const AH_ASL_OPERATOR   *Op);
-
-static void
-AhDisplayOperatorKeywords (
-    const AH_ASL_OPERATOR   *Op);
 
-static void
-AhDisplayAslKeyword (
-    const AH_ASL_KEYWORD    *Op);
+/*******************************************************************************
+ *
+ * FUNCTION:    AhPrintOneField
+ *
+ * PARAMETERS:  Indent              - Indent length for new line(s)
+ *              CurrentPosition     - Position on current line
+ *              MaxPosition         - Max allowed line length
+ *              Field               - Data to output
+ *
+ * RETURN:      Line position after field is written
+ *
+ * DESCRIPTION: Split long lines appropriately for ease of reading.
+ *
+ ******************************************************************************/
 
-static void
+void
 AhPrintOneField (
     UINT32                  Indent,
     UINT32                  CurrentPosition,
     UINT32                  MaxPosition,
-    const char              *Field);
+    const char              *Field)
+{
+    UINT32                  Position;
+    UINT32                  TokenLength;
+    const char              *This;
+    const char              *Next;
+    const char              *Last;
+
+
+    This = Field;
+    Position = CurrentPosition;
+
+    if (Position == 0)
+    {
+        printf ("%*s", (int) Indent, " ");
+        Position = Indent;
+    }
+
+    Last = This + strlen (This);
+    while ((Next = strpbrk (This, " ")))
+    {
+        TokenLength = Next - This;
+        Position += TokenLength;
+
+        /* Split long lines */
+
+        if (Position > MaxPosition)
+        {
+            printf ("\n%*s", (int) Indent, " ");
+            Position = TokenLength;
+        }
+
+        printf ("%.*s ", (int) TokenLength, This);
+        This = Next + 1;
+    }
+
+    /* Handle last token on the input line */
+
+    TokenLength = Last - This;
+    if (TokenLength > 0)
+    {
+        Position += TokenLength;
+        if (Position > MaxPosition)
+        {
+            printf ("\n%*s", (int) Indent, " ");
+        }
+
+        printf ("%s", This);
+    }
+}
 
 
 /*******************************************************************************
@@ -125,7 +157,7 @@ AhDisplayDirectives (
 
     printf ("iASL Preprocessor Directives\n\n");
 
-    for (Info = PreprocessorDirectives; Info->Name; Info++)
+    for (Info = Gbl_PreprocessorDirectives; Info->Name; Info++)
     {
         printf ("  %-36s : %s\n", Info->Name, Info->Description);
     }
@@ -329,632 +361,6 @@ AhDisplayResourceName (
 
 /*******************************************************************************
  *
- * FUNCTION:    AhFindAmlOpcode (entry point for AML opcode name search)
- *
- * PARAMETERS:  Name                - Name or prefix for an AML opcode.
- *                                    NULL means "find all"
- *
- * RETURN:      None
- *
- * DESCRIPTION: Find all AML opcodes that match the input Name or name
- *              prefix.
- *
- ******************************************************************************/
-
-void
-AhFindAmlOpcode (
-    char                    *Name)
-{
-    const AH_AML_OPCODE     *Op;
-    BOOLEAN                 Found = FALSE;
-
-
-    AcpiUtStrupr (Name);
-
-    /* Find/display all opcode names that match the input name prefix */
-
-    for (Op = AmlOpcodeInfo; Op->OpcodeString; Op++)
-    {
-        if (!Op->OpcodeName) /* Unused opcodes */
-        {
-            continue;
-        }
-
-        if (!Name || (Name[0] == '*'))
-        {
-            AhDisplayAmlOpcode (Op);
-            Found = TRUE;
-            continue;
-        }
-
-        /* Upper case the opcode name before substring compare */
-
-        strcpy (Gbl_Buffer, Op->OpcodeName);
-        AcpiUtStrupr (Gbl_Buffer);
-
-        if (strstr (Gbl_Buffer, Name) == Gbl_Buffer)
-        {
-            AhDisplayAmlOpcode (Op);
-            Found = TRUE;
-        }
-    }
-
-    if (!Found)
-    {
-        printf ("%s, no matching AML operators\n", Name);
-    }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AhDecodeAmlOpcode (entry point for AML opcode search)
- *
- * PARAMETERS:  OpcodeString        - String version of AML opcode
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display information about the input AML opcode
- *
- ******************************************************************************/
-
-void
-AhDecodeAmlOpcode (
-    char                    *OpcodeString)
-{
-    const AH_AML_OPCODE     *Op;
-    UINT32                  Opcode;
-    UINT8                   Prefix;
-
-
-    if (!OpcodeString)
-    {
-        AhFindAmlOpcode (NULL);
-        return;
-    }
-
-    Opcode = strtoul (OpcodeString, NULL, 16);
-    if (Opcode > ACPI_UINT16_MAX)
-    {
-        printf ("Invalid opcode (more than 16 bits)\n");
-        return;
-    }
-
-    /* Only valid opcode extension is 0x5B */
-
-    Prefix = (Opcode & 0x0000FF00) >> 8;
-    if (Prefix && (Prefix != 0x5B))
-    {
-        printf ("Invalid opcode (invalid extension prefix 0x%X)\n",
-            Prefix);
-        return;
-    }
-
-    /* Find/Display the opcode. May fall within an opcode range */
-
-    for (Op = AmlOpcodeInfo; Op->OpcodeString; Op++)
-    {
-        if ((Opcode >= Op->OpcodeRangeStart) &&
-            (Opcode <= Op->OpcodeRangeEnd))
-        {
-            AhDisplayAmlOpcode (Op);
-        }
-    }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AhDisplayAmlOpcode
- *
- * PARAMETERS:  Op                  - An opcode info struct
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display the contents of an AML opcode information struct
- *
- ******************************************************************************/
-
-static void
-AhDisplayAmlOpcode (
-    const AH_AML_OPCODE     *Op)
-{
-
-    if (!Op->OpcodeName)
-    {
-        printf ("%18s: Opcode=%-9s\n", "Reserved opcode", Op->OpcodeString);
-        return;
-    }
-
-    /* Opcode name and value(s) */
-
-    printf ("%18s: Opcode=%-9s Type (%s)",
-        Op->OpcodeName, Op->OpcodeString, Op->Type);
-
-    /* Optional fixed/static arguments */
-
-    if (Op->FixedArguments)
-    {
-        printf (" FixedArgs (");
-        AhPrintOneField (37, 36 + 7 + strlen (Op->Type) + 12,
-            AH_MAX_AML_LINE_LENGTH, Op->FixedArguments);
-        printf (")");
-    }
-
-    /* Optional variable-length argument list */
-
-    if (Op->VariableArguments)
-    {
-        if (Op->FixedArguments)
-        {
-            printf ("\n%*s", 36, " ");
-        }
-        printf (" VariableArgs (");
-        AhPrintOneField (37, 15, AH_MAX_AML_LINE_LENGTH, Op->VariableArguments);
-        printf (")");
-    }
-    printf ("\n");
-
-    /* Grammar specification */
-
-    if (Op->Grammar)
-    {
-        AhPrintOneField (37, 0, AH_MAX_AML_LINE_LENGTH, Op->Grammar);
-        printf ("\n");
-    }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AhFindAmlTypes (entry point for AML grammar keyword search)
- *
- * PARAMETERS:  Name                - Name or prefix for an AML grammar element.
- *                                    NULL means "find all"
- *
- * RETURN:      None
- *
- * DESCRIPTION: Find all AML grammar keywords that match the input Name or name
- *              prefix.
- *
- ******************************************************************************/
-
-void
-AhFindAmlTypes (
-    char                    *Name)
-{
-    const AH_AML_TYPE       *Keyword;
-    BOOLEAN                 Found = FALSE;
-
-
-    AcpiUtStrupr (Name);
-
-    for (Keyword = AmlTypesInfo; Keyword->Name; Keyword++)
-    {
-        if (!Name)
-        {
-            printf ("    %s\n", Keyword->Name);
-            Found = TRUE;
-            continue;
-        }
-
-        if (*Name == '*')
-        {
-            AhDisplayAmlType (Keyword);
-            Found = TRUE;
-            continue;
-        }
-
-        /* Upper case the operator name before substring compare */
-
-        strcpy (Gbl_Buffer, Keyword->Name);
-        AcpiUtStrupr (Gbl_Buffer);
-
-        if (strstr (Gbl_Buffer, Name) == Gbl_Buffer)
-        {
-            AhDisplayAmlType (Keyword);
-            Found = TRUE;
-        }
-    }
-
-    if (!Found)
-    {
-        printf ("%s, no matching AML grammar type\n", Name);
-    }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AhDisplayAmlType
- *
- * PARAMETERS:  Op                  - Pointer to AML grammar info
- *
- * RETURN:      None
- *
- * DESCRIPTION: Format and display info for an AML grammar element.
- *
- ******************************************************************************/
-
-static void
-AhDisplayAmlType (
-    const AH_AML_TYPE       *Op)
-{
-    char                    *Description;
-
-
-    Description = Op->Description;
-    printf ("%4s", " ");    /* Primary indent */
-
-    /* Emit the entire description string */
-
-    while (*Description)
-    {
-        /* Description can be multiple lines, must indent each */
-
-        while (*Description != '\n')
-        {
-            printf ("%c", *Description);
-            Description++;
-        }
-
-        printf ("\n");
-        Description++;
-
-        /* Do indent */
-
-        if (*Description)
-        {
-            printf ("%8s", " ");    /* Secondary indent */
-
-            /* Index extra for a comment */
-
-            if ((Description[0] == '/') &&
-                (Description[1] == '/'))
-            {
-                printf ("%4s", " ");
-            }
-        }
-    }
-
-    printf ("\n");
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AhFindAslKeywords (entry point for ASL keyword search)
- *
- * PARAMETERS:  Name                - Name or prefix for an ASL keyword.
- *                                    NULL means "find all"
- *
- * RETURN:      None
- *
- * DESCRIPTION: Find all ASL keywords that match the input Name or name
- *              prefix.
- *
- ******************************************************************************/
-
-void
-AhFindAslKeywords (
-    char                    *Name)
-{
-    const AH_ASL_KEYWORD    *Keyword;
-    BOOLEAN                 Found = FALSE;
-
-
-    AcpiUtStrupr (Name);
-
-    for (Keyword = AslKeywordInfo; Keyword->Name; Keyword++)
-    {
-        if (!Name || (Name[0] == '*'))
-        {
-            AhDisplayAslKeyword (Keyword);
-            Found = TRUE;
-            continue;
-        }
-
-        /* Upper case the operator name before substring compare */
-
-        strcpy (Gbl_Buffer, Keyword->Name);
-        AcpiUtStrupr (Gbl_Buffer);
-
-        if (strstr (Gbl_Buffer, Name) == Gbl_Buffer)
-        {
-            AhDisplayAslKeyword (Keyword);
-            Found = TRUE;
-        }
-    }
-
-    if (!Found)
-    {
-        printf ("%s, no matching ASL keywords\n", Name);
-    }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AhDisplayAslKeyword
- *
- * PARAMETERS:  Op                  - Pointer to ASL keyword with syntax info
- *
- * RETURN:      None
- *
- * DESCRIPTION: Format and display syntax info for an ASL keyword. Splits
- *              long lines appropriately for reading.
- *
- ******************************************************************************/
-
-static void
-AhDisplayAslKeyword (
-    const AH_ASL_KEYWORD    *Op)
-{
-
-    /* ASL keyword name and description */
-
-    printf ("%22s: %s\n", Op->Name, Op->Description);
-    if (!Op->KeywordList)
-    {
-        return;
-    }
-
-    /* List of actual keywords */
-
-    AhPrintOneField (24, 0, AH_MAX_ASL_LINE_LENGTH, Op->KeywordList);
-    printf ("\n");
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AhFindAslAndAmlOperators
- *
- * PARAMETERS:  Name                - Name or prefix for an ASL operator.
- *                                    NULL means "find all"
- *
- * RETURN:      None
- *
- * DESCRIPTION: Find all ASL operators that match the input Name or name
- *              prefix. Also displays the AML information if only one entry
- *              matches.
- *
- ******************************************************************************/
-
-void
-AhFindAslAndAmlOperators (
-    char                    *Name)
-{
-    UINT32                  MatchCount;
-
-
-    MatchCount = AhFindAslOperators (Name);
-    if (MatchCount == 1)
-    {
-        AhFindAmlOpcode (Name);
-    }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AhFindAslOperators (entry point for ASL operator search)
- *
- * PARAMETERS:  Name                - Name or prefix for an ASL operator.
- *                                    NULL means "find all"
- *
- * RETURN:      Number of operators that matched the name prefix.
- *
- * DESCRIPTION: Find all ASL operators that match the input Name or name
- *              prefix.
- *
- ******************************************************************************/
-
-UINT32
-AhFindAslOperators (
-    char                    *Name)
-{
-    const AH_ASL_OPERATOR   *Operator;
-    BOOLEAN                 MatchCount = 0;
-
-
-    AcpiUtStrupr (Name);
-
-    /* Find/display all names that match the input name prefix */
-
-    for (Operator = AslOperatorInfo; Operator->Name; Operator++)
-    {
-        if (!Name || (Name[0] == '*'))
-        {
-            AhDisplayAslOperator (Operator);
-            MatchCount++;
-            continue;
-        }
-
-        /* Upper case the operator name before substring compare */
-
-        strcpy (Gbl_Buffer, Operator->Name);
-        AcpiUtStrupr (Gbl_Buffer);
-
-        if (strstr (Gbl_Buffer, Name) == Gbl_Buffer)
-        {
-            AhDisplayAslOperator (Operator);
-            MatchCount++;
-        }
-    }
-
-    if (!MatchCount)
-    {
-        printf ("%s, no matching ASL operators\n", Name);
-    }
-
-    return (MatchCount);
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AhDisplayAslOperator
- *
- * PARAMETERS:  Op                  - Pointer to ASL operator with syntax info
- *
- * RETURN:      None
- *
- * DESCRIPTION: Format and display syntax info for an ASL operator. Splits
- *              long lines appropriately for reading.
- *
- ******************************************************************************/
-
-static void
-AhDisplayAslOperator (
-    const AH_ASL_OPERATOR   *Op)
-{
-
-    /* ASL operator name and description */
-
-    printf ("%16s: %s\n", Op->Name, Op->Description);
-    if (!Op->Syntax)
-    {
-        return;
-    }
-
-    /* Syntax for the operator */
-
-    AhPrintOneField (18, 0, AH_MAX_ASL_LINE_LENGTH, Op->Syntax);
-    printf ("\n");
-
-    AhDisplayOperatorKeywords (Op);
-    printf ("\n");
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AhDisplayOperatorKeywords
- *
- * PARAMETERS:  Op                  - Pointer to ASL keyword with syntax info
- *
- * RETURN:      None
- *
- * DESCRIPTION: Display any/all keywords that are associated with the ASL
- *              operator.
- *
- ******************************************************************************/
-
-static void
-AhDisplayOperatorKeywords (
-    const AH_ASL_OPERATOR   *Op)
-{
-    char                    *Token;
-    char                    *Separators = "(){}, ";
-    BOOLEAN                 FirstKeyword = TRUE;
-
-
-    if (!Op || !Op->Syntax)
-    {
-        return;
-    }
-
-    /*
-     * Find all parameters that have the word "keyword" within, and then
-     * display the info about that keyword
-     */
-    strcpy (Gbl_LineBuffer, Op->Syntax);
-    Token = strtok (Gbl_LineBuffer, Separators);
-    while (Token)
-    {
-        if (strstr (Token, "Keyword"))
-        {
-            if (FirstKeyword)
-            {
-                printf ("\n");
-                FirstKeyword = FALSE;
-            }
-
-            /* Found a keyword, display keyword information */
-
-            AhFindAslKeywords (Token);
-        }
-
-        Token = strtok (NULL, Separators);
-    }
-}
-
-
-/*******************************************************************************
- *
- * FUNCTION:    AhPrintOneField
- *
- * PARAMETERS:  Indent              - Indent length for new line(s)
- *              CurrentPosition     - Position on current line
- *              MaxPosition         - Max allowed line length
- *              Field               - Data to output
- *
- * RETURN:      Line position after field is written
- *
- * DESCRIPTION: Split long lines appropriately for ease of reading.
- *
- ******************************************************************************/
-
-static void
-AhPrintOneField (
-    UINT32                  Indent,
-    UINT32                  CurrentPosition,
-    UINT32                  MaxPosition,
-    const char              *Field)
-{
-    UINT32                  Position;
-    UINT32                  TokenLength;
-    const char              *This;
-    const char              *Next;
-    const char              *Last;
-
-
-    This = Field;
-    Position = CurrentPosition;
-
-    if (Position == 0)
-    {
-        printf ("%*s", (int) Indent, " ");
-        Position = Indent;
-    }
-
-    Last = This + strlen (This);
-    while ((Next = strpbrk (This, " ")))
-    {
-        TokenLength = Next - This;
-        Position += TokenLength;
-
-        /* Split long lines */
-
-        if (Position > MaxPosition)
-        {
-            printf ("\n%*s", (int) Indent, " ");
-            Position = TokenLength;
-        }
-
-        printf ("%.*s ", (int) TokenLength, This);
-        This = Next + 1;
-    }
-
-    /* Handle last token on the input line */
-
-    TokenLength = Last - This;
-    if (TokenLength > 0)
-    {
-        Position += TokenLength;
-        if (Position > MaxPosition)
-        {
-            printf ("\n%*s", (int) Indent, " ");
-        }
-
-        printf ("%s", This);
-    }
-}
-
-
-/*******************************************************************************
- *
  * FUNCTION:    AhDisplayDeviceIds
  *
  * PARAMETERS:  Name                - Device Hardware ID string.
@@ -1049,7 +455,7 @@ AhDisplayUuids (
 
     /* Display entire table of known ACPI-related UUIDs/GUIDs */
 
-    for (Info = AcpiUuids; Info->Description; Info++)
+    for (Info = Gbl_AcpiUuids; Info->Description; Info++)
     {
         if (!Info->String) /* Null UUID string means group description */
         {
@@ -1096,7 +502,7 @@ AhDisplayTables (
 
     printf ("Known ACPI tables:\n");
 
-    for (Info = AcpiSupportedTables; Info->Signature; Info++)
+    for (Info = Gbl_AcpiSupportedTables; Info->Signature; Info++)
     {
         printf ("%8s : %s\n", Info->Signature, Info->Description);
         i++;
diff --git a/sys/contrib/dev/acpica/source/tools/acpihelp/ahgrammar.c b/sys/contrib/dev/acpica/source/tools/acpihelp/ahgrammar.c
index 1e0d549746..d345893a1f 100644
--- a/sys/contrib/dev/acpica/source/tools/acpihelp/ahgrammar.c
+++ b/sys/contrib/dev/acpica/source/tools/acpihelp/ahgrammar.c
@@ -43,7 +43,7 @@
 
 #include "acpihelp.h"
 
-const AH_AML_TYPE           AmlTypesInfo[] =
+const AH_AML_TYPE           Gbl_AmlTypesInfo[] =
 {
     {"ComputationalData",
         "ComputationalData :=\n"
diff --git a/sys/contrib/dev/acpica/source/tools/acpihelp/ahmain.c b/sys/contrib/dev/acpica/source/tools/acpihelp/ahmain.c
index 1c45e43626..b62ec62f5e 100644
--- a/sys/contrib/dev/acpica/source/tools/acpihelp/ahmain.c
+++ b/sys/contrib/dev/acpica/source/tools/acpihelp/ahmain.c
@@ -41,6 +41,7 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
+#define DEFINE_AHELP_GLOBALS
 #include "acpihelp.h"
 
 
@@ -61,6 +62,7 @@ AhDisplayUsage (
 #define ACPI_OPTION(Name, Description) \
     AcpiOsPrintf ("  %-24s%s\n", Name, Description);
 
+
 /******************************************************************************
  *
  * FUNCTION:    AhDisplayUsage
diff --git a/sys/contrib/dev/acpica/source/tools/efihello/efihello.c b/sys/contrib/dev/acpica/source/tools/efihello/efihello.c
new file mode 100644
index 0000000000..ac7a64ce71
--- /dev/null
+++ b/sys/contrib/dev/acpica/source/tools/efihello/efihello.c
@@ -0,0 +1,124 @@
+/******************************************************************************
+ *
+ * Module Name: efihello - very simple ACPICA/EFI integration example
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2016, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *    substantially similar to the "NO WARRANTY" disclaimer below
+ *    ("Disclaimer") and any redistribution must be conditioned upon
+ *    including a substantially similar Disclaimer requirement for further
+ *    binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *    of any contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include "acpi.h"
+#include "accommon.h"
+#include "acapps.h"
+
+
+#define LINE_SIZE           256
+static char                 LineBuffer[LINE_SIZE];
+
+/******************************************************************************
+ *
+ * FUNCTION:    main
+ *
+ * PARAMETERS:  argc/argv           - Standard argc/argv
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: C main function for efihello
+ *
+ ******************************************************************************/
+
+#ifndef _GNU_EFI
+int ACPI_SYSTEM_XFACE
+main (
+    int                     argc,
+    char                    *argv[])
+#else
+int ACPI_SYSTEM_XFACE
+acpi_main (
+    int                     argc,
+    char                    *argv[])
+#endif
+{
+    ACPI_FILE               File;
+    BOOLEAN                 DoCloseFile = FALSE;
+    char                    *Result;
+
+
+    AcpiOsInitialize ();
+
+    printf ("argc=%d\n", argc);
+
+    if (argc > 1)
+    {
+        File = fopen (argv[1], "r");
+        if (!File)
+        {
+            printf ("Failed to open %s.\n", argv[1]);
+            return (-1);
+        }
+        DoCloseFile = TRUE;
+    }
+    else
+    {
+        File = stdin;
+    }
+
+    while (1)
+    {
+        Result = fgets (LineBuffer, LINE_SIZE, File);
+        if (!Result)
+        {
+            printf ("Failed to read %s.\n", argv[1]);
+            fclose (File);
+            return (-2);
+        }
+
+        printf ("%s", LineBuffer);
+
+        if (strncmp (Result, "exit", 4) == 0)
+        {
+            break;
+        }
+    }
+
+
+    if (DoCloseFile)
+    {
+        fclose (File);
+    }
+    return (0);
+}
diff --git a/sys/contrib/dev/acpica/tests/misc/grammar.asl b/sys/contrib/dev/acpica/tests/misc/grammar.asl
index 1b89e59993..080a36546a 100644
--- a/sys/contrib/dev/acpica/tests/misc/grammar.asl
+++ b/sys/contrib/dev/acpica/tests/misc/grammar.asl
@@ -965,19 +965,20 @@ DefinitionBlock (
         Store ("DIV0 - noabort", Debug)
     }
 
-    Method (ERR_, 1)
+    Method (ERR_, 2)
     {
+        Local0 = ToDecimalString (Arg1)
         if (LEqual (Arg0, 0))
         {
-            Store ("+*+*+*+* MTHD_ERROR: Results not equal!", Debug)
+            Printf ("+*+*+*+* MTHD_ERROR at line %o: Results not equal!", Local0)
         }
         if (LEqual (Arg0, 1))
         {
-            Store ("+*+*+*+* MTHD_ERROR: Numeric result is incorrect!", Debug)
+            Printf ("+*+*+*+* MTHD_ERROR at line %o: Numeric result is incorrect!", Local0)
         }
         if (LEqual (Arg0, 2))
         {
-            Store ("+*+*+*+* MTHD_ERROR: Operand was clobbered!", Debug)
+            Printf ("+*+*+*+* MTHD_ERROR at line %o: Operand was clobbered!", Local0)
         }
 
         Notify (DEV1, Arg0)
@@ -1033,245 +1034,245 @@ DefinitionBlock (
         Store (\IFEL.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\NOSV.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\IDXF.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\_SB_.NSTL.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\RTBF.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\_SB_.RTLV.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\_SB_.RETP.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\WHLR.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\ANDO.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\BRKP.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\ADSU.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\INDC.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\LOPS.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\FDSO.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\MLDV.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\NBIT.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\SHFT.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\XORD.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\CRBF.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\IDX4.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\EVNT.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\SZLV.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\_SB_.BYTF.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\DWDF.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\DVAX.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\IDX6.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\IDX5.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\_SB_.IDX0.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\_SB_.IDX3.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\IDX7.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\MTCH.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\WHLB.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\_SB_.IDX2.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\SIZO.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
         Store (\_SB_.SMIS.TEST(), Local0)
         if (LGreater (Local0, 0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
             Return(Local0)
         }
 
@@ -1331,14 +1332,14 @@ DefinitionBlock (
         Store (BIT2, Local0)
         if (LNotEqual (Local0, 0x1))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
         }
         else
         {
             Store (DerefOf (Index (BUF2, 0)), Local0)
             if (LNotEqual (Local0, 0x08))
             {
-                ERR_ (1)
+                ERR_ (1, __LINE__)
             }
             else
             {
@@ -1350,7 +1351,7 @@ DefinitionBlock (
         Store (BYT2, Local0)
         if (LNotEqual (Local0, 0x1A))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
         }
         else
         {
@@ -1361,7 +1362,7 @@ DefinitionBlock (
         Store (WRD2, Local0)
         if (LNotEqual (Local0, 0x1234))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
         }
         else
         {
@@ -1372,7 +1373,7 @@ DefinitionBlock (
         Store (FLD2, Local0)
         if (LNotEqual (Local0, 0x123))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
         }
         else
         {
@@ -1383,7 +1384,7 @@ DefinitionBlock (
         Store (DWD2, Local0)
         if (LNotEqual (Local0, 0x12345678))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
         }
         else
         {
@@ -1394,7 +1395,7 @@ DefinitionBlock (
         Store (QWD2, Local0)
         if (LNotEqual (Local0, 0x1234567887654321))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
         }
         else
         {
@@ -1546,7 +1547,7 @@ DefinitionBlock (
         Store ("++++++++ Checking result from ADD", Debug)
         if (LNotEqual (Local0, Local1))
         {
-            ERR_ (0)
+            ERR_ (0, __LINE__)
         }
 
 
@@ -1561,7 +1562,7 @@ DefinitionBlock (
         Store ("++++++++ Checking result from SUBTRACT", Debug)
         if (LNotEqual (Local4, Local5))
         {
-            ERR_ (0)
+            ERR_ (0, __LINE__)
         }
 
 
@@ -1577,7 +1578,7 @@ DefinitionBlock (
         Store ("++++++++ Checking result from MULTIPLY", Debug)
         if (LNotEqual (Local6, Local7))
         {
-            ERR_ (0)
+            ERR_ (0, __LINE__)
         }
 
 
@@ -1592,7 +1593,7 @@ DefinitionBlock (
         Store ("++++++++ Checking (quotient) result from DIVIDE", Debug)
         if (LNotEqual (Local2, Local3))
         {
-            ERR_ (0)
+            ERR_ (0, __LINE__)
         }
 
 
@@ -1606,7 +1607,7 @@ DefinitionBlock (
         Store ("++++++++ Checking result from INCREMENT", Debug)
         if (LNotEqual (Local0, Local1))
         {
-            ERR_ (0)
+            ERR_ (0, __LINE__)
         }
 
 
@@ -1620,7 +1621,7 @@ DefinitionBlock (
         Store ("++++++++ Checking result from DECREMENT", Debug)
         if (LNotEqual (Local0, Local1))
         {
-            ERR_ (0)
+            ERR_ (0, __LINE__)
         }
 
 
@@ -1649,22 +1650,22 @@ DefinitionBlock (
         Add (Local0, Local1)
         if (LNotEqual (Local0, 3))
         {
-            ERR_ (2)
+            ERR_ (2, __LINE__)
         }
         if (LNotEqual (Local1, 7))
         {
-            ERR_ (2)
+            ERR_ (2, __LINE__)
         }
 
 
         Add (Local0, Local1, Local2)
         if (LNotEqual (Local0, 3))
         {
-            ERR_ (2)
+            ERR_ (2, __LINE__)
         }
         if (LNotEqual (Local1, 7))
         {
-            ERR_ (2)
+            ERR_ (2, __LINE__)
         }
     }
 
@@ -1692,63 +1693,63 @@ DefinitionBlock (
         FindSetLeftBit (0x00100100, Local0)
         if (LNotEqual (Local0, 21))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
         }
 
         Store ("++++++++ FindSetRightBit (0x00100100, Local1)", Debug)
         FindSetRightBit (0x00100100, Local1)
         if (LNotEqual (Local1, 9))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
         }
 
         Store ("++++++++ And (0xF0F0F0F0, 0x11111111, Local2)", Debug)
         And (0xF0F0F0F0, 0x11111111, Local2)
         if (LNotEqual (Local2, 0x10101010))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
         }
 
         Store ("++++++++ NAnd (0xF0F0F0F0, 0x11111111, Local3)", Debug)
         NAnd (0xF0F0F0F0, 0x11111111, Local3)
         if (LNotEqual (Local3, 0xEFEFEFEF))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
         }
 
         Store ("++++++++ Or (0x11111111, 0x22222222, Local4)", Debug)
         Or (0x11111111, 0x22222222, Local4)
         if (LNotEqual (Local4, 0x33333333))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
         }
 
         Store ("++++++++ NOr (0x11111111, 0x22222222, Local5)", Debug)
         NOr (0x11111111, 0x22222222, Local5)
         if (LNotEqual (Local5, 0xCCCCCCCC))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
         }
 
         Store ("++++++++ XOr (0x11113333, 0x22222222, Local6)", Debug)
         XOr (0x11113333, 0x22222222, Local6)
         if (LNotEqual (Local6, 0x33331111))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
         }
 
         Store ("++++++++ ShiftLeft (0x11112222, 2, Local7)", Debug)
         ShiftLeft (0x11112222, 2, Local7)
         if (LNotEqual (Local7, 0x44448888))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
         }
 
         Store ("++++++++ ShiftRight (Local7, 2, Local7)", Debug)
         ShiftRight (Local7, 2, Local7)
         if (LNotEqual (Local7, 0x11112222))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
         }
 
 
@@ -1757,12 +1758,12 @@ DefinitionBlock (
         Not (Local0, Local1)
         if (LNotEqual (Local0, 0x22224444))
         {
-            ERR_ (2)
+            ERR_ (2, __LINE__)
         }
 
         if (LNotEqual (Local1, 0xDDDDBBBB))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
         }
 
         Return (Local7)
@@ -1795,12 +1796,12 @@ DefinitionBlock (
         Store (LNot (Local6), Local7)
         if (LNotEqual (Local6, 0x00001111))
         {
-            ERR_ (2)
+            ERR_ (2, __LINE__)
         }
 
         if (LNotEqual (Local7, 0x0))
         {
-            ERR_ (1)
+            ERR_ (1, __LINE__)
         }
 
 
@@ -1933,25 +1934,25 @@ DefinitionBlock (
         Store (CondRefOf (ABCD, Local0), Local1)
         if (LNotEqual (Local1, 0))
         {
-            ERR_ (2)
+            ERR_ (2, __LINE__)
         }
 
         Store (CondRefOf (BBUF, Local0), Local1)
         if (LNotEqual (Local1, Ones))
         {
-            ERR_ (2)
+            ERR_ (2, __LINE__)
         }
 
         Store (DeRefOf (Index (BBUF, 3)), Local6)
         if (LNotEqual (Local6, 0xB3))
         {
-            ERR_ (2)
+            ERR_ (2, __LINE__)
         }
 
         Store (DeRefOf (Index (DeRefOf (Index (NEST, 1)), 3)), Local0)
         if (LNotEqual (Local0, 0x14))
         {
-            ERR_ (2)
+            ERR_ (2, __LINE__)
         }
 
 
@@ -1961,7 +1962,7 @@ DefinitionBlock (
         Store (DerefOf (Local1), Local2)
         If (LNotEqual (Local2, 0x11223344))
         {
-            ERR_ (2)
+            ERR_ (2, __LINE__)
         }
 
 
diff --git a/sys/dev/acpica/Osd/OsdDebug.c b/sys/dev/acpica/Osd/OsdDebug.c
index e5fd8f798c..1873d3d5d2 100644
--- a/sys/dev/acpica/Osd/OsdDebug.c
+++ b/sys/dev/acpica/Osd/OsdDebug.c
@@ -44,6 +44,8 @@
 #include "acpivar.h"
 #include "acdebug.h"
 
+ACPI_MODULE_NAME("DEBUG")
+
 ACPI_STATUS
 AcpiOsGetLine(char *Buffer, UINT32 BufferLength, UINT32 *BytesRead)
 {
@@ -93,16 +95,56 @@ AcpiOsSignal(UINT32 Function, void *Info)
 }
 
 #ifdef ACPI_DEBUGGER
-DB_COMMAND(acpidb, db_cmd_acpidb)
+ACPI_STATUS
+AcpiOsInitializeDebugger(void)
 {
-    kprintf("Entering ACPICA debugger...\n");
-    while (!AcpiGbl_DbTerminateLoop) {
+	return (AE_OK);
+}
+
+void
+AcpiOsTerminateDebugger(void)
+{
+}
+
+ACPI_STATUS
+AcpiOsWaitCommandReady(void)
+{
+	ACPI_STATUS Status;
+
+	/* Force output to console until a command is entered */
+
 	AcpiDbSetOutputDestination(ACPI_DB_CONSOLE_OUTPUT);
+
+	/* Different prompt if method is executing */
+
 	if (!AcpiGbl_MethodExecuting)
-	    AcpiOsPrintf("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
+		AcpiOsPrintf("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
 	else
-	    AcpiOsPrintf("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
-	AcpiOsGetLine(AcpiGbl_DbLineBuf, ACPI_DB_LINE_BUFFER_SIZE, NULL);
+		AcpiOsPrintf("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
+
+	/* Get the user input line */
+
+	Status = AcpiOsGetLine(AcpiGbl_DbLineBuf,
+	    ACPI_DB_LINE_BUFFER_SIZE, NULL);
+
+	if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE)
+		ACPI_EXCEPTION ((AE_INFO, Status,
+			"While parsing/handling command line"));
+	return (Status);
+}
+
+ACPI_STATUS
+AcpiOsNotifyCommandComplete(void)
+{
+	return (AE_OK);
+}
+
+DB_COMMAND(acpidb, db_cmd_acpidb)
+{
+    kprintf("Entering ACPICA debugger...\n");
+    while (!AcpiGbl_DbTerminateLoop) {
+	if (ACPI_FAILURE(AcpiOsWaitCommandReady()))
+	    break;
 	AcpiDbCommandDispatch(AcpiGbl_DbLineBuf, NULL, NULL);
     }
     AcpiGbl_DbTerminateLoop = FALSE;
diff --git a/sys/dev/acpica/Osd/OsdHardware.c b/sys/dev/acpica/Osd/OsdHardware.c
index 67783aef43..52753db103 100644
--- a/sys/dev/acpica/Osd/OsdHardware.c
+++ b/sys/dev/acpica/Osd/OsdHardware.c
@@ -124,3 +124,12 @@ AcpiOsWritePciConfiguration(ACPI_PCI_ID *PciId, UINT32 Register,
 
     return (AE_OK);
 }
+
+ACPI_STATUS
+AcpiOsEnterSleep (
+    UINT8                   SleepState,
+    UINT32                  RegaValue,
+    UINT32                  RegbValue)
+{
+    return (AE_OK);
+}
diff --git a/usr.sbin/acpi/acpiexec/Makefile b/usr.sbin/acpi/acpiexec/Makefile
index 91619189bd..383b4e0284 100644
--- a/usr.sbin/acpi/acpiexec/Makefile
+++ b/usr.sbin/acpi/acpiexec/Makefile
@@ -137,6 +137,7 @@ SRCS+=	\
 	nsxfeval.c \
 	nsxfname.c \
 	nsxfobj.c \
+	osgendbg.c \
 	osunixxf.c \
 	psargs.c \
 	psloop.c \
diff --git a/usr.sbin/acpi/acpihelp/Makefile b/usr.sbin/acpi/acpihelp/Makefile
index 261572f165..22d5583e3f 100644
--- a/usr.sbin/acpi/acpihelp/Makefile
+++ b/usr.sbin/acpi/acpihelp/Makefile
@@ -11,7 +11,9 @@ PROG=	acpihelp
 MAN=	acpihelp.8
 
 SRCS=	\
+	ahaml.c \
 	ahamlops.c \
+	ahasl.c \
 	ahaslkey.c \
 	ahaslops.c \
 	ahdecode.c \
-- 
2.11.0

