1 /*******************************************************************************
3 * Module Name: dmwalk - AML disassembly tree walk
5 ******************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2017, 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 *****************************************************************************/
152 #include <contrib/dev/acpica/include/acpi.h>
153 #include <contrib/dev/acpica/include/accommon.h>
154 #include <contrib/dev/acpica/include/acparser.h>
155 #include <contrib/dev/acpica/include/amlcode.h>
156 #include <contrib/dev/acpica/include/acdebug.h>
157 #include <contrib/dev/acpica/include/acconvert.h>
160 #define _COMPONENT ACPI_CA_DEBUGGER
161 ACPI_MODULE_NAME ("dmwalk")
164 #define DB_FULL_OP_INFO "[%4.4s] @%5.5X #%4.4X: "
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 (Gbl_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 (AcpiDmIsTempName(Op))
589 /* Ignore compiler generated temporary names */
591 return (AE_CTRL_DEPTH);
594 if (Op->Common.DisasmOpcode == ACPI_DASM_IGNORE_SINGLE)
596 /* Ignore this op, but not it's children */
601 if (Op->Common.AmlOpcode == AML_IF_OP)
603 NextOp = AcpiPsGetDepthNext (NULL, Op);
606 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
608 /* Don't emit the actual embedded externals unless asked */
610 if (!AcpiGbl_DmEmitExternalOpcodes)
613 * A Zero predicate indicates the possibility of one or more
614 * External() opcodes within the If() block.
616 if (NextOp->Common.AmlOpcode == AML_ZERO_OP)
618 NextOp2 = NextOp->Common.Next;
621 (NextOp2->Common.AmlOpcode == AML_EXTERNAL_OP))
623 /* Ignore the If 0 block and all children */
625 Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
626 return (AE_CTRL_DEPTH);
633 /* Level 0 is at the Definition Block level */
637 /* In verbose mode, print the AML offset, opcode and depth count */
641 AmlOffset = (UINT32) ACPI_PTR_DIFF (Op->Common.Aml,
642 Info->WalkState->ParserState.AmlStart);
643 if (AcpiGbl_DmOpt_Verbose)
645 AcpiOsPrintf (DB_FULL_OP_INFO,
646 (Info->WalkState->MethodNode ?
647 Info->WalkState->MethodNode->Name.Ascii : " "),
648 AmlOffset, (UINT32) Op->Common.AmlOpcode);
652 if (Op->Common.AmlOpcode == AML_SCOPE_OP)
654 /* This is the beginning of the Definition Block */
656 AcpiOsPrintf ("{\n");
658 /* Emit all External() declarations here */
660 if (!AcpiGbl_DmEmitExternalOpcodes)
662 AcpiDmEmitExternals ();
668 else if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
669 (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)) &&
670 (!(Op->Common.DisasmFlags & ACPI_PARSEOP_ELSEIF)) &&
671 (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))
674 * This is a first-level element of a term list,
677 switch (Op->Common.AmlOpcode)
681 * Optionally just ignore this opcode. Some tables use
682 * NoOp opcodes for "padding" out packages that the BIOS
683 * changes dynamically. This can leave hundreds or
684 * thousands of NoOp opcodes that if disassembled,
685 * cannot be compiled because they are syntactically
688 if (AcpiGbl_IgnoreNoopOperator)
690 Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
698 AcpiDmIndent (Level);
702 Info->LastLevel = Level;
707 * This is an inexpensive mechanism to try and keep lines from getting
708 * too long. When the limit is hit, start a new line at the previous
709 * indent plus one. A better but more expensive mechanism would be to
710 * keep track of the current column.
713 if (Info->Count /* +Info->LastLevel */ > 12)
717 AcpiDmIndent (Info->LastLevel + 1);
720 /* If ASL+ is enabled, check for a C-style operator */
722 if (AcpiDmCheckForSymbolicOpcode (Op, Info))
727 /* Print the opcode name */
729 AcpiDmDisassembleOneOp (NULL, Info, Op);
731 if ((Op->Common.DisasmOpcode == ACPI_DASM_LNOT_PREFIX) ||
732 (Op->Common.AmlOpcode == AML_INT_CONNECTION_OP))
737 if ((Op->Common.AmlOpcode == AML_NAME_OP) ||
738 (Op->Common.AmlOpcode == AML_RETURN_OP))
743 if (Op->Common.AmlOpcode == AML_EXTERNAL_OP)
745 Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
746 return (AE_CTRL_DEPTH);
749 /* Start the opcode argument list if necessary */
751 if ((OpInfo->Flags & AML_HAS_ARGS) ||
752 (Op->Common.AmlOpcode == AML_EVENT_OP))
754 /* This opcode has an argument list */
756 if (AcpiDmBlockType (Op) & BLOCK_PAREN)
759 if (!(AcpiDmBlockType (Op) & BLOCK_BRACE))
761 ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, " ", 0);
765 /* If this is a named opcode, print the associated name value */
767 if (OpInfo->Flags & AML_NAMED)
769 switch (Op->Common.AmlOpcode)
773 NextOp = AcpiPsGetDepthNext (NULL, Op);
774 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
775 AcpiDmNamestring (NextOp->Common.Value.Name);
778 /*lint -fallthrough */
782 Name = AcpiPsGetName (Op);
785 AcpiDmNamestring ((char *) Op->Named.Path);
789 AcpiDmDumpName (Name);
792 if (Op->Common.AmlOpcode != AML_INT_NAMEDFIELD_OP)
794 if (AcpiGbl_DmOpt_Verbose)
796 (void) AcpiPsDisplayObjectPathname (NULL, Op);
802 switch (Op->Common.AmlOpcode)
806 AcpiDmMethodFlags (Op);
807 ASL_CV_CLOSE_PAREN (Op, Level);
809 /* Emit description comment for Method() with a predefined ACPI name */
811 AcpiDmPredefinedDescription (Op);
816 /* Check for _HID and related EISAID() */
818 AcpiDmCheckForHardwareId (Op);
820 ASL_CV_PRINT_ONE_COMMENT (Op, AML_NAMECOMMENT, NULL, 0);
825 AcpiDmRegionFlags (Op);
828 case AML_POWER_RESOURCE_OP:
830 /* Mark the next two Ops as part of the parameter list */
833 NextOp = AcpiPsGetDepthNext (NULL, Op);
834 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
836 NextOp = NextOp->Common.Next;
837 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
840 case AML_PROCESSOR_OP:
842 /* Mark the next three Ops as part of the parameter list */
845 NextOp = AcpiPsGetDepthNext (NULL, Op);
846 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
848 NextOp = NextOp->Common.Next;
849 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
851 NextOp = NextOp->Common.Next;
852 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
856 case AML_DATA_REGION_OP:
868 case AML_THERMAL_ZONE_OP:
870 ASL_CV_CLOSE_PAREN (Op, Level);
875 AcpiOsPrintf ("*** Unhandled named opcode %X\n",
876 Op->Common.AmlOpcode);
881 else switch (Op->Common.AmlOpcode)
884 case AML_BANK_FIELD_OP:
885 case AML_INDEX_FIELD_OP:
889 /* Name of the parent OperationRegion */
891 NextOp = AcpiPsGetDepthNext (NULL, Op);
892 AcpiDmNamestring (NextOp->Common.Value.Name);
894 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
896 switch (Op->Common.AmlOpcode)
898 case AML_BANK_FIELD_OP:
900 /* Namestring - Bank Name */
902 NextOp = AcpiPsGetDepthNext (NULL, NextOp);
903 AcpiDmNamestring (NextOp->Common.Value.Name);
904 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
908 * Bank Value. This is a TermArg in the middle of the parameter
909 * list, must handle it here.
911 * Disassemble the TermArg parse tree. ACPI_PARSEOP_PARAMETER_LIST
912 * eliminates newline in the output.
914 NextOp = NextOp->Common.Next;
916 Info->Flags = ACPI_PARSEOP_PARAMETER_LIST;
917 AcpiDmWalkParseTree (NextOp, AcpiDmDescendingOp,
918 AcpiDmAscendingOp, Info);
922 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
926 case AML_INDEX_FIELD_OP:
928 /* Namestring - Data Name */
930 NextOp = AcpiPsGetDepthNext (NULL, NextOp);
931 AcpiDmNamestring (NextOp->Common.Value.Name);
933 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
941 AcpiDmFieldFlags (NextOp);
946 /* The next op is the size parameter */
948 NextOp = AcpiPsGetDepthNext (NULL, Op);
951 /* Single-step support */
956 if (Op->Common.DisasmOpcode == ACPI_DASM_RESOURCE)
959 * We have a resource list. Don't need to output
960 * the buffer size Op. Open up a new block
962 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
963 NextOp = NextOp->Common.Next;
964 ASL_CV_CLOSE_PAREN (Op, Level);
966 /* Emit description comment for Name() with a predefined ACPI name */
968 AcpiDmPredefinedDescription (Op->Asl.Parent);
971 AcpiDmIndent (Info->Level);
972 AcpiOsPrintf ("{\n");
976 /* Normal Buffer, mark size as in the parameter list */
978 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
982 case AML_VARIABLE_PACKAGE_OP:
985 /* The next op is the size or predicate parameter */
987 NextOp = AcpiPsGetDepthNext (NULL, Op);
990 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
996 /* The next op is the size parameter */
998 NextOp = AcpiPsGetDepthNext (NULL, Op);
1001 NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
1015 if (AcpiDmBlockType (Op) & BLOCK_BRACE)
1017 AcpiOsPrintf ("\n");
1018 AcpiDmIndent (Level);
1019 AcpiOsPrintf ("{\n");
1027 /*******************************************************************************
1029 * FUNCTION: AcpiDmAscendingOp
1031 * PARAMETERS: ASL_WALK_CALLBACK
1035 * DESCRIPTION: Second visitation of a parse object, during ascent of parse
1036 * tree. Close out any parameter lists and complete the opcode.
1038 ******************************************************************************/
1042 ACPI_PARSE_OBJECT *Op,
1046 ACPI_OP_WALK_INFO *Info = Context;
1047 ACPI_PARSE_OBJECT *ParentOp;
1050 /* Point the Op's filename pointer to the proper file */
1052 if (Gbl_CaptureComments)
1054 ASL_CV_LABEL_FILENODE (Op);
1056 /* Switch the output of these files if necessary */
1058 if (ASL_CV_FILE_HAS_SWITCHED (Op))
1060 ASL_CV_SWITCH_FILES (Level, Op);
1064 if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE ||
1065 Op->Common.DisasmOpcode == ACPI_DASM_IGNORE_SINGLE)
1067 /* Ignore this op -- it was handled elsewhere */
1072 if ((Level == 0) && (Op->Common.AmlOpcode == AML_SCOPE_OP))
1074 /* Indicates the end of the current descriptor block (table) */
1076 ASL_CV_CLOSE_BRACE (Op, Level);
1078 /* Print any comments that are at the end of the file here */
1080 if (Gbl_CaptureComments && AcpiGbl_LastListHead)
1082 AcpiOsPrintf ("\n");
1083 ASL_CV_PRINT_ONE_COMMENT_LIST (AcpiGbl_LastListHead, 0);
1085 AcpiOsPrintf ("\n\n");
1090 switch (AcpiDmBlockType (Op))
1094 /* Completed an op that has arguments, add closing paren if needed */
1096 AcpiDmCloseOperator (Op);
1098 if (Op->Common.AmlOpcode == AML_NAME_OP)
1100 /* Emit description comment for Name() with a predefined ACPI name */
1102 AcpiDmPredefinedDescription (Op);
1106 /* For Create* operators, attempt to emit resource tag description */
1108 AcpiDmFieldPredefinedDescription (Op);
1111 /* Decode Notify() values */
1113 if (Op->Common.AmlOpcode == AML_NOTIFY_OP)
1115 AcpiDmNotifyDescription (Op);
1118 AcpiDmDisplayTargetPathname (Op);
1120 /* Could be a nested operator, check if comma required */
1122 if (!AcpiDmCommaIfListMember (Op))
1124 if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
1125 (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)) &&
1126 (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))
1129 * This is a first-level element of a term list
1132 if (!(Info->Flags & ACPI_PARSEOP_PARAMETER_LIST))
1134 AcpiOsPrintf ("\n");
1141 case (BLOCK_BRACE | BLOCK_PAREN):
1143 /* Completed an op that has a term list, add closing brace */
1145 if (Op->Common.DisasmFlags & ACPI_PARSEOP_EMPTY_TERMLIST)
1147 ASL_CV_CLOSE_BRACE (Op, Level);
1151 AcpiDmIndent (Level);
1152 ASL_CV_CLOSE_BRACE (Op, Level);
1155 AcpiDmCommaIfListMember (Op);
1157 if (AcpiDmBlockType (Op->Common.Parent) != BLOCK_PAREN)
1159 AcpiOsPrintf ("\n");
1160 if (!(Op->Common.DisasmFlags & ACPI_PARSEOP_EMPTY_TERMLIST))
1162 if ((Op->Common.AmlOpcode == AML_IF_OP) &&
1163 (Op->Common.Next) &&
1164 (Op->Common.Next->Common.AmlOpcode == AML_ELSE_OP))
1169 if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
1174 AcpiOsPrintf ("\n");
1182 /* Could be a nested operator, check if comma required */
1184 if (!AcpiDmCommaIfListMember (Op))
1186 if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
1187 (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)) &&
1188 (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))
1191 * This is a first-level element of a term list
1194 AcpiOsPrintf ("\n");
1197 else if (Op->Common.Parent)
1199 switch (Op->Common.Parent->Common.AmlOpcode)
1201 case AML_PACKAGE_OP:
1202 case AML_VARIABLE_PACKAGE_OP:
1204 if (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST))
1206 AcpiOsPrintf ("\n");
1218 if (Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)
1220 if ((Op->Common.Next) &&
1221 (Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST))
1227 * The parent Op is guaranteed to be valid because of the flag
1228 * ACPI_PARSEOP_PARAMETER_LIST -- which means that this op is part of
1229 * a parameter list and thus has a valid parent.
1231 ParentOp = Op->Common.Parent;
1234 * Just completed a parameter node for something like "Buffer (param)".
1235 * Close the paren and open up the term list block with a brace.
1237 * Switch predicates don't have a Next node but require a closing paren
1238 * and opening brace.
1240 if (Op->Common.Next || Op->Common.DisasmOpcode == ACPI_DASM_SWITCH_PREDICATE)
1242 ASL_CV_CLOSE_PAREN (Op, Level);
1245 * Emit a description comment for a Name() operator that is a
1246 * predefined ACPI name. Must check the grandparent.
1248 ParentOp = ParentOp->Common.Parent;
1250 (ParentOp->Asl.AmlOpcode == AML_NAME_OP))
1252 AcpiDmPredefinedDescription (ParentOp);
1255 /* Correct the indentation level for Switch and Case predicates */
1257 if (Op->Common.DisasmOpcode == ACPI_DASM_SWITCH_PREDICATE)
1262 AcpiOsPrintf ("\n");
1263 AcpiDmIndent (Level - 1);
1264 AcpiOsPrintf ("{\n");
1268 ParentOp->Common.DisasmFlags |= ACPI_PARSEOP_EMPTY_TERMLIST;
1269 ASL_CV_CLOSE_PAREN (Op, Level);
1274 if ((Op->Common.AmlOpcode == AML_NAME_OP) ||
1275 (Op->Common.AmlOpcode == AML_RETURN_OP))
1281 * For ASL+, check for and emit a C-style symbol. If valid, the
1282 * symbol string has been deferred until after the first operand
1284 if (AcpiGbl_CstyleDisassembly)
1286 if (Op->Asl.OperatorSymbol)
1288 AcpiOsPrintf ("%s", Op->Asl.OperatorSymbol);
1289 Op->Asl.OperatorSymbol = NULL;