dbdisply.c revision 77424
1194676Sthompsa/*******************************************************************************
2194676Sthompsa *
3194676Sthompsa * Module Name: dbdisply - debug display commands
4195957Salfred *              $Revision: 45 $
5194676Sthompsa *
6194676Sthompsa ******************************************************************************/
7194676Sthompsa
8194676Sthompsa/******************************************************************************
9194676Sthompsa *
10194676Sthompsa * 1. Copyright Notice
11194676Sthompsa *
12194676Sthompsa * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
13194676Sthompsa * All rights reserved.
14194676Sthompsa *
15194676Sthompsa * 2. License
16194676Sthompsa *
17194676Sthompsa * 2.1. This is your license from Intel Corp. under its intellectual property
18194676Sthompsa * rights.  You may have additional license terms from the party that provided
19194676Sthompsa * you this software, covering your right to use that party's intellectual
20194676Sthompsa * property rights.
21194676Sthompsa *
22194676Sthompsa * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23194676Sthompsa * copy of the source code appearing in this file ("Covered Code") an
24194676Sthompsa * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25194676Sthompsa * base code distributed originally by Intel ("Original Intel Code") to copy,
26194676Sthompsa * make derivatives, distribute, use and display any portion of the Covered
27194676Sthompsa * Code in any form, with the right to sublicense such rights; and
28203815Swkoszek *
29203815Swkoszek * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30203815Swkoszek * license (with the right to sublicense), under only those claims of Intel
31203815Swkoszek * patents that are infringed by the Original Intel Code, to make, use, sell,
32203774Swkoszek * offer to sell, and import the Covered Code and derivative works thereof
33203815Swkoszek * solely to the minimum extent necessary to exercise the above copyright
34203815Swkoszek * license, and in no event shall the patent license extend to any additions
35203815Swkoszek * to or modifications of the Original Intel Code.  No other license or right
36203815Swkoszek * is granted directly or by implication, estoppel or otherwise;
37194676Sthompsa *
38194676Sthompsa * The above copyright and patent license is granted only if the following
39194676Sthompsa * conditions are met:
40208020Sthompsa *
41208020Sthompsa * 3. Conditions
42194676Sthompsa *
43194676Sthompsa * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44194676Sthompsa * Redistribution of source code of any substantial portion of the Covered
45194676Sthompsa * Code or modification with rights to further distribute source must include
46194676Sthompsa * the above Copyright Notice, the above License, this list of Conditions,
47194676Sthompsa * and the following Disclaimer and Export Compliance provision.  In addition,
48194676Sthompsa * Licensee must cause all Covered Code to which Licensee contributes to
49194676Sthompsa * contain a file documenting the changes Licensee made to create that Covered
50194676Sthompsa * Code and the date of any change.  Licensee must include in that file the
51195957Salfred * documentation of any changes made by any predecessor Licensee.  Licensee
52195957Salfred * must include a prominent statement that the modification is derived,
53195957Salfred * directly or indirectly, from Original Intel Code.
54195957Salfred *
55195957Salfred * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56195957Salfred * Redistribution of source code of any substantial portion of the Covered
57195957Salfred * Code or modification without rights to further distribute source must
58195957Salfred * include the following Disclaimer and Export Compliance provision in the
59195957Salfred * documentation and/or other materials provided with distribution.  In
60195957Salfred * addition, Licensee may not authorize further sublicense of source of any
61195957Salfred * portion of the Covered Code, and must include terms to the effect that the
62194676Sthompsa * license from Licensee to its licensee is limited to the intellectual
63194676Sthompsa * property embodied in the software Licensee provides to its licensee, and
64194676Sthompsa * not to intellectual property embodied in modifications its licensee may
65195957Salfred * make.
66194676Sthompsa *
67195957Salfred * 3.3. Redistribution of Executable. Redistribution in executable form of any
68194676Sthompsa * substantial portion of the Covered Code or modification must reproduce the
69194676Sthompsa * above Copyright Notice, and the following Disclaimer and Export Compliance
70194676Sthompsa * provision in the documentation and/or other materials provided with the
71194676Sthompsa * distribution.
72213853Shselasky *
73213853Shselasky * 3.4. Intel retains all right, title, and interest in and to the Original
74213853Shselasky * Intel Code.
75213853Shselasky *
76213853Shselasky * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77213853Shselasky * Intel shall be used in advertising or otherwise to promote the sale, use or
78213853Shselasky * other dealings in products derived from or relating to the Covered Code
79213853Shselasky * without prior written authorization from Intel.
80213853Shselasky *
81213853Shselasky * 4. Disclaimer and Export Compliance
82213853Shselasky *
83213853Shselasky * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84213853Shselasky * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85213853Shselasky * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86213853Shselasky * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87213853Shselasky * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88213853Shselasky * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89213853Shselasky * PARTICULAR PURPOSE.
90213853Shselasky *
91194676Sthompsa * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92195957Salfred * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93194676Sthompsa * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94194676Sthompsa * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95195957Salfred * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96194676Sthompsa * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97194676Sthompsa * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98194676Sthompsa * LIMITED REMEDY.
99194676Sthompsa *
100194676Sthompsa * 4.3. Licensee shall not export, either directly or indirectly, any of this
101194676Sthompsa * software or system incorporating such software without first obtaining any
102194676Sthompsa * required license or other approval from the U. S. Department of Commerce or
103194676Sthompsa * any other agency or department of the United States Government.  In the
104194676Sthompsa * event Licensee exports any such software from the United States or
105194676Sthompsa * re-exports any such software from a foreign destination, Licensee shall
106194676Sthompsa * ensure that the distribution and export/re-export of the software is in
107194676Sthompsa * compliance with all laws, regulations, orders, or other restrictions of the
108194676Sthompsa * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109194676Sthompsa * any of its subsidiaries will export/re-export any technical data, process,
110195957Salfred * software, or service, directly or indirectly, to any country for which the
111195957Salfred * United States government or any agency thereof requires an export license,
112194676Sthompsa * other governmental approval, or letter of assurance, without first obtaining
113195957Salfred * such license, approval or letter.
114195957Salfred *
115194676Sthompsa *****************************************************************************/
116195957Salfred
117194676Sthompsa
118194676Sthompsa#include "acpi.h"
119194676Sthompsa#include "acparser.h"
120195957Salfred#include "amlcode.h"
121195957Salfred#include "acdispat.h"
122194676Sthompsa#include "acnamesp.h"
123194676Sthompsa#include "acparser.h"
124194676Sthompsa#include "acevents.h"
125195957Salfred#include "acinterp.h"
126213853Shselasky#include "acdebug.h"
127213853Shselasky
128194676Sthompsa
129195957Salfred#ifdef ENABLE_DEBUGGER
130194676Sthompsa
131194676Sthompsa
132194676Sthompsa#define _COMPONENT          ACPI_DEBUGGER
133194676Sthompsa        MODULE_NAME         ("dbdisply")
134194676Sthompsa
135194676Sthompsa
136194676Sthompsa/******************************************************************************
137194676Sthompsa *
138194676Sthompsa * FUNCTION:    AcpiDbGetPointer
139194676Sthompsa *
140195957Salfred * PARAMETERS:  Target          - Pointer to string to be converted
141195957Salfred *
142194676Sthompsa * RETURN:      Converted pointer
143194676Sthompsa *
144194676Sthompsa * DESCRIPTION: Convert an ascii pointer value to a real value
145194676Sthompsa *
146195957Salfred *****************************************************************************/
147194676Sthompsa
148195957Salfredvoid *
149194676SthompsaAcpiDbGetPointer (
150195957Salfred    void                    *Target)
151195957Salfred{
152195957Salfred    void                    *ObjPtr;
153195957Salfred
154195957Salfred
155195957Salfred#ifdef _IA16
156194676Sthompsa#include <stdio.h>
157194676Sthompsa
158195957Salfred    /* Have to handle 16-bit pointers of the form segment:offset */
159195957Salfred
160194676Sthompsa    if (!sscanf (Target, "%p", &ObjPtr))
161194676Sthompsa    {
162194676Sthompsa        AcpiOsPrintf ("Invalid pointer: %s\n", Target);
163194676Sthompsa        return (NULL);
164194676Sthompsa    }
165194676Sthompsa
166194676Sthompsa#else
167194676Sthompsa
168194676Sthompsa    /* Simple flat pointer */
169194676Sthompsa
170194676Sthompsa    ObjPtr = (void *) STRTOUL (Target, NULL, 16);
171194676Sthompsa
172194676Sthompsa#endif
173195957Salfred
174194676Sthompsa    return (ObjPtr);
175195957Salfred}
176194676Sthompsa
177194676Sthompsa
178194676Sthompsa/*******************************************************************************
179194676Sthompsa *
180195957Salfred * FUNCTION:    AcpiDbDumpParserDescriptor
181194676Sthompsa *
182195957Salfred * PARAMETERS:  Op              - A parser Op descriptor
183195957Salfred *
184195957Salfred * RETURN:      None
185195957Salfred *
186195957Salfred * DESCRIPTION: Display a formatted parser object
187195957Salfred *
188194676Sthompsa ******************************************************************************/
189194676Sthompsa
190195957Salfredvoid
191194676SthompsaAcpiDbDumpParserDescriptor (
192195957Salfred    ACPI_PARSE_OBJECT       *Op)
193194676Sthompsa{
194194676Sthompsa    ACPI_OPCODE_INFO        *Info;
195194676Sthompsa
196194676Sthompsa
197194676Sthompsa    Info = AcpiPsGetOpcodeInfo (Op->Opcode);
198195957Salfred
199194676Sthompsa    AcpiOsPrintf ("Parser Op Descriptor:\n");
200194676Sthompsa    AcpiOsPrintf ("%20.20s : %4.4X\n", "Opcode", Op->Opcode);
201194676Sthompsa
202194676Sthompsa    DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name", Info->Name));
203194676Sthompsa
204195957Salfred    AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Value);
205194676Sthompsa    AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Parent);
206194676Sthompsa    AcpiOsPrintf ("%20.20s : %p\n", "NextOp", Op->Next);
207194676Sthompsa}
208194676Sthompsa
209194676Sthompsa
210195560Sthompsa/*******************************************************************************
211195560Sthompsa *
212195560Sthompsa * FUNCTION:    AcpiDbDecodeAndDisplayObject
213195560Sthompsa *
214194676Sthompsa * PARAMETERS:  Target          - String with object to be displayed.  Names
215195957Salfred *                                and hex pointers are supported.
216194676Sthompsa *              OutputType      - Byte, Word, Dword, or Qword (B|W|D|Q)
217194676Sthompsa *
218194676Sthompsa * RETURN:      None
219199055Sthompsa *
220199055Sthompsa * DESCRIPTION: Display a formatted ACPI object
221199055Sthompsa *
222199055Sthompsa ******************************************************************************/
223194676Sthompsa
224194676Sthompsavoid
225195957SalfredAcpiDbDecodeAndDisplayObject (
226195957Salfred    NATIVE_CHAR             *Target,
227195957Salfred    NATIVE_CHAR             *OutputType)
228195957Salfred{
229194676Sthompsa    void                    *ObjPtr;
230194676Sthompsa    ACPI_NAMESPACE_NODE     *Node;
231194676Sthompsa    UINT32                  Display = DB_BYTE_DISPLAY;
232194676Sthompsa    NATIVE_CHAR             Buffer[80];
233195957Salfred    ACPI_BUFFER             RetBuf;
234194676Sthompsa    ACPI_STATUS             Status;
235194676Sthompsa    UINT32                  Size;
236194676Sthompsa
237194676Sthompsa
238194676Sthompsa    if (!Target)
239194676Sthompsa    {
240194676Sthompsa        return;
241194676Sthompsa    }
242194676Sthompsa
243194676Sthompsa    /* Decode the output type */
244194676Sthompsa
245194676Sthompsa    if (OutputType)
246194676Sthompsa    {
247194676Sthompsa        STRUPR (OutputType);
248194676Sthompsa        if (OutputType[0] == 'W')
249194676Sthompsa        {
250195957Salfred            Display = DB_WORD_DISPLAY;
251194676Sthompsa        }
252194676Sthompsa        else if (OutputType[0] == 'D')
253194676Sthompsa        {
254194676Sthompsa            Display = DB_DWORD_DISPLAY;
255194676Sthompsa        }
256194676Sthompsa        else if (OutputType[0] == 'Q')
257194676Sthompsa        {
258194676Sthompsa            Display = DB_QWORD_DISPLAY;
259194676Sthompsa        }
260195957Salfred    }
261194676Sthompsa
262194676Sthompsa
263195957Salfred    RetBuf.Length = sizeof (Buffer);
264195957Salfred    RetBuf.Pointer = Buffer;
265194676Sthompsa
266194676Sthompsa    /* Differentiate between a number and a name */
267194676Sthompsa
268195957Salfred    if ((Target[0] >= 0x30) && (Target[0] <= 0x39))
269194676Sthompsa    {
270194676Sthompsa        ObjPtr = AcpiDbGetPointer (Target);
271195957Salfred        if (!AcpiOsReadable (ObjPtr, 16))
272195957Salfred        {
273194676Sthompsa            AcpiOsPrintf ("Address %p is invalid in this address space\n", ObjPtr);
274194676Sthompsa            return;
275224903Shselasky        }
276224903Shselasky
277224903Shselasky        /* Decode the object type */
278224903Shselasky
279225035Shselasky        if (VALID_DESCRIPTOR_TYPE ((ObjPtr), ACPI_DESC_TYPE_NAMED))
280224903Shselasky        {
281224903Shselasky            /* This is a Node */
282224903Shselasky
283224903Shselasky            if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE)))
284224903Shselasky            {
285224903Shselasky                AcpiOsPrintf ("Cannot read entire Named object at address %p\n", ObjPtr);
286224903Shselasky                return;
287224903Shselasky            }
288224903Shselasky
289224903Shselasky            Node = ObjPtr;
290224903Shselasky            goto DumpNte;
291224903Shselasky        }
292224903Shselasky
293224903Shselasky        else if (VALID_DESCRIPTOR_TYPE ((ObjPtr), ACPI_DESC_TYPE_INTERNAL))
294224903Shselasky        {
295224903Shselasky            /* This is an ACPI OBJECT */
296194676Sthompsa
297195957Salfred            if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT)))
298194676Sthompsa            {
299194676Sthompsa                AcpiOsPrintf ("Cannot read entire ACPI object at address %p\n", ObjPtr);
300194676Sthompsa                return;
301194676Sthompsa            }
302194676Sthompsa
303195957Salfred            AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX);
304195957Salfred            AcpiExDumpObjectDescriptor (ObjPtr, 1);
305195957Salfred        }
306195957Salfred
307194676Sthompsa        else if (VALID_DESCRIPTOR_TYPE ((ObjPtr), ACPI_DESC_TYPE_PARSER))
308194676Sthompsa        {
309194676Sthompsa            /* This is an Parser Op object */
310194676Sthompsa
311195957Salfred            if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT)))
312195957Salfred            {
313195957Salfred                AcpiOsPrintf ("Cannot read entire Parser object at address %p\n", ObjPtr);
314195957Salfred                return;
315194676Sthompsa            }
316195957Salfred
317194676Sthompsa
318195957Salfred            AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), Display, ACPI_UINT32_MAX);
319194676Sthompsa            AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr);
320195957Salfred        }
321194676Sthompsa
322194676Sthompsa        else
323194676Sthompsa        {
324194676Sthompsa            Size = 16;
325194676Sthompsa            if (AcpiOsReadable (ObjPtr, 64))
326194676Sthompsa            {
327194676Sthompsa                Size = 64;
328194676Sthompsa            }
329194676Sthompsa
330194676Sthompsa            /* Just dump some memory */
331194676Sthompsa
332194676Sthompsa            AcpiUtDumpBuffer (ObjPtr, Size, Display, ACPI_UINT32_MAX);
333194676Sthompsa        }
334194676Sthompsa
335194676Sthompsa        return;
336195957Salfred    }
337194676Sthompsa
338194676Sthompsa
339195957Salfred    /* The parameter is a name string that must be resolved to a Named obj */
340194676Sthompsa
341195957Salfred    Node = AcpiDbLocalNsLookup (Target);
342194676Sthompsa    if (!Node)
343195957Salfred    {
344194676Sthompsa        return;
345194676Sthompsa    }
346194676Sthompsa
347194676Sthompsa
348194676SthompsaDumpNte:
349195957Salfred    /* Now dump the Named obj */
350194676Sthompsa
351194676Sthompsa    Status = AcpiGetName (Node, ACPI_FULL_PATHNAME, &RetBuf);
352195957Salfred    if (ACPI_FAILURE (Status))
353194676Sthompsa    {
354195957Salfred        AcpiOsPrintf ("Could not convert name to pathname\n");
355194676Sthompsa    }
356195957Salfred
357194676Sthompsa    else
358194676Sthompsa    {
359194676Sthompsa        AcpiOsPrintf ("Object Pathname:  %s\n", RetBuf.Pointer);
360194676Sthompsa    }
361194676Sthompsa
362194676Sthompsa    if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
363194676Sthompsa    {
364194676Sthompsa        AcpiOsPrintf ("Invalid Named object at address %p\n", Node);
365195957Salfred        return;
366194676Sthompsa    }
367194676Sthompsa
368194676Sthompsa    AcpiUtDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE), Display, ACPI_UINT32_MAX);
369195957Salfred    AcpiExDumpNode (Node, 1);
370194676Sthompsa
371194676Sthompsa    if (Node->Object)
372194676Sthompsa    {
373194676Sthompsa        AcpiOsPrintf ("\nAttached Object (%p):\n", Node->Object);
374194676Sthompsa        if (!AcpiOsReadable (Node->Object, sizeof (ACPI_OPERAND_OBJECT)))
375195957Salfred        {
376195957Salfred            AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n", Node->Object);
377194676Sthompsa            return;
378195957Salfred        }
379195957Salfred
380195957Salfred        AcpiUtDumpBuffer (Node->Object, sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX);
381195957Salfred        AcpiExDumpObjectDescriptor (Node->Object, 1);
382194676Sthompsa    }
383194676Sthompsa}
384195957Salfred
385194676Sthompsa
386194676Sthompsa/*******************************************************************************
387195957Salfred *
388194676Sthompsa * FUNCTION:    AcpiDbDecodeInternalObject
389194676Sthompsa *
390195957Salfred * PARAMETERS:  ObjDesc         - Object to be displayed
391195957Salfred *
392194676Sthompsa * RETURN:      None
393213853Shselasky *
394195957Salfred * DESCRIPTION: Short display of an internal object.  Numbers and Strings.
395195957Salfred *
396194676Sthompsa ******************************************************************************/
397195957Salfred
398194676Sthompsavoid
399194676SthompsaAcpiDbDecodeInternalObject (
400194676Sthompsa    ACPI_OPERAND_OBJECT     *ObjDesc)
401194676Sthompsa{
402194676Sthompsa    UINT32                  i;
403195957Salfred
404194676Sthompsa
405194676Sthompsa    if (!ObjDesc)
406194676Sthompsa    {
407194676Sthompsa        return;
408194676Sthompsa    }
409195957Salfred
410195957Salfred    AcpiOsPrintf (" %s", AcpiUtGetTypeName (ObjDesc->Common.Type));
411194676Sthompsa
412195957Salfred    switch (ObjDesc->Common.Type)
413195957Salfred    {
414195957Salfred    case ACPI_TYPE_INTEGER:
415195957Salfred        AcpiOsPrintf (" %.8X", ObjDesc->Integer.Value);
416195560Sthompsa        break;
417194676Sthompsa
418194676Sthompsa    case ACPI_TYPE_STRING:
419194676Sthompsa        AcpiOsPrintf ("(%d) \"%.16s\"...",
420194676Sthompsa                ObjDesc->String.Length, ObjDesc->String.Pointer);
421194676Sthompsa        break;
422195957Salfred
423194676Sthompsa    case ACPI_TYPE_BUFFER:
424195957Salfred        AcpiOsPrintf ("(%d)", ObjDesc->Buffer.Length);
425195957Salfred        for (i = 0; (i < 8) && (i < ObjDesc->Buffer.Length); i++)
426195957Salfred        {
427195957Salfred            AcpiOsPrintf (" %2.2X", ObjDesc->Buffer.Pointer[i]);
428195957Salfred        }
429194676Sthompsa        break;
430195560Sthompsa    }
431195957Salfred}
432195957Salfred
433195957Salfred
434195560Sthompsa/*******************************************************************************
435194676Sthompsa *
436200424Sscf * FUNCTION:    AcpiDbDisplayInternalObject
437200424Sscf *
438194676Sthompsa * PARAMETERS:  ObjDesc         - Object to be displayed
439194676Sthompsa *              WalkState       - Current walk state
440195560Sthompsa *
441195957Salfred * RETURN:      None
442194676Sthompsa *
443194676Sthompsa * DESCRIPTION: Short display of an internal object
444194676Sthompsa *
445195957Salfred ******************************************************************************/
446194676Sthompsa
447194676Sthompsavoid
448195957SalfredAcpiDbDisplayInternalObject (
449195957Salfred    ACPI_OPERAND_OBJECT     *ObjDesc,
450194676Sthompsa    ACPI_WALK_STATE         *WalkState)
451194676Sthompsa{
452195957Salfred    UINT8                   Type;
453195957Salfred
454194676Sthompsa
455195957Salfred    AcpiOsPrintf ("%p ", ObjDesc);
456195957Salfred
457194676Sthompsa    if (!ObjDesc)
458195957Salfred    {
459194676Sthompsa        AcpiOsPrintf ("<NullObj>\n");
460195957Salfred        return;
461199055Sthompsa    }
462199055Sthompsa
463195957Salfred
464194676Sthompsa    /* Decode the object type */
465195957Salfred
466195957Salfred    else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_PARSER))
467194676Sthompsa    {
468213853Shselasky        AcpiOsPrintf ("<Parser>  ");
469195957Salfred    }
470195957Salfred
471194676Sthompsa    else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED))
472194676Sthompsa    {
473194676Sthompsa        AcpiOsPrintf ("<Node>            Name %4.4s Type-%s",
474194676Sthompsa                        &((ACPI_NAMESPACE_NODE *)ObjDesc)->Name,
475195957Salfred                        AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) ObjDesc)->Type));
476194676Sthompsa        if (((ACPI_NAMESPACE_NODE *) ObjDesc)->Flags & ANOBJ_METHOD_ARG)
477195957Salfred        {
478194676Sthompsa            AcpiOsPrintf (" [Method Arg]");
479195957Salfred        }
480194676Sthompsa        if (((ACPI_NAMESPACE_NODE *) ObjDesc)->Flags & ANOBJ_METHOD_LOCAL)
481194676Sthompsa        {
482194676Sthompsa            AcpiOsPrintf (" [Method Local]");
483195957Salfred        }
484194676Sthompsa    }
485195957Salfred
486194676Sthompsa    else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL))
487195957Salfred    {
488194676Sthompsa        AcpiOsPrintf ("<Obj> ");
489194676Sthompsa        Type = ObjDesc->Common.Type;
490195957Salfred        if (Type > INTERNAL_TYPE_MAX)
491195957Salfred        {
492195957Salfred            AcpiOsPrintf (" Type %x [Invalid Type]", Type);
493194676Sthompsa            return;
494195957Salfred        }
495195957Salfred
496195957Salfred        /* Decode the ACPI object type */
497195957Salfred
498194676Sthompsa        switch (ObjDesc->Common.Type)
499194676Sthompsa        {
500194676Sthompsa        case INTERNAL_TYPE_REFERENCE:
501194676Sthompsa            switch (ObjDesc->Reference.Opcode)
502195957Salfred            {
503194676Sthompsa            case AML_ZERO_OP:
504195957Salfred                AcpiOsPrintf ("[Const]     Number %.8X", 0);
505195957Salfred                break;
506195957Salfred
507195957Salfred            case AML_ONES_OP:
508194676Sthompsa                AcpiOsPrintf ("[Const]     Number %.8X", ACPI_UINT32_MAX);
509195957Salfred                break;
510195957Salfred
511194676Sthompsa            case AML_ONE_OP:
512194676Sthompsa                AcpiOsPrintf ("[Const]     Number %.8X", 1);
513195957Salfred                break;
514195957Salfred
515195957Salfred            case AML_LOCAL_OP:
516195957Salfred                AcpiOsPrintf ("[Local%d]   ", ObjDesc->Reference.Offset);
517195957Salfred                if (WalkState)
518195957Salfred                {
519194676Sthompsa                    ObjDesc = WalkState->LocalVariables[ObjDesc->Reference.Offset].Object;
520195957Salfred                    AcpiDbDecodeInternalObject (ObjDesc);
521195957Salfred                }
522195957Salfred                break;
523195957Salfred
524195957Salfred            case AML_ARG_OP:
525195957Salfred                AcpiOsPrintf ("[Arg%d]     ", ObjDesc->Reference.Offset);
526195957Salfred                if (WalkState)
527195957Salfred                {
528195957Salfred                    ObjDesc = WalkState->Arguments[ObjDesc->Reference.Offset].Object;
529195957Salfred                    AcpiDbDecodeInternalObject (ObjDesc);
530195957Salfred                }
531195957Salfred                break;
532195957Salfred
533195957Salfred            case AML_DEBUG_OP:
534195957Salfred                AcpiOsPrintf ("[Debug]  ");
535195957Salfred                break;
536195957Salfred
537195957Salfred            case AML_INDEX_OP:
538195957Salfred                AcpiOsPrintf ("[Index]     ");
539195957Salfred                AcpiDbDecodeInternalObject (ObjDesc->Reference.Object);
540195957Salfred                break;
541195957Salfred
542195957Salfred            default:
543195957Salfred                break;
544195957Salfred
545194676Sthompsa            }
546194676Sthompsa            break;
547194676Sthompsa
548195957Salfred        default:
549194676Sthompsa            AcpiOsPrintf ("           ");
550195957Salfred            AcpiDbDecodeInternalObject (ObjDesc);
551195957Salfred            break;
552194676Sthompsa        }
553195957Salfred    }
554194676Sthompsa
555194676Sthompsa    else
556194676Sthompsa    {
557195957Salfred        AcpiOsPrintf ("<Not a valid ACPI Object Descriptor> ");
558194676Sthompsa    }
559194676Sthompsa
560195957Salfred    AcpiOsPrintf ("\n");
561194676Sthompsa}
562195957Salfred
563194676Sthompsa
564195957Salfred/*******************************************************************************
565194676Sthompsa *
566195957Salfred * FUNCTION:    AcpiDbDisplayMethodInfo
567195957Salfred *
568194676Sthompsa * PARAMETERS:  StartOp         - Root of the control method parse tree
569194676Sthompsa *
570194676Sthompsa * RETURN:      None
571195957Salfred *
572194676Sthompsa * DESCRIPTION: Display information about the current method
573195957Salfred *
574195957Salfred ******************************************************************************/
575194676Sthompsa
576195957Salfredvoid
577194676SthompsaAcpiDbDisplayMethodInfo (
578194676Sthompsa    ACPI_PARSE_OBJECT       *StartOp)
579194676Sthompsa{
580195957Salfred    ACPI_WALK_STATE         *WalkState;
581194676Sthompsa    ACPI_OPERAND_OBJECT     *ObjDesc;
582194676Sthompsa    ACPI_NAMESPACE_NODE     *Node;
583195957Salfred    ACPI_PARSE_OBJECT       *RootOp;
584194676Sthompsa    ACPI_PARSE_OBJECT       *Op;
585195957Salfred    ACPI_OPCODE_INFO        *OpInfo;
586194676Sthompsa    UINT32                  NumOps = 0;
587195957Salfred    UINT32                  NumOperands = 0;
588194676Sthompsa    UINT32                  NumOperators = 0;
589195957Salfred    UINT32                  NumRemainingOps = 0;
590195957Salfred    UINT32                  NumRemainingOperands = 0;
591194676Sthompsa    UINT32                  NumRemainingOperators = 0;
592194676Sthompsa    UINT32                  NumArgs;
593194676Sthompsa    UINT32                  Concurrency;
594195957Salfred    BOOLEAN                 CountRemaining = FALSE;
595194676Sthompsa
596194676Sthompsa
597195957Salfred    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
598195957Salfred    if (!WalkState)
599194676Sthompsa    {
600195957Salfred        AcpiOsPrintf ("There is no method currently executing\n");
601194676Sthompsa        return;
602194676Sthompsa    }
603194676Sthompsa
604195957Salfred    ObjDesc = WalkState->MethodDesc;
605194676Sthompsa    Node = WalkState->MethodNode;
606194676Sthompsa
607195957Salfred    NumArgs = ObjDesc->Method.ParamCount;
608195957Salfred    Concurrency = ObjDesc->Method.Concurrency;
609195957Salfred
610195957Salfred    AcpiOsPrintf ("Currently executing control method is [%4.4s]\n", &Node->Name);
611194676Sthompsa    AcpiOsPrintf ("%X arguments, max concurrency = %X\n", NumArgs, Concurrency);
612195957Salfred
613195957Salfred
614195957Salfred    RootOp = StartOp;
615195957Salfred    while (RootOp->Parent)
616195957Salfred    {
617195957Salfred        RootOp = RootOp->Parent;
618195957Salfred    }
619195957Salfred
620195957Salfred    Op = RootOp;
621195957Salfred
622195957Salfred    while (Op)
623195957Salfred    {
624195957Salfred        if (Op == StartOp)
625195957Salfred        {
626195957Salfred            CountRemaining = TRUE;
627194676Sthompsa        }
628194676Sthompsa
629195957Salfred        NumOps++;
630195957Salfred        if (CountRemaining)
631195957Salfred        {
632195957Salfred            NumRemainingOps++;
633195957Salfred        }
634195957Salfred
635195957Salfred        OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode);
636195957Salfred        if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE)
637195957Salfred        {
638195957Salfred            /* Bad opcode or ASCII character */
639195957Salfred
640195957Salfred            continue;
641195957Salfred        }
642195957Salfred
643195957Salfred
644194676Sthompsa        /* Decode the opcode */
645195957Salfred
646194676Sthompsa        switch (ACPI_GET_OP_CLASS (OpInfo))
647194676Sthompsa        {
648195957Salfred        case OPTYPE_CONSTANT:           /* argument type only */
649195957Salfred        case OPTYPE_LITERAL:            /* argument type only */
650194676Sthompsa        case OPTYPE_DATA_TERM:          /* argument type only */
651195957Salfred        case OPTYPE_LOCAL_VARIABLE:     /* argument type only */
652195560Sthompsa        case OPTYPE_METHOD_ARGUMENT:    /* argument type only */
653195957Salfred            if (CountRemaining)
654194676Sthompsa            {
655195957Salfred                NumRemainingOperands++;
656213853Shselasky            }
657213853Shselasky
658195957Salfred            NumOperands++;
659195957Salfred            break;
660223642Shselasky
661195957Salfred        default:
662195957Salfred            if (CountRemaining)
663195957Salfred            {
664194676Sthompsa                NumRemainingOperators++;
665194676Sthompsa            }
666194676Sthompsa
667195957Salfred            NumOperators++;
668195957Salfred            break;
669195957Salfred        }
670195957Salfred
671194676Sthompsa
672195957Salfred        Op = AcpiPsGetDepthNext (StartOp, Op);
673195957Salfred    }
674195957Salfred
675194676Sthompsa    AcpiOsPrintf ("Method contains:       %X AML Opcodes - %X Operators, %X Operands\n",
676194676Sthompsa                NumOps, NumOperators, NumOperands);
677194676Sthompsa
678195957Salfred    AcpiOsPrintf ("Remaining to execute:  %X AML Opcodes - %X Operators, %X Operands\n",
679194676Sthompsa                NumRemainingOps, NumRemainingOperators, NumRemainingOperands);
680195957Salfred}
681195957Salfred
682194676Sthompsa
683195957Salfred/*******************************************************************************
684194676Sthompsa *
685213853Shselasky * FUNCTION:    AcpiDbDisplayLocals
686194676Sthompsa *
687195957Salfred * PARAMETERS:  None
688195957Salfred *
689195957Salfred * RETURN:      None
690195957Salfred *
691195957Salfred * DESCRIPTION: Display all locals for the currently running control method
692195957Salfred *
693195957Salfred ******************************************************************************/
694195957Salfred
695195957Salfredvoid
696195957SalfredAcpiDbDisplayLocals (void)
697195957Salfred{
698194676Sthompsa    UINT32                  i;
699194676Sthompsa    ACPI_WALK_STATE         *WalkState;
700194676Sthompsa    ACPI_OPERAND_OBJECT     *ObjDesc;
701213848Shselasky    ACPI_NAMESPACE_NODE     *Node;
702213848Shselasky
703213848Shselasky
704213848Shselasky    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
705213848Shselasky    if (!WalkState)
706213848Shselasky    {
707213848Shselasky        AcpiOsPrintf ("There is no method currently executing\n");
708213848Shselasky        return;
709213848Shselasky    }
710213848Shselasky
711213848Shselasky    ObjDesc = WalkState->MethodDesc;
712213848Shselasky    Node = WalkState->MethodNode;
713213848Shselasky
714213848Shselasky
715213848Shselasky    AcpiOsPrintf ("Local Variables for method [%4.4s]:\n", &Node->Name);
716195957Salfred
717194676Sthompsa    for (i = 0; i < MTH_NUM_LOCALS; i++)
718195957Salfred    {
719194676Sthompsa        ObjDesc = WalkState->LocalVariables[i].Object;
720194676Sthompsa        AcpiOsPrintf ("Local%d: ", i);
721195957Salfred        AcpiDbDisplayInternalObject (ObjDesc, WalkState);
722195957Salfred    }
723194676Sthompsa}
724194676Sthompsa
725194676Sthompsa
726213853Shselasky/*******************************************************************************
727213853Shselasky *
728213853Shselasky * FUNCTION:    AcpiDbDisplayArguments
729213853Shselasky *
730213853Shselasky * PARAMETERS:  None
731213853Shselasky *
732213853Shselasky * RETURN:      None
733213853Shselasky *
734213853Shselasky * DESCRIPTION: Display all arguments for the currently running control method
735213853Shselasky *
736213853Shselasky ******************************************************************************/
737213853Shselasky
738213853Shselaskyvoid
739213853ShselaskyAcpiDbDisplayArguments (void)
740213853Shselasky{
741213853Shselasky    UINT32                  i;
742213853Shselasky    ACPI_WALK_STATE         *WalkState;
743224085Shselasky    ACPI_OPERAND_OBJECT     *ObjDesc;
744224085Shselasky    UINT32                  NumArgs;
745213853Shselasky    UINT32                  Concurrency;
746213853Shselasky    ACPI_NAMESPACE_NODE     *Node;
747213853Shselasky
748213853Shselasky
749213853Shselasky    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
750213853Shselasky    if (!WalkState)
751213853Shselasky    {
752213853Shselasky        AcpiOsPrintf ("There is no method currently executing\n");
753213853Shselasky        return;
754213853Shselasky    }
755213853Shselasky
756213853Shselasky    ObjDesc = WalkState->MethodDesc;
757213853Shselasky    Node = WalkState->MethodNode;
758213853Shselasky
759213853Shselasky    NumArgs = ObjDesc->Method.ParamCount;
760213853Shselasky    Concurrency = ObjDesc->Method.Concurrency;
761213853Shselasky
762213853Shselasky    AcpiOsPrintf ("Method [%4.4s] has %X arguments, max concurrency = %X\n", &Node->Name, NumArgs, Concurrency);
763213853Shselasky
764213853Shselasky    for (i = 0; i < NumArgs; i++)
765213853Shselasky    {
766213853Shselasky        ObjDesc = WalkState->Arguments[i].Object;
767195957Salfred        AcpiOsPrintf ("Arg%d: ", i);
768194676Sthompsa        AcpiDbDisplayInternalObject (ObjDesc, WalkState);
769195957Salfred    }
770194676Sthompsa}
771195957Salfred
772194676Sthompsa
773194676Sthompsa/*******************************************************************************
774195957Salfred *
775195957Salfred * FUNCTION:    AcpiDbDisplayResults
776194676Sthompsa *
777213853Shselasky * PARAMETERS:  None
778194676Sthompsa *
779194676Sthompsa * RETURN:      None
780194676Sthompsa *
781195957Salfred * DESCRIPTION: Display current contents of a method result stack
782194676Sthompsa *
783195957Salfred ******************************************************************************/
784194676Sthompsa
785195957Salfredvoid
786194676SthompsaAcpiDbDisplayResults (void)
787194676Sthompsa{
788194676Sthompsa    UINT32                  i;
789194676Sthompsa    ACPI_WALK_STATE         *WalkState;
790194676Sthompsa    ACPI_OPERAND_OBJECT     *ObjDesc;
791194676Sthompsa    UINT32                  NumResults = 0;
792194676Sthompsa    ACPI_NAMESPACE_NODE     *Node;
793194676Sthompsa
794195957Salfred
795195957Salfred    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
796194676Sthompsa    if (!WalkState)
797194676Sthompsa    {
798194676Sthompsa        AcpiOsPrintf ("There is no method currently executing\n");
799195957Salfred        return;
800194676Sthompsa    }
801194676Sthompsa
802195957Salfred    ObjDesc = WalkState->MethodDesc;
803195957Salfred    Node = WalkState->MethodNode;
804194676Sthompsa
805194676Sthompsa    if (WalkState->Results)
806195957Salfred    {
807194676Sthompsa        NumResults = WalkState->Results->Results.NumResults;
808195957Salfred    }
809195957Salfred
810194676Sthompsa    AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n", &Node->Name, NumResults);
811195957Salfred
812195957Salfred    for (i = 0; i < NumResults; i++)
813195957Salfred    {
814195957Salfred        ObjDesc = WalkState->Results->Results.ObjDesc[i];
815194676Sthompsa        AcpiOsPrintf ("Result%d: ", i);
816194676Sthompsa        AcpiDbDisplayInternalObject (ObjDesc, WalkState);
817194676Sthompsa    }
818195957Salfred}
819194676Sthompsa
820195957Salfred
821194676Sthompsa/*******************************************************************************
822195957Salfred *
823195957Salfred * FUNCTION:    AcpiDbDisplayCallingTree
824194676Sthompsa *
825215253Shselasky * PARAMETERS:  None
826215253Shselasky *
827215253Shselasky * RETURN:      None
828215253Shselasky *
829195957Salfred * DESCRIPTION: Display current calling tree of nested control methods
830195957Salfred *
831194676Sthompsa ******************************************************************************/
832195957Salfred
833194676Sthompsavoid
834194676SthompsaAcpiDbDisplayCallingTree (void)
835219100Shselasky{
836195957Salfred    UINT32                  i;
837195560Sthompsa    ACPI_WALK_STATE         *WalkState;
838219100Shselasky    ACPI_NAMESPACE_NODE     *Node;
839195560Sthompsa
840195560Sthompsa
841195560Sthompsa    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
842219100Shselasky    if (!WalkState)
843195957Salfred    {
844195560Sthompsa        AcpiOsPrintf ("There is no method currently executing\n");
845195560Sthompsa        return;
846195957Salfred    }
847195560Sthompsa
848195560Sthompsa    Node = WalkState->MethodNode;
849195957Salfred
850195560Sthompsa    AcpiOsPrintf ("Current Control Method Call Tree\n");
851195957Salfred
852195560Sthompsa    for (i = 0; WalkState; i++)
853195560Sthompsa    {
854195560Sthompsa        Node = WalkState->MethodNode;
855195957Salfred
856195560Sthompsa        AcpiOsPrintf ("    [%4.4s]\n", &Node->Name);
857195560Sthompsa
858195560Sthompsa        WalkState = WalkState->Next;
859195560Sthompsa    }
860195560Sthompsa}
861195560Sthompsa
862195560Sthompsa
863195560Sthompsa/*******************************************************************************
864195957Salfred *
865195957Salfred * FUNCTION:    AcpiDbDisplayResultObject
866195560Sthompsa *
867195957Salfred * PARAMETERS:  ObjDesc         - Object to be displayed
868195957Salfred *              WalkState       - Current walk state
869195957Salfred *
870195560Sthompsa * RETURN:      None
871195957Salfred *
872195957Salfred * DESCRIPTION: Display the result of an AML opcode
873195957Salfred *
874195957Salfred ******************************************************************************/
875195957Salfred
876195957Salfredvoid
877195957SalfredAcpiDbDisplayResultObject (
878195957Salfred    ACPI_OPERAND_OBJECT     *ObjDesc,
879195957Salfred    ACPI_WALK_STATE         *WalkState)
880195560Sthompsa{
881195957Salfred
882195560Sthompsa    /* TBD: [Future] We don't always want to display the result.
883195957Salfred     * For now, only display if single stepping
884195560Sthompsa     * however, this output is very useful in other contexts also
885195560Sthompsa     */
886195957Salfred
887195957Salfred    if (!AcpiGbl_CmSingleStep)
888195957Salfred    {
889195957Salfred        return;
890195957Salfred    }
891195957Salfred
892195957Salfred    AcpiOsPrintf ("ResultObj: ");
893195957Salfred    AcpiDbDisplayInternalObject (ObjDesc, WalkState);
894195957Salfred    AcpiOsPrintf ("\n");
895195957Salfred}
896195957Salfred
897195957Salfred
898195957Salfred/*******************************************************************************
899195957Salfred *
900195957Salfred * FUNCTION:    AcpiDbDisplayArgumentObject
901195957Salfred *
902195957Salfred * PARAMETERS:  ObjDesc         - Object to be displayed
903195957Salfred *              WalkState       - Current walk state
904195957Salfred *
905195957Salfred * RETURN:      None
906195957Salfred *
907195957Salfred * DESCRIPTION: Display the result of an AML opcode
908195957Salfred *
909195957Salfred ******************************************************************************/
910195957Salfred
911195957Salfredvoid
912194676SthompsaAcpiDbDisplayArgumentObject (
913195957Salfred    ACPI_OPERAND_OBJECT     *ObjDesc,
914195957Salfred    ACPI_WALK_STATE         *WalkState)
915194676Sthompsa{
916195957Salfred
917195957Salfred
918195957Salfred    if (!AcpiGbl_CmSingleStep)
919195957Salfred    {
920195957Salfred        return;
921195957Salfred    }
922195957Salfred
923195957Salfred    AcpiOsPrintf ("ArgObj:    ");
924195957Salfred    AcpiDbDisplayInternalObject (ObjDesc, WalkState);
925199575Sthompsa}
926195957Salfred
927195957Salfred#endif /* ENABLE_DEBUGGER */
928199575Sthompsa
929199575Sthompsa