1*3446Smrj /******************************************************************************* 2*3446Smrj * 3*3446Smrj * Module Name: dbcmds - debug commands and output routines 4*3446Smrj * $Revision: 1.145 $ 5*3446Smrj * 6*3446Smrj ******************************************************************************/ 7*3446Smrj 8*3446Smrj /****************************************************************************** 9*3446Smrj * 10*3446Smrj * 1. Copyright Notice 11*3446Smrj * 12*3446Smrj * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. 13*3446Smrj * All rights reserved. 14*3446Smrj * 15*3446Smrj * 2. License 16*3446Smrj * 17*3446Smrj * 2.1. This is your license from Intel Corp. under its intellectual property 18*3446Smrj * rights. You may have additional license terms from the party that provided 19*3446Smrj * you this software, covering your right to use that party's intellectual 20*3446Smrj * property rights. 21*3446Smrj * 22*3446Smrj * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23*3446Smrj * copy of the source code appearing in this file ("Covered Code") an 24*3446Smrj * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25*3446Smrj * base code distributed originally by Intel ("Original Intel Code") to copy, 26*3446Smrj * make derivatives, distribute, use and display any portion of the Covered 27*3446Smrj * Code in any form, with the right to sublicense such rights; and 28*3446Smrj * 29*3446Smrj * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30*3446Smrj * license (with the right to sublicense), under only those claims of Intel 31*3446Smrj * patents that are infringed by the Original Intel Code, to make, use, sell, 32*3446Smrj * offer to sell, and import the Covered Code and derivative works thereof 33*3446Smrj * solely to the minimum extent necessary to exercise the above copyright 34*3446Smrj * license, and in no event shall the patent license extend to any additions 35*3446Smrj * to or modifications of the Original Intel Code. No other license or right 36*3446Smrj * is granted directly or by implication, estoppel or otherwise; 37*3446Smrj * 38*3446Smrj * The above copyright and patent license is granted only if the following 39*3446Smrj * conditions are met: 40*3446Smrj * 41*3446Smrj * 3. Conditions 42*3446Smrj * 43*3446Smrj * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44*3446Smrj * Redistribution of source code of any substantial portion of the Covered 45*3446Smrj * Code or modification with rights to further distribute source must include 46*3446Smrj * the above Copyright Notice, the above License, this list of Conditions, 47*3446Smrj * and the following Disclaimer and Export Compliance provision. In addition, 48*3446Smrj * Licensee must cause all Covered Code to which Licensee contributes to 49*3446Smrj * contain a file documenting the changes Licensee made to create that Covered 50*3446Smrj * Code and the date of any change. Licensee must include in that file the 51*3446Smrj * documentation of any changes made by any predecessor Licensee. Licensee 52*3446Smrj * must include a prominent statement that the modification is derived, 53*3446Smrj * directly or indirectly, from Original Intel Code. 54*3446Smrj * 55*3446Smrj * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56*3446Smrj * Redistribution of source code of any substantial portion of the Covered 57*3446Smrj * Code or modification without rights to further distribute source must 58*3446Smrj * include the following Disclaimer and Export Compliance provision in the 59*3446Smrj * documentation and/or other materials provided with distribution. In 60*3446Smrj * addition, Licensee may not authorize further sublicense of source of any 61*3446Smrj * portion of the Covered Code, and must include terms to the effect that the 62*3446Smrj * license from Licensee to its licensee is limited to the intellectual 63*3446Smrj * property embodied in the software Licensee provides to its licensee, and 64*3446Smrj * not to intellectual property embodied in modifications its licensee may 65*3446Smrj * make. 66*3446Smrj * 67*3446Smrj * 3.3. Redistribution of Executable. Redistribution in executable form of any 68*3446Smrj * substantial portion of the Covered Code or modification must reproduce the 69*3446Smrj * above Copyright Notice, and the following Disclaimer and Export Compliance 70*3446Smrj * provision in the documentation and/or other materials provided with the 71*3446Smrj * distribution. 72*3446Smrj * 73*3446Smrj * 3.4. Intel retains all right, title, and interest in and to the Original 74*3446Smrj * Intel Code. 75*3446Smrj * 76*3446Smrj * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77*3446Smrj * Intel shall be used in advertising or otherwise to promote the sale, use or 78*3446Smrj * other dealings in products derived from or relating to the Covered Code 79*3446Smrj * without prior written authorization from Intel. 80*3446Smrj * 81*3446Smrj * 4. Disclaimer and Export Compliance 82*3446Smrj * 83*3446Smrj * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84*3446Smrj * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85*3446Smrj * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86*3446Smrj * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87*3446Smrj * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88*3446Smrj * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89*3446Smrj * PARTICULAR PURPOSE. 90*3446Smrj * 91*3446Smrj * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92*3446Smrj * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93*3446Smrj * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94*3446Smrj * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95*3446Smrj * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96*3446Smrj * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97*3446Smrj * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98*3446Smrj * LIMITED REMEDY. 99*3446Smrj * 100*3446Smrj * 4.3. Licensee shall not export, either directly or indirectly, any of this 101*3446Smrj * software or system incorporating such software without first obtaining any 102*3446Smrj * required license or other approval from the U. S. Department of Commerce or 103*3446Smrj * any other agency or department of the United States Government. In the 104*3446Smrj * event Licensee exports any such software from the United States or 105*3446Smrj * re-exports any such software from a foreign destination, Licensee shall 106*3446Smrj * ensure that the distribution and export/re-export of the software is in 107*3446Smrj * compliance with all laws, regulations, orders, or other restrictions of the 108*3446Smrj * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109*3446Smrj * any of its subsidiaries will export/re-export any technical data, process, 110*3446Smrj * software, or service, directly or indirectly, to any country for which the 111*3446Smrj * United States government or any agency thereof requires an export license, 112*3446Smrj * other governmental approval, or letter of assurance, without first obtaining 113*3446Smrj * such license, approval or letter. 114*3446Smrj * 115*3446Smrj *****************************************************************************/ 116*3446Smrj 117*3446Smrj 118*3446Smrj #include "acpi.h" 119*3446Smrj #include "acdispat.h" 120*3446Smrj #include "amlcode.h" 121*3446Smrj #include "acnamesp.h" 122*3446Smrj #include "acevents.h" 123*3446Smrj #include "acdebug.h" 124*3446Smrj #include "acresrc.h" 125*3446Smrj #include "acdisasm.h" 126*3446Smrj 127*3446Smrj 128*3446Smrj #include "acparser.h" 129*3446Smrj 130*3446Smrj #ifdef ACPI_DEBUGGER 131*3446Smrj 132*3446Smrj #define _COMPONENT ACPI_CA_DEBUGGER 133*3446Smrj ACPI_MODULE_NAME ("dbcmds") 134*3446Smrj 135*3446Smrj /* Local prototypes */ 136*3446Smrj 137*3446Smrj static ACPI_STATUS 138*3446Smrj AcpiDbIntegrityWalk ( 139*3446Smrj ACPI_HANDLE ObjHandle, 140*3446Smrj UINT32 NestingLevel, 141*3446Smrj void *Context, 142*3446Smrj void **ReturnValue); 143*3446Smrj 144*3446Smrj static ACPI_STATUS 145*3446Smrj AcpiDbWalkAndMatchName ( 146*3446Smrj ACPI_HANDLE ObjHandle, 147*3446Smrj UINT32 NestingLevel, 148*3446Smrj void *Context, 149*3446Smrj void **ReturnValue); 150*3446Smrj 151*3446Smrj static ACPI_STATUS 152*3446Smrj AcpiDbWalkForReferences ( 153*3446Smrj ACPI_HANDLE ObjHandle, 154*3446Smrj UINT32 NestingLevel, 155*3446Smrj void *Context, 156*3446Smrj void **ReturnValue); 157*3446Smrj 158*3446Smrj static ACPI_STATUS 159*3446Smrj AcpiDbWalkForSpecificObjects ( 160*3446Smrj ACPI_HANDLE ObjHandle, 161*3446Smrj UINT32 NestingLevel, 162*3446Smrj void *Context, 163*3446Smrj void **ReturnValue); 164*3446Smrj 165*3446Smrj static ACPI_NAMESPACE_NODE * 166*3446Smrj AcpiDbConvertToNode ( 167*3446Smrj char *InString); 168*3446Smrj 169*3446Smrj static void 170*3446Smrj AcpiDmCompareAmlResources ( 171*3446Smrj UINT8 *Aml1Buffer, 172*3446Smrj ACPI_RSDESC_SIZE Aml1BufferLength, 173*3446Smrj UINT8 *Aml2Buffer, 174*3446Smrj ACPI_RSDESC_SIZE Aml2BufferLength); 175*3446Smrj 176*3446Smrj static ACPI_STATUS 177*3446Smrj AcpiDmTestResourceConversion ( 178*3446Smrj ACPI_NAMESPACE_NODE *Node, 179*3446Smrj char *Name); 180*3446Smrj 181*3446Smrj 182*3446Smrj /* 183*3446Smrj * Arguments for the Objects command 184*3446Smrj * These object types map directly to the ACPI_TYPES 185*3446Smrj */ 186*3446Smrj static ARGUMENT_INFO AcpiDbObjectTypes [] = 187*3446Smrj { 188*3446Smrj {"ANY"}, 189*3446Smrj {"INTEGERS"}, 190*3446Smrj {"STRINGS"}, 191*3446Smrj {"BUFFERS"}, 192*3446Smrj {"PACKAGES"}, 193*3446Smrj {"FIELDS"}, 194*3446Smrj {"DEVICES"}, 195*3446Smrj {"EVENTS"}, 196*3446Smrj {"METHODS"}, 197*3446Smrj {"MUTEXES"}, 198*3446Smrj {"REGIONS"}, 199*3446Smrj {"POWERRESOURCES"}, 200*3446Smrj {"PROCESSORS"}, 201*3446Smrj {"THERMALZONES"}, 202*3446Smrj {"BUFFERFIELDS"}, 203*3446Smrj {"DDBHANDLES"}, 204*3446Smrj {"DEBUG"}, 205*3446Smrj {"REGIONFIELDS"}, 206*3446Smrj {"BANKFIELDS"}, 207*3446Smrj {"INDEXFIELDS"}, 208*3446Smrj {"REFERENCES"}, 209*3446Smrj {"ALIAS"}, 210*3446Smrj {NULL} /* Must be null terminated */ 211*3446Smrj }; 212*3446Smrj 213*3446Smrj 214*3446Smrj /******************************************************************************* 215*3446Smrj * 216*3446Smrj * FUNCTION: AcpiDbConvertToNode 217*3446Smrj * 218*3446Smrj * PARAMETERS: InString - String to convert 219*3446Smrj * 220*3446Smrj * RETURN: Pointer to a NS node 221*3446Smrj * 222*3446Smrj * DESCRIPTION: Convert a string to a valid NS pointer. Handles numeric or 223*3446Smrj * alpha strings. 224*3446Smrj * 225*3446Smrj ******************************************************************************/ 226*3446Smrj 227*3446Smrj static ACPI_NAMESPACE_NODE * 228*3446Smrj AcpiDbConvertToNode ( 229*3446Smrj char *InString) 230*3446Smrj { 231*3446Smrj ACPI_NAMESPACE_NODE *Node; 232*3446Smrj 233*3446Smrj 234*3446Smrj if ((*InString >= 0x30) && (*InString <= 0x39)) 235*3446Smrj { 236*3446Smrj /* Numeric argument, convert */ 237*3446Smrj 238*3446Smrj Node = ACPI_TO_POINTER (ACPI_STRTOUL (InString, NULL, 16)); 239*3446Smrj if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE))) 240*3446Smrj { 241*3446Smrj AcpiOsPrintf ("Address %p is invalid in this address space\n", 242*3446Smrj Node); 243*3446Smrj return (NULL); 244*3446Smrj } 245*3446Smrj 246*3446Smrj /* Make sure pointer is valid NS node */ 247*3446Smrj 248*3446Smrj if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) 249*3446Smrj { 250*3446Smrj AcpiOsPrintf ("Address %p is not a valid NS node [%s]\n", 251*3446Smrj Node, AcpiUtGetDescriptorName (Node)); 252*3446Smrj return (NULL); 253*3446Smrj } 254*3446Smrj } 255*3446Smrj else 256*3446Smrj { 257*3446Smrj /* Alpha argument */ 258*3446Smrj /* The parameter is a name string that must be resolved to a 259*3446Smrj * Named obj 260*3446Smrj */ 261*3446Smrj Node = AcpiDbLocalNsLookup (InString); 262*3446Smrj if (!Node) 263*3446Smrj { 264*3446Smrj Node = AcpiGbl_RootNode; 265*3446Smrj } 266*3446Smrj } 267*3446Smrj 268*3446Smrj return (Node); 269*3446Smrj } 270*3446Smrj 271*3446Smrj 272*3446Smrj /******************************************************************************* 273*3446Smrj * 274*3446Smrj * FUNCTION: AcpiDbSleep 275*3446Smrj * 276*3446Smrj * PARAMETERS: ObjectArg - Desired sleep state (0-5) 277*3446Smrj * 278*3446Smrj * RETURN: Status 279*3446Smrj * 280*3446Smrj * DESCRIPTION: Simulate a sleep/wake sequence 281*3446Smrj * 282*3446Smrj ******************************************************************************/ 283*3446Smrj 284*3446Smrj ACPI_STATUS 285*3446Smrj AcpiDbSleep ( 286*3446Smrj char *ObjectArg) 287*3446Smrj { 288*3446Smrj #if ACPI_MACHINE_WIDTH == 16 289*3446Smrj return (AE_OK); 290*3446Smrj #else 291*3446Smrj ACPI_STATUS Status; 292*3446Smrj UINT8 SleepState; 293*3446Smrj 294*3446Smrj 295*3446Smrj SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0); 296*3446Smrj 297*3446Smrj AcpiOsPrintf ("**** Prepare to sleep ****\n"); 298*3446Smrj Status = AcpiEnterSleepStatePrep (SleepState); 299*3446Smrj if (ACPI_FAILURE (Status)) 300*3446Smrj { 301*3446Smrj return (Status); 302*3446Smrj } 303*3446Smrj 304*3446Smrj AcpiOsPrintf ("**** Going to sleep ****\n"); 305*3446Smrj Status = AcpiEnterSleepState (SleepState); 306*3446Smrj if (ACPI_FAILURE (Status)) 307*3446Smrj { 308*3446Smrj return (Status); 309*3446Smrj } 310*3446Smrj 311*3446Smrj AcpiOsPrintf ("**** returning from sleep ****\n"); 312*3446Smrj Status = AcpiLeaveSleepState (SleepState); 313*3446Smrj 314*3446Smrj return (Status); 315*3446Smrj #endif 316*3446Smrj } 317*3446Smrj 318*3446Smrj 319*3446Smrj /******************************************************************************* 320*3446Smrj * 321*3446Smrj * FUNCTION: AcpiDbWalkForReferences 322*3446Smrj * 323*3446Smrj * PARAMETERS: Callback from WalkNamespace 324*3446Smrj * 325*3446Smrj * RETURN: Status 326*3446Smrj * 327*3446Smrj * DESCRIPTION: Check if this namespace object refers to the target object 328*3446Smrj * that is passed in as the context value. 329*3446Smrj * 330*3446Smrj * Note: Currently doesn't check subobjects within the Node's object 331*3446Smrj * 332*3446Smrj ******************************************************************************/ 333*3446Smrj 334*3446Smrj static ACPI_STATUS 335*3446Smrj AcpiDbWalkForReferences ( 336*3446Smrj ACPI_HANDLE ObjHandle, 337*3446Smrj UINT32 NestingLevel, 338*3446Smrj void *Context, 339*3446Smrj void **ReturnValue) 340*3446Smrj { 341*3446Smrj ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context; 342*3446Smrj ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 343*3446Smrj 344*3446Smrj 345*3446Smrj /* Check for match against the namespace node itself */ 346*3446Smrj 347*3446Smrj if (Node == (void *) ObjDesc) 348*3446Smrj { 349*3446Smrj AcpiOsPrintf ("Object is a Node [%4.4s]\n", 350*3446Smrj AcpiUtGetNodeName (Node)); 351*3446Smrj } 352*3446Smrj 353*3446Smrj /* Check for match against the object attached to the node */ 354*3446Smrj 355*3446Smrj if (AcpiNsGetAttachedObject (Node) == ObjDesc) 356*3446Smrj { 357*3446Smrj AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", 358*3446Smrj Node, AcpiUtGetNodeName (Node)); 359*3446Smrj } 360*3446Smrj 361*3446Smrj return (AE_OK); 362*3446Smrj } 363*3446Smrj 364*3446Smrj 365*3446Smrj /******************************************************************************* 366*3446Smrj * 367*3446Smrj * FUNCTION: AcpiDbFindReferences 368*3446Smrj * 369*3446Smrj * PARAMETERS: ObjectArg - String with hex value of the object 370*3446Smrj * 371*3446Smrj * RETURN: None 372*3446Smrj * 373*3446Smrj * DESCRIPTION: Search namespace for all references to the input object 374*3446Smrj * 375*3446Smrj ******************************************************************************/ 376*3446Smrj 377*3446Smrj void 378*3446Smrj AcpiDbFindReferences ( 379*3446Smrj char *ObjectArg) 380*3446Smrj { 381*3446Smrj ACPI_OPERAND_OBJECT *ObjDesc; 382*3446Smrj 383*3446Smrj 384*3446Smrj /* Convert string to object pointer */ 385*3446Smrj 386*3446Smrj ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16)); 387*3446Smrj 388*3446Smrj /* Search all nodes in namespace */ 389*3446Smrj 390*3446Smrj (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 391*3446Smrj AcpiDbWalkForReferences, (void *) ObjDesc, NULL); 392*3446Smrj } 393*3446Smrj 394*3446Smrj 395*3446Smrj /******************************************************************************* 396*3446Smrj * 397*3446Smrj * FUNCTION: AcpiDbDisplayLocks 398*3446Smrj * 399*3446Smrj * PARAMETERS: None 400*3446Smrj * 401*3446Smrj * RETURN: None 402*3446Smrj * 403*3446Smrj * DESCRIPTION: Display information about internal mutexes. 404*3446Smrj * 405*3446Smrj ******************************************************************************/ 406*3446Smrj 407*3446Smrj void 408*3446Smrj AcpiDbDisplayLocks ( 409*3446Smrj void) 410*3446Smrj { 411*3446Smrj UINT32 i; 412*3446Smrj 413*3446Smrj 414*3446Smrj for (i = 0; i < ACPI_MAX_MUTEX; i++) 415*3446Smrj { 416*3446Smrj AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i), 417*3446Smrj AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED 418*3446Smrj ? "Locked" : "Unlocked"); 419*3446Smrj } 420*3446Smrj } 421*3446Smrj 422*3446Smrj 423*3446Smrj /******************************************************************************* 424*3446Smrj * 425*3446Smrj * FUNCTION: AcpiDbDisplayTableInfo 426*3446Smrj * 427*3446Smrj * PARAMETERS: TableArg - String with name of table to be displayed 428*3446Smrj * 429*3446Smrj * RETURN: None 430*3446Smrj * 431*3446Smrj * DESCRIPTION: Display information about loaded tables. Current 432*3446Smrj * implementation displays all loaded tables. 433*3446Smrj * 434*3446Smrj ******************************************************************************/ 435*3446Smrj 436*3446Smrj void 437*3446Smrj AcpiDbDisplayTableInfo ( 438*3446Smrj char *TableArg) 439*3446Smrj { 440*3446Smrj UINT32 i; 441*3446Smrj ACPI_TABLE_DESC *TableDesc; 442*3446Smrj 443*3446Smrj 444*3446Smrj for (i = 0; i < (ACPI_TABLE_ID_MAX+1); i++) 445*3446Smrj { 446*3446Smrj TableDesc = AcpiGbl_TableLists[i].Next; 447*3446Smrj while (TableDesc) 448*3446Smrj { 449*3446Smrj AcpiOsPrintf ( "%s at %p length %.5X", 450*3446Smrj AcpiGbl_TableData[i].Name, TableDesc->Pointer, 451*3446Smrj (UINT32) TableDesc->Length); 452*3446Smrj 453*3446Smrj if (i != ACPI_TABLE_ID_FACS) 454*3446Smrj { 455*3446Smrj AcpiOsPrintf (" OemID=%6s TableId=%8s OemRevision=%8.8X", 456*3446Smrj TableDesc->Pointer->OemId, 457*3446Smrj TableDesc->Pointer->OemTableId, 458*3446Smrj TableDesc->Pointer->OemRevision); 459*3446Smrj } 460*3446Smrj AcpiOsPrintf ("\n"); 461*3446Smrj 462*3446Smrj TableDesc = TableDesc->Next; 463*3446Smrj } 464*3446Smrj } 465*3446Smrj } 466*3446Smrj 467*3446Smrj 468*3446Smrj /******************************************************************************* 469*3446Smrj * 470*3446Smrj * FUNCTION: AcpiDbUnloadAcpiTable 471*3446Smrj * 472*3446Smrj * PARAMETERS: TableArg - Name of the table to be unloaded 473*3446Smrj * InstanceArg - Which instance of the table to unload (if 474*3446Smrj * there are multiple tables of the same type) 475*3446Smrj * 476*3446Smrj * RETURN: Nonde 477*3446Smrj * 478*3446Smrj * DESCRIPTION: Unload an ACPI table. 479*3446Smrj * Instance is not implemented 480*3446Smrj * 481*3446Smrj ******************************************************************************/ 482*3446Smrj 483*3446Smrj void 484*3446Smrj AcpiDbUnloadAcpiTable ( 485*3446Smrj char *TableArg, 486*3446Smrj char *InstanceArg) 487*3446Smrj { 488*3446Smrj UINT32 i; 489*3446Smrj ACPI_STATUS Status; 490*3446Smrj 491*3446Smrj 492*3446Smrj /* Search all tables for the target type */ 493*3446Smrj 494*3446Smrj for (i = 0; i < (ACPI_TABLE_ID_MAX+1); i++) 495*3446Smrj { 496*3446Smrj if (!ACPI_STRNCMP (TableArg, AcpiGbl_TableData[i].Signature, 497*3446Smrj AcpiGbl_TableData[i].SigLength)) 498*3446Smrj { 499*3446Smrj /* Found the table, unload it */ 500*3446Smrj 501*3446Smrj Status = AcpiUnloadTable (i); 502*3446Smrj if (ACPI_SUCCESS (Status)) 503*3446Smrj { 504*3446Smrj AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg); 505*3446Smrj } 506*3446Smrj else 507*3446Smrj { 508*3446Smrj AcpiOsPrintf ("%s, while unloading [%s]\n", 509*3446Smrj AcpiFormatException (Status), TableArg); 510*3446Smrj } 511*3446Smrj 512*3446Smrj return; 513*3446Smrj } 514*3446Smrj } 515*3446Smrj 516*3446Smrj AcpiOsPrintf ("Unknown table type [%s]\n", TableArg); 517*3446Smrj } 518*3446Smrj 519*3446Smrj 520*3446Smrj /******************************************************************************* 521*3446Smrj * 522*3446Smrj * FUNCTION: AcpiDbSetMethodBreakpoint 523*3446Smrj * 524*3446Smrj * PARAMETERS: Location - AML offset of breakpoint 525*3446Smrj * WalkState - Current walk info 526*3446Smrj * Op - Current Op (from parse walk) 527*3446Smrj * 528*3446Smrj * RETURN: None 529*3446Smrj * 530*3446Smrj * DESCRIPTION: Set a breakpoint in a control method at the specified 531*3446Smrj * AML offset 532*3446Smrj * 533*3446Smrj ******************************************************************************/ 534*3446Smrj 535*3446Smrj void 536*3446Smrj AcpiDbSetMethodBreakpoint ( 537*3446Smrj char *Location, 538*3446Smrj ACPI_WALK_STATE *WalkState, 539*3446Smrj ACPI_PARSE_OBJECT *Op) 540*3446Smrj { 541*3446Smrj UINT32 Address; 542*3446Smrj 543*3446Smrj 544*3446Smrj if (!Op) 545*3446Smrj { 546*3446Smrj AcpiOsPrintf ("There is no method currently executing\n"); 547*3446Smrj return; 548*3446Smrj } 549*3446Smrj 550*3446Smrj /* Get and verify the breakpoint address */ 551*3446Smrj 552*3446Smrj Address = ACPI_STRTOUL (Location, NULL, 16); 553*3446Smrj if (Address <= Op->Common.AmlOffset) 554*3446Smrj { 555*3446Smrj AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", 556*3446Smrj Address, Op->Common.AmlOffset); 557*3446Smrj } 558*3446Smrj 559*3446Smrj /* Save breakpoint in current walk */ 560*3446Smrj 561*3446Smrj WalkState->UserBreakpoint = Address; 562*3446Smrj AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address); 563*3446Smrj } 564*3446Smrj 565*3446Smrj 566*3446Smrj /******************************************************************************* 567*3446Smrj * 568*3446Smrj * FUNCTION: AcpiDbSetMethodCallBreakpoint 569*3446Smrj * 570*3446Smrj * PARAMETERS: Op - Current Op (from parse walk) 571*3446Smrj * 572*3446Smrj * RETURN: None 573*3446Smrj * 574*3446Smrj * DESCRIPTION: Set a breakpoint in a control method at the specified 575*3446Smrj * AML offset 576*3446Smrj * 577*3446Smrj ******************************************************************************/ 578*3446Smrj 579*3446Smrj void 580*3446Smrj AcpiDbSetMethodCallBreakpoint ( 581*3446Smrj ACPI_PARSE_OBJECT *Op) 582*3446Smrj { 583*3446Smrj 584*3446Smrj 585*3446Smrj if (!Op) 586*3446Smrj { 587*3446Smrj AcpiOsPrintf ("There is no method currently executing\n"); 588*3446Smrj return; 589*3446Smrj } 590*3446Smrj 591*3446Smrj AcpiGbl_StepToNextCall = TRUE; 592*3446Smrj } 593*3446Smrj 594*3446Smrj 595*3446Smrj /******************************************************************************* 596*3446Smrj * 597*3446Smrj * FUNCTION: AcpiDbDisassembleAml 598*3446Smrj * 599*3446Smrj * PARAMETERS: Statements - Number of statements to disassemble 600*3446Smrj * Op - Current Op (from parse walk) 601*3446Smrj * 602*3446Smrj * RETURN: None 603*3446Smrj * 604*3446Smrj * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number 605*3446Smrj * of statements specified. 606*3446Smrj * 607*3446Smrj ******************************************************************************/ 608*3446Smrj 609*3446Smrj void 610*3446Smrj AcpiDbDisassembleAml ( 611*3446Smrj char *Statements, 612*3446Smrj ACPI_PARSE_OBJECT *Op) 613*3446Smrj { 614*3446Smrj UINT32 NumStatements = 8; 615*3446Smrj 616*3446Smrj 617*3446Smrj if (!Op) 618*3446Smrj { 619*3446Smrj AcpiOsPrintf ("There is no method currently executing\n"); 620*3446Smrj return; 621*3446Smrj } 622*3446Smrj 623*3446Smrj if (Statements) 624*3446Smrj { 625*3446Smrj NumStatements = ACPI_STRTOUL (Statements, NULL, 0); 626*3446Smrj } 627*3446Smrj 628*3446Smrj AcpiDmDisassemble (NULL, Op, NumStatements); 629*3446Smrj } 630*3446Smrj 631*3446Smrj 632*3446Smrj /******************************************************************************* 633*3446Smrj * 634*3446Smrj * FUNCTION: AcpiDbDisassembleMethod 635*3446Smrj * 636*3446Smrj * PARAMETERS: Name - Name of control method 637*3446Smrj * 638*3446Smrj * RETURN: None 639*3446Smrj * 640*3446Smrj * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number 641*3446Smrj * of statements specified. 642*3446Smrj * 643*3446Smrj ******************************************************************************/ 644*3446Smrj 645*3446Smrj ACPI_STATUS 646*3446Smrj AcpiDbDisassembleMethod ( 647*3446Smrj char *Name) 648*3446Smrj { 649*3446Smrj ACPI_STATUS Status; 650*3446Smrj ACPI_PARSE_OBJECT *Op; 651*3446Smrj ACPI_WALK_STATE *WalkState; 652*3446Smrj ACPI_OPERAND_OBJECT *ObjDesc; 653*3446Smrj ACPI_NAMESPACE_NODE *Method; 654*3446Smrj 655*3446Smrj 656*3446Smrj Method = AcpiDbConvertToNode (Name); 657*3446Smrj if (!Method) 658*3446Smrj { 659*3446Smrj return (AE_BAD_PARAMETER); 660*3446Smrj } 661*3446Smrj 662*3446Smrj ObjDesc = Method->Object; 663*3446Smrj 664*3446Smrj Op = AcpiPsCreateScopeOp (); 665*3446Smrj if (!Op) 666*3446Smrj { 667*3446Smrj return (AE_NO_MEMORY); 668*3446Smrj } 669*3446Smrj 670*3446Smrj /* Create and initialize a new walk state */ 671*3446Smrj 672*3446Smrj WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL); 673*3446Smrj if (!WalkState) 674*3446Smrj { 675*3446Smrj return (AE_NO_MEMORY); 676*3446Smrj } 677*3446Smrj 678*3446Smrj Status = AcpiDsInitAmlWalk (WalkState, Op, NULL, 679*3446Smrj ObjDesc->Method.AmlStart, 680*3446Smrj ObjDesc->Method.AmlLength, NULL, 1); 681*3446Smrj if (ACPI_FAILURE (Status)) 682*3446Smrj { 683*3446Smrj return (Status); 684*3446Smrj } 685*3446Smrj 686*3446Smrj /* Parse the AML */ 687*3446Smrj 688*3446Smrj WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE; 689*3446Smrj WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE; 690*3446Smrj Status = AcpiPsParseAml (WalkState); 691*3446Smrj 692*3446Smrj AcpiDmDisassemble (NULL, Op, 0); 693*3446Smrj AcpiPsDeleteParseTree (Op); 694*3446Smrj return (AE_OK); 695*3446Smrj } 696*3446Smrj 697*3446Smrj 698*3446Smrj /******************************************************************************* 699*3446Smrj * 700*3446Smrj * FUNCTION: AcpiDbDumpNamespace 701*3446Smrj * 702*3446Smrj * PARAMETERS: StartArg - Node to begin namespace dump 703*3446Smrj * DepthArg - Maximum tree depth to be dumped 704*3446Smrj * 705*3446Smrj * RETURN: None 706*3446Smrj * 707*3446Smrj * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed 708*3446Smrj * with type and other information. 709*3446Smrj * 710*3446Smrj ******************************************************************************/ 711*3446Smrj 712*3446Smrj void 713*3446Smrj AcpiDbDumpNamespace ( 714*3446Smrj char *StartArg, 715*3446Smrj char *DepthArg) 716*3446Smrj { 717*3446Smrj ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; 718*3446Smrj UINT32 MaxDepth = ACPI_UINT32_MAX; 719*3446Smrj 720*3446Smrj 721*3446Smrj /* No argument given, just start at the root and dump entire namespace */ 722*3446Smrj 723*3446Smrj if (StartArg) 724*3446Smrj { 725*3446Smrj SubtreeEntry = AcpiDbConvertToNode (StartArg); 726*3446Smrj if (!SubtreeEntry) 727*3446Smrj { 728*3446Smrj return; 729*3446Smrj } 730*3446Smrj 731*3446Smrj /* Now we can check for the depth argument */ 732*3446Smrj 733*3446Smrj if (DepthArg) 734*3446Smrj { 735*3446Smrj MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0); 736*3446Smrj } 737*3446Smrj } 738*3446Smrj 739*3446Smrj AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); 740*3446Smrj AcpiOsPrintf ("ACPI Namespace (from %4.4s (%p) subtree):\n", 741*3446Smrj ((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Name.Ascii, SubtreeEntry); 742*3446Smrj 743*3446Smrj /* Display the subtree */ 744*3446Smrj 745*3446Smrj AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 746*3446Smrj AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, 747*3446Smrj ACPI_OWNER_ID_MAX, SubtreeEntry); 748*3446Smrj AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 749*3446Smrj } 750*3446Smrj 751*3446Smrj 752*3446Smrj /******************************************************************************* 753*3446Smrj * 754*3446Smrj * FUNCTION: AcpiDbDumpNamespaceByOwner 755*3446Smrj * 756*3446Smrj * PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed 757*3446Smrj * DepthArg - Maximum tree depth to be dumped 758*3446Smrj * 759*3446Smrj * RETURN: None 760*3446Smrj * 761*3446Smrj * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId. 762*3446Smrj * 763*3446Smrj ******************************************************************************/ 764*3446Smrj 765*3446Smrj void 766*3446Smrj AcpiDbDumpNamespaceByOwner ( 767*3446Smrj char *OwnerArg, 768*3446Smrj char *DepthArg) 769*3446Smrj { 770*3446Smrj ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode; 771*3446Smrj UINT32 MaxDepth = ACPI_UINT32_MAX; 772*3446Smrj ACPI_OWNER_ID OwnerId; 773*3446Smrj 774*3446Smrj 775*3446Smrj OwnerId = (ACPI_OWNER_ID) ACPI_STRTOUL (OwnerArg, NULL, 0); 776*3446Smrj 777*3446Smrj /* Now we can check for the depth argument */ 778*3446Smrj 779*3446Smrj if (DepthArg) 780*3446Smrj { 781*3446Smrj MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0); 782*3446Smrj } 783*3446Smrj 784*3446Smrj AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); 785*3446Smrj AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId); 786*3446Smrj 787*3446Smrj /* Display the subtree */ 788*3446Smrj 789*3446Smrj AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 790*3446Smrj AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId, 791*3446Smrj SubtreeEntry); 792*3446Smrj AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 793*3446Smrj } 794*3446Smrj 795*3446Smrj 796*3446Smrj /******************************************************************************* 797*3446Smrj * 798*3446Smrj * FUNCTION: AcpiDbSendNotify 799*3446Smrj * 800*3446Smrj * PARAMETERS: Name - Name of ACPI object to send the notify to 801*3446Smrj * Value - Value of the notify to send. 802*3446Smrj * 803*3446Smrj * RETURN: None 804*3446Smrj * 805*3446Smrj * DESCRIPTION: Send an ACPI notification. The value specified is sent to the 806*3446Smrj * named object as an ACPI notify. 807*3446Smrj * 808*3446Smrj ******************************************************************************/ 809*3446Smrj 810*3446Smrj void 811*3446Smrj AcpiDbSendNotify ( 812*3446Smrj char *Name, 813*3446Smrj UINT32 Value) 814*3446Smrj { 815*3446Smrj ACPI_NAMESPACE_NODE *Node; 816*3446Smrj ACPI_STATUS Status; 817*3446Smrj 818*3446Smrj 819*3446Smrj /* Translate name to an Named object */ 820*3446Smrj 821*3446Smrj Node = AcpiDbConvertToNode (Name); 822*3446Smrj if (!Node) 823*3446Smrj { 824*3446Smrj return; 825*3446Smrj } 826*3446Smrj 827*3446Smrj /* Decode Named object type */ 828*3446Smrj 829*3446Smrj switch (Node->Type) 830*3446Smrj { 831*3446Smrj case ACPI_TYPE_DEVICE: 832*3446Smrj case ACPI_TYPE_THERMAL: 833*3446Smrj 834*3446Smrj /* Send the notify */ 835*3446Smrj 836*3446Smrj Status = AcpiEvQueueNotifyRequest (Node, Value); 837*3446Smrj if (ACPI_FAILURE (Status)) 838*3446Smrj { 839*3446Smrj AcpiOsPrintf ("Could not queue notify\n"); 840*3446Smrj } 841*3446Smrj break; 842*3446Smrj 843*3446Smrj default: 844*3446Smrj AcpiOsPrintf ("Named object is not a device or a thermal object\n"); 845*3446Smrj break; 846*3446Smrj } 847*3446Smrj } 848*3446Smrj 849*3446Smrj 850*3446Smrj /******************************************************************************* 851*3446Smrj * 852*3446Smrj * FUNCTION: AcpiDbSetMethodData 853*3446Smrj * 854*3446Smrj * PARAMETERS: TypeArg - L for local, A for argument 855*3446Smrj * IndexArg - which one 856*3446Smrj * ValueArg - Value to set. 857*3446Smrj * 858*3446Smrj * RETURN: None 859*3446Smrj * 860*3446Smrj * DESCRIPTION: Set a local or argument for the running control method. 861*3446Smrj * NOTE: only object supported is Number. 862*3446Smrj * 863*3446Smrj ******************************************************************************/ 864*3446Smrj 865*3446Smrj void 866*3446Smrj AcpiDbSetMethodData ( 867*3446Smrj char *TypeArg, 868*3446Smrj char *IndexArg, 869*3446Smrj char *ValueArg) 870*3446Smrj { 871*3446Smrj char Type; 872*3446Smrj UINT32 Index; 873*3446Smrj UINT32 Value; 874*3446Smrj ACPI_WALK_STATE *WalkState; 875*3446Smrj ACPI_OPERAND_OBJECT *ObjDesc; 876*3446Smrj ACPI_STATUS Status; 877*3446Smrj ACPI_NAMESPACE_NODE *Node; 878*3446Smrj 879*3446Smrj 880*3446Smrj /* Validate TypeArg */ 881*3446Smrj 882*3446Smrj AcpiUtStrupr (TypeArg); 883*3446Smrj Type = TypeArg[0]; 884*3446Smrj if ((Type != 'L') && 885*3446Smrj (Type != 'A') && 886*3446Smrj (Type != 'N')) 887*3446Smrj { 888*3446Smrj AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg); 889*3446Smrj return; 890*3446Smrj } 891*3446Smrj 892*3446Smrj Value = ACPI_STRTOUL (ValueArg, NULL, 16); 893*3446Smrj 894*3446Smrj if (Type == 'N') 895*3446Smrj { 896*3446Smrj Node = AcpiDbConvertToNode (IndexArg); 897*3446Smrj if (Node->Type != ACPI_TYPE_INTEGER) 898*3446Smrj { 899*3446Smrj AcpiOsPrintf ("Can only set Integer nodes\n"); 900*3446Smrj return; 901*3446Smrj } 902*3446Smrj ObjDesc = Node->Object; 903*3446Smrj ObjDesc->Integer.Value = Value; 904*3446Smrj return; 905*3446Smrj } 906*3446Smrj 907*3446Smrj /* Get the index and value */ 908*3446Smrj 909*3446Smrj Index = ACPI_STRTOUL (IndexArg, NULL, 16); 910*3446Smrj 911*3446Smrj WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList); 912*3446Smrj if (!WalkState) 913*3446Smrj { 914*3446Smrj AcpiOsPrintf ("There is no method currently executing\n"); 915*3446Smrj return; 916*3446Smrj } 917*3446Smrj 918*3446Smrj /* Create and initialize the new object */ 919*3446Smrj 920*3446Smrj ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); 921*3446Smrj if (!ObjDesc) 922*3446Smrj { 923*3446Smrj AcpiOsPrintf ("Could not create an internal object\n"); 924*3446Smrj return; 925*3446Smrj } 926*3446Smrj 927*3446Smrj ObjDesc->Integer.Value = Value; 928*3446Smrj 929*3446Smrj /* Store the new object into the target */ 930*3446Smrj 931*3446Smrj switch (Type) 932*3446Smrj { 933*3446Smrj case 'A': 934*3446Smrj 935*3446Smrj /* Set a method argument */ 936*3446Smrj 937*3446Smrj if (Index > ACPI_METHOD_MAX_ARG) 938*3446Smrj { 939*3446Smrj AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index); 940*3446Smrj goto Cleanup; 941*3446Smrj } 942*3446Smrj 943*3446Smrj Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, ObjDesc, 944*3446Smrj WalkState); 945*3446Smrj if (ACPI_FAILURE (Status)) 946*3446Smrj { 947*3446Smrj goto Cleanup; 948*3446Smrj } 949*3446Smrj 950*3446Smrj ObjDesc = WalkState->Arguments[Index].Object; 951*3446Smrj 952*3446Smrj AcpiOsPrintf ("Arg%d: ", Index); 953*3446Smrj AcpiDmDisplayInternalObject (ObjDesc, WalkState); 954*3446Smrj break; 955*3446Smrj 956*3446Smrj case 'L': 957*3446Smrj 958*3446Smrj /* Set a method local */ 959*3446Smrj 960*3446Smrj if (Index > ACPI_METHOD_MAX_LOCAL) 961*3446Smrj { 962*3446Smrj AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index); 963*3446Smrj goto Cleanup; 964*3446Smrj } 965*3446Smrj 966*3446Smrj Status = AcpiDsStoreObjectToLocal (AML_LOCAL_OP, Index, ObjDesc, 967*3446Smrj WalkState); 968*3446Smrj if (ACPI_FAILURE (Status)) 969*3446Smrj { 970*3446Smrj goto Cleanup; 971*3446Smrj } 972*3446Smrj 973*3446Smrj ObjDesc = WalkState->LocalVariables[Index].Object; 974*3446Smrj 975*3446Smrj AcpiOsPrintf ("Local%d: ", Index); 976*3446Smrj AcpiDmDisplayInternalObject (ObjDesc, WalkState); 977*3446Smrj break; 978*3446Smrj 979*3446Smrj default: 980*3446Smrj break; 981*3446Smrj } 982*3446Smrj 983*3446Smrj Cleanup: 984*3446Smrj AcpiUtRemoveReference (ObjDesc); 985*3446Smrj } 986*3446Smrj 987*3446Smrj 988*3446Smrj /******************************************************************************* 989*3446Smrj * 990*3446Smrj * FUNCTION: AcpiDbWalkForSpecificObjects 991*3446Smrj * 992*3446Smrj * PARAMETERS: Callback from WalkNamespace 993*3446Smrj * 994*3446Smrj * RETURN: Status 995*3446Smrj * 996*3446Smrj * DESCRIPTION: Display short info about objects in the namespace 997*3446Smrj * 998*3446Smrj ******************************************************************************/ 999*3446Smrj 1000*3446Smrj static ACPI_STATUS 1001*3446Smrj AcpiDbWalkForSpecificObjects ( 1002*3446Smrj ACPI_HANDLE ObjHandle, 1003*3446Smrj UINT32 NestingLevel, 1004*3446Smrj void *Context, 1005*3446Smrj void **ReturnValue) 1006*3446Smrj { 1007*3446Smrj ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context; 1008*3446Smrj ACPI_BUFFER Buffer; 1009*3446Smrj ACPI_STATUS Status; 1010*3446Smrj 1011*3446Smrj 1012*3446Smrj Info->Count++; 1013*3446Smrj 1014*3446Smrj /* Get and display the full pathname to this object */ 1015*3446Smrj 1016*3446Smrj Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 1017*3446Smrj Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); 1018*3446Smrj if (ACPI_FAILURE (Status)) 1019*3446Smrj { 1020*3446Smrj AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); 1021*3446Smrj return (AE_OK); 1022*3446Smrj } 1023*3446Smrj 1024*3446Smrj AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); 1025*3446Smrj ACPI_FREE (Buffer.Pointer); 1026*3446Smrj 1027*3446Smrj /* Dump short info about the object */ 1028*3446Smrj 1029*3446Smrj (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL); 1030*3446Smrj return (AE_OK); 1031*3446Smrj } 1032*3446Smrj 1033*3446Smrj 1034*3446Smrj /******************************************************************************* 1035*3446Smrj * 1036*3446Smrj * FUNCTION: AcpiDbDisplayObjects 1037*3446Smrj * 1038*3446Smrj * PARAMETERS: ObjTypeArg - Type of object to display 1039*3446Smrj * DisplayCountArg - Max depth to display 1040*3446Smrj * 1041*3446Smrj * RETURN: None 1042*3446Smrj * 1043*3446Smrj * DESCRIPTION: Display objects in the namespace of the requested type 1044*3446Smrj * 1045*3446Smrj ******************************************************************************/ 1046*3446Smrj 1047*3446Smrj ACPI_STATUS 1048*3446Smrj AcpiDbDisplayObjects ( 1049*3446Smrj char *ObjTypeArg, 1050*3446Smrj char *DisplayCountArg) 1051*3446Smrj { 1052*3446Smrj ACPI_WALK_INFO Info; 1053*3446Smrj ACPI_OBJECT_TYPE Type; 1054*3446Smrj 1055*3446Smrj 1056*3446Smrj /* Get the object type */ 1057*3446Smrj 1058*3446Smrj Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes); 1059*3446Smrj if (Type == ACPI_TYPE_NOT_FOUND) 1060*3446Smrj { 1061*3446Smrj AcpiOsPrintf ("Invalid or unsupported argument\n"); 1062*3446Smrj return (AE_OK); 1063*3446Smrj } 1064*3446Smrj 1065*3446Smrj AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT); 1066*3446Smrj AcpiOsPrintf ( 1067*3446Smrj "Objects of type [%s] defined in the current ACPI Namespace:\n", 1068*3446Smrj AcpiUtGetTypeName (Type)); 1069*3446Smrj 1070*3446Smrj AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 1071*3446Smrj 1072*3446Smrj Info.Count = 0; 1073*3446Smrj Info.OwnerId = ACPI_OWNER_ID_MAX; 1074*3446Smrj Info.DebugLevel = ACPI_UINT32_MAX; 1075*3446Smrj Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT; 1076*3446Smrj 1077*3446Smrj /* Walk the namespace from the root */ 1078*3446Smrj 1079*3446Smrj (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 1080*3446Smrj AcpiDbWalkForSpecificObjects, (void *) &Info, NULL); 1081*3446Smrj 1082*3446Smrj AcpiOsPrintf ( 1083*3446Smrj "\nFound %u objects of type [%s] in the current ACPI Namespace\n", 1084*3446Smrj Info.Count, AcpiUtGetTypeName (Type)); 1085*3446Smrj 1086*3446Smrj AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 1087*3446Smrj return (AE_OK); 1088*3446Smrj } 1089*3446Smrj 1090*3446Smrj 1091*3446Smrj /******************************************************************************* 1092*3446Smrj * 1093*3446Smrj * FUNCTION: AcpiDbWalkAndMatchName 1094*3446Smrj * 1095*3446Smrj * PARAMETERS: Callback from WalkNamespace 1096*3446Smrj * 1097*3446Smrj * RETURN: Status 1098*3446Smrj * 1099*3446Smrj * DESCRIPTION: Find a particular name/names within the namespace. Wildcards 1100*3446Smrj * are supported -- '?' matches any character. 1101*3446Smrj * 1102*3446Smrj ******************************************************************************/ 1103*3446Smrj 1104*3446Smrj static ACPI_STATUS 1105*3446Smrj AcpiDbWalkAndMatchName ( 1106*3446Smrj ACPI_HANDLE ObjHandle, 1107*3446Smrj UINT32 NestingLevel, 1108*3446Smrj void *Context, 1109*3446Smrj void **ReturnValue) 1110*3446Smrj { 1111*3446Smrj ACPI_STATUS Status; 1112*3446Smrj char *RequestedName = (char *) Context; 1113*3446Smrj UINT32 i; 1114*3446Smrj ACPI_BUFFER Buffer; 1115*3446Smrj ACPI_WALK_INFO Info; 1116*3446Smrj 1117*3446Smrj 1118*3446Smrj /* Check for a name match */ 1119*3446Smrj 1120*3446Smrj for (i = 0; i < 4; i++) 1121*3446Smrj { 1122*3446Smrj /* Wildcard support */ 1123*3446Smrj 1124*3446Smrj if ((RequestedName[i] != '?') && 1125*3446Smrj (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i])) 1126*3446Smrj { 1127*3446Smrj /* No match, just exit */ 1128*3446Smrj 1129*3446Smrj return (AE_OK); 1130*3446Smrj } 1131*3446Smrj } 1132*3446Smrj 1133*3446Smrj /* Get the full pathname to this object */ 1134*3446Smrj 1135*3446Smrj Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 1136*3446Smrj Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); 1137*3446Smrj if (ACPI_FAILURE (Status)) 1138*3446Smrj { 1139*3446Smrj AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); 1140*3446Smrj } 1141*3446Smrj else 1142*3446Smrj { 1143*3446Smrj Info.OwnerId = ACPI_OWNER_ID_MAX; 1144*3446Smrj Info.DebugLevel = ACPI_UINT32_MAX; 1145*3446Smrj Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT; 1146*3446Smrj 1147*3446Smrj AcpiOsPrintf ("%32s", (char *) Buffer.Pointer); 1148*3446Smrj (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL); 1149*3446Smrj ACPI_FREE (Buffer.Pointer); 1150*3446Smrj } 1151*3446Smrj 1152*3446Smrj return (AE_OK); 1153*3446Smrj } 1154*3446Smrj 1155*3446Smrj 1156*3446Smrj /******************************************************************************* 1157*3446Smrj * 1158*3446Smrj * FUNCTION: AcpiDbFindNameInNamespace 1159*3446Smrj * 1160*3446Smrj * PARAMETERS: NameArg - The 4-character ACPI name to find. 1161*3446Smrj * wildcards are supported. 1162*3446Smrj * 1163*3446Smrj * RETURN: None 1164*3446Smrj * 1165*3446Smrj * DESCRIPTION: Search the namespace for a given name (with wildcards) 1166*3446Smrj * 1167*3446Smrj ******************************************************************************/ 1168*3446Smrj 1169*3446Smrj ACPI_STATUS 1170*3446Smrj AcpiDbFindNameInNamespace ( 1171*3446Smrj char *NameArg) 1172*3446Smrj { 1173*3446Smrj 1174*3446Smrj if (ACPI_STRLEN (NameArg) > 4) 1175*3446Smrj { 1176*3446Smrj AcpiOsPrintf ("Name must be no longer than 4 characters\n"); 1177*3446Smrj return (AE_OK); 1178*3446Smrj } 1179*3446Smrj 1180*3446Smrj /* Walk the namespace from the root */ 1181*3446Smrj 1182*3446Smrj AcpiUtStrupr (NameArg); 1183*3446Smrj (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 1184*3446Smrj AcpiDbWalkAndMatchName, NameArg, NULL); 1185*3446Smrj 1186*3446Smrj AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 1187*3446Smrj return (AE_OK); 1188*3446Smrj } 1189*3446Smrj 1190*3446Smrj 1191*3446Smrj /******************************************************************************* 1192*3446Smrj * 1193*3446Smrj * FUNCTION: AcpiDbSetScope 1194*3446Smrj * 1195*3446Smrj * PARAMETERS: Name - New scope path 1196*3446Smrj * 1197*3446Smrj * RETURN: Status 1198*3446Smrj * 1199*3446Smrj * DESCRIPTION: Set the "current scope" as maintained by this utility. 1200*3446Smrj * The scope is used as a prefix to ACPI paths. 1201*3446Smrj * 1202*3446Smrj ******************************************************************************/ 1203*3446Smrj 1204*3446Smrj void 1205*3446Smrj AcpiDbSetScope ( 1206*3446Smrj char *Name) 1207*3446Smrj { 1208*3446Smrj ACPI_STATUS Status; 1209*3446Smrj ACPI_NAMESPACE_NODE *Node; 1210*3446Smrj 1211*3446Smrj 1212*3446Smrj if (!Name || Name[0] == 0) 1213*3446Smrj { 1214*3446Smrj AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf); 1215*3446Smrj return; 1216*3446Smrj } 1217*3446Smrj 1218*3446Smrj AcpiDbPrepNamestring (Name); 1219*3446Smrj 1220*3446Smrj if (Name[0] == '\\') 1221*3446Smrj { 1222*3446Smrj /* Validate new scope from the root */ 1223*3446Smrj 1224*3446Smrj Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, ACPI_NS_NO_UPSEARCH, 1225*3446Smrj &Node); 1226*3446Smrj if (ACPI_FAILURE (Status)) 1227*3446Smrj { 1228*3446Smrj goto ErrorExit; 1229*3446Smrj } 1230*3446Smrj 1231*3446Smrj ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name); 1232*3446Smrj ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\"); 1233*3446Smrj } 1234*3446Smrj else 1235*3446Smrj { 1236*3446Smrj /* Validate new scope relative to old scope */ 1237*3446Smrj 1238*3446Smrj Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, ACPI_NS_NO_UPSEARCH, 1239*3446Smrj &Node); 1240*3446Smrj if (ACPI_FAILURE (Status)) 1241*3446Smrj { 1242*3446Smrj goto ErrorExit; 1243*3446Smrj } 1244*3446Smrj 1245*3446Smrj ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name); 1246*3446Smrj ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\"); 1247*3446Smrj } 1248*3446Smrj 1249*3446Smrj AcpiGbl_DbScopeNode = Node; 1250*3446Smrj AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf); 1251*3446Smrj return; 1252*3446Smrj 1253*3446Smrj ErrorExit: 1254*3446Smrj 1255*3446Smrj AcpiOsPrintf ("Could not attach scope: %s, %s\n", 1256*3446Smrj Name, AcpiFormatException (Status)); 1257*3446Smrj } 1258*3446Smrj 1259*3446Smrj 1260*3446Smrj /******************************************************************************* 1261*3446Smrj * 1262*3446Smrj * FUNCTION: AcpiDmCompareAmlResources 1263*3446Smrj * 1264*3446Smrj * PARAMETERS: Aml1Buffer - Contains first resource list 1265*3446Smrj * Aml1BufferLength - Length of first resource list 1266*3446Smrj * Aml2Buffer - Contains second resource list 1267*3446Smrj * Aml2BufferLength - Length of second resource list 1268*3446Smrj * 1269*3446Smrj * RETURN: None 1270*3446Smrj * 1271*3446Smrj * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in 1272*3446Smrj * order to isolate a miscompare to an individual resource) 1273*3446Smrj * 1274*3446Smrj ******************************************************************************/ 1275*3446Smrj 1276*3446Smrj static void 1277*3446Smrj AcpiDmCompareAmlResources ( 1278*3446Smrj UINT8 *Aml1Buffer, 1279*3446Smrj ACPI_RSDESC_SIZE Aml1BufferLength, 1280*3446Smrj UINT8 *Aml2Buffer, 1281*3446Smrj ACPI_RSDESC_SIZE Aml2BufferLength) 1282*3446Smrj { 1283*3446Smrj UINT8 *Aml1; 1284*3446Smrj UINT8 *Aml2; 1285*3446Smrj ACPI_RSDESC_SIZE Aml1Length; 1286*3446Smrj ACPI_RSDESC_SIZE Aml2Length; 1287*3446Smrj ACPI_RSDESC_SIZE Offset = 0; 1288*3446Smrj UINT8 ResourceType; 1289*3446Smrj UINT32 Count = 0; 1290*3446Smrj 1291*3446Smrj 1292*3446Smrj /* Compare overall buffer sizes (may be different due to size rounding) */ 1293*3446Smrj 1294*3446Smrj if (Aml1BufferLength != Aml2BufferLength) 1295*3446Smrj { 1296*3446Smrj AcpiOsPrintf ( 1297*3446Smrj "**** Buffer length mismatch in converted AML: original %X new %X ****\n", 1298*3446Smrj Aml1BufferLength, Aml2BufferLength); 1299*3446Smrj } 1300*3446Smrj 1301*3446Smrj Aml1 = Aml1Buffer; 1302*3446Smrj Aml2 = Aml2Buffer; 1303*3446Smrj 1304*3446Smrj /* Walk the descriptor lists, comparing each descriptor */ 1305*3446Smrj 1306*3446Smrj while (Aml1 < (Aml1Buffer + Aml1BufferLength)) 1307*3446Smrj { 1308*3446Smrj /* Get the lengths of each descriptor */ 1309*3446Smrj 1310*3446Smrj Aml1Length = AcpiUtGetDescriptorLength (Aml1); 1311*3446Smrj Aml2Length = AcpiUtGetDescriptorLength (Aml2); 1312*3446Smrj ResourceType = AcpiUtGetResourceType (Aml1); 1313*3446Smrj 1314*3446Smrj /* Check for descriptor length match */ 1315*3446Smrj 1316*3446Smrj if (Aml1Length != Aml2Length) 1317*3446Smrj { 1318*3446Smrj AcpiOsPrintf ( 1319*3446Smrj "**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X L1 %X L2 %X ****\n", 1320*3446Smrj Count, ResourceType, Offset, Aml1Length, Aml2Length); 1321*3446Smrj } 1322*3446Smrj 1323*3446Smrj /* Check for descriptor byte match */ 1324*3446Smrj 1325*3446Smrj else if (ACPI_MEMCMP (Aml1, Aml2, Aml1Length)) 1326*3446Smrj { 1327*3446Smrj AcpiOsPrintf ( 1328*3446Smrj "**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n", 1329*3446Smrj Count, ResourceType, Offset); 1330*3446Smrj } 1331*3446Smrj 1332*3446Smrj /* Exit on EndTag descriptor */ 1333*3446Smrj 1334*3446Smrj if (ResourceType == ACPI_RESOURCE_NAME_END_TAG) 1335*3446Smrj { 1336*3446Smrj return; 1337*3446Smrj } 1338*3446Smrj 1339*3446Smrj /* Point to next descriptor in each buffer */ 1340*3446Smrj 1341*3446Smrj Count++; 1342*3446Smrj Offset += Aml1Length; 1343*3446Smrj Aml1 += Aml1Length; 1344*3446Smrj Aml2 += Aml2Length; 1345*3446Smrj } 1346*3446Smrj } 1347*3446Smrj 1348*3446Smrj 1349*3446Smrj /******************************************************************************* 1350*3446Smrj * 1351*3446Smrj * FUNCTION: AcpiDmTestResourceConversion 1352*3446Smrj * 1353*3446Smrj * PARAMETERS: Node - Parent device node 1354*3446Smrj * Name - resource method name (_CRS) 1355*3446Smrj * 1356*3446Smrj * RETURN: Status 1357*3446Smrj * 1358*3446Smrj * DESCRIPTION: Compare the original AML with a conversion of the AML to 1359*3446Smrj * internal resource list, then back to AML. 1360*3446Smrj * 1361*3446Smrj ******************************************************************************/ 1362*3446Smrj 1363*3446Smrj static ACPI_STATUS 1364*3446Smrj AcpiDmTestResourceConversion ( 1365*3446Smrj ACPI_NAMESPACE_NODE *Node, 1366*3446Smrj char *Name) 1367*3446Smrj { 1368*3446Smrj ACPI_STATUS Status; 1369*3446Smrj ACPI_BUFFER ReturnObj; 1370*3446Smrj ACPI_BUFFER ResourceObj; 1371*3446Smrj ACPI_BUFFER NewAml; 1372*3446Smrj ACPI_OBJECT *OriginalAml; 1373*3446Smrj 1374*3446Smrj 1375*3446Smrj AcpiOsPrintf ("Resource Conversion Comparison:\n"); 1376*3446Smrj 1377*3446Smrj NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 1378*3446Smrj ReturnObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 1379*3446Smrj ResourceObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 1380*3446Smrj 1381*3446Smrj /* Get the original _CRS AML resource template */ 1382*3446Smrj 1383*3446Smrj Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnObj); 1384*3446Smrj if (ACPI_FAILURE (Status)) 1385*3446Smrj { 1386*3446Smrj AcpiOsPrintf ("Could not obtain %s: %s\n", 1387*3446Smrj Name, AcpiFormatException (Status)); 1388*3446Smrj return (Status); 1389*3446Smrj } 1390*3446Smrj 1391*3446Smrj /* Get the AML resource template, converted to internal resource structs */ 1392*3446Smrj 1393*3446Smrj Status = AcpiGetCurrentResources (Node, &ResourceObj); 1394*3446Smrj if (ACPI_FAILURE (Status)) 1395*3446Smrj { 1396*3446Smrj AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", 1397*3446Smrj AcpiFormatException (Status)); 1398*3446Smrj goto Exit1; 1399*3446Smrj } 1400*3446Smrj 1401*3446Smrj /* Convert internal resource list to external AML resource template */ 1402*3446Smrj 1403*3446Smrj Status = AcpiRsCreateAmlResources (ResourceObj.Pointer, &NewAml); 1404*3446Smrj if (ACPI_FAILURE (Status)) 1405*3446Smrj { 1406*3446Smrj AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n", 1407*3446Smrj AcpiFormatException (Status)); 1408*3446Smrj goto Exit2; 1409*3446Smrj } 1410*3446Smrj 1411*3446Smrj /* Compare original AML to the newly created AML resource list */ 1412*3446Smrj 1413*3446Smrj OriginalAml = ReturnObj.Pointer; 1414*3446Smrj 1415*3446Smrj AcpiDmCompareAmlResources ( 1416*3446Smrj OriginalAml->Buffer.Pointer, OriginalAml->Buffer.Length, 1417*3446Smrj NewAml.Pointer, NewAml.Length); 1418*3446Smrj 1419*3446Smrj /* Cleanup and exit */ 1420*3446Smrj 1421*3446Smrj ACPI_FREE (NewAml.Pointer); 1422*3446Smrj Exit2: 1423*3446Smrj ACPI_FREE (ResourceObj.Pointer); 1424*3446Smrj Exit1: 1425*3446Smrj ACPI_FREE (ReturnObj.Pointer); 1426*3446Smrj return (Status); 1427*3446Smrj } 1428*3446Smrj 1429*3446Smrj 1430*3446Smrj /******************************************************************************* 1431*3446Smrj * 1432*3446Smrj * FUNCTION: AcpiDbDisplayResources 1433*3446Smrj * 1434*3446Smrj * PARAMETERS: ObjectArg - String with hex value of the object 1435*3446Smrj * 1436*3446Smrj * RETURN: None 1437*3446Smrj * 1438*3446Smrj * DESCRIPTION: Display the resource objects associated with a device. 1439*3446Smrj * 1440*3446Smrj ******************************************************************************/ 1441*3446Smrj 1442*3446Smrj void 1443*3446Smrj AcpiDbDisplayResources ( 1444*3446Smrj char *ObjectArg) 1445*3446Smrj { 1446*3446Smrj #if ACPI_MACHINE_WIDTH != 16 1447*3446Smrj 1448*3446Smrj ACPI_NAMESPACE_NODE *Node; 1449*3446Smrj ACPI_STATUS Status; 1450*3446Smrj ACPI_BUFFER ReturnObj; 1451*3446Smrj 1452*3446Smrj 1453*3446Smrj AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT); 1454*3446Smrj AcpiDbgLevel |= ACPI_LV_RESOURCES; 1455*3446Smrj 1456*3446Smrj /* Convert string to object pointer */ 1457*3446Smrj 1458*3446Smrj Node = AcpiDbConvertToNode (ObjectArg); 1459*3446Smrj if (!Node) 1460*3446Smrj { 1461*3446Smrj return; 1462*3446Smrj } 1463*3446Smrj 1464*3446Smrj /* Prepare for a return object of arbitrary size */ 1465*3446Smrj 1466*3446Smrj ReturnObj.Pointer = AcpiGbl_DbBuffer; 1467*3446Smrj ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 1468*3446Smrj 1469*3446Smrj /* _PRT */ 1470*3446Smrj 1471*3446Smrj AcpiOsPrintf ("Evaluating _PRT\n"); 1472*3446Smrj 1473*3446Smrj /* Check if _PRT exists */ 1474*3446Smrj 1475*3446Smrj Status = AcpiEvaluateObject (Node, METHOD_NAME__PRT, NULL, &ReturnObj); 1476*3446Smrj if (ACPI_FAILURE (Status)) 1477*3446Smrj { 1478*3446Smrj AcpiOsPrintf ("Could not obtain _PRT: %s\n", 1479*3446Smrj AcpiFormatException (Status)); 1480*3446Smrj goto GetCrs; 1481*3446Smrj } 1482*3446Smrj 1483*3446Smrj ReturnObj.Pointer = AcpiGbl_DbBuffer; 1484*3446Smrj ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 1485*3446Smrj 1486*3446Smrj Status = AcpiGetIrqRoutingTable (Node, &ReturnObj); 1487*3446Smrj if (ACPI_FAILURE (Status)) 1488*3446Smrj { 1489*3446Smrj AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", 1490*3446Smrj AcpiFormatException (Status)); 1491*3446Smrj goto GetCrs; 1492*3446Smrj } 1493*3446Smrj 1494*3446Smrj AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer)); 1495*3446Smrj 1496*3446Smrj 1497*3446Smrj /* _CRS */ 1498*3446Smrj 1499*3446Smrj GetCrs: 1500*3446Smrj AcpiOsPrintf ("Evaluating _CRS\n"); 1501*3446Smrj 1502*3446Smrj ReturnObj.Pointer = AcpiGbl_DbBuffer; 1503*3446Smrj ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 1504*3446Smrj 1505*3446Smrj /* Check if _CRS exists */ 1506*3446Smrj 1507*3446Smrj Status = AcpiEvaluateObject (Node, METHOD_NAME__CRS, NULL, &ReturnObj); 1508*3446Smrj if (ACPI_FAILURE (Status)) 1509*3446Smrj { 1510*3446Smrj AcpiOsPrintf ("Could not obtain _CRS: %s\n", 1511*3446Smrj AcpiFormatException (Status)); 1512*3446Smrj goto GetPrs; 1513*3446Smrj } 1514*3446Smrj 1515*3446Smrj /* Get the _CRS resource list */ 1516*3446Smrj 1517*3446Smrj ReturnObj.Pointer = AcpiGbl_DbBuffer; 1518*3446Smrj ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 1519*3446Smrj 1520*3446Smrj Status = AcpiGetCurrentResources (Node, &ReturnObj); 1521*3446Smrj if (ACPI_FAILURE (Status)) 1522*3446Smrj { 1523*3446Smrj AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", 1524*3446Smrj AcpiFormatException (Status)); 1525*3446Smrj goto GetPrs; 1526*3446Smrj } 1527*3446Smrj 1528*3446Smrj /* Dump the _CRS resource list */ 1529*3446Smrj 1530*3446Smrj AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, 1531*3446Smrj ReturnObj.Pointer)); 1532*3446Smrj 1533*3446Smrj /* 1534*3446Smrj * Perform comparison of original AML to newly created AML. This tests both 1535*3446Smrj * the AML->Resource conversion and the Resource->Aml conversion. 1536*3446Smrj */ 1537*3446Smrj Status = AcpiDmTestResourceConversion (Node, METHOD_NAME__CRS); 1538*3446Smrj 1539*3446Smrj /* Execute _SRS with the resource list */ 1540*3446Smrj 1541*3446Smrj Status = AcpiSetCurrentResources (Node, &ReturnObj); 1542*3446Smrj if (ACPI_FAILURE (Status)) 1543*3446Smrj { 1544*3446Smrj AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", 1545*3446Smrj AcpiFormatException (Status)); 1546*3446Smrj goto GetPrs; 1547*3446Smrj } 1548*3446Smrj 1549*3446Smrj 1550*3446Smrj /* _PRS */ 1551*3446Smrj 1552*3446Smrj GetPrs: 1553*3446Smrj AcpiOsPrintf ("Evaluating _PRS\n"); 1554*3446Smrj 1555*3446Smrj ReturnObj.Pointer = AcpiGbl_DbBuffer; 1556*3446Smrj ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 1557*3446Smrj 1558*3446Smrj /* Check if _PRS exists */ 1559*3446Smrj 1560*3446Smrj Status = AcpiEvaluateObject (Node, METHOD_NAME__PRS, NULL, &ReturnObj); 1561*3446Smrj if (ACPI_FAILURE (Status)) 1562*3446Smrj { 1563*3446Smrj AcpiOsPrintf ("Could not obtain _PRS: %s\n", 1564*3446Smrj AcpiFormatException (Status)); 1565*3446Smrj goto Cleanup; 1566*3446Smrj } 1567*3446Smrj 1568*3446Smrj ReturnObj.Pointer = AcpiGbl_DbBuffer; 1569*3446Smrj ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE; 1570*3446Smrj 1571*3446Smrj Status = AcpiGetPossibleResources (Node, &ReturnObj); 1572*3446Smrj if (ACPI_FAILURE (Status)) 1573*3446Smrj { 1574*3446Smrj AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", 1575*3446Smrj AcpiFormatException (Status)); 1576*3446Smrj goto Cleanup; 1577*3446Smrj } 1578*3446Smrj 1579*3446Smrj AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer)); 1580*3446Smrj 1581*3446Smrj Cleanup: 1582*3446Smrj 1583*3446Smrj AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT); 1584*3446Smrj return; 1585*3446Smrj #endif 1586*3446Smrj } 1587*3446Smrj 1588*3446Smrj 1589*3446Smrj /******************************************************************************* 1590*3446Smrj * 1591*3446Smrj * FUNCTION: AcpiDbIntegrityWalk 1592*3446Smrj * 1593*3446Smrj * PARAMETERS: Callback from WalkNamespace 1594*3446Smrj * 1595*3446Smrj * RETURN: Status 1596*3446Smrj * 1597*3446Smrj * DESCRIPTION: Examine one NS node for valid values. 1598*3446Smrj * 1599*3446Smrj ******************************************************************************/ 1600*3446Smrj 1601*3446Smrj static ACPI_STATUS 1602*3446Smrj AcpiDbIntegrityWalk ( 1603*3446Smrj ACPI_HANDLE ObjHandle, 1604*3446Smrj UINT32 NestingLevel, 1605*3446Smrj void *Context, 1606*3446Smrj void **ReturnValue) 1607*3446Smrj { 1608*3446Smrj ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context; 1609*3446Smrj ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 1610*3446Smrj ACPI_OPERAND_OBJECT *Object; 1611*3446Smrj 1612*3446Smrj 1613*3446Smrj Info->Nodes++; 1614*3446Smrj if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) 1615*3446Smrj { 1616*3446Smrj AcpiOsPrintf ("Invalid Descriptor Type for Node %p [%s]\n", 1617*3446Smrj Node, AcpiUtGetDescriptorName (Node)); 1618*3446Smrj } 1619*3446Smrj 1620*3446Smrj if (Node->Type > ACPI_TYPE_LOCAL_MAX) 1621*3446Smrj { 1622*3446Smrj AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n", 1623*3446Smrj Node, Node->Type); 1624*3446Smrj } 1625*3446Smrj 1626*3446Smrj if (!AcpiUtValidAcpiName (Node->Name.Integer)) 1627*3446Smrj { 1628*3446Smrj AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node); 1629*3446Smrj } 1630*3446Smrj 1631*3446Smrj Object = AcpiNsGetAttachedObject (Node); 1632*3446Smrj if (Object) 1633*3446Smrj { 1634*3446Smrj Info->Objects++; 1635*3446Smrj if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND) 1636*3446Smrj { 1637*3446Smrj AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n", 1638*3446Smrj Object, AcpiUtGetDescriptorName (Object)); 1639*3446Smrj } 1640*3446Smrj } 1641*3446Smrj 1642*3446Smrj return (AE_OK); 1643*3446Smrj } 1644*3446Smrj 1645*3446Smrj 1646*3446Smrj /******************************************************************************* 1647*3446Smrj * 1648*3446Smrj * FUNCTION: AcpiDbCheckIntegrity 1649*3446Smrj * 1650*3446Smrj * PARAMETERS: None 1651*3446Smrj * 1652*3446Smrj * RETURN: None 1653*3446Smrj * 1654*3446Smrj * DESCRIPTION: Check entire namespace for data structure integrity 1655*3446Smrj * 1656*3446Smrj ******************************************************************************/ 1657*3446Smrj 1658*3446Smrj void 1659*3446Smrj AcpiDbCheckIntegrity ( 1660*3446Smrj void) 1661*3446Smrj { 1662*3446Smrj ACPI_INTEGRITY_INFO Info = {0,0}; 1663*3446Smrj 1664*3446Smrj /* Search all nodes in namespace */ 1665*3446Smrj 1666*3446Smrj (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 1667*3446Smrj AcpiDbIntegrityWalk, (void *) &Info, NULL); 1668*3446Smrj 1669*3446Smrj AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n", 1670*3446Smrj Info.Nodes, Info.Objects); 1671*3446Smrj } 1672*3446Smrj 1673*3446Smrj 1674*3446Smrj /******************************************************************************* 1675*3446Smrj * 1676*3446Smrj * FUNCTION: AcpiDbGenerateGpe 1677*3446Smrj * 1678*3446Smrj * PARAMETERS: GpeArg - Raw GPE number, ascii string 1679*3446Smrj * BlockArg - GPE block number, ascii string 1680*3446Smrj * 0 or 1 for FADT GPE blocks 1681*3446Smrj * 1682*3446Smrj * RETURN: None 1683*3446Smrj * 1684*3446Smrj * DESCRIPTION: Generate a GPE 1685*3446Smrj * 1686*3446Smrj ******************************************************************************/ 1687*3446Smrj 1688*3446Smrj void 1689*3446Smrj AcpiDbGenerateGpe ( 1690*3446Smrj char *GpeArg, 1691*3446Smrj char *BlockArg) 1692*3446Smrj { 1693*3446Smrj UINT32 BlockNumber; 1694*3446Smrj UINT32 GpeNumber; 1695*3446Smrj ACPI_GPE_EVENT_INFO *GpeEventInfo; 1696*3446Smrj 1697*3446Smrj 1698*3446Smrj GpeNumber = ACPI_STRTOUL (GpeArg, NULL, 0); 1699*3446Smrj BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0); 1700*3446Smrj 1701*3446Smrj 1702*3446Smrj GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber), 1703*3446Smrj GpeNumber); 1704*3446Smrj if (!GpeEventInfo) 1705*3446Smrj { 1706*3446Smrj AcpiOsPrintf ("Invalid GPE\n"); 1707*3446Smrj return; 1708*3446Smrj } 1709*3446Smrj 1710*3446Smrj (void) AcpiEvGpeDispatch (GpeEventInfo, GpeNumber); 1711*3446Smrj } 1712*3446Smrj 1713*3446Smrj 1714*3446Smrj /******************************************************************************* 1715*3446Smrj * 1716*3446Smrj * FUNCTION: AcpiDbBusWalk 1717*3446Smrj * 1718*3446Smrj * PARAMETERS: Callback from WalkNamespace 1719*3446Smrj * 1720*3446Smrj * RETURN: Status 1721*3446Smrj * 1722*3446Smrj * DESCRIPTION: Display info about device objects that have a corresponding 1723*3446Smrj * _PRT method. 1724*3446Smrj * 1725*3446Smrj ******************************************************************************/ 1726*3446Smrj 1727*3446Smrj static ACPI_STATUS 1728*3446Smrj AcpiDbBusWalk ( 1729*3446Smrj ACPI_HANDLE ObjHandle, 1730*3446Smrj UINT32 NestingLevel, 1731*3446Smrj void *Context, 1732*3446Smrj void **ReturnValue) 1733*3446Smrj { 1734*3446Smrj ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle; 1735*3446Smrj ACPI_STATUS Status; 1736*3446Smrj ACPI_BUFFER Buffer; 1737*3446Smrj ACPI_INTEGER ADR; 1738*3446Smrj ACPI_DEVICE_ID Id; 1739*3446Smrj ACPI_COMPATIBLE_ID_LIST *Cid; 1740*3446Smrj ACPI_NAMESPACE_NODE *TempNode; 1741*3446Smrj 1742*3446Smrj 1743*3446Smrj /* Exit if there is no _PRT under this device */ 1744*3446Smrj 1745*3446Smrj Status = AcpiGetHandle (Node, METHOD_NAME__PRT, 1746*3446Smrj ACPI_CAST_PTR (ACPI_HANDLE, &TempNode)); 1747*3446Smrj if (ACPI_FAILURE (Status)) 1748*3446Smrj { 1749*3446Smrj return (AE_OK); 1750*3446Smrj } 1751*3446Smrj 1752*3446Smrj /* Get the full path to this device object */ 1753*3446Smrj 1754*3446Smrj Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER; 1755*3446Smrj Status = AcpiNsHandleToPathname (ObjHandle, &Buffer); 1756*3446Smrj if (ACPI_FAILURE (Status)) 1757*3446Smrj { 1758*3446Smrj AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle); 1759*3446Smrj return (AE_OK); 1760*3446Smrj } 1761*3446Smrj 1762*3446Smrj /* Display the full path */ 1763*3446Smrj 1764*3446Smrj AcpiOsPrintf ("%-32s", (char *) Buffer.Pointer); 1765*3446Smrj ACPI_FREE (Buffer.Pointer); 1766*3446Smrj 1767*3446Smrj /* _PRT info */ 1768*3446Smrj 1769*3446Smrj AcpiOsPrintf ("_PRT=%p", TempNode); 1770*3446Smrj 1771*3446Smrj /* Get the _ADR value */ 1772*3446Smrj 1773*3446Smrj Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, &ADR); 1774*3446Smrj if (ACPI_FAILURE (Status)) 1775*3446Smrj { 1776*3446Smrj AcpiOsPrintf (" No _ADR "); 1777*3446Smrj } 1778*3446Smrj else 1779*3446Smrj { 1780*3446Smrj AcpiOsPrintf (" _ADR=%8.8X", (UINT32) ADR); 1781*3446Smrj } 1782*3446Smrj 1783*3446Smrj /* Get the _HID if present */ 1784*3446Smrj 1785*3446Smrj Status = AcpiUtExecute_HID (Node, &Id); 1786*3446Smrj if (ACPI_SUCCESS (Status)) 1787*3446Smrj { 1788*3446Smrj AcpiOsPrintf (" _HID=%s", Id.Value); 1789*3446Smrj } 1790*3446Smrj else 1791*3446Smrj { 1792*3446Smrj AcpiOsPrintf (" "); 1793*3446Smrj } 1794*3446Smrj 1795*3446Smrj /* Get the _UID if present */ 1796*3446Smrj 1797*3446Smrj Status = AcpiUtExecute_UID (Node, &Id); 1798*3446Smrj if (ACPI_SUCCESS (Status)) 1799*3446Smrj { 1800*3446Smrj AcpiOsPrintf (" _UID=%s", Id.Value); 1801*3446Smrj } 1802*3446Smrj 1803*3446Smrj /* Get the _CID if present */ 1804*3446Smrj 1805*3446Smrj Status = AcpiUtExecute_CID (Node, &Cid); 1806*3446Smrj if (ACPI_SUCCESS (Status)) 1807*3446Smrj { 1808*3446Smrj AcpiOsPrintf (" _CID=%s", Cid->Id[0].Value); 1809*3446Smrj ACPI_FREE (Cid); 1810*3446Smrj } 1811*3446Smrj 1812*3446Smrj AcpiOsPrintf ("\n"); 1813*3446Smrj return (AE_OK); 1814*3446Smrj } 1815*3446Smrj 1816*3446Smrj 1817*3446Smrj /******************************************************************************* 1818*3446Smrj * 1819*3446Smrj * FUNCTION: AcpiDbGetBusInfo 1820*3446Smrj * 1821*3446Smrj * PARAMETERS: None 1822*3446Smrj * 1823*3446Smrj * RETURN: None 1824*3446Smrj * 1825*3446Smrj * DESCRIPTION: Display info about system busses. 1826*3446Smrj * 1827*3446Smrj ******************************************************************************/ 1828*3446Smrj 1829*3446Smrj void 1830*3446Smrj AcpiDbGetBusInfo ( 1831*3446Smrj void) 1832*3446Smrj { 1833*3446Smrj /* Search all nodes in namespace */ 1834*3446Smrj 1835*3446Smrj (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 1836*3446Smrj AcpiDbBusWalk, NULL, NULL); 1837*3446Smrj } 1838*3446Smrj 1839*3446Smrj #endif /* ACPI_DEBUGGER */ 1840