nsdump.c revision 67754
1/****************************************************************************** 2 * 3 * Module Name: nsdump - table dumping routines for debug 4 * $Revision: 80 $ 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights 13 * 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 NAMESPACE 127 MODULE_NAME ("nsdump") 128 129 130#ifdef ACPI_DEBUG 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 = AcpiCmAllocate (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 AcpiCmFree (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 OBJECT_TYPE_INTERNAL ObjType; 211 OBJECT_TYPE_INTERNAL 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, ("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 (!AcpiCmValidAcpiName (ThisNode->Name)) 307 { 308 REPORT_WARNING (("Invalid ACPI Name 0x%X\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, AcpiCmGetTypeName (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_NUMBER: 342 343 DEBUG_PRINT_RAW (TRACE_TABLES, (" N:%X\n", 344 ((ACPI_OPERAND_OBJECT *) ThisNode->Object)->Number.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 0x%X [UNKNOWN])\n", ObjType)); 413 BytesToDump = 32; 414 } 415 416 else 417 { 418 DEBUG_PRINT_RAW (TRACE_TABLES, ("(Ptr to ACPI Object type 0x%X [%s])\n", 419 ObjType, AcpiCmGetTypeName (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_PACKAGE: 454 Value = (UINT8 *) ObjDesc->Package.Elements; 455 break; 456 457 case ACPI_TYPE_METHOD: 458 Value = (UINT8 *) ObjDesc->Method.Pcode; 459 break; 460 461 case ACPI_TYPE_FIELD_UNIT: 462 Value = (UINT8 *) ObjDesc->FieldUnit.Container; 463 break; 464 465 case INTERNAL_TYPE_DEF_FIELD: 466 Value = (UINT8 *) ObjDesc->Field.Container; 467 break; 468 469 case INTERNAL_TYPE_BANK_FIELD: 470 Value = (UINT8 *) ObjDesc->BankField.Container; 471 break; 472 473 case INTERNAL_TYPE_INDEX_FIELD: 474 Value = (UINT8 *) ObjDesc->IndexField.Index; 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 OBJECT_TYPE_INTERNAL 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/**************************************************************************** 525 * 526 * FUNCTION: AcpiNsDumpOneDevice 527 * 528 * PARAMETERS: Handle - Node to be dumped 529 * Level - Nesting level of the handle 530 * Context - Passed into WalkNamespace 531 * 532 * DESCRIPTION: Dump a single Node that represents a device 533 * This procedure is a UserFunction called by AcpiNsWalkNamespace. 534 * 535 ***************************************************************************/ 536 537ACPI_STATUS 538AcpiNsDumpOneDevice ( 539 ACPI_HANDLE ObjHandle, 540 UINT32 Level, 541 void *Context, 542 void **ReturnValue) 543{ 544 ACPI_DEVICE_INFO Info; 545 ACPI_STATUS Status; 546 UINT32 i; 547 548 549 Status = AcpiNsDumpOneObject (ObjHandle, Level, Context, ReturnValue); 550 551 Status = AcpiGetObjectInfo (ObjHandle, &Info); 552 if (ACPI_SUCCESS (Status)) 553 { 554 for (i = 0; i < Level; i++) 555 { 556 DEBUG_PRINT_RAW (TRACE_TABLES, (" ")); 557 } 558 559 DEBUG_PRINT_RAW (TRACE_TABLES, (" HID: %.8X, ADR: %.8X, Status: %x\n", 560 Info.HardwareId, Info.Address, Info.CurrentStatus)); 561 } 562 563 return (Status); 564} 565 566 567/**************************************************************************** 568 * 569 * FUNCTION: AcpiNsDumpRootDevices 570 * 571 * PARAMETERS: None 572 * 573 * DESCRIPTION: Dump all objects of type "device" 574 * 575 ***************************************************************************/ 576 577void 578AcpiNsDumpRootDevices (void) 579{ 580 ACPI_HANDLE SysBusHandle; 581 582 583 /* Only dump the table if tracing is enabled */ 584 585 if (!(TRACE_TABLES & AcpiDbgLevel)) 586 { 587 return; 588 } 589 590 AcpiGetHandle (0, NS_SYSTEM_BUS, &SysBusHandle); 591 592 DEBUG_PRINT (TRACE_TABLES, ("Display of all devices in the namespace:\n")); 593 AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, SysBusHandle, ACPI_UINT32_MAX, NS_WALK_NO_UNLOCK, 594 AcpiNsDumpOneDevice, NULL, NULL); 595} 596 597 598/**************************************************************************** 599 * 600 * FUNCTION: AcpiNsDumpTables 601 * 602 * PARAMETERS: SearchBase - Root of subtree to be dumped, or 603 * NS_ALL to dump the entire namespace 604 * MaxDepth - Maximum depth of dump. Use INT_MAX 605 * for an effectively unlimited depth. 606 * 607 * DESCRIPTION: Dump the name space, or a portion of it. 608 * 609 ***************************************************************************/ 610 611void 612AcpiNsDumpTables ( 613 ACPI_HANDLE SearchBase, 614 UINT32 MaxDepth) 615{ 616 ACPI_HANDLE SearchHandle = SearchBase; 617 618 619 FUNCTION_TRACE ("NsDumpTables"); 620 621 622 if (!AcpiGbl_RootNode) 623 { 624 /* 625 * If the name space has not been initialized, 626 * there is nothing to dump. 627 */ 628 DEBUG_PRINT (TRACE_TABLES, ("NsDumpTables: name space not initialized!\n")); 629 return_VOID; 630 } 631 632 if (NS_ALL == SearchBase) 633 { 634 /* entire namespace */ 635 636 SearchHandle = AcpiGbl_RootNode; 637 DEBUG_PRINT (TRACE_TABLES, ("\\\n")); 638 } 639 640 641 AcpiNsDumpObjects (ACPI_TYPE_ANY, MaxDepth, ACPI_UINT32_MAX, SearchHandle); 642 return_VOID; 643} 644 645 646/**************************************************************************** 647 * 648 * FUNCTION: AcpiNsDumpEntry 649 * 650 * PARAMETERS: Handle - Node to be dumped 651 * DebugLevel - Output level 652 * 653 * DESCRIPTION: Dump a single Node 654 * 655 ***************************************************************************/ 656 657void 658AcpiNsDumpEntry ( 659 ACPI_HANDLE Handle, 660 UINT32 DebugLevel) 661{ 662 ACPI_WALK_INFO Info; 663 664 665 FUNCTION_TRACE_PTR ("NsDumpEntry", Handle); 666 667 Info.DebugLevel = DebugLevel; 668 Info.OwnerId = ACPI_UINT32_MAX; 669 670 AcpiNsDumpOneObject (Handle, 1, &Info, NULL); 671 672 DEBUG_PRINT (TRACE_EXEC, ("leave AcpiNsDumpEntry %p\n", Handle)); 673 return_VOID; 674} 675 676#endif 677 678