nsdump.c revision 77424
1/****************************************************************************** 2 * 3 * Module Name: nsdump - table dumping routines for debug 4 * $Revision: 93 $ 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. 13 * All rights reserved. 14 * 15 * 2. License 16 * 17 * 2.1. This is your license from Intel Corp. under its intellectual property 18 * rights. You may have additional license terms from the party that provided 19 * you this software, covering your right to use that party's intellectual 20 * property rights. 21 * 22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23 * copy of the source code appearing in this file ("Covered Code") an 24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25 * base code distributed originally by Intel ("Original Intel Code") to copy, 26 27 * make derivatives, distribute, use and display any portion of the Covered 28 * Code in any form, with the right to sublicense such rights; and 29 * 30 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 31 * license (with the right to sublicense), under only those claims of Intel 32 * patents that are infringed by the Original Intel Code, to make, use, sell, 33 * offer to sell, and import the Covered Code and derivative works thereof 34 * solely to the minimum extent necessary to exercise the above copyright 35 * license, and in no event shall the patent license extend to any additions 36 * to or modifications of the Original Intel Code. No other license or right 37 * is granted directly or by implication, estoppel or otherwise; 38 * 39 * The above copyright and patent license is granted only if the following 40 * conditions are met: 41 * 42 * 3. Conditions 43 * 44 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 45 * Redistribution of source code of any substantial portion of the Covered 46 * Code or modification with rights to further distribute source must include 47 * the above Copyright Notice, the above License, this list of Conditions, 48 * and the following Disclaimer and Export Compliance provision. In addition, 49 * Licensee must cause all Covered Code to which Licensee contributes to 50 * contain a file documenting the changes Licensee made to create that Covered 51 * Code and the date of any change. Licensee must include in that file the 52 * documentation of any changes made by any predecessor Licensee. Licensee 53 * must include a prominent statement that the modification is derived, 54 * directly or indirectly, from Original Intel Code. 55 * 56 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 57 * Redistribution of source code of any substantial portion of the Covered 58 * Code or modification without rights to further distribute source must 59 * include the following Disclaimer and Export Compliance provision in the 60 * documentation and/or other materials provided with distribution. In 61 * addition, Licensee may not authorize further sublicense of source of any 62 * portion of the Covered Code, and must include terms to the effect that the 63 * license from Licensee to its licensee is limited to the intellectual 64 * property embodied in the software Licensee provides to its licensee, and 65 * not to intellectual property embodied in modifications its licensee may 66 * make. 67 * 68 * 3.3. Redistribution of Executable. Redistribution in executable form of any 69 * substantial portion of the Covered Code or modification must reproduce the 70 * above Copyright Notice, and the following Disclaimer and Export Compliance 71 * provision in the documentation and/or other materials provided with the 72 * distribution. 73 * 74 * 3.4. Intel retains all right, title, and interest in and to the Original 75 * Intel Code. 76 * 77 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 78 * Intel shall be used in advertising or otherwise to promote the sale, use or 79 * other dealings in products derived from or relating to the Covered Code 80 * without prior written authorization from Intel. 81 * 82 * 4. Disclaimer and Export Compliance 83 * 84 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 85 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 86 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 87 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 88 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 90 * PARTICULAR PURPOSE. 91 * 92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 99 * LIMITED REMEDY. 100 * 101 * 4.3. Licensee shall not export, either directly or indirectly, any of this 102 * software or system incorporating such software without first obtaining any 103 * required license or other approval from the U. S. Department of Commerce or 104 * any other agency or department of the United States Government. In the 105 * event Licensee exports any such software from the United States or 106 * re-exports any such software from a foreign destination, Licensee shall 107 * ensure that the distribution and export/re-export of the software is in 108 * compliance with all laws, regulations, orders, or other restrictions of the 109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 110 * any of its subsidiaries will export/re-export any technical data, process, 111 * software, or service, directly or indirectly, to any country for which the 112 * United States government or any agency thereof requires an export license, 113 * other governmental approval, or letter of assurance, without first obtaining 114 * such license, approval or letter. 115 * 116 *****************************************************************************/ 117 118#define __NSDUMP_C__ 119 120#include "acpi.h" 121#include "acinterp.h" 122#include "acnamesp.h" 123#include "actables.h" 124 125 126#define _COMPONENT ACPI_NAMESPACE 127 MODULE_NAME ("nsdump") 128 129 130#if defined(ACPI_DEBUG) || defined(ENABLE_DEBUGGER) 131 132/******************************************************************************* 133 * 134 * FUNCTION: AcpiNsDumpPathname 135 * 136 * PARAMETERS: Handle - Object 137 * Msg - Prefix message 138 * Level - Desired debug level 139 * Component - Caller's component ID 140 * 141 * DESCRIPTION: Print an object's full namespace pathname 142 * Manages allocation/freeing of a pathname buffer 143 * 144 ******************************************************************************/ 145 146ACPI_STATUS 147AcpiNsDumpPathname ( 148 ACPI_HANDLE Handle, 149 NATIVE_CHAR *Msg, 150 UINT32 Level, 151 UINT32 Component) 152{ 153 NATIVE_CHAR *Buffer; 154 UINT32 Length; 155 156 157 FUNCTION_TRACE ("NsDumpPathname"); 158 159 /* Do this only if the requested debug level and component are enabled */ 160 161 if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component)) 162 { 163 return_ACPI_STATUS (AE_OK); 164 } 165 166 Buffer = AcpiUtAllocate (PATHNAME_MAX); 167 if (!Buffer) 168 { 169 return_ACPI_STATUS (AE_NO_MEMORY); 170 } 171 172 /* Convert handle to a full pathname and print it (with supplied message) */ 173 174 Length = PATHNAME_MAX; 175 if (ACPI_SUCCESS (AcpiNsHandleToPathname (Handle, &Length, Buffer))) 176 { 177 AcpiOsPrintf ("%s %s (%p)\n", Msg, Buffer, Handle); 178 } 179 180 AcpiUtFree (Buffer); 181 182 return_ACPI_STATUS (AE_OK); 183} 184 185 186/******************************************************************************* 187 * 188 * FUNCTION: AcpiNsDumpOneObject 189 * 190 * PARAMETERS: Handle - Node to be dumped 191 * Level - Nesting level of the handle 192 * Context - Passed into WalkNamespace 193 * 194 * DESCRIPTION: Dump a single Node 195 * This procedure is a UserFunction called by AcpiNsWalkNamespace. 196 * 197 ******************************************************************************/ 198 199ACPI_STATUS 200AcpiNsDumpOneObject ( 201 ACPI_HANDLE ObjHandle, 202 UINT32 Level, 203 void *Context, 204 void **ReturnValue) 205{ 206 ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context; 207 ACPI_NAMESPACE_NODE *ThisNode; 208 UINT8 *Value; 209 ACPI_OPERAND_OBJECT *ObjDesc = NULL; 210 ACPI_OBJECT_TYPE8 ObjType; 211 ACPI_OBJECT_TYPE8 Type; 212 UINT32 BytesToDump; 213 UINT32 DownstreamSiblingMask = 0; 214 UINT32 LevelTmp; 215 UINT32 WhichBit; 216 217 218 ThisNode = AcpiNsConvertHandleToEntry (ObjHandle); 219 220 LevelTmp = Level; 221 Type = ThisNode->Type; 222 WhichBit = 1; 223 224 225 if (!(AcpiDbgLevel & Info->DebugLevel)) 226 { 227 return (AE_OK); 228 } 229 230 if (!ObjHandle) 231 { 232 DEBUG_PRINT (ACPI_INFO, ("NsDumpOneObject: Null object handle\n")); 233 return (AE_OK); 234 } 235 236 /* Check if the owner matches */ 237 238 if ((Info->OwnerId != ACPI_UINT32_MAX) && 239 (Info->OwnerId != ThisNode->OwnerId)) 240 { 241 return (AE_OK); 242 } 243 244 245 /* Indent the object according to the level */ 246 247 while (LevelTmp--) 248 { 249 250 /* Print appropriate characters to form tree structure */ 251 252 if (LevelTmp) 253 { 254 if (DownstreamSiblingMask & WhichBit) 255 { 256 DEBUG_PRINT_RAW (TRACE_TABLES, ("|")); 257 } 258 259 else 260 { 261 DEBUG_PRINT_RAW (TRACE_TABLES, (" ")); 262 } 263 264 WhichBit <<= 1; 265 } 266 267 else 268 { 269 if (AcpiNsExistDownstreamSibling (ThisNode + 1)) 270 { 271 DownstreamSiblingMask |= (1 << (Level - 1)); 272 DEBUG_PRINT_RAW (TRACE_TABLES, ("+")); 273 } 274 275 else 276 { 277 DownstreamSiblingMask &= ACPI_UINT32_MAX ^ (1 << (Level - 1)); 278 DEBUG_PRINT_RAW (TRACE_TABLES, ("+")); 279 } 280 281 if (ThisNode->Child == NULL) 282 { 283 DEBUG_PRINT_RAW (TRACE_TABLES, ("-")); 284 } 285 286 else if (AcpiNsExistDownstreamSibling (ThisNode->Child)) 287 { 288 DEBUG_PRINT_RAW (TRACE_TABLES, ("+")); 289 } 290 291 else 292 { 293 DEBUG_PRINT_RAW (TRACE_TABLES, ("-")); 294 } 295 } 296 } 297 298 299 /* Check the integrity of our data */ 300 301 if (Type > INTERNAL_TYPE_MAX) 302 { 303 Type = INTERNAL_TYPE_DEF_ANY; /* prints as *ERROR* */ 304 } 305 306 if (!AcpiUtValidAcpiName (ThisNode->Name)) 307 { 308 REPORT_WARNING (("Invalid ACPI Name %08X\n", ThisNode->Name)); 309 } 310 311 /* 312 * Now we can print out the pertinent information 313 */ 314 315 DEBUG_PRINT_RAW (TRACE_TABLES, (" %4.4s %-9s ", &ThisNode->Name, AcpiUtGetTypeName (Type))); 316 DEBUG_PRINT_RAW (TRACE_TABLES, ("%p S:%p O:%p", ThisNode, ThisNode->Child, ThisNode->Object)); 317 318 319 if (!ThisNode->Object) 320 { 321 /* No attached object, we are done */ 322 323 DEBUG_PRINT_RAW (TRACE_TABLES, ("\n")); 324 return (AE_OK); 325 } 326 327 switch (Type) 328 { 329 330 case ACPI_TYPE_METHOD: 331 332 /* Name is a Method and its AML offset/length are set */ 333 334 DEBUG_PRINT_RAW (TRACE_TABLES, (" M:%p-%X\n", 335 ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Method.Pcode, 336 ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Method.PcodeLength)); 337 338 break; 339 340 341 case ACPI_TYPE_INTEGER: 342 343 DEBUG_PRINT_RAW (TRACE_TABLES, (" N:%X\n", 344 ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Integer.Value)); 345 break; 346 347 348 case ACPI_TYPE_STRING: 349 350 DEBUG_PRINT_RAW (TRACE_TABLES, (" S:%p-%X\n", 351 ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->String.Pointer, 352 ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->String.Length)); 353 break; 354 355 356 case ACPI_TYPE_BUFFER: 357 358 DEBUG_PRINT_RAW (TRACE_TABLES, (" B:%p-%X\n", 359 ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Buffer.Pointer, 360 ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Buffer.Length)); 361 break; 362 363 364 default: 365 366 DEBUG_PRINT_RAW (TRACE_TABLES, ("\n")); 367 break; 368 } 369 370 /* If debug turned off, done */ 371 372 if (!(AcpiDbgLevel & TRACE_VALUES)) 373 { 374 return (AE_OK); 375 } 376 377 378 /* If there is an attached object, display it */ 379 380 Value = ThisNode->Object; 381 382 /* Dump attached objects */ 383 384 while (Value) 385 { 386 ObjType = INTERNAL_TYPE_INVALID; 387 388 /* Decode the type of attached object and dump the contents */ 389 390 DEBUG_PRINT_RAW (TRACE_TABLES, (" Attached Object %p: ", Value)); 391 392 if (AcpiTbSystemTablePointer (Value)) 393 { 394 DEBUG_PRINT_RAW (TRACE_TABLES, ("(Ptr to AML Code)\n")); 395 BytesToDump = 16; 396 } 397 398 else if (VALID_DESCRIPTOR_TYPE (Value, ACPI_DESC_TYPE_NAMED)) 399 { 400 DEBUG_PRINT_RAW (TRACE_TABLES, ("(Ptr to Node)\n")); 401 BytesToDump = sizeof (ACPI_NAMESPACE_NODE); 402 } 403 404 405 else if (VALID_DESCRIPTOR_TYPE (Value, ACPI_DESC_TYPE_INTERNAL)) 406 { 407 ObjDesc = (ACPI_OPERAND_OBJECT *) Value; 408 ObjType = ObjDesc->Common.Type; 409 410 if (ObjType > INTERNAL_TYPE_MAX) 411 { 412 DEBUG_PRINT_RAW (TRACE_TABLES, ("(Ptr to ACPI Object type %X [UNKNOWN])\n", ObjType)); 413 BytesToDump = 32; 414 } 415 416 else 417 { 418 DEBUG_PRINT_RAW (TRACE_TABLES, ("(Ptr to ACPI Object type %X [%s])\n", 419 ObjType, AcpiUtGetTypeName (ObjType))); 420 BytesToDump = sizeof (ACPI_OPERAND_OBJECT); 421 } 422 } 423 424 else 425 { 426 DEBUG_PRINT_RAW (TRACE_TABLES, ("(String or Buffer - not descriptor)\n", Value)); 427 BytesToDump = 16; 428 } 429 430 DUMP_BUFFER (Value, BytesToDump); 431 432 /* If value is NOT an internal object, we are done */ 433 434 if ((AcpiTbSystemTablePointer (Value)) || 435 (VALID_DESCRIPTOR_TYPE (Value, ACPI_DESC_TYPE_NAMED))) 436 { 437 goto Cleanup; 438 } 439 440 /* 441 * Valid object, get the pointer to next level, if any 442 */ 443 switch (ObjType) 444 { 445 case ACPI_TYPE_STRING: 446 Value = (UINT8 *) ObjDesc->String.Pointer; 447 break; 448 449 case ACPI_TYPE_BUFFER: 450 Value = (UINT8 *) ObjDesc->Buffer.Pointer; 451 break; 452 453 case ACPI_TYPE_BUFFER_FIELD: 454 Value = (UINT8 *) ObjDesc->BufferField.BufferObj; 455 break; 456 457 case ACPI_TYPE_PACKAGE: 458 Value = (UINT8 *) ObjDesc->Package.Elements; 459 break; 460 461 case ACPI_TYPE_METHOD: 462 Value = (UINT8 *) ObjDesc->Method.Pcode; 463 break; 464 465 case INTERNAL_TYPE_REGION_FIELD: 466 Value = (UINT8 *) ObjDesc->Field.RegionObj; 467 break; 468 469 case INTERNAL_TYPE_BANK_FIELD: 470 Value = (UINT8 *) ObjDesc->BankField.RegionObj; 471 break; 472 473 case INTERNAL_TYPE_INDEX_FIELD: 474 Value = (UINT8 *) ObjDesc->IndexField.IndexObj; 475 break; 476 477 default: 478 goto Cleanup; 479 } 480 481 ObjType = INTERNAL_TYPE_INVALID; /* Terminate loop after next pass */ 482 } 483 484Cleanup: 485 DEBUG_PRINT_RAW (TRACE_TABLES, ("\n")); 486 return (AE_OK); 487} 488 489 490/******************************************************************************* 491 * 492 * FUNCTION: AcpiNsDumpObjects 493 * 494 * PARAMETERS: Type - Object type to be dumped 495 * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX 496 * for an effectively unlimited depth. 497 * OwnerId - Dump only objects owned by this ID. Use 498 * ACPI_UINT32_MAX to match all owners. 499 * StartHandle - Where in namespace to start/end search 500 * 501 * DESCRIPTION: Dump typed objects within the loaded namespace. 502 * Uses AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject. 503 * 504 ******************************************************************************/ 505 506void 507AcpiNsDumpObjects ( 508 ACPI_OBJECT_TYPE8 Type, 509 UINT32 MaxDepth, 510 UINT32 OwnerId, 511 ACPI_HANDLE StartHandle) 512{ 513 ACPI_WALK_INFO Info; 514 515 516 Info.DebugLevel = TRACE_TABLES; 517 Info.OwnerId = OwnerId; 518 519 AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, NS_WALK_NO_UNLOCK, AcpiNsDumpOneObject, 520 (void *) &Info, NULL); 521} 522 523 524#ifndef _ACPI_ASL_COMPILER 525/******************************************************************************* 526 * 527 * FUNCTION: AcpiNsDumpOneDevice 528 * 529 * PARAMETERS: Handle - Node to be dumped 530 * Level - Nesting level of the handle 531 * Context - Passed into WalkNamespace 532 * 533 * DESCRIPTION: Dump a single Node that represents a device 534 * This procedure is a UserFunction called by AcpiNsWalkNamespace. 535 * 536 ******************************************************************************/ 537 538ACPI_STATUS 539AcpiNsDumpOneDevice ( 540 ACPI_HANDLE ObjHandle, 541 UINT32 Level, 542 void *Context, 543 void **ReturnValue) 544{ 545 ACPI_DEVICE_INFO Info; 546 ACPI_STATUS Status; 547 UINT32 i; 548 549 550 Status = AcpiNsDumpOneObject (ObjHandle, Level, Context, ReturnValue); 551 552 Status = AcpiGetObjectInfo (ObjHandle, &Info); 553 if (ACPI_SUCCESS (Status)) 554 { 555 for (i = 0; i < Level; i++) 556 { 557 DEBUG_PRINT_RAW (TRACE_TABLES, (" ")); 558 } 559 560 DEBUG_PRINT_RAW (TRACE_TABLES, (" HID: %.8X, ADR: %.8X, Status: %x\n", 561 Info.HardwareId, Info.Address, Info.CurrentStatus)); 562 } 563 564 return (Status); 565} 566 567 568/******************************************************************************* 569 * 570 * FUNCTION: AcpiNsDumpRootDevices 571 * 572 * PARAMETERS: None 573 * 574 * DESCRIPTION: Dump all objects of type "device" 575 * 576 ******************************************************************************/ 577 578void 579AcpiNsDumpRootDevices (void) 580{ 581 ACPI_HANDLE SysBusHandle; 582 583 584 /* Only dump the table if tracing is enabled */ 585 586 if (!(TRACE_TABLES & AcpiDbgLevel)) 587 { 588 return; 589 } 590 591 AcpiGetHandle (0, NS_SYSTEM_BUS, &SysBusHandle); 592 593 DEBUG_PRINT (TRACE_TABLES, ("Display of all devices in the namespace:\n")); 594 AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, SysBusHandle, ACPI_UINT32_MAX, NS_WALK_NO_UNLOCK, 595 AcpiNsDumpOneDevice, NULL, NULL); 596} 597 598#endif 599 600/******************************************************************************* 601 * 602 * FUNCTION: AcpiNsDumpTables 603 * 604 * PARAMETERS: SearchBase - Root of subtree to be dumped, or 605 * NS_ALL to dump the entire namespace 606 * MaxDepth - Maximum depth of dump. Use INT_MAX 607 * for an effectively unlimited depth. 608 * 609 * DESCRIPTION: Dump the name space, or a portion of it. 610 * 611 ******************************************************************************/ 612 613void 614AcpiNsDumpTables ( 615 ACPI_HANDLE SearchBase, 616 UINT32 MaxDepth) 617{ 618 ACPI_HANDLE SearchHandle = SearchBase; 619 620 621 FUNCTION_TRACE ("NsDumpTables"); 622 623 624 if (!AcpiGbl_RootNode) 625 { 626 /* 627 * If the name space has not been initialized, 628 * there is nothing to dump. 629 */ 630 DEBUG_PRINTP (TRACE_TABLES, ("name space not initialized!\n")); 631 return_VOID; 632 } 633 634 if (NS_ALL == SearchBase) 635 { 636 /* entire namespace */ 637 638 SearchHandle = AcpiGbl_RootNode; 639 DEBUG_PRINT (TRACE_TABLES, ("\\\n")); 640 } 641 642 643 AcpiNsDumpObjects (ACPI_TYPE_ANY, MaxDepth, ACPI_UINT32_MAX, SearchHandle); 644 return_VOID; 645} 646 647 648/******************************************************************************* 649 * 650 * FUNCTION: AcpiNsDumpEntry 651 * 652 * PARAMETERS: Handle - Node to be dumped 653 * DebugLevel - Output level 654 * 655 * DESCRIPTION: Dump a single Node 656 * 657 ******************************************************************************/ 658 659void 660AcpiNsDumpEntry ( 661 ACPI_HANDLE Handle, 662 UINT32 DebugLevel) 663{ 664 ACPI_WALK_INFO Info; 665 666 667 FUNCTION_TRACE_PTR ("NsDumpEntry", Handle); 668 669 Info.DebugLevel = DebugLevel; 670 Info.OwnerId = ACPI_UINT32_MAX; 671 672 AcpiNsDumpOneObject (Handle, 1, &Info, NULL); 673 674 return_VOID; 675} 676 677#endif 678 679