Path: blob/main/sys/contrib/dev/acpica/components/debugger/dbdisply.c
48406 views
/*******************************************************************************1*2* Module Name: dbdisply - debug display commands3*4******************************************************************************/56/******************************************************************************7*8* 1. Copyright Notice9*10* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.11* All rights reserved.12*13* 2. License14*15* 2.1. This is your license from Intel Corp. under its intellectual property16* rights. You may have additional license terms from the party that provided17* you this software, covering your right to use that party's intellectual18* property rights.19*20* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a21* copy of the source code appearing in this file ("Covered Code") an22* irrevocable, perpetual, worldwide license under Intel's copyrights in the23* base code distributed originally by Intel ("Original Intel Code") to copy,24* make derivatives, distribute, use and display any portion of the Covered25* Code in any form, with the right to sublicense such rights; and26*27* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent28* license (with the right to sublicense), under only those claims of Intel29* patents that are infringed by the Original Intel Code, to make, use, sell,30* offer to sell, and import the Covered Code and derivative works thereof31* solely to the minimum extent necessary to exercise the above copyright32* license, and in no event shall the patent license extend to any additions33* to or modifications of the Original Intel Code. No other license or right34* is granted directly or by implication, estoppel or otherwise;35*36* The above copyright and patent license is granted only if the following37* conditions are met:38*39* 3. Conditions40*41* 3.1. Redistribution of Source with Rights to Further Distribute Source.42* Redistribution of source code of any substantial portion of the Covered43* Code or modification with rights to further distribute source must include44* the above Copyright Notice, the above License, this list of Conditions,45* and the following Disclaimer and Export Compliance provision. In addition,46* Licensee must cause all Covered Code to which Licensee contributes to47* contain a file documenting the changes Licensee made to create that Covered48* Code and the date of any change. Licensee must include in that file the49* documentation of any changes made by any predecessor Licensee. Licensee50* must include a prominent statement that the modification is derived,51* directly or indirectly, from Original Intel Code.52*53* 3.2. Redistribution of Source with no Rights to Further Distribute Source.54* Redistribution of source code of any substantial portion of the Covered55* Code or modification without rights to further distribute source must56* include the following Disclaimer and Export Compliance provision in the57* documentation and/or other materials provided with distribution. In58* addition, Licensee may not authorize further sublicense of source of any59* portion of the Covered Code, and must include terms to the effect that the60* license from Licensee to its licensee is limited to the intellectual61* property embodied in the software Licensee provides to its licensee, and62* not to intellectual property embodied in modifications its licensee may63* make.64*65* 3.3. Redistribution of Executable. Redistribution in executable form of any66* substantial portion of the Covered Code or modification must reproduce the67* above Copyright Notice, and the following Disclaimer and Export Compliance68* provision in the documentation and/or other materials provided with the69* distribution.70*71* 3.4. Intel retains all right, title, and interest in and to the Original72* Intel Code.73*74* 3.5. Neither the name Intel nor any other trademark owned or controlled by75* Intel shall be used in advertising or otherwise to promote the sale, use or76* other dealings in products derived from or relating to the Covered Code77* without prior written authorization from Intel.78*79* 4. Disclaimer and Export Compliance80*81* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED82* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE83* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,84* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY85* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY86* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A87* PARTICULAR PURPOSE.88*89* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES90* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR91* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,92* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY93* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL94* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS95* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY96* LIMITED REMEDY.97*98* 4.3. Licensee shall not export, either directly or indirectly, any of this99* software or system incorporating such software without first obtaining any100* required license or other approval from the U. S. Department of Commerce or101* any other agency or department of the United States Government. In the102* event Licensee exports any such software from the United States or103* re-exports any such software from a foreign destination, Licensee shall104* ensure that the distribution and export/re-export of the software is in105* compliance with all laws, regulations, orders, or other restrictions of the106* U.S. Export Administration Regulations. Licensee agrees that neither it nor107* any of its subsidiaries will export/re-export any technical data, process,108* software, or service, directly or indirectly, to any country for which the109* United States government or any agency thereof requires an export license,110* other governmental approval, or letter of assurance, without first obtaining111* such license, approval or letter.112*113*****************************************************************************114*115* Alternatively, you may choose to be licensed under the terms of the116* following license:117*118* Redistribution and use in source and binary forms, with or without119* modification, are permitted provided that the following conditions120* are met:121* 1. Redistributions of source code must retain the above copyright122* notice, this list of conditions, and the following disclaimer,123* without modification.124* 2. Redistributions in binary form must reproduce at minimum a disclaimer125* substantially similar to the "NO WARRANTY" disclaimer below126* ("Disclaimer") and any redistribution must be conditioned upon127* including a substantially similar Disclaimer requirement for further128* binary redistribution.129* 3. Neither the names of the above-listed copyright holders nor the names130* of any contributors may be used to endorse or promote products derived131* from this software without specific prior written permission.132*133* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS134* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT135* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR136* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT137* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,138* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT139* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,140* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY141* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT142* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE143* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.144*145* Alternatively, you may choose to be licensed under the terms of the146* GNU General Public License ("GPL") version 2 as published by the Free147* Software Foundation.148*149*****************************************************************************/150151#include <contrib/dev/acpica/include/acpi.h>152#include <contrib/dev/acpica/include/accommon.h>153#include <contrib/dev/acpica/include/amlcode.h>154#include <contrib/dev/acpica/include/acdispat.h>155#include <contrib/dev/acpica/include/acnamesp.h>156#include <contrib/dev/acpica/include/acparser.h>157#include <contrib/dev/acpica/include/acinterp.h>158#include <contrib/dev/acpica/include/acevents.h>159#include <contrib/dev/acpica/include/acdebug.h>160161162#define _COMPONENT ACPI_CA_DEBUGGER163ACPI_MODULE_NAME ("dbdisply")164165/* Local prototypes */166167static void168AcpiDbDumpParserDescriptor (169ACPI_PARSE_OBJECT *Op);170171static void *172AcpiDbGetPointer (173void *Target);174175static ACPI_STATUS176AcpiDbDisplayNonRootHandlers (177ACPI_HANDLE ObjHandle,178UINT32 NestingLevel,179void *Context,180void **ReturnValue);181182/*183* System handler information.184* Used for Handlers command, in AcpiDbDisplayHandlers.185*/186#define ACPI_PREDEFINED_PREFIX "%25s (%.2X) : "187#define ACPI_HANDLER_NAME_STRING "%30s : "188#define ACPI_HANDLER_PRESENT_STRING "%-9s (%p)\n"189#define ACPI_HANDLER_PRESENT_STRING2 "%-9s (%p)"190#define ACPI_HANDLER_NOT_PRESENT_STRING "%-9s\n"191192/* All predefined Address Space IDs */193194static ACPI_ADR_SPACE_TYPE AcpiGbl_SpaceIdList[] =195{196ACPI_ADR_SPACE_SYSTEM_MEMORY,197ACPI_ADR_SPACE_SYSTEM_IO,198ACPI_ADR_SPACE_PCI_CONFIG,199ACPI_ADR_SPACE_EC,200ACPI_ADR_SPACE_SMBUS,201ACPI_ADR_SPACE_CMOS,202ACPI_ADR_SPACE_PCI_BAR_TARGET,203ACPI_ADR_SPACE_IPMI,204ACPI_ADR_SPACE_GPIO,205ACPI_ADR_SPACE_GSBUS,206ACPI_ADR_SPACE_PLATFORM_COMM,207ACPI_ADR_SPACE_PLATFORM_RT,208ACPI_ADR_SPACE_DATA_TABLE,209ACPI_ADR_SPACE_FIXED_HARDWARE210};211212/* Global handler information */213214typedef struct acpi_handler_info215{216void *Handler;217char *Name;218219} ACPI_HANDLER_INFO;220221static ACPI_HANDLER_INFO AcpiGbl_HandlerList[] =222{223{&AcpiGbl_GlobalNotify[0].Handler, "System Notifications"},224{&AcpiGbl_GlobalNotify[1].Handler, "Device Notifications"},225{&AcpiGbl_TableHandler, "ACPI Table Events"},226{&AcpiGbl_ExceptionHandler, "Control Method Exceptions"},227{&AcpiGbl_InterfaceHandler, "OSI Invocations"}228};229230231/*******************************************************************************232*233* FUNCTION: AcpiDbGetPointer234*235* PARAMETERS: Target - Pointer to string to be converted236*237* RETURN: Converted pointer238*239* DESCRIPTION: Convert an ascii pointer value to a real value240*241******************************************************************************/242243static void *244AcpiDbGetPointer (245void *Target)246{247void *ObjPtr;248ACPI_SIZE Address;249250251Address = strtoul (Target, NULL, 16);252ObjPtr = ACPI_TO_POINTER (Address);253return (ObjPtr);254}255256257/*******************************************************************************258*259* FUNCTION: AcpiDbDumpParserDescriptor260*261* PARAMETERS: Op - A parser Op descriptor262*263* RETURN: None264*265* DESCRIPTION: Display a formatted parser object266*267******************************************************************************/268269static void270AcpiDbDumpParserDescriptor (271ACPI_PARSE_OBJECT *Op)272{273const ACPI_OPCODE_INFO *Info;274275276Info = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);277278AcpiOsPrintf ("Parser Op Descriptor:\n");279AcpiOsPrintf ("%20.20s : %4.4X\n", "Opcode", Op->Common.AmlOpcode);280281ACPI_DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name",282Info->Name));283284AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Common.Value.Arg);285AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Common.Parent);286AcpiOsPrintf ("%20.20s : %p\n", "NextOp", Op->Common.Next);287}288289290/*******************************************************************************291*292* FUNCTION: AcpiDbDecodeAndDisplayObject293*294* PARAMETERS: Target - String with object to be displayed. Names295* and hex pointers are supported.296* OutputType - Byte, Word, Dword, or Qword (B|W|D|Q)297*298* RETURN: None299*300* DESCRIPTION: Display a formatted ACPI object301*302******************************************************************************/303304void305AcpiDbDecodeAndDisplayObject (306char *Target,307char *OutputType)308{309void *ObjPtr;310ACPI_NAMESPACE_NODE *Node;311ACPI_OPERAND_OBJECT *ObjDesc;312UINT32 Display = DB_BYTE_DISPLAY;313char Buffer[80];314ACPI_BUFFER RetBuf;315ACPI_STATUS Status;316UINT32 Size;317318319if (!Target)320{321return;322}323324/* Decode the output type */325326if (OutputType)327{328AcpiUtStrupr (OutputType);329if (OutputType[0] == 'W')330{331Display = DB_WORD_DISPLAY;332}333else if (OutputType[0] == 'D')334{335Display = DB_DWORD_DISPLAY;336}337else if (OutputType[0] == 'Q')338{339Display = DB_QWORD_DISPLAY;340}341}342343RetBuf.Length = sizeof (Buffer);344RetBuf.Pointer = Buffer;345346/* Differentiate between a number and a name */347348if ((Target[0] >= 0x30) && (Target[0] <= 0x39))349{350ObjPtr = AcpiDbGetPointer (Target);351if (!AcpiOsReadable (ObjPtr, 16))352{353AcpiOsPrintf (354"Address %p is invalid in this address space\n",355ObjPtr);356return;357}358359/* Decode the object type */360361switch (ACPI_GET_DESCRIPTOR_TYPE (ObjPtr))362{363case ACPI_DESC_TYPE_NAMED:364365/* This is a namespace Node */366367if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE)))368{369AcpiOsPrintf (370"Cannot read entire Named object at address %p\n",371ObjPtr);372return;373}374375Node = ObjPtr;376goto DumpNode;377378case ACPI_DESC_TYPE_OPERAND:379380/* This is a ACPI OPERAND OBJECT */381382if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT)))383{384AcpiOsPrintf (385"Cannot read entire ACPI object at address %p\n",386ObjPtr);387return;388}389390AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT),391Display, ACPI_UINT32_MAX);392AcpiExDumpObjectDescriptor (ObjPtr, 1);393break;394395case ACPI_DESC_TYPE_PARSER:396397/* This is a Parser Op object */398399if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT)))400{401AcpiOsPrintf (402"Cannot read entire Parser object at address %p\n",403ObjPtr);404return;405}406407AcpiUtDebugDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT),408Display, ACPI_UINT32_MAX);409AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr);410break;411412default:413414/* Is not a recognizable object */415416AcpiOsPrintf (417"Not a known ACPI internal object, descriptor type %2.2X\n",418ACPI_GET_DESCRIPTOR_TYPE (ObjPtr));419420Size = 16;421if (AcpiOsReadable (ObjPtr, 64))422{423Size = 64;424}425426/* Just dump some memory */427428AcpiUtDebugDumpBuffer (ObjPtr, Size, Display, ACPI_UINT32_MAX);429break;430}431432return;433}434435/* The parameter is a name string that must be resolved to a Named obj */436437Node = AcpiDbLocalNsLookup (Target);438if (!Node)439{440return;441}442443444DumpNode:445/* Now dump the NS node */446447Status = AcpiGetName (Node, ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf);448if (ACPI_FAILURE (Status))449{450AcpiOsPrintf ("Could not convert name to pathname\n");451}452453else454{455AcpiOsPrintf ("Object %p: Namespace Node - Pathname: %s\n",456Node, (char *) RetBuf.Pointer);457}458459if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))460{461AcpiOsPrintf ("Invalid Named object at address %p\n", Node);462return;463}464465AcpiUtDebugDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE),466Display, ACPI_UINT32_MAX);467AcpiExDumpNamespaceNode (Node, 1);468469ObjDesc = AcpiNsGetAttachedObject (Node);470if (ObjDesc)471{472AcpiOsPrintf ("\nAttached Object %p:", ObjDesc);473if (!AcpiOsReadable (ObjDesc, sizeof (ACPI_OPERAND_OBJECT)))474{475AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n",476ObjDesc);477return;478}479480if (ACPI_GET_DESCRIPTOR_TYPE (481((ACPI_NAMESPACE_NODE *) ObjDesc)) == ACPI_DESC_TYPE_NAMED)482{483AcpiOsPrintf (" Namespace Node - ");484Status = AcpiGetName ((ACPI_NAMESPACE_NODE *) ObjDesc,485ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf);486if (ACPI_FAILURE (Status))487{488AcpiOsPrintf ("Could not convert name to pathname\n");489}490else491{492AcpiOsPrintf ("Pathname: %s",493(char *) RetBuf.Pointer);494}495496AcpiOsPrintf ("\n");497AcpiUtDebugDumpBuffer ((void *) ObjDesc,498sizeof (ACPI_NAMESPACE_NODE), Display, ACPI_UINT32_MAX);499}500else501{502AcpiOsPrintf ("\n");503AcpiUtDebugDumpBuffer ((void *) ObjDesc,504sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX);505}506507AcpiExDumpObjectDescriptor (ObjDesc, 1);508}509}510511512/*******************************************************************************513*514* FUNCTION: AcpiDbDisplayMethodInfo515*516* PARAMETERS: StartOp - Root of the control method parse tree517*518* RETURN: None519*520* DESCRIPTION: Display information about the current method521*522******************************************************************************/523524void525AcpiDbDisplayMethodInfo (526ACPI_PARSE_OBJECT *StartOp)527{528ACPI_WALK_STATE *WalkState;529ACPI_OPERAND_OBJECT *ObjDesc;530ACPI_NAMESPACE_NODE *Node;531ACPI_PARSE_OBJECT *RootOp;532ACPI_PARSE_OBJECT *Op;533const ACPI_OPCODE_INFO *OpInfo;534UINT32 NumOps = 0;535UINT32 NumOperands = 0;536UINT32 NumOperators = 0;537UINT32 NumRemainingOps = 0;538UINT32 NumRemainingOperands = 0;539UINT32 NumRemainingOperators = 0;540BOOLEAN CountRemaining = FALSE;541542543WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);544if (!WalkState)545{546AcpiOsPrintf ("There is no method currently executing\n");547return;548}549550ObjDesc = WalkState->MethodDesc;551Node = WalkState->MethodNode;552553AcpiOsPrintf ("Currently executing control method is [%4.4s]\n",554AcpiUtGetNodeName (Node));555AcpiOsPrintf ("%X Arguments, SyncLevel = %X\n",556(UINT32) ObjDesc->Method.ParamCount,557(UINT32) ObjDesc->Method.SyncLevel);558559RootOp = StartOp;560while (RootOp->Common.Parent)561{562RootOp = RootOp->Common.Parent;563}564565Op = RootOp;566567while (Op)568{569if (Op == StartOp)570{571CountRemaining = TRUE;572}573574NumOps++;575if (CountRemaining)576{577NumRemainingOps++;578}579580/* Decode the opcode */581582OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);583switch (OpInfo->Class)584{585case AML_CLASS_ARGUMENT:586587if (CountRemaining)588{589NumRemainingOperands++;590}591592NumOperands++;593break;594595case AML_CLASS_UNKNOWN:596597/* Bad opcode or ASCII character */598599continue;600601default:602603if (CountRemaining)604{605NumRemainingOperators++;606}607608NumOperators++;609break;610}611612Op = AcpiPsGetDepthNext (StartOp, Op);613}614615AcpiOsPrintf (616"Method contains: %X AML Opcodes - %X Operators, %X Operands\n",617NumOps, NumOperators, NumOperands);618619AcpiOsPrintf (620"Remaining to execute: %X AML Opcodes - %X Operators, %X Operands\n",621NumRemainingOps, NumRemainingOperators, NumRemainingOperands);622}623624625/*******************************************************************************626*627* FUNCTION: AcpiDbDisplayLocals628*629* PARAMETERS: None630*631* RETURN: None632*633* DESCRIPTION: Display all locals for the currently running control method634*635******************************************************************************/636637void638AcpiDbDisplayLocals (639void)640{641ACPI_WALK_STATE *WalkState;642643644WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);645if (!WalkState)646{647AcpiOsPrintf ("There is no method currently executing\n");648return;649}650651AcpiDbDecodeLocals (WalkState);652}653654655/*******************************************************************************656*657* FUNCTION: AcpiDbDisplayArguments658*659* PARAMETERS: None660*661* RETURN: None662*663* DESCRIPTION: Display all arguments for the currently running control method664*665******************************************************************************/666667void668AcpiDbDisplayArguments (669void)670{671ACPI_WALK_STATE *WalkState;672673674WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);675if (!WalkState)676{677AcpiOsPrintf ("There is no method currently executing\n");678return;679}680681AcpiDbDecodeArguments (WalkState);682}683684685/*******************************************************************************686*687* FUNCTION: AcpiDbDisplayResults688*689* PARAMETERS: None690*691* RETURN: None692*693* DESCRIPTION: Display current contents of a method result stack694*695******************************************************************************/696697void698AcpiDbDisplayResults (699void)700{701UINT32 i;702ACPI_WALK_STATE *WalkState;703ACPI_OPERAND_OBJECT *ObjDesc;704UINT32 ResultCount = 0;705ACPI_NAMESPACE_NODE *Node;706ACPI_GENERIC_STATE *Frame;707UINT32 Index; /* Index onto current frame */708709710WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);711if (!WalkState)712{713AcpiOsPrintf ("There is no method currently executing\n");714return;715}716717Node = WalkState->MethodNode;718719if (WalkState->Results)720{721ResultCount = WalkState->ResultCount;722}723724AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n",725AcpiUtGetNodeName (Node), ResultCount);726727/* From the top element of result stack */728729Frame = WalkState->Results;730Index = (ResultCount - 1) % ACPI_RESULTS_FRAME_OBJ_NUM;731732for (i = 0; i < ResultCount; i++)733{734ObjDesc = Frame->Results.ObjDesc[Index];735AcpiOsPrintf ("Result%u: ", i);736AcpiDbDisplayInternalObject (ObjDesc, WalkState);737738if (Index == 0)739{740Frame = Frame->Results.Next;741Index = ACPI_RESULTS_FRAME_OBJ_NUM;742}743744Index--;745}746}747748749/*******************************************************************************750*751* FUNCTION: AcpiDbDisplayCallingTree752*753* PARAMETERS: None754*755* RETURN: None756*757* DESCRIPTION: Display current calling tree of nested control methods758*759******************************************************************************/760761void762AcpiDbDisplayCallingTree (763void)764{765ACPI_WALK_STATE *WalkState;766ACPI_NAMESPACE_NODE *Node;767768769WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);770if (!WalkState)771{772AcpiOsPrintf ("There is no method currently executing\n");773return;774}775776AcpiOsPrintf ("Current Control Method Call Tree\n");777778while (WalkState)779{780Node = WalkState->MethodNode;781AcpiOsPrintf (" [%4.4s]\n", AcpiUtGetNodeName (Node));782783WalkState = WalkState->Next;784}785}786787788/*******************************************************************************789*790* FUNCTION: AcpiDbDisplayObjectType791*792* PARAMETERS: ObjectArg - User entered NS node handle793*794* RETURN: None795*796* DESCRIPTION: Display type of an arbitrary NS node797*798******************************************************************************/799800void801AcpiDbDisplayObjectType (802char *ObjectArg)803{804ACPI_SIZE Arg;805ACPI_HANDLE Handle;806ACPI_DEVICE_INFO *Info;807ACPI_STATUS Status;808UINT32 i;809810811Arg = strtoul (ObjectArg, NULL, 16);812Handle = ACPI_TO_POINTER (Arg);813814Status = AcpiGetObjectInfo (Handle, &Info);815if (ACPI_FAILURE (Status))816{817AcpiOsPrintf ("Could not get object info, %s\n",818AcpiFormatException (Status));819return;820}821822AcpiOsPrintf ("ADR: %8.8X%8.8X, Flags: %X\n",823ACPI_FORMAT_UINT64 (Info->Address), Info->Flags);824825AcpiOsPrintf ("S1D-%2.2X S2D-%2.2X S3D-%2.2X S4D-%2.2X\n",826Info->HighestDstates[0], Info->HighestDstates[1],827Info->HighestDstates[2], Info->HighestDstates[3]);828829AcpiOsPrintf ("S0W-%2.2X S1W-%2.2X S2W-%2.2X S3W-%2.2X S4W-%2.2X\n",830Info->LowestDstates[0], Info->LowestDstates[1],831Info->LowestDstates[2], Info->LowestDstates[3],832Info->LowestDstates[4]);833834if (Info->Valid & ACPI_VALID_HID)835{836AcpiOsPrintf ("HID: %s\n", Info->HardwareId.String);837}838839if (Info->Valid & ACPI_VALID_UID)840{841AcpiOsPrintf ("UID: %s\n", Info->UniqueId.String);842}843844if (Info->Valid & ACPI_VALID_CID)845{846for (i = 0; i < Info->CompatibleIdList.Count; i++)847{848AcpiOsPrintf ("CID %u: %s\n", i,849Info->CompatibleIdList.Ids[i].String);850}851}852853ACPI_FREE (Info);854}855856857/*******************************************************************************858*859* FUNCTION: AcpiDbDisplayResultObject860*861* PARAMETERS: ObjDesc - Object to be displayed862* WalkState - Current walk state863*864* RETURN: None865*866* DESCRIPTION: Display the result of an AML opcode867*868* Note: Currently only displays the result object if we are single stepping.869* However, this output may be useful in other contexts and could be enabled870* to do so if needed.871*872******************************************************************************/873874void875AcpiDbDisplayResultObject (876ACPI_OPERAND_OBJECT *ObjDesc,877ACPI_WALK_STATE *WalkState)878{879880#ifndef ACPI_APPLICATION881if (AcpiGbl_DbThreadId != AcpiOsGetThreadId())882{883return;884}885#endif886887/* Only display if single stepping */888889if (!AcpiGbl_CmSingleStep)890{891return;892}893894AcpiOsPrintf ("ResultObj: ");895AcpiDbDisplayInternalObject (ObjDesc, WalkState);896AcpiOsPrintf ("\n");897}898899900/*******************************************************************************901*902* FUNCTION: AcpiDbDisplayArgumentObject903*904* PARAMETERS: ObjDesc - Object to be displayed905* WalkState - Current walk state906*907* RETURN: None908*909* DESCRIPTION: Display the result of an AML opcode910*911******************************************************************************/912913void914AcpiDbDisplayArgumentObject (915ACPI_OPERAND_OBJECT *ObjDesc,916ACPI_WALK_STATE *WalkState)917{918919#ifndef ACPI_APPLICATION920if (AcpiGbl_DbThreadId != AcpiOsGetThreadId())921{922return;923}924#endif925926if (!AcpiGbl_CmSingleStep)927{928return;929}930931AcpiOsPrintf ("ArgObj: ");932AcpiDbDisplayInternalObject (ObjDesc, WalkState);933}934935936#if (!ACPI_REDUCED_HARDWARE)937/*******************************************************************************938*939* FUNCTION: AcpiDbDisplayGpes940*941* PARAMETERS: None942*943* RETURN: None944*945* DESCRIPTION: Display the current GPE structures946*947******************************************************************************/948949void950AcpiDbDisplayGpes (951void)952{953ACPI_GPE_BLOCK_INFO *GpeBlock;954ACPI_GPE_XRUPT_INFO *GpeXruptInfo;955ACPI_GPE_EVENT_INFO *GpeEventInfo;956ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;957char *GpeType;958ACPI_GPE_NOTIFY_INFO *Notify;959UINT32 GpeIndex;960UINT32 Block = 0;961UINT32 i;962UINT32 j;963UINT32 Count;964char Buffer[80];965ACPI_BUFFER RetBuf;966ACPI_STATUS Status;967968969RetBuf.Length = sizeof (Buffer);970RetBuf.Pointer = Buffer;971972Block = 0;973974/* Walk the GPE lists */975976GpeXruptInfo = AcpiGbl_GpeXruptListHead;977while (GpeXruptInfo)978{979GpeBlock = GpeXruptInfo->GpeBlockListHead;980while (GpeBlock)981{982Status = AcpiGetName (GpeBlock->Node,983ACPI_FULL_PATHNAME_NO_TRAILING, &RetBuf);984if (ACPI_FAILURE (Status))985{986AcpiOsPrintf ("Could not convert name to pathname\n");987}988989if (GpeBlock->Node == AcpiGbl_FadtGpeDevice)990{991GpeType = "FADT-defined GPE block";992}993else994{995GpeType = "GPE Block Device";996}997998AcpiOsPrintf (999"\nBlock %u - Info %p DeviceNode %p [%s] - %s\n",1000Block, GpeBlock, GpeBlock->Node, Buffer, GpeType);10011002AcpiOsPrintf (1003" Registers: %u (%u GPEs)\n",1004GpeBlock->RegisterCount, GpeBlock->GpeCount);10051006AcpiOsPrintf (1007" GPE range: 0x%X to 0x%X on interrupt %u\n",1008GpeBlock->BlockBaseNumber,1009GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1),1010GpeXruptInfo->InterruptNumber);10111012AcpiOsPrintf (1013" RegisterInfo: %p Status %8.8X%8.8X Enable %8.8X%8.8X\n",1014GpeBlock->RegisterInfo,1015ACPI_FORMAT_UINT64 (1016GpeBlock->RegisterInfo->StatusAddress.Address),1017ACPI_FORMAT_UINT64 (1018GpeBlock->RegisterInfo->EnableAddress.Address));10191020AcpiOsPrintf (" EventInfo: %p\n", GpeBlock->EventInfo);10211022/* Examine each GPE Register within the block */10231024for (i = 0; i < GpeBlock->RegisterCount; i++)1025{1026GpeRegisterInfo = &GpeBlock->RegisterInfo[i];10271028AcpiOsPrintf (1029" Reg %u: (GPE %.2X-%.2X) "1030"RunEnable %2.2X WakeEnable %2.2X"1031" Status %8.8X%8.8X Enable %8.8X%8.8X\n",1032i, GpeRegisterInfo->BaseGpeNumber,1033GpeRegisterInfo->BaseGpeNumber +1034(ACPI_GPE_REGISTER_WIDTH - 1),1035GpeRegisterInfo->EnableForRun,1036GpeRegisterInfo->EnableForWake,1037ACPI_FORMAT_UINT64 (1038GpeRegisterInfo->StatusAddress.Address),1039ACPI_FORMAT_UINT64 (1040GpeRegisterInfo->EnableAddress.Address));10411042/* Now look at the individual GPEs in this byte register */10431044for (j = 0; j < ACPI_GPE_REGISTER_WIDTH; j++)1045{1046GpeIndex = (i * ACPI_GPE_REGISTER_WIDTH) + j;1047GpeEventInfo = &GpeBlock->EventInfo[GpeIndex];10481049if (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags) ==1050ACPI_GPE_DISPATCH_NONE)1051{1052/* This GPE is not used (no method or handler), ignore it */10531054continue;1055}10561057AcpiOsPrintf (1058" GPE %.2X: %p RunRefs %2.2X Flags %2.2X (",1059GpeBlock->BlockBaseNumber + GpeIndex, GpeEventInfo,1060GpeEventInfo->RuntimeCount, GpeEventInfo->Flags);10611062/* Decode the flags byte */10631064if (GpeEventInfo->Flags & ACPI_GPE_LEVEL_TRIGGERED)1065{1066AcpiOsPrintf ("Level, ");1067}1068else1069{1070AcpiOsPrintf ("Edge, ");1071}10721073if (GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE)1074{1075AcpiOsPrintf ("CanWake, ");1076}1077else1078{1079AcpiOsPrintf ("RunOnly, ");1080}10811082switch (ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags))1083{1084case ACPI_GPE_DISPATCH_NONE:10851086AcpiOsPrintf ("NotUsed");1087break;10881089case ACPI_GPE_DISPATCH_METHOD:10901091AcpiOsPrintf ("Method");1092break;10931094case ACPI_GPE_DISPATCH_HANDLER:10951096AcpiOsPrintf ("Handler");1097break;10981099case ACPI_GPE_DISPATCH_NOTIFY:11001101Count = 0;1102Notify = GpeEventInfo->Dispatch.NotifyList;1103while (Notify)1104{1105Count++;1106Notify = Notify->Next;1107}11081109AcpiOsPrintf ("Implicit Notify on %u devices",1110Count);1111break;11121113case ACPI_GPE_DISPATCH_RAW_HANDLER:11141115AcpiOsPrintf ("RawHandler");1116break;11171118default:11191120AcpiOsPrintf ("UNKNOWN: %X",1121ACPI_GPE_DISPATCH_TYPE (GpeEventInfo->Flags));1122break;1123}11241125AcpiOsPrintf (")\n");1126}1127}11281129Block++;1130GpeBlock = GpeBlock->Next;1131}11321133GpeXruptInfo = GpeXruptInfo->Next;1134}1135}1136#endif /* !ACPI_REDUCED_HARDWARE */113711381139/*******************************************************************************1140*1141* FUNCTION: AcpiDbDisplayHandlers1142*1143* PARAMETERS: None1144*1145* RETURN: None1146*1147* DESCRIPTION: Display the currently installed global handlers1148*1149******************************************************************************/11501151void1152AcpiDbDisplayHandlers (1153void)1154{1155ACPI_OPERAND_OBJECT *ObjDesc;1156ACPI_OPERAND_OBJECT *HandlerObj;1157ACPI_ADR_SPACE_TYPE SpaceId;1158UINT32 i;115911601161/* Operation region handlers */11621163AcpiOsPrintf ("\nOperation Region Handlers at the namespace root:\n");11641165ObjDesc = AcpiNsGetAttachedObject (AcpiGbl_RootNode);1166if (ObjDesc)1167{1168for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_SpaceIdList); i++)1169{1170SpaceId = AcpiGbl_SpaceIdList[i];11711172AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,1173AcpiUtGetRegionName ((UINT8) SpaceId), SpaceId);11741175HandlerObj = AcpiEvFindRegionHandler (1176SpaceId, ObjDesc->CommonNotify.Handler);1177if (HandlerObj)1178{1179AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,1180(HandlerObj->AddressSpace.HandlerFlags &1181ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ?1182"Default" : "User",1183HandlerObj->AddressSpace.Handler);11841185goto FoundHandler;1186}11871188/* There is no handler for this SpaceId */11891190AcpiOsPrintf ("None\n");11911192FoundHandler:;1193}11941195/* Find all handlers for user-defined SpaceIDs */11961197HandlerObj = ObjDesc->CommonNotify.Handler;1198while (HandlerObj)1199{1200if (HandlerObj->AddressSpace.SpaceId >= ACPI_USER_REGION_BEGIN)1201{1202AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,1203"User-defined ID", HandlerObj->AddressSpace.SpaceId);1204AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING,1205(HandlerObj->AddressSpace.HandlerFlags &1206ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ?1207"Default" : "User",1208HandlerObj->AddressSpace.Handler);1209}12101211HandlerObj = HandlerObj->AddressSpace.Next;1212}1213}12141215#if (!ACPI_REDUCED_HARDWARE)12161217/* Fixed event handlers */12181219AcpiOsPrintf ("\nFixed Event Handlers:\n");12201221for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)1222{1223AcpiOsPrintf (ACPI_PREDEFINED_PREFIX, AcpiUtGetEventName (i), i);1224if (AcpiGbl_FixedEventHandlers[i].Handler)1225{1226AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",1227AcpiGbl_FixedEventHandlers[i].Handler);1228}1229else1230{1231AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");1232}1233}12341235#endif /* !ACPI_REDUCED_HARDWARE */12361237/* Miscellaneous global handlers */12381239AcpiOsPrintf ("\nMiscellaneous Global Handlers:\n");12401241for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiGbl_HandlerList); i++)1242{1243AcpiOsPrintf (ACPI_HANDLER_NAME_STRING,1244AcpiGbl_HandlerList[i].Name);12451246if (AcpiGbl_HandlerList[i].Handler)1247{1248AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING, "User",1249AcpiGbl_HandlerList[i].Handler);1250}1251else1252{1253AcpiOsPrintf (ACPI_HANDLER_NOT_PRESENT_STRING, "None");1254}1255}125612571258/* Other handlers that are installed throughout the namespace */12591260AcpiOsPrintf ("\nOperation Region Handlers for specific devices:\n");12611262(void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,1263ACPI_UINT32_MAX, AcpiDbDisplayNonRootHandlers,1264NULL, NULL, NULL);1265}126612671268/*******************************************************************************1269*1270* FUNCTION: AcpiDbDisplayNonRootHandlers1271*1272* PARAMETERS: ACPI_WALK_CALLBACK1273*1274* RETURN: Status1275*1276* DESCRIPTION: Display information about all handlers installed for a1277* device object.1278*1279******************************************************************************/12801281static ACPI_STATUS1282AcpiDbDisplayNonRootHandlers (1283ACPI_HANDLE ObjHandle,1284UINT32 NestingLevel,1285void *Context,1286void **ReturnValue)1287{1288ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);1289ACPI_OPERAND_OBJECT *ObjDesc;1290ACPI_OPERAND_OBJECT *HandlerObj;1291char *Pathname;129212931294ObjDesc = AcpiNsGetAttachedObject (Node);1295if (!ObjDesc)1296{1297return (AE_OK);1298}12991300Pathname = AcpiNsGetNormalizedPathname (Node, TRUE);1301if (!Pathname)1302{1303return (AE_OK);1304}13051306/* Display all handlers associated with this device */13071308HandlerObj = ObjDesc->CommonNotify.Handler;1309while (HandlerObj)1310{1311AcpiOsPrintf (ACPI_PREDEFINED_PREFIX,1312AcpiUtGetRegionName ((UINT8) HandlerObj->AddressSpace.SpaceId),1313HandlerObj->AddressSpace.SpaceId);13141315AcpiOsPrintf (ACPI_HANDLER_PRESENT_STRING2,1316(HandlerObj->AddressSpace.HandlerFlags &1317ACPI_ADDR_HANDLER_DEFAULT_INSTALLED) ? "Default" : "User",1318HandlerObj->AddressSpace.Handler);13191320AcpiOsPrintf (" Device Name: %s (%p)\n", Pathname, Node);13211322HandlerObj = HandlerObj->AddressSpace.Next;1323}13241325ACPI_FREE (Pathname);1326return (AE_OK);1327}132813291330