1 /******************************************************************************
3 * Module Name: utdecode - Utility decoding routines (value-to-string)
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2015, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
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.
44 #include <contrib/dev/acpica/include/acpi.h>
45 #include <contrib/dev/acpica/include/accommon.h>
46 #include <contrib/dev/acpica/include/acnamesp.h>
48 #define _COMPONENT ACPI_UTILITIES
49 ACPI_MODULE_NAME ("utdecode")
53 * Properties of the ACPI Object Types, both internal and external.
54 * The table is indexed by values of ACPI_OBJECT_TYPE
56 const UINT8 AcpiGbl_NsProperties[ACPI_NUM_NS_TYPES] =
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 */
92 /*******************************************************************************
94 * FUNCTION: AcpiUtGetRegionName
96 * PARAMETERS: Space ID - ID for the region
98 * RETURN: Decoded region SpaceId name
100 * DESCRIPTION: Translate a Space ID into a name string (Debug only)
102 ******************************************************************************/
104 /* Region type decoding */
106 const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] =
108 "SystemMemory", /* 0x00 */
109 "SystemIO", /* 0x01 */
110 "PCI_Config", /* 0x02 */
111 "EmbeddedControl", /* 0x03 */
113 "SystemCMOS", /* 0x05 */
114 "PCIBARTarget", /* 0x06 */
116 "GeneralPurposeIo", /* 0x08 */
117 "GenericSerialBus", /* 0x09 */
123 AcpiUtGetRegionName (
127 if (SpaceId >= ACPI_USER_REGION_BEGIN)
129 return ("UserDefinedRegion");
131 else if (SpaceId == ACPI_ADR_SPACE_DATA_TABLE)
133 return ("DataTable");
135 else if (SpaceId == ACPI_ADR_SPACE_FIXED_HARDWARE)
137 return ("FunctionalFixedHW");
139 else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS)
141 return ("InvalidSpaceId");
144 return (ACPI_CAST_PTR (char, AcpiGbl_RegionTypes[SpaceId]));
148 /*******************************************************************************
150 * FUNCTION: AcpiUtGetEventName
152 * PARAMETERS: EventId - Fixed event ID
154 * RETURN: Decoded event ID name
156 * DESCRIPTION: Translate a Event ID into a name string (Debug only)
158 ******************************************************************************/
160 /* Event type decoding */
162 static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] =
177 if (EventId > ACPI_EVENT_MAX)
179 return ("InvalidEventID");
182 return (ACPI_CAST_PTR (char, AcpiGbl_EventTypes[EventId]));
186 /*******************************************************************************
188 * FUNCTION: AcpiUtGetTypeName
190 * PARAMETERS: Type - An ACPI object type
192 * RETURN: Decoded ACPI object type name
194 * DESCRIPTION: Translate a Type ID into a name string (Debug only)
196 ******************************************************************************/
199 * Elements of AcpiGbl_NsTypeNames below must match
200 * one-to-one with values of ACPI_OBJECT_TYPE
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.
206 static const char AcpiGbl_BadType[] = "UNDEFINED";
208 /* Printable names of the ACPI object types */
210 static const char *AcpiGbl_NsTypeNames[] =
217 /* 05 */ "FieldUnit",
224 /* 12 */ "Processor",
226 /* 14 */ "BufferField",
227 /* 15 */ "DdbHandle",
228 /* 16 */ "DebugObject",
229 /* 17 */ "RegionField",
230 /* 18 */ "BankField",
231 /* 19 */ "IndexField",
232 /* 20 */ "Reference",
234 /* 22 */ "MethodAlias",
236 /* 24 */ "AddrHandler",
237 /* 25 */ "ResourceDesc",
238 /* 26 */ "ResourceFld",
248 ACPI_OBJECT_TYPE Type)
251 if (Type > ACPI_TYPE_INVALID)
253 return (ACPI_CAST_PTR (char, AcpiGbl_BadType));
256 return (ACPI_CAST_PTR (char, AcpiGbl_NsTypeNames[Type]));
261 AcpiUtGetObjectTypeName (
262 ACPI_OPERAND_OBJECT *ObjDesc)
267 return ("[NULL Object Descriptor]");
270 return (AcpiUtGetTypeName (ObjDesc->Common.Type));
274 /*******************************************************************************
276 * FUNCTION: AcpiUtGetNodeName
278 * PARAMETERS: Object - A namespace node
280 * RETURN: ASCII name of the node
282 * DESCRIPTION: Validate the node and return the node's ACPI name.
284 ******************************************************************************/
290 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) Object;
293 /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
300 /* Check for Root node */
302 if ((Object == ACPI_ROOT_OBJECT) ||
303 (Object == AcpiGbl_RootNode))
308 /* Descriptor must be a namespace node */
310 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
316 * Ensure name is valid. The name was validated/repaired when the node
317 * was created, but make sure it has not been corrupted.
319 AcpiUtRepairName (Node->Name.Ascii);
321 /* Return the name */
323 return (Node->Name.Ascii);
327 /*******************************************************************************
329 * FUNCTION: AcpiUtGetDescriptorName
331 * PARAMETERS: Object - An ACPI object
333 * RETURN: Decoded name of the descriptor type
335 * DESCRIPTION: Validate object and return the descriptor type
337 ******************************************************************************/
339 /* Printable names of object descriptor types */
341 static const char *AcpiGbl_DescTypeNames[] =
343 /* 00 */ "Not a Descriptor",
345 /* 02 */ "State-Generic",
346 /* 03 */ "State-Update",
347 /* 04 */ "State-Package",
348 /* 05 */ "State-Control",
349 /* 06 */ "State-RootParseScope",
350 /* 07 */ "State-ParseScope",
351 /* 08 */ "State-WalkScope",
352 /* 09 */ "State-Result",
353 /* 10 */ "State-Notify",
354 /* 11 */ "State-Thread",
363 AcpiUtGetDescriptorName (
369 return ("NULL OBJECT");
372 if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX)
374 return ("Not a Descriptor");
377 return (ACPI_CAST_PTR (char,
378 AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)]));
383 /*******************************************************************************
385 * FUNCTION: AcpiUtGetReferenceName
387 * PARAMETERS: Object - An ACPI reference object
389 * RETURN: Decoded name of the type of reference
391 * DESCRIPTION: Decode a reference object sub-type to a string.
393 ******************************************************************************/
395 /* Printable names of reference object sub-types */
397 static const char *AcpiGbl_RefClassNames[] =
403 /* 04 */ "DdbHandle",
404 /* 05 */ "Named Object",
409 AcpiUtGetReferenceName (
410 ACPI_OPERAND_OBJECT *Object)
415 return ("NULL Object");
418 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
420 return ("Not an Operand object");
423 if (Object->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
425 return ("Not a Reference object");
428 if (Object->Reference.Class > ACPI_REFCLASS_MAX)
430 return ("Unknown Reference class");
433 return (AcpiGbl_RefClassNames[Object->Reference.Class]);
437 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
439 * Strings and procedures used for debug only
442 /*******************************************************************************
444 * FUNCTION: AcpiUtGetMutexName
446 * PARAMETERS: MutexId - The predefined ID for this mutex.
448 * RETURN: Decoded name of the internal mutex
450 * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
452 ******************************************************************************/
454 /* Names for internal mutex objects, used for debug output */
456 static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] =
458 "ACPI_MTX_Interpreter",
459 "ACPI_MTX_Namespace",
464 "ACPI_MTX_CommandComplete",
465 "ACPI_MTX_CommandReady"
473 if (MutexId > ACPI_MAX_MUTEX)
475 return ("Invalid Mutex ID");
478 return (AcpiGbl_MutexNames[MutexId]);
482 /*******************************************************************************
484 * FUNCTION: AcpiUtGetNotifyName
486 * PARAMETERS: NotifyValue - Value from the Notify() request
488 * RETURN: Decoded name for the notify value
490 * DESCRIPTION: Translate a Notify Value to a notify namestring.
492 ******************************************************************************/
494 /* Names for Notify() values, used for debug output */
496 static const char *AcpiGbl_GenericNotify[ACPI_NOTIFY_MAX + 1] =
498 /* 00 */ "Bus Check",
499 /* 01 */ "Device Check",
500 /* 02 */ "Device Wake",
501 /* 03 */ "Eject Request",
502 /* 04 */ "Device Check Light",
503 /* 05 */ "Frequency Mismatch",
504 /* 06 */ "Bus Mode Mismatch",
505 /* 07 */ "Power Fault",
506 /* 08 */ "Capabilities Check",
507 /* 09 */ "Device PLD Check",
509 /* 0B */ "System Locality Update",
510 /* 0C */ "Shutdown Request",
511 /* 0D */ "System Resource Affinity Update"
514 static const char *AcpiGbl_DeviceNotify[4] =
516 /* 80 */ "Status Change",
517 /* 81 */ "Information Change",
518 /* 82 */ "Device-Specific Change",
519 /* 83 */ "Device-Specific Change"
522 static const char *AcpiGbl_ProcessorNotify[4] =
524 /* 80 */ "Performance Capability Change",
525 /* 81 */ "C-State Change",
526 /* 82 */ "Throttling Capability Change",
527 /* 83 */ "Device-Specific Change"
530 static const char *AcpiGbl_ThermalNotify[4] =
532 /* 80 */ "Thermal Status Change",
533 /* 81 */ "Thermal Trip Point Change",
534 /* 82 */ "Thermal Device List Change",
535 /* 83 */ "Thermal Relationship Change"
540 AcpiUtGetNotifyName (
542 ACPI_OBJECT_TYPE Type)
545 /* 00 - 0D are common to all object types */
547 if (NotifyValue <= ACPI_NOTIFY_MAX)
549 return (AcpiGbl_GenericNotify[NotifyValue]);
552 /* 0D - 7F are reserved */
554 if (NotifyValue <= ACPI_MAX_SYS_NOTIFY)
559 /* 80 - 83 are per-object-type */
561 if (NotifyValue <= 0x83)
566 case ACPI_TYPE_DEVICE:
567 return (AcpiGbl_DeviceNotify [NotifyValue - 0x80]);
569 case ACPI_TYPE_PROCESSOR:
570 return (AcpiGbl_ProcessorNotify [NotifyValue - 0x80]);
572 case ACPI_TYPE_THERMAL:
573 return (AcpiGbl_ThermalNotify [NotifyValue - 0x80]);
576 return ("Target object type does not support notifies");
580 /* 84 - BF are device-specific */
582 if (NotifyValue <= ACPI_MAX_DEVICE_SPECIFIC_NOTIFY)
584 return ("Device-Specific");
587 /* C0 and above are hardware-specific */
589 return ("Hardware-Specific");
594 /*******************************************************************************
596 * FUNCTION: AcpiUtValidObjectType
598 * PARAMETERS: Type - Object type to be validated
600 * RETURN: TRUE if valid object type, FALSE otherwise
602 * DESCRIPTION: Validate an object type
604 ******************************************************************************/
607 AcpiUtValidObjectType (
608 ACPI_OBJECT_TYPE Type)
611 if (Type > ACPI_TYPE_LOCAL_MAX)
613 /* Note: Assumes all TYPEs are contiguous (external/local) */