1 /*******************************************************************************
3 * Module Name: dmopcode - AML disassembler, specific AML opcodes
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.
44 #include <contrib/dev/acpica/include/acpi.h>
45 #include <contrib/dev/acpica/include/accommon.h>
46 #include <contrib/dev/acpica/include/acparser.h>
47 #include <contrib/dev/acpica/include/amlcode.h>
48 #include <contrib/dev/acpica/include/acdisasm.h>
50 #ifdef ACPI_DISASSEMBLER
52 #define _COMPONENT ACPI_CA_DEBUGGER
53 ACPI_MODULE_NAME ("dmopcode")
55 /* Local prototypes */
59 ACPI_PARSE_OBJECT *Op);
62 /*******************************************************************************
64 * FUNCTION: AcpiDmMethodFlags
66 * PARAMETERS: Op - Method Object to be examined
70 * DESCRIPTION: Decode control method flags
72 ******************************************************************************/
76 ACPI_PARSE_OBJECT *Op)
82 /* The next Op contains the flags */
84 Op = AcpiPsGetDepthNext (NULL, Op);
85 Flags = (UINT8) Op->Common.Value.Integer;
88 /* Mark the Op as completed */
90 Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
92 /* 1) Method argument count */
94 AcpiOsPrintf (", %u, ", Args);
96 /* 2) Serialize rule */
100 AcpiOsPrintf ("Not");
103 AcpiOsPrintf ("Serialized");
109 AcpiOsPrintf (", %u", Flags >> 4);
114 /*******************************************************************************
116 * FUNCTION: AcpiDmFieldFlags
118 * PARAMETERS: Op - Field Object to be examined
122 * DESCRIPTION: Decode Field definition flags
124 ******************************************************************************/
128 ACPI_PARSE_OBJECT *Op)
133 Op = Op->Common.Next;
134 Flags = (UINT8) Op->Common.Value.Integer;
136 /* Mark the Op as completed */
138 Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
140 AcpiOsPrintf ("%s, ", AcpiGbl_AccessTypes [Flags & 0x07]);
141 AcpiOsPrintf ("%s, ", AcpiGbl_LockRule [(Flags & 0x10) >> 4]);
142 AcpiOsPrintf ("%s)", AcpiGbl_UpdateRules [(Flags & 0x60) >> 5]);
146 /*******************************************************************************
148 * FUNCTION: AcpiDmAddressSpace
150 * PARAMETERS: SpaceId - ID to be translated
154 * DESCRIPTION: Decode a SpaceId to an AddressSpaceKeyword
156 ******************************************************************************/
163 if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS)
167 AcpiOsPrintf ("FFixedHW, ");
171 AcpiOsPrintf ("0x%.2X, ", SpaceId);
176 AcpiOsPrintf ("%s, ", AcpiGbl_RegionTypes [SpaceId]);
181 /*******************************************************************************
183 * FUNCTION: AcpiDmRegionFlags
185 * PARAMETERS: Op - Object to be examined
189 * DESCRIPTION: Decode OperationRegion flags
191 ******************************************************************************/
195 ACPI_PARSE_OBJECT *Op)
199 /* The next Op contains the SpaceId */
201 Op = AcpiPsGetDepthNext (NULL, Op);
203 /* Mark the Op as completed */
205 Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
208 AcpiDmAddressSpace ((UINT8) Op->Common.Value.Integer);
212 /*******************************************************************************
214 * FUNCTION: AcpiDmMatchOp
216 * PARAMETERS: Op - Match Object to be examined
220 * DESCRIPTION: Decode Match opcode operands
222 ******************************************************************************/
226 ACPI_PARSE_OBJECT *Op)
228 ACPI_PARSE_OBJECT *NextOp;
231 NextOp = AcpiPsGetDepthNext (NULL, Op);
232 NextOp = NextOp->Common.Next;
236 /* Handle partial tree during single-step */
241 /* Mark the two nodes that contain the encoding for the match keywords */
243 NextOp->Common.DisasmOpcode = ACPI_DASM_MATCHOP;
245 NextOp = NextOp->Common.Next;
246 NextOp = NextOp->Common.Next;
247 NextOp->Common.DisasmOpcode = ACPI_DASM_MATCHOP;
251 /*******************************************************************************
253 * FUNCTION: AcpiDmMatchKeyword
255 * PARAMETERS: Op - Match Object to be examined
259 * DESCRIPTION: Decode Match opcode operands
261 ******************************************************************************/
265 ACPI_PARSE_OBJECT *Op)
269 if (((UINT32) Op->Common.Value.Integer) > ACPI_MAX_MATCH_OPCODE)
271 AcpiOsPrintf ("/* Unknown Match Keyword encoding */");
275 AcpiOsPrintf ("%s", ACPI_CAST_PTR (char,
276 AcpiGbl_MatchOps[(ACPI_SIZE) Op->Common.Value.Integer]));
281 /*******************************************************************************
283 * FUNCTION: AcpiDmDisassembleOneOp
285 * PARAMETERS: WalkState - Current walk info
286 * Info - Parse tree walk info
287 * Op - Op that is to be printed
291 * DESCRIPTION: Disassemble a single AML opcode
293 ******************************************************************************/
296 AcpiDmDisassembleOneOp (
297 ACPI_WALK_STATE *WalkState,
298 ACPI_OP_WALK_INFO *Info,
299 ACPI_PARSE_OBJECT *Op)
301 const ACPI_OPCODE_INFO *OpInfo = NULL;
304 ACPI_PARSE_OBJECT *Child;
310 AcpiOsPrintf ("<NULL OP PTR>");
314 switch (Op->Common.DisasmOpcode)
316 case ACPI_DASM_MATCHOP:
318 AcpiDmMatchKeyword (Op);
321 case ACPI_DASM_LNOT_SUFFIX:
322 switch (Op->Common.AmlOpcode)
325 AcpiOsPrintf ("LNotEqual");
328 case AML_LGREATER_OP:
329 AcpiOsPrintf ("LLessEqual");
333 AcpiOsPrintf ("LGreaterEqual");
339 Op->Common.DisasmOpcode = 0;
340 Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
348 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
350 /* The op and arguments */
352 switch (Op->Common.AmlOpcode)
356 Child = Op->Common.Value.Arg;
357 if ((Child->Common.AmlOpcode == AML_LEQUAL_OP) ||
358 (Child->Common.AmlOpcode == AML_LGREATER_OP) ||
359 (Child->Common.AmlOpcode == AML_LLESS_OP))
361 Child->Common.DisasmOpcode = ACPI_DASM_LNOT_SUFFIX;
362 Op->Common.DisasmOpcode = ACPI_DASM_LNOT_PREFIX;
366 AcpiOsPrintf ("%s", OpInfo->Name);
372 AcpiOsPrintf ("0x%2.2X", (UINT32) Op->Common.Value.Integer);
378 if (Op->Common.DisasmOpcode == ACPI_DASM_EISAID)
380 AcpiDmEisaId ((UINT32) Op->Common.Value.Integer);
384 AcpiOsPrintf ("0x%4.4X", (UINT32) Op->Common.Value.Integer);
391 if (Op->Common.DisasmOpcode == ACPI_DASM_EISAID)
393 AcpiDmEisaId ((UINT32) Op->Common.Value.Integer);
397 AcpiOsPrintf ("0x%8.8X", (UINT32) Op->Common.Value.Integer);
404 AcpiOsPrintf ("0x%8.8X%8.8X",
405 ACPI_FORMAT_UINT64 (Op->Common.Value.Integer));
411 AcpiUtPrintString (Op->Common.Value.String, ACPI_UINT8_MAX);
418 * Determine the type of buffer. We can have one of the following:
420 * 1) ResourceTemplate containing Resource Descriptors.
421 * 2) Unicode String buffer
422 * 3) ASCII String buffer
423 * 4) Raw data buffer (if none of the above)
425 * Since there are no special AML opcodes to differentiate these
426 * types of buffers, we have to closely look at the data in the
427 * buffer to determine the type.
429 Status = AcpiDmIsResourceTemplate (Op);
430 if (ACPI_SUCCESS (Status))
432 Op->Common.DisasmOpcode = ACPI_DASM_RESOURCE;
433 AcpiOsPrintf ("ResourceTemplate");
436 else if (Status == AE_AML_NO_RESOURCE_END_TAG)
438 AcpiOsPrintf ("/**** Is ResourceTemplate, but EndTag not at buffer end ****/ ");
441 if (AcpiDmIsUnicodeBuffer (Op))
443 Op->Common.DisasmOpcode = ACPI_DASM_UNICODE;
444 AcpiOsPrintf ("Unicode (");
446 else if (AcpiDmIsStringBuffer (Op))
448 Op->Common.DisasmOpcode = ACPI_DASM_STRING;
449 AcpiOsPrintf ("Buffer");
453 Op->Common.DisasmOpcode = ACPI_DASM_BUFFER;
454 AcpiOsPrintf ("Buffer");
459 case AML_INT_STATICSTRING_OP:
461 if (Op->Common.Value.String)
463 AcpiOsPrintf ("%s", Op->Common.Value.String);
467 AcpiOsPrintf ("\"<NULL STATIC STRING PTR>\"");
472 case AML_INT_NAMEPATH_OP:
474 AcpiDmNamestring (Op->Common.Value.Name);
478 case AML_INT_NAMEDFIELD_OP:
480 Length = AcpiDmDumpName (Op->Named.Name);
481 AcpiOsPrintf (",%*.s %u", (unsigned) (5 - Length), " ",
482 (UINT32) Op->Common.Value.Integer);
483 AcpiDmCommaIfFieldMember (Op);
485 Info->BitOffset += (UINT32) Op->Common.Value.Integer;
489 case AML_INT_RESERVEDFIELD_OP:
491 /* Offset() -- Must account for previous offsets */
493 Offset = (UINT32) Op->Common.Value.Integer;
494 Info->BitOffset += Offset;
496 if (Info->BitOffset % 8 == 0)
498 AcpiOsPrintf (" Offset (0x%.2X)", ACPI_DIV_8 (Info->BitOffset));
502 AcpiOsPrintf (" , %u", Offset);
505 AcpiDmCommaIfFieldMember (Op);
509 case AML_INT_ACCESSFIELD_OP:
511 AcpiOsPrintf (" AccessAs (%s, ",
512 AcpiGbl_AccessTypes [(UINT32) (Op->Common.Value.Integer >> 8) & 0x7]);
514 AcpiDmDecodeAttribute ((UINT8) Op->Common.Value.Integer);
516 AcpiDmCommaIfFieldMember (Op);
520 case AML_INT_BYTELIST_OP:
522 AcpiDmByteList (Info, Op);
526 case AML_INT_METHODCALL_OP:
528 Op = AcpiPsGetDepthNext (NULL, Op);
529 Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
531 AcpiDmNamestring (Op->Common.Value.Name);
537 /* Just get the opcode name and print it */
539 AcpiOsPrintf ("%s", OpInfo->Name);
544 if ((Op->Common.AmlOpcode == AML_INT_RETURN_VALUE_OP) &&
546 (WalkState->Results) &&
547 (WalkState->ResultCount))
549 AcpiDmDecodeInternalObject (
550 WalkState->Results->Results.ObjDesc [
551 (WalkState->ResultCount - 1) %
552 ACPI_RESULTS_FRAME_OBJ_NUM]);
560 #endif /* ACPI_DISASSEMBLER */