summaryrefslogtreecommitdiffstats
path: root/sys/contrib/dev/acpica/components/disassembler/dmwalk.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/dev/acpica/components/disassembler/dmwalk.c')
-rw-r--r--sys/contrib/dev/acpica/components/disassembler/dmwalk.c276
1 files changed, 235 insertions, 41 deletions
diff --git a/sys/contrib/dev/acpica/components/disassembler/dmwalk.c b/sys/contrib/dev/acpica/components/disassembler/dmwalk.c
index 9621862..8f7a475 100644
--- a/sys/contrib/dev/acpica/components/disassembler/dmwalk.c
+++ b/sys/contrib/dev/acpica/components/disassembler/dmwalk.c
@@ -4,10 +4,118 @@
*
******************************************************************************/
-/*
- * Copyright (C) 2000 - 2016, Intel Corp.
+/******************************************************************************
+ *
+ * 1. Copyright Notice
+ *
+ * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp.
* All rights reserved.
*
+ * 2. License
+ *
+ * 2.1. This is your license from Intel Corp. under its intellectual property
+ * rights. You may have additional license terms from the party that provided
+ * you this software, covering your right to use that party's intellectual
+ * property rights.
+ *
+ * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
+ * copy of the source code appearing in this file ("Covered Code") an
+ * irrevocable, perpetual, worldwide license under Intel's copyrights in the
+ * base code distributed originally by Intel ("Original Intel Code") to copy,
+ * make derivatives, distribute, use and display any portion of the Covered
+ * Code in any form, with the right to sublicense such rights; and
+ *
+ * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
+ * license (with the right to sublicense), under only those claims of Intel
+ * patents that are infringed by the Original Intel Code, to make, use, sell,
+ * offer to sell, and import the Covered Code and derivative works thereof
+ * solely to the minimum extent necessary to exercise the above copyright
+ * license, and in no event shall the patent license extend to any additions
+ * to or modifications of the Original Intel Code. No other license or right
+ * is granted directly or by implication, estoppel or otherwise;
+ *
+ * The above copyright and patent license is granted only if the following
+ * conditions are met:
+ *
+ * 3. Conditions
+ *
+ * 3.1. Redistribution of Source with Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification with rights to further distribute source must include
+ * the above Copyright Notice, the above License, this list of Conditions,
+ * and the following Disclaimer and Export Compliance provision. In addition,
+ * Licensee must cause all Covered Code to which Licensee contributes to
+ * contain a file documenting the changes Licensee made to create that Covered
+ * Code and the date of any change. Licensee must include in that file the
+ * documentation of any changes made by any predecessor Licensee. Licensee
+ * must include a prominent statement that the modification is derived,
+ * directly or indirectly, from Original Intel Code.
+ *
+ * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
+ * Redistribution of source code of any substantial portion of the Covered
+ * Code or modification without rights to further distribute source must
+ * include the following Disclaimer and Export Compliance provision in the
+ * documentation and/or other materials provided with distribution. In
+ * addition, Licensee may not authorize further sublicense of source of any
+ * portion of the Covered Code, and must include terms to the effect that the
+ * license from Licensee to its licensee is limited to the intellectual
+ * property embodied in the software Licensee provides to its licensee, and
+ * not to intellectual property embodied in modifications its licensee may
+ * make.
+ *
+ * 3.3. Redistribution of Executable. Redistribution in executable form of any
+ * substantial portion of the Covered Code or modification must reproduce the
+ * above Copyright Notice, and the following Disclaimer and Export Compliance
+ * provision in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3.4. Intel retains all right, title, and interest in and to the Original
+ * Intel Code.
+ *
+ * 3.5. Neither the name Intel nor any other trademark owned or controlled by
+ * Intel shall be used in advertising or otherwise to promote the sale, use or
+ * other dealings in products derived from or relating to the Covered Code
+ * without prior written authorization from Intel.
+ *
+ * 4. Disclaimer and Export Compliance
+ *
+ * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
+ * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
+ * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
+ * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
+ * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
+ * PARTICULAR PURPOSE.
+ *
+ * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
+ * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
+ * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
+ * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
+ * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
+ * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
+ * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
+ * LIMITED REMEDY.
+ *
+ * 4.3. Licensee shall not export, either directly or indirectly, any of this
+ * software or system incorporating such software without first obtaining any
+ * required license or other approval from the U. S. Department of Commerce or
+ * any other agency or department of the United States Government. In the
+ * event Licensee exports any such software from the United States or
+ * re-exports any such software from a foreign destination, Licensee shall
+ * ensure that the distribution and export/re-export of the software is in
+ * compliance with all laws, regulations, orders, or other restrictions of the
+ * U.S. Export Administration Regulations. Licensee agrees that neither it nor
+ * any of its subsidiaries will export/re-export any technical data, process,
+ * software, or service, directly or indirectly, to any country for which the
+ * United States government or any agency thereof requires an export license,
+ * other governmental approval, or letter of assurance, without first obtaining
+ * such license, approval or letter.
+ *
+ *****************************************************************************
+ *
+ * Alternatively, you may choose to be licensed under the terms of the
+ * following license:
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -23,29 +131,30 @@
* 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
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 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.
- */
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * 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 DAMAGE.
+ *
+ * Alternatively, you may choose to be licensed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ *****************************************************************************/
#include <contrib/dev/acpica/include/acpi.h>
#include <contrib/dev/acpica/include/accommon.h>
#include <contrib/dev/acpica/include/acparser.h>
#include <contrib/dev/acpica/include/amlcode.h>
#include <contrib/dev/acpica/include/acdebug.h>
+#include <contrib/dev/acpica/include/acconvert.h>
#define _COMPONENT ACPI_CA_DEBUGGER
@@ -63,6 +172,14 @@ AcpiDmEmitExternals (
{
return;
}
+
+void
+AcpiDmEmitExternal (
+ ACPI_PARSE_OBJECT *NameOp,
+ ACPI_PARSE_OBJECT *TypeOp)
+{
+ return;
+}
#endif
/* Local prototypes */
@@ -79,10 +196,6 @@ AcpiDmAscendingOp (
UINT32 Level,
void *Context);
-static UINT32
-AcpiDmBlockType (
- ACPI_PARSE_OBJECT *Op);
-
/*******************************************************************************
*
@@ -248,7 +361,7 @@ AcpiDmWalkParseTree (
*
******************************************************************************/
-static UINT32
+UINT32
AcpiDmBlockType (
ACPI_PARSE_OBJECT *Op)
{
@@ -270,7 +383,7 @@ AcpiDmBlockType (
case AML_DEVICE_OP:
case AML_SCOPE_OP:
case AML_PROCESSOR_OP:
- case AML_POWER_RES_OP:
+ case AML_POWER_RESOURCE_OP:
case AML_THERMAL_ZONE_OP:
case AML_IF_OP:
case AML_WHILE_OP:
@@ -292,7 +405,7 @@ AcpiDmBlockType (
/*lint -fallthrough */
case AML_PACKAGE_OP:
- case AML_VAR_PACKAGE_OP:
+ case AML_VARIABLE_PACKAGE_OP:
return (BLOCK_PAREN | BLOCK_BRACE);
@@ -304,7 +417,7 @@ AcpiDmBlockType (
if (Op->Common.Parent &&
((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
- (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)))
+ (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP)))
{
/* This is a reference to a method, not an invocation */
@@ -357,7 +470,7 @@ AcpiDmListType (
case AML_METHOD_OP:
case AML_DEVICE_OP:
case AML_SCOPE_OP:
- case AML_POWER_RES_OP:
+ case AML_POWER_RESOURCE_OP:
case AML_PROCESSOR_OP:
case AML_THERMAL_ZONE_OP:
case AML_IF_OP:
@@ -370,7 +483,7 @@ AcpiDmListType (
case AML_BUFFER_OP:
case AML_PACKAGE_OP:
- case AML_VAR_PACKAGE_OP:
+ case AML_VARIABLE_PACKAGE_OP:
return (BLOCK_COMMA_LIST);
@@ -414,6 +527,22 @@ AcpiDmDescendingOp (
UINT32 AmlOffset;
+ /* Determine which file this parse node is contained in. */
+
+ if (Gbl_CaptureComments)
+ {
+ ASL_CV_LABEL_FILENODE (Op);
+
+ if (Level != 0 && ASL_CV_FILE_HAS_SWITCHED (Op))
+ {
+ ASL_CV_SWITCH_FILES (Level, Op);
+ }
+
+ /* If this parse node has regular comments, print them here. */
+
+ ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_STANDARD, NULL, Level);
+ }
+
OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
/* Listing support to dump the AML code after the ASL statement */
@@ -455,6 +584,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);
@@ -514,7 +657,11 @@ AcpiDmDescendingOp (
/* Emit all External() declarations here */
- AcpiDmEmitExternals ();
+ if (!AcpiGbl_DmEmitExternalOpcodes)
+ {
+ AcpiDmEmitExternals ();
+ }
+
return (AE_OK);
}
}
@@ -593,6 +740,12 @@ AcpiDmDescendingOp (
Info->Level--;
}
+ if (Op->Common.AmlOpcode == AML_EXTERNAL_OP)
+ {
+ Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
+ return (AE_CTRL_DEPTH);
+ }
+
/* Start the opcode argument list if necessary */
if ((OpInfo->Flags & AML_HAS_ARGS) ||
@@ -603,6 +756,10 @@ AcpiDmDescendingOp (
if (AcpiDmBlockType (Op) & BLOCK_PAREN)
{
AcpiOsPrintf (" (");
+ if (!(AcpiDmBlockType (Op) & BLOCK_BRACE))
+ {
+ ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, " ", 0);
+ }
}
/* If this is a named opcode, print the associated name value */
@@ -647,7 +804,7 @@ AcpiDmDescendingOp (
case AML_METHOD_OP:
AcpiDmMethodFlags (Op);
- AcpiOsPrintf (")");
+ ASL_CV_CLOSE_PAREN (Op, Level);
/* Emit description comment for Method() with a predefined ACPI name */
@@ -660,6 +817,7 @@ AcpiDmDescendingOp (
AcpiDmCheckForHardwareId (Op);
AcpiOsPrintf (", ");
+ ASL_CV_PRINT_ONE_COMMENT (Op, AML_NAMECOMMENT, NULL, 0);
break;
case AML_REGION_OP:
@@ -667,7 +825,7 @@ AcpiDmDescendingOp (
AcpiDmRegionFlags (Op);
break;
- case AML_POWER_RES_OP:
+ case AML_POWER_RESOURCE_OP:
/* Mark the next two Ops as part of the parameter list */
@@ -709,7 +867,7 @@ AcpiDmDescendingOp (
case AML_DEVICE_OP:
case AML_THERMAL_ZONE_OP:
- AcpiOsPrintf (")");
+ ASL_CV_CLOSE_PAREN (Op, Level);
break;
default:
@@ -803,7 +961,7 @@ AcpiDmDescendingOp (
*/
NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
NextOp = NextOp->Common.Next;
- AcpiOsPrintf (")");
+ ASL_CV_CLOSE_PAREN (Op, Level);
/* Emit description comment for Name() with a predefined ACPI name */
@@ -821,7 +979,7 @@ AcpiDmDescendingOp (
return (AE_OK);
case AML_IF_OP:
- case AML_VAR_PACKAGE_OP:
+ case AML_VARIABLE_PACKAGE_OP:
case AML_WHILE_OP:
/* The next op is the size or predicate parameter */
@@ -889,7 +1047,22 @@ AcpiDmAscendingOp (
ACPI_PARSE_OBJECT *ParentOp;
- if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE)
+ /* Point the Op's filename pointer to the proper file */
+
+ if (Gbl_CaptureComments)
+ {
+ ASL_CV_LABEL_FILENODE (Op);
+
+ /* Switch the output of these files if necessary */
+
+ if (ASL_CV_FILE_HAS_SWITCHED (Op))
+ {
+ ASL_CV_SWITCH_FILES (Level, Op);
+ }
+ }
+
+ if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE ||
+ Op->Common.DisasmOpcode == ACPI_DASM_IGNORE_SINGLE)
{
/* Ignore this op -- it was handled elsewhere */
@@ -900,7 +1073,17 @@ AcpiDmAscendingOp (
{
/* Indicates the end of the current descriptor block (table) */
- AcpiOsPrintf ("}\n\n");
+ ASL_CV_CLOSE_BRACE (Op, Level);
+
+ /* Print any comments that are at the end of the file here */
+
+ if (Gbl_CaptureComments && AcpiGbl_LastListHead)
+ {
+ AcpiOsPrintf ("\n");
+ ASL_CV_PRINT_ONE_COMMENT_LIST (AcpiGbl_LastListHead, 0);
+ }
+ AcpiOsPrintf ("\n\n");
+
return (AE_OK);
}
@@ -961,12 +1144,12 @@ AcpiDmAscendingOp (
if (Op->Common.DisasmFlags & ACPI_PARSEOP_EMPTY_TERMLIST)
{
- AcpiOsPrintf ("}");
+ ASL_CV_CLOSE_BRACE (Op, Level);
}
else
{
AcpiDmIndent (Level);
- AcpiOsPrintf ("}");
+ ASL_CV_CLOSE_BRACE (Op, Level);
}
AcpiDmCommaIfListMember (Op);
@@ -1016,7 +1199,7 @@ AcpiDmAscendingOp (
switch (Op->Common.Parent->Common.AmlOpcode)
{
case AML_PACKAGE_OP:
- case AML_VAR_PACKAGE_OP:
+ case AML_VARIABLE_PACKAGE_OP:
if (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST))
{
@@ -1049,11 +1232,14 @@ 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 (")");
+ ASL_CV_CLOSE_PAREN (Op, Level);
/*
* Emit a description comment for a Name() operator that is a
@@ -1066,6 +1252,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");
@@ -1073,7 +1266,8 @@ AcpiDmAscendingOp (
else
{
ParentOp->Common.DisasmFlags |= ACPI_PARSEOP_EMPTY_TERMLIST;
- AcpiOsPrintf (") {");
+ ASL_CV_CLOSE_PAREN (Op, Level);
+ AcpiOsPrintf ("{");
}
}
OpenPOWER on IntegriCloud