dbdisply.c revision 167802
167754Smsmith/******************************************************************************* 267754Smsmith * 367754Smsmith * Module Name: dbdisply - debug display commands 4167802Sjkim * $Revision: 1.120 $ 567754Smsmith * 667754Smsmith ******************************************************************************/ 767754Smsmith 867754Smsmith/****************************************************************************** 967754Smsmith * 1067754Smsmith * 1. Copyright Notice 1167754Smsmith * 12167802Sjkim * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. 1370243Smsmith * All rights reserved. 1467754Smsmith * 1567754Smsmith * 2. License 1667754Smsmith * 1767754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property 1867754Smsmith * rights. You may have additional license terms from the party that provided 1967754Smsmith * you this software, covering your right to use that party's intellectual 2067754Smsmith * property rights. 2167754Smsmith * 2267754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2367754Smsmith * copy of the source code appearing in this file ("Covered Code") an 2467754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2567754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy, 2667754Smsmith * make derivatives, distribute, use and display any portion of the Covered 2767754Smsmith * Code in any form, with the right to sublicense such rights; and 2867754Smsmith * 2967754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 3067754Smsmith * license (with the right to sublicense), under only those claims of Intel 3167754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell, 3267754Smsmith * offer to sell, and import the Covered Code and derivative works thereof 3367754Smsmith * solely to the minimum extent necessary to exercise the above copyright 3467754Smsmith * license, and in no event shall the patent license extend to any additions 3567754Smsmith * to or modifications of the Original Intel Code. No other license or right 3667754Smsmith * is granted directly or by implication, estoppel or otherwise; 3767754Smsmith * 3867754Smsmith * The above copyright and patent license is granted only if the following 3967754Smsmith * conditions are met: 4067754Smsmith * 4167754Smsmith * 3. Conditions 4267754Smsmith * 4367754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4467754Smsmith * Redistribution of source code of any substantial portion of the Covered 4567754Smsmith * Code or modification with rights to further distribute source must include 4667754Smsmith * the above Copyright Notice, the above License, this list of Conditions, 4767754Smsmith * and the following Disclaimer and Export Compliance provision. In addition, 4867754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to 4967754Smsmith * contain a file documenting the changes Licensee made to create that Covered 5067754Smsmith * Code and the date of any change. Licensee must include in that file the 5167754Smsmith * documentation of any changes made by any predecessor Licensee. Licensee 5267754Smsmith * must include a prominent statement that the modification is derived, 5367754Smsmith * directly or indirectly, from Original Intel Code. 5467754Smsmith * 5567754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5667754Smsmith * Redistribution of source code of any substantial portion of the Covered 5767754Smsmith * Code or modification without rights to further distribute source must 5867754Smsmith * include the following Disclaimer and Export Compliance provision in the 5967754Smsmith * documentation and/or other materials provided with distribution. In 6067754Smsmith * addition, Licensee may not authorize further sublicense of source of any 6167754Smsmith * portion of the Covered Code, and must include terms to the effect that the 6267754Smsmith * license from Licensee to its licensee is limited to the intellectual 6367754Smsmith * property embodied in the software Licensee provides to its licensee, and 6467754Smsmith * not to intellectual property embodied in modifications its licensee may 6567754Smsmith * make. 6667754Smsmith * 6767754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any 6867754Smsmith * substantial portion of the Covered Code or modification must reproduce the 6967754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance 7067754Smsmith * provision in the documentation and/or other materials provided with the 7167754Smsmith * distribution. 7267754Smsmith * 7367754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original 7467754Smsmith * Intel Code. 7567754Smsmith * 7667754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7767754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or 7867754Smsmith * other dealings in products derived from or relating to the Covered Code 7967754Smsmith * without prior written authorization from Intel. 8067754Smsmith * 8167754Smsmith * 4. Disclaimer and Export Compliance 8267754Smsmith * 8367754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8467754Smsmith * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8567754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8667754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8767754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 8867754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 8967754Smsmith * PARTICULAR PURPOSE. 9067754Smsmith * 9167754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9267754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9367754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9467754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9567754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9667754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9767754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 9867754Smsmith * LIMITED REMEDY. 9967754Smsmith * 10067754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this 10167754Smsmith * software or system incorporating such software without first obtaining any 10267754Smsmith * required license or other approval from the U. S. Department of Commerce or 10367754Smsmith * any other agency or department of the United States Government. In the 10467754Smsmith * event Licensee exports any such software from the United States or 10567754Smsmith * re-exports any such software from a foreign destination, Licensee shall 10667754Smsmith * ensure that the distribution and export/re-export of the software is in 10767754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the 10867754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor 10967754Smsmith * any of its subsidiaries will export/re-export any technical data, process, 11067754Smsmith * software, or service, directly or indirectly, to any country for which the 11167754Smsmith * United States government or any agency thereof requires an export license, 11267754Smsmith * other governmental approval, or letter of assurance, without first obtaining 11367754Smsmith * such license, approval or letter. 11467754Smsmith * 11567754Smsmith *****************************************************************************/ 11667754Smsmith 11767754Smsmith 118151600Sobrien#include <contrib/dev/acpica/acpi.h> 119151600Sobrien#include <contrib/dev/acpica/amlcode.h> 120151600Sobrien#include <contrib/dev/acpica/acdispat.h> 121151600Sobrien#include <contrib/dev/acpica/acnamesp.h> 122151600Sobrien#include <contrib/dev/acpica/acparser.h> 123151600Sobrien#include <contrib/dev/acpica/acinterp.h> 124151600Sobrien#include <contrib/dev/acpica/acdebug.h> 125151600Sobrien#include <contrib/dev/acpica/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_BUFFER Buffer; 686117521Snjl ACPI_DEVICE_INFO *Info; 687117521Snjl ACPI_STATUS Status; 688117521Snjl ACPI_NATIVE_UINT i; 689117521Snjl 690117521Snjl 691117521Snjl Handle = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16)); 692117521Snjl Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 693117521Snjl 694117521Snjl Status = AcpiGetObjectInfo (Handle, &Buffer); 695117521Snjl if (ACPI_SUCCESS (Status)) 696117521Snjl { 697117521Snjl Info = Buffer.Pointer; 698151937Sjkim AcpiOsPrintf ( 699151937Sjkim "S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X HID: %s, ADR: %8.8X%8.8X, Status %8.8X\n", 700151937Sjkim Info->HighestDstates[0], Info->HighestDstates[1], 701151937Sjkim Info->HighestDstates[2], Info->HighestDstates[3], 702151937Sjkim Info->HardwareId.Value, 703151937Sjkim ACPI_FORMAT_UINT64 (Info->Address), 704151937Sjkim Info->CurrentStatus); 705117521Snjl 706117521Snjl if (Info->Valid & ACPI_VALID_CID) 707117521Snjl { 708117521Snjl for (i = 0; i < Info->CompatibilityId.Count; i++) 709117521Snjl { 710151937Sjkim AcpiOsPrintf ("CID #%d: %s\n", (UINT32) i, 711151937Sjkim Info->CompatibilityId.Id[i].Value); 712117521Snjl } 713117521Snjl } 714117521Snjl 715167802Sjkim ACPI_FREE (Info); 716117521Snjl } 717117521Snjl else 718117521Snjl { 719117521Snjl AcpiOsPrintf ("%s\n", AcpiFormatException (Status)); 720117521Snjl } 721117521Snjl} 722117521Snjl 723117521Snjl 724117521Snjl/******************************************************************************* 725117521Snjl * 72667754Smsmith * FUNCTION: AcpiDbDisplayResultObject 72767754Smsmith * 72867754Smsmith * PARAMETERS: ObjDesc - Object to be displayed 72967754Smsmith * WalkState - Current walk state 73067754Smsmith * 73167754Smsmith * RETURN: None 73267754Smsmith * 73367754Smsmith * DESCRIPTION: Display the result of an AML opcode 73467754Smsmith * 73591116Smsmith * Note: Curently only displays the result object if we are single stepping. 73691116Smsmith * However, this output may be useful in other contexts and could be enabled 73791116Smsmith * to do so if needed. 73891116Smsmith * 73967754Smsmith ******************************************************************************/ 74067754Smsmith 74167754Smsmithvoid 74267754SmsmithAcpiDbDisplayResultObject ( 74367754Smsmith ACPI_OPERAND_OBJECT *ObjDesc, 74467754Smsmith ACPI_WALK_STATE *WalkState) 74567754Smsmith{ 74667754Smsmith 74791116Smsmith /* Only display if single stepping */ 74891116Smsmith 74967754Smsmith if (!AcpiGbl_CmSingleStep) 75067754Smsmith { 75167754Smsmith return; 75267754Smsmith } 75367754Smsmith 75467754Smsmith AcpiOsPrintf ("ResultObj: "); 755117521Snjl AcpiDmDisplayInternalObject (ObjDesc, WalkState); 75667754Smsmith AcpiOsPrintf ("\n"); 75767754Smsmith} 75867754Smsmith 75967754Smsmith 76067754Smsmith/******************************************************************************* 76167754Smsmith * 76267754Smsmith * FUNCTION: AcpiDbDisplayArgumentObject 76367754Smsmith * 76467754Smsmith * PARAMETERS: ObjDesc - Object to be displayed 76567754Smsmith * WalkState - Current walk state 76667754Smsmith * 76767754Smsmith * RETURN: None 76867754Smsmith * 76967754Smsmith * DESCRIPTION: Display the result of an AML opcode 77067754Smsmith * 77167754Smsmith ******************************************************************************/ 77267754Smsmith 77367754Smsmithvoid 77467754SmsmithAcpiDbDisplayArgumentObject ( 77567754Smsmith ACPI_OPERAND_OBJECT *ObjDesc, 77667754Smsmith ACPI_WALK_STATE *WalkState) 77767754Smsmith{ 77867754Smsmith 77967754Smsmith if (!AcpiGbl_CmSingleStep) 78067754Smsmith { 78167754Smsmith return; 78267754Smsmith } 78367754Smsmith 78467754Smsmith AcpiOsPrintf ("ArgObj: "); 785117521Snjl AcpiDmDisplayInternalObject (ObjDesc, WalkState); 78667754Smsmith} 78767754Smsmith 788114237Snjl 789114237Snjl/******************************************************************************* 790114237Snjl * 791114237Snjl * FUNCTION: AcpiDbDisplayGpes 792114237Snjl * 793123315Snjl * PARAMETERS: None 794114237Snjl * 795114237Snjl * RETURN: None 796114237Snjl * 797123315Snjl * DESCRIPTION: Display the current GPE structures 798114237Snjl * 799114237Snjl ******************************************************************************/ 800114237Snjl 801114237Snjlvoid 802151937SjkimAcpiDbDisplayGpes ( 803151937Sjkim void) 804114237Snjl{ 805114237Snjl ACPI_GPE_BLOCK_INFO *GpeBlock; 806117521Snjl ACPI_GPE_XRUPT_INFO *GpeXruptInfo; 807129684Snjl ACPI_GPE_EVENT_INFO *GpeEventInfo; 808129684Snjl ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; 809129684Snjl UINT32 GpeIndex; 810129684Snjl UINT32 Block = 0; 811129684Snjl UINT32 i; 812129684Snjl UINT32 j; 813129684Snjl char Buffer[80]; 814129684Snjl ACPI_BUFFER RetBuf; 815129684Snjl ACPI_STATUS Status; 816114237Snjl 817114237Snjl 818129684Snjl RetBuf.Length = sizeof (Buffer); 819129684Snjl RetBuf.Pointer = Buffer; 820129684Snjl 821129684Snjl Block = 0; 822129684Snjl 823129684Snjl /* Walk the GPE lists */ 824129684Snjl 825117521Snjl GpeXruptInfo = AcpiGbl_GpeXruptListHead; 826117521Snjl while (GpeXruptInfo) 827114237Snjl { 828117521Snjl GpeBlock = GpeXruptInfo->GpeBlockListHead; 829117521Snjl while (GpeBlock) 830117521Snjl { 831129684Snjl Status = AcpiGetName (GpeBlock->Node, ACPI_FULL_PATHNAME, &RetBuf); 832129684Snjl if (ACPI_FAILURE (Status)) 833129684Snjl { 834129684Snjl AcpiOsPrintf ("Could not convert name to pathname\n"); 835129684Snjl } 836129684Snjl 837129684Snjl AcpiOsPrintf ("\nBlock %d - Info %p DeviceNode %p [%s]\n", 838151937Sjkim Block, GpeBlock, GpeBlock->Node, Buffer); 839151937Sjkim 840151937Sjkim AcpiOsPrintf (" Registers: %u (%u GPEs)\n", 841151937Sjkim GpeBlock->RegisterCount, 842151937Sjkim ACPI_MUL_8 (GpeBlock->RegisterCount)); 843151937Sjkim 844129684Snjl AcpiOsPrintf (" GPE range: 0x%X to 0x%X\n", 845151937Sjkim GpeBlock->BlockBaseNumber, 846151937Sjkim GpeBlock->BlockBaseNumber + 847151937Sjkim (GpeBlock->RegisterCount * 8) -1); 848151937Sjkim 849151937Sjkim AcpiOsPrintf ( 850151937Sjkim " RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n", 851151937Sjkim GpeBlock->RegisterInfo, 852167802Sjkim ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->StatusAddress.Address), 853167802Sjkim ACPI_FORMAT_UINT64 (GpeBlock->RegisterInfo->EnableAddress.Address)); 854151937Sjkim 855117521Snjl AcpiOsPrintf (" EventInfo: %p\n", GpeBlock->EventInfo); 856114237Snjl 857129684Snjl /* Examine each GPE Register within the block */ 858129684Snjl 859129684Snjl for (i = 0; i < GpeBlock->RegisterCount; i++) 860129684Snjl { 861129684Snjl GpeRegisterInfo = &GpeBlock->RegisterInfo[i]; 862129684Snjl 863129684Snjl AcpiOsPrintf ( 864151937Sjkim " Reg %u: WakeEnable %2.2X, RunEnable %2.2X Status %8.8X%8.8X Enable %8.8X%8.8X\n", 865151937Sjkim i, GpeRegisterInfo->EnableForWake, 866151937Sjkim GpeRegisterInfo->EnableForRun, 867167802Sjkim ACPI_FORMAT_UINT64 (GpeRegisterInfo->StatusAddress.Address), 868167802Sjkim ACPI_FORMAT_UINT64 (GpeRegisterInfo->EnableAddress.Address)); 869129684Snjl 870129684Snjl /* Now look at the individual GPEs in this byte register */ 871129684Snjl 872129684Snjl for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++) 873129684Snjl { 874129684Snjl GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j; 875129684Snjl GpeEventInfo = &GpeBlock->EventInfo[GpeIndex]; 876129684Snjl 877129684Snjl if (!(GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK)) 878129684Snjl { 879129684Snjl /* This GPE is not used (no method or handler) */ 880129684Snjl 881129684Snjl continue; 882129684Snjl } 883129684Snjl 884129684Snjl AcpiOsPrintf ( 885167802Sjkim " GPE %.3X: %p Flags %2.2X: ", 886151937Sjkim GpeBlock->BlockBaseNumber + GpeIndex, 887167802Sjkim GpeEventInfo, 888151937Sjkim GpeEventInfo->Flags); 889129684Snjl 890129684Snjl if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED) 891129684Snjl { 892129684Snjl AcpiOsPrintf ("Level, "); 893129684Snjl } 894129684Snjl else 895129684Snjl { 896129684Snjl AcpiOsPrintf ("Edge, "); 897129684Snjl } 898129684Snjl 899129684Snjl switch (GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) 900129684Snjl { 901129684Snjl case ACPI_GPE_TYPE_WAKE: 902129684Snjl AcpiOsPrintf ("WakeOnly: "); 903129684Snjl break; 904129684Snjl case ACPI_GPE_TYPE_RUNTIME: 905129684Snjl AcpiOsPrintf (" RunOnly: "); 906129684Snjl break; 907129684Snjl case ACPI_GPE_TYPE_WAKE_RUN: 908129684Snjl AcpiOsPrintf (" WakeRun: "); 909129684Snjl break; 910129684Snjl default: 911129684Snjl AcpiOsPrintf (" NotUsed: "); 912129684Snjl break; 913129684Snjl } 914129684Snjl 915129684Snjl if (GpeEventInfo->Flags & ACPI_GPE_WAKE_ENABLED) 916129684Snjl { 917129684Snjl AcpiOsPrintf ("[Wake 1 "); 918129684Snjl } 919129684Snjl else 920129684Snjl { 921129684Snjl AcpiOsPrintf ("[Wake 0 "); 922129684Snjl } 923129684Snjl 924129684Snjl if (GpeEventInfo->Flags & ACPI_GPE_RUN_ENABLED) 925129684Snjl { 926129684Snjl AcpiOsPrintf ("Run 1], "); 927129684Snjl } 928129684Snjl else 929129684Snjl { 930129684Snjl AcpiOsPrintf ("Run 0], "); 931129684Snjl } 932129684Snjl 933129684Snjl switch (GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) 934129684Snjl { 935129684Snjl case ACPI_GPE_DISPATCH_NOT_USED: 936129684Snjl AcpiOsPrintf ("NotUsed"); 937129684Snjl break; 938129684Snjl case ACPI_GPE_DISPATCH_HANDLER: 939129684Snjl AcpiOsPrintf ("Handler"); 940129684Snjl break; 941129684Snjl case ACPI_GPE_DISPATCH_METHOD: 942129684Snjl AcpiOsPrintf ("Method"); 943129684Snjl break; 944129684Snjl default: 945129684Snjl AcpiOsPrintf ("UNKNOWN: %X", 946129684Snjl GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK); 947129684Snjl break; 948129684Snjl } 949129684Snjl 950129684Snjl AcpiOsPrintf ("\n"); 951129684Snjl } 952129684Snjl } 953129684Snjl Block++; 954117521Snjl GpeBlock = GpeBlock->Next; 955117521Snjl } 956117521Snjl GpeXruptInfo = GpeXruptInfo->Next; 957114237Snjl } 958114237Snjl} 959114237Snjl 960102550Siwasaki#endif /* ACPI_DEBUGGER */ 96167754Smsmith 962