dbcmds.c revision 117521
167754Smsmith/******************************************************************************* 267754Smsmith * 367754Smsmith * Module Name: dbcmds - debug commands and output routines 4117521Snjl * $Revision: 105 $ 567754Smsmith * 667754Smsmith ******************************************************************************/ 767754Smsmith 867754Smsmith/****************************************************************************** 967754Smsmith * 1067754Smsmith * 1. Copyright Notice 1167754Smsmith * 12114237Snjl * Some or all of this work - Copyright (c) 1999 - 2003, 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 11867754Smsmith#include "acpi.h" 11967754Smsmith#include "acdispat.h" 12067754Smsmith#include "amlcode.h" 12167754Smsmith#include "acnamesp.h" 12267754Smsmith#include "acevents.h" 12367754Smsmith#include "acdebug.h" 12477424Smsmith#include "acresrc.h" 125100966Siwasaki#include "acdisasm.h" 12667754Smsmith 127102550Siwasaki#ifdef ACPI_DEBUGGER 12867754Smsmith 129102550Siwasaki#define _COMPONENT ACPI_CA_DEBUGGER 13091116Smsmith ACPI_MODULE_NAME ("dbcmds") 13167754Smsmith 13267754Smsmith 13367754Smsmith/* 13467754Smsmith * Arguments for the Objects command 13567754Smsmith * These object types map directly to the ACPI_TYPES 13667754Smsmith */ 13767754Smsmith 13899679Siwasakistatic ARGUMENT_INFO AcpiDbObjectTypes [] = 13967754Smsmith{ 14067754Smsmith {"ANY"}, 14167754Smsmith {"NUMBERS"}, 14267754Smsmith {"STRINGS"}, 14367754Smsmith {"BUFFERS"}, 14467754Smsmith {"PACKAGES"}, 14567754Smsmith {"FIELDS"}, 14667754Smsmith {"DEVICES"}, 14767754Smsmith {"EVENTS"}, 14867754Smsmith {"METHODS"}, 14967754Smsmith {"MUTEXES"}, 15067754Smsmith {"REGIONS"}, 15167754Smsmith {"POWERRESOURCES"}, 15267754Smsmith {"PROCESSORS"}, 15367754Smsmith {"THERMALZONES"}, 15467754Smsmith {"BUFFERFIELDS"}, 15567754Smsmith {"DDBHANDLES"}, 15667754Smsmith {NULL} /* Must be null terminated */ 15767754Smsmith}; 15867754Smsmith 15967754Smsmith 16067754Smsmith/******************************************************************************* 16167754Smsmith * 16267754Smsmith * FUNCTION: AcpiDbWalkForReferences 16367754Smsmith * 16467754Smsmith * PARAMETERS: Callback from WalkNamespace 16567754Smsmith * 16667754Smsmith * RETURN: Status 16767754Smsmith * 16867754Smsmith * DESCRIPTION: Check if this namespace object refers to the target object 16967754Smsmith * that is passed in as the context value. 17067754Smsmith * 17191116Smsmith * Note: Currently doesn't check subobjects within the Node's object 17291116Smsmith * 17367754Smsmith ******************************************************************************/ 17467754Smsmith 17567754SmsmithACPI_STATUS 17667754SmsmithAcpiDbWalkForReferences ( 17767754Smsmith ACPI_HANDLE ObjHandle, 17867754Smsmith UINT32 NestingLevel, 17967754Smsmith void *Context, 18067754Smsmith void **ReturnValue) 18167754Smsmith{ 18267754Smsmith ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context; 18367754Smsmith ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 18467754Smsmith 18567754Smsmith 18667754Smsmith /* Check for match against the namespace node itself */ 18767754Smsmith 18867754Smsmith if (Node == (void *) ObjDesc) 18967754Smsmith { 19099679Siwasaki AcpiOsPrintf ("Object is a Node [%4.4s]\n", Node->Name.Ascii); 19167754Smsmith } 19267754Smsmith 19367754Smsmith /* Check for match against the object attached to the node */ 19467754Smsmith 19587031Smsmith if (AcpiNsGetAttachedObject (Node) == ObjDesc) 19667754Smsmith { 19799679Siwasaki AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", Node, Node->Name.Ascii); 19867754Smsmith } 19967754Smsmith 20067754Smsmith return (AE_OK); 20167754Smsmith} 20267754Smsmith 20367754Smsmith 20467754Smsmith/******************************************************************************* 20567754Smsmith * 20667754Smsmith * FUNCTION: AcpiDbFindReferences 20767754Smsmith * 20867754Smsmith * PARAMETERS: ObjectArg - String with hex value of the object 20967754Smsmith * 21067754Smsmith * RETURN: None 21167754Smsmith * 21267754Smsmith * DESCRIPTION: Search namespace for all references to the input object 21367754Smsmith * 21467754Smsmith ******************************************************************************/ 21567754Smsmith 21667754Smsmithvoid 21767754SmsmithAcpiDbFindReferences ( 218114237Snjl char *ObjectArg) 21967754Smsmith{ 22067754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 22167754Smsmith 22267754Smsmith 22367754Smsmith /* Convert string to object pointer */ 22467754Smsmith 22591116Smsmith ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16)); 22667754Smsmith 22767754Smsmith /* Search all nodes in namespace */ 22867754Smsmith 22999679Siwasaki (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 23067754Smsmith AcpiDbWalkForReferences, (void *) ObjDesc, NULL); 23167754Smsmith} 23267754Smsmith 23367754Smsmith 23467754Smsmith/******************************************************************************* 23567754Smsmith * 23677424Smsmith * FUNCTION: AcpiDbDisplayLocks 23777424Smsmith * 23877424Smsmith * PARAMETERS: None 23977424Smsmith * 24077424Smsmith * RETURN: None 24177424Smsmith * 24277424Smsmith * DESCRIPTION: Display information about internal mutexes. 24377424Smsmith * 24477424Smsmith ******************************************************************************/ 24577424Smsmith 24677424Smsmithvoid 24777424SmsmithAcpiDbDisplayLocks (void) 24877424Smsmith{ 24977424Smsmith UINT32 i; 25077424Smsmith 25177424Smsmith 252117521Snjl for (i = 0; i < MAX_MUTEX; i++) 25377424Smsmith { 25477424Smsmith AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i), 255117521Snjl AcpiGbl_MutexInfo[i].OwnerId == ACPI_MUTEX_NOT_ACQUIRED 25677424Smsmith ? "Locked" : "Unlocked"); 25777424Smsmith } 25877424Smsmith} 25977424Smsmith 26077424Smsmith 26177424Smsmith/******************************************************************************* 26277424Smsmith * 26367754Smsmith * FUNCTION: AcpiDbDisplayTableInfo 26467754Smsmith * 26567754Smsmith * PARAMETERS: TableArg - String with name of table to be displayed 26667754Smsmith * 26767754Smsmith * RETURN: None 26867754Smsmith * 26967754Smsmith * DESCRIPTION: Display information about loaded tables. Current 27067754Smsmith * implementation displays all loaded tables. 27167754Smsmith * 27267754Smsmith ******************************************************************************/ 27367754Smsmith 27467754Smsmithvoid 27567754SmsmithAcpiDbDisplayTableInfo ( 276114237Snjl char *TableArg) 27767754Smsmith{ 27867754Smsmith UINT32 i; 279117521Snjl ACPI_TABLE_DESC *TableDesc; 28067754Smsmith 28167754Smsmith 282117521Snjl for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) 28367754Smsmith { 284117521Snjl TableDesc = AcpiGbl_TableLists[i].Next; 285117521Snjl while (TableDesc) 28667754Smsmith { 287117521Snjl AcpiOsPrintf ( "%s at %p length %.5X", 288117521Snjl AcpiGbl_TableData[i].Name, TableDesc->Pointer, 289117521Snjl (UINT32) TableDesc->Length); 290117521Snjl 291117521Snjl if (i != ACPI_TABLE_FACS) 292117521Snjl { 293117521Snjl AcpiOsPrintf (" OemID=%6s TableId=%8s OemRevision=%8.8X", 294117521Snjl TableDesc->Pointer->OemId, 295117521Snjl TableDesc->Pointer->OemTableId, 296117521Snjl TableDesc->Pointer->OemRevision); 297117521Snjl } 298117521Snjl AcpiOsPrintf ("\n"); 299117521Snjl 300117521Snjl TableDesc = TableDesc->Next; 30167754Smsmith } 30267754Smsmith } 30367754Smsmith} 30467754Smsmith 30567754Smsmith 30667754Smsmith/******************************************************************************* 30767754Smsmith * 30867754Smsmith * FUNCTION: AcpiDbUnloadAcpiTable 30967754Smsmith * 31067754Smsmith * PARAMETERS: TableArg - Name of the table to be unloaded 31167754Smsmith * InstanceArg - Which instance of the table to unload (if 31267754Smsmith * there are multiple tables of the same type) 31367754Smsmith * 31467754Smsmith * RETURN: Nonde 31567754Smsmith * 31667754Smsmith * DESCRIPTION: Unload an ACPI table. 31767754Smsmith * Instance is not implemented 31867754Smsmith * 31967754Smsmith ******************************************************************************/ 32067754Smsmith 32167754Smsmithvoid 32267754SmsmithAcpiDbUnloadAcpiTable ( 323114237Snjl char *TableArg, 324114237Snjl char *InstanceArg) 32567754Smsmith{ 32667754Smsmith UINT32 i; 32767754Smsmith ACPI_STATUS Status; 32867754Smsmith 32967754Smsmith 33067754Smsmith /* Search all tables for the target type */ 33167754Smsmith 332117521Snjl for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++) 33367754Smsmith { 334117521Snjl if (!ACPI_STRNCMP (TableArg, AcpiGbl_TableData[i].Signature, 335117521Snjl AcpiGbl_TableData[i].SigLength)) 33667754Smsmith { 33767754Smsmith /* Found the table, unload it */ 33867754Smsmith 33967754Smsmith Status = AcpiUnloadTable (i); 34067754Smsmith if (ACPI_SUCCESS (Status)) 34167754Smsmith { 34267754Smsmith AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg); 34367754Smsmith } 34467754Smsmith else 34567754Smsmith { 34683174Smsmith AcpiOsPrintf ("%s, while unloading [%s]\n", 34780062Smsmith AcpiFormatException (Status), TableArg); 34867754Smsmith } 34967754Smsmith 35067754Smsmith return; 35167754Smsmith } 35267754Smsmith } 35367754Smsmith 35467754Smsmith AcpiOsPrintf ("Unknown table type [%s]\n", TableArg); 35567754Smsmith} 35667754Smsmith 35767754Smsmith 35867754Smsmith/******************************************************************************* 35967754Smsmith * 36067754Smsmith * FUNCTION: AcpiDbSetMethodBreakpoint 36167754Smsmith * 36267754Smsmith * PARAMETERS: Location - AML offset of breakpoint 36367754Smsmith * WalkState - Current walk info 36467754Smsmith * Op - Current Op (from parse walk) 36567754Smsmith * 36667754Smsmith * RETURN: None 36767754Smsmith * 36867754Smsmith * DESCRIPTION: Set a breakpoint in a control method at the specified 36967754Smsmith * AML offset 37067754Smsmith * 37167754Smsmith ******************************************************************************/ 37267754Smsmith 37367754Smsmithvoid 37467754SmsmithAcpiDbSetMethodBreakpoint ( 375114237Snjl char *Location, 37667754Smsmith ACPI_WALK_STATE *WalkState, 37767754Smsmith ACPI_PARSE_OBJECT *Op) 37867754Smsmith{ 37967754Smsmith UINT32 Address; 38067754Smsmith 38167754Smsmith 38267754Smsmith if (!Op) 38367754Smsmith { 38467754Smsmith AcpiOsPrintf ("There is no method currently executing\n"); 38567754Smsmith return; 38667754Smsmith } 38767754Smsmith 38867754Smsmith /* Get and verify the breakpoint address */ 38967754Smsmith 39091116Smsmith Address = ACPI_STRTOUL (Location, NULL, 16); 39199679Siwasaki if (Address <= Op->Common.AmlOffset) 39267754Smsmith { 39399679Siwasaki AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", Address, Op->Common.AmlOffset); 39467754Smsmith } 39567754Smsmith 39667754Smsmith /* Save breakpoint in current walk */ 39767754Smsmith 39891116Smsmith WalkState->UserBreakpoint = Address; 39969746Smsmith AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address); 40067754Smsmith} 40167754Smsmith 40267754Smsmith 40367754Smsmith/******************************************************************************* 40467754Smsmith * 40567754Smsmith * FUNCTION: AcpiDbSetMethodCallBreakpoint 40667754Smsmith * 40767754Smsmith * PARAMETERS: Op - Current Op (from parse walk) 40867754Smsmith * 40967754Smsmith * RETURN: None 41067754Smsmith * 41167754Smsmith * DESCRIPTION: Set a breakpoint in a control method at the specified 41267754Smsmith * AML offset 41367754Smsmith * 41467754Smsmith ******************************************************************************/ 41567754Smsmith 41667754Smsmithvoid 41767754SmsmithAcpiDbSetMethodCallBreakpoint ( 41867754Smsmith ACPI_PARSE_OBJECT *Op) 41967754Smsmith{ 42067754Smsmith 42167754Smsmith 42267754Smsmith if (!Op) 42367754Smsmith { 42467754Smsmith AcpiOsPrintf ("There is no method currently executing\n"); 42567754Smsmith return; 42667754Smsmith } 42767754Smsmith 42867754Smsmith AcpiGbl_StepToNextCall = TRUE; 42967754Smsmith} 43067754Smsmith 43167754Smsmith 43267754Smsmith/******************************************************************************* 43367754Smsmith * 43467754Smsmith * FUNCTION: AcpiDbDisassembleAml 43567754Smsmith * 43667754Smsmith * PARAMETERS: Statements - Number of statements to disassemble 43767754Smsmith * Op - Current Op (from parse walk) 43867754Smsmith * 43967754Smsmith * RETURN: None 44067754Smsmith * 44167754Smsmith * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number 44267754Smsmith * of statements specified. 44367754Smsmith * 44467754Smsmith ******************************************************************************/ 44567754Smsmith 44667754Smsmithvoid 44767754SmsmithAcpiDbDisassembleAml ( 448114237Snjl char *Statements, 44967754Smsmith ACPI_PARSE_OBJECT *Op) 45067754Smsmith{ 45167754Smsmith UINT32 NumStatements = 8; 45267754Smsmith 45367754Smsmith 45467754Smsmith if (!Op) 45567754Smsmith { 45667754Smsmith AcpiOsPrintf ("There is no method currently executing\n"); 45767754Smsmith return; 45867754Smsmith } 45967754Smsmith 46067754Smsmith if (Statements) 46167754Smsmith { 46291116Smsmith NumStatements = ACPI_STRTOUL (Statements, NULL, 0); 46367754Smsmith } 46467754Smsmith 465100966Siwasaki AcpiDmDisassemble (NULL, Op, NumStatements); 46667754Smsmith} 46767754Smsmith 46867754Smsmith 46967754Smsmith/******************************************************************************* 47067754Smsmith * 47167754Smsmith * FUNCTION: AcpiDbDumpNamespace 47267754Smsmith * 47367754Smsmith * PARAMETERS: StartArg - Node to begin namespace dump 47467754Smsmith * DepthArg - Maximum tree depth to be dumped 47567754Smsmith * 47667754Smsmith * RETURN: None 47767754Smsmith * 47867754Smsmith * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed 47967754Smsmith * with type and other information. 48067754Smsmith * 48167754Smsmith ******************************************************************************/ 48267754Smsmith 48367754Smsmithvoid 48467754SmsmithAcpiDbDumpNamespace ( 485114237Snjl char *StartArg, 486114237Snjl char *DepthArg) 48767754Smsmith{ 48867754Smsmith ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; 48967754Smsmith UINT32 MaxDepth = ACPI_UINT32_MAX; 49067754Smsmith 49167754Smsmith 49267754Smsmith /* No argument given, just start at the root and dump entire namespace */ 49367754Smsmith 49467754Smsmith if (StartArg) 49567754Smsmith { 49667754Smsmith /* Check if numeric argument, must be a Node */ 49767754Smsmith 49867754Smsmith if ((StartArg[0] >= 0x30) && (StartArg[0] <= 0x39)) 49967754Smsmith { 50091116Smsmith SubtreeEntry = ACPI_TO_POINTER (ACPI_STRTOUL (StartArg, NULL, 16)); 50167754Smsmith if (!AcpiOsReadable (SubtreeEntry, sizeof (ACPI_NAMESPACE_NODE))) 50267754Smsmith { 50367754Smsmith AcpiOsPrintf ("Address %p is invalid in this address space\n", SubtreeEntry); 50467754Smsmith return; 50567754Smsmith } 50667754Smsmith 50791116Smsmith if (ACPI_GET_DESCRIPTOR_TYPE (SubtreeEntry) != ACPI_DESC_TYPE_NAMED) 50867754Smsmith { 50967754Smsmith AcpiOsPrintf ("Address %p is not a valid Named object\n", SubtreeEntry); 51067754Smsmith return; 51167754Smsmith } 51267754Smsmith } 51367754Smsmith else 51467754Smsmith { 515117521Snjl /* Alpha argument */ 51667754Smsmith /* The parameter is a name string that must be resolved to a Named obj*/ 51767754Smsmith 51867754Smsmith SubtreeEntry = AcpiDbLocalNsLookup (StartArg); 51967754Smsmith if (!SubtreeEntry) 52067754Smsmith { 52167754Smsmith SubtreeEntry = AcpiGbl_RootNode; 52267754Smsmith } 52367754Smsmith } 52467754Smsmith 52567754Smsmith /* Now we can check for the depth argument */ 52667754Smsmith 52767754Smsmith if (DepthArg) 52867754Smsmith { 52991116Smsmith MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0); 53067754Smsmith } 53167754Smsmith } 53267754Smsmith 53391116Smsmith AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); 53467754Smsmith AcpiOsPrintf ("ACPI Namespace (from %p subtree):\n", SubtreeEntry); 53567754Smsmith 53667754Smsmith /* Display the subtree */ 53767754Smsmith 53891116Smsmith AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 53985756Smsmith AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, ACPI_UINT32_MAX, SubtreeEntry); 54091116Smsmith AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 54167754Smsmith} 54267754Smsmith 54367754Smsmith 54467754Smsmith/******************************************************************************* 54567754Smsmith * 54667754Smsmith * FUNCTION: AcpiDbDumpNamespaceByOwner 54767754Smsmith * 54867754Smsmith * PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed 54967754Smsmith * DepthArg - Maximum tree depth to be dumped 55067754Smsmith * 55167754Smsmith * RETURN: None 55267754Smsmith * 55367754Smsmith * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId. 55467754Smsmith * 55567754Smsmith ******************************************************************************/ 55667754Smsmith 55767754Smsmithvoid 55867754SmsmithAcpiDbDumpNamespaceByOwner ( 559114237Snjl char *OwnerArg, 560114237Snjl char *DepthArg) 56167754Smsmith{ 56267754Smsmith ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; 56367754Smsmith UINT32 MaxDepth = ACPI_UINT32_MAX; 56467754Smsmith UINT16 OwnerId; 56567754Smsmith 56667754Smsmith 56791116Smsmith OwnerId = (UINT16) ACPI_STRTOUL (OwnerArg, NULL, 0); 56867754Smsmith 56967754Smsmith /* Now we can check for the depth argument */ 57067754Smsmith 57167754Smsmith if (DepthArg) 57267754Smsmith { 57391116Smsmith MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0); 57467754Smsmith } 57567754Smsmith 57691116Smsmith AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); 57769746Smsmith AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId); 57867754Smsmith 57967754Smsmith /* Display the subtree */ 58067754Smsmith 58191116Smsmith AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 58285756Smsmith AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId, SubtreeEntry); 58391116Smsmith AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 58467754Smsmith} 58567754Smsmith 58667754Smsmith 58767754Smsmith/******************************************************************************* 58867754Smsmith * 58967754Smsmith * FUNCTION: AcpiDbSendNotify 59067754Smsmith * 59167754Smsmith * PARAMETERS: Name - Name of ACPI object to send the notify to 59267754Smsmith * Value - Value of the notify to send. 59367754Smsmith * 59467754Smsmith * RETURN: None 59567754Smsmith * 59667754Smsmith * DESCRIPTION: Send an ACPI notification. The value specified is sent to the 59767754Smsmith * named object as an ACPI notify. 59867754Smsmith * 59967754Smsmith ******************************************************************************/ 60067754Smsmith 60167754Smsmithvoid 60267754SmsmithAcpiDbSendNotify ( 603114237Snjl char *Name, 60467754Smsmith UINT32 Value) 60567754Smsmith{ 60667754Smsmith ACPI_NAMESPACE_NODE *Node; 60799679Siwasaki ACPI_STATUS Status; 60867754Smsmith 60967754Smsmith 61067754Smsmith /* Translate name to an Named object */ 61167754Smsmith 61267754Smsmith Node = AcpiDbLocalNsLookup (Name); 61367754Smsmith if (!Node) 61467754Smsmith { 61567754Smsmith return; 61667754Smsmith } 61767754Smsmith 61867754Smsmith /* Decode Named object type */ 61967754Smsmith 62067754Smsmith switch (Node->Type) 62167754Smsmith { 62267754Smsmith case ACPI_TYPE_DEVICE: 62367754Smsmith case ACPI_TYPE_THERMAL: 62467754Smsmith 62567754Smsmith /* Send the notify */ 62667754Smsmith 62799679Siwasaki Status = AcpiEvQueueNotifyRequest (Node, Value); 62899679Siwasaki if (ACPI_FAILURE (Status)) 62999679Siwasaki { 63099679Siwasaki AcpiOsPrintf ("Could not queue notify\n"); 63199679Siwasaki } 63267754Smsmith break; 63367754Smsmith 63467754Smsmith default: 63567754Smsmith AcpiOsPrintf ("Named object is not a device or a thermal object\n"); 63667754Smsmith break; 63767754Smsmith } 63867754Smsmith} 63967754Smsmith 64067754Smsmith 64167754Smsmith/******************************************************************************* 64267754Smsmith * 64367754Smsmith * FUNCTION: AcpiDbSetMethodData 64467754Smsmith * 64567754Smsmith * PARAMETERS: TypeArg - L for local, A for argument 64667754Smsmith * IndexArg - which one 64767754Smsmith * ValueArg - Value to set. 64867754Smsmith * 64967754Smsmith * RETURN: None 65067754Smsmith * 65167754Smsmith * DESCRIPTION: Set a local or argument for the running control method. 65267754Smsmith * NOTE: only object supported is Number. 65367754Smsmith * 65467754Smsmith ******************************************************************************/ 65567754Smsmith 65667754Smsmithvoid 65767754SmsmithAcpiDbSetMethodData ( 658114237Snjl char *TypeArg, 659114237Snjl char *IndexArg, 660114237Snjl char *ValueArg) 66167754Smsmith{ 662114237Snjl char Type; 66367754Smsmith UINT32 Index; 66467754Smsmith UINT32 Value; 66567754Smsmith ACPI_WALK_STATE *WalkState; 66667754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 66799679Siwasaki ACPI_STATUS Status; 66867754Smsmith 66967754Smsmith 67067754Smsmith /* Validate TypeArg */ 67167754Smsmith 67291116Smsmith ACPI_STRUPR (TypeArg); 67367754Smsmith Type = TypeArg[0]; 67467754Smsmith if ((Type != 'L') && 67567754Smsmith (Type != 'A')) 67667754Smsmith { 67767754Smsmith AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg); 67867754Smsmith return; 67967754Smsmith } 68067754Smsmith 68167754Smsmith /* Get the index and value */ 68267754Smsmith 68391116Smsmith Index = ACPI_STRTOUL (IndexArg, NULL, 16); 68491116Smsmith Value = ACPI_STRTOUL (ValueArg, NULL, 16); 68567754Smsmith 68667754Smsmith WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 68767754Smsmith if (!WalkState) 68867754Smsmith { 68967754Smsmith AcpiOsPrintf ("There is no method currently executing\n"); 69067754Smsmith return; 69167754Smsmith } 69267754Smsmith 69367754Smsmith /* Create and initialize the new object */ 69467754Smsmith 69577424Smsmith ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); 69667754Smsmith if (!ObjDesc) 69767754Smsmith { 69867754Smsmith AcpiOsPrintf ("Could not create an internal object\n"); 69967754Smsmith return; 70067754Smsmith } 70167754Smsmith 70271867Smsmith ObjDesc->Integer.Value = Value; 70367754Smsmith 70467754Smsmith /* Store the new object into the target */ 70567754Smsmith 70667754Smsmith switch (Type) 70767754Smsmith { 70867754Smsmith case 'A': 70967754Smsmith 71067754Smsmith /* Set a method argument */ 71167754Smsmith 712114237Snjl if (Index > ACPI_METHOD_MAX_ARG) 71367754Smsmith { 71467754Smsmith AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index); 71567754Smsmith return; 71667754Smsmith } 71767754Smsmith 71899679Siwasaki Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, ObjDesc, WalkState); 71999679Siwasaki if (ACPI_FAILURE (Status)) 72099679Siwasaki { 72199679Siwasaki return; 72299679Siwasaki } 72399679Siwasaki 72467754Smsmith ObjDesc = WalkState->Arguments[Index].Object; 72567754Smsmith 72667754Smsmith AcpiOsPrintf ("Arg%d: ", Index); 727117521Snjl AcpiDmDisplayInternalObject (ObjDesc, WalkState); 72867754Smsmith break; 72967754Smsmith 73067754Smsmith case 'L': 73167754Smsmith 73267754Smsmith /* Set a method local */ 73367754Smsmith 734114237Snjl if (Index > ACPI_METHOD_MAX_LOCAL) 73567754Smsmith { 73667754Smsmith AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index); 73767754Smsmith return; 73867754Smsmith } 73967754Smsmith 74099679Siwasaki Status = AcpiDsStoreObjectToLocal (AML_LOCAL_OP, Index, ObjDesc, WalkState); 74199679Siwasaki if (ACPI_FAILURE (Status)) 74299679Siwasaki { 74399679Siwasaki return; 74499679Siwasaki } 74599679Siwasaki 74667754Smsmith ObjDesc = WalkState->LocalVariables[Index].Object; 74767754Smsmith 74867754Smsmith AcpiOsPrintf ("Local%d: ", Index); 749117521Snjl AcpiDmDisplayInternalObject (ObjDesc, WalkState); 75067754Smsmith break; 75167754Smsmith 75267754Smsmith default: 75367754Smsmith break; 75467754Smsmith } 75567754Smsmith} 75667754Smsmith 75767754Smsmith 75867754Smsmith/******************************************************************************* 75967754Smsmith * 76067754Smsmith * FUNCTION: AcpiDbWalkForSpecificObjects 76167754Smsmith * 76267754Smsmith * PARAMETERS: Callback from WalkNamespace 76367754Smsmith * 76467754Smsmith * RETURN: Status 76567754Smsmith * 76667754Smsmith * DESCRIPTION: Display short info about objects in the namespace 76767754Smsmith * 76867754Smsmith ******************************************************************************/ 76967754Smsmith 77067754SmsmithACPI_STATUS 77167754SmsmithAcpiDbWalkForSpecificObjects ( 77267754Smsmith ACPI_HANDLE ObjHandle, 77367754Smsmith UINT32 NestingLevel, 77467754Smsmith void *Context, 77567754Smsmith void **ReturnValue) 77667754Smsmith{ 77767754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 77867754Smsmith ACPI_STATUS Status; 77991116Smsmith ACPI_BUFFER Buffer; 78067754Smsmith 78167754Smsmith 78287031Smsmith ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjHandle); 78367754Smsmith 78467754Smsmith /* Get and display the full pathname to this object */ 78567754Smsmith 78691116Smsmith Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 78791116Smsmith Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); 78867754Smsmith if (ACPI_FAILURE (Status)) 78967754Smsmith { 79067754Smsmith AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); 79167754Smsmith return (AE_OK); 79267754Smsmith } 79367754Smsmith 794104470Siwasaki AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); 79591116Smsmith ACPI_MEM_FREE (Buffer.Pointer); 79667754Smsmith 79767754Smsmith /* Display short information about the object */ 79867754Smsmith 79967754Smsmith if (ObjDesc) 80067754Smsmith { 80199679Siwasaki switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) 80267754Smsmith { 80367754Smsmith case ACPI_TYPE_METHOD: 804114237Snjl AcpiOsPrintf (" #Args %d Concurrency %X", 805104470Siwasaki ObjDesc->Method.ParamCount, ObjDesc->Method.Concurrency); 80667754Smsmith break; 80767754Smsmith 80871867Smsmith case ACPI_TYPE_INTEGER: 809114237Snjl AcpiOsPrintf (" Value %8.8X%8.8X", 810104470Siwasaki ACPI_HIDWORD (ObjDesc->Integer.Value), 811104470Siwasaki ACPI_LODWORD (ObjDesc->Integer.Value)); 81267754Smsmith break; 81367754Smsmith 81467754Smsmith case ACPI_TYPE_STRING: 81567754Smsmith AcpiOsPrintf (" \"%s\"", ObjDesc->String.Pointer); 81667754Smsmith break; 81767754Smsmith 81867754Smsmith case ACPI_TYPE_REGION: 819114237Snjl AcpiOsPrintf (" SpaceId %X Length %X Address %8.8X%8.8X", 820104470Siwasaki ObjDesc->Region.SpaceId, 821104470Siwasaki ObjDesc->Region.Length, 822104470Siwasaki ACPI_HIDWORD (ObjDesc->Region.Address), 823104470Siwasaki ACPI_LODWORD (ObjDesc->Region.Address)); 82467754Smsmith break; 82567754Smsmith 82667754Smsmith case ACPI_TYPE_PACKAGE: 82769746Smsmith AcpiOsPrintf (" #Elements %X", ObjDesc->Package.Count); 82867754Smsmith break; 82967754Smsmith 83067754Smsmith case ACPI_TYPE_BUFFER: 83169746Smsmith AcpiOsPrintf (" Length %X", ObjDesc->Buffer.Length); 83267754Smsmith break; 83399679Siwasaki 83499679Siwasaki default: 83599679Siwasaki /* Ignore other object types */ 83699679Siwasaki break; 83767754Smsmith } 83867754Smsmith } 83967754Smsmith 84067754Smsmith AcpiOsPrintf ("\n"); 84167754Smsmith return (AE_OK); 84267754Smsmith} 84367754Smsmith 84467754Smsmith 84567754Smsmith/******************************************************************************* 84667754Smsmith * 84767754Smsmith * FUNCTION: AcpiDbDisplayObjects 84867754Smsmith * 84967754Smsmith * PARAMETERS: ObjTypeArg - Type of object to display 85067754Smsmith * DisplayCountArg - Max depth to display 85167754Smsmith * 85267754Smsmith * RETURN: None 85367754Smsmith * 85467754Smsmith * DESCRIPTION: Display objects in the namespace of the requested type 85567754Smsmith * 85667754Smsmith ******************************************************************************/ 85767754Smsmith 85867754SmsmithACPI_STATUS 85967754SmsmithAcpiDbDisplayObjects ( 860114237Snjl char *ObjTypeArg, 861114237Snjl char *DisplayCountArg) 86267754Smsmith{ 86391116Smsmith ACPI_OBJECT_TYPE Type; 86467754Smsmith 86567754Smsmith 86667754Smsmith /* Get the object type */ 86767754Smsmith 86867754Smsmith Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes); 86967754Smsmith if (Type == ACPI_TYPE_NOT_FOUND) 87067754Smsmith { 87167754Smsmith AcpiOsPrintf ("Invalid or unsupported argument\n"); 87267754Smsmith return (AE_OK); 87367754Smsmith } 87467754Smsmith 87591116Smsmith AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); 876102550Siwasaki AcpiOsPrintf ("Objects of type [%s] defined in the current ACPI Namespace: \n", 87799679Siwasaki AcpiUtGetTypeName (Type)); 87867754Smsmith 87991116Smsmith AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 88067754Smsmith 88167754Smsmith /* Walk the namespace from the root */ 88267754Smsmith 88399679Siwasaki (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 88467754Smsmith AcpiDbWalkForSpecificObjects, (void *) &Type, NULL); 88567754Smsmith 88691116Smsmith AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 88767754Smsmith return (AE_OK); 88867754Smsmith} 88967754Smsmith 89067754Smsmith 89167754Smsmith/******************************************************************************* 89267754Smsmith * 89367754Smsmith * FUNCTION: AcpiDbWalkAndMatchName 89467754Smsmith * 89567754Smsmith * PARAMETERS: Callback from WalkNamespace 89667754Smsmith * 89767754Smsmith * RETURN: Status 89867754Smsmith * 89967754Smsmith * DESCRIPTION: Find a particular name/names within the namespace. Wildcards 90067754Smsmith * are supported -- '?' matches any character. 90167754Smsmith * 90267754Smsmith ******************************************************************************/ 90367754Smsmith 90467754SmsmithACPI_STATUS 90567754SmsmithAcpiDbWalkAndMatchName ( 90667754Smsmith ACPI_HANDLE ObjHandle, 90767754Smsmith UINT32 NestingLevel, 90867754Smsmith void *Context, 90967754Smsmith void **ReturnValue) 91067754Smsmith{ 91167754Smsmith ACPI_STATUS Status; 912114237Snjl char *RequestedName = (char *) Context; 91367754Smsmith UINT32 i; 91491116Smsmith ACPI_BUFFER Buffer; 91567754Smsmith 91667754Smsmith 91767754Smsmith /* Check for a name match */ 91867754Smsmith 91967754Smsmith for (i = 0; i < 4; i++) 92067754Smsmith { 92167754Smsmith /* Wildcard support */ 92267754Smsmith 92367754Smsmith if ((RequestedName[i] != '?') && 92499679Siwasaki (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i])) 92567754Smsmith { 92667754Smsmith /* No match, just exit */ 92767754Smsmith 92867754Smsmith return (AE_OK); 92967754Smsmith } 93067754Smsmith } 93167754Smsmith 93267754Smsmith /* Get the full pathname to this object */ 93367754Smsmith 93491116Smsmith Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 93591116Smsmith Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); 93667754Smsmith if (ACPI_FAILURE (Status)) 93767754Smsmith { 93867754Smsmith AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); 93967754Smsmith } 94067754Smsmith else 94167754Smsmith { 942104470Siwasaki AcpiOsPrintf ("%32s (%p) - %s\n", (char *) Buffer.Pointer, ObjHandle, 94377424Smsmith AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) ObjHandle)->Type)); 94491116Smsmith ACPI_MEM_FREE (Buffer.Pointer); 94567754Smsmith } 94667754Smsmith 94767754Smsmith return (AE_OK); 94867754Smsmith} 94967754Smsmith 95067754Smsmith 95167754Smsmith/******************************************************************************* 95267754Smsmith * 95367754Smsmith * FUNCTION: AcpiDbFindNameInNamespace 95467754Smsmith * 95567754Smsmith * PARAMETERS: NameArg - The 4-character ACPI name to find. 95667754Smsmith * wildcards are supported. 95767754Smsmith * 95867754Smsmith * RETURN: None 95967754Smsmith * 96067754Smsmith * DESCRIPTION: Search the namespace for a given name (with wildcards) 96167754Smsmith * 96267754Smsmith ******************************************************************************/ 96367754Smsmith 96467754SmsmithACPI_STATUS 96567754SmsmithAcpiDbFindNameInNamespace ( 966114237Snjl char *NameArg) 96767754Smsmith{ 96867754Smsmith 96991116Smsmith if (ACPI_STRLEN (NameArg) > 4) 97067754Smsmith { 97167754Smsmith AcpiOsPrintf ("Name must be no longer than 4 characters\n"); 97267754Smsmith return (AE_OK); 97367754Smsmith } 97467754Smsmith 97567754Smsmith /* Walk the namespace from the root */ 97667754Smsmith 97799679Siwasaki (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 97867754Smsmith AcpiDbWalkAndMatchName, NameArg, NULL); 97967754Smsmith 98091116Smsmith AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 98167754Smsmith return (AE_OK); 98267754Smsmith} 98367754Smsmith 98467754Smsmith 98567754Smsmith/******************************************************************************* 98667754Smsmith * 98767754Smsmith * FUNCTION: AcpiDbSetScope 98867754Smsmith * 98967754Smsmith * PARAMETERS: Name - New scope path 99067754Smsmith * 99167754Smsmith * RETURN: Status 99267754Smsmith * 99367754Smsmith * DESCRIPTION: Set the "current scope" as maintained by this utility. 99467754Smsmith * The scope is used as a prefix to ACPI paths. 99567754Smsmith * 99667754Smsmith ******************************************************************************/ 99767754Smsmith 99867754Smsmithvoid 99967754SmsmithAcpiDbSetScope ( 1000114237Snjl char *Name) 100167754Smsmith{ 100291116Smsmith ACPI_STATUS Status; 100391116Smsmith ACPI_NAMESPACE_NODE *Node; 100467754Smsmith 100591116Smsmith 100667754Smsmith if (!Name || Name[0] == 0) 100767754Smsmith { 100883174Smsmith AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf); 100967754Smsmith return; 101067754Smsmith } 101167754Smsmith 101267754Smsmith AcpiDbPrepNamestring (Name); 101367754Smsmith 101467754Smsmith if (Name[0] == '\\') 101567754Smsmith { 101691116Smsmith /* Validate new scope from the root */ 101791116Smsmith 101891116Smsmith Status = AcpiNsGetNodeByPath (Name, AcpiGbl_RootNode, ACPI_NS_NO_UPSEARCH, &Node); 101991116Smsmith if (ACPI_FAILURE (Status)) 102091116Smsmith { 102191116Smsmith goto ErrorExit; 102291116Smsmith } 102391116Smsmith 102491116Smsmith ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name); 102591116Smsmith ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\"); 102667754Smsmith } 102767754Smsmith else 102867754Smsmith { 102991116Smsmith /* Validate new scope relative to old scope */ 103091116Smsmith 103191116Smsmith Status = AcpiNsGetNodeByPath (Name, AcpiGbl_DbScopeNode, ACPI_NS_NO_UPSEARCH, &Node); 103291116Smsmith if (ACPI_FAILURE (Status)) 103391116Smsmith { 103491116Smsmith goto ErrorExit; 103591116Smsmith } 103691116Smsmith 103791116Smsmith ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name); 103891116Smsmith ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\"); 103967754Smsmith } 104067754Smsmith 104191116Smsmith AcpiGbl_DbScopeNode = Node; 104283174Smsmith AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf); 104391116Smsmith return; 104491116Smsmith 104591116SmsmithErrorExit: 104691116Smsmith 104791116Smsmith AcpiOsPrintf ("Could not attach scope: %s, %s\n", Name, AcpiFormatException (Status)); 104867754Smsmith} 104967754Smsmith 105073561Smsmith 105173561Smsmith/******************************************************************************* 105273561Smsmith * 105373561Smsmith * FUNCTION: AcpiDbDisplayResources 105473561Smsmith * 105573561Smsmith * PARAMETERS: ObjectArg - String with hex value of the object 105673561Smsmith * 105773561Smsmith * RETURN: None 105873561Smsmith * 1059107325Siwasaki * DESCRIPTION: Display the resource objects associated with a device. 106073561Smsmith * 106173561Smsmith ******************************************************************************/ 106273561Smsmith 106373561Smsmithvoid 106473561SmsmithAcpiDbDisplayResources ( 1065114237Snjl char *ObjectArg) 106673561Smsmith{ 106799679Siwasaki#if ACPI_MACHINE_WIDTH != 16 106899679Siwasaki 106973561Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 107073561Smsmith ACPI_STATUS Status; 107173561Smsmith ACPI_BUFFER ReturnObj; 107273561Smsmith 107373561Smsmith 107491116Smsmith AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 107591116Smsmith AcpiDbgLevel |= ACPI_LV_RESOURCES; 107673561Smsmith 107773561Smsmith /* Convert string to object pointer */ 107873561Smsmith 107991116Smsmith ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16)); 108073561Smsmith 108173561Smsmith /* Prepare for a return object of arbitrary size */ 108273561Smsmith 108383174Smsmith ReturnObj.Pointer = AcpiGbl_DbBuffer; 108483174Smsmith ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 108573561Smsmith 108677424Smsmith /* _PRT */ 108777424Smsmith 108877424Smsmith AcpiOsPrintf ("Evaluating _PRT\n"); 108977424Smsmith 109073561Smsmith Status = AcpiEvaluateObject (ObjDesc, "_PRT", NULL, &ReturnObj); 109173561Smsmith if (ACPI_FAILURE (Status)) 109273561Smsmith { 109380062Smsmith AcpiOsPrintf ("Could not obtain _PRT: %s\n", AcpiFormatException (Status)); 109483174Smsmith goto GetCrs; 109573561Smsmith } 109673561Smsmith 109783174Smsmith ReturnObj.Pointer = AcpiGbl_DbBuffer; 109883174Smsmith ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 109973561Smsmith 110073561Smsmith Status = AcpiGetIrqRoutingTable (ObjDesc, &ReturnObj); 110173561Smsmith if (ACPI_FAILURE (Status)) 110273561Smsmith { 110380062Smsmith AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", AcpiFormatException (Status)); 110477424Smsmith } 110583174Smsmith else 110683174Smsmith { 110783174Smsmith AcpiRsDumpIrqList ((UINT8 *) AcpiGbl_DbBuffer); 110883174Smsmith } 110977424Smsmith 111077424Smsmith 111177424Smsmith /* _CRS */ 111283174Smsmith 111383174SmsmithGetCrs: 111477424Smsmith AcpiOsPrintf ("Evaluating _CRS\n"); 111577424Smsmith 111683174Smsmith ReturnObj.Pointer = AcpiGbl_DbBuffer; 111783174Smsmith ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 111877424Smsmith 111977424Smsmith Status = AcpiEvaluateObject (ObjDesc, "_CRS", NULL, &ReturnObj); 112077424Smsmith if (ACPI_FAILURE (Status)) 112177424Smsmith { 112280062Smsmith AcpiOsPrintf ("Could not obtain _CRS: %s\n", AcpiFormatException (Status)); 112383174Smsmith goto GetPrs; 112477424Smsmith } 112577424Smsmith 112683174Smsmith ReturnObj.Pointer = AcpiGbl_DbBuffer; 112783174Smsmith ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 112877424Smsmith 112977424Smsmith Status = AcpiGetCurrentResources (ObjDesc, &ReturnObj); 113077424Smsmith if (ACPI_FAILURE (Status)) 113177424Smsmith { 113280062Smsmith AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", AcpiFormatException (Status)); 113391116Smsmith goto GetPrs; 113477424Smsmith } 113583174Smsmith else 113683174Smsmith { 113799679Siwasaki AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer)); 113883174Smsmith } 113977424Smsmith 114091116Smsmith Status = AcpiSetCurrentResources (ObjDesc, &ReturnObj); 114191116Smsmith if (ACPI_FAILURE (Status)) 114291116Smsmith { 114391116Smsmith AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", AcpiFormatException (Status)); 114491116Smsmith goto GetPrs; 114591116Smsmith } 114683174Smsmith 114791116Smsmith 114877424Smsmith /* _PRS */ 114983174Smsmith 115083174SmsmithGetPrs: 115177424Smsmith AcpiOsPrintf ("Evaluating _PRS\n"); 115277424Smsmith 115383174Smsmith ReturnObj.Pointer = AcpiGbl_DbBuffer; 115483174Smsmith ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 115577424Smsmith 115677424Smsmith Status = AcpiEvaluateObject (ObjDesc, "_PRS", NULL, &ReturnObj); 115777424Smsmith if (ACPI_FAILURE (Status)) 115877424Smsmith { 115980062Smsmith AcpiOsPrintf ("Could not obtain _PRS: %s\n", AcpiFormatException (Status)); 116073561Smsmith goto Cleanup; 116173561Smsmith } 116273561Smsmith 116383174Smsmith ReturnObj.Pointer = AcpiGbl_DbBuffer; 116483174Smsmith ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 116577424Smsmith 116677424Smsmith Status = AcpiGetPossibleResources (ObjDesc, &ReturnObj); 116777424Smsmith if (ACPI_FAILURE (Status)) 116873561Smsmith { 116980062Smsmith AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", AcpiFormatException (Status)); 117073561Smsmith } 117183174Smsmith else 117283174Smsmith { 117399679Siwasaki AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer)); 117483174Smsmith } 117577424Smsmith 117673561SmsmithCleanup: 117773561Smsmith 117891116Smsmith AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 117973561Smsmith return; 118077424Smsmith#endif 118173561Smsmith} 118273561Smsmith 118373561Smsmith 118499679Siwasaki/******************************************************************************* 118599679Siwasaki * 118699679Siwasaki * FUNCTION: AcpiDbIntegrityWalk 118799679Siwasaki * 118899679Siwasaki * PARAMETERS: Callback from WalkNamespace 118999679Siwasaki * 119099679Siwasaki * RETURN: Status 119199679Siwasaki * 119299679Siwasaki * DESCRIPTION: Examine one NS node for valid values. 119399679Siwasaki * 119499679Siwasaki ******************************************************************************/ 119599679Siwasaki 119699679SiwasakiACPI_STATUS 119799679SiwasakiAcpiDbIntegrityWalk ( 119899679Siwasaki ACPI_HANDLE ObjHandle, 119999679Siwasaki UINT32 NestingLevel, 120099679Siwasaki void *Context, 120199679Siwasaki void **ReturnValue) 120299679Siwasaki{ 120399679Siwasaki ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context; 120499679Siwasaki ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 120599679Siwasaki ACPI_OPERAND_OBJECT *Object; 120699679Siwasaki 120799679Siwasaki 120899679Siwasaki Info->Nodes++; 120999679Siwasaki if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) 121099679Siwasaki { 121199679Siwasaki AcpiOsPrintf ("Invalid Descriptor Type for Node %p, Type = %X\n", 121299679Siwasaki Node, ACPI_GET_DESCRIPTOR_TYPE (Node)); 121399679Siwasaki } 121499679Siwasaki 1215107325Siwasaki if (Node->Type > ACPI_TYPE_LOCAL_MAX) 121699679Siwasaki { 121799679Siwasaki AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n", 121899679Siwasaki Node, Node->Type); 121999679Siwasaki } 122099679Siwasaki 122199679Siwasaki if (!AcpiUtValidAcpiName (Node->Name.Integer)) 122299679Siwasaki { 122399679Siwasaki AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node); 122499679Siwasaki } 122599679Siwasaki 122699679Siwasaki Object = AcpiNsGetAttachedObject (Node); 122799679Siwasaki if (Object) 122899679Siwasaki { 122999679Siwasaki Info->Objects++; 123099679Siwasaki if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND) 123199679Siwasaki { 123299679Siwasaki AcpiOsPrintf ("Invalid Descriptor Type for Object %p, Type = %X\n", 123399679Siwasaki Object, ACPI_GET_DESCRIPTOR_TYPE (Object)); 123499679Siwasaki } 123599679Siwasaki } 123699679Siwasaki 123799679Siwasaki return (AE_OK); 123899679Siwasaki} 123999679Siwasaki 124099679Siwasaki 124199679Siwasaki/******************************************************************************* 124299679Siwasaki * 124399679Siwasaki * FUNCTION: AcpiDbCheckIntegrity 124499679Siwasaki * 124599679Siwasaki * PARAMETERS: None 124699679Siwasaki * 124799679Siwasaki * RETURN: None 124899679Siwasaki * 124999679Siwasaki * DESCRIPTION: Check entire namespace for data structure integrity 125099679Siwasaki * 125199679Siwasaki ******************************************************************************/ 125299679Siwasaki 125399679Siwasakivoid 125499679SiwasakiAcpiDbCheckIntegrity (void) 125599679Siwasaki{ 125699679Siwasaki ACPI_INTEGRITY_INFO Info = {0,0}; 125799679Siwasaki 125899679Siwasaki /* Search all nodes in namespace */ 125999679Siwasaki 126099679Siwasaki (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 126199679Siwasaki AcpiDbIntegrityWalk, (void *) &Info, NULL); 126299679Siwasaki 126399679Siwasaki AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n", Info.Nodes, Info.Objects); 126499679Siwasaki} 126599679Siwasaki 1266114237Snjl 1267114237Snjl/******************************************************************************* 1268114237Snjl * 1269114237Snjl * FUNCTION: AcpiDbGenerateGpe 1270114237Snjl * 1271114237Snjl * PARAMETERS: None 1272114237Snjl * 1273114237Snjl * RETURN: None 1274114237Snjl * 1275114237Snjl * DESCRIPTION: Generate a GPE 1276114237Snjl * 1277114237Snjl ******************************************************************************/ 1278114237Snjl 1279114237Snjlvoid 1280114237SnjlAcpiDbGenerateGpe ( 1281114237Snjl char *GpeArg, 1282114237Snjl char *BlockArg) 1283114237Snjl{ 1284114237Snjl UINT32 BlockNumber; 1285114237Snjl UINT32 GpeNumber; 1286114237Snjl ACPI_GPE_EVENT_INFO *GpeEventInfo; 1287114237Snjl 1288114237Snjl 1289117521Snjl GpeNumber = ACPI_STRTOUL (GpeArg, NULL, 0); 1290117521Snjl BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0); 1291114237Snjl 1292114237Snjl 1293117521Snjl GpeEventInfo = AcpiEvGetGpeEventInfo ((void *) BlockNumber, GpeNumber); 1294114237Snjl if (!GpeEventInfo) 1295114237Snjl { 1296114237Snjl AcpiOsPrintf ("Invalid GPE\n"); 1297114237Snjl return; 1298114237Snjl } 1299114237Snjl 1300117521Snjl AcpiEvGpeDispatch (GpeEventInfo, GpeNumber); 1301114237Snjl} 1302114237Snjl 1303102550Siwasaki#endif /* ACPI_DEBUGGER */ 1304