1 /*******************************************************************************
3 * Module Name: dmutils - AML disassembler utilities
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2014, 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.
49 #ifdef ACPI_ASL_COMPILER
53 #ifdef ACPI_DISASSEMBLER
55 #define _COMPONENT ACPI_CA_DEBUGGER
56 ACPI_MODULE_NAME ("dmutils")
59 /* Data used in keeping track of fields */
61 const char *AcpiGbl_FENames[] =
65 }; /* FE = Field Element */
68 /* Operators for Match() */
70 const char *AcpiGbl_MatchOps[] =
80 /* Access type decoding */
82 const char *AcpiGbl_AccessTypes[] =
94 /* Lock rule decoding */
96 const char *AcpiGbl_LockRule[] =
102 /* Update rule decoding */
104 const char *AcpiGbl_UpdateRules[] =
112 /* Strings used to decode resource descriptors */
114 const char *AcpiGbl_WordDecode[] =
119 "UnknownResourceType"
122 const char *AcpiGbl_IrqDecode[] =
129 /*******************************************************************************
131 * FUNCTION: AcpiDmDecodeAttribute
133 * PARAMETERS: Attribute - Attribute field of AccessAs keyword
137 * DESCRIPTION: Decode the AccessAs attribute byte. (Mostly SMBus and
138 * GenericSerialBus stuff.)
140 ******************************************************************************/
143 AcpiDmDecodeAttribute (
149 case AML_FIELD_ATTRIB_QUICK:
151 AcpiOsPrintf ("AttribQuick");
154 case AML_FIELD_ATTRIB_SEND_RCV:
156 AcpiOsPrintf ("AttribSendReceive");
159 case AML_FIELD_ATTRIB_BYTE:
161 AcpiOsPrintf ("AttribByte");
164 case AML_FIELD_ATTRIB_WORD:
166 AcpiOsPrintf ("AttribWord");
169 case AML_FIELD_ATTRIB_BLOCK:
171 AcpiOsPrintf ("AttribBlock");
174 case AML_FIELD_ATTRIB_MULTIBYTE:
176 AcpiOsPrintf ("AttribBytes");
179 case AML_FIELD_ATTRIB_WORD_CALL:
181 AcpiOsPrintf ("AttribProcessCall");
184 case AML_FIELD_ATTRIB_BLOCK_CALL:
186 AcpiOsPrintf ("AttribBlockProcessCall");
189 case AML_FIELD_ATTRIB_RAW_BYTES:
191 AcpiOsPrintf ("AttribRawBytes");
194 case AML_FIELD_ATTRIB_RAW_PROCESS:
196 AcpiOsPrintf ("AttribRawProcessBytes");
201 /* A ByteConst is allowed by the grammar */
203 AcpiOsPrintf ("0x%2.2X", Attribute);
209 /*******************************************************************************
211 * FUNCTION: AcpiDmIndent
213 * PARAMETERS: Level - Current source code indentation level
217 * DESCRIPTION: Indent 4 spaces per indentation level.
219 ******************************************************************************/
231 AcpiOsPrintf ("%*.s", ACPI_MUL_4 (Level), " ");
235 /*******************************************************************************
237 * FUNCTION: AcpiDmCommaIfListMember
239 * PARAMETERS: Op - Current operator/operand
241 * RETURN: TRUE if a comma was inserted
243 * DESCRIPTION: Insert a comma if this Op is a member of an argument list.
245 ******************************************************************************/
248 AcpiDmCommaIfListMember (
249 ACPI_PARSE_OBJECT *Op)
252 if (!Op->Common.Next)
257 if (AcpiDmListType (Op->Common.Parent) & BLOCK_COMMA_LIST)
259 /* Exit if Target has been marked IGNORE */
261 if (Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_IGNORE)
266 /* Check for a NULL target operand */
268 if ((Op->Common.Next->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
269 (!Op->Common.Next->Common.Value.String))
272 * To handle the Divide() case where there are two optional
273 * targets, look ahead one more op. If null, this null target
274 * is the one and only target -- no comma needed. Otherwise,
275 * we need a comma to prepare for the next target.
277 if (!Op->Common.Next->Common.Next)
283 if ((Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST) &&
284 (!(Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)))
289 /* Emit comma only if this is not a C-style operator */
291 if (!Op->Common.OperatorSymbol)
299 else if ((Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST) &&
300 (Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST))
310 /*******************************************************************************
312 * FUNCTION: AcpiDmCommaIfFieldMember
314 * PARAMETERS: Op - Current operator/operand
318 * DESCRIPTION: Insert a comma if this Op is a member of a Field argument list.
320 ******************************************************************************/
323 AcpiDmCommaIfFieldMember (
324 ACPI_PARSE_OBJECT *Op)