1 /******************************************************************************
3 * Module Name: utdecode - Utility decoding routines (value-to-string)
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2013, 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 #define __UTDECODE_C__
50 #define _COMPONENT ACPI_UTILITIES
51 ACPI_MODULE_NAME ("utdecode")
55 * Properties of the ACPI Object Types, both internal and external.
56 * The table is indexed by values of ACPI_OBJECT_TYPE
58 const UINT8 AcpiGbl_NsProperties
[ACPI_NUM_NS_TYPES
] =
60 ACPI_NS_NORMAL
, /* 00 Any */
61 ACPI_NS_NORMAL
, /* 01 Number */
62 ACPI_NS_NORMAL
, /* 02 String */
63 ACPI_NS_NORMAL
, /* 03 Buffer */
64 ACPI_NS_NORMAL
, /* 04 Package */
65 ACPI_NS_NORMAL
, /* 05 FieldUnit */
66 ACPI_NS_NEWSCOPE
, /* 06 Device */
67 ACPI_NS_NORMAL
, /* 07 Event */
68 ACPI_NS_NEWSCOPE
, /* 08 Method */
69 ACPI_NS_NORMAL
, /* 09 Mutex */
70 ACPI_NS_NORMAL
, /* 10 Region */
71 ACPI_NS_NEWSCOPE
, /* 11 Power */
72 ACPI_NS_NEWSCOPE
, /* 12 Processor */
73 ACPI_NS_NEWSCOPE
, /* 13 Thermal */
74 ACPI_NS_NORMAL
, /* 14 BufferField */
75 ACPI_NS_NORMAL
, /* 15 DdbHandle */
76 ACPI_NS_NORMAL
, /* 16 Debug Object */
77 ACPI_NS_NORMAL
, /* 17 DefField */
78 ACPI_NS_NORMAL
, /* 18 BankField */
79 ACPI_NS_NORMAL
, /* 19 IndexField */
80 ACPI_NS_NORMAL
, /* 20 Reference */
81 ACPI_NS_NORMAL
, /* 21 Alias */
82 ACPI_NS_NORMAL
, /* 22 MethodAlias */
83 ACPI_NS_NORMAL
, /* 23 Notify */
84 ACPI_NS_NORMAL
, /* 24 Address Handler */
85 ACPI_NS_NEWSCOPE
| ACPI_NS_LOCAL
, /* 25 Resource Desc */
86 ACPI_NS_NEWSCOPE
| ACPI_NS_LOCAL
, /* 26 Resource Field */
87 ACPI_NS_NEWSCOPE
, /* 27 Scope */
88 ACPI_NS_NORMAL
, /* 28 Extra */
89 ACPI_NS_NORMAL
, /* 29 Data */
90 ACPI_NS_NORMAL
/* 30 Invalid */
94 /*******************************************************************************
96 * FUNCTION: AcpiUtHexToAsciiChar
98 * PARAMETERS: Integer - Contains the hex digit
99 * Position - bit position of the digit within the
100 * integer (multiple of 4)
102 * RETURN: The converted Ascii character
104 * DESCRIPTION: Convert a hex digit to an Ascii character
106 ******************************************************************************/
108 /* Hex to ASCII conversion table */
110 static const char AcpiGbl_HexToAscii
[] =
112 '0','1','2','3','4','5','6','7',
113 '8','9','A','B','C','D','E','F'
117 AcpiUtHexToAsciiChar (
122 return (AcpiGbl_HexToAscii
[(Integer
>> Position
) & 0xF]);
126 /*******************************************************************************
128 * FUNCTION: AcpiUtGetRegionName
130 * PARAMETERS: Space ID - ID for the region
132 * RETURN: Decoded region SpaceId name
134 * DESCRIPTION: Translate a Space ID into a name string (Debug only)
136 ******************************************************************************/
138 /* Region type decoding */
140 const char *AcpiGbl_RegionTypes
[ACPI_NUM_PREDEFINED_REGIONS
] =
142 "SystemMemory", /* 0x00 */
143 "SystemIO", /* 0x01 */
144 "PCI_Config", /* 0x02 */
145 "EmbeddedControl", /* 0x03 */
147 "SystemCMOS", /* 0x05 */
148 "PCIBARTarget", /* 0x06 */
150 "GeneralPurposeIo", /* 0x08 */
151 "GenericSerialBus", /* 0x09 */
157 AcpiUtGetRegionName (
161 if (SpaceId
>= ACPI_USER_REGION_BEGIN
)
163 return ("UserDefinedRegion");
165 else if (SpaceId
== ACPI_ADR_SPACE_DATA_TABLE
)
167 return ("DataTable");
169 else if (SpaceId
== ACPI_ADR_SPACE_FIXED_HARDWARE
)
171 return ("FunctionalFixedHW");
173 else if (SpaceId
>= ACPI_NUM_PREDEFINED_REGIONS
)
175 return ("InvalidSpaceId");
178 return (ACPI_CAST_PTR (char, AcpiGbl_RegionTypes
[SpaceId
]));
182 /*******************************************************************************
184 * FUNCTION: AcpiUtGetEventName
186 * PARAMETERS: EventId - Fixed event ID
188 * RETURN: Decoded event ID name
190 * DESCRIPTION: Translate a Event ID into a name string (Debug only)
192 ******************************************************************************/
194 /* Event type decoding */
196 static const char *AcpiGbl_EventTypes
[ACPI_NUM_FIXED_EVENTS
] =
211 if (EventId
> ACPI_EVENT_MAX
)
213 return ("InvalidEventID");
216 return (ACPI_CAST_PTR (char, AcpiGbl_EventTypes
[EventId
]));
220 /*******************************************************************************
222 * FUNCTION: AcpiUtGetTypeName
224 * PARAMETERS: Type - An ACPI object type
226 * RETURN: Decoded ACPI object type name
228 * DESCRIPTION: Translate a Type ID into a name string (Debug only)
230 ******************************************************************************/
233 * Elements of AcpiGbl_NsTypeNames below must match
234 * one-to-one with values of ACPI_OBJECT_TYPE
236 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
237 * when stored in a table it really means that we have thus far seen no
238 * evidence to indicate what type is actually going to be stored for this entry.
240 static const char AcpiGbl_BadType
[] = "UNDEFINED";
242 /* Printable names of the ACPI object types */
244 static const char *AcpiGbl_NsTypeNames
[] =
251 /* 05 */ "FieldUnit",
258 /* 12 */ "Processor",
260 /* 14 */ "BufferField",
261 /* 15 */ "DdbHandle",
262 /* 16 */ "DebugObject",
263 /* 17 */ "RegionField",
264 /* 18 */ "BankField",
265 /* 19 */ "IndexField",
266 /* 20 */ "Reference",
268 /* 22 */ "MethodAlias",
270 /* 24 */ "AddrHandler",
271 /* 25 */ "ResourceDesc",
272 /* 26 */ "ResourceFld",
282 ACPI_OBJECT_TYPE Type
)
285 if (Type
> ACPI_TYPE_INVALID
)
287 return (ACPI_CAST_PTR (char, AcpiGbl_BadType
));
290 return (ACPI_CAST_PTR (char, AcpiGbl_NsTypeNames
[Type
]));
295 AcpiUtGetObjectTypeName (
296 ACPI_OPERAND_OBJECT
*ObjDesc
)
301 return ("[NULL Object Descriptor]");
304 return (AcpiUtGetTypeName (ObjDesc
->Common
.Type
));
308 /*******************************************************************************
310 * FUNCTION: AcpiUtGetNodeName
312 * PARAMETERS: Object - A namespace node
314 * RETURN: ASCII name of the node
316 * DESCRIPTION: Validate the node and return the node's ACPI name.
318 ******************************************************************************/
324 ACPI_NAMESPACE_NODE
*Node
= (ACPI_NAMESPACE_NODE
*) Object
;
327 /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
334 /* Check for Root node */
336 if ((Object
== ACPI_ROOT_OBJECT
) ||
337 (Object
== AcpiGbl_RootNode
))
342 /* Descriptor must be a namespace node */
344 if (ACPI_GET_DESCRIPTOR_TYPE (Node
) != ACPI_DESC_TYPE_NAMED
)
350 * Ensure name is valid. The name was validated/repaired when the node
351 * was created, but make sure it has not been corrupted.
353 AcpiUtRepairName (Node
->Name
.Ascii
);
355 /* Return the name */
357 return (Node
->Name
.Ascii
);
361 /*******************************************************************************
363 * FUNCTION: AcpiUtGetDescriptorName
365 * PARAMETERS: Object - An ACPI object
367 * RETURN: Decoded name of the descriptor type
369 * DESCRIPTION: Validate object and return the descriptor type
371 ******************************************************************************/
373 /* Printable names of object descriptor types */
375 static const char *AcpiGbl_DescTypeNames
[] =
377 /* 00 */ "Not a Descriptor",
379 /* 02 */ "State-Generic",
380 /* 03 */ "State-Update",
381 /* 04 */ "State-Package",
382 /* 05 */ "State-Control",
383 /* 06 */ "State-RootParseScope",
384 /* 07 */ "State-ParseScope",
385 /* 08 */ "State-WalkScope",
386 /* 09 */ "State-Result",
387 /* 10 */ "State-Notify",
388 /* 11 */ "State-Thread",
397 AcpiUtGetDescriptorName (
403 return ("NULL OBJECT");
406 if (ACPI_GET_DESCRIPTOR_TYPE (Object
) > ACPI_DESC_TYPE_MAX
)
408 return ("Not a Descriptor");
411 return (ACPI_CAST_PTR (char,
412 AcpiGbl_DescTypeNames
[ACPI_GET_DESCRIPTOR_TYPE (Object
)]));
417 /*******************************************************************************
419 * FUNCTION: AcpiUtGetReferenceName
421 * PARAMETERS: Object - An ACPI reference object
423 * RETURN: Decoded name of the type of reference
425 * DESCRIPTION: Decode a reference object sub-type to a string.
427 ******************************************************************************/
429 /* Printable names of reference object sub-types */
431 static const char *AcpiGbl_RefClassNames
[] =
437 /* 04 */ "DdbHandle",
438 /* 05 */ "Named Object",
443 AcpiUtGetReferenceName (
444 ACPI_OPERAND_OBJECT
*Object
)
449 return ("NULL Object");
452 if (ACPI_GET_DESCRIPTOR_TYPE (Object
) != ACPI_DESC_TYPE_OPERAND
)
454 return ("Not an Operand object");
457 if (Object
->Common
.Type
!= ACPI_TYPE_LOCAL_REFERENCE
)
459 return ("Not a Reference object");
462 if (Object
->Reference
.Class
> ACPI_REFCLASS_MAX
)
464 return ("Unknown Reference class");
467 return (AcpiGbl_RefClassNames
[Object
->Reference
.Class
]);
471 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
473 * Strings and procedures used for debug only
476 /*******************************************************************************
478 * FUNCTION: AcpiUtGetMutexName
480 * PARAMETERS: MutexId - The predefined ID for this mutex.
482 * RETURN: Decoded name of the internal mutex
484 * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
486 ******************************************************************************/
488 /* Names for internal mutex objects, used for debug output */
490 static char *AcpiGbl_MutexNames
[ACPI_NUM_MUTEX
] =
492 "ACPI_MTX_Interpreter",
493 "ACPI_MTX_Namespace",
498 "ACPI_MTX_CommandComplete",
499 "ACPI_MTX_CommandReady"
507 if (MutexId
> ACPI_MAX_MUTEX
)
509 return ("Invalid Mutex ID");
512 return (AcpiGbl_MutexNames
[MutexId
]);
516 /*******************************************************************************
518 * FUNCTION: AcpiUtGetNotifyName
520 * PARAMETERS: NotifyValue - Value from the Notify() request
522 * RETURN: Decoded name for the notify value
524 * DESCRIPTION: Translate a Notify Value to a notify namestring.
526 ******************************************************************************/
528 /* Names for Notify() values, used for debug output */
530 static const char *AcpiGbl_NotifyValueNames
[ACPI_NOTIFY_MAX
+ 1] =
532 /* 00 */ "Bus Check",
533 /* 01 */ "Device Check",
534 /* 02 */ "Device Wake",
535 /* 03 */ "Eject Request",
536 /* 04 */ "Device Check Light",
537 /* 05 */ "Frequency Mismatch",
538 /* 06 */ "Bus Mode Mismatch",
539 /* 07 */ "Power Fault",
540 /* 08 */ "Capabilities Check",
541 /* 09 */ "Device PLD Check",
543 /* 11 */ "System Locality Update",
544 /* 12 */ "Shutdown Request"
548 AcpiUtGetNotifyName (
552 if (NotifyValue
<= ACPI_NOTIFY_MAX
)
554 return (AcpiGbl_NotifyValueNames
[NotifyValue
]);
556 else if (NotifyValue
<= ACPI_MAX_SYS_NOTIFY
)
560 else if (NotifyValue
<= ACPI_MAX_DEVICE_SPECIFIC_NOTIFY
)
562 return ("Device Specific");
566 return ("Hardware Specific");
572 /*******************************************************************************
574 * FUNCTION: AcpiUtValidObjectType
576 * PARAMETERS: Type - Object type to be validated
578 * RETURN: TRUE if valid object type, FALSE otherwise
580 * DESCRIPTION: Validate an object type
582 ******************************************************************************/
585 AcpiUtValidObjectType (
586 ACPI_OBJECT_TYPE Type
)
589 if (Type
> ACPI_TYPE_LOCAL_MAX
)
591 /* Note: Assumes all TYPEs are contiguous (external/local) */