1 /****************************************************************************** 2 * 3 * Module Name: utdecode - Utility decoding routines (value-to-string) 4 * 5 *****************************************************************************/ 6 7 /****************************************************************************** 8 * 9 * 1. Copyright Notice 10 * 11 * Some or all of this work - Copyright (c) 1999 - 2012, Intel Corp. 12 * All rights reserved. 13 * 14 * 2. License 15 * 16 * 2.1. This is your license from Intel Corp. under its intellectual property 17 * rights. You may have additional license terms from the party that provided 18 * you this software, covering your right to use that party's intellectual 19 * property rights. 20 * 21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22 * copy of the source code appearing in this file ("Covered Code") an 23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24 * base code distributed originally by Intel ("Original Intel Code") to copy, 25 * make derivatives, distribute, use and display any portion of the Covered 26 * Code in any form, with the right to sublicense such rights; and 27 * 28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29 * license (with the right to sublicense), under only those claims of Intel 30 * patents that are infringed by the Original Intel Code, to make, use, sell, 31 * offer to sell, and import the Covered Code and derivative works thereof 32 * solely to the minimum extent necessary to exercise the above copyright 33 * license, and in no event shall the patent license extend to any additions 34 * to or modifications of the Original Intel Code. No other license or right 35 * is granted directly or by implication, estoppel or otherwise; 36 * 37 * The above copyright and patent license is granted only if the following 38 * conditions are met: 39 * 40 * 3. Conditions 41 * 42 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43 * Redistribution of source code of any substantial portion of the Covered 44 * Code or modification with rights to further distribute source must include 45 * the above Copyright Notice, the above License, this list of Conditions, 46 * and the following Disclaimer and Export Compliance provision. In addition, 47 * Licensee must cause all Covered Code to which Licensee contributes to 48 * contain a file documenting the changes Licensee made to create that Covered 49 * Code and the date of any change. Licensee must include in that file the 50 * documentation of any changes made by any predecessor Licensee. Licensee 51 * must include a prominent statement that the modification is derived, 52 * directly or indirectly, from Original Intel Code. 53 * 54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55 * Redistribution of source code of any substantial portion of the Covered 56 * Code or modification without rights to further distribute source must 57 * include the following Disclaimer and Export Compliance provision in the 58 * documentation and/or other materials provided with distribution. In 59 * addition, Licensee may not authorize further sublicense of source of any 60 * portion of the Covered Code, and must include terms to the effect that the 61 * license from Licensee to its licensee is limited to the intellectual 62 * property embodied in the software Licensee provides to its licensee, and 63 * not to intellectual property embodied in modifications its licensee may 64 * make. 65 * 66 * 3.3. Redistribution of Executable. Redistribution in executable form of any 67 * substantial portion of the Covered Code or modification must reproduce the 68 * above Copyright Notice, and the following Disclaimer and Export Compliance 69 * provision in the documentation and/or other materials provided with the 70 * distribution. 71 * 72 * 3.4. Intel retains all right, title, and interest in and to the Original 73 * Intel Code. 74 * 75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76 * Intel shall be used in advertising or otherwise to promote the sale, use or 77 * other dealings in products derived from or relating to the Covered Code 78 * without prior written authorization from Intel. 79 * 80 * 4. Disclaimer and Export Compliance 81 * 82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88 * PARTICULAR PURPOSE. 89 * 90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97 * LIMITED REMEDY. 98 * 99 * 4.3. Licensee shall not export, either directly or indirectly, any of this 100 * software or system incorporating such software without first obtaining any 101 * required license or other approval from the U. S. Department of Commerce or 102 * any other agency or department of the United States Government. In the 103 * event Licensee exports any such software from the United States or 104 * re-exports any such software from a foreign destination, Licensee shall 105 * ensure that the distribution and export/re-export of the software is in 106 * compliance with all laws, regulations, orders, or other restrictions of the 107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108 * any of its subsidiaries will export/re-export any technical data, process, 109 * software, or service, directly or indirectly, to any country for which the 110 * United States government or any agency thereof requires an export license, 111 * other governmental approval, or letter of assurance, without first obtaining 112 * such license, approval or letter. 113 * 114 *****************************************************************************/ 115 116 #define __UTDECODE_C__ 117 118 #include "acpi.h" 119 #include "accommon.h" 120 #include "acnamesp.h" 121 122 #define _COMPONENT ACPI_UTILITIES 123 ACPI_MODULE_NAME ("utdecode") 124 125 126 /* 127 * Properties of the ACPI Object Types, both internal and external. 128 * The table is indexed by values of ACPI_OBJECT_TYPE 129 */ 130 const UINT8 AcpiGbl_NsProperties[ACPI_NUM_NS_TYPES] = 131 { 132 ACPI_NS_NORMAL, /* 00 Any */ 133 ACPI_NS_NORMAL, /* 01 Number */ 134 ACPI_NS_NORMAL, /* 02 String */ 135 ACPI_NS_NORMAL, /* 03 Buffer */ 136 ACPI_NS_NORMAL, /* 04 Package */ 137 ACPI_NS_NORMAL, /* 05 FieldUnit */ 138 ACPI_NS_NEWSCOPE, /* 06 Device */ 139 ACPI_NS_NORMAL, /* 07 Event */ 140 ACPI_NS_NEWSCOPE, /* 08 Method */ 141 ACPI_NS_NORMAL, /* 09 Mutex */ 142 ACPI_NS_NORMAL, /* 10 Region */ 143 ACPI_NS_NEWSCOPE, /* 11 Power */ 144 ACPI_NS_NEWSCOPE, /* 12 Processor */ 145 ACPI_NS_NEWSCOPE, /* 13 Thermal */ 146 ACPI_NS_NORMAL, /* 14 BufferField */ 147 ACPI_NS_NORMAL, /* 15 DdbHandle */ 148 ACPI_NS_NORMAL, /* 16 Debug Object */ 149 ACPI_NS_NORMAL, /* 17 DefField */ 150 ACPI_NS_NORMAL, /* 18 BankField */ 151 ACPI_NS_NORMAL, /* 19 IndexField */ 152 ACPI_NS_NORMAL, /* 20 Reference */ 153 ACPI_NS_NORMAL, /* 21 Alias */ 154 ACPI_NS_NORMAL, /* 22 MethodAlias */ 155 ACPI_NS_NORMAL, /* 23 Notify */ 156 ACPI_NS_NORMAL, /* 24 Address Handler */ 157 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */ 158 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */ 159 ACPI_NS_NEWSCOPE, /* 27 Scope */ 160 ACPI_NS_NORMAL, /* 28 Extra */ 161 ACPI_NS_NORMAL, /* 29 Data */ 162 ACPI_NS_NORMAL /* 30 Invalid */ 163 }; 164 165 166 /******************************************************************************* 167 * 168 * FUNCTION: AcpiUtHexToAsciiChar 169 * 170 * PARAMETERS: Integer - Contains the hex digit 171 * Position - bit position of the digit within the 172 * integer (multiple of 4) 173 * 174 * RETURN: The converted Ascii character 175 * 176 * DESCRIPTION: Convert a hex digit to an Ascii character 177 * 178 ******************************************************************************/ 179 180 /* Hex to ASCII conversion table */ 181 182 static const char AcpiGbl_HexToAscii[] = 183 { 184 '0','1','2','3','4','5','6','7', 185 '8','9','A','B','C','D','E','F' 186 }; 187 188 char 189 AcpiUtHexToAsciiChar ( 190 UINT64 Integer, 191 UINT32 Position) 192 { 193 194 return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]); 195 } 196 197 198 /******************************************************************************* 199 * 200 * FUNCTION: AcpiUtGetRegionName 201 * 202 * PARAMETERS: Space ID - ID for the region 203 * 204 * RETURN: Decoded region SpaceId name 205 * 206 * DESCRIPTION: Translate a Space ID into a name string (Debug only) 207 * 208 ******************************************************************************/ 209 210 /* Region type decoding */ 211 212 const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] = 213 { 214 "SystemMemory", /* 0x00 */ 215 "SystemIO", /* 0x01 */ 216 "PCI_Config", /* 0x02 */ 217 "EmbeddedControl", /* 0x03 */ 218 "SMBus", /* 0x04 */ 219 "SystemCMOS", /* 0x05 */ 220 "PCIBARTarget", /* 0x06 */ 221 "IPMI", /* 0x07 */ 222 "GeneralPurposeIo", /* 0x08 */ 223 "GenericSerialBus", /* 0x09 */ 224 "PCC" /* 0x0A */ 225 }; 226 227 228 char * 229 AcpiUtGetRegionName ( 230 UINT8 SpaceId) 231 { 232 233 if (SpaceId >= ACPI_USER_REGION_BEGIN) 234 { 235 return ("UserDefinedRegion"); 236 } 237 else if (SpaceId == ACPI_ADR_SPACE_DATA_TABLE) 238 { 239 return ("DataTable"); 240 } 241 else if (SpaceId == ACPI_ADR_SPACE_FIXED_HARDWARE) 242 { 243 return ("FunctionalFixedHW"); 244 } 245 else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) 246 { 247 return ("InvalidSpaceId"); 248 } 249 250 return (ACPI_CAST_PTR (char, AcpiGbl_RegionTypes[SpaceId])); 251 } 252 253 254 /******************************************************************************* 255 * 256 * FUNCTION: AcpiUtGetEventName 257 * 258 * PARAMETERS: EventId - Fixed event ID 259 * 260 * RETURN: Decoded event ID name 261 * 262 * DESCRIPTION: Translate a Event ID into a name string (Debug only) 263 * 264 ******************************************************************************/ 265 266 /* Event type decoding */ 267 268 static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] = 269 { 270 "PM_Timer", 271 "GlobalLock", 272 "PowerButton", 273 "SleepButton", 274 "RealTimeClock", 275 }; 276 277 278 char * 279 AcpiUtGetEventName ( 280 UINT32 EventId) 281 { 282 283 if (EventId > ACPI_EVENT_MAX) 284 { 285 return ("InvalidEventID"); 286 } 287 288 return (ACPI_CAST_PTR (char, AcpiGbl_EventTypes[EventId])); 289 } 290 291 292 /******************************************************************************* 293 * 294 * FUNCTION: AcpiUtGetTypeName 295 * 296 * PARAMETERS: Type - An ACPI object type 297 * 298 * RETURN: Decoded ACPI object type name 299 * 300 * DESCRIPTION: Translate a Type ID into a name string (Debug only) 301 * 302 ******************************************************************************/ 303 304 /* 305 * Elements of AcpiGbl_NsTypeNames below must match 306 * one-to-one with values of ACPI_OBJECT_TYPE 307 * 308 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; 309 * when stored in a table it really means that we have thus far seen no 310 * evidence to indicate what type is actually going to be stored for this entry. 311 */ 312 static const char AcpiGbl_BadType[] = "UNDEFINED"; 313 314 /* Printable names of the ACPI object types */ 315 316 static const char *AcpiGbl_NsTypeNames[] = 317 { 318 /* 00 */ "Untyped", 319 /* 01 */ "Integer", 320 /* 02 */ "String", 321 /* 03 */ "Buffer", 322 /* 04 */ "Package", 323 /* 05 */ "FieldUnit", 324 /* 06 */ "Device", 325 /* 07 */ "Event", 326 /* 08 */ "Method", 327 /* 09 */ "Mutex", 328 /* 10 */ "Region", 329 /* 11 */ "Power", 330 /* 12 */ "Processor", 331 /* 13 */ "Thermal", 332 /* 14 */ "BufferField", 333 /* 15 */ "DdbHandle", 334 /* 16 */ "DebugObject", 335 /* 17 */ "RegionField", 336 /* 18 */ "BankField", 337 /* 19 */ "IndexField", 338 /* 20 */ "Reference", 339 /* 21 */ "Alias", 340 /* 22 */ "MethodAlias", 341 /* 23 */ "Notify", 342 /* 24 */ "AddrHandler", 343 /* 25 */ "ResourceDesc", 344 /* 26 */ "ResourceFld", 345 /* 27 */ "Scope", 346 /* 28 */ "Extra", 347 /* 29 */ "Data", 348 /* 30 */ "Invalid" 349 }; 350 351 352 char * 353 AcpiUtGetTypeName ( 354 ACPI_OBJECT_TYPE Type) 355 { 356 357 if (Type > ACPI_TYPE_INVALID) 358 { 359 return (ACPI_CAST_PTR (char, AcpiGbl_BadType)); 360 } 361 362 return (ACPI_CAST_PTR (char, AcpiGbl_NsTypeNames[Type])); 363 } 364 365 366 char * 367 AcpiUtGetObjectTypeName ( 368 ACPI_OPERAND_OBJECT *ObjDesc) 369 { 370 371 if (!ObjDesc) 372 { 373 return ("[NULL Object Descriptor]"); 374 } 375 376 return (AcpiUtGetTypeName (ObjDesc->Common.Type)); 377 } 378 379 380 /******************************************************************************* 381 * 382 * FUNCTION: AcpiUtGetNodeName 383 * 384 * PARAMETERS: Object - A namespace node 385 * 386 * RETURN: ASCII name of the node 387 * 388 * DESCRIPTION: Validate the node and return the node's ACPI name. 389 * 390 ******************************************************************************/ 391 392 char * 393 AcpiUtGetNodeName ( 394 void *Object) 395 { 396 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) Object; 397 398 399 /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */ 400 401 if (!Object) 402 { 403 return ("NULL"); 404 } 405 406 /* Check for Root node */ 407 408 if ((Object == ACPI_ROOT_OBJECT) || 409 (Object == AcpiGbl_RootNode)) 410 { 411 return ("\"\\\" "); 412 } 413 414 /* Descriptor must be a namespace node */ 415 416 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) 417 { 418 return ("####"); 419 } 420 421 /* 422 * Ensure name is valid. The name was validated/repaired when the node 423 * was created, but make sure it has not been corrupted. 424 */ 425 AcpiUtRepairName (Node->Name.Ascii); 426 427 /* Return the name */ 428 429 return (Node->Name.Ascii); 430 } 431 432 433 /******************************************************************************* 434 * 435 * FUNCTION: AcpiUtGetDescriptorName 436 * 437 * PARAMETERS: Object - An ACPI object 438 * 439 * RETURN: Decoded name of the descriptor type 440 * 441 * DESCRIPTION: Validate object and return the descriptor type 442 * 443 ******************************************************************************/ 444 445 /* Printable names of object descriptor types */ 446 447 static const char *AcpiGbl_DescTypeNames[] = 448 { 449 /* 00 */ "Not a Descriptor", 450 /* 01 */ "Cached", 451 /* 02 */ "State-Generic", 452 /* 03 */ "State-Update", 453 /* 04 */ "State-Package", 454 /* 05 */ "State-Control", 455 /* 06 */ "State-RootParseScope", 456 /* 07 */ "State-ParseScope", 457 /* 08 */ "State-WalkScope", 458 /* 09 */ "State-Result", 459 /* 10 */ "State-Notify", 460 /* 11 */ "State-Thread", 461 /* 12 */ "Walk", 462 /* 13 */ "Parser", 463 /* 14 */ "Operand", 464 /* 15 */ "Node" 465 }; 466 467 468 char * 469 AcpiUtGetDescriptorName ( 470 void *Object) 471 { 472 473 if (!Object) 474 { 475 return ("NULL OBJECT"); 476 } 477 478 if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX) 479 { 480 return ("Not a Descriptor"); 481 } 482 483 return (ACPI_CAST_PTR (char, 484 AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)])); 485 486 } 487 488 489 /******************************************************************************* 490 * 491 * FUNCTION: AcpiUtGetReferenceName 492 * 493 * PARAMETERS: Object - An ACPI reference object 494 * 495 * RETURN: Decoded name of the type of reference 496 * 497 * DESCRIPTION: Decode a reference object sub-type to a string. 498 * 499 ******************************************************************************/ 500 501 /* Printable names of reference object sub-types */ 502 503 static const char *AcpiGbl_RefClassNames[] = 504 { 505 /* 00 */ "Local", 506 /* 01 */ "Argument", 507 /* 02 */ "RefOf", 508 /* 03 */ "Index", 509 /* 04 */ "DdbHandle", 510 /* 05 */ "Named Object", 511 /* 06 */ "Debug" 512 }; 513 514 const char * 515 AcpiUtGetReferenceName ( 516 ACPI_OPERAND_OBJECT *Object) 517 { 518 519 if (!Object) 520 { 521 return ("NULL Object"); 522 } 523 524 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND) 525 { 526 return ("Not an Operand object"); 527 } 528 529 if (Object->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) 530 { 531 return ("Not a Reference object"); 532 } 533 534 if (Object->Reference.Class > ACPI_REFCLASS_MAX) 535 { 536 return ("Unknown Reference class"); 537 } 538 539 return (AcpiGbl_RefClassNames[Object->Reference.Class]); 540 } 541 542 543 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 544 /* 545 * Strings and procedures used for debug only 546 */ 547 548 /******************************************************************************* 549 * 550 * FUNCTION: AcpiUtGetMutexName 551 * 552 * PARAMETERS: MutexId - The predefined ID for this mutex. 553 * 554 * RETURN: Decoded name of the internal mutex 555 * 556 * DESCRIPTION: Translate a mutex ID into a name string (Debug only) 557 * 558 ******************************************************************************/ 559 560 /* Names for internal mutex objects, used for debug output */ 561 562 static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] = 563 { 564 "ACPI_MTX_Interpreter", 565 "ACPI_MTX_Namespace", 566 "ACPI_MTX_Tables", 567 "ACPI_MTX_Events", 568 "ACPI_MTX_Caches", 569 "ACPI_MTX_Memory", 570 "ACPI_MTX_CommandComplete", 571 "ACPI_MTX_CommandReady" 572 }; 573 574 char * 575 AcpiUtGetMutexName ( 576 UINT32 MutexId) 577 { 578 579 if (MutexId > ACPI_MAX_MUTEX) 580 { 581 return ("Invalid Mutex ID"); 582 } 583 584 return (AcpiGbl_MutexNames[MutexId]); 585 } 586 587 588 /******************************************************************************* 589 * 590 * FUNCTION: AcpiUtGetNotifyName 591 * 592 * PARAMETERS: NotifyValue - Value from the Notify() request 593 * 594 * RETURN: Decoded name for the notify value 595 * 596 * DESCRIPTION: Translate a Notify Value to a notify namestring. 597 * 598 ******************************************************************************/ 599 600 /* Names for Notify() values, used for debug output */ 601 602 static const char *AcpiGbl_NotifyValueNames[ACPI_NOTIFY_MAX + 1] = 603 { 604 /* 00 */ "Bus Check", 605 /* 01 */ "Device Check", 606 /* 02 */ "Device Wake", 607 /* 03 */ "Eject Request", 608 /* 04 */ "Device Check Light", 609 /* 05 */ "Frequency Mismatch", 610 /* 06 */ "Bus Mode Mismatch", 611 /* 07 */ "Power Fault", 612 /* 08 */ "Capabilities Check", 613 /* 09 */ "Device PLD Check", 614 /* 10 */ "Reserved", 615 /* 11 */ "System Locality Update", 616 /* 12 */ "Shutdown Request" 617 }; 618 619 const char * 620 AcpiUtGetNotifyName ( 621 UINT32 NotifyValue) 622 { 623 624 if (NotifyValue <= ACPI_NOTIFY_MAX) 625 { 626 return (AcpiGbl_NotifyValueNames[NotifyValue]); 627 } 628 else if (NotifyValue <= ACPI_MAX_SYS_NOTIFY) 629 { 630 return ("Reserved"); 631 } 632 else if (NotifyValue <= ACPI_MAX_DEVICE_SPECIFIC_NOTIFY) 633 { 634 return ("Device Specific"); 635 } 636 else 637 { 638 return ("Hardware Specific"); 639 } 640 } 641 #endif 642 643 644 /******************************************************************************* 645 * 646 * FUNCTION: AcpiUtValidObjectType 647 * 648 * PARAMETERS: Type - Object type to be validated 649 * 650 * RETURN: TRUE if valid object type, FALSE otherwise 651 * 652 * DESCRIPTION: Validate an object type 653 * 654 ******************************************************************************/ 655 656 BOOLEAN 657 AcpiUtValidObjectType ( 658 ACPI_OBJECT_TYPE Type) 659 { 660 661 if (Type > ACPI_TYPE_LOCAL_MAX) 662 { 663 /* Note: Assumes all TYPEs are contiguous (external/local) */ 664 665 return (FALSE); 666 } 667 668 return (TRUE); 669 } 670