1 /*******************************************************************************
3 * Module Name: dmwalk - AML disassembly tree walk
5 ******************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2020, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
150 *****************************************************************************/
153 #include "accommon.h"
154 #include "acparser.h"
157 #include "acconvert.h"
160 #ifdef ACPI_DISASSEMBLER
162 #define _COMPONENT ACPI_CA_DEBUGGER
163 ACPI_MODULE_NAME ("dmwalk")
166 /* Stub for non-compiler code */
168 #ifndef ACPI_ASL_COMPILER
170 AcpiDmEmitExternals (
178 ACPI_PARSE_OBJECT *NameOp,
179 ACPI_PARSE_OBJECT *TypeOp)
185 /* Local prototypes */
189 ACPI_PARSE_OBJECT *Op,
195 ACPI_PARSE_OBJECT *Op,
200 /*******************************************************************************
202 * FUNCTION: AcpiDmDisassemble
204 * PARAMETERS: WalkState - Current state
205 * Origin - Starting object
206 * NumOpcodes - Max number of opcodes to be displayed
210 * DESCRIPTION: Disassemble parser object and its children. This is the
211 * main entry point of the disassembler.
213 ******************************************************************************/
217 ACPI_WALK_STATE *WalkState,
218 ACPI_PARSE_OBJECT *Origin,
221 ACPI_PARSE_OBJECT *Op = Origin;
222 ACPI_OP_WALK_INFO Info;
230 memset (&Info, 0, sizeof (ACPI_OP_WALK_INFO));
231 Info.WalkState = WalkState;
232 Info.StartAml = Op->Common.Aml - sizeof (ACPI_TABLE_HEADER);
233 Info.AmlOffset = Op->Common.Aml - Info.StartAml;
235 AcpiDmWalkParseTree (Op, AcpiDmDescendingOp, AcpiDmAscendingOp, &Info);
240 /*******************************************************************************
242 * FUNCTION: AcpiDmWalkParseTree
244 * PARAMETERS: Op - Root Op object
245 * DescendingCallback - Called during tree descent
246 * AscendingCallback - Called during tree ascent
247 * Context - To be passed to the callbacks
249 * RETURN: Status from callback(s)
251 * DESCRIPTION: Walk the entire parse tree.
253 ******************************************************************************/
256 AcpiDmWalkParseTree (
257 ACPI_PARSE_OBJECT *Op,
258 ASL_WALK_CALLBACK DescendingCallback,
259 ASL_WALK_CALLBACK AscendingCallback,
262 BOOLEAN NodePreviouslyVisited;
263 ACPI_PARSE_OBJECT *StartOp = Op;
265 ACPI_PARSE_OBJECT *Next;
266 ACPI_OP_WALK_INFO *Info = Context;
270 NodePreviouslyVisited = FALSE;
274 if (NodePreviouslyVisited)
276 if (AscendingCallback)
278 Status = AscendingCallback (Op, Info->Level, Context);
279 if (ACPI_FAILURE (Status))
287 /* Let the callback process the node */
289 Status = DescendingCallback (Op, Info->Level, Context);
290 if (ACPI_SUCCESS (Status))
292 /* Visit children first, once */
294 Next = AcpiPsGetArg (Op, 0);
302 else if (Status != AE_CTRL_DEPTH)
304 /* Exit immediately on any error */
310 /* Terminate walk at start op */
317 /* No more children, re-visit this node */
319 if (!NodePreviouslyVisited)
321 NodePreviouslyVisited = TRUE;
325 /* No more children, visit peers */
329 Op = Op->Common.Next;
330 NodePreviouslyVisited = FALSE;
334 /* No peers, re-visit parent */
336 if (Info->Level != 0 )
341 Op = Op->Common.Parent;
342 NodePreviouslyVisited = TRUE;
346 /* If we get here, the walk completed with no errors */
352 /*******************************************************************************
354 * FUNCTION: AcpiDmBlockType
356 * PARAMETERS: Op - Object to be examined
358 * RETURN: BlockType - not a block, parens, braces, or even both.
360 * DESCRIPTION: Type of block for this op (parens or braces)
362 ******************************************************************************/
366 ACPI_PARSE_OBJECT *Op)
368 const ACPI_OPCODE_INFO *OpInfo;
376 switch (Op->Common.AmlOpcode)
380 return (BLOCK_BRACE);
385 case AML_PROCESSOR_OP:
386 case AML_POWER_RESOURCE_OP:
387 case AML_THERMAL_ZONE_OP:
391 case AML_INDEX_FIELD_OP:
392 case AML_BANK_FIELD_OP:
394 return (BLOCK_PAREN | BLOCK_BRACE);
398 if ((Op->Common.DisasmOpcode == ACPI_DASM_UNICODE) ||
399 (Op->Common.DisasmOpcode == ACPI_DASM_UUID) ||
400 (Op->Common.DisasmOpcode == ACPI_DASM_PLD_METHOD))
405 /*lint -fallthrough */
408 case AML_VARIABLE_PACKAGE_OP:
410 return (BLOCK_PAREN | BLOCK_BRACE);
414 return (BLOCK_PAREN);
416 case AML_INT_METHODCALL_OP:
418 if (Op->Common.Parent &&
419 ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
420 (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP)))
422 /* This is a reference to a method, not an invocation */
427 /*lint -fallthrough */
431 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
432 if (OpInfo->Flags & AML_HAS_ARGS)
434 return (BLOCK_PAREN);
442 /*******************************************************************************
444 * FUNCTION: AcpiDmListType
446 * PARAMETERS: Op - Object to be examined
448 * RETURN: ListType - has commas or not.
450 * DESCRIPTION: Type of block for this op (parens or braces)
452 ******************************************************************************/
456 ACPI_PARSE_OBJECT *Op)
458 const ACPI_OPCODE_INFO *OpInfo;
466 switch (Op->Common.AmlOpcode)
473 case AML_POWER_RESOURCE_OP:
474 case AML_PROCESSOR_OP:
475 case AML_THERMAL_ZONE_OP:
479 case AML_INDEX_FIELD_OP:
480 case AML_BANK_FIELD_OP:
486 case AML_VARIABLE_PACKAGE_OP:
488 return (BLOCK_COMMA_LIST);
492 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
493 if (OpInfo->Flags & AML_HAS_ARGS)
495 return (BLOCK_COMMA_LIST);
503 /*******************************************************************************
505 * FUNCTION: AcpiDmDescendingOp
507 * PARAMETERS: ASL_WALK_CALLBACK
511 * DESCRIPTION: First visitation of a parse object during tree descent.
512 * Decode opcode name and begin parameter list(s), if any.
514 ******************************************************************************/
518 ACPI_PARSE_OBJECT *Op,
522 ACPI_OP_WALK_INFO *Info = Context;
523 const ACPI_OPCODE_INFO *OpInfo;
525 ACPI_PARSE_OBJECT *NextOp;
526 ACPI_PARSE_OBJECT *NextOp2;
530 /* Determine which file this parse node is contained in. */
532 if (AcpiGbl_CaptureComments)
534 ASL_CV_LABEL_FILENODE (Op);
536 if (Level != 0 && ASL_CV_FILE_HAS_SWITCHED (Op))
538 ASL_CV_SWITCH_FILES (Level, Op);
541 /* If this parse node has regular comments, print them here. */
543 ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_STANDARD, NULL, Level);
546 OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
548 /* Listing support to dump the AML code after the ASL statement */
550 if (AcpiGbl_DmOpt_Listing)
552 /* We only care about these classes of objects */
554 if ((OpInfo->Class == AML_CLASS_NAMED_OBJECT) ||
555 (OpInfo->Class == AML_CLASS_CONTROL) ||
556 (OpInfo->Class == AML_CLASS_CREATE) ||
557 ((OpInfo->Class == AML_CLASS_EXECUTE) && (!Op->Common.Next)))
559 if (AcpiGbl_DmOpt_Listing && Info->PreviousAml)
561 /* Dump the AML byte code for the previous Op */
563 if (Op->Common.Aml > Info->PreviousAml)
567 (Info->StartAml + Info->AmlOffset),
568 (Op->Common.Aml - Info->PreviousAml),
569 DB_BYTE_DISPLAY, Info->AmlOffset);
573 Info->AmlOffset = (Op->Common.Aml - Info->StartAml);
576 Info->PreviousAml = Op->Common.Aml;
580 if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE)
582 /* Ignore this op -- it was handled elsewhere */
584 return (AE_CTRL_DEPTH);
587 if (Op->Common.DisasmOpcode == ACPI_DASM_IGNORE_SINGLE)
589 /* Ignore this op, but not it's children */
594 if (Op->Common.AmlOpcode == AML_IF_OP)
596 NextOp = AcpiPsGetDepthNext (NULL, Op);
599 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
601 /* Don't emit the actual embedded externals unless asked */
603 if (!AcpiGbl_DmEmitExternalOpcodes)
606 * A Zero predicate indicates the possibility of one or more
607 * External() opcodes within the If() block.
609 if (NextOp->Common.AmlOpcode == AML_ZERO_OP)
611 NextOp2 = NextOp->Common.Next;
614 (NextOp2->Common.AmlOpcode == AML_EXTERNAL_OP))
616 /* Ignore the If 0 block and all children */
618 Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
619 return (AE_CTRL_DEPTH);
626 /* Level 0 is at the Definition Block level */
630 /* In verbose mode, print the AML offset, opcode and depth count */
634 AmlOffset = (UINT32) ACPI_PTR_DIFF (Op->Common.Aml,
635 Info->WalkState->ParserState.AmlStart);
636 if (AcpiGbl_DmOpt_Verbose)
638 if (AcpiGbl_CmSingleStep)
640 AcpiOsPrintf ("%5.5X/%4.4X: ",
641 AmlOffset, (UINT32) Op->Common.AmlOpcode);
645 AcpiOsPrintf ("AML Offset %5.5X, Opcode %4.4X: ",
646 AmlOffset, (UINT32) Op->Common.AmlOpcode);
651 if (Op->Common.AmlOpcode == AML_SCOPE_OP)
653 /* This is the beginning of the Definition Block */
655 AcpiOsPrintf ("{\n");
657 /* Emit all External() declarations here */
659 if (!AcpiGbl_DmEmitExternalOpcodes)
661 AcpiDmEmitExternals ();
667 else if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
668 (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)) &&
669 (!(Op->Common.DisasmFlags & ACPI_PARSEOP_ELSEIF)) &&
670 (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))
673 * This is a first-level element of a term list,
676 switch (Op->Common.AmlOpcode)
680 * Optionally just ignore this opcode. Some tables use
681 * NoOp opcodes for "padding" out packages that the BIOS
682 * changes dynamically. This can leave hundreds or
683 * thousands of NoOp opcodes that if disassembled,
684 * cannot be compiled because they are syntactically
687 if (AcpiGbl_IgnoreNoopOperator)
689 Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
697 AcpiDmIndent (Level);
701 Info->LastLevel = Level;
706 * This is an inexpensive mechanism to try and keep lines from getting
707 * too long. When the limit is hit, start a new line at the previous
708 * indent plus one. A better but more expensive mechanism would be to
709 * keep track of the current column.
712 if (Info->Count /* +Info->LastLevel */ > 12)
716 AcpiDmIndent (Info->LastLevel + 1);
719 /* If ASL+ is enabled, check for a C-style operator */
721 if (AcpiDmCheckForSymbolicOpcode (Op, Info))
726 /* Print the opcode name */
728 AcpiDmDisassembleOneOp (NULL, Info, Op);
730 if ((Op->Common.DisasmOpcode == ACPI_DASM_LNOT_PREFIX) ||
731 (Op->Common.AmlOpcode == AML_INT_CONNECTION_OP))
736 if ((Op->Common.AmlOpcode == AML_NAME_OP) ||
737 (Op->Common.AmlOpcode == AML_RETURN_OP))
742 if (Op->Common.AmlOpcode == AML_EXTERNAL_OP)
744 Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
745 return (AE_CTRL_DEPTH);
748 /* Start the opcode argument list if necessary */
750 if ((OpInfo->Flags & AML_HAS_ARGS) ||
751 (Op->Common.AmlOpcode == AML_EVENT_OP))
753 /* This opcode has an argument list */
755 if (AcpiDmBlockType (Op) & BLOCK_PAREN)
758 if (!(AcpiDmBlockType (Op) & BLOCK_BRACE))
760 ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, " ", 0);
764 /* If this is a named opcode, print the associated name value */
766 if (OpInfo->Flags & AML_NAMED)
768 switch (Op->Common.AmlOpcode)
772 NextOp = AcpiPsGetDepthNext (NULL, Op);
773 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
774 AcpiDmNamestring (NextOp->Common.Value.Name);
777 /*lint -fallthrough */
781 Name = AcpiPsGetName (Op);
784 AcpiDmNamestring (Op->Named.Path);
788 AcpiDmDumpName (Name);
791 if (Op->Common.AmlOpcode != AML_INT_NAMEDFIELD_OP)
793 if (AcpiGbl_DmOpt_Verbose)
795 (void) AcpiPsDisplayObjectPathname (NULL, Op);
801 switch (Op->Common.AmlOpcode)
805 AcpiDmMethodFlags (Op);
806 ASL_CV_CLOSE_PAREN (Op, Level);
808 /* Emit description comment for Method() with a predefined ACPI name */
810 AcpiDmPredefinedDescription (Op);
815 /* Check for _HID and related EISAID() */
817 AcpiDmCheckForHardwareId (Op);
819 ASL_CV_PRINT_ONE_COMMENT (Op, AML_NAMECOMMENT, NULL, 0);
824 AcpiDmRegionFlags (Op);
827 case AML_POWER_RESOURCE_OP:
829 /* Mark the next two Ops as part of the parameter list */
832 NextOp = AcpiPsGetDepthNext (NULL, Op);
833 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
835 NextOp = NextOp->Common.Next;
836 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
839 case AML_PROCESSOR_OP:
841 /* Mark the next three Ops as part of the parameter list */
844 NextOp = AcpiPsGetDepthNext (NULL, Op);
845 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
847 NextOp = NextOp->Common.Next;
848 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
850 NextOp = NextOp->Common.Next;
851 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
855 case AML_DATA_REGION_OP:
867 case AML_THERMAL_ZONE_OP:
869 ASL_CV_CLOSE_PAREN (Op, Level);
874 AcpiOsPrintf ("*** Unhandled named opcode %X\n",
875 Op->Common.AmlOpcode);
880 else switch (Op->Common.AmlOpcode)
883 case AML_BANK_FIELD_OP:
884 case AML_INDEX_FIELD_OP:
888 /* Name of the parent OperationRegion */
890 NextOp = AcpiPsGetDepthNext (NULL, Op);
891 AcpiDmNamestring (NextOp->Common.Value.Name);
893 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
895 switch (Op->Common.AmlOpcode)
897 case AML_BANK_FIELD_OP:
899 /* Namestring - Bank Name */
901 NextOp = AcpiPsGetDepthNext (NULL, NextOp);
902 AcpiDmNamestring (NextOp->Common.Value.Name);
903 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
907 * Bank Value. This is a TermArg in the middle of the parameter
908 * list, must handle it here.
910 * Disassemble the TermArg parse tree. ACPI_PARSEOP_PARAMETER_LIST
911 * eliminates newline in the output.
913 NextOp = NextOp->Common.Next;
915 Info->Flags = ACPI_PARSEOP_PARAMETER_LIST;
916 AcpiDmWalkParseTree (NextOp, AcpiDmDescendingOp,
917 AcpiDmAscendingOp, Info);
921 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
925 case AML_INDEX_FIELD_OP:
927 /* Namestring - Data Name */
929 NextOp = AcpiPsGetDepthNext (NULL, NextOp);
930 AcpiDmNamestring (NextOp->Common.Value.Name);
932 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
940 AcpiDmFieldFlags (NextOp);
945 /* The next op is the size parameter */
947 NextOp = AcpiPsGetDepthNext (NULL, Op);
950 /* Single-step support */
955 if (Op->Common.DisasmOpcode == ACPI_DASM_RESOURCE)
958 * We have a resource list. Don't need to output
959 * the buffer size Op. Open up a new block
961 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
962 ASL_CV_CLOSE_PAREN (Op, Level);
964 /* Emit description comment for Name() with a predefined ACPI name */
966 AcpiDmPredefinedDescription (Op->Asl.Parent);
969 AcpiDmIndent (Info->Level);
970 AcpiOsPrintf ("{\n");
974 /* Normal Buffer, mark size as in the parameter list */
976 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
980 case AML_VARIABLE_PACKAGE_OP:
983 /* The next op is the size or predicate parameter */
985 NextOp = AcpiPsGetDepthNext (NULL, Op);
988 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
994 /* The next op is the size parameter */
996 NextOp = AcpiPsGetDepthNext (NULL, Op);
999 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
1013 if (AcpiDmBlockType (Op) & BLOCK_BRACE)
1015 AcpiOsPrintf ("\n");
1016 AcpiDmIndent (Level);
1017 AcpiOsPrintf ("{\n");
1025 /*******************************************************************************
1027 * FUNCTION: AcpiDmAscendingOp
1029 * PARAMETERS: ASL_WALK_CALLBACK
1033 * DESCRIPTION: Second visitation of a parse object, during ascent of parse
1034 * tree. Close out any parameter lists and complete the opcode.
1036 ******************************************************************************/
1040 ACPI_PARSE_OBJECT *Op,
1044 ACPI_OP_WALK_INFO *Info = Context;
1045 ACPI_PARSE_OBJECT *ParentOp;
1048 /* Point the Op's filename pointer to the proper file */
1050 if (AcpiGbl_CaptureComments)
1052 ASL_CV_LABEL_FILENODE (Op);
1054 /* Switch the output of these files if necessary */
1056 if (ASL_CV_FILE_HAS_SWITCHED (Op))
1058 ASL_CV_SWITCH_FILES (Level, Op);
1062 if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE ||
1063 Op->Common.DisasmOpcode == ACPI_DASM_IGNORE_SINGLE)
1065 /* Ignore this op -- it was handled elsewhere */
1070 if ((Level == 0) && (Op->Common.AmlOpcode == AML_SCOPE_OP))
1072 /* Indicates the end of the current descriptor block (table) */
1074 ASL_CV_CLOSE_BRACE (Op, Level);
1076 /* Print any comments that are at the end of the file here */
1078 if (AcpiGbl_CaptureComments && AcpiGbl_LastListHead)
1080 AcpiOsPrintf ("\n");
1081 ASL_CV_PRINT_ONE_COMMENT_LIST (AcpiGbl_LastListHead, 0);
1083 AcpiOsPrintf ("\n\n");
1088 switch (AcpiDmBlockType (Op))
1092 /* Completed an op that has arguments, add closing paren if needed */
1094 AcpiDmCloseOperator (Op);
1096 if (Op->Common.AmlOpcode == AML_NAME_OP)
1098 /* Emit description comment for Name() with a predefined ACPI name */
1100 AcpiDmPredefinedDescription (Op);
1104 /* For Create* operators, attempt to emit resource tag description */
1106 AcpiDmFieldPredefinedDescription (Op);
1109 /* Decode Notify() values */
1111 if (Op->Common.AmlOpcode == AML_NOTIFY_OP)
1113 AcpiDmNotifyDescription (Op);
1116 AcpiDmDisplayTargetPathname (Op);
1118 /* Could be a nested operator, check if comma required */
1120 if (!AcpiDmCommaIfListMember (Op))
1122 if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
1123 (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)) &&
1124 (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))
1127 * This is a first-level element of a term list
1130 if (!(Info->Flags & ACPI_PARSEOP_PARAMETER_LIST))
1132 AcpiOsPrintf ("\n");
1139 case (BLOCK_BRACE | BLOCK_PAREN):
1141 /* Completed an op that has a term list, add closing brace */
1143 if (Op->Common.DisasmFlags & ACPI_PARSEOP_EMPTY_TERMLIST)
1145 ASL_CV_CLOSE_BRACE (Op, Level);
1149 AcpiDmIndent (Level);
1150 ASL_CV_CLOSE_BRACE (Op, Level);
1153 AcpiDmCommaIfListMember (Op);
1155 if (AcpiDmBlockType (Op->Common.Parent) != BLOCK_PAREN)
1157 AcpiOsPrintf ("\n");
1158 if (!(Op->Common.DisasmFlags & ACPI_PARSEOP_EMPTY_TERMLIST))
1160 if ((Op->Common.AmlOpcode == AML_IF_OP) &&
1161 (Op->Common.Next) &&
1162 (Op->Common.Next->Common.AmlOpcode == AML_ELSE_OP))
1167 if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
1172 AcpiOsPrintf ("\n");
1180 /* Could be a nested operator, check if comma required */
1182 if (!AcpiDmCommaIfListMember (Op))
1184 if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
1185 (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)) &&
1186 (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))
1189 * This is a first-level element of a term list
1192 AcpiOsPrintf ("\n");
1195 else if (Op->Common.Parent)
1197 switch (Op->Common.Parent->Common.AmlOpcode)
1199 case AML_PACKAGE_OP:
1200 case AML_VARIABLE_PACKAGE_OP:
1202 if (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST))
1204 AcpiOsPrintf ("\n");
1216 if (Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)
1218 if ((Op->Common.Next) &&
1219 (Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST))
1225 * The parent Op is guaranteed to be valid because of the flag
1226 * ACPI_PARSEOP_PARAMETER_LIST -- which means that this op is part of
1227 * a parameter list and thus has a valid parent.
1229 ParentOp = Op->Common.Parent;
1232 * Just completed a parameter node for something like "Buffer (param)".
1233 * Close the paren and open up the term list block with a brace.
1235 * Switch predicates don't have a Next node but require a closing paren
1236 * and opening brace.
1238 if (Op->Common.Next || Op->Common.DisasmOpcode == ACPI_DASM_SWITCH_PREDICATE)
1240 ASL_CV_CLOSE_PAREN (Op, Level);
1243 * Emit a description comment for a Name() operator that is a
1244 * predefined ACPI name. Must check the grandparent.
1246 ParentOp = ParentOp->Common.Parent;
1248 (ParentOp->Asl.AmlOpcode == AML_NAME_OP))
1250 AcpiDmPredefinedDescription (ParentOp);
1253 /* Correct the indentation level for Switch and Case predicates */
1255 if (Op->Common.DisasmOpcode == ACPI_DASM_SWITCH_PREDICATE)
1260 AcpiOsPrintf ("\n");
1261 AcpiDmIndent (Level - 1);
1262 AcpiOsPrintf ("{\n");
1266 ParentOp->Common.DisasmFlags |= ACPI_PARSEOP_EMPTY_TERMLIST;
1267 ASL_CV_CLOSE_PAREN (Op, Level);
1272 if ((Op->Common.AmlOpcode == AML_NAME_OP) ||
1273 (Op->Common.AmlOpcode == AML_RETURN_OP))
1279 * For ASL+, check for and emit a C-style symbol. If valid, the
1280 * symbol string has been deferred until after the first operand
1282 if (AcpiGbl_CstyleDisassembly)
1284 if (Op->Asl.OperatorSymbol)
1286 AcpiOsPrintf ("%s", Op->Asl.OperatorSymbol);
1287 Op->Asl.OperatorSymbol = NULL;
1294 #endif /* ACPI_DISASSEMBLER */