dbdisply.c revision 207344
167754Smsmith/******************************************************************************* 267754Smsmith * 367754Smsmith * Module Name: dbdisply - debug display commands 467754Smsmith * 567754Smsmith ******************************************************************************/ 667754Smsmith 767754Smsmith/****************************************************************************** 867754Smsmith * 967754Smsmith * 1. Copyright Notice 1067754Smsmith * 11202771Sjkim * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. 1270243Smsmith * All rights reserved. 1367754Smsmith * 1467754Smsmith * 2. License 1567754Smsmith * 1667754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property 1767754Smsmith * rights. You may have additional license terms from the party that provided 1867754Smsmith * you this software, covering your right to use that party's intellectual 1967754Smsmith * property rights. 2067754Smsmith * 2167754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2267754Smsmith * copy of the source code appearing in this file ("Covered Code") an 2367754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2467754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy, 2567754Smsmith * make derivatives, distribute, use and display any portion of the Covered 2667754Smsmith * Code in any form, with the right to sublicense such rights; and 2767754Smsmith * 2867754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 2967754Smsmith * license (with the right to sublicense), under only those claims of Intel 3067754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell, 3167754Smsmith * offer to sell, and import the Covered Code and derivative works thereof 3267754Smsmith * solely to the minimum extent necessary to exercise the above copyright 3367754Smsmith * license, and in no event shall the patent license extend to any additions 3467754Smsmith * to or modifications of the Original Intel Code. No other license or right 3567754Smsmith * is granted directly or by implication, estoppel or otherwise; 3667754Smsmith * 3767754Smsmith * The above copyright and patent license is granted only if the following 3867754Smsmith * conditions are met: 3967754Smsmith * 4067754Smsmith * 3. Conditions 4167754Smsmith * 4267754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4367754Smsmith * Redistribution of source code of any substantial portion of the Covered 4467754Smsmith * Code or modification with rights to further distribute source must include 4567754Smsmith * the above Copyright Notice, the above License, this list of Conditions, 4667754Smsmith * and the following Disclaimer and Export Compliance provision. In addition, 4767754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to 4867754Smsmith * contain a file documenting the changes Licensee made to create that Covered 4967754Smsmith * Code and the date of any change. Licensee must include in that file the 5067754Smsmith * documentation of any changes made by any predecessor Licensee. Licensee 5167754Smsmith * must include a prominent statement that the modification is derived, 5267754Smsmith * directly or indirectly, from Original Intel Code. 5367754Smsmith * 5467754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5567754Smsmith * Redistribution of source code of any substantial portion of the Covered 5667754Smsmith * Code or modification without rights to further distribute source must 5767754Smsmith * include the following Disclaimer and Export Compliance provision in the 5867754Smsmith * documentation and/or other materials provided with distribution. In 5967754Smsmith * addition, Licensee may not authorize further sublicense of source of any 6067754Smsmith * portion of the Covered Code, and must include terms to the effect that the 6167754Smsmith * license from Licensee to its licensee is limited to the intellectual 6267754Smsmith * property embodied in the software Licensee provides to its licensee, and 6367754Smsmith * not to intellectual property embodied in modifications its licensee may 6467754Smsmith * make. 6567754Smsmith * 6667754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any 6767754Smsmith * substantial portion of the Covered Code or modification must reproduce the 6867754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance 6967754Smsmith * provision in the documentation and/or other materials provided with the 7067754Smsmith * distribution. 7167754Smsmith * 7267754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original 7367754Smsmith * Intel Code. 7467754Smsmith * 7567754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7667754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or 7767754Smsmith * other dealings in products derived from or relating to the Covered Code 7867754Smsmith * without prior written authorization from Intel. 7967754Smsmith * 8067754Smsmith * 4. Disclaimer and Export Compliance 8167754Smsmith * 8267754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8367754Smsmith * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8467754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8567754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8667754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 8767754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 8867754Smsmith * PARTICULAR PURPOSE. 8967754Smsmith * 9067754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9167754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9267754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9367754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9467754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9567754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9667754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 9767754Smsmith * LIMITED REMEDY. 9867754Smsmith * 9967754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this 10067754Smsmith * software or system incorporating such software without first obtaining any 10167754Smsmith * required license or other approval from the U. S. Department of Commerce or 10267754Smsmith * any other agency or department of the United States Government. In the 10367754Smsmith * event Licensee exports any such software from the United States or 10467754Smsmith * re-exports any such software from a foreign destination, Licensee shall 10567754Smsmith * ensure that the distribution and export/re-export of the software is in 10667754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the 10767754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor 10867754Smsmith * any of its subsidiaries will export/re-export any technical data, process, 10967754Smsmith * software, or service, directly or indirectly, to any country for which the 11067754Smsmith * United States government or any agency thereof requires an export license, 11167754Smsmith * other governmental approval, or letter of assurance, without first obtaining 11267754Smsmith * such license, approval or letter. 11367754Smsmith * 11467754Smsmith *****************************************************************************/ 11567754Smsmith 11667754Smsmith 117193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 118193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 119193341Sjkim#include <contrib/dev/acpica/include/amlcode.h> 120193341Sjkim#include <contrib/dev/acpica/include/acdispat.h> 121193341Sjkim#include <contrib/dev/acpica/include/acnamesp.h> 122193341Sjkim#include <contrib/dev/acpica/include/acparser.h> 123193341Sjkim#include <contrib/dev/acpica/include/acinterp.h> 124193341Sjkim#include <contrib/dev/acpica/include/acdebug.h> 125193341Sjkim#include <contrib/dev/acpica/include/acdisasm.h> 12667754Smsmith 12767754Smsmith 128102550Siwasaki#ifdef ACPI_DEBUGGER 12967754Smsmith 130102550Siwasaki#define _COMPONENT ACPI_CA_DEBUGGER 13191116Smsmith ACPI_MODULE_NAME ("dbdisply") 13267754Smsmith 133151937Sjkim/* Local prototypes */ 13467754Smsmith 135151937Sjkimstatic void 136151937SjkimAcpiDbDumpParserDescriptor ( 137151937Sjkim ACPI_PARSE_OBJECT *Op); 138151937Sjkim 139151937Sjkimstatic void * 140151937SjkimAcpiDbGetPointer ( 141151937Sjkim void *Target); 142151937Sjkim 143151937Sjkim 144151937Sjkim/******************************************************************************* 14567754Smsmith * 14667754Smsmith * FUNCTION: AcpiDbGetPointer 14767754Smsmith * 14867754Smsmith * PARAMETERS: Target - Pointer to string to be converted 14967754Smsmith * 15067754Smsmith * RETURN: Converted pointer 15167754Smsmith * 15267754Smsmith * DESCRIPTION: Convert an ascii pointer value to a real value 15367754Smsmith * 154151937Sjkim ******************************************************************************/ 15567754Smsmith 156151937Sjkimstatic void * 15767754SmsmithAcpiDbGetPointer ( 15867754Smsmith void *Target) 15967754Smsmith{ 16067754Smsmith void *ObjPtr; 16167754Smsmith 16267754Smsmith 16391116Smsmith ObjPtr = ACPI_TO_POINTER (ACPI_STRTOUL (Target, NULL, 16)); 16467754Smsmith return (ObjPtr); 16567754Smsmith} 16667754Smsmith 16767754Smsmith 16867754Smsmith/******************************************************************************* 16967754Smsmith * 17067754Smsmith * FUNCTION: AcpiDbDumpParserDescriptor 17167754Smsmith * 17267754Smsmith * PARAMETERS: Op - A parser Op descriptor 17367754Smsmith * 17467754Smsmith * RETURN: None 17567754Smsmith * 17667754Smsmith * DESCRIPTION: Display a formatted parser object 17767754Smsmith * 17867754Smsmith ******************************************************************************/ 17967754Smsmith 180151937Sjkimstatic void 18167754SmsmithAcpiDbDumpParserDescriptor ( 18267754Smsmith ACPI_PARSE_OBJECT *Op) 18367754Smsmith{ 18483174Smsmith const ACPI_OPCODE_INFO *Info; 18567754Smsmith 18667754Smsmith 18799679Siwasaki Info = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); 18867754Smsmith 18967754Smsmith AcpiOsPrintf ("Parser Op Descriptor:\n"); 19099679Siwasaki AcpiOsPrintf ("%20.20s : %4.4X\n", "Opcode", Op->Common.AmlOpcode); 19167754Smsmith 192151937Sjkim ACPI_DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name", 193151937Sjkim Info->Name)); 19467754Smsmith 19599679Siwasaki AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Common.Value.Arg); 19699679Siwasaki AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Common.Parent); 19799679Siwasaki AcpiOsPrintf ("%20.20s : %p\n", "NextOp", Op->Common.Next); 19867754Smsmith} 19967754Smsmith 20067754Smsmith 20167754Smsmith/******************************************************************************* 20267754Smsmith * 20367754Smsmith * FUNCTION: AcpiDbDecodeAndDisplayObject 20467754Smsmith * 20567754Smsmith * PARAMETERS: Target - String with object to be displayed. Names 20667754Smsmith * and hex pointers are supported. 20767754Smsmith * OutputType - Byte, Word, Dword, or Qword (B|W|D|Q) 20867754Smsmith * 20967754Smsmith * RETURN: None 21067754Smsmith * 21167754Smsmith * DESCRIPTION: Display a formatted ACPI object 21267754Smsmith * 21367754Smsmith ******************************************************************************/ 21467754Smsmith 21567754Smsmithvoid 21667754SmsmithAcpiDbDecodeAndDisplayObject ( 217114237Snjl char *Target, 218114237Snjl char *OutputType) 21967754Smsmith{ 22067754Smsmith void *ObjPtr; 22167754Smsmith ACPI_NAMESPACE_NODE *Node; 22287031Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 22367754Smsmith UINT32 Display = DB_BYTE_DISPLAY; 224114237Snjl char Buffer[80]; 22567754Smsmith ACPI_BUFFER RetBuf; 22667754Smsmith ACPI_STATUS Status; 22767754Smsmith UINT32 Size; 22867754Smsmith 22967754Smsmith 23067754Smsmith if (!Target) 23167754Smsmith { 23267754Smsmith return; 23367754Smsmith } 23467754Smsmith 23567754Smsmith /* Decode the output type */ 23667754Smsmith 23767754Smsmith if (OutputType) 23867754Smsmith { 239151937Sjkim AcpiUtStrupr (OutputType); 24067754Smsmith if (OutputType[0] == 'W') 24167754Smsmith { 24267754Smsmith Display = DB_WORD_DISPLAY; 24367754Smsmith } 24467754Smsmith else if (OutputType[0] == 'D') 24567754Smsmith { 24667754Smsmith Display = DB_DWORD_DISPLAY; 24767754Smsmith } 24867754Smsmith else if (OutputType[0] == 'Q') 24967754Smsmith { 25067754Smsmith Display = DB_QWORD_DISPLAY; 25167754Smsmith } 25267754Smsmith } 25367754Smsmith 25467754Smsmith RetBuf.Length = sizeof (Buffer); 25567754Smsmith RetBuf.Pointer = Buffer; 25667754Smsmith 25767754Smsmith /* Differentiate between a number and a name */ 25867754Smsmith 25967754Smsmith if ((Target[0] >= 0x30) && (Target[0] <= 0x39)) 26067754Smsmith { 26167754Smsmith ObjPtr = AcpiDbGetPointer (Target); 26267754Smsmith if (!AcpiOsReadable (ObjPtr, 16)) 26367754Smsmith { 264151937Sjkim AcpiOsPrintf ("Address %p is invalid in this address space\n", 265151937Sjkim ObjPtr); 26667754Smsmith return; 26767754Smsmith } 26867754Smsmith 26967754Smsmith /* Decode the object type */ 27067754Smsmith 27191116Smsmith switch (ACPI_GET_DESCRIPTOR_TYPE (ObjPtr)) 27267754Smsmith { 27391116Smsmith case ACPI_DESC_TYPE_NAMED: 27467754Smsmith 27591116Smsmith /* This is a namespace Node */ 27691116Smsmith 27767754Smsmith if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE))) 27867754Smsmith { 279151937Sjkim AcpiOsPrintf ( 280151937Sjkim "Cannot read entire Named object at address %p\n", ObjPtr); 28167754Smsmith return; 28267754Smsmith } 28367754Smsmith 28467754Smsmith Node = ObjPtr; 285151937Sjkim goto DumpNode; 28667754Smsmith 28767754Smsmith 28899679Siwasaki case ACPI_DESC_TYPE_OPERAND: 28991116Smsmith 29091116Smsmith /* This is a ACPI OPERAND OBJECT */ 29191116Smsmith 29267754Smsmith if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT))) 29367754Smsmith { 294151937Sjkim AcpiOsPrintf ("Cannot read entire ACPI object at address %p\n", 295151937Sjkim ObjPtr); 29667754Smsmith return; 29767754Smsmith } 29867754Smsmith 299151937Sjkim AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), Display, 300151937Sjkim ACPI_UINT32_MAX); 30177424Smsmith AcpiExDumpObjectDescriptor (ObjPtr, 1); 30291116Smsmith break; 30367754Smsmith 30467754Smsmith 30591116Smsmith case ACPI_DESC_TYPE_PARSER: 30691116Smsmith 30791116Smsmith /* This is a Parser Op object */ 30891116Smsmith 30967754Smsmith if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT))) 31067754Smsmith { 311151937Sjkim AcpiOsPrintf ( 312151937Sjkim "Cannot read entire Parser object at address %p\n", ObjPtr); 31367754Smsmith return; 31467754Smsmith } 31567754Smsmith 316151937Sjkim AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), Display, 317151937Sjkim ACPI_UINT32_MAX); 31867754Smsmith AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr); 31991116Smsmith break; 32067754Smsmith 32191116Smsmith 32291116Smsmith default: 32391116Smsmith 32491116Smsmith /* Is not a recognizeable object */ 32591116Smsmith 32667754Smsmith Size = 16; 32767754Smsmith if (AcpiOsReadable (ObjPtr, 64)) 32867754Smsmith { 32967754Smsmith Size = 64; 33067754Smsmith } 33167754Smsmith 33267754Smsmith /* Just dump some memory */ 33367754Smsmith 33477424Smsmith AcpiUtDumpBuffer (ObjPtr, Size, Display, ACPI_UINT32_MAX); 33591116Smsmith break; 33667754Smsmith } 33767754Smsmith 33867754Smsmith return; 33967754Smsmith } 34067754Smsmith 34167754Smsmith /* The parameter is a name string that must be resolved to a Named obj */ 34267754Smsmith 34367754Smsmith Node = AcpiDbLocalNsLookup (Target); 34467754Smsmith if (!Node) 34567754Smsmith { 34667754Smsmith return; 34767754Smsmith } 34867754Smsmith 34967754Smsmith 350151937SjkimDumpNode: 351151937Sjkim /* Now dump the NS node */ 35267754Smsmith 35367754Smsmith Status = AcpiGetName (Node, ACPI_FULL_PATHNAME, &RetBuf); 35467754Smsmith if (ACPI_FAILURE (Status)) 35567754Smsmith { 35667754Smsmith AcpiOsPrintf ("Could not convert name to pathname\n"); 35767754Smsmith } 35867754Smsmith 35969746Smsmith else 36069746Smsmith { 361151937Sjkim AcpiOsPrintf ("Object (%p) Pathname: %s\n", 362151937Sjkim Node, (char *) RetBuf.Pointer); 36369746Smsmith } 36469746Smsmith 36567754Smsmith if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) 36667754Smsmith { 36767754Smsmith AcpiOsPrintf ("Invalid Named object at address %p\n", Node); 36867754Smsmith return; 36967754Smsmith } 37067754Smsmith 371151937Sjkim AcpiUtDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE), 372151937Sjkim Display, ACPI_UINT32_MAX); 373167802Sjkim AcpiExDumpNamespaceNode (Node, 1); 37467754Smsmith 37587031Smsmith ObjDesc = AcpiNsGetAttachedObject (Node); 37687031Smsmith if (ObjDesc) 37767754Smsmith { 37887031Smsmith AcpiOsPrintf ("\nAttached Object (%p):\n", ObjDesc); 37987031Smsmith if (!AcpiOsReadable (ObjDesc, sizeof (ACPI_OPERAND_OBJECT))) 38067754Smsmith { 381151937Sjkim AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n", 382151937Sjkim ObjDesc); 38367754Smsmith return; 38467754Smsmith } 38567754Smsmith 386151937Sjkim AcpiUtDumpBuffer ((void *) ObjDesc, sizeof (ACPI_OPERAND_OBJECT), 387151937Sjkim Display, ACPI_UINT32_MAX); 38887031Smsmith AcpiExDumpObjectDescriptor (ObjDesc, 1); 38967754Smsmith } 39067754Smsmith} 39167754Smsmith 39267754Smsmith 39367754Smsmith/******************************************************************************* 39467754Smsmith * 39567754Smsmith * FUNCTION: AcpiDbDisplayMethodInfo 39667754Smsmith * 39767754Smsmith * PARAMETERS: StartOp - Root of the control method parse tree 39867754Smsmith * 39967754Smsmith * RETURN: None 40067754Smsmith * 40167754Smsmith * DESCRIPTION: Display information about the current method 40267754Smsmith * 40367754Smsmith ******************************************************************************/ 40467754Smsmith 40567754Smsmithvoid 40667754SmsmithAcpiDbDisplayMethodInfo ( 40767754Smsmith ACPI_PARSE_OBJECT *StartOp) 40867754Smsmith{ 40967754Smsmith ACPI_WALK_STATE *WalkState; 41067754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 41167754Smsmith ACPI_NAMESPACE_NODE *Node; 41267754Smsmith ACPI_PARSE_OBJECT *RootOp; 41367754Smsmith ACPI_PARSE_OBJECT *Op; 41483174Smsmith const ACPI_OPCODE_INFO *OpInfo; 41567754Smsmith UINT32 NumOps = 0; 41667754Smsmith UINT32 NumOperands = 0; 41767754Smsmith UINT32 NumOperators = 0; 41867754Smsmith UINT32 NumRemainingOps = 0; 41967754Smsmith UINT32 NumRemainingOperands = 0; 42067754Smsmith UINT32 NumRemainingOperators = 0; 42167754Smsmith BOOLEAN CountRemaining = FALSE; 42267754Smsmith 42367754Smsmith 42467754Smsmith WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 42567754Smsmith if (!WalkState) 42667754Smsmith { 42767754Smsmith AcpiOsPrintf ("There is no method currently executing\n"); 42867754Smsmith return; 42967754Smsmith } 43067754Smsmith 43167754Smsmith ObjDesc = WalkState->MethodDesc; 43287031Smsmith Node = WalkState->MethodNode; 43367754Smsmith 434123315Snjl AcpiOsPrintf ("Currently executing control method is [%4.4s]\n", 435123315Snjl AcpiUtGetNodeName (Node)); 436167802Sjkim AcpiOsPrintf ("%X Arguments, SyncLevel = %X\n", 437167802Sjkim (UINT32) ObjDesc->Method.ParamCount, 438167802Sjkim (UINT32) ObjDesc->Method.SyncLevel); 43967754Smsmith 44067754Smsmith 44167754Smsmith RootOp = StartOp; 44299679Siwasaki while (RootOp->Common.Parent) 44367754Smsmith { 44499679Siwasaki RootOp = RootOp->Common.Parent; 44567754Smsmith } 44667754Smsmith 44767754Smsmith Op = RootOp; 44867754Smsmith 44967754Smsmith while (Op) 45067754Smsmith { 45167754Smsmith if (Op == StartOp) 45267754Smsmith { 45367754Smsmith CountRemaining = TRUE; 45467754Smsmith } 45567754Smsmith 45667754Smsmith NumOps++; 45767754Smsmith if (CountRemaining) 45867754Smsmith { 45967754Smsmith NumRemainingOps++; 46067754Smsmith } 46167754Smsmith 46267754Smsmith /* Decode the opcode */ 46367754Smsmith 46499679Siwasaki OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode); 46585756Smsmith switch (OpInfo->Class) 46667754Smsmith { 46785756Smsmith case AML_CLASS_ARGUMENT: 46867754Smsmith if (CountRemaining) 46967754Smsmith { 47067754Smsmith NumRemainingOperands++; 47167754Smsmith } 47267754Smsmith 47367754Smsmith NumOperands++; 47467754Smsmith break; 47567754Smsmith 47685756Smsmith case AML_CLASS_UNKNOWN: 47785756Smsmith /* Bad opcode or ASCII character */ 47885756Smsmith 47985756Smsmith continue; 48085756Smsmith 48167754Smsmith default: 48267754Smsmith if (CountRemaining) 48367754Smsmith { 48467754Smsmith NumRemainingOperators++; 48567754Smsmith } 48667754Smsmith 48767754Smsmith NumOperators++; 48867754Smsmith break; 48967754Smsmith } 49067754Smsmith 49167754Smsmith Op = AcpiPsGetDepthNext (StartOp, Op); 49267754Smsmith } 49367754Smsmith 494151937Sjkim AcpiOsPrintf ( 495151937Sjkim "Method contains: %X AML Opcodes - %X Operators, %X Operands\n", 496151937Sjkim NumOps, NumOperators, NumOperands); 49767754Smsmith 498151937Sjkim AcpiOsPrintf ( 499151937Sjkim "Remaining to execute: %X AML Opcodes - %X Operators, %X Operands\n", 500151937Sjkim NumRemainingOps, NumRemainingOperators, NumRemainingOperands); 50167754Smsmith} 50267754Smsmith 50367754Smsmith 50467754Smsmith/******************************************************************************* 50567754Smsmith * 50667754Smsmith * FUNCTION: AcpiDbDisplayLocals 50767754Smsmith * 50867754Smsmith * PARAMETERS: None 50967754Smsmith * 51067754Smsmith * RETURN: None 51167754Smsmith * 51267754Smsmith * DESCRIPTION: Display all locals for the currently running control method 51367754Smsmith * 51467754Smsmith ******************************************************************************/ 51567754Smsmith 51667754Smsmithvoid 517151937SjkimAcpiDbDisplayLocals ( 518151937Sjkim void) 51967754Smsmith{ 52067754Smsmith ACPI_WALK_STATE *WalkState; 52167754Smsmith 52267754Smsmith 52367754Smsmith WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 52467754Smsmith if (!WalkState) 52567754Smsmith { 52667754Smsmith AcpiOsPrintf ("There is no method currently executing\n"); 52767754Smsmith return; 52867754Smsmith } 52967754Smsmith 530117521Snjl AcpiDmDisplayLocals (WalkState); 53167754Smsmith} 53267754Smsmith 53367754Smsmith 53467754Smsmith/******************************************************************************* 53567754Smsmith * 53667754Smsmith * FUNCTION: AcpiDbDisplayArguments 53767754Smsmith * 53867754Smsmith * PARAMETERS: None 53967754Smsmith * 54067754Smsmith * RETURN: None 54167754Smsmith * 54267754Smsmith * DESCRIPTION: Display all arguments for the currently running control method 54367754Smsmith * 54467754Smsmith ******************************************************************************/ 54567754Smsmith 54667754Smsmithvoid 547151937SjkimAcpiDbDisplayArguments ( 548151937Sjkim void) 54967754Smsmith{ 55067754Smsmith ACPI_WALK_STATE *WalkState; 55167754Smsmith 55267754Smsmith 55367754Smsmith WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 55467754Smsmith if (!WalkState) 55567754Smsmith { 55667754Smsmith AcpiOsPrintf ("There is no method currently executing\n"); 55767754Smsmith return; 55867754Smsmith } 55967754Smsmith 560117521Snjl AcpiDmDisplayArguments (WalkState); 56167754Smsmith} 56267754Smsmith 56367754Smsmith 56467754Smsmith/******************************************************************************* 56567754Smsmith * 56667754Smsmith * FUNCTION: AcpiDbDisplayResults 56767754Smsmith * 56867754Smsmith * PARAMETERS: None 56967754Smsmith * 57067754Smsmith * RETURN: None 57167754Smsmith * 57267754Smsmith * DESCRIPTION: Display current contents of a method result stack 57367754Smsmith * 57467754Smsmith ******************************************************************************/ 57567754Smsmith 57667754Smsmithvoid 577151937SjkimAcpiDbDisplayResults ( 578151937Sjkim void) 57967754Smsmith{ 58067754Smsmith UINT32 i; 58167754Smsmith ACPI_WALK_STATE *WalkState; 58267754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 583167802Sjkim UINT32 ResultCount = 0; 58467754Smsmith ACPI_NAMESPACE_NODE *Node; 585167802Sjkim ACPI_GENERIC_STATE *Frame; 586167802Sjkim UINT32 Index; /* Index onto current frame */ 58767754Smsmith 58867754Smsmith 58967754Smsmith WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 59067754Smsmith if (!WalkState) 59167754Smsmith { 59267754Smsmith AcpiOsPrintf ("There is no method currently executing\n"); 59367754Smsmith return; 59467754Smsmith } 59567754Smsmith 59667754Smsmith ObjDesc = WalkState->MethodDesc; 597123315Snjl Node = WalkState->MethodNode; 59867754Smsmith 59969746Smsmith if (WalkState->Results) 60069746Smsmith { 601167802Sjkim ResultCount = WalkState->ResultCount; 60269746Smsmith } 60367754Smsmith 60487031Smsmith AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n", 605167802Sjkim AcpiUtGetNodeName (Node), ResultCount); 60669746Smsmith 607167802Sjkim /* From the top element of result stack */ 608167802Sjkim 609167802Sjkim Frame = WalkState->Results; 610167802Sjkim Index = (ResultCount - 1) % ACPI_RESULTS_FRAME_OBJ_NUM; 611167802Sjkim 612167802Sjkim for (i = 0; i < ResultCount; i++) 61367754Smsmith { 614167802Sjkim ObjDesc = Frame->Results.ObjDesc[Index]; 61567754Smsmith AcpiOsPrintf ("Result%d: ", i); 616117521Snjl AcpiDmDisplayInternalObject (ObjDesc, WalkState); 617167802Sjkim if (Index == 0) 618167802Sjkim { 619167802Sjkim Frame = Frame->Results.Next; 620167802Sjkim Index = ACPI_RESULTS_FRAME_OBJ_NUM; 621167802Sjkim } 622167802Sjkim Index--; 62367754Smsmith } 62467754Smsmith} 62567754Smsmith 62667754Smsmith 62767754Smsmith/******************************************************************************* 62867754Smsmith * 62967754Smsmith * FUNCTION: AcpiDbDisplayCallingTree 63067754Smsmith * 63167754Smsmith * PARAMETERS: None 63267754Smsmith * 63367754Smsmith * RETURN: None 63467754Smsmith * 63567754Smsmith * DESCRIPTION: Display current calling tree of nested control methods 63667754Smsmith * 63767754Smsmith ******************************************************************************/ 63867754Smsmith 63967754Smsmithvoid 640151937SjkimAcpiDbDisplayCallingTree ( 641151937Sjkim void) 64267754Smsmith{ 64367754Smsmith ACPI_WALK_STATE *WalkState; 64467754Smsmith ACPI_NAMESPACE_NODE *Node; 64567754Smsmith 64667754Smsmith 64767754Smsmith WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 64867754Smsmith if (!WalkState) 64967754Smsmith { 65067754Smsmith AcpiOsPrintf ("There is no method currently executing\n"); 65167754Smsmith return; 65267754Smsmith } 65367754Smsmith 65469450Smsmith Node = WalkState->MethodNode; 65567754Smsmith AcpiOsPrintf ("Current Control Method Call Tree\n"); 65667754Smsmith 65799679Siwasaki while (WalkState) 65867754Smsmith { 65969450Smsmith Node = WalkState->MethodNode; 66067754Smsmith 661123315Snjl AcpiOsPrintf (" [%4.4s]\n", AcpiUtGetNodeName (Node)); 66267754Smsmith 66367754Smsmith WalkState = WalkState->Next; 66467754Smsmith } 66567754Smsmith} 66667754Smsmith 66767754Smsmith 66867754Smsmith/******************************************************************************* 66967754Smsmith * 670117521Snjl * FUNCTION: AcpiDbDisplayObjectType 671117521Snjl * 672123315Snjl * PARAMETERS: ObjectArg - User entered NS node handle 673117521Snjl * 674117521Snjl * RETURN: None 675117521Snjl * 676123315Snjl * DESCRIPTION: Display type of an arbitrary NS node 677117521Snjl * 678117521Snjl ******************************************************************************/ 679117521Snjl 680117521Snjlvoid 681117521SnjlAcpiDbDisplayObjectType ( 682117521Snjl char *ObjectArg) 683117521Snjl{ 684117521Snjl ACPI_HANDLE Handle; 685117521Snjl ACPI_DEVICE_INFO *Info; 686117521Snjl ACPI_STATUS Status; 687193267Sjkim UINT32 i; 688117521Snjl 689117521Snjl 690117521Snjl Handle = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16)); 691117521Snjl 692197104Sjkim Status = AcpiGetObjectInfo (Handle, &Info); 693197104Sjkim if (ACPI_FAILURE (Status)) 694117521Snjl { 695197104Sjkim AcpiOsPrintf ("Could not get object info, %s\n", 696197104Sjkim AcpiFormatException (Status)); 697197104Sjkim return; 698197104Sjkim } 699117521Snjl 700197104Sjkim AcpiOsPrintf ("ADR: %8.8X%8.8X, STA: %8.8X, Flags: %X\n", 701197104Sjkim ACPI_FORMAT_UINT64 (Info->Address), 702197104Sjkim Info->CurrentStatus, Info->Flags); 703117521Snjl 704197104Sjkim AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n", 705197104Sjkim Info->HighestDstates[0], Info->HighestDstates[1], 706197104Sjkim Info->HighestDstates[2], Info->HighestDstates[3]); 707197104Sjkim 708197104Sjkim AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n", 709197104Sjkim Info->LowestDstates[0], Info->LowestDstates[1], 710197104Sjkim Info->LowestDstates[2], Info->LowestDstates[3], 711197104Sjkim Info->LowestDstates[4]); 712197104Sjkim 713197104Sjkim if (Info->Valid & ACPI_VALID_HID) 714197104Sjkim { 715197104Sjkim AcpiOsPrintf ("HID: %s\n", Info->HardwareId.String); 716117521Snjl } 717197104Sjkim if (Info->Valid & ACPI_VALID_UID) 718117521Snjl { 719197104Sjkim AcpiOsPrintf ("UID: %s\n", Info->UniqueId.String); 720117521Snjl } 721197104Sjkim if (Info->Valid & ACPI_VALID_CID) 722197104Sjkim { 723197104Sjkim for (i = 0; i < Info->CompatibleIdList.Count; i++) 724197104Sjkim { 725197104Sjkim AcpiOsPrintf ("CID %d: %s\n", i, 726197104Sjkim Info->CompatibleIdList.Ids[i].String); 727197104Sjkim } 728197104Sjkim } 729197104Sjkim 730197104Sjkim ACPI_FREE (Info); 731117521Snjl} 732117521Snjl 733117521Snjl 734117521Snjl/******************************************************************************* 735117521Snjl * 73667754Smsmith * FUNCTION: AcpiDbDisplayResultObject 73767754Smsmith * 73867754Smsmith * PARAMETERS: ObjDesc - Object to be displayed 73967754Smsmith * WalkState - Current walk state 74067754Smsmith * 74167754Smsmith * RETURN: None 74267754Smsmith * 74367754Smsmith * DESCRIPTION: Display the result of an AML opcode 74467754Smsmith * 74591116Smsmith * Note: Curently only displays the result object if we are single stepping. 74691116Smsmith * However, this output may be useful in other contexts and could be enabled 74791116Smsmith * to do so if needed. 74891116Smsmith * 74967754Smsmith ******************************************************************************/ 75067754Smsmith 75167754Smsmithvoid 75267754SmsmithAcpiDbDisplayResultObject ( 75367754Smsmith ACPI_OPERAND_OBJECT *ObjDesc, 75467754Smsmith ACPI_WALK_STATE *WalkState) 75567754Smsmith{ 75667754Smsmith 75791116Smsmith /* Only display if single stepping */ 75891116Smsmith 75967754Smsmith if (!AcpiGbl_CmSingleStep) 76067754Smsmith { 76167754Smsmith return; 76267754Smsmith } 76367754Smsmith 76467754Smsmith AcpiOsPrintf ("ResultObj: "); 765117521Snjl AcpiDmDisplayInternalObject (ObjDesc, WalkState); 76667754Smsmith AcpiOsPrintf ("\n"); 76767754Smsmith} 76867754Smsmith 76967754Smsmith 77067754Smsmith/******************************************************************************* 77167754Smsmith * 77267754Smsmith * FUNCTION: AcpiDbDisplayArgumentObject 77367754Smsmith * 77467754Smsmith * PARAMETERS: ObjDesc - Object to be displayed 77567754Smsmith * WalkState - Current walk state 77667754Smsmith * 77767754Smsmith * RETURN: None 77867754Smsmith * 77967754Smsmith * DESCRIPTION: Display the result of an AML opcode 78067754Smsmith * 78167754Smsmith ******************************************************************************/ 78267754Smsmith 78367754Smsmithvoid 78467754SmsmithAcpiDbDisplayArgumentObject ( 78567754Smsmith ACPI_OPERAND_OBJECT *ObjDesc, 78667754Smsmith ACPI_WALK_STATE *WalkState) 78767754Smsmith{ 78867754Smsmith 78967754Smsmith if (!AcpiGbl_CmSingleStep) 79067754Smsmith { 79167754Smsmith return; 79267754Smsmith } 79367754Smsmith 79467754Smsmith AcpiOsPrintf ("ArgObj: "); 795117521Snjl AcpiDmDisplayInternalObject (ObjDesc, WalkState); 79667754Smsmith} 79767754Smsmith 798114237Snjl 799114237Snjl/******************************************************************************* 800114237Snjl * 801114237Snjl * FUNCTION: AcpiDbDisplayGpes 802114237Snjl * 803123315Snjl * PARAMETERS: None 804114237Snjl * 805114237Snjl * RETURN: None 806114237Snjl * 807123315Snjl * DESCRIPTION: Display the current GPE structures 808114237Snjl * 809114237Snjl ******************************************************************************/ 810114237Snjl 811114237Snjlvoid 812151937SjkimAcpiDbDisplayGpes ( 813151937Sjkim void) 814114237Snjl{ 815114237Snjl ACPI_GPE_BLOCK_INFO *GpeBlock; 816117521Snjl ACPI_GPE_XRUPT_INFO *GpeXruptInfo; 817129684Snjl ACPI_GPE_EVENT_INFO *GpeEventInfo; 818129684Snjl ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; 819207344Sjkim char *GpeType; 820129684Snjl UINT32 GpeIndex; 821129684Snjl UINT32 Block = 0; 822129684Snjl UINT32 i; 823129684Snjl UINT32 j; 824129684Snjl char Buffer[80]; 825129684Snjl ACPI_BUFFER RetBuf; 826129684Snjl ACPI_STATUS Status; 827114237Snjl 828114237Snjl 829129684Snjl RetBuf.Length = sizeof (Buffer); 830129684Snjl RetBuf.Pointer = Buffer; 831129684Snjl 832129684Snjl Block = 0; 833129684Snjl 834129684Snjl /* Walk the GPE lists */ 835129684Snjl 836117521Snjl GpeXruptInfo = AcpiGbl_GpeXruptListHead; 837117521Snjl while (GpeXruptInfo) 838114237Snjl { 839117521Snjl GpeBlock = GpeXruptInfo->GpeBlockListHead; 840117521Snjl while (GpeBlock) 841117521Snjl { 842129684Snjl Status = AcpiGetName (GpeBlock->Node, ACPI_FULL_PATHNAME, &RetBuf); 843129684Snjl if (ACPI_FAILURE (Status)) 844129684Snjl { 845129684Snjl AcpiOsPrintf ("Could not convert name to pathname\n"); 846129684Snjl } 847129684Snjl 848207344Sjkim if (GpeBlock->Node == AcpiGbl_FadtGpeDevice) 849207344Sjkim { 850207344Sjkim GpeType = "FADT-defined GPE block"; 851207344Sjkim } 852207344Sjkim else 853207344Sjkim { 854207344Sjkim GpeType = "GPE Block Device"; 855207344Sjkim } 856151937Sjkim 857207344Sjkim AcpiOsPrintf ("\nBlock %d - Info %p DeviceNode %p [%s] - %s\n", 858207344Sjkim Block, GpeBlock, GpeBlock->Node, Buffer, GpeType); 859207344Sjkim 860151937Sjkim AcpiOsPrintf (" Registers: %u (%u GPEs)\n", 861206117Sjkim GpeBlock->RegisterCount, GpeBlock->GpeCount); 862151937Sjkim 863206117Sjkim AcpiOsPrintf (" GPE range: 0x%X to 0x%X on interrupt %u\n", 864151937Sjkim GpeBlock->BlockBaseNumber, 865206117Sjkim GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1), 866206117Sjkim GpeXruptInfo->InterruptNumber); 867151937Sjkim 868151937Sjkim AcpiOsPrintf ( 869151937Sjkim " RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n", 870151937Sjkim GpeBlock->RegisterInfo, 871167802Sjkim ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->StatusAddress.Address), 872167802Sjkim ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->EnableAddress.Address)); 873151937Sjkim 874117521Snjl AcpiOsPrintf (" EventInfo: %p\n", GpeBlock->EventInfo); 875114237Snjl 876129684Snjl /* Examine each GPE Register within the block */ 877129684Snjl 878129684Snjl for (i = 0; i < GpeBlock->RegisterCount; i++) 879129684Snjl { 880129684Snjl GpeRegisterInfo = &GpeBlock->RegisterInfo[i]; 881129684Snjl 882129684Snjl AcpiOsPrintf ( 883206117Sjkim " Reg %u: (GPE %.2X-%.2X) RunEnable %2.2X WakeEnable %2.2X" 884206117Sjkim " Status %8.8X%8.8X Enable %8.8X%8.8X\n", 885206117Sjkim i, GpeRegisterInfo->BaseGpeNumber, 886206117Sjkim GpeRegisterInfo->BaseGpeNumber + (ACPI_GPE_REGISTER_WIDTH - 1), 887151937Sjkim GpeRegisterInfo->EnableForRun, 888206117Sjkim GpeRegisterInfo->EnableForWake, 889167802Sjkim ACPI_FORMAT_UINT64 (GpeRegisterInfo->StatusAddress.Address), 890167802Sjkim ACPI_FORMAT_UINT64 (GpeRegisterInfo->EnableAddress.Address)); 891129684Snjl 892129684Snjl /* Now look at the individual GPEs in this byte register */ 893129684Snjl 894129684Snjl for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) 895129684Snjl { 896129684Snjl GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j; 897129684Snjl GpeEventInfo = &GpeBlock->EventInfo[GpeIndex]; 898129684Snjl 899129684Snjl if (!(GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK)) 900129684Snjl { 901206117Sjkim /* This GPE is not used (no method or handler), ignore it */ 902129684Snjl 903129684Snjl continue; 904129684Snjl } 905129684Snjl 906129684Snjl AcpiOsPrintf ( 907206117Sjkim " GPE %.2X: %p RunRefs %2.2X WakeRefs %2.2X Flags %2.2X (", 908206117Sjkim GpeBlock->BlockBaseNumber + GpeIndex, GpeEventInfo, 909206117Sjkim GpeEventInfo->RuntimeCount, GpeEventInfo->WakeupCount, 910151937Sjkim GpeEventInfo->Flags); 911129684Snjl 912206117Sjkim /* Decode the flags byte */ 913206117Sjkim 914129684Snjl if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED) 915129684Snjl { 916129684Snjl AcpiOsPrintf ("Level, "); 917129684Snjl } 918129684Snjl else 919129684Snjl { 920129684Snjl AcpiOsPrintf ("Edge, "); 921129684Snjl } 922129684Snjl 923206117Sjkim if (GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE) 924129684Snjl { 925206117Sjkim AcpiOsPrintf ("CanWake, "); 926129684Snjl } 927129684Snjl else 928129684Snjl { 929206117Sjkim AcpiOsPrintf ("RunOnly, "); 930129684Snjl } 931129684Snjl 932129684Snjl switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) 933129684Snjl { 934129684Snjl case ACPI_GPE_DISPATCH_NOT_USED: 935129684Snjl AcpiOsPrintf ("NotUsed"); 936129684Snjl break; 937129684Snjl case ACPI_GPE_DISPATCH_HANDLER: 938129684Snjl AcpiOsPrintf ("Handler"); 939129684Snjl break; 940129684Snjl case ACPI_GPE_DISPATCH_METHOD: 941129684Snjl AcpiOsPrintf ("Method"); 942129684Snjl break; 943129684Snjl default: 944129684Snjl AcpiOsPrintf ("UNKNOWN: %X", 945129684Snjl GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK); 946129684Snjl break; 947129684Snjl } 948129684Snjl 949206117Sjkim AcpiOsPrintf (")\n"); 950129684Snjl } 951129684Snjl } 952129684Snjl Block++; 953117521Snjl GpeBlock = GpeBlock->Next; 954117521Snjl } 955117521Snjl GpeXruptInfo = GpeXruptInfo->Next; 956114237Snjl } 957114237Snjl} 958114237Snjl 959102550Siwasaki#endif /* ACPI_DEBUGGER */ 96067754Smsmith 961