1 /*******************************************************************************
3 * Module Name: dmutils - AML disassembler utilities
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2011, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
45 #include <contrib/dev/acpica/include/acpi.h>
46 #include <contrib/dev/acpica/include/accommon.h>
47 #include <contrib/dev/acpica/include/amlcode.h>
48 #include <contrib/dev/acpica/include/acdisasm.h>
50 #ifdef ACPI_ASL_COMPILER
51 #include <contrib/dev/acpica/include/acnamesp.h>
54 #ifdef ACPI_DISASSEMBLER
56 #define _COMPONENT ACPI_CA_DEBUGGER
57 ACPI_MODULE_NAME ("dmutils")
60 /* Data used in keeping track of fields */
62 const char *AcpiGbl_FENames[] =
66 }; /* FE = Field Element */
69 /* Operators for Match() */
71 const char *AcpiGbl_MatchOps[] =
81 /* Access type decoding */
83 const char *AcpiGbl_AccessTypes[] =
95 /* Lock rule decoding */
97 const char *AcpiGbl_LockRule[] =
103 /* Update rule decoding */
105 const char *AcpiGbl_UpdateRules[] =
113 /* Strings used to decode resource descriptors */
115 const char *AcpiGbl_WordDecode[] =
120 "UnknownResourceType"
123 const char *AcpiGbl_IrqDecode[] =
130 /*******************************************************************************
132 * FUNCTION: AcpiDmDecodeAttribute
134 * PARAMETERS: Attribute - Attribute field of AccessAs keyword
138 * DESCRIPTION: Decode the AccessAs attribute byte. (Mostly SMBus stuff)
140 ******************************************************************************/
143 AcpiDmDecodeAttribute (
149 case AML_FIELD_ATTRIB_SMB_QUICK:
151 AcpiOsPrintf ("SMBQuick");
154 case AML_FIELD_ATTRIB_SMB_SEND_RCV:
156 AcpiOsPrintf ("SMBSendReceive");
159 case AML_FIELD_ATTRIB_SMB_BYTE:
161 AcpiOsPrintf ("SMBByte");
164 case AML_FIELD_ATTRIB_SMB_WORD:
166 AcpiOsPrintf ("SMBWord");
169 case AML_FIELD_ATTRIB_SMB_WORD_CALL:
171 AcpiOsPrintf ("SMBProcessCall");
174 case AML_FIELD_ATTRIB_SMB_BLOCK:
176 AcpiOsPrintf ("SMBBlock");
179 case AML_FIELD_ATTRIB_SMB_BLOCK_CALL:
181 AcpiOsPrintf ("SMBBlockProcessCall");
186 AcpiOsPrintf ("0x%.2X", Attribute);
192 /*******************************************************************************
194 * FUNCTION: AcpiDmIndent
196 * PARAMETERS: Level - Current source code indentation level
200 * DESCRIPTION: Indent 4 spaces per indentation level.
202 ******************************************************************************/
214 AcpiOsPrintf ("%*.s", ACPI_MUL_4 (Level), " ");
218 /*******************************************************************************
220 * FUNCTION: AcpiDmCommaIfListMember
222 * PARAMETERS: Op - Current operator/operand
224 * RETURN: TRUE if a comma was inserted
226 * DESCRIPTION: Insert a comma if this Op is a member of an argument list.
228 ******************************************************************************/
231 AcpiDmCommaIfListMember (
232 ACPI_PARSE_OBJECT *Op)
235 if (!Op->Common.Next)
240 if (AcpiDmListType (Op->Common.Parent) & BLOCK_COMMA_LIST)
242 /* Check for a NULL target operand */
244 if ((Op->Common.Next->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
245 (!Op->Common.Next->Common.Value.String))
248 * To handle the Divide() case where there are two optional
249 * targets, look ahead one more op. If null, this null target
250 * is the one and only target -- no comma needed. Otherwise,
251 * we need a comma to prepare for the next target.
253 if (!Op->Common.Next->Common.Next)
259 if ((Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST) &&
260 (!(Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)))
269 else if ((Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST) &&
270 (Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST))
280 /*******************************************************************************
282 * FUNCTION: AcpiDmCommaIfFieldMember
284 * PARAMETERS: Op - Current operator/operand
288 * DESCRIPTION: Insert a comma if this Op is a member of a Field argument list.
290 ******************************************************************************/
293 AcpiDmCommaIfFieldMember (
294 ACPI_PARSE_OBJECT *Op)