13446Smrj /*******************************************************************************
23446Smrj *
33446Smrj * Module Name: dbdisply - debug display commands
43446Smrj *
53446Smrj ******************************************************************************/
63446Smrj
73446Smrj /******************************************************************************
83446Smrj *
93446Smrj * 1. Copyright Notice
103446Smrj *
119980SDana.Myers@Sun.COM * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
123446Smrj * All rights reserved.
133446Smrj *
143446Smrj * 2. License
153446Smrj *
163446Smrj * 2.1. This is your license from Intel Corp. under its intellectual property
173446Smrj * rights. You may have additional license terms from the party that provided
183446Smrj * you this software, covering your right to use that party's intellectual
193446Smrj * property rights.
203446Smrj *
213446Smrj * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
223446Smrj * copy of the source code appearing in this file ("Covered Code") an
233446Smrj * irrevocable, perpetual, worldwide license under Intel's copyrights in the
243446Smrj * base code distributed originally by Intel ("Original Intel Code") to copy,
253446Smrj * make derivatives, distribute, use and display any portion of the Covered
263446Smrj * Code in any form, with the right to sublicense such rights; and
273446Smrj *
283446Smrj * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
293446Smrj * license (with the right to sublicense), under only those claims of Intel
303446Smrj * patents that are infringed by the Original Intel Code, to make, use, sell,
313446Smrj * offer to sell, and import the Covered Code and derivative works thereof
323446Smrj * solely to the minimum extent necessary to exercise the above copyright
333446Smrj * license, and in no event shall the patent license extend to any additions
343446Smrj * to or modifications of the Original Intel Code. No other license or right
353446Smrj * is granted directly or by implication, estoppel or otherwise;
363446Smrj *
373446Smrj * The above copyright and patent license is granted only if the following
383446Smrj * conditions are met:
393446Smrj *
403446Smrj * 3. Conditions
413446Smrj *
423446Smrj * 3.1. Redistribution of Source with Rights to Further Distribute Source.
433446Smrj * Redistribution of source code of any substantial portion of the Covered
443446Smrj * Code or modification with rights to further distribute source must include
453446Smrj * the above Copyright Notice, the above License, this list of Conditions,
463446Smrj * and the following Disclaimer and Export Compliance provision. In addition,
473446Smrj * Licensee must cause all Covered Code to which Licensee contributes to
483446Smrj * contain a file documenting the changes Licensee made to create that Covered
493446Smrj * Code and the date of any change. Licensee must include in that file the
503446Smrj * documentation of any changes made by any predecessor Licensee. Licensee
513446Smrj * must include a prominent statement that the modification is derived,
523446Smrj * directly or indirectly, from Original Intel Code.
533446Smrj *
543446Smrj * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
553446Smrj * Redistribution of source code of any substantial portion of the Covered
563446Smrj * Code or modification without rights to further distribute source must
573446Smrj * include the following Disclaimer and Export Compliance provision in the
583446Smrj * documentation and/or other materials provided with distribution. In
593446Smrj * addition, Licensee may not authorize further sublicense of source of any
603446Smrj * portion of the Covered Code, and must include terms to the effect that the
613446Smrj * license from Licensee to its licensee is limited to the intellectual
623446Smrj * property embodied in the software Licensee provides to its licensee, and
633446Smrj * not to intellectual property embodied in modifications its licensee may
643446Smrj * make.
653446Smrj *
663446Smrj * 3.3. Redistribution of Executable. Redistribution in executable form of any
673446Smrj * substantial portion of the Covered Code or modification must reproduce the
683446Smrj * above Copyright Notice, and the following Disclaimer and Export Compliance
693446Smrj * provision in the documentation and/or other materials provided with the
703446Smrj * distribution.
713446Smrj *
723446Smrj * 3.4. Intel retains all right, title, and interest in and to the Original
733446Smrj * Intel Code.
743446Smrj *
753446Smrj * 3.5. Neither the name Intel nor any other trademark owned or controlled by
763446Smrj * Intel shall be used in advertising or otherwise to promote the sale, use or
773446Smrj * other dealings in products derived from or relating to the Covered Code
783446Smrj * without prior written authorization from Intel.
793446Smrj *
803446Smrj * 4. Disclaimer and Export Compliance
813446Smrj *
823446Smrj * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
833446Smrj * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
843446Smrj * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
853446Smrj * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
863446Smrj * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
873446Smrj * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
883446Smrj * PARTICULAR PURPOSE.
893446Smrj *
903446Smrj * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
913446Smrj * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
923446Smrj * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
933446Smrj * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
943446Smrj * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
953446Smrj * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
963446Smrj * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
973446Smrj * LIMITED REMEDY.
983446Smrj *
993446Smrj * 4.3. Licensee shall not export, either directly or indirectly, any of this
1003446Smrj * software or system incorporating such software without first obtaining any
1013446Smrj * required license or other approval from the U. S. Department of Commerce or
1023446Smrj * any other agency or department of the United States Government. In the
1033446Smrj * event Licensee exports any such software from the United States or
1043446Smrj * re-exports any such software from a foreign destination, Licensee shall
1053446Smrj * ensure that the distribution and export/re-export of the software is in
1063446Smrj * compliance with all laws, regulations, orders, or other restrictions of the
1073446Smrj * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1083446Smrj * any of its subsidiaries will export/re-export any technical data, process,
1093446Smrj * software, or service, directly or indirectly, to any country for which the
1103446Smrj * United States government or any agency thereof requires an export license,
1113446Smrj * other governmental approval, or letter of assurance, without first obtaining
1123446Smrj * such license, approval or letter.
1133446Smrj *
1143446Smrj *****************************************************************************/
1153446Smrj
1163446Smrj
1173446Smrj #include "acpi.h"
1189980SDana.Myers@Sun.COM #include "accommon.h"
1193446Smrj #include "amlcode.h"
1203446Smrj #include "acdispat.h"
1213446Smrj #include "acnamesp.h"
1223446Smrj #include "acparser.h"
1233446Smrj #include "acinterp.h"
1243446Smrj #include "acdebug.h"
1253446Smrj #include "acdisasm.h"
1263446Smrj
1273446Smrj
1283446Smrj #ifdef ACPI_DEBUGGER
1293446Smrj
1303446Smrj #define _COMPONENT ACPI_CA_DEBUGGER
1313446Smrj ACPI_MODULE_NAME ("dbdisply")
1323446Smrj
1333446Smrj /* Local prototypes */
1343446Smrj
1353446Smrj static void
1363446Smrj AcpiDbDumpParserDescriptor (
1373446Smrj ACPI_PARSE_OBJECT *Op);
1383446Smrj
1393446Smrj static void *
1403446Smrj AcpiDbGetPointer (
1413446Smrj void *Target);
1423446Smrj
1433446Smrj
1443446Smrj /*******************************************************************************
1453446Smrj *
1463446Smrj * FUNCTION: AcpiDbGetPointer
1473446Smrj *
1483446Smrj * PARAMETERS: Target - Pointer to string to be converted
1493446Smrj *
1503446Smrj * RETURN: Converted pointer
1513446Smrj *
1523446Smrj * DESCRIPTION: Convert an ascii pointer value to a real value
1533446Smrj *
1543446Smrj ******************************************************************************/
1553446Smrj
1563446Smrj static void *
AcpiDbGetPointer(void * Target)1573446Smrj AcpiDbGetPointer (
1583446Smrj void *Target)
1593446Smrj {
1603446Smrj void *ObjPtr;
1613446Smrj
1623446Smrj
1633446Smrj ObjPtr = ACPI_TO_POINTER (ACPI_STRTOUL (Target, NULL, 16));
1643446Smrj return (ObjPtr);
1653446Smrj }
1663446Smrj
1673446Smrj
1683446Smrj /*******************************************************************************
1693446Smrj *
1703446Smrj * FUNCTION: AcpiDbDumpParserDescriptor
1713446Smrj *
1723446Smrj * PARAMETERS: Op - A parser Op descriptor
1733446Smrj *
1743446Smrj * RETURN: None
1753446Smrj *
1763446Smrj * DESCRIPTION: Display a formatted parser object
1773446Smrj *
1783446Smrj ******************************************************************************/
1793446Smrj
1803446Smrj static void
AcpiDbDumpParserDescriptor(ACPI_PARSE_OBJECT * Op)1813446Smrj AcpiDbDumpParserDescriptor (
1823446Smrj ACPI_PARSE_OBJECT *Op)
1833446Smrj {
1843446Smrj const ACPI_OPCODE_INFO *Info;
1853446Smrj
1863446Smrj
1873446Smrj Info = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
1883446Smrj
1893446Smrj AcpiOsPrintf ("Parser Op Descriptor:\n");
1903446Smrj AcpiOsPrintf ("%20.20s : %4.4X\n", "Opcode", Op->Common.AmlOpcode);
1913446Smrj
1923446Smrj ACPI_DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name",
1933446Smrj Info->Name));
1943446Smrj
1953446Smrj AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Common.Value.Arg);
1963446Smrj AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Common.Parent);
1973446Smrj AcpiOsPrintf ("%20.20s : %p\n", "NextOp", Op->Common.Next);
1983446Smrj }
1993446Smrj
2003446Smrj
2013446Smrj /*******************************************************************************
2023446Smrj *
2033446Smrj * FUNCTION: AcpiDbDecodeAndDisplayObject
2043446Smrj *
2053446Smrj * PARAMETERS: Target - String with object to be displayed. Names
2063446Smrj * and hex pointers are supported.
2073446Smrj * OutputType - Byte, Word, Dword, or Qword (B|W|D|Q)
2083446Smrj *
2093446Smrj * RETURN: None
2103446Smrj *
2113446Smrj * DESCRIPTION: Display a formatted ACPI object
2123446Smrj *
2133446Smrj ******************************************************************************/
2143446Smrj
2153446Smrj void
AcpiDbDecodeAndDisplayObject(char * Target,char * OutputType)2163446Smrj AcpiDbDecodeAndDisplayObject (
2173446Smrj char *Target,
2183446Smrj char *OutputType)
2193446Smrj {
2203446Smrj void *ObjPtr;
2213446Smrj ACPI_NAMESPACE_NODE *Node;
2223446Smrj ACPI_OPERAND_OBJECT *ObjDesc;
2233446Smrj UINT32 Display = DB_BYTE_DISPLAY;
2243446Smrj char Buffer[80];
2253446Smrj ACPI_BUFFER RetBuf;
2263446Smrj ACPI_STATUS Status;
2273446Smrj UINT32 Size;
2283446Smrj
2293446Smrj
2303446Smrj if (!Target)
2313446Smrj {
2323446Smrj return;
2333446Smrj }
2343446Smrj
2353446Smrj /* Decode the output type */
2363446Smrj
2373446Smrj if (OutputType)
2383446Smrj {
2393446Smrj AcpiUtStrupr (OutputType);
2403446Smrj if (OutputType[0] == 'W')
2413446Smrj {
2423446Smrj Display = DB_WORD_DISPLAY;
2433446Smrj }
2443446Smrj else if (OutputType[0] == 'D')
2453446Smrj {
2463446Smrj Display = DB_DWORD_DISPLAY;
2473446Smrj }
2483446Smrj else if (OutputType[0] == 'Q')
2493446Smrj {
2503446Smrj Display = DB_QWORD_DISPLAY;
2513446Smrj }
2523446Smrj }
2533446Smrj
2543446Smrj RetBuf.Length = sizeof (Buffer);
2553446Smrj RetBuf.Pointer = Buffer;
2563446Smrj
2573446Smrj /* Differentiate between a number and a name */
2583446Smrj
2593446Smrj if ((Target[0] >= 0x30) && (Target[0] <= 0x39))
2603446Smrj {
2613446Smrj ObjPtr = AcpiDbGetPointer (Target);
2623446Smrj if (!AcpiOsReadable (ObjPtr, 16))
2633446Smrj {
2643446Smrj AcpiOsPrintf ("Address %p is invalid in this address space\n",
2653446Smrj ObjPtr);
2663446Smrj return;
2673446Smrj }
2683446Smrj
2693446Smrj /* Decode the object type */
2703446Smrj
2713446Smrj switch (ACPI_GET_DESCRIPTOR_TYPE (ObjPtr))
2723446Smrj {
2733446Smrj case ACPI_DESC_TYPE_NAMED:
2743446Smrj
2753446Smrj /* This is a namespace Node */
2763446Smrj
2773446Smrj if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE)))
2783446Smrj {
2793446Smrj AcpiOsPrintf (
2803446Smrj "Cannot read entire Named object at address %p\n", ObjPtr);
2813446Smrj return;
2823446Smrj }
2833446Smrj
2843446Smrj Node = ObjPtr;
2853446Smrj goto DumpNode;
2863446Smrj
2873446Smrj
2883446Smrj case ACPI_DESC_TYPE_OPERAND:
2893446Smrj
2903446Smrj /* This is a ACPI OPERAND OBJECT */
2913446Smrj
2923446Smrj if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT)))
2933446Smrj {
2943446Smrj AcpiOsPrintf ("Cannot read entire ACPI object at address %p\n",
2953446Smrj ObjPtr);
2963446Smrj return;
2973446Smrj }
2983446Smrj
2993446Smrj AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), Display,
3003446Smrj ACPI_UINT32_MAX);
3013446Smrj AcpiExDumpObjectDescriptor (ObjPtr, 1);
3023446Smrj break;
3033446Smrj
3043446Smrj
3053446Smrj case ACPI_DESC_TYPE_PARSER:
3063446Smrj
3073446Smrj /* This is a Parser Op object */
3083446Smrj
3093446Smrj if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT)))
3103446Smrj {
3113446Smrj AcpiOsPrintf (
3123446Smrj "Cannot read entire Parser object at address %p\n", ObjPtr);
3133446Smrj return;
3143446Smrj }
3153446Smrj
3163446Smrj AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), Display,
3173446Smrj ACPI_UINT32_MAX);
3183446Smrj AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr);
3193446Smrj break;
3203446Smrj
3213446Smrj
3223446Smrj default:
3233446Smrj
3243446Smrj /* Is not a recognizeable object */
3253446Smrj
3263446Smrj Size = 16;
3273446Smrj if (AcpiOsReadable (ObjPtr, 64))
3283446Smrj {
3293446Smrj Size = 64;
3303446Smrj }
3313446Smrj
3323446Smrj /* Just dump some memory */
3333446Smrj
3343446Smrj AcpiUtDumpBuffer (ObjPtr, Size, Display, ACPI_UINT32_MAX);
3353446Smrj break;
3363446Smrj }
3373446Smrj
3383446Smrj return;
3393446Smrj }
3403446Smrj
3413446Smrj /* The parameter is a name string that must be resolved to a Named obj */
3423446Smrj
3433446Smrj Node = AcpiDbLocalNsLookup (Target);
3443446Smrj if (!Node)
3453446Smrj {
3463446Smrj return;
3473446Smrj }
3483446Smrj
3493446Smrj
3503446Smrj DumpNode:
3513446Smrj /* Now dump the NS node */
3523446Smrj
3533446Smrj Status = AcpiGetName (Node, ACPI_FULL_PATHNAME, &RetBuf);
3543446Smrj if (ACPI_FAILURE (Status))
3553446Smrj {
3563446Smrj AcpiOsPrintf ("Could not convert name to pathname\n");
3573446Smrj }
3583446Smrj
3593446Smrj else
3603446Smrj {
3613446Smrj AcpiOsPrintf ("Object (%p) Pathname: %s\n",
3623446Smrj Node, (char *) RetBuf.Pointer);
3633446Smrj }
3643446Smrj
3653446Smrj if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
3663446Smrj {
3673446Smrj AcpiOsPrintf ("Invalid Named object at address %p\n", Node);
3683446Smrj return;
3693446Smrj }
3703446Smrj
3713446Smrj AcpiUtDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE),
3723446Smrj Display, ACPI_UINT32_MAX);
3733446Smrj AcpiExDumpNamespaceNode (Node, 1);
3743446Smrj
3753446Smrj ObjDesc = AcpiNsGetAttachedObject (Node);
3763446Smrj if (ObjDesc)
3773446Smrj {
3783446Smrj AcpiOsPrintf ("\nAttached Object (%p):\n", ObjDesc);
3793446Smrj if (!AcpiOsReadable (ObjDesc, sizeof (ACPI_OPERAND_OBJECT)))
3803446Smrj {
3813446Smrj AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n",
3823446Smrj ObjDesc);
3833446Smrj return;
3843446Smrj }
3853446Smrj
3863446Smrj AcpiUtDumpBuffer ((void *) ObjDesc, sizeof (ACPI_OPERAND_OBJECT),
3873446Smrj Display, ACPI_UINT32_MAX);
3883446Smrj AcpiExDumpObjectDescriptor (ObjDesc, 1);
3893446Smrj }
3903446Smrj }
3913446Smrj
3923446Smrj
3933446Smrj /*******************************************************************************
3943446Smrj *
3953446Smrj * FUNCTION: AcpiDbDisplayMethodInfo
3963446Smrj *
3973446Smrj * PARAMETERS: StartOp - Root of the control method parse tree
3983446Smrj *
3993446Smrj * RETURN: None
4003446Smrj *
4013446Smrj * DESCRIPTION: Display information about the current method
4023446Smrj *
4033446Smrj ******************************************************************************/
4043446Smrj
4053446Smrj void
AcpiDbDisplayMethodInfo(ACPI_PARSE_OBJECT * StartOp)4063446Smrj AcpiDbDisplayMethodInfo (
4073446Smrj ACPI_PARSE_OBJECT *StartOp)
4083446Smrj {
4093446Smrj ACPI_WALK_STATE *WalkState;
4103446Smrj ACPI_OPERAND_OBJECT *ObjDesc;
4113446Smrj ACPI_NAMESPACE_NODE *Node;
4123446Smrj ACPI_PARSE_OBJECT *RootOp;
4133446Smrj ACPI_PARSE_OBJECT *Op;
4143446Smrj const ACPI_OPCODE_INFO *OpInfo;
4153446Smrj UINT32 NumOps = 0;
4163446Smrj UINT32 NumOperands = 0;
4173446Smrj UINT32 NumOperators = 0;
4183446Smrj UINT32 NumRemainingOps = 0;
4193446Smrj UINT32 NumRemainingOperands = 0;
4203446Smrj UINT32 NumRemainingOperators = 0;
4213446Smrj BOOLEAN CountRemaining = FALSE;
4223446Smrj
4233446Smrj
4243446Smrj WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
4253446Smrj if (!WalkState)
4263446Smrj {
4273446Smrj AcpiOsPrintf ("There is no method currently executing\n");
4283446Smrj return;
4293446Smrj }
4303446Smrj
4313446Smrj ObjDesc = WalkState->MethodDesc;
4323446Smrj Node = WalkState->MethodNode;
4333446Smrj
4343446Smrj AcpiOsPrintf ("Currently executing control method is [%4.4s]\n",
4353446Smrj AcpiUtGetNodeName (Node));
4363446Smrj AcpiOsPrintf ("%X Arguments, SyncLevel = %X\n",
4373446Smrj (UINT32) ObjDesc->Method.ParamCount,
4383446Smrj (UINT32) ObjDesc->Method.SyncLevel);
4393446Smrj
4403446Smrj
4413446Smrj RootOp = StartOp;
4423446Smrj while (RootOp->Common.Parent)
4433446Smrj {
4443446Smrj RootOp = RootOp->Common.Parent;
4453446Smrj }
4463446Smrj
4473446Smrj Op = RootOp;
4483446Smrj
4493446Smrj while (Op)
4503446Smrj {
4513446Smrj if (Op == StartOp)
4523446Smrj {
4533446Smrj CountRemaining = TRUE;
4543446Smrj }
4553446Smrj
4563446Smrj NumOps++;
4573446Smrj if (CountRemaining)
4583446Smrj {
4593446Smrj NumRemainingOps++;
4603446Smrj }
4613446Smrj
4623446Smrj /* Decode the opcode */
4633446Smrj
4643446Smrj OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
4653446Smrj switch (OpInfo->Class)
4663446Smrj {
4673446Smrj case AML_CLASS_ARGUMENT:
4683446Smrj if (CountRemaining)
4693446Smrj {
4703446Smrj NumRemainingOperands++;
4713446Smrj }
4723446Smrj
4733446Smrj NumOperands++;
4743446Smrj break;
4753446Smrj
4763446Smrj case AML_CLASS_UNKNOWN:
4773446Smrj /* Bad opcode or ASCII character */
4783446Smrj
4793446Smrj continue;
4803446Smrj
4813446Smrj default:
4823446Smrj if (CountRemaining)
4833446Smrj {
4843446Smrj NumRemainingOperators++;
4853446Smrj }
4863446Smrj
4873446Smrj NumOperators++;
4883446Smrj break;
4893446Smrj }
4903446Smrj
4913446Smrj Op = AcpiPsGetDepthNext (StartOp, Op);
4923446Smrj }
4933446Smrj
4943446Smrj AcpiOsPrintf (
4953446Smrj "Method contains: %X AML Opcodes - %X Operators, %X Operands\n",
4963446Smrj NumOps, NumOperators, NumOperands);
4973446Smrj
4983446Smrj AcpiOsPrintf (
4993446Smrj "Remaining to execute: %X AML Opcodes - %X Operators, %X Operands\n",
5003446Smrj NumRemainingOps, NumRemainingOperators, NumRemainingOperands);
5013446Smrj }
5023446Smrj
5033446Smrj
5043446Smrj /*******************************************************************************
5053446Smrj *
5063446Smrj * FUNCTION: AcpiDbDisplayLocals
5073446Smrj *
5083446Smrj * PARAMETERS: None
5093446Smrj *
5103446Smrj * RETURN: None
5113446Smrj *
5123446Smrj * DESCRIPTION: Display all locals for the currently running control method
5133446Smrj *
5143446Smrj ******************************************************************************/
5153446Smrj
5163446Smrj void
AcpiDbDisplayLocals(void)5173446Smrj AcpiDbDisplayLocals (
5183446Smrj void)
5193446Smrj {
5203446Smrj ACPI_WALK_STATE *WalkState;
5213446Smrj
5223446Smrj
5233446Smrj WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
5243446Smrj if (!WalkState)
5253446Smrj {
5263446Smrj AcpiOsPrintf ("There is no method currently executing\n");
5273446Smrj return;
5283446Smrj }
5293446Smrj
5303446Smrj AcpiDmDisplayLocals (WalkState);
5313446Smrj }
5323446Smrj
5333446Smrj
5343446Smrj /*******************************************************************************
5353446Smrj *
5363446Smrj * FUNCTION: AcpiDbDisplayArguments
5373446Smrj *
5383446Smrj * PARAMETERS: None
5393446Smrj *
5403446Smrj * RETURN: None
5413446Smrj *
5423446Smrj * DESCRIPTION: Display all arguments for the currently running control method
5433446Smrj *
5443446Smrj ******************************************************************************/
5453446Smrj
5463446Smrj void
AcpiDbDisplayArguments(void)5473446Smrj AcpiDbDisplayArguments (
5483446Smrj void)
5493446Smrj {
5503446Smrj ACPI_WALK_STATE *WalkState;
5513446Smrj
5523446Smrj
5533446Smrj WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
5543446Smrj if (!WalkState)
5553446Smrj {
5563446Smrj AcpiOsPrintf ("There is no method currently executing\n");
5573446Smrj return;
5583446Smrj }
5593446Smrj
5603446Smrj AcpiDmDisplayArguments (WalkState);
5613446Smrj }
5623446Smrj
5633446Smrj
5643446Smrj /*******************************************************************************
5653446Smrj *
5663446Smrj * FUNCTION: AcpiDbDisplayResults
5673446Smrj *
5683446Smrj * PARAMETERS: None
5693446Smrj *
5703446Smrj * RETURN: None
5713446Smrj *
5723446Smrj * DESCRIPTION: Display current contents of a method result stack
5733446Smrj *
5743446Smrj ******************************************************************************/
5753446Smrj
5763446Smrj void
AcpiDbDisplayResults(void)5773446Smrj AcpiDbDisplayResults (
5783446Smrj void)
5793446Smrj {
5803446Smrj UINT32 i;
5813446Smrj ACPI_WALK_STATE *WalkState;
5823446Smrj ACPI_OPERAND_OBJECT *ObjDesc;
5837851SDana.Myers@Sun.COM UINT32 ResultCount = 0;
5843446Smrj ACPI_NAMESPACE_NODE *Node;
5857851SDana.Myers@Sun.COM ACPI_GENERIC_STATE *Frame;
5867851SDana.Myers@Sun.COM UINT32 Index; /* Index onto current frame */
5873446Smrj
5883446Smrj
5893446Smrj WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
5903446Smrj if (!WalkState)
5913446Smrj {
5923446Smrj AcpiOsPrintf ("There is no method currently executing\n");
5933446Smrj return;
5943446Smrj }
5953446Smrj
5963446Smrj ObjDesc = WalkState->MethodDesc;
5973446Smrj Node = WalkState->MethodNode;
5983446Smrj
5993446Smrj if (WalkState->Results)
6003446Smrj {
6017851SDana.Myers@Sun.COM ResultCount = WalkState->ResultCount;
6023446Smrj }
6033446Smrj
6043446Smrj AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n",
6057851SDana.Myers@Sun.COM AcpiUtGetNodeName (Node), ResultCount);
6067851SDana.Myers@Sun.COM
6077851SDana.Myers@Sun.COM /* From the top element of result stack */
6083446Smrj
6097851SDana.Myers@Sun.COM Frame = WalkState->Results;
6107851SDana.Myers@Sun.COM Index = (ResultCount - 1) % ACPI_RESULTS_FRAME_OBJ_NUM;
6117851SDana.Myers@Sun.COM
6127851SDana.Myers@Sun.COM for (i = 0; i < ResultCount; i++)
6133446Smrj {
6147851SDana.Myers@Sun.COM ObjDesc = Frame->Results.ObjDesc[Index];
6153446Smrj AcpiOsPrintf ("Result%d: ", i);
6163446Smrj AcpiDmDisplayInternalObject (ObjDesc, WalkState);
6177851SDana.Myers@Sun.COM if (Index == 0)
6187851SDana.Myers@Sun.COM {
6197851SDana.Myers@Sun.COM Frame = Frame->Results.Next;
6207851SDana.Myers@Sun.COM Index = ACPI_RESULTS_FRAME_OBJ_NUM;
6217851SDana.Myers@Sun.COM }
6227851SDana.Myers@Sun.COM Index--;
6233446Smrj }
6243446Smrj }
6253446Smrj
6263446Smrj
6273446Smrj /*******************************************************************************
6283446Smrj *
6293446Smrj * FUNCTION: AcpiDbDisplayCallingTree
6303446Smrj *
6313446Smrj * PARAMETERS: None
6323446Smrj *
6333446Smrj * RETURN: None
6343446Smrj *
6353446Smrj * DESCRIPTION: Display current calling tree of nested control methods
6363446Smrj *
6373446Smrj ******************************************************************************/
6383446Smrj
6393446Smrj void
AcpiDbDisplayCallingTree(void)6403446Smrj AcpiDbDisplayCallingTree (
6413446Smrj void)
6423446Smrj {
6433446Smrj ACPI_WALK_STATE *WalkState;
6443446Smrj ACPI_NAMESPACE_NODE *Node;
6453446Smrj
6463446Smrj
6473446Smrj WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
6483446Smrj if (!WalkState)
6493446Smrj {
6503446Smrj AcpiOsPrintf ("There is no method currently executing\n");
6513446Smrj return;
6523446Smrj }
6533446Smrj
6543446Smrj Node = WalkState->MethodNode;
6553446Smrj AcpiOsPrintf ("Current Control Method Call Tree\n");
6563446Smrj
6573446Smrj while (WalkState)
6583446Smrj {
6593446Smrj Node = WalkState->MethodNode;
6603446Smrj
6613446Smrj AcpiOsPrintf (" [%4.4s]\n", AcpiUtGetNodeName (Node));
6623446Smrj
6633446Smrj WalkState = WalkState->Next;
6643446Smrj }
6653446Smrj }
6663446Smrj
6673446Smrj
6683446Smrj /*******************************************************************************
6693446Smrj *
6703446Smrj * FUNCTION: AcpiDbDisplayObjectType
6713446Smrj *
6723446Smrj * PARAMETERS: ObjectArg - User entered NS node handle
6733446Smrj *
6743446Smrj * RETURN: None
6753446Smrj *
6763446Smrj * DESCRIPTION: Display type of an arbitrary NS node
6773446Smrj *
6783446Smrj ******************************************************************************/
6793446Smrj
6803446Smrj void
AcpiDbDisplayObjectType(char * ObjectArg)6813446Smrj AcpiDbDisplayObjectType (
6823446Smrj char *ObjectArg)
6833446Smrj {
6843446Smrj ACPI_HANDLE Handle;
6853446Smrj ACPI_DEVICE_INFO *Info;
6863446Smrj ACPI_STATUS Status;
6877851SDana.Myers@Sun.COM UINT32 i;
6883446Smrj
6893446Smrj
6903446Smrj Handle = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
6913446Smrj
692*11225SDana.Myers@Sun.COM Status = AcpiGetObjectInfo (Handle, &Info);
693*11225SDana.Myers@Sun.COM if (ACPI_FAILURE (Status))
6943446Smrj {
695*11225SDana.Myers@Sun.COM AcpiOsPrintf ("Could not get object info, %s\n",
696*11225SDana.Myers@Sun.COM AcpiFormatException (Status));
697*11225SDana.Myers@Sun.COM return;
698*11225SDana.Myers@Sun.COM }
699*11225SDana.Myers@Sun.COM
700*11225SDana.Myers@Sun.COM AcpiOsPrintf ("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n",
701*11225SDana.Myers@Sun.COM ACPI_FORMAT_UINT64 (Info->Address),
702*11225SDana.Myers@Sun.COM Info->CurrentStatus, Info->Flags);
703*11225SDana.Myers@Sun.COM
704*11225SDana.Myers@Sun.COM AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n",
705*11225SDana.Myers@Sun.COM Info->HighestDstates[0], Info->HighestDstates[1],
706*11225SDana.Myers@Sun.COM Info->HighestDstates[2], Info->HighestDstates[3]);
7073446Smrj
708*11225SDana.Myers@Sun.COM AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n",
709*11225SDana.Myers@Sun.COM Info->LowestDstates[0], Info->LowestDstates[1],
710*11225SDana.Myers@Sun.COM Info->LowestDstates[2], Info->LowestDstates[3],
711*11225SDana.Myers@Sun.COM Info->LowestDstates[4]);
712*11225SDana.Myers@Sun.COM
713*11225SDana.Myers@Sun.COM if (Info->Valid & ACPI_VALID_HID)
714*11225SDana.Myers@Sun.COM {
715*11225SDana.Myers@Sun.COM AcpiOsPrintf ("HID: %s\n", Info->HardwareId.String);
716*11225SDana.Myers@Sun.COM }
717*11225SDana.Myers@Sun.COM if (Info->Valid & ACPI_VALID_UID)
718*11225SDana.Myers@Sun.COM {
719*11225SDana.Myers@Sun.COM AcpiOsPrintf ("UID: %s\n", Info->UniqueId.String);
720*11225SDana.Myers@Sun.COM }
721*11225SDana.Myers@Sun.COM if (Info->Valid & ACPI_VALID_CID)
722*11225SDana.Myers@Sun.COM {
723*11225SDana.Myers@Sun.COM for (i = 0; i < Info->CompatibleIdList.Count; i++)
7243446Smrj {
725*11225SDana.Myers@Sun.COM AcpiOsPrintf ("CID %d: %s\n", i,
726*11225SDana.Myers@Sun.COM Info->CompatibleIdList.Ids[i].String);
7273446Smrj }
728*11225SDana.Myers@Sun.COM }
7293446Smrj
730*11225SDana.Myers@Sun.COM ACPI_FREE (Info);
7313446Smrj }
7323446Smrj
7333446Smrj
7343446Smrj /*******************************************************************************
7353446Smrj *
7363446Smrj * FUNCTION: AcpiDbDisplayResultObject
7373446Smrj *
7383446Smrj * PARAMETERS: ObjDesc - Object to be displayed
7393446Smrj * WalkState - Current walk state
7403446Smrj *
7413446Smrj * RETURN: None
7423446Smrj *
7433446Smrj * DESCRIPTION: Display the result of an AML opcode
7443446Smrj *
7453446Smrj * Note: Curently only displays the result object if we are single stepping.
7463446Smrj * However, this output may be useful in other contexts and could be enabled
7473446Smrj * to do so if needed.
7483446Smrj *
7493446Smrj ******************************************************************************/
7503446Smrj
7513446Smrj void
AcpiDbDisplayResultObject(ACPI_OPERAND_OBJECT * ObjDesc,ACPI_WALK_STATE * WalkState)7523446Smrj AcpiDbDisplayResultObject (
7533446Smrj ACPI_OPERAND_OBJECT *ObjDesc,
7543446Smrj ACPI_WALK_STATE *WalkState)
7553446Smrj {
7563446Smrj
7573446Smrj /* Only display if single stepping */
7583446Smrj
7593446Smrj if (!AcpiGbl_CmSingleStep)
7603446Smrj {
7613446Smrj return;
7623446Smrj }
7633446Smrj
7643446Smrj AcpiOsPrintf ("ResultObj: ");
7653446Smrj AcpiDmDisplayInternalObject (ObjDesc, WalkState);
7663446Smrj AcpiOsPrintf ("\n");
7673446Smrj }
7683446Smrj
7693446Smrj
7703446Smrj /*******************************************************************************
7713446Smrj *
7723446Smrj * FUNCTION: AcpiDbDisplayArgumentObject
7733446Smrj *
7743446Smrj * PARAMETERS: ObjDesc - Object to be displayed
7753446Smrj * WalkState - Current walk state
7763446Smrj *
7773446Smrj * RETURN: None
7783446Smrj *
7793446Smrj * DESCRIPTION: Display the result of an AML opcode
7803446Smrj *
7813446Smrj ******************************************************************************/
7823446Smrj
7833446Smrj void
AcpiDbDisplayArgumentObject(ACPI_OPERAND_OBJECT * ObjDesc,ACPI_WALK_STATE * WalkState)7843446Smrj AcpiDbDisplayArgumentObject (
7853446Smrj ACPI_OPERAND_OBJECT *ObjDesc,
7863446Smrj ACPI_WALK_STATE *WalkState)
7873446Smrj {
7883446Smrj
7893446Smrj if (!AcpiGbl_CmSingleStep)
7903446Smrj {
7913446Smrj return;
7923446Smrj }
7933446Smrj
7943446Smrj AcpiOsPrintf ("ArgObj: ");
7953446Smrj AcpiDmDisplayInternalObject (ObjDesc, WalkState);
7963446Smrj }
7973446Smrj
7983446Smrj
7993446Smrj /*******************************************************************************
8003446Smrj *
8013446Smrj * FUNCTION: AcpiDbDisplayGpes
8023446Smrj *
8033446Smrj * PARAMETERS: None
8043446Smrj *
8053446Smrj * RETURN: None
8063446Smrj *
8073446Smrj * DESCRIPTION: Display the current GPE structures
8083446Smrj *
8093446Smrj ******************************************************************************/
8103446Smrj
8113446Smrj void
AcpiDbDisplayGpes(void)8123446Smrj AcpiDbDisplayGpes (
8133446Smrj void)
8143446Smrj {
8153446Smrj ACPI_GPE_BLOCK_INFO *GpeBlock;
8163446Smrj ACPI_GPE_XRUPT_INFO *GpeXruptInfo;
8173446Smrj ACPI_GPE_EVENT_INFO *GpeEventInfo;
8183446Smrj ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
8193446Smrj UINT32 GpeIndex;
8203446Smrj UINT32 Block = 0;
8213446Smrj UINT32 i;
8223446Smrj UINT32 j;
8233446Smrj char Buffer[80];
8243446Smrj ACPI_BUFFER RetBuf;
8253446Smrj ACPI_STATUS Status;
8263446Smrj
8273446Smrj
8283446Smrj RetBuf.Length = sizeof (Buffer);
8293446Smrj RetBuf.Pointer = Buffer;
8303446Smrj
8313446Smrj Block = 0;
8323446Smrj
8333446Smrj /* Walk the GPE lists */
8343446Smrj
8353446Smrj GpeXruptInfo = AcpiGbl_GpeXruptListHead;
8363446Smrj while (GpeXruptInfo)
8373446Smrj {
8383446Smrj GpeBlock = GpeXruptInfo->GpeBlockListHead;
8393446Smrj while (GpeBlock)
8403446Smrj {
8413446Smrj Status = AcpiGetName (GpeBlock->Node, ACPI_FULL_PATHNAME, &RetBuf);
8423446Smrj if (ACPI_FAILURE (Status))
8433446Smrj {
8443446Smrj AcpiOsPrintf ("Could not convert name to pathname\n");
8453446Smrj }
8463446Smrj
8473446Smrj AcpiOsPrintf ("\nBlock %d - Info %p DeviceNode %p [%s]\n",
8483446Smrj Block, GpeBlock, GpeBlock->Node, Buffer);
8493446Smrj
8503446Smrj AcpiOsPrintf (" Registers: %u (%u GPEs)\n",
8513446Smrj GpeBlock->RegisterCount,
8523446Smrj ACPI_MUL_8 (GpeBlock->RegisterCount));
8533446Smrj
8543446Smrj AcpiOsPrintf (" GPE range: 0x%X to 0x%X\n",
8553446Smrj GpeBlock->BlockBaseNumber,
8563446Smrj GpeBlock->BlockBaseNumber +
8573446Smrj (GpeBlock->RegisterCount * 8) -1);
8583446Smrj
8593446Smrj AcpiOsPrintf (
8603446Smrj " RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n",
8613446Smrj GpeBlock->RegisterInfo,
8627851SDana.Myers@Sun.COM ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->StatusAddress.Address),
8637851SDana.Myers@Sun.COM ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->EnableAddress.Address));
8643446Smrj
8653446Smrj AcpiOsPrintf (" EventInfo: %p\n", GpeBlock->EventInfo);
8663446Smrj
8673446Smrj /* Examine each GPE Register within the block */
8683446Smrj
8693446Smrj for (i = 0; i < GpeBlock->RegisterCount; i++)
8703446Smrj {
8713446Smrj GpeRegisterInfo = &GpeBlock->RegisterInfo[i];
8723446Smrj
8733446Smrj AcpiOsPrintf (
8743446Smrj " Reg %u: WakeEnable %2.2X, RunEnable %2.2X Status %8.8X%8.8X Enable %8.8X%8.8X\n",
8753446Smrj i, GpeRegisterInfo->EnableForWake,
8763446Smrj GpeRegisterInfo->EnableForRun,
8777851SDana.Myers@Sun.COM ACPI_FORMAT_UINT64 (GpeRegisterInfo->StatusAddress.Address),
8787851SDana.Myers@Sun.COM ACPI_FORMAT_UINT64 (GpeRegisterInfo->EnableAddress.Address));
8793446Smrj
8803446Smrj /* Now look at the individual GPEs in this byte register */
8813446Smrj
8823446Smrj for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)
8833446Smrj {
8843446Smrj GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j;
8853446Smrj GpeEventInfo = &GpeBlock->EventInfo[GpeIndex];
8863446Smrj
8873446Smrj if (!(GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK))
8883446Smrj {
8893446Smrj /* This GPE is not used (no method or handler) */
8903446Smrj
8913446Smrj continue;
8923446Smrj }
8933446Smrj
8943446Smrj AcpiOsPrintf (
8957851SDana.Myers@Sun.COM " GPE %.3X: %p Flags %2.2X: ",
8963446Smrj GpeBlock->BlockBaseNumber + GpeIndex,
8977851SDana.Myers@Sun.COM GpeEventInfo,
8983446Smrj GpeEventInfo->Flags);
8993446Smrj
9003446Smrj if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED)
9013446Smrj {
9023446Smrj AcpiOsPrintf ("Level, ");
9033446Smrj }
9043446Smrj else
9053446Smrj {
9063446Smrj AcpiOsPrintf ("Edge, ");
9073446Smrj }
9083446Smrj
9093446Smrj switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK)
9103446Smrj {
9113446Smrj case ACPI_GPE_TYPE_WAKE:
9123446Smrj AcpiOsPrintf ("WakeOnly: ");
9133446Smrj break;
9143446Smrj case ACPI_GPE_TYPE_RUNTIME:
9153446Smrj AcpiOsPrintf (" RunOnly: ");
9163446Smrj break;
9173446Smrj case ACPI_GPE_TYPE_WAKE_RUN:
9183446Smrj AcpiOsPrintf (" WakeRun: ");
9193446Smrj break;
9203446Smrj default:
9213446Smrj AcpiOsPrintf (" NotUsed: ");
9223446Smrj break;
9233446Smrj }
9243446Smrj
9253446Smrj if (GpeEventInfo->Flags & ACPI_GPE_WAKE_ENABLED)
9263446Smrj {
9273446Smrj AcpiOsPrintf ("[Wake 1 ");
9283446Smrj }
9293446Smrj else
9303446Smrj {
9313446Smrj AcpiOsPrintf ("[Wake 0 ");
9323446Smrj }
9333446Smrj
9343446Smrj if (GpeEventInfo->Flags & ACPI_GPE_RUN_ENABLED)
9353446Smrj {
9363446Smrj AcpiOsPrintf ("Run 1], ");
9373446Smrj }
9383446Smrj else
9393446Smrj {
9403446Smrj AcpiOsPrintf ("Run 0], ");
9413446Smrj }
9423446Smrj
9433446Smrj switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK)
9443446Smrj {
9453446Smrj case ACPI_GPE_DISPATCH_NOT_USED:
9463446Smrj AcpiOsPrintf ("NotUsed");
9473446Smrj break;
9483446Smrj case ACPI_GPE_DISPATCH_HANDLER:
9493446Smrj AcpiOsPrintf ("Handler");
9503446Smrj break;
9513446Smrj case ACPI_GPE_DISPATCH_METHOD:
9523446Smrj AcpiOsPrintf ("Method");
9533446Smrj break;
9543446Smrj default:
9553446Smrj AcpiOsPrintf ("UNKNOWN: %X",
9563446Smrj GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK);
9573446Smrj break;
9583446Smrj }
9593446Smrj
9603446Smrj AcpiOsPrintf ("\n");
9613446Smrj }
9623446Smrj }
9633446Smrj Block++;
9643446Smrj GpeBlock = GpeBlock->Next;
9653446Smrj }
9663446Smrj GpeXruptInfo = GpeXruptInfo->Next;
9673446Smrj }
9683446Smrj }
9693446Smrj
9703446Smrj #endif /* ACPI_DEBUGGER */
9713446Smrj
972