1 /******************************************************************************
3 * Module Name: utdecode - Utility decoding routines (value-to-string)
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2011, 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__
46 #include <contrib/dev/acpica/include/acpi.h>
47 #include <contrib/dev/acpica/include/accommon.h>
48 #include <contrib/dev/acpica/include/acnamesp.h>
50 #define _COMPONENT ACPI_UTILITIES
51 ACPI_MODULE_NAME ("utdecode")
54 /*******************************************************************************
56 * FUNCTION: AcpiFormatException
58 * PARAMETERS: Status - The ACPI_STATUS code to be formatted
60 * RETURN: A string containing the exception text. A valid pointer is
63 * DESCRIPTION: This function translates an ACPI exception into an ASCII string
64 * It is here instead of utxface.c so it is always present.
66 ******************************************************************************/
72 const char *Exception = NULL;
75 ACPI_FUNCTION_ENTRY ();
78 Exception = AcpiUtValidateException (Status);
81 /* Exception code was not recognized */
84 "Unknown exception code: 0x%8.8X", Status));
86 Exception = "UNKNOWN_STATUS_CODE";
89 return (ACPI_CAST_PTR (const char, Exception));
92 ACPI_EXPORT_SYMBOL (AcpiFormatException)
96 * Properties of the ACPI Object Types, both internal and external.
97 * The table is indexed by values of ACPI_OBJECT_TYPE
99 const UINT8 AcpiGbl_NsProperties[ACPI_NUM_NS_TYPES] =
101 ACPI_NS_NORMAL, /* 00 Any */
102 ACPI_NS_NORMAL, /* 01 Number */
103 ACPI_NS_NORMAL, /* 02 String */
104 ACPI_NS_NORMAL, /* 03 Buffer */
105 ACPI_NS_NORMAL, /* 04 Package */
106 ACPI_NS_NORMAL, /* 05 FieldUnit */
107 ACPI_NS_NEWSCOPE, /* 06 Device */
108 ACPI_NS_NORMAL, /* 07 Event */
109 ACPI_NS_NEWSCOPE, /* 08 Method */
110 ACPI_NS_NORMAL, /* 09 Mutex */
111 ACPI_NS_NORMAL, /* 10 Region */
112 ACPI_NS_NEWSCOPE, /* 11 Power */
113 ACPI_NS_NEWSCOPE, /* 12 Processor */
114 ACPI_NS_NEWSCOPE, /* 13 Thermal */
115 ACPI_NS_NORMAL, /* 14 BufferField */
116 ACPI_NS_NORMAL, /* 15 DdbHandle */
117 ACPI_NS_NORMAL, /* 16 Debug Object */
118 ACPI_NS_NORMAL, /* 17 DefField */
119 ACPI_NS_NORMAL, /* 18 BankField */
120 ACPI_NS_NORMAL, /* 19 IndexField */
121 ACPI_NS_NORMAL, /* 20 Reference */
122 ACPI_NS_NORMAL, /* 21 Alias */
123 ACPI_NS_NORMAL, /* 22 MethodAlias */
124 ACPI_NS_NORMAL, /* 23 Notify */
125 ACPI_NS_NORMAL, /* 24 Address Handler */
126 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 25 Resource Desc */
127 ACPI_NS_NEWSCOPE | ACPI_NS_LOCAL, /* 26 Resource Field */
128 ACPI_NS_NEWSCOPE, /* 27 Scope */
129 ACPI_NS_NORMAL, /* 28 Extra */
130 ACPI_NS_NORMAL, /* 29 Data */
131 ACPI_NS_NORMAL /* 30 Invalid */
135 /*******************************************************************************
137 * FUNCTION: AcpiUtHexToAsciiChar
139 * PARAMETERS: Integer - Contains the hex digit
140 * Position - bit position of the digit within the
141 * integer (multiple of 4)
143 * RETURN: The converted Ascii character
145 * DESCRIPTION: Convert a hex digit to an Ascii character
147 ******************************************************************************/
149 /* Hex to ASCII conversion table */
151 static const char AcpiGbl_HexToAscii[] =
153 '0','1','2','3','4','5','6','7',
154 '8','9','A','B','C','D','E','F'
158 AcpiUtHexToAsciiChar (
163 return (AcpiGbl_HexToAscii[(Integer >> Position) & 0xF]);
167 /*******************************************************************************
169 * FUNCTION: AcpiUtGetRegionName
171 * PARAMETERS: Space ID - ID for the region
173 * RETURN: Decoded region SpaceId name
175 * DESCRIPTION: Translate a Space ID into a name string (Debug only)
177 ******************************************************************************/
179 /* Region type decoding */
181 const char *AcpiGbl_RegionTypes[ACPI_NUM_PREDEFINED_REGIONS] =
195 AcpiUtGetRegionName (
199 if (SpaceId >= ACPI_USER_REGION_BEGIN)
201 return ("UserDefinedRegion");
203 else if (SpaceId == ACPI_ADR_SPACE_DATA_TABLE)
205 return ("DataTable");
207 else if (SpaceId == ACPI_ADR_SPACE_FIXED_HARDWARE)
209 return ("FunctionalFixedHW");
211 else if (SpaceId >= ACPI_NUM_PREDEFINED_REGIONS)
213 return ("InvalidSpaceId");
216 return (ACPI_CAST_PTR (char, AcpiGbl_RegionTypes[SpaceId]));
220 /*******************************************************************************
222 * FUNCTION: AcpiUtGetEventName
224 * PARAMETERS: EventId - Fixed event ID
226 * RETURN: Decoded event ID name
228 * DESCRIPTION: Translate a Event ID into a name string (Debug only)
230 ******************************************************************************/
232 /* Event type decoding */
234 static const char *AcpiGbl_EventTypes[ACPI_NUM_FIXED_EVENTS] =
249 if (EventId > ACPI_EVENT_MAX)
251 return ("InvalidEventID");
254 return (ACPI_CAST_PTR (char, AcpiGbl_EventTypes[EventId]));
258 /*******************************************************************************
260 * FUNCTION: AcpiUtGetTypeName
262 * PARAMETERS: Type - An ACPI object type
264 * RETURN: Decoded ACPI object type name
266 * DESCRIPTION: Translate a Type ID into a name string (Debug only)
268 ******************************************************************************/
271 * Elements of AcpiGbl_NsTypeNames below must match
272 * one-to-one with values of ACPI_OBJECT_TYPE
274 * The type ACPI_TYPE_ANY (Untyped) is used as a "don't care" when searching;
275 * when stored in a table it really means that we have thus far seen no
276 * evidence to indicate what type is actually going to be stored for this entry.
278 static const char AcpiGbl_BadType[] = "UNDEFINED";
280 /* Printable names of the ACPI object types */
282 static const char *AcpiGbl_NsTypeNames[] =
289 /* 05 */ "FieldUnit",
296 /* 12 */ "Processor",
298 /* 14 */ "BufferField",
299 /* 15 */ "DdbHandle",
300 /* 16 */ "DebugObject",
301 /* 17 */ "RegionField",
302 /* 18 */ "BankField",
303 /* 19 */ "IndexField",
304 /* 20 */ "Reference",
306 /* 22 */ "MethodAlias",
308 /* 24 */ "AddrHandler",
309 /* 25 */ "ResourceDesc",
310 /* 26 */ "ResourceFld",
320 ACPI_OBJECT_TYPE Type)
323 if (Type > ACPI_TYPE_INVALID)
325 return (ACPI_CAST_PTR (char, AcpiGbl_BadType));
328 return (ACPI_CAST_PTR (char, AcpiGbl_NsTypeNames[Type]));
333 AcpiUtGetObjectTypeName (
334 ACPI_OPERAND_OBJECT *ObjDesc)
339 return ("[NULL Object Descriptor]");
342 return (AcpiUtGetTypeName (ObjDesc->Common.Type));
346 /*******************************************************************************
348 * FUNCTION: AcpiUtGetNodeName
350 * PARAMETERS: Object - A namespace node
352 * RETURN: ASCII name of the node
354 * DESCRIPTION: Validate the node and return the node's ACPI name.
356 ******************************************************************************/
362 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) Object;
365 /* Must return a string of exactly 4 characters == ACPI_NAME_SIZE */
372 /* Check for Root node */
374 if ((Object == ACPI_ROOT_OBJECT) ||
375 (Object == AcpiGbl_RootNode))
380 /* Descriptor must be a namespace node */
382 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
388 * Ensure name is valid. The name was validated/repaired when the node
389 * was created, but make sure it has not been corrupted.
391 AcpiUtRepairName (Node->Name.Ascii);
393 /* Return the name */
395 return (Node->Name.Ascii);
399 /*******************************************************************************
401 * FUNCTION: AcpiUtGetDescriptorName
403 * PARAMETERS: Object - An ACPI object
405 * RETURN: Decoded name of the descriptor type
407 * DESCRIPTION: Validate object and return the descriptor type
409 ******************************************************************************/
411 /* Printable names of object descriptor types */
413 static const char *AcpiGbl_DescTypeNames[] =
415 /* 00 */ "Not a Descriptor",
417 /* 02 */ "State-Generic",
418 /* 03 */ "State-Update",
419 /* 04 */ "State-Package",
420 /* 05 */ "State-Control",
421 /* 06 */ "State-RootParseScope",
422 /* 07 */ "State-ParseScope",
423 /* 08 */ "State-WalkScope",
424 /* 09 */ "State-Result",
425 /* 10 */ "State-Notify",
426 /* 11 */ "State-Thread",
435 AcpiUtGetDescriptorName (
441 return ("NULL OBJECT");
444 if (ACPI_GET_DESCRIPTOR_TYPE (Object) > ACPI_DESC_TYPE_MAX)
446 return ("Not a Descriptor");
449 return (ACPI_CAST_PTR (char,
450 AcpiGbl_DescTypeNames[ACPI_GET_DESCRIPTOR_TYPE (Object)]));
455 /*******************************************************************************
457 * FUNCTION: AcpiUtGetReferenceName
459 * PARAMETERS: Object - An ACPI reference object
461 * RETURN: Decoded name of the type of reference
463 * DESCRIPTION: Decode a reference object sub-type to a string.
465 ******************************************************************************/
467 /* Printable names of reference object sub-types */
469 static const char *AcpiGbl_RefClassNames[] =
475 /* 04 */ "DdbHandle",
476 /* 05 */ "Named Object",
481 AcpiUtGetReferenceName (
482 ACPI_OPERAND_OBJECT *Object)
487 return ("NULL Object");
490 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
492 return ("Not an Operand object");
495 if (Object->Common.Type != ACPI_TYPE_LOCAL_REFERENCE)
497 return ("Not a Reference object");
500 if (Object->Reference.Class > ACPI_REFCLASS_MAX)
502 return ("Unknown Reference class");
505 return (AcpiGbl_RefClassNames[Object->Reference.Class]);
509 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
511 * Strings and procedures used for debug only
514 /*******************************************************************************
516 * FUNCTION: AcpiUtGetMutexName
518 * PARAMETERS: MutexId - The predefined ID for this mutex.
520 * RETURN: Decoded name of the internal mutex
522 * DESCRIPTION: Translate a mutex ID into a name string (Debug only)
524 ******************************************************************************/
526 /* Names for internal mutex objects, used for debug output */
528 static char *AcpiGbl_MutexNames[ACPI_NUM_MUTEX] =
530 "ACPI_MTX_Interpreter",
531 "ACPI_MTX_Namespace",
536 "ACPI_MTX_CommandComplete",
537 "ACPI_MTX_CommandReady"
545 if (MutexId > ACPI_MAX_MUTEX)
547 return ("Invalid Mutex ID");
550 return (AcpiGbl_MutexNames[MutexId]);
554 /*******************************************************************************
556 * FUNCTION: AcpiUtGetNotifyName
558 * PARAMETERS: NotifyValue - Value from the Notify() request
560 * RETURN: Decoded name for the notify value
562 * DESCRIPTION: Translate a Notify Value to a notify namestring.
564 ******************************************************************************/
566 /* Names for Notify() values, used for debug output */
568 static const char *AcpiGbl_NotifyValueNames[] =
574 "Device Check Light",
575 "Frequency Mismatch",
578 "Capabilities Check",
581 "System Locality Update"
585 AcpiUtGetNotifyName (
589 if (NotifyValue <= ACPI_NOTIFY_MAX)
591 return (AcpiGbl_NotifyValueNames[NotifyValue]);
593 else if (NotifyValue <= ACPI_MAX_SYS_NOTIFY)
597 else /* Greater or equal to 0x80 */
599 return ("**Device Specific**");
605 /*******************************************************************************
607 * FUNCTION: AcpiUtValidObjectType
609 * PARAMETERS: Type - Object type to be validated
611 * RETURN: TRUE if valid object type, FALSE otherwise
613 * DESCRIPTION: Validate an object type
615 ******************************************************************************/
618 AcpiUtValidObjectType (
619 ACPI_OBJECT_TYPE Type)
622 if (Type > ACPI_TYPE_LOCAL_MAX)
624 /* Note: Assumes all TYPEs are contiguous (external/local) */