1 /****************************************************************************** 2 * 3 * Module Name: utdecode - Utility decoding routines (value-to-string) 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2015, Intel Corp. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions, and the following disclaimer, 16 * without modification. 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 * substantially similar to the "NO WARRANTY" disclaimer below 19 * ("Disclaimer") and any redistribution must be conditioned upon 20 * including a substantially similar Disclaimer requirement for further 21 * binary redistribution. 22 * 3. Neither the names of the above-listed copyright holders nor the names 23 * of any contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * Alternatively, this software may be distributed under the terms of the 27 * GNU General Public License ("GPL") version 2 as published by the Free 28 * Software Foundation. 29 * 30 * NO WARRANTY 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 * POSSIBILITY OF SUCH DAMAGES. 42 */ 43 44 #include "acpi.h" 45 #include "accommon.h" 46 #include "acnamesp.h" 47 48 #define _COMPONENT ACPI_UTILITIES 49 ACPI_MODULE_NAME ("utdecode") 50 51 52 /* 53 * Properties of the ACPI Object Types, both internal and external. 54 * The table is indexed by values of ACPI_OBJECT_TYPE 55 */ 56 const UINT8 AcpiGbl_NsProperties[ACPI_NUM_NS_TYPES] = 57 { 58 ACPI_NS_NORMAL, /* 00 Any */ 59 ACPI_NS_NORMAL, /* 01 Number */ 60 ACPI_NS_NORMAL, /* 02 String */ 61 ACPI_NS_NORMAL, /* 03 Buffer */ 62 ACPI_NS_NORMAL, /* 04 Package */ 63 ACPI_NS_NORMAL, /* 05 FieldUnit */ 64 ACPI_NS_NEWSCOPE, /* 06 Device */ 65 ACPI_NS_NORMAL, /* 07 Event */ 66 ACPI_NS_NEWSCOPE, /* 08 Method */ 67 ACPI_NS_NORMAL, /* 09 Mutex */ 68 ACPI_NS_NORMAL, /* 10 Region */ 69 ACPI_NS_NEWSCOPE, /* 11 Power */ 70 ACPI_NS_NEWSCOPE, /* 12 Processor */ 71 ACPI_NS_NEWSCOPE, /* 13 Thermal */ 72 ACPI_NS_NORMAL, /* 14 BufferField */ 73 ACPI_NS_NORMAL, /* 15 DdbHandle */ 74 ACPI_NS_NORMAL, /* 16 Debug Object */ 75 ACPI_NS_NORMAL, /* 17 DefField */ 76 ACPI_NS_NORMAL, /* 18 BankField */ 77 ACPI_NS_NORMAL, /* 19 IndexField */ 78 ACPI_NS_NORMAL, /* 20 Reference */ 79 ACPI_NS_NORMAL, /* 21 Alias */ 80 ACPI_NS_NORMAL, /* 22 MethodAlias */ 81 ACPI_NS_NORMAL, /* 23 Notify */ 82 ACPI_NS_NORMAL, /* 24 Address Handler */ 83 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */ 84 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */ 85 ACPI_NS_NEWSCOPE, /* 27 Scope */ 86 ACPI_NS_NORMAL, /* 28 Extra */ 87 ACPI_NS_NORMAL, /* 29 Data */ 88 ACPI_NS_NORMAL /* 30 Invalid */ 89 }; 90 91 92 /******************************************************************************* 93 * 94 * FUNCTION: AcpiUtGetRegionName 95 * 96 * PARAMETERS: Space ID - ID for the region 97 * 98 * RETURN: Decoded region SpaceId name 99 * 100 * DESCRIPTION: Translate a Space ID into a name string (Debug only) 101 * 102 ******************************************************************************/ 103 104 /* Region type decoding */ 105 106 const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] = 107 { 108 "SystemMemory", /* 0x00 */ 109 "SystemIO", /* 0x01 */ 110 "PCI_Config", /* 0x02 */ 111 "EmbeddedControl", /* 0x03 */ 112 "SMBus", /* 0x04 */ 113 "SystemCMOS", /* 0x05 */ 114 "PCIBARTarget", /* 0x06 */ 115 "IPMI", /* 0x07 */ 116 "GeneralPurposeIo", /* 0x08 */ 117 "GenericSerialBus", /* 0x09 */ 118 "PCC" /* 0x0A */ 119 }; 120 121 122 char * 123 AcpiUtGetRegionName ( 124 UINT8 SpaceId) 125 { 126 127 if (SpaceId >= ACPI_USER_REGION_BEGIN) 128 { 129 return ("UserDefinedRegion"); 130 } 131 else if (SpaceId == ACPI_ADR_SPACE_DATA_TABLE) 132 { 133 return ("DataTable"); 134 } 135 else if (SpaceId == ACPI_ADR_SPACE_FIXED_HARDWARE) 136 { 137 return ("FunctionalFixedHW"); 138 } 139 else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) 140 { 141 return ("InvalidSpaceId"); 142 } 143 144 return (ACPI_CAST_PTR (char, AcpiGbl_RegionTypes[SpaceId])); 145 } 146 147 148 /******************************************************************************* 149 * 150 * FUNCTION: AcpiUtGetEventName 151 * 152 * PARAMETERS: EventId - Fixed event ID 153 * 154 * RETURN: Decoded event ID name 155 * 156 * DESCRIPTION: Translate a Event ID into a name string (Debug only) 157 * 158 ******************************************************************************/ 159 160 /* Event type decoding */ 161 162 static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] = 163 { 164 "PM_Timer", 165 "GlobalLock", 166 "PowerButton", 167 "SleepButton", 168 "RealTimeClock", 169 }; 170 171 172 char * 173 AcpiUtGetEventName ( 174 UINT32 EventId) 175 { 176 177 if (EventId > ACPI_EVENT_MAX) 178 { 179 return ("InvalidEventID"); 180 } 181 182 return (ACPI_CAST_PTR (char, AcpiGbl_EventTypes[EventId])); 183 } 184 185 186 /******************************************************************************* 187 * 188 * FUNCTION: AcpiUtGetTypeName 189 * 190 * PARAMETERS: Type - An ACPI object type 191 * 192 * RETURN: Decoded ACPI object type name 193 * 194 * DESCRIPTION: Translate a Type ID into a name string (Debug only) 195 * 196 ******************************************************************************/ 197 198 /* 199 * Elements of AcpiGbl_NsTypeNames below must match 200 * one-to-one with values of ACPI_OBJECT_TYPE 201 * 202 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching; 203 * when stored in a table it really means that we have thus far seen no 204 * evidence to indicate what type is actually going to be stored for this entry. 205 */ 206 static const char AcpiGbl_BadType[] = "UNDEFINED"; 207 208 /* Printable names of the ACPI object types */ 209 210 static const char *AcpiGbl_NsTypeNames[] = 211 { 212 /* 00 */ "Untyped", 213 /* 01 */ "Integer", 214 /* 02 */ "String", 215 /* 03 */ "Buffer", 216 /* 04 */ "Package", 217 /* 05 */ "FieldUnit", 218 /* 06 */ "Device", 219 /* 07 */ "Event", 220 /* 08 */ "Method", 221 /* 09 */ "Mutex", 222 /* 10 */ "Region", 223 /* 11 */ "Power", 224 /* 12 */ "Processor", 225 /* 13 */ "Thermal", 226 /* 14 */ "BufferField", 227 /* 15 */ "DdbHandle", 228 /* 16 */ "DebugObject", 229 /* 17 */ "RegionField", 230 /* 18 */ "BankField", 231 /* 19 */ "IndexField", 232 /* 20 */ "Reference", 233 /* 21 */ "Alias", 234 /* 22 */ "MethodAlias", 235 /* 23 */ "Notify", 236 /* 24 */ "AddrHandler", 237 /* 25 */ "ResourceDesc", 238 /* 26 */ "ResourceFld", 239 /* 27 */ "Scope", 240 /* 28 */ "Extra", 241 /* 29 */ "Data", 242 /* 30 */ "Invalid" 243 }; 244 245 246 char * 247 AcpiUtGetTypeName ( 248 ACPI_OBJECT_TYPE Type) 249 { 250 251 if (Type > ACPI_TYPE_INVALID) 252 { 253 return (ACPI_CAST_PTR (char, AcpiGbl_BadType)); 254 } 255 256 return (ACPI_CAST_PTR (char, AcpiGbl_NsTypeNames[Type])); 257 } 258 259 260 char * 261 AcpiUtGetObjectTypeName ( 262 ACPI_OPERAND_OBJECT *ObjDesc) 263 { 264 ACPI_FUNCTION_TRACE (UtGetObjectTypeName); 265 266 267 if (!ObjDesc) 268 { 269 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Null Object Descriptor\n")); 270 return_PTR ("[NULL Object Descriptor]"); 271 } 272 273 /* These descriptor types share a common area */ 274 275 if ((ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) && 276 (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_NAMED)) 277 { 278 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 279 "Invalid object descriptor type: 0x%2.2X [%s] (%p)\n", 280 ACPI_GET_DESCRIPTOR_TYPE (ObjDesc), 281 AcpiUtGetDescriptorName (ObjDesc), ObjDesc)); 282 283 return_PTR ("Invalid object"); 284 } 285 286 return_PTR (AcpiUtGetTypeName (ObjDesc->Common.Type)); 287 } 288 289 290 /******************************************************************************* 291 * 292 * FUNCTION: AcpiUtGetNodeName 293 * 294 * PARAMETERS: Object - A namespace node 295 * 296 * RETURN: ASCII name of the node 297 * 298 * DESCRIPTION: Validate the node and return the node's ACPI name. 299 * 300 ******************************************************************************/ 301 302 char * 303 AcpiUtGetNodeName ( 304 void *Object) 305 { 306 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) Object; 307 308 309 /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */ 310 311 if (!Object) 312 { 313 return ("NULL"); 314 } 315 316 /* Check for Root node */ 317 318 if ((Object == ACPI_ROOT_OBJECT) || 319 (Object == AcpiGbl_RootNode)) 320 { 321 return ("\"\\\" "); 322 } 323 324 /* Descriptor must be a namespace node */ 325 326 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED) 327 { 328 return ("####"); 329 } 330 331 /* 332 * Ensure name is valid. The name was validated/repaired when the node 333 * was created, but make sure it has not been corrupted. 334 */ 335 AcpiUtRepairName (Node->Name.Ascii); 336 337 /* Return the name */ 338 339 return (Node->Name.Ascii); 340 } 341 342 343 /******************************************************************************* 344 * 345 * FUNCTION: AcpiUtGetDescriptorName 346 * 347 * PARAMETERS: Object - An ACPI object 348 * 349 * RETURN: Decoded name of the descriptor type 350 * 351 * DESCRIPTION: Validate object and return the descriptor type 352 * 353 ******************************************************************************/ 354 355 /* Printable names of object descriptor types */ 356 357 static const char *AcpiGbl_DescTypeNames[] = 358 { 359 /* 00 */ "Not a Descriptor", 360 /* 01 */ "Cached", 361 /* 02 */ "State-Generic", 362 /* 03 */ "State-Update", 363 /* 04 */ "State-Package", 364 /* 05 */ "State-Control", 365 /* 06 */ "State-RootParseScope", 366 /* 07 */ "State-ParseScope", 367 /* 08 */ "State-WalkScope", 368 /* 09 */ "State-Result", 369 /* 10 */ "State-Notify", 370 /* 11 */ "State-Thread", 371 /* 12 */ "Walk", 372 /* 13 */ "Parser", 373 /* 14 */ "Operand", 374 /* 15 */ "Node" 375 }; 376 377 378 char * 379 AcpiUtGetDescriptorName ( 380 void *Object) 381 { 382 383 if (!Object) 384 { 385 return ("NULL OBJECT"); 386 } 387 388 if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX) 389 { 390 return ("Not a Descriptor"); 391 } 392 393 return (ACPI_CAST_PTR (char, 394 AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)])); 395 396 } 397 398 399 /******************************************************************************* 400 * 401 * FUNCTION: AcpiUtGetReferenceName 402 * 403 * PARAMETERS: Object - An ACPI reference object 404 * 405 * RETURN: Decoded name of the type of reference 406 * 407 * DESCRIPTION: Decode a reference object sub-type to a string. 408 * 409 ******************************************************************************/ 410 411 /* Printable names of reference object sub-types */ 412 413 static const char *AcpiGbl_RefClassNames[] = 414 { 415 /* 00 */ "Local", 416 /* 01 */ "Argument", 417 /* 02 */ "RefOf", 418 /* 03 */ "Index", 419 /* 04 */ "DdbHandle", 420 /* 05 */ "Named Object", 421 /* 06 */ "Debug" 422 }; 423 424 const char * 425 AcpiUtGetReferenceName ( 426 ACPI_OPERAND_OBJECT *Object) 427 { 428 429 if (!Object) 430 { 431 return ("NULL Object"); 432 } 433 434 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND) 435 { 436 return ("Not an Operand object"); 437 } 438 439 if (Object->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) 440 { 441 return ("Not a Reference object"); 442 } 443 444 if (Object->Reference.Class > ACPI_REFCLASS_MAX) 445 { 446 return ("Unknown Reference class"); 447 } 448 449 return (AcpiGbl_RefClassNames[Object->Reference.Class]); 450 } 451 452 453 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER) 454 /* 455 * Strings and procedures used for debug only 456 */ 457 458 /******************************************************************************* 459 * 460 * FUNCTION: AcpiUtGetMutexName 461 * 462 * PARAMETERS: MutexId - The predefined ID for this mutex. 463 * 464 * RETURN: Decoded name of the internal mutex 465 * 466 * DESCRIPTION: Translate a mutex ID into a name string (Debug only) 467 * 468 ******************************************************************************/ 469 470 /* Names for internal mutex objects, used for debug output */ 471 472 static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] = 473 { 474 "ACPI_MTX_Interpreter", 475 "ACPI_MTX_Namespace", 476 "ACPI_MTX_Tables", 477 "ACPI_MTX_Events", 478 "ACPI_MTX_Caches", 479 "ACPI_MTX_Memory", 480 }; 481 482 char * 483 AcpiUtGetMutexName ( 484 UINT32 MutexId) 485 { 486 487 if (MutexId > ACPI_MAX_MUTEX) 488 { 489 return ("Invalid Mutex ID"); 490 } 491 492 return (AcpiGbl_MutexNames[MutexId]); 493 } 494 495 496 /******************************************************************************* 497 * 498 * FUNCTION: AcpiUtGetNotifyName 499 * 500 * PARAMETERS: NotifyValue - Value from the Notify() request 501 * 502 * RETURN: Decoded name for the notify value 503 * 504 * DESCRIPTION: Translate a Notify Value to a notify namestring. 505 * 506 ******************************************************************************/ 507 508 /* Names for Notify() values, used for debug output */ 509 510 static const char *AcpiGbl_GenericNotify[ACPI_NOTIFY_MAX + 1] = 511 { 512 /* 00 */ "Bus Check", 513 /* 01 */ "Device Check", 514 /* 02 */ "Device Wake", 515 /* 03 */ "Eject Request", 516 /* 04 */ "Device Check Light", 517 /* 05 */ "Frequency Mismatch", 518 /* 06 */ "Bus Mode Mismatch", 519 /* 07 */ "Power Fault", 520 /* 08 */ "Capabilities Check", 521 /* 09 */ "Device PLD Check", 522 /* 0A */ "Reserved", 523 /* 0B */ "System Locality Update", 524 /* 0C */ "Shutdown Request", 525 /* 0D */ "System Resource Affinity Update" 526 }; 527 528 static const char *AcpiGbl_DeviceNotify[4] = 529 { 530 /* 80 */ "Status Change", 531 /* 81 */ "Information Change", 532 /* 82 */ "Device-Specific Change", 533 /* 83 */ "Device-Specific Change" 534 }; 535 536 static const char *AcpiGbl_ProcessorNotify[4] = 537 { 538 /* 80 */ "Performance Capability Change", 539 /* 81 */ "C-State Change", 540 /* 82 */ "Throttling Capability Change", 541 /* 83 */ "Device-Specific Change" 542 }; 543 544 static const char *AcpiGbl_ThermalNotify[4] = 545 { 546 /* 80 */ "Thermal Status Change", 547 /* 81 */ "Thermal Trip Point Change", 548 /* 82 */ "Thermal Device List Change", 549 /* 83 */ "Thermal Relationship Change" 550 }; 551 552 553 const char * 554 AcpiUtGetNotifyName ( 555 UINT32 NotifyValue, 556 ACPI_OBJECT_TYPE Type) 557 { 558 559 /* 00 - 0D are common to all object types */ 560 561 if (NotifyValue <= ACPI_NOTIFY_MAX) 562 { 563 return (AcpiGbl_GenericNotify[NotifyValue]); 564 } 565 566 /* 0D - 7F are reserved */ 567 568 if (NotifyValue <= ACPI_MAX_SYS_NOTIFY) 569 { 570 return ("Reserved"); 571 } 572 573 /* 80 - 83 are per-object-type */ 574 575 if (NotifyValue <= 0x83) 576 { 577 switch (Type) 578 { 579 case ACPI_TYPE_ANY: 580 case ACPI_TYPE_DEVICE: 581 return (AcpiGbl_DeviceNotify [NotifyValue - 0x80]); 582 583 case ACPI_TYPE_PROCESSOR: 584 return (AcpiGbl_ProcessorNotify [NotifyValue - 0x80]); 585 586 case ACPI_TYPE_THERMAL: 587 return (AcpiGbl_ThermalNotify [NotifyValue - 0x80]); 588 589 default: 590 return ("Target object type does not support notifies"); 591 } 592 } 593 594 /* 84 - BF are device-specific */ 595 596 if (NotifyValue <= ACPI_MAX_DEVICE_SPECIFIC_NOTIFY) 597 { 598 return ("Device-Specific"); 599 } 600 601 /* C0 and above are hardware-specific */ 602 603 return ("Hardware-Specific"); 604 } 605 #endif 606 607 608 /******************************************************************************* 609 * 610 * FUNCTION: AcpiUtValidObjectType 611 * 612 * PARAMETERS: Type - Object type to be validated 613 * 614 * RETURN: TRUE if valid object type, FALSE otherwise 615 * 616 * DESCRIPTION: Validate an object type 617 * 618 ******************************************************************************/ 619 620 BOOLEAN 621 AcpiUtValidObjectType ( 622 ACPI_OBJECT_TYPE Type) 623 { 624 625 if (Type > ACPI_TYPE_LOCAL_MAX) 626 { 627 /* Note: Assumes all TYPEs are contiguous (external/local) */ 628 629 return (FALSE); 630 } 631 632 return (TRUE); 633 } 634