1bc36eafdSMike Gerdts /*******************************************************************************
2bc36eafdSMike Gerdts *
3bc36eafdSMike Gerdts * Module Name: dmwalk - AML disassembly tree walk
4bc36eafdSMike Gerdts *
5bc36eafdSMike Gerdts ******************************************************************************/
6bc36eafdSMike Gerdts
7*35786f68SRobert Mustacchi /******************************************************************************
8*35786f68SRobert Mustacchi *
9*35786f68SRobert Mustacchi * 1. Copyright Notice
10*35786f68SRobert Mustacchi *
11*35786f68SRobert Mustacchi * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12bc36eafdSMike Gerdts * All rights reserved.
13bc36eafdSMike Gerdts *
14*35786f68SRobert Mustacchi * 2. License
15*35786f68SRobert Mustacchi *
16*35786f68SRobert Mustacchi * 2.1. This is your license from Intel Corp. under its intellectual property
17*35786f68SRobert Mustacchi * rights. You may have additional license terms from the party that provided
18*35786f68SRobert Mustacchi * you this software, covering your right to use that party's intellectual
19*35786f68SRobert Mustacchi * property rights.
20*35786f68SRobert Mustacchi *
21*35786f68SRobert Mustacchi * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22*35786f68SRobert Mustacchi * copy of the source code appearing in this file ("Covered Code") an
23*35786f68SRobert Mustacchi * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24*35786f68SRobert Mustacchi * base code distributed originally by Intel ("Original Intel Code") to copy,
25*35786f68SRobert Mustacchi * make derivatives, distribute, use and display any portion of the Covered
26*35786f68SRobert Mustacchi * Code in any form, with the right to sublicense such rights; and
27*35786f68SRobert Mustacchi *
28*35786f68SRobert Mustacchi * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29*35786f68SRobert Mustacchi * license (with the right to sublicense), under only those claims of Intel
30*35786f68SRobert Mustacchi * patents that are infringed by the Original Intel Code, to make, use, sell,
31*35786f68SRobert Mustacchi * offer to sell, and import the Covered Code and derivative works thereof
32*35786f68SRobert Mustacchi * solely to the minimum extent necessary to exercise the above copyright
33*35786f68SRobert Mustacchi * license, and in no event shall the patent license extend to any additions
34*35786f68SRobert Mustacchi * to or modifications of the Original Intel Code. No other license or right
35*35786f68SRobert Mustacchi * is granted directly or by implication, estoppel or otherwise;
36*35786f68SRobert Mustacchi *
37*35786f68SRobert Mustacchi * The above copyright and patent license is granted only if the following
38*35786f68SRobert Mustacchi * conditions are met:
39*35786f68SRobert Mustacchi *
40*35786f68SRobert Mustacchi * 3. Conditions
41*35786f68SRobert Mustacchi *
42*35786f68SRobert Mustacchi * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43*35786f68SRobert Mustacchi * Redistribution of source code of any substantial portion of the Covered
44*35786f68SRobert Mustacchi * Code or modification with rights to further distribute source must include
45*35786f68SRobert Mustacchi * the above Copyright Notice, the above License, this list of Conditions,
46*35786f68SRobert Mustacchi * and the following Disclaimer and Export Compliance provision. In addition,
47*35786f68SRobert Mustacchi * Licensee must cause all Covered Code to which Licensee contributes to
48*35786f68SRobert Mustacchi * contain a file documenting the changes Licensee made to create that Covered
49*35786f68SRobert Mustacchi * Code and the date of any change. Licensee must include in that file the
50*35786f68SRobert Mustacchi * documentation of any changes made by any predecessor Licensee. Licensee
51*35786f68SRobert Mustacchi * must include a prominent statement that the modification is derived,
52*35786f68SRobert Mustacchi * directly or indirectly, from Original Intel Code.
53*35786f68SRobert Mustacchi *
54*35786f68SRobert Mustacchi * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55*35786f68SRobert Mustacchi * Redistribution of source code of any substantial portion of the Covered
56*35786f68SRobert Mustacchi * Code or modification without rights to further distribute source must
57*35786f68SRobert Mustacchi * include the following Disclaimer and Export Compliance provision in the
58*35786f68SRobert Mustacchi * documentation and/or other materials provided with distribution. In
59*35786f68SRobert Mustacchi * addition, Licensee may not authorize further sublicense of source of any
60*35786f68SRobert Mustacchi * portion of the Covered Code, and must include terms to the effect that the
61*35786f68SRobert Mustacchi * license from Licensee to its licensee is limited to the intellectual
62*35786f68SRobert Mustacchi * property embodied in the software Licensee provides to its licensee, and
63*35786f68SRobert Mustacchi * not to intellectual property embodied in modifications its licensee may
64*35786f68SRobert Mustacchi * make.
65*35786f68SRobert Mustacchi *
66*35786f68SRobert Mustacchi * 3.3. Redistribution of Executable. Redistribution in executable form of any
67*35786f68SRobert Mustacchi * substantial portion of the Covered Code or modification must reproduce the
68*35786f68SRobert Mustacchi * above Copyright Notice, and the following Disclaimer and Export Compliance
69*35786f68SRobert Mustacchi * provision in the documentation and/or other materials provided with the
70*35786f68SRobert Mustacchi * distribution.
71*35786f68SRobert Mustacchi *
72*35786f68SRobert Mustacchi * 3.4. Intel retains all right, title, and interest in and to the Original
73*35786f68SRobert Mustacchi * Intel Code.
74*35786f68SRobert Mustacchi *
75*35786f68SRobert Mustacchi * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76*35786f68SRobert Mustacchi * Intel shall be used in advertising or otherwise to promote the sale, use or
77*35786f68SRobert Mustacchi * other dealings in products derived from or relating to the Covered Code
78*35786f68SRobert Mustacchi * without prior written authorization from Intel.
79*35786f68SRobert Mustacchi *
80*35786f68SRobert Mustacchi * 4. Disclaimer and Export Compliance
81*35786f68SRobert Mustacchi *
82*35786f68SRobert Mustacchi * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83*35786f68SRobert Mustacchi * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84*35786f68SRobert Mustacchi * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85*35786f68SRobert Mustacchi * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86*35786f68SRobert Mustacchi * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87*35786f68SRobert Mustacchi * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88*35786f68SRobert Mustacchi * PARTICULAR PURPOSE.
89*35786f68SRobert Mustacchi *
90*35786f68SRobert Mustacchi * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91*35786f68SRobert Mustacchi * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92*35786f68SRobert Mustacchi * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93*35786f68SRobert Mustacchi * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94*35786f68SRobert Mustacchi * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95*35786f68SRobert Mustacchi * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96*35786f68SRobert Mustacchi * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97*35786f68SRobert Mustacchi * LIMITED REMEDY.
98*35786f68SRobert Mustacchi *
99*35786f68SRobert Mustacchi * 4.3. Licensee shall not export, either directly or indirectly, any of this
100*35786f68SRobert Mustacchi * software or system incorporating such software without first obtaining any
101*35786f68SRobert Mustacchi * required license or other approval from the U. S. Department of Commerce or
102*35786f68SRobert Mustacchi * any other agency or department of the United States Government. In the
103*35786f68SRobert Mustacchi * event Licensee exports any such software from the United States or
104*35786f68SRobert Mustacchi * re-exports any such software from a foreign destination, Licensee shall
105*35786f68SRobert Mustacchi * ensure that the distribution and export/re-export of the software is in
106*35786f68SRobert Mustacchi * compliance with all laws, regulations, orders, or other restrictions of the
107*35786f68SRobert Mustacchi * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108*35786f68SRobert Mustacchi * any of its subsidiaries will export/re-export any technical data, process,
109*35786f68SRobert Mustacchi * software, or service, directly or indirectly, to any country for which the
110*35786f68SRobert Mustacchi * United States government or any agency thereof requires an export license,
111*35786f68SRobert Mustacchi * other governmental approval, or letter of assurance, without first obtaining
112*35786f68SRobert Mustacchi * such license, approval or letter.
113*35786f68SRobert Mustacchi *
114*35786f68SRobert Mustacchi *****************************************************************************
115*35786f68SRobert Mustacchi *
116*35786f68SRobert Mustacchi * Alternatively, you may choose to be licensed under the terms of the
117*35786f68SRobert Mustacchi * following license:
118*35786f68SRobert Mustacchi *
119bc36eafdSMike Gerdts * Redistribution and use in source and binary forms, with or without
120bc36eafdSMike Gerdts * modification, are permitted provided that the following conditions
121bc36eafdSMike Gerdts * are met:
122bc36eafdSMike Gerdts * 1. Redistributions of source code must retain the above copyright
123bc36eafdSMike Gerdts * notice, this list of conditions, and the following disclaimer,
124bc36eafdSMike Gerdts * without modification.
125bc36eafdSMike Gerdts * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126bc36eafdSMike Gerdts * substantially similar to the "NO WARRANTY" disclaimer below
127bc36eafdSMike Gerdts * ("Disclaimer") and any redistribution must be conditioned upon
128bc36eafdSMike Gerdts * including a substantially similar Disclaimer requirement for further
129bc36eafdSMike Gerdts * binary redistribution.
130bc36eafdSMike Gerdts * 3. Neither the names of the above-listed copyright holders nor the names
131bc36eafdSMike Gerdts * of any contributors may be used to endorse or promote products derived
132bc36eafdSMike Gerdts * from this software without specific prior written permission.
133bc36eafdSMike Gerdts *
134*35786f68SRobert Mustacchi * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135*35786f68SRobert Mustacchi * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136*35786f68SRobert Mustacchi * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137*35786f68SRobert Mustacchi * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138*35786f68SRobert Mustacchi * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139*35786f68SRobert Mustacchi * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140*35786f68SRobert Mustacchi * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141*35786f68SRobert Mustacchi * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142*35786f68SRobert Mustacchi * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143*35786f68SRobert Mustacchi * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144*35786f68SRobert Mustacchi * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145*35786f68SRobert Mustacchi *
146*35786f68SRobert Mustacchi * Alternatively, you may choose to be licensed under the terms of the
147bc36eafdSMike Gerdts * GNU General Public License ("GPL") version 2 as published by the Free
148bc36eafdSMike Gerdts * Software Foundation.
149bc36eafdSMike Gerdts *
150*35786f68SRobert Mustacchi *****************************************************************************/
151bc36eafdSMike Gerdts
152bc36eafdSMike Gerdts #include "acpi.h"
153bc36eafdSMike Gerdts #include "accommon.h"
154bc36eafdSMike Gerdts #include "acparser.h"
155bc36eafdSMike Gerdts #include "amlcode.h"
156bc36eafdSMike Gerdts #include "acdebug.h"
157*35786f68SRobert Mustacchi #include "acconvert.h"
158bc36eafdSMike Gerdts
159bc36eafdSMike Gerdts
160bc36eafdSMike Gerdts #define _COMPONENT ACPI_CA_DEBUGGER
161bc36eafdSMike Gerdts ACPI_MODULE_NAME ("dmwalk")
162bc36eafdSMike Gerdts
163bc36eafdSMike Gerdts
164bc36eafdSMike Gerdts /* Stub for non-compiler code */
165bc36eafdSMike Gerdts
166bc36eafdSMike Gerdts #ifndef ACPI_ASL_COMPILER
167bc36eafdSMike Gerdts void
AcpiDmEmitExternals(void)168bc36eafdSMike Gerdts AcpiDmEmitExternals (
169bc36eafdSMike Gerdts void)
170bc36eafdSMike Gerdts {
171bc36eafdSMike Gerdts return;
172bc36eafdSMike Gerdts }
173*35786f68SRobert Mustacchi
174*35786f68SRobert Mustacchi void
AcpiDmEmitExternal(ACPI_PARSE_OBJECT * NameOp,ACPI_PARSE_OBJECT * TypeOp)175*35786f68SRobert Mustacchi AcpiDmEmitExternal (
176*35786f68SRobert Mustacchi ACPI_PARSE_OBJECT *NameOp,
177*35786f68SRobert Mustacchi ACPI_PARSE_OBJECT *TypeOp)
178*35786f68SRobert Mustacchi {
179*35786f68SRobert Mustacchi return;
180*35786f68SRobert Mustacchi }
181bc36eafdSMike Gerdts #endif
182bc36eafdSMike Gerdts
183bc36eafdSMike Gerdts /* Local prototypes */
184bc36eafdSMike Gerdts
185bc36eafdSMike Gerdts static ACPI_STATUS
186bc36eafdSMike Gerdts AcpiDmDescendingOp (
187bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op,
188bc36eafdSMike Gerdts UINT32 Level,
189bc36eafdSMike Gerdts void *Context);
190bc36eafdSMike Gerdts
191bc36eafdSMike Gerdts static ACPI_STATUS
192bc36eafdSMike Gerdts AcpiDmAscendingOp (
193bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op,
194bc36eafdSMike Gerdts UINT32 Level,
195bc36eafdSMike Gerdts void *Context);
196bc36eafdSMike Gerdts
197bc36eafdSMike Gerdts
198bc36eafdSMike Gerdts /*******************************************************************************
199bc36eafdSMike Gerdts *
200bc36eafdSMike Gerdts * FUNCTION: AcpiDmDisassemble
201bc36eafdSMike Gerdts *
202bc36eafdSMike Gerdts * PARAMETERS: WalkState - Current state
203bc36eafdSMike Gerdts * Origin - Starting object
204bc36eafdSMike Gerdts * NumOpcodes - Max number of opcodes to be displayed
205bc36eafdSMike Gerdts *
206bc36eafdSMike Gerdts * RETURN: None
207bc36eafdSMike Gerdts *
208bc36eafdSMike Gerdts * DESCRIPTION: Disassemble parser object and its children. This is the
209bc36eafdSMike Gerdts * main entry point of the disassembler.
210bc36eafdSMike Gerdts *
211bc36eafdSMike Gerdts ******************************************************************************/
212bc36eafdSMike Gerdts
213bc36eafdSMike Gerdts void
AcpiDmDisassemble(ACPI_WALK_STATE * WalkState,ACPI_PARSE_OBJECT * Origin,UINT32 NumOpcodes)214bc36eafdSMike Gerdts AcpiDmDisassemble (
215bc36eafdSMike Gerdts ACPI_WALK_STATE *WalkState,
216bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Origin,
217bc36eafdSMike Gerdts UINT32 NumOpcodes)
218bc36eafdSMike Gerdts {
219bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op = Origin;
220bc36eafdSMike Gerdts ACPI_OP_WALK_INFO Info;
221bc36eafdSMike Gerdts
222bc36eafdSMike Gerdts
223bc36eafdSMike Gerdts if (!Op)
224bc36eafdSMike Gerdts {
225bc36eafdSMike Gerdts return;
226bc36eafdSMike Gerdts }
227bc36eafdSMike Gerdts
228bc36eafdSMike Gerdts memset (&Info, 0, sizeof (ACPI_OP_WALK_INFO));
229bc36eafdSMike Gerdts Info.WalkState = WalkState;
230bc36eafdSMike Gerdts Info.StartAml = Op->Common.Aml - sizeof (ACPI_TABLE_HEADER);
231bc36eafdSMike Gerdts Info.AmlOffset = Op->Common.Aml - Info.StartAml;
232bc36eafdSMike Gerdts
233bc36eafdSMike Gerdts AcpiDmWalkParseTree (Op, AcpiDmDescendingOp, AcpiDmAscendingOp, &Info);
234bc36eafdSMike Gerdts return;
235bc36eafdSMike Gerdts }
236bc36eafdSMike Gerdts
237bc36eafdSMike Gerdts
238bc36eafdSMike Gerdts /*******************************************************************************
239bc36eafdSMike Gerdts *
240bc36eafdSMike Gerdts * FUNCTION: AcpiDmWalkParseTree
241bc36eafdSMike Gerdts *
242bc36eafdSMike Gerdts * PARAMETERS: Op - Root Op object
243bc36eafdSMike Gerdts * DescendingCallback - Called during tree descent
244bc36eafdSMike Gerdts * AscendingCallback - Called during tree ascent
245bc36eafdSMike Gerdts * Context - To be passed to the callbacks
246bc36eafdSMike Gerdts *
247bc36eafdSMike Gerdts * RETURN: Status from callback(s)
248bc36eafdSMike Gerdts *
249bc36eafdSMike Gerdts * DESCRIPTION: Walk the entire parse tree.
250bc36eafdSMike Gerdts *
251bc36eafdSMike Gerdts ******************************************************************************/
252bc36eafdSMike Gerdts
253bc36eafdSMike Gerdts void
AcpiDmWalkParseTree(ACPI_PARSE_OBJECT * Op,ASL_WALK_CALLBACK DescendingCallback,ASL_WALK_CALLBACK AscendingCallback,void * Context)254bc36eafdSMike Gerdts AcpiDmWalkParseTree (
255bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op,
256bc36eafdSMike Gerdts ASL_WALK_CALLBACK DescendingCallback,
257bc36eafdSMike Gerdts ASL_WALK_CALLBACK AscendingCallback,
258bc36eafdSMike Gerdts void *Context)
259bc36eafdSMike Gerdts {
260bc36eafdSMike Gerdts BOOLEAN NodePreviouslyVisited;
261bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *StartOp = Op;
262bc36eafdSMike Gerdts ACPI_STATUS Status;
263bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Next;
264bc36eafdSMike Gerdts ACPI_OP_WALK_INFO *Info = Context;
265bc36eafdSMike Gerdts
266bc36eafdSMike Gerdts
267bc36eafdSMike Gerdts Info->Level = 0;
268bc36eafdSMike Gerdts NodePreviouslyVisited = FALSE;
269bc36eafdSMike Gerdts
270bc36eafdSMike Gerdts while (Op)
271bc36eafdSMike Gerdts {
272bc36eafdSMike Gerdts if (NodePreviouslyVisited)
273bc36eafdSMike Gerdts {
274bc36eafdSMike Gerdts if (AscendingCallback)
275bc36eafdSMike Gerdts {
276bc36eafdSMike Gerdts Status = AscendingCallback (Op, Info->Level, Context);
277bc36eafdSMike Gerdts if (ACPI_FAILURE (Status))
278bc36eafdSMike Gerdts {
279bc36eafdSMike Gerdts return;
280bc36eafdSMike Gerdts }
281bc36eafdSMike Gerdts }
282bc36eafdSMike Gerdts }
283bc36eafdSMike Gerdts else
284bc36eafdSMike Gerdts {
285bc36eafdSMike Gerdts /* Let the callback process the node */
286bc36eafdSMike Gerdts
287bc36eafdSMike Gerdts Status = DescendingCallback (Op, Info->Level, Context);
288bc36eafdSMike Gerdts if (ACPI_SUCCESS (Status))
289bc36eafdSMike Gerdts {
290bc36eafdSMike Gerdts /* Visit children first, once */
291bc36eafdSMike Gerdts
292bc36eafdSMike Gerdts Next = AcpiPsGetArg (Op, 0);
293bc36eafdSMike Gerdts if (Next)
294bc36eafdSMike Gerdts {
295bc36eafdSMike Gerdts Info->Level++;
296bc36eafdSMike Gerdts Op = Next;
297bc36eafdSMike Gerdts continue;
298bc36eafdSMike Gerdts }
299bc36eafdSMike Gerdts }
300bc36eafdSMike Gerdts else if (Status != AE_CTRL_DEPTH)
301bc36eafdSMike Gerdts {
302bc36eafdSMike Gerdts /* Exit immediately on any error */
303bc36eafdSMike Gerdts
304bc36eafdSMike Gerdts return;
305bc36eafdSMike Gerdts }
306bc36eafdSMike Gerdts }
307bc36eafdSMike Gerdts
308bc36eafdSMike Gerdts /* Terminate walk at start op */
309bc36eafdSMike Gerdts
310bc36eafdSMike Gerdts if (Op == StartOp)
311bc36eafdSMike Gerdts {
312bc36eafdSMike Gerdts break;
313bc36eafdSMike Gerdts }
314bc36eafdSMike Gerdts
315bc36eafdSMike Gerdts /* No more children, re-visit this node */
316bc36eafdSMike Gerdts
317bc36eafdSMike Gerdts if (!NodePreviouslyVisited)
318bc36eafdSMike Gerdts {
319bc36eafdSMike Gerdts NodePreviouslyVisited = TRUE;
320bc36eafdSMike Gerdts continue;
321bc36eafdSMike Gerdts }
322bc36eafdSMike Gerdts
323bc36eafdSMike Gerdts /* No more children, visit peers */
324bc36eafdSMike Gerdts
325bc36eafdSMike Gerdts if (Op->Common.Next)
326bc36eafdSMike Gerdts {
327bc36eafdSMike Gerdts Op = Op->Common.Next;
328bc36eafdSMike Gerdts NodePreviouslyVisited = FALSE;
329bc36eafdSMike Gerdts }
330bc36eafdSMike Gerdts else
331bc36eafdSMike Gerdts {
332bc36eafdSMike Gerdts /* No peers, re-visit parent */
333bc36eafdSMike Gerdts
334bc36eafdSMike Gerdts if (Info->Level != 0 )
335bc36eafdSMike Gerdts {
336bc36eafdSMike Gerdts Info->Level--;
337bc36eafdSMike Gerdts }
338bc36eafdSMike Gerdts
339bc36eafdSMike Gerdts Op = Op->Common.Parent;
340bc36eafdSMike Gerdts NodePreviouslyVisited = TRUE;
341bc36eafdSMike Gerdts }
342bc36eafdSMike Gerdts }
343bc36eafdSMike Gerdts
344bc36eafdSMike Gerdts /* If we get here, the walk completed with no errors */
345bc36eafdSMike Gerdts
346bc36eafdSMike Gerdts return;
347bc36eafdSMike Gerdts }
348bc36eafdSMike Gerdts
349bc36eafdSMike Gerdts
350bc36eafdSMike Gerdts /*******************************************************************************
351bc36eafdSMike Gerdts *
352bc36eafdSMike Gerdts * FUNCTION: AcpiDmBlockType
353bc36eafdSMike Gerdts *
354bc36eafdSMike Gerdts * PARAMETERS: Op - Object to be examined
355bc36eafdSMike Gerdts *
356bc36eafdSMike Gerdts * RETURN: BlockType - not a block, parens, braces, or even both.
357bc36eafdSMike Gerdts *
358bc36eafdSMike Gerdts * DESCRIPTION: Type of block for this op (parens or braces)
359bc36eafdSMike Gerdts *
360bc36eafdSMike Gerdts ******************************************************************************/
361bc36eafdSMike Gerdts
362*35786f68SRobert Mustacchi UINT32
AcpiDmBlockType(ACPI_PARSE_OBJECT * Op)363bc36eafdSMike Gerdts AcpiDmBlockType (
364bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op)
365bc36eafdSMike Gerdts {
366bc36eafdSMike Gerdts const ACPI_OPCODE_INFO *OpInfo;
367bc36eafdSMike Gerdts
368bc36eafdSMike Gerdts
369bc36eafdSMike Gerdts if (!Op)
370bc36eafdSMike Gerdts {
371bc36eafdSMike Gerdts return (BLOCK_NONE);
372bc36eafdSMike Gerdts }
373bc36eafdSMike Gerdts
374bc36eafdSMike Gerdts switch (Op->Common.AmlOpcode)
375bc36eafdSMike Gerdts {
376bc36eafdSMike Gerdts case AML_ELSE_OP:
377bc36eafdSMike Gerdts
378bc36eafdSMike Gerdts return (BLOCK_BRACE);
379bc36eafdSMike Gerdts
380bc36eafdSMike Gerdts case AML_METHOD_OP:
381bc36eafdSMike Gerdts case AML_DEVICE_OP:
382bc36eafdSMike Gerdts case AML_SCOPE_OP:
383bc36eafdSMike Gerdts case AML_PROCESSOR_OP:
384*35786f68SRobert Mustacchi case AML_POWER_RESOURCE_OP:
385bc36eafdSMike Gerdts case AML_THERMAL_ZONE_OP:
386bc36eafdSMike Gerdts case AML_IF_OP:
387bc36eafdSMike Gerdts case AML_WHILE_OP:
388bc36eafdSMike Gerdts case AML_FIELD_OP:
389bc36eafdSMike Gerdts case AML_INDEX_FIELD_OP:
390bc36eafdSMike Gerdts case AML_BANK_FIELD_OP:
391bc36eafdSMike Gerdts
392bc36eafdSMike Gerdts return (BLOCK_PAREN | BLOCK_BRACE);
393bc36eafdSMike Gerdts
394bc36eafdSMike Gerdts case AML_BUFFER_OP:
395bc36eafdSMike Gerdts
396bc36eafdSMike Gerdts if ((Op->Common.DisasmOpcode == ACPI_DASM_UNICODE) ||
397bc36eafdSMike Gerdts (Op->Common.DisasmOpcode == ACPI_DASM_UUID) ||
398bc36eafdSMike Gerdts (Op->Common.DisasmOpcode == ACPI_DASM_PLD_METHOD))
399bc36eafdSMike Gerdts {
400bc36eafdSMike Gerdts return (BLOCK_NONE);
401bc36eafdSMike Gerdts }
402bc36eafdSMike Gerdts
403bc36eafdSMike Gerdts /*lint -fallthrough */
404bc36eafdSMike Gerdts
405bc36eafdSMike Gerdts case AML_PACKAGE_OP:
406*35786f68SRobert Mustacchi case AML_VARIABLE_PACKAGE_OP:
407bc36eafdSMike Gerdts
408bc36eafdSMike Gerdts return (BLOCK_PAREN | BLOCK_BRACE);
409bc36eafdSMike Gerdts
410bc36eafdSMike Gerdts case AML_EVENT_OP:
411bc36eafdSMike Gerdts
412bc36eafdSMike Gerdts return (BLOCK_PAREN);
413bc36eafdSMike Gerdts
414bc36eafdSMike Gerdts case AML_INT_METHODCALL_OP:
415bc36eafdSMike Gerdts
416bc36eafdSMike Gerdts if (Op->Common.Parent &&
417bc36eafdSMike Gerdts ((Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP) ||
418*35786f68SRobert Mustacchi (Op->Common.Parent->Common.AmlOpcode == AML_VARIABLE_PACKAGE_OP)))
419bc36eafdSMike Gerdts {
420bc36eafdSMike Gerdts /* This is a reference to a method, not an invocation */
421bc36eafdSMike Gerdts
422bc36eafdSMike Gerdts return (BLOCK_NONE);
423bc36eafdSMike Gerdts }
424bc36eafdSMike Gerdts
425bc36eafdSMike Gerdts /*lint -fallthrough */
426bc36eafdSMike Gerdts
427bc36eafdSMike Gerdts default:
428bc36eafdSMike Gerdts
429bc36eafdSMike Gerdts OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
430bc36eafdSMike Gerdts if (OpInfo->Flags & AML_HAS_ARGS)
431bc36eafdSMike Gerdts {
432bc36eafdSMike Gerdts return (BLOCK_PAREN);
433bc36eafdSMike Gerdts }
434bc36eafdSMike Gerdts
435bc36eafdSMike Gerdts return (BLOCK_NONE);
436bc36eafdSMike Gerdts }
437bc36eafdSMike Gerdts }
438bc36eafdSMike Gerdts
439bc36eafdSMike Gerdts
440bc36eafdSMike Gerdts /*******************************************************************************
441bc36eafdSMike Gerdts *
442bc36eafdSMike Gerdts * FUNCTION: AcpiDmListType
443bc36eafdSMike Gerdts *
444bc36eafdSMike Gerdts * PARAMETERS: Op - Object to be examined
445bc36eafdSMike Gerdts *
446bc36eafdSMike Gerdts * RETURN: ListType - has commas or not.
447bc36eafdSMike Gerdts *
448bc36eafdSMike Gerdts * DESCRIPTION: Type of block for this op (parens or braces)
449bc36eafdSMike Gerdts *
450bc36eafdSMike Gerdts ******************************************************************************/
451bc36eafdSMike Gerdts
452bc36eafdSMike Gerdts UINT32
AcpiDmListType(ACPI_PARSE_OBJECT * Op)453bc36eafdSMike Gerdts AcpiDmListType (
454bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op)
455bc36eafdSMike Gerdts {
456bc36eafdSMike Gerdts const ACPI_OPCODE_INFO *OpInfo;
457bc36eafdSMike Gerdts
458bc36eafdSMike Gerdts
459bc36eafdSMike Gerdts if (!Op)
460bc36eafdSMike Gerdts {
461bc36eafdSMike Gerdts return (BLOCK_NONE);
462bc36eafdSMike Gerdts }
463bc36eafdSMike Gerdts
464bc36eafdSMike Gerdts switch (Op->Common.AmlOpcode)
465bc36eafdSMike Gerdts {
466bc36eafdSMike Gerdts
467bc36eafdSMike Gerdts case AML_ELSE_OP:
468bc36eafdSMike Gerdts case AML_METHOD_OP:
469bc36eafdSMike Gerdts case AML_DEVICE_OP:
470bc36eafdSMike Gerdts case AML_SCOPE_OP:
471*35786f68SRobert Mustacchi case AML_POWER_RESOURCE_OP:
472bc36eafdSMike Gerdts case AML_PROCESSOR_OP:
473bc36eafdSMike Gerdts case AML_THERMAL_ZONE_OP:
474bc36eafdSMike Gerdts case AML_IF_OP:
475bc36eafdSMike Gerdts case AML_WHILE_OP:
476bc36eafdSMike Gerdts case AML_FIELD_OP:
477bc36eafdSMike Gerdts case AML_INDEX_FIELD_OP:
478bc36eafdSMike Gerdts case AML_BANK_FIELD_OP:
479bc36eafdSMike Gerdts
480bc36eafdSMike Gerdts return (BLOCK_NONE);
481bc36eafdSMike Gerdts
482bc36eafdSMike Gerdts case AML_BUFFER_OP:
483bc36eafdSMike Gerdts case AML_PACKAGE_OP:
484*35786f68SRobert Mustacchi case AML_VARIABLE_PACKAGE_OP:
485bc36eafdSMike Gerdts
486bc36eafdSMike Gerdts return (BLOCK_COMMA_LIST);
487bc36eafdSMike Gerdts
488bc36eafdSMike Gerdts default:
489bc36eafdSMike Gerdts
490bc36eafdSMike Gerdts OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
491bc36eafdSMike Gerdts if (OpInfo->Flags & AML_HAS_ARGS)
492bc36eafdSMike Gerdts {
493bc36eafdSMike Gerdts return (BLOCK_COMMA_LIST);
494bc36eafdSMike Gerdts }
495bc36eafdSMike Gerdts
496bc36eafdSMike Gerdts return (BLOCK_NONE);
497bc36eafdSMike Gerdts }
498bc36eafdSMike Gerdts }
499bc36eafdSMike Gerdts
500bc36eafdSMike Gerdts
501bc36eafdSMike Gerdts /*******************************************************************************
502bc36eafdSMike Gerdts *
503bc36eafdSMike Gerdts * FUNCTION: AcpiDmDescendingOp
504bc36eafdSMike Gerdts *
505bc36eafdSMike Gerdts * PARAMETERS: ASL_WALK_CALLBACK
506bc36eafdSMike Gerdts *
507bc36eafdSMike Gerdts * RETURN: Status
508bc36eafdSMike Gerdts *
509bc36eafdSMike Gerdts * DESCRIPTION: First visitation of a parse object during tree descent.
510bc36eafdSMike Gerdts * Decode opcode name and begin parameter list(s), if any.
511bc36eafdSMike Gerdts *
512bc36eafdSMike Gerdts ******************************************************************************/
513bc36eafdSMike Gerdts
514bc36eafdSMike Gerdts static ACPI_STATUS
AcpiDmDescendingOp(ACPI_PARSE_OBJECT * Op,UINT32 Level,void * Context)515bc36eafdSMike Gerdts AcpiDmDescendingOp (
516bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op,
517bc36eafdSMike Gerdts UINT32 Level,
518bc36eafdSMike Gerdts void *Context)
519bc36eafdSMike Gerdts {
520bc36eafdSMike Gerdts ACPI_OP_WALK_INFO *Info = Context;
521bc36eafdSMike Gerdts const ACPI_OPCODE_INFO *OpInfo;
522bc36eafdSMike Gerdts UINT32 Name;
523bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *NextOp;
524bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *NextOp2;
525bc36eafdSMike Gerdts UINT32 AmlOffset;
526bc36eafdSMike Gerdts
527bc36eafdSMike Gerdts
528*35786f68SRobert Mustacchi /* Determine which file this parse node is contained in. */
529*35786f68SRobert Mustacchi
530*35786f68SRobert Mustacchi if (AcpiGbl_CaptureComments)
531*35786f68SRobert Mustacchi {
532*35786f68SRobert Mustacchi ASL_CV_LABEL_FILENODE (Op);
533*35786f68SRobert Mustacchi
534*35786f68SRobert Mustacchi if (Level != 0 && ASL_CV_FILE_HAS_SWITCHED (Op))
535*35786f68SRobert Mustacchi {
536*35786f68SRobert Mustacchi ASL_CV_SWITCH_FILES (Level, Op);
537*35786f68SRobert Mustacchi }
538*35786f68SRobert Mustacchi
539*35786f68SRobert Mustacchi /* If this parse node has regular comments, print them here. */
540*35786f68SRobert Mustacchi
541*35786f68SRobert Mustacchi ASL_CV_PRINT_ONE_COMMENT (Op, AML_COMMENT_STANDARD, NULL, Level);
542*35786f68SRobert Mustacchi }
543*35786f68SRobert Mustacchi
544bc36eafdSMike Gerdts OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
545bc36eafdSMike Gerdts
546bc36eafdSMike Gerdts /* Listing support to dump the AML code after the ASL statement */
547bc36eafdSMike Gerdts
548bc36eafdSMike Gerdts if (AcpiGbl_DmOpt_Listing)
549bc36eafdSMike Gerdts {
550bc36eafdSMike Gerdts /* We only care about these classes of objects */
551bc36eafdSMike Gerdts
552bc36eafdSMike Gerdts if ((OpInfo->Class == AML_CLASS_NAMED_OBJECT) ||
553bc36eafdSMike Gerdts (OpInfo->Class == AML_CLASS_CONTROL) ||
554bc36eafdSMike Gerdts (OpInfo->Class == AML_CLASS_CREATE) ||
555bc36eafdSMike Gerdts ((OpInfo->Class == AML_CLASS_EXECUTE) && (!Op->Common.Next)))
556bc36eafdSMike Gerdts {
557bc36eafdSMike Gerdts if (AcpiGbl_DmOpt_Listing && Info->PreviousAml)
558bc36eafdSMike Gerdts {
559bc36eafdSMike Gerdts /* Dump the AML byte code for the previous Op */
560bc36eafdSMike Gerdts
561bc36eafdSMike Gerdts if (Op->Common.Aml > Info->PreviousAml)
562bc36eafdSMike Gerdts {
563bc36eafdSMike Gerdts AcpiOsPrintf ("\n");
564bc36eafdSMike Gerdts AcpiUtDumpBuffer (
565bc36eafdSMike Gerdts (Info->StartAml + Info->AmlOffset),
566bc36eafdSMike Gerdts (Op->Common.Aml - Info->PreviousAml),
567bc36eafdSMike Gerdts DB_BYTE_DISPLAY, Info->AmlOffset);
568bc36eafdSMike Gerdts AcpiOsPrintf ("\n");
569bc36eafdSMike Gerdts }
570bc36eafdSMike Gerdts
571bc36eafdSMike Gerdts Info->AmlOffset = (Op->Common.Aml - Info->StartAml);
572bc36eafdSMike Gerdts }
573bc36eafdSMike Gerdts
574bc36eafdSMike Gerdts Info->PreviousAml = Op->Common.Aml;
575bc36eafdSMike Gerdts }
576bc36eafdSMike Gerdts }
577bc36eafdSMike Gerdts
578bc36eafdSMike Gerdts if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE)
579bc36eafdSMike Gerdts {
580bc36eafdSMike Gerdts /* Ignore this op -- it was handled elsewhere */
581bc36eafdSMike Gerdts
582bc36eafdSMike Gerdts return (AE_CTRL_DEPTH);
583bc36eafdSMike Gerdts }
584bc36eafdSMike Gerdts
585*35786f68SRobert Mustacchi if (Op->Common.DisasmOpcode == ACPI_DASM_IGNORE_SINGLE)
586*35786f68SRobert Mustacchi {
587*35786f68SRobert Mustacchi /* Ignore this op, but not it's children */
588*35786f68SRobert Mustacchi
589*35786f68SRobert Mustacchi return (AE_OK);
590*35786f68SRobert Mustacchi }
591*35786f68SRobert Mustacchi
592bc36eafdSMike Gerdts if (Op->Common.AmlOpcode == AML_IF_OP)
593bc36eafdSMike Gerdts {
594bc36eafdSMike Gerdts NextOp = AcpiPsGetDepthNext (NULL, Op);
595bc36eafdSMike Gerdts if (NextOp)
596bc36eafdSMike Gerdts {
597bc36eafdSMike Gerdts NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
598bc36eafdSMike Gerdts
599bc36eafdSMike Gerdts /* Don't emit the actual embedded externals unless asked */
600bc36eafdSMike Gerdts
601bc36eafdSMike Gerdts if (!AcpiGbl_DmEmitExternalOpcodes)
602bc36eafdSMike Gerdts {
603bc36eafdSMike Gerdts /*
604bc36eafdSMike Gerdts * A Zero predicate indicates the possibility of one or more
605bc36eafdSMike Gerdts * External() opcodes within the If() block.
606bc36eafdSMike Gerdts */
607bc36eafdSMike Gerdts if (NextOp->Common.AmlOpcode == AML_ZERO_OP)
608bc36eafdSMike Gerdts {
609bc36eafdSMike Gerdts NextOp2 = NextOp->Common.Next;
610bc36eafdSMike Gerdts
611bc36eafdSMike Gerdts if (NextOp2 &&
612bc36eafdSMike Gerdts (NextOp2->Common.AmlOpcode == AML_EXTERNAL_OP))
613bc36eafdSMike Gerdts {
614bc36eafdSMike Gerdts /* Ignore the If 0 block and all children */
615bc36eafdSMike Gerdts
616bc36eafdSMike Gerdts Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
617bc36eafdSMike Gerdts return (AE_CTRL_DEPTH);
618bc36eafdSMike Gerdts }
619bc36eafdSMike Gerdts }
620bc36eafdSMike Gerdts }
621bc36eafdSMike Gerdts }
622bc36eafdSMike Gerdts }
623bc36eafdSMike Gerdts
624bc36eafdSMike Gerdts /* Level 0 is at the Definition Block level */
625bc36eafdSMike Gerdts
626bc36eafdSMike Gerdts if (Level == 0)
627bc36eafdSMike Gerdts {
628bc36eafdSMike Gerdts /* In verbose mode, print the AML offset, opcode and depth count */
629bc36eafdSMike Gerdts
630bc36eafdSMike Gerdts if (Info->WalkState)
631bc36eafdSMike Gerdts {
632bc36eafdSMike Gerdts AmlOffset = (UINT32) ACPI_PTR_DIFF (Op->Common.Aml,
633bc36eafdSMike Gerdts Info->WalkState->ParserState.AmlStart);
634bc36eafdSMike Gerdts if (AcpiGbl_DmOpt_Verbose)
635bc36eafdSMike Gerdts {
636*35786f68SRobert Mustacchi if (AcpiGbl_CmSingleStep)
637*35786f68SRobert Mustacchi {
638*35786f68SRobert Mustacchi AcpiOsPrintf ("%5.5X/%4.4X: ",
639bc36eafdSMike Gerdts AmlOffset, (UINT32) Op->Common.AmlOpcode);
640bc36eafdSMike Gerdts }
641*35786f68SRobert Mustacchi else
642*35786f68SRobert Mustacchi {
643*35786f68SRobert Mustacchi AcpiOsPrintf ("AML Offset %5.5X, Opcode %4.4X: ",
644*35786f68SRobert Mustacchi AmlOffset, (UINT32) Op->Common.AmlOpcode);
645*35786f68SRobert Mustacchi }
646*35786f68SRobert Mustacchi }
647bc36eafdSMike Gerdts }
648bc36eafdSMike Gerdts
649bc36eafdSMike Gerdts if (Op->Common.AmlOpcode == AML_SCOPE_OP)
650bc36eafdSMike Gerdts {
651bc36eafdSMike Gerdts /* This is the beginning of the Definition Block */
652bc36eafdSMike Gerdts
653bc36eafdSMike Gerdts AcpiOsPrintf ("{\n");
654bc36eafdSMike Gerdts
655bc36eafdSMike Gerdts /* Emit all External() declarations here */
656bc36eafdSMike Gerdts
657*35786f68SRobert Mustacchi if (!AcpiGbl_DmEmitExternalOpcodes)
658*35786f68SRobert Mustacchi {
659bc36eafdSMike Gerdts AcpiDmEmitExternals ();
660*35786f68SRobert Mustacchi }
661*35786f68SRobert Mustacchi
662bc36eafdSMike Gerdts return (AE_OK);
663bc36eafdSMike Gerdts }
664bc36eafdSMike Gerdts }
665bc36eafdSMike Gerdts else if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
666bc36eafdSMike Gerdts (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)) &&
667bc36eafdSMike Gerdts (!(Op->Common.DisasmFlags & ACPI_PARSEOP_ELSEIF)) &&
668bc36eafdSMike Gerdts (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))
669bc36eafdSMike Gerdts {
670bc36eafdSMike Gerdts /*
671bc36eafdSMike Gerdts * This is a first-level element of a term list,
672bc36eafdSMike Gerdts * indent a new line
673bc36eafdSMike Gerdts */
674bc36eafdSMike Gerdts switch (Op->Common.AmlOpcode)
675bc36eafdSMike Gerdts {
676bc36eafdSMike Gerdts case AML_NOOP_OP:
677bc36eafdSMike Gerdts /*
678bc36eafdSMike Gerdts * Optionally just ignore this opcode. Some tables use
679bc36eafdSMike Gerdts * NoOp opcodes for "padding" out packages that the BIOS
680bc36eafdSMike Gerdts * changes dynamically. This can leave hundreds or
681bc36eafdSMike Gerdts * thousands of NoOp opcodes that if disassembled,
682bc36eafdSMike Gerdts * cannot be compiled because they are syntactically
683bc36eafdSMike Gerdts * incorrect.
684bc36eafdSMike Gerdts */
685bc36eafdSMike Gerdts if (AcpiGbl_IgnoreNoopOperator)
686bc36eafdSMike Gerdts {
687bc36eafdSMike Gerdts Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
688bc36eafdSMike Gerdts return (AE_OK);
689bc36eafdSMike Gerdts }
690bc36eafdSMike Gerdts
691bc36eafdSMike Gerdts /* Fallthrough */
692bc36eafdSMike Gerdts
693bc36eafdSMike Gerdts default:
694bc36eafdSMike Gerdts
695bc36eafdSMike Gerdts AcpiDmIndent (Level);
696bc36eafdSMike Gerdts break;
697bc36eafdSMike Gerdts }
698bc36eafdSMike Gerdts
699bc36eafdSMike Gerdts Info->LastLevel = Level;
700bc36eafdSMike Gerdts Info->Count = 0;
701bc36eafdSMike Gerdts }
702bc36eafdSMike Gerdts
703bc36eafdSMike Gerdts /*
704bc36eafdSMike Gerdts * This is an inexpensive mechanism to try and keep lines from getting
705bc36eafdSMike Gerdts * too long. When the limit is hit, start a new line at the previous
706bc36eafdSMike Gerdts * indent plus one. A better but more expensive mechanism would be to
707bc36eafdSMike Gerdts * keep track of the current column.
708bc36eafdSMike Gerdts */
709bc36eafdSMike Gerdts Info->Count++;
710bc36eafdSMike Gerdts if (Info->Count /* +Info->LastLevel */ > 12)
711bc36eafdSMike Gerdts {
712bc36eafdSMike Gerdts Info->Count = 0;
713bc36eafdSMike Gerdts AcpiOsPrintf ("\n");
714bc36eafdSMike Gerdts AcpiDmIndent (Info->LastLevel + 1);
715bc36eafdSMike Gerdts }
716bc36eafdSMike Gerdts
717bc36eafdSMike Gerdts /* If ASL+ is enabled, check for a C-style operator */
718bc36eafdSMike Gerdts
719bc36eafdSMike Gerdts if (AcpiDmCheckForSymbolicOpcode (Op, Info))
720bc36eafdSMike Gerdts {
721bc36eafdSMike Gerdts return (AE_OK);
722bc36eafdSMike Gerdts }
723bc36eafdSMike Gerdts
724bc36eafdSMike Gerdts /* Print the opcode name */
725bc36eafdSMike Gerdts
726bc36eafdSMike Gerdts AcpiDmDisassembleOneOp (NULL, Info, Op);
727bc36eafdSMike Gerdts
728bc36eafdSMike Gerdts if ((Op->Common.DisasmOpcode == ACPI_DASM_LNOT_PREFIX) ||
729bc36eafdSMike Gerdts (Op->Common.AmlOpcode == AML_INT_CONNECTION_OP))
730bc36eafdSMike Gerdts {
731bc36eafdSMike Gerdts return (AE_OK);
732bc36eafdSMike Gerdts }
733bc36eafdSMike Gerdts
734bc36eafdSMike Gerdts if ((Op->Common.AmlOpcode == AML_NAME_OP) ||
735bc36eafdSMike Gerdts (Op->Common.AmlOpcode == AML_RETURN_OP))
736bc36eafdSMike Gerdts {
737bc36eafdSMike Gerdts Info->Level--;
738bc36eafdSMike Gerdts }
739bc36eafdSMike Gerdts
740*35786f68SRobert Mustacchi if (Op->Common.AmlOpcode == AML_EXTERNAL_OP)
741*35786f68SRobert Mustacchi {
742*35786f68SRobert Mustacchi Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
743*35786f68SRobert Mustacchi return (AE_CTRL_DEPTH);
744*35786f68SRobert Mustacchi }
745*35786f68SRobert Mustacchi
746bc36eafdSMike Gerdts /* Start the opcode argument list if necessary */
747bc36eafdSMike Gerdts
748bc36eafdSMike Gerdts if ((OpInfo->Flags & AML_HAS_ARGS) ||
749bc36eafdSMike Gerdts (Op->Common.AmlOpcode == AML_EVENT_OP))
750bc36eafdSMike Gerdts {
751bc36eafdSMike Gerdts /* This opcode has an argument list */
752bc36eafdSMike Gerdts
753bc36eafdSMike Gerdts if (AcpiDmBlockType (Op) & BLOCK_PAREN)
754bc36eafdSMike Gerdts {
755bc36eafdSMike Gerdts AcpiOsPrintf (" (");
756*35786f68SRobert Mustacchi if (!(AcpiDmBlockType (Op) & BLOCK_BRACE))
757*35786f68SRobert Mustacchi {
758*35786f68SRobert Mustacchi ASL_CV_PRINT_ONE_COMMENT (Op, AMLCOMMENT_INLINE, " ", 0);
759*35786f68SRobert Mustacchi }
760bc36eafdSMike Gerdts }
761bc36eafdSMike Gerdts
762bc36eafdSMike Gerdts /* If this is a named opcode, print the associated name value */
763bc36eafdSMike Gerdts
764bc36eafdSMike Gerdts if (OpInfo->Flags & AML_NAMED)
765bc36eafdSMike Gerdts {
766bc36eafdSMike Gerdts switch (Op->Common.AmlOpcode)
767bc36eafdSMike Gerdts {
768bc36eafdSMike Gerdts case AML_ALIAS_OP:
769bc36eafdSMike Gerdts
770bc36eafdSMike Gerdts NextOp = AcpiPsGetDepthNext (NULL, Op);
771bc36eafdSMike Gerdts NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
772bc36eafdSMike Gerdts AcpiDmNamestring (NextOp->Common.Value.Name);
773bc36eafdSMike Gerdts AcpiOsPrintf (", ");
774bc36eafdSMike Gerdts
775bc36eafdSMike Gerdts /*lint -fallthrough */
776bc36eafdSMike Gerdts
777bc36eafdSMike Gerdts default:
778bc36eafdSMike Gerdts
779bc36eafdSMike Gerdts Name = AcpiPsGetName (Op);
780bc36eafdSMike Gerdts if (Op->Named.Path)
781bc36eafdSMike Gerdts {
782*35786f68SRobert Mustacchi AcpiDmNamestring (Op->Named.Path);
783bc36eafdSMike Gerdts }
784bc36eafdSMike Gerdts else
785bc36eafdSMike Gerdts {
786bc36eafdSMike Gerdts AcpiDmDumpName (Name);
787bc36eafdSMike Gerdts }
788bc36eafdSMike Gerdts
789bc36eafdSMike Gerdts if (Op->Common.AmlOpcode != AML_INT_NAMEDFIELD_OP)
790bc36eafdSMike Gerdts {
791bc36eafdSMike Gerdts if (AcpiGbl_DmOpt_Verbose)
792bc36eafdSMike Gerdts {
793bc36eafdSMike Gerdts (void) AcpiPsDisplayObjectPathname (NULL, Op);
794bc36eafdSMike Gerdts }
795bc36eafdSMike Gerdts }
796bc36eafdSMike Gerdts break;
797bc36eafdSMike Gerdts }
798bc36eafdSMike Gerdts
799bc36eafdSMike Gerdts switch (Op->Common.AmlOpcode)
800bc36eafdSMike Gerdts {
801bc36eafdSMike Gerdts case AML_METHOD_OP:
802bc36eafdSMike Gerdts
803bc36eafdSMike Gerdts AcpiDmMethodFlags (Op);
804*35786f68SRobert Mustacchi ASL_CV_CLOSE_PAREN (Op, Level);
805bc36eafdSMike Gerdts
806bc36eafdSMike Gerdts /* Emit description comment for Method() with a predefined ACPI name */
807bc36eafdSMike Gerdts
808bc36eafdSMike Gerdts AcpiDmPredefinedDescription (Op);
809bc36eafdSMike Gerdts break;
810bc36eafdSMike Gerdts
811bc36eafdSMike Gerdts case AML_NAME_OP:
812bc36eafdSMike Gerdts
813bc36eafdSMike Gerdts /* Check for _HID and related EISAID() */
814bc36eafdSMike Gerdts
815bc36eafdSMike Gerdts AcpiDmCheckForHardwareId (Op);
816bc36eafdSMike Gerdts AcpiOsPrintf (", ");
817*35786f68SRobert Mustacchi ASL_CV_PRINT_ONE_COMMENT (Op, AML_NAMECOMMENT, NULL, 0);
818bc36eafdSMike Gerdts break;
819bc36eafdSMike Gerdts
820bc36eafdSMike Gerdts case AML_REGION_OP:
821bc36eafdSMike Gerdts
822bc36eafdSMike Gerdts AcpiDmRegionFlags (Op);
823bc36eafdSMike Gerdts break;
824bc36eafdSMike Gerdts
825*35786f68SRobert Mustacchi case AML_POWER_RESOURCE_OP:
826bc36eafdSMike Gerdts
827bc36eafdSMike Gerdts /* Mark the next two Ops as part of the parameter list */
828bc36eafdSMike Gerdts
829bc36eafdSMike Gerdts AcpiOsPrintf (", ");
830bc36eafdSMike Gerdts NextOp = AcpiPsGetDepthNext (NULL, Op);
831bc36eafdSMike Gerdts NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
832bc36eafdSMike Gerdts
833bc36eafdSMike Gerdts NextOp = NextOp->Common.Next;
834bc36eafdSMike Gerdts NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
835bc36eafdSMike Gerdts return (AE_OK);
836bc36eafdSMike Gerdts
837bc36eafdSMike Gerdts case AML_PROCESSOR_OP:
838bc36eafdSMike Gerdts
839bc36eafdSMike Gerdts /* Mark the next three Ops as part of the parameter list */
840bc36eafdSMike Gerdts
841bc36eafdSMike Gerdts AcpiOsPrintf (", ");
842bc36eafdSMike Gerdts NextOp = AcpiPsGetDepthNext (NULL, Op);
843bc36eafdSMike Gerdts NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
844bc36eafdSMike Gerdts
845bc36eafdSMike Gerdts NextOp = NextOp->Common.Next;
846bc36eafdSMike Gerdts NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
847bc36eafdSMike Gerdts
848bc36eafdSMike Gerdts NextOp = NextOp->Common.Next;
849bc36eafdSMike Gerdts NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
850bc36eafdSMike Gerdts return (AE_OK);
851bc36eafdSMike Gerdts
852bc36eafdSMike Gerdts case AML_MUTEX_OP:
853bc36eafdSMike Gerdts case AML_DATA_REGION_OP:
854bc36eafdSMike Gerdts
855bc36eafdSMike Gerdts AcpiOsPrintf (", ");
856bc36eafdSMike Gerdts return (AE_OK);
857bc36eafdSMike Gerdts
858bc36eafdSMike Gerdts case AML_EVENT_OP:
859bc36eafdSMike Gerdts case AML_ALIAS_OP:
860bc36eafdSMike Gerdts
861bc36eafdSMike Gerdts return (AE_OK);
862bc36eafdSMike Gerdts
863bc36eafdSMike Gerdts case AML_SCOPE_OP:
864bc36eafdSMike Gerdts case AML_DEVICE_OP:
865bc36eafdSMike Gerdts case AML_THERMAL_ZONE_OP:
866bc36eafdSMike Gerdts
867*35786f68SRobert Mustacchi ASL_CV_CLOSE_PAREN (Op, Level);
868bc36eafdSMike Gerdts break;
869bc36eafdSMike Gerdts
870bc36eafdSMike Gerdts default:
871bc36eafdSMike Gerdts
872bc36eafdSMike Gerdts AcpiOsPrintf ("*** Unhandled named opcode %X\n",
873bc36eafdSMike Gerdts Op->Common.AmlOpcode);
874bc36eafdSMike Gerdts break;
875bc36eafdSMike Gerdts }
876bc36eafdSMike Gerdts }
877bc36eafdSMike Gerdts
878bc36eafdSMike Gerdts else switch (Op->Common.AmlOpcode)
879bc36eafdSMike Gerdts {
880bc36eafdSMike Gerdts case AML_FIELD_OP:
881bc36eafdSMike Gerdts case AML_BANK_FIELD_OP:
882bc36eafdSMike Gerdts case AML_INDEX_FIELD_OP:
883bc36eafdSMike Gerdts
884bc36eafdSMike Gerdts Info->BitOffset = 0;
885bc36eafdSMike Gerdts
886bc36eafdSMike Gerdts /* Name of the parent OperationRegion */
887bc36eafdSMike Gerdts
888bc36eafdSMike Gerdts NextOp = AcpiPsGetDepthNext (NULL, Op);
889bc36eafdSMike Gerdts AcpiDmNamestring (NextOp->Common.Value.Name);
890bc36eafdSMike Gerdts AcpiOsPrintf (", ");
891bc36eafdSMike Gerdts NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
892bc36eafdSMike Gerdts
893bc36eafdSMike Gerdts switch (Op->Common.AmlOpcode)
894bc36eafdSMike Gerdts {
895bc36eafdSMike Gerdts case AML_BANK_FIELD_OP:
896bc36eafdSMike Gerdts
897bc36eafdSMike Gerdts /* Namestring - Bank Name */
898bc36eafdSMike Gerdts
899bc36eafdSMike Gerdts NextOp = AcpiPsGetDepthNext (NULL, NextOp);
900bc36eafdSMike Gerdts AcpiDmNamestring (NextOp->Common.Value.Name);
901bc36eafdSMike Gerdts NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
902bc36eafdSMike Gerdts AcpiOsPrintf (", ");
903bc36eafdSMike Gerdts
904bc36eafdSMike Gerdts /*
905bc36eafdSMike Gerdts * Bank Value. This is a TermArg in the middle of the parameter
906bc36eafdSMike Gerdts * list, must handle it here.
907bc36eafdSMike Gerdts *
908bc36eafdSMike Gerdts * Disassemble the TermArg parse tree. ACPI_PARSEOP_PARAMETER_LIST
909bc36eafdSMike Gerdts * eliminates newline in the output.
910bc36eafdSMike Gerdts */
911bc36eafdSMike Gerdts NextOp = NextOp->Common.Next;
912bc36eafdSMike Gerdts
913bc36eafdSMike Gerdts Info->Flags = ACPI_PARSEOP_PARAMETER_LIST;
914bc36eafdSMike Gerdts AcpiDmWalkParseTree (NextOp, AcpiDmDescendingOp,
915bc36eafdSMike Gerdts AcpiDmAscendingOp, Info);
916bc36eafdSMike Gerdts Info->Flags = 0;
917bc36eafdSMike Gerdts Info->Level = Level;
918bc36eafdSMike Gerdts
919bc36eafdSMike Gerdts NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
920bc36eafdSMike Gerdts AcpiOsPrintf (", ");
921bc36eafdSMike Gerdts break;
922bc36eafdSMike Gerdts
923bc36eafdSMike Gerdts case AML_INDEX_FIELD_OP:
924bc36eafdSMike Gerdts
925bc36eafdSMike Gerdts /* Namestring - Data Name */
926bc36eafdSMike Gerdts
927bc36eafdSMike Gerdts NextOp = AcpiPsGetDepthNext (NULL, NextOp);
928bc36eafdSMike Gerdts AcpiDmNamestring (NextOp->Common.Value.Name);
929bc36eafdSMike Gerdts AcpiOsPrintf (", ");
930bc36eafdSMike Gerdts NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
931bc36eafdSMike Gerdts break;
932bc36eafdSMike Gerdts
933bc36eafdSMike Gerdts default:
934bc36eafdSMike Gerdts
935bc36eafdSMike Gerdts break;
936bc36eafdSMike Gerdts }
937bc36eafdSMike Gerdts
938bc36eafdSMike Gerdts AcpiDmFieldFlags (NextOp);
939bc36eafdSMike Gerdts break;
940bc36eafdSMike Gerdts
941bc36eafdSMike Gerdts case AML_BUFFER_OP:
942bc36eafdSMike Gerdts
943bc36eafdSMike Gerdts /* The next op is the size parameter */
944bc36eafdSMike Gerdts
945bc36eafdSMike Gerdts NextOp = AcpiPsGetDepthNext (NULL, Op);
946bc36eafdSMike Gerdts if (!NextOp)
947bc36eafdSMike Gerdts {
948bc36eafdSMike Gerdts /* Single-step support */
949bc36eafdSMike Gerdts
950bc36eafdSMike Gerdts return (AE_OK);
951bc36eafdSMike Gerdts }
952bc36eafdSMike Gerdts
953bc36eafdSMike Gerdts if (Op->Common.DisasmOpcode == ACPI_DASM_RESOURCE)
954bc36eafdSMike Gerdts {
955bc36eafdSMike Gerdts /*
956bc36eafdSMike Gerdts * We have a resource list. Don't need to output
957bc36eafdSMike Gerdts * the buffer size Op. Open up a new block
958bc36eafdSMike Gerdts */
959bc36eafdSMike Gerdts NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
960bc36eafdSMike Gerdts NextOp = NextOp->Common.Next;
961*35786f68SRobert Mustacchi ASL_CV_CLOSE_PAREN (Op, Level);
962bc36eafdSMike Gerdts
963bc36eafdSMike Gerdts /* Emit description comment for Name() with a predefined ACPI name */
964bc36eafdSMike Gerdts
965bc36eafdSMike Gerdts AcpiDmPredefinedDescription (Op->Asl.Parent);
966bc36eafdSMike Gerdts
967bc36eafdSMike Gerdts AcpiOsPrintf ("\n");
968bc36eafdSMike Gerdts AcpiDmIndent (Info->Level);
969bc36eafdSMike Gerdts AcpiOsPrintf ("{\n");
970bc36eafdSMike Gerdts return (AE_OK);
971bc36eafdSMike Gerdts }
972bc36eafdSMike Gerdts
973bc36eafdSMike Gerdts /* Normal Buffer, mark size as in the parameter list */
974bc36eafdSMike Gerdts
975bc36eafdSMike Gerdts NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
976bc36eafdSMike Gerdts return (AE_OK);
977bc36eafdSMike Gerdts
978bc36eafdSMike Gerdts case AML_IF_OP:
979*35786f68SRobert Mustacchi case AML_VARIABLE_PACKAGE_OP:
980bc36eafdSMike Gerdts case AML_WHILE_OP:
981bc36eafdSMike Gerdts
982bc36eafdSMike Gerdts /* The next op is the size or predicate parameter */
983bc36eafdSMike Gerdts
984bc36eafdSMike Gerdts NextOp = AcpiPsGetDepthNext (NULL, Op);
985bc36eafdSMike Gerdts if (NextOp)
986bc36eafdSMike Gerdts {
987bc36eafdSMike Gerdts NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
988bc36eafdSMike Gerdts }
989bc36eafdSMike Gerdts return (AE_OK);
990bc36eafdSMike Gerdts
991bc36eafdSMike Gerdts case AML_PACKAGE_OP:
992bc36eafdSMike Gerdts
993bc36eafdSMike Gerdts /* The next op is the size parameter */
994bc36eafdSMike Gerdts
995bc36eafdSMike Gerdts NextOp = AcpiPsGetDepthNext (NULL, Op);
996bc36eafdSMike Gerdts if (NextOp)
997bc36eafdSMike Gerdts {
998bc36eafdSMike Gerdts NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
999bc36eafdSMike Gerdts }
1000bc36eafdSMike Gerdts return (AE_OK);
1001bc36eafdSMike Gerdts
1002bc36eafdSMike Gerdts case AML_MATCH_OP:
1003bc36eafdSMike Gerdts
1004bc36eafdSMike Gerdts AcpiDmMatchOp (Op);
1005bc36eafdSMike Gerdts break;
1006bc36eafdSMike Gerdts
1007bc36eafdSMike Gerdts default:
1008bc36eafdSMike Gerdts
1009bc36eafdSMike Gerdts break;
1010bc36eafdSMike Gerdts }
1011bc36eafdSMike Gerdts
1012bc36eafdSMike Gerdts if (AcpiDmBlockType (Op) & BLOCK_BRACE)
1013bc36eafdSMike Gerdts {
1014bc36eafdSMike Gerdts AcpiOsPrintf ("\n");
1015bc36eafdSMike Gerdts AcpiDmIndent (Level);
1016bc36eafdSMike Gerdts AcpiOsPrintf ("{\n");
1017bc36eafdSMike Gerdts }
1018bc36eafdSMike Gerdts }
1019bc36eafdSMike Gerdts
1020bc36eafdSMike Gerdts return (AE_OK);
1021bc36eafdSMike Gerdts }
1022bc36eafdSMike Gerdts
1023bc36eafdSMike Gerdts
1024bc36eafdSMike Gerdts /*******************************************************************************
1025bc36eafdSMike Gerdts *
1026bc36eafdSMike Gerdts * FUNCTION: AcpiDmAscendingOp
1027bc36eafdSMike Gerdts *
1028bc36eafdSMike Gerdts * PARAMETERS: ASL_WALK_CALLBACK
1029bc36eafdSMike Gerdts *
1030bc36eafdSMike Gerdts * RETURN: Status
1031bc36eafdSMike Gerdts *
1032bc36eafdSMike Gerdts * DESCRIPTION: Second visitation of a parse object, during ascent of parse
1033bc36eafdSMike Gerdts * tree. Close out any parameter lists and complete the opcode.
1034bc36eafdSMike Gerdts *
1035bc36eafdSMike Gerdts ******************************************************************************/
1036bc36eafdSMike Gerdts
1037bc36eafdSMike Gerdts static ACPI_STATUS
AcpiDmAscendingOp(ACPI_PARSE_OBJECT * Op,UINT32 Level,void * Context)1038bc36eafdSMike Gerdts AcpiDmAscendingOp (
1039bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *Op,
1040bc36eafdSMike Gerdts UINT32 Level,
1041bc36eafdSMike Gerdts void *Context)
1042bc36eafdSMike Gerdts {
1043bc36eafdSMike Gerdts ACPI_OP_WALK_INFO *Info = Context;
1044bc36eafdSMike Gerdts ACPI_PARSE_OBJECT *ParentOp;
1045bc36eafdSMike Gerdts
1046bc36eafdSMike Gerdts
1047*35786f68SRobert Mustacchi /* Point the Op's filename pointer to the proper file */
1048*35786f68SRobert Mustacchi
1049*35786f68SRobert Mustacchi if (AcpiGbl_CaptureComments)
1050*35786f68SRobert Mustacchi {
1051*35786f68SRobert Mustacchi ASL_CV_LABEL_FILENODE (Op);
1052*35786f68SRobert Mustacchi
1053*35786f68SRobert Mustacchi /* Switch the output of these files if necessary */
1054*35786f68SRobert Mustacchi
1055*35786f68SRobert Mustacchi if (ASL_CV_FILE_HAS_SWITCHED (Op))
1056*35786f68SRobert Mustacchi {
1057*35786f68SRobert Mustacchi ASL_CV_SWITCH_FILES (Level, Op);
1058*35786f68SRobert Mustacchi }
1059*35786f68SRobert Mustacchi }
1060*35786f68SRobert Mustacchi
1061*35786f68SRobert Mustacchi if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE ||
1062*35786f68SRobert Mustacchi Op->Common.DisasmOpcode == ACPI_DASM_IGNORE_SINGLE)
1063bc36eafdSMike Gerdts {
1064bc36eafdSMike Gerdts /* Ignore this op -- it was handled elsewhere */
1065bc36eafdSMike Gerdts
1066bc36eafdSMike Gerdts return (AE_OK);
1067bc36eafdSMike Gerdts }
1068bc36eafdSMike Gerdts
1069bc36eafdSMike Gerdts if ((Level == 0) && (Op->Common.AmlOpcode == AML_SCOPE_OP))
1070bc36eafdSMike Gerdts {
1071bc36eafdSMike Gerdts /* Indicates the end of the current descriptor block (table) */
1072bc36eafdSMike Gerdts
1073*35786f68SRobert Mustacchi ASL_CV_CLOSE_BRACE (Op, Level);
1074*35786f68SRobert Mustacchi
1075*35786f68SRobert Mustacchi /* Print any comments that are at the end of the file here */
1076*35786f68SRobert Mustacchi
1077*35786f68SRobert Mustacchi if (AcpiGbl_CaptureComments && AcpiGbl_LastListHead)
1078*35786f68SRobert Mustacchi {
1079*35786f68SRobert Mustacchi AcpiOsPrintf ("\n");
1080*35786f68SRobert Mustacchi ASL_CV_PRINT_ONE_COMMENT_LIST (AcpiGbl_LastListHead, 0);
1081*35786f68SRobert Mustacchi }
1082*35786f68SRobert Mustacchi AcpiOsPrintf ("\n\n");
1083*35786f68SRobert Mustacchi
1084bc36eafdSMike Gerdts return (AE_OK);
1085bc36eafdSMike Gerdts }
1086bc36eafdSMike Gerdts
1087bc36eafdSMike Gerdts switch (AcpiDmBlockType (Op))
1088bc36eafdSMike Gerdts {
1089bc36eafdSMike Gerdts case BLOCK_PAREN:
1090bc36eafdSMike Gerdts
1091bc36eafdSMike Gerdts /* Completed an op that has arguments, add closing paren if needed */
1092bc36eafdSMike Gerdts
1093bc36eafdSMike Gerdts AcpiDmCloseOperator (Op);
1094bc36eafdSMike Gerdts
1095bc36eafdSMike Gerdts if (Op->Common.AmlOpcode == AML_NAME_OP)
1096bc36eafdSMike Gerdts {
1097bc36eafdSMike Gerdts /* Emit description comment for Name() with a predefined ACPI name */
1098bc36eafdSMike Gerdts
1099bc36eafdSMike Gerdts AcpiDmPredefinedDescription (Op);
1100bc36eafdSMike Gerdts }
1101bc36eafdSMike Gerdts else
1102bc36eafdSMike Gerdts {
1103bc36eafdSMike Gerdts /* For Create* operators, attempt to emit resource tag description */
1104bc36eafdSMike Gerdts
1105bc36eafdSMike Gerdts AcpiDmFieldPredefinedDescription (Op);
1106bc36eafdSMike Gerdts }
1107bc36eafdSMike Gerdts
1108bc36eafdSMike Gerdts /* Decode Notify() values */
1109bc36eafdSMike Gerdts
1110bc36eafdSMike Gerdts if (Op->Common.AmlOpcode == AML_NOTIFY_OP)
1111bc36eafdSMike Gerdts {
1112bc36eafdSMike Gerdts AcpiDmNotifyDescription (Op);
1113bc36eafdSMike Gerdts }
1114bc36eafdSMike Gerdts
1115bc36eafdSMike Gerdts AcpiDmDisplayTargetPathname (Op);
1116bc36eafdSMike Gerdts
1117bc36eafdSMike Gerdts /* Could be a nested operator, check if comma required */
1118bc36eafdSMike Gerdts
1119bc36eafdSMike Gerdts if (!AcpiDmCommaIfListMember (Op))
1120bc36eafdSMike Gerdts {
1121bc36eafdSMike Gerdts if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
1122bc36eafdSMike Gerdts (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)) &&
1123bc36eafdSMike Gerdts (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))
1124bc36eafdSMike Gerdts {
1125bc36eafdSMike Gerdts /*
1126bc36eafdSMike Gerdts * This is a first-level element of a term list
1127bc36eafdSMike Gerdts * start a new line
1128bc36eafdSMike Gerdts */
1129bc36eafdSMike Gerdts if (!(Info->Flags & ACPI_PARSEOP_PARAMETER_LIST))
1130bc36eafdSMike Gerdts {
1131bc36eafdSMike Gerdts AcpiOsPrintf ("\n");
1132bc36eafdSMike Gerdts }
1133bc36eafdSMike Gerdts }
1134bc36eafdSMike Gerdts }
1135bc36eafdSMike Gerdts break;
1136bc36eafdSMike Gerdts
1137bc36eafdSMike Gerdts case BLOCK_BRACE:
1138bc36eafdSMike Gerdts case (BLOCK_BRACE | BLOCK_PAREN):
1139bc36eafdSMike Gerdts
1140bc36eafdSMike Gerdts /* Completed an op that has a term list, add closing brace */
1141bc36eafdSMike Gerdts
1142bc36eafdSMike Gerdts if (Op->Common.DisasmFlags & ACPI_PARSEOP_EMPTY_TERMLIST)
1143bc36eafdSMike Gerdts {
1144*35786f68SRobert Mustacchi ASL_CV_CLOSE_BRACE (Op, Level);
1145bc36eafdSMike Gerdts }
1146bc36eafdSMike Gerdts else
1147bc36eafdSMike Gerdts {
1148bc36eafdSMike Gerdts AcpiDmIndent (Level);
1149*35786f68SRobert Mustacchi ASL_CV_CLOSE_BRACE (Op, Level);
1150bc36eafdSMike Gerdts }
1151bc36eafdSMike Gerdts
1152bc36eafdSMike Gerdts AcpiDmCommaIfListMember (Op);
1153bc36eafdSMike Gerdts
1154bc36eafdSMike Gerdts if (AcpiDmBlockType (Op->Common.Parent) != BLOCK_PAREN)
1155bc36eafdSMike Gerdts {
1156bc36eafdSMike Gerdts AcpiOsPrintf ("\n");
1157bc36eafdSMike Gerdts if (!(Op->Common.DisasmFlags & ACPI_PARSEOP_EMPTY_TERMLIST))
1158bc36eafdSMike Gerdts {
1159bc36eafdSMike Gerdts if ((Op->Common.AmlOpcode == AML_IF_OP) &&
1160bc36eafdSMike Gerdts (Op->Common.Next) &&
1161bc36eafdSMike Gerdts (Op->Common.Next->Common.AmlOpcode == AML_ELSE_OP))
1162bc36eafdSMike Gerdts {
1163bc36eafdSMike Gerdts break;
1164bc36eafdSMike Gerdts }
1165bc36eafdSMike Gerdts
1166bc36eafdSMike Gerdts if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
1167bc36eafdSMike Gerdts (!Op->Common.Next))
1168bc36eafdSMike Gerdts {
1169bc36eafdSMike Gerdts break;
1170bc36eafdSMike Gerdts }
1171bc36eafdSMike Gerdts AcpiOsPrintf ("\n");
1172bc36eafdSMike Gerdts }
1173bc36eafdSMike Gerdts }
1174bc36eafdSMike Gerdts break;
1175bc36eafdSMike Gerdts
1176bc36eafdSMike Gerdts case BLOCK_NONE:
1177bc36eafdSMike Gerdts default:
1178bc36eafdSMike Gerdts
1179bc36eafdSMike Gerdts /* Could be a nested operator, check if comma required */
1180bc36eafdSMike Gerdts
1181bc36eafdSMike Gerdts if (!AcpiDmCommaIfListMember (Op))
1182bc36eafdSMike Gerdts {
1183bc36eafdSMike Gerdts if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
1184bc36eafdSMike Gerdts (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)) &&
1185bc36eafdSMike Gerdts (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))
1186bc36eafdSMike Gerdts {
1187bc36eafdSMike Gerdts /*
1188bc36eafdSMike Gerdts * This is a first-level element of a term list
1189bc36eafdSMike Gerdts * start a new line
1190bc36eafdSMike Gerdts */
1191bc36eafdSMike Gerdts AcpiOsPrintf ("\n");
1192bc36eafdSMike Gerdts }
1193bc36eafdSMike Gerdts }
1194bc36eafdSMike Gerdts else if (Op->Common.Parent)
1195bc36eafdSMike Gerdts {
1196bc36eafdSMike Gerdts switch (Op->Common.Parent->Common.AmlOpcode)
1197bc36eafdSMike Gerdts {
1198bc36eafdSMike Gerdts case AML_PACKAGE_OP:
1199*35786f68SRobert Mustacchi case AML_VARIABLE_PACKAGE_OP:
1200bc36eafdSMike Gerdts
1201bc36eafdSMike Gerdts if (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST))
1202bc36eafdSMike Gerdts {
1203bc36eafdSMike Gerdts AcpiOsPrintf ("\n");
1204bc36eafdSMike Gerdts }
1205bc36eafdSMike Gerdts break;
1206bc36eafdSMike Gerdts
1207bc36eafdSMike Gerdts default:
1208bc36eafdSMike Gerdts
1209bc36eafdSMike Gerdts break;
1210bc36eafdSMike Gerdts }
1211bc36eafdSMike Gerdts }
1212bc36eafdSMike Gerdts break;
1213bc36eafdSMike Gerdts }
1214bc36eafdSMike Gerdts
1215bc36eafdSMike Gerdts if (Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST)
1216bc36eafdSMike Gerdts {
1217bc36eafdSMike Gerdts if ((Op->Common.Next) &&
1218bc36eafdSMike Gerdts (Op->Common.Next->Common.DisasmFlags & ACPI_PARSEOP_PARAMETER_LIST))
1219bc36eafdSMike Gerdts {
1220bc36eafdSMike Gerdts return (AE_OK);
1221bc36eafdSMike Gerdts }
1222bc36eafdSMike Gerdts
1223bc36eafdSMike Gerdts /*
1224bc36eafdSMike Gerdts * The parent Op is guaranteed to be valid because of the flag
1225bc36eafdSMike Gerdts * ACPI_PARSEOP_PARAMETER_LIST -- which means that this op is part of
1226bc36eafdSMike Gerdts * a parameter list and thus has a valid parent.
1227bc36eafdSMike Gerdts */
1228bc36eafdSMike Gerdts ParentOp = Op->Common.Parent;
1229bc36eafdSMike Gerdts
1230bc36eafdSMike Gerdts /*
1231bc36eafdSMike Gerdts * Just completed a parameter node for something like "Buffer (param)".
1232*35786f68SRobert Mustacchi * Close the paren and open up the term list block with a brace.
1233*35786f68SRobert Mustacchi *
1234*35786f68SRobert Mustacchi * Switch predicates don't have a Next node but require a closing paren
1235*35786f68SRobert Mustacchi * and opening brace.
1236bc36eafdSMike Gerdts */
1237*35786f68SRobert Mustacchi if (Op->Common.Next || Op->Common.DisasmOpcode == ACPI_DASM_SWITCH_PREDICATE)
1238bc36eafdSMike Gerdts {
1239*35786f68SRobert Mustacchi ASL_CV_CLOSE_PAREN (Op, Level);
1240bc36eafdSMike Gerdts
1241bc36eafdSMike Gerdts /*
1242bc36eafdSMike Gerdts * Emit a description comment for a Name() operator that is a
1243bc36eafdSMike Gerdts * predefined ACPI name. Must check the grandparent.
1244bc36eafdSMike Gerdts */
1245bc36eafdSMike Gerdts ParentOp = ParentOp->Common.Parent;
1246bc36eafdSMike Gerdts if (ParentOp &&
1247bc36eafdSMike Gerdts (ParentOp->Asl.AmlOpcode == AML_NAME_OP))
1248bc36eafdSMike Gerdts {
1249bc36eafdSMike Gerdts AcpiDmPredefinedDescription (ParentOp);
1250bc36eafdSMike Gerdts }
1251bc36eafdSMike Gerdts
1252*35786f68SRobert Mustacchi /* Correct the indentation level for Switch and Case predicates */
1253*35786f68SRobert Mustacchi
1254*35786f68SRobert Mustacchi if (Op->Common.DisasmOpcode == ACPI_DASM_SWITCH_PREDICATE)
1255*35786f68SRobert Mustacchi {
1256*35786f68SRobert Mustacchi --Level;
1257*35786f68SRobert Mustacchi }
1258*35786f68SRobert Mustacchi
1259bc36eafdSMike Gerdts AcpiOsPrintf ("\n");
1260bc36eafdSMike Gerdts AcpiDmIndent (Level - 1);
1261bc36eafdSMike Gerdts AcpiOsPrintf ("{\n");
1262bc36eafdSMike Gerdts }
1263bc36eafdSMike Gerdts else
1264bc36eafdSMike Gerdts {
1265bc36eafdSMike Gerdts ParentOp->Common.DisasmFlags |= ACPI_PARSEOP_EMPTY_TERMLIST;
1266*35786f68SRobert Mustacchi ASL_CV_CLOSE_PAREN (Op, Level);
1267*35786f68SRobert Mustacchi AcpiOsPrintf ("{");
1268bc36eafdSMike Gerdts }
1269bc36eafdSMike Gerdts }
1270bc36eafdSMike Gerdts
1271bc36eafdSMike Gerdts if ((Op->Common.AmlOpcode == AML_NAME_OP) ||
1272bc36eafdSMike Gerdts (Op->Common.AmlOpcode == AML_RETURN_OP))
1273bc36eafdSMike Gerdts {
1274bc36eafdSMike Gerdts Info->Level++;
1275bc36eafdSMike Gerdts }
1276bc36eafdSMike Gerdts
1277bc36eafdSMike Gerdts /*
1278bc36eafdSMike Gerdts * For ASL+, check for and emit a C-style symbol. If valid, the
1279bc36eafdSMike Gerdts * symbol string has been deferred until after the first operand
1280bc36eafdSMike Gerdts */
1281bc36eafdSMike Gerdts if (AcpiGbl_CstyleDisassembly)
1282bc36eafdSMike Gerdts {
1283bc36eafdSMike Gerdts if (Op->Asl.OperatorSymbol)
1284bc36eafdSMike Gerdts {
1285bc36eafdSMike Gerdts AcpiOsPrintf ("%s", Op->Asl.OperatorSymbol);
1286bc36eafdSMike Gerdts Op->Asl.OperatorSymbol = NULL;
1287bc36eafdSMike Gerdts }
1288bc36eafdSMike Gerdts }
1289bc36eafdSMike Gerdts
1290bc36eafdSMike Gerdts return (AE_OK);
1291bc36eafdSMike Gerdts }
1292